blob: 6b0adb413aeb872cb0168ee86122ad3c811fafe4 [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
512
kelvin-onlab54400a92015-02-26 18:05:51 -0800513 #time.sleep(300)
Hari Krishnab35c6d02015-03-18 11:13:51 -0700514 #main.cleanup()
515 #main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800516
kelvin-onlab8a832582015-01-16 17:06:11 -0800517 # just returning TRUE for now as this one just collects data
Hari Krishnab35c6d02015-03-18 11:13:51 -0700518 case3Result = topoResult
Hari Krishna22c3d412015-02-17 16:48:12 -0800519 utilities.assert_equals( expect=main.TRUE, actual=case3Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800520 onpass="Saving ONOS topology data test PASS",
521 onfail="Saving ONOS topology data test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800522
kelvin-onlab65a72d22015-03-26 13:46:32 -0700523 def CASE40( self, main ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800524 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700525 Verify Reactive forwarding (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -0800526 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800527 import re
528 import copy
529 import time
Hari Krishnab35c6d02015-03-18 11:13:51 -0700530 main.log.report( "Verify Reactive forwarding (Att Topology)" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800531 main.log.report( "______________________________________________" )
532 main.case( "Enable Reactive forwarding and Verify ping all" )
533 main.step( "Enable Reactive forwarding" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800534 installResult = main.TRUE
kelvin-onlab06ade552015-03-31 18:09:27 -0700535 # Activate fwd app
536 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700537 appCheck = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800538 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800539 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700540 t = main.Thread( target=cli.appToIDCheck,
541 name="appToIDCheck-" + str( i ),
542 args=[] )
543 pool.append( t )
kelvin-onlab54400a92015-02-26 18:05:51 -0800544 t.start()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800545 for t in pool:
546 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700547 appCheck = appCheck and t.result
548 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
549 onpass="App Ids seem to be correct",
550 onfail="Something is wrong with app Ids" )
551 if appCheck != main.TRUE:
552 main.log.warn( main.CLIs[0].apps() )
553 main.log.warn( main.CLIs[0].appIDs() )
554
555 time.sleep( 10 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800556
kelvin-onlab8a832582015-01-16 17:06:11 -0800557 main.step( "Verify Pingall" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800558 ping_result = main.FALSE
559 time1 = time.time()
kelvin-onlab4df89f22015-04-13 18:10:23 -0700560 ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800561 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800562 timeDiff = round( ( time2 - time1 ), 2 )
563 main.log.report(
564 "Time taken for Ping All: " +
565 str( timeDiff ) +
566 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800567
568 if ping_result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800569 main.log.report( "Pingall Test in Reactive mode successful" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800570 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800571 main.log.report( "Pingall Test in Reactive mode failed" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800572
kelvin-onlab8a832582015-01-16 17:06:11 -0800573 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700574
575 main.log.info( "Uninstall reactive forwarding app" )
576 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800577 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800578 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700579 t = main.Thread( target=cli.appToIDCheck,
580 name="appToIDCheck-" + str( i ),
581 args=[] )
582 pool.append( t )
kelvin-onlab54400a92015-02-26 18:05:51 -0800583 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700584
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800585 for t in pool:
586 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700587 appCheck = appCheck and t.result
588 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
589 onpass="App Ids seem to be correct",
590 onfail="Something is wrong with app Ids" )
591 if appCheck != main.TRUE:
592 main.log.warn( main.CLIs[0].apps() )
593 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800594
kelvin-onlab8a832582015-01-16 17:06:11 -0800595 # Waiting for reative flows to be cleared.
Hari Krishna0ce0e152015-06-23 09:55:29 -0700596 time.sleep( 30 )
kelvin-onlab06ade552015-03-31 18:09:27 -0700597 case40Result = installResult and uninstallResult and ping_result
598 utilities.assert_equals( expect=main.TRUE, actual=case40Result,
Hari Krishnab35c6d02015-03-18 11:13:51 -0700599 onpass="Reactive Mode Pingall test PASS",
600 onfail="Reactive Mode Pingall test FAIL" )
601
602 def CASE41( self, main ):
603 """
604 Verify Reactive forwarding (Chordal Topology)
605 """
606 import re
607 import copy
608 import time
609 main.log.report( "Verify Reactive forwarding (Chordal Topology)" )
610 main.log.report( "______________________________________________" )
611 main.case( "Enable Reactive forwarding and Verify ping all" )
612 main.step( "Enable Reactive forwarding" )
613 installResult = main.TRUE
kelvin-onlab06ade552015-03-31 18:09:27 -0700614 # Activate fwd app
615 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
616
617 appCheck = main.TRUE
Hari Krishnab35c6d02015-03-18 11:13:51 -0700618 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700619 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700620 t = main.Thread( target=cli.appToIDCheck,
621 name="appToIDCheck-" + str( i ),
622 args=[] )
623 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700624 t.start()
Hari Krishnab35c6d02015-03-18 11:13:51 -0700625 for t in pool:
626 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700627 appCheck = appCheck and t.result
628 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
629 onpass="App Ids seem to be correct",
630 onfail="Something is wrong with app Ids" )
631 if appCheck != main.TRUE:
632 main.log.warn( main.CLIs[0].apps() )
633 main.log.warn( main.CLIs[0].appIDs() )
634
635 time.sleep( 10 )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700636
637 main.step( "Verify Pingall" )
638 ping_result = main.FALSE
639 time1 = time.time()
kelvin-onlab4df89f22015-04-13 18:10:23 -0700640 ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700641 time2 = time.time()
642 timeDiff = round( ( time2 - time1 ), 2 )
643 main.log.report(
644 "Time taken for Ping All: " +
645 str( timeDiff ) +
646 " seconds" )
647
648 if ping_result == main.TRUE:
649 main.log.report( "Pingall Test in Reactive mode successful" )
650 else:
651 main.log.report( "Pingall Test in Reactive mode failed" )
652
653 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700654
655 main.log.info( "Uninstall reactive forwarding app" )
656 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700657 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700658 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700659 t = main.Thread( target=cli.appToIDCheck,
660 name="appToIDCheck-" + str( i ),
661 args=[] )
662 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700663 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700664
Hari Krishnab35c6d02015-03-18 11:13:51 -0700665 for t in pool:
666 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700667 appCheck = appCheck and t.result
668 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
669 onpass="App Ids seem to be correct",
670 onfail="Something is wrong with app Ids" )
671 if appCheck != main.TRUE:
672 main.log.warn( main.CLIs[0].apps() )
673 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700674
675 # Waiting for reative flows to be cleared.
Hari Krishna0ce0e152015-06-23 09:55:29 -0700676 time.sleep( 30 )
kelvin-onlab06ade552015-03-31 18:09:27 -0700677 case41Result = installResult and uninstallResult and ping_result
678 utilities.assert_equals( expect=main.TRUE, actual=case41Result,
Hari Krishnab35c6d02015-03-18 11:13:51 -0700679 onpass="Reactive Mode Pingall test PASS",
680 onfail="Reactive Mode Pingall test FAIL" )
681
682 def CASE42( self, main ):
683 """
684 Verify Reactive forwarding (Spine Topology)
685 """
686 import re
687 import copy
688 import time
689 main.log.report( "Verify Reactive forwarding (Spine Topology)" )
690 main.log.report( "______________________________________________" )
691 main.case( "Enable Reactive forwarding and Verify ping all" )
692 main.step( "Enable Reactive forwarding" )
693 installResult = main.TRUE
kelvin-onlab06ade552015-03-31 18:09:27 -0700694 # Activate fwd app
695 appResults = main.CLIs[0].activateApp( "org.onosproject.fwd" )
696
697 appCheck = main.TRUE
Hari Krishnab35c6d02015-03-18 11:13:51 -0700698 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700699 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700700 t = main.Thread( target=cli.appToIDCheck,
701 name="appToIDCheck-" + str( i ),
702 args=[] )
703 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700704 t.start()
Hari Krishnab35c6d02015-03-18 11:13:51 -0700705 for t in pool:
706 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700707 appCheck = appCheck and t.result
708 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
709 onpass="App Ids seem to be correct",
710 onfail="Something is wrong with app Ids" )
711 if appCheck != main.TRUE:
712 main.log.warn( main.CLIs[0].apps() )
713 main.log.warn( main.CLIs[0].appIDs() )
714
715 time.sleep( 10 )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700716
717 main.step( "Verify Pingall" )
718 ping_result = main.FALSE
719 time1 = time.time()
kelvin-onlab4df89f22015-04-13 18:10:23 -0700720 ping_result = main.Mininet1.pingall( timeout=main.pingTimeout )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700721 time2 = time.time()
722 timeDiff = round( ( time2 - time1 ), 2 )
723 main.log.report(
724 "Time taken for Ping All: " +
725 str( timeDiff ) +
726 " seconds" )
727
728 if ping_result == main.TRUE:
729 main.log.report( "Pingall Test in Reactive mode successful" )
730 else:
731 main.log.report( "Pingall Test in Reactive mode failed" )
732
733 main.step( "Disable Reactive forwarding" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700734
735 main.log.info( "Uninstall reactive forwarding app" )
736 appResults = appResults and main.CLIs[0].deactivateApp( "org.onosproject.fwd" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700737 pool = []
Hari Krishnab35c6d02015-03-18 11:13:51 -0700738 for cli in main.CLIs:
kelvin-onlab06ade552015-03-31 18:09:27 -0700739 t = main.Thread( target=cli.appToIDCheck,
740 name="appToIDCheck-" + str( i ),
741 args=[] )
742 pool.append( t )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700743 t.start()
kelvin-onlab06ade552015-03-31 18:09:27 -0700744
Hari Krishnab35c6d02015-03-18 11:13:51 -0700745 for t in pool:
746 t.join()
kelvin-onlab06ade552015-03-31 18:09:27 -0700747 appCheck = appCheck and t.result
748 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
749 onpass="App Ids seem to be correct",
750 onfail="Something is wrong with app Ids" )
751 if appCheck != main.TRUE:
752 main.log.warn( main.CLIs[0].apps() )
753 main.log.warn( main.CLIs[0].appIDs() )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700754
755 # Waiting for reative flows to be cleared.
Hari Krishna0ce0e152015-06-23 09:55:29 -0700756 time.sleep( 30 )
kelvin-onlab06ade552015-03-31 18:09:27 -0700757 case42Result = installResult and uninstallResult and ping_result
758 utilities.assert_equals( expect=main.TRUE, actual=case42Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800759 onpass="Reactive Mode Pingall test PASS",
760 onfail="Reactive Mode Pingall test FAIL" )
kelvin-onlab06ade552015-03-31 18:09:27 -0700761
kelvin-onlab8a832582015-01-16 17:06:11 -0800762 def CASE5( self, main ):
763 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800764 Compare current ONOS topology with reference data
kelvin-onlab8a832582015-01-16 17:06:11 -0800765 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800766 import re
kelvin-onlab54400a92015-02-26 18:05:51 -0800767
Hari Krishna22c3d412015-02-17 16:48:12 -0800768 devicesDPIDTemp = []
769 hostMACsTemp = []
770 deviceLinksTemp = []
771 deviceActiveLinksCountTemp = []
772 devicePortsEnabledCountTemp = []
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800773
kelvin-onlab8a832582015-01-16 17:06:11 -0800774 main.log.report(
775 "Compare ONOS topology with reference data in Stores" )
776 main.log.report( "__________________________________________________" )
777 main.case( "Compare ONOS topology with reference data" )
778
779 main.step( "Compare current Device ports enabled with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800780 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800781 for i in xrange( 1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800782 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800783 for cli in main.CLIs:
kelvin-onlabc44f0192015-04-02 22:08:41 -0700784 if i >= main.numMNswitches + 1:
785 break
kelvin-onlab54400a92015-02-26 18:05:51 -0800786 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800787 t = main.Thread(target = cli.getDevicePortsEnabledCount,
788 threadID = main.threadID,
789 name = "getDevicePortsEnabledCount",
790 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800791 t.start()
792 pool.append(t)
793 i = i + 1
794 main.threadID = main.threadID + 1
795 for thread in pool:
796 thread.join()
797 portResult = thread.result
Hari Krishna0ce0e152015-06-23 09:55:29 -0700798 #portTemp = re.split( r'\t+', portResult )
799 #portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
800 devicePortsEnabledCountTemp.append( portResult )
801
kelvin-onlab54400a92015-02-26 18:05:51 -0800802 time2 = time.time()
803 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800804 main.log.info (
805 "Device Enabled ports EXPECTED: %s" %
806 str( main.devicePortsEnabledCount ) )
807 main.log.info (
808 "Device Enabled ports ACTUAL: %s" %
809 str( devicePortsEnabledCountTemp ) )
kelvin-onlab54400a92015-02-26 18:05:51 -0800810
Hari Krishna22c3d412015-02-17 16:48:12 -0800811 if ( cmp( main.devicePortsEnabledCount,
812 devicePortsEnabledCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800813 stepResult1 = main.TRUE
814 else:
815 stepResult1 = main.FALSE
816
kelvin-onlab8a832582015-01-16 17:06:11 -0800817 main.step( "Compare Device active links with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800818 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800819 for i in xrange( 1, ( main.numMNswitches + 1) , int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800820 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800821 for cli in main.CLIs:
Hari Krishna0ce0e152015-06-23 09:55:29 -0700822 if i >= main.numMNswitches + 1:
823 break
kelvin-onlab54400a92015-02-26 18:05:51 -0800824 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800825 t = main.Thread(target = cli.getDeviceLinksActiveCount,
826 threadID = main.threadID,
Hari Krishna0ce0e152015-06-23 09:55:29 -0700827 name = "getDeviceLinksActiveCount",
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800828 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800829 t.start()
830 pool.append(t)
831 i = i + 1
832 main.threadID = main.threadID + 1
833 for thread in pool:
834 thread.join()
835 linkCountResult = thread.result
Hari Krishna0ce0e152015-06-23 09:55:29 -0700836 #linkCountTemp = re.split( r'\t+', linkCountResult )
837 #linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
838 deviceActiveLinksCountTemp.append( linkCountResult )
839
kelvin-onlab54400a92015-02-26 18:05:51 -0800840 time2 = time.time()
841 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800842 main.log.info (
843 "Device Active links EXPECTED: %s" %
844 str( main.deviceActiveLinksCount ) )
845 main.log.info (
846 "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) )
847 if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800848 stepResult2 = main.TRUE
849 else:
850 stepResult2 = main.FALSE
851
kelvin-onlab8a832582015-01-16 17:06:11 -0800852 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800853 place holder for comparing devices, hosts, paths and intents if required.
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800854 Links and ports data would be incorrect with out devices anyways.
kelvin-onlab8a832582015-01-16 17:06:11 -0800855 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800856 case5Result = ( stepResult1 and stepResult2 )
857 utilities.assert_equals( expect=main.TRUE, actual=case5Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800858 onpass="Compare Topology test PASS",
859 onfail="Compare Topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800860
kelvin-onlab65a72d22015-03-26 13:46:32 -0700861 def CASE60( self ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800862 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700863 Install 300 host intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -0800864 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700865 main.log.report( "Add 300 host intents and verify pingall (Att Topology)" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800866 main.log.report( "_______________________________________" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800867 import itertools
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700868 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800869 main.case( "Install 300 host intents" )
870 main.step( "Add host Intents" )
871 intentResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800872 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800873
kelvin-onlab54400a92015-02-26 18:05:51 -0800874 intentIdList = []
875 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800876 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800877 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800878 for cli in main.CLIs:
879 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800880 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800881 t = main.Thread( target=cli.addHostIntent,
882 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -0800883 name="addHostIntent",
884 args=[hostCombos[i][0],hostCombos[i][1]])
885 pool.append(t)
886 t.start()
887 i = i + 1
888 main.threadID = main.threadID + 1
889 for thread in pool:
890 thread.join()
891 intentIdList.append(thread.result)
892 time2 = time.time()
kelvin-onlabadfc8db2015-03-24 15:52:48 -0700893 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
894
kelvin-onlab54400a92015-02-26 18:05:51 -0800895 intentResult = main.TRUE
896 intentsJson = main.ONOScli2.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800897 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
kelvin-onlab54400a92015-02-26 18:05:51 -0800898 intentsJson = intentsJson)
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -0700899 print "len of intent ID", str(len(intentIdList))
900 print "len of intent state results", str(len(getIntentStateResult))
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800901 print getIntentStateResult
Hari Krishnab35c6d02015-03-18 11:13:51 -0700902 # Takes awhile for all the onos to get the intents
Hari Krishna0ce0e152015-06-23 09:55:29 -0700903 time.sleep( 30 )
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -0700904 """intentState = main.TRUE
905 for i in getIntentStateResult:
906 if getIntentStateResult.get( 'state' ) != 'INSTALLED':
907 """
908
909
kelvin-onlab8a832582015-01-16 17:06:11 -0800910 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800911 pingResult = main.FALSE
912 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -0700913 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800914 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800915 timeDiff = round( ( time2 - time1 ), 2 )
916 main.log.report(
917 "Time taken for Ping All: " +
918 str( timeDiff ) +
919 " seconds" )
920 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
921 onpass="PING ALL PASS",
922 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800923
kelvin-onlab65a72d22015-03-26 13:46:32 -0700924 case60Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -0800925
kelvin-onlab8a832582015-01-16 17:06:11 -0800926 utilities.assert_equals(
927 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -0700928 actual=case60Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800929 onpass="Install 300 Host Intents and Ping All test PASS",
930 onfail="Install 300 Host Intents and Ping All test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800931
kelvin-onlab65a72d22015-03-26 13:46:32 -0700932 def CASE61( self ):
933 """
934 Install 600 host intents and verify ping all for Chordal Topology
935 """
936 main.log.report( "Add 600 host intents and verify pingall (Chordal Topo)" )
937 main.log.report( "_______________________________________" )
938 import itertools
939
940 main.case( "Install 600 host intents" )
941 main.step( "Add host Intents" )
942 intentResult = main.TRUE
943 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
944
945 intentIdList = []
946 time1 = time.time()
947
948 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
949 pool = []
950 for cli in main.CLIs:
951 if i >= len( hostCombos ):
952 break
953 t = main.Thread( target=cli.addHostIntent,
954 threadID=main.threadID,
955 name="addHostIntent",
956 args=[hostCombos[i][0],hostCombos[i][1]])
957 pool.append(t)
958 t.start()
959 i = i + 1
960 main.threadID = main.threadID + 1
961 for thread in pool:
962 thread.join()
963 intentIdList.append(thread.result)
964 time2 = time.time()
965 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
966 intentResult = main.TRUE
967 intentsJson = main.ONOScli2.intents()
968 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
969 intentsJson = intentsJson)
970 print getIntentStateResult
971
972 main.step( "Verify Ping across all hosts" )
973 pingResult = main.FALSE
974 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -0700975 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab65a72d22015-03-26 13:46:32 -0700976 time2 = time.time()
977 timeDiff = round( ( time2 - time1 ), 2 )
978 main.log.report(
979 "Time taken for Ping All: " +
980 str( timeDiff ) +
981 " seconds" )
982 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
983 onpass="PING ALL PASS",
984 onfail="PING ALL FAIL" )
985
986 case14Result = ( intentResult and pingResult )
987
988 utilities.assert_equals(
989 expect=main.TRUE,
990 actual=case14Result,
991 onpass="Install 300 Host Intents and Ping All test PASS",
992 onfail="Install 300 Host Intents and Ping All test FAIL" )
993
994 def CASE62( self ):
995 """
996 Install 2278 host intents and verify ping all for Spine Topology
997 """
998 main.log.report( "Add 2278 host intents and verify pingall (Spine Topo)" )
999 main.log.report( "_______________________________________" )
1000 import itertools
1001
1002 main.case( "Install 2278 host intents" )
1003 main.step( "Add host Intents" )
1004 intentResult = main.TRUE
1005 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
1006 main.pingTimeout = 300
1007 intentIdList = []
1008 time1 = time.time()
1009 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
1010 pool = []
1011 for cli in main.CLIs:
1012 if i >= len( hostCombos ):
1013 break
1014 t = main.Thread( target=cli.addHostIntent,
1015 threadID=main.threadID,
1016 name="addHostIntent",
1017 args=[hostCombos[i][0],hostCombos[i][1]])
1018 pool.append(t)
1019 t.start()
1020 i = i + 1
1021 main.threadID = main.threadID + 1
1022 for thread in pool:
1023 thread.join()
1024 intentIdList.append(thread.result)
1025 time2 = time.time()
1026 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
1027 intentResult = main.TRUE
1028 intentsJson = main.ONOScli2.intents()
1029 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1030 intentsJson = intentsJson)
1031 print getIntentStateResult
1032
1033 main.step( "Verify Ping across all hosts" )
1034 pingResult = main.FALSE
1035 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001036 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001037 time2 = time.time()
1038 timeDiff = round( ( time2 - time1 ), 2 )
1039 main.log.report(
1040 "Time taken for Ping All: " +
1041 str( timeDiff ) +
1042 " seconds" )
1043 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1044 onpass="PING ALL PASS",
1045 onfail="PING ALL FAIL" )
1046
1047 case15Result = ( intentResult and pingResult )
1048
1049 utilities.assert_equals(
1050 expect=main.TRUE,
1051 actual=case15Result,
1052 onpass="Install 2278 Host Intents and Ping All test PASS",
1053 onfail="Install 2278 Host Intents and Ping All test FAIL" )
1054
kelvin-onlab8a832582015-01-16 17:06:11 -08001055 def CASE70( self, main ):
1056 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001057 Randomly bring some core links down and verify ping all ( Host Intents-Att Topo)
kelvin-onlab8a832582015-01-16 17:06:11 -08001058 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001059 import random
Hari Krishna22c3d412015-02-17 16:48:12 -08001060 main.randomLink1 = []
1061 main.randomLink2 = []
1062 main.randomLink3 = []
kelvin-onlab65a72d22015-03-26 13:46:32 -07001063 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1064 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1065 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1066 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1067 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1068 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1069 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001070 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001071
Hari Krishnab35c6d02015-03-18 11:13:51 -07001072 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" )
1073 main.log.report( "___________________________________________________________________________" )
Hari Krishnad97213e2015-01-24 19:30:14 -08001074 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1075 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001076 if ( int( switchLinksToToggle ) ==
1077 0 or int( switchLinksToToggle ) > 5 ):
Hari Krishna46997e02015-01-27 11:23:07 -08001078 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 -07001079 #main.cleanup()
1080 #main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001081 else:
Hari Krishnad97213e2015-01-24 19:30:14 -08001082 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 -08001083
kelvin-onlab8a832582015-01-16 17:06:11 -08001084 main.step( "Cut links on Core devices using user provided range" )
Hari Krishna22c3d412015-02-17 16:48:12 -08001085 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1086 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1087 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001088 for i in range( int( switchLinksToToggle ) ):
1089 main.Mininet1.link(
1090 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001091 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001092 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001093 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001094 main.Mininet1.link(
1095 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001096 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001097 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001098 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001099 main.Mininet1.link(
1100 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001101 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001102 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001103 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001104
1105 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001106 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -08001107 topology_output, main.numMNswitches, str(
1108 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001109 utilities.assert_equals(
1110 expect=main.TRUE,
1111 actual=linkDown,
1112 onpass="Link Down discovered properly",
1113 onfail="Link down was not discovered in " +
1114 str( link_sleep ) +
1115 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001116
kelvin-onlab8a832582015-01-16 17:06:11 -08001117 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001118 pingResultLinkDown = main.FALSE
1119 time1 = time.time()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001120 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001121 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001122 timeDiff = round( ( time2 - time1 ), 2 )
1123 main.log.report(
1124 "Time taken for Ping All: " +
1125 str( timeDiff ) +
1126 " seconds" )
1127 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1128 onpass="PING ALL PASS",
1129 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001130
Hari Krishna22c3d412015-02-17 16:48:12 -08001131 caseResult70 = linkDown and pingResultLinkDown
1132 utilities.assert_equals( expect=main.TRUE, actual=caseResult70,
kelvin-onlab8a832582015-01-16 17:06:11 -08001133 onpass="Random Link cut Test PASS",
1134 onfail="Random Link cut Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001135
kelvin-onlab8a832582015-01-16 17:06:11 -08001136 def CASE80( self, main ):
1137 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001138 Bring the core links up that are down and verify ping all ( Host Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -08001139 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001140 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001141 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1142 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1143 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001144 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001145 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001146
kelvin-onlab8a832582015-01-16 17:06:11 -08001147 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -07001148 "Bring the core links up that are down and verify ping all (Host Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001149 main.log.report(
1150 "__________________________________________________________________" )
1151 main.case(
1152 "Host intents - Bring the core links up that are down and verify ping all" )
1153 main.step( "Bring randomly cut links on Core devices up" )
1154 for i in range( int( switchLinksToToggle ) ):
1155 main.Mininet1.link(
1156 END1=link1End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001157 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001158 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001159 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001160 main.Mininet1.link(
1161 END1=link2End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001162 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001163 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001164 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001165 main.Mininet1.link(
1166 END1=link3End1,
kelvin-onlab54400a92015-02-26 18:05:51 -08001167 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001168 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001169 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001170
1171 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001172 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -08001173 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -08001174 main.numMNswitches,
1175 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001176 utilities.assert_equals(
1177 expect=main.TRUE,
1178 actual=linkUp,
1179 onpass="Link up discovered properly",
1180 onfail="Link up was not discovered in " +
1181 str( link_sleep ) +
1182 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001183
kelvin-onlab8a832582015-01-16 17:06:11 -08001184 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001185 pingResultLinkUp = main.FALSE
1186 time1 = time.time()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001187 pingResultLinkUp = main.Mininet1.pingall( timeout=main.pingTimeout )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001188 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001189 timeDiff = round( ( time2 - time1 ), 2 )
1190 main.log.report(
1191 "Time taken for Ping All: " +
1192 str( timeDiff ) +
1193 " seconds" )
1194 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1195 onpass="PING ALL PASS",
1196 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001197
Hari Krishna22c3d412015-02-17 16:48:12 -08001198 caseResult80 = linkUp and pingResultLinkUp
1199 utilities.assert_equals( expect=main.TRUE, actual=caseResult80,
kelvin-onlab8a832582015-01-16 17:06:11 -08001200 onpass="Link Up Test PASS",
1201 onfail="Link Up Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001202
kelvin-onlab8a832582015-01-16 17:06:11 -08001203 def CASE71( self, main ):
1204 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001205 Randomly bring some core links down and verify ping all ( Point Intents-Att Topo)
kelvin-onlab8a832582015-01-16 17:06:11 -08001206 """
kelvin8ec71442015-01-15 16:57:00 -08001207 import random
Hari Krishna22c3d412015-02-17 16:48:12 -08001208 main.randomLink1 = []
1209 main.randomLink2 = []
1210 main.randomLink3 = []
kelvin-onlab65a72d22015-03-26 13:46:32 -07001211 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1212 link1End2 = main.params[ 'ATTCORELINKS' ][ 'linkS3b' ].split( ',' )
1213 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1214 link2End2 = main.params[ 'ATTCORELINKS' ][ 'linkS14b' ].split( ',' )
1215 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
1216 link3End2 = main.params[ 'ATTCORELINKS' ][ 'linkS18b' ].split( ',' )
1217 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001218 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin8ec71442015-01-15 16:57:00 -08001219
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001220 main.log.report( "Randomly bring some core links down and verify ping all (Point Intents-Att Topo)" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001221 main.log.report( "___________________________________________________________________________" )
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001222 main.case( "Point intents - Randomly bring some core links down and verify ping all" )
Hari Krishnad97213e2015-01-24 19:30:14 -08001223 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001224 if ( int( switchLinksToToggle ) ==
1225 0 or int( switchLinksToToggle ) > 5 ):
kelvin-onlab65a72d22015-03-26 13:46:32 -07001226 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 -07001227 #main.cleanup()
1228 #main.exit()
kelvin8ec71442015-01-15 16:57:00 -08001229 else:
kelvin-onlab65a72d22015-03-26 13:46:32 -07001230 main.log.info( "User provided Core switch links range to toggle is correct, proceeding to run the test" )
kelvin8ec71442015-01-15 16:57:00 -08001231
kelvin-onlab8a832582015-01-16 17:06:11 -08001232 main.step( "Cut links on Core devices using user provided range" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001233 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
1234 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
1235 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001236 for i in range( int( switchLinksToToggle ) ):
1237 main.Mininet1.link(
1238 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001239 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001240 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001241 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001242 main.Mininet1.link(
1243 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001244 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001245 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001246 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001247 main.Mininet1.link(
1248 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001249 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001250 OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001251 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -08001252
1253 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001254 linkDown = main.ONOSbench.checkStatus(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001255 topology_output, main.numMNswitches, str(
1256 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001257 utilities.assert_equals(
1258 expect=main.TRUE,
1259 actual=linkDown,
1260 onpass="Link Down discovered properly",
1261 onfail="Link down was not discovered in " +
1262 str( link_sleep ) +
1263 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -08001264
kelvin-onlab8a832582015-01-16 17:06:11 -08001265 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -08001266 pingResultLinkDown = main.FALSE
1267 time1 = time.time()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001268 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
kelvin8ec71442015-01-15 16:57:00 -08001269 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001270 timeDiff = round( ( time2 - time1 ), 2 )
1271 main.log.report(
1272 "Time taken for Ping All: " +
1273 str( timeDiff ) +
1274 " seconds" )
1275 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1276 onpass="PING ALL PASS",
1277 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001278
kelvin-onlab65a72d22015-03-26 13:46:32 -07001279 caseResult71 = linkDown and pingResultLinkDown
1280 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
kelvin-onlab8a832582015-01-16 17:06:11 -08001281 onpass="Random Link cut Test PASS",
1282 onfail="Random Link cut Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001283
kelvin-onlab8a832582015-01-16 17:06:11 -08001284 def CASE81( self, main ):
1285 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001286 Bring the core links up that are down and verify ping all ( Point Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -08001287 """
kelvin8ec71442015-01-15 16:57:00 -08001288 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001289 link1End1 = main.params[ 'ATTCORELINKS' ][ 'linkS3a' ]
1290 link2End1 = main.params[ 'ATTCORELINKS' ][ 'linkS14a' ]
1291 link3End1 = main.params[ 'ATTCORELINKS' ][ 'linkS18a' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001292 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001293 switchLinksToToggle = main.params[ 'ATTCORELINKS' ][ 'toggleLinks' ]
kelvin8ec71442015-01-15 16:57:00 -08001294
kelvin-onlab8a832582015-01-16 17:06:11 -08001295 main.log.report(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001296 "Bring the core links up that are down and verify ping all ( Point Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001297 main.log.report(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001298 "__________________________________________________________________" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001299 main.case(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001300 "Point intents - Bring the core links up that are down and verify ping all" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001301 main.step( "Bring randomly cut links on Core devices up" )
1302 for i in range( int( switchLinksToToggle ) ):
1303 main.Mininet1.link(
1304 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001305 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001306 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001307 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001308 main.Mininet1.link(
1309 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001310 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001311 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001312 time.sleep( link_sleep )
kelvin-onlab8a832582015-01-16 17:06:11 -08001313 main.Mininet1.link(
1314 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001315 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001316 OPTION="up" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001317 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -08001318
1319 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001320 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -08001321 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -08001322 main.numMNswitches,
1323 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001324 utilities.assert_equals(
1325 expect=main.TRUE,
1326 actual=linkUp,
1327 onpass="Link up discovered properly",
1328 onfail="Link up was not discovered in " +
1329 str( link_sleep ) +
1330 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -08001331
kelvin-onlab8a832582015-01-16 17:06:11 -08001332 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -08001333 pingResultLinkUp = main.FALSE
1334 time1 = time.time()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001335 pingResultLinkUp = main.Mininet1.pingall(timeout = main.pingTimeout )
kelvin8ec71442015-01-15 16:57:00 -08001336 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001337 timeDiff = round( ( time2 - time1 ), 2 )
1338 main.log.report(
1339 "Time taken for Ping All: " +
1340 str( timeDiff ) +
1341 " seconds" )
1342 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1343 onpass="PING ALL PASS",
1344 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001345
Hari Krishna22c3d412015-02-17 16:48:12 -08001346 caseResult81 = linkUp and pingResultLinkUp
1347 utilities.assert_equals( expect=main.TRUE, actual=caseResult81,
kelvin-onlab8a832582015-01-16 17:06:11 -08001348 onpass="Link Up Test PASS",
1349 onfail="Link Up Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001350
Hari Krishnab35c6d02015-03-18 11:13:51 -07001351 def CASE72( self, main ):
1352 """
1353 Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo)
1354 """
1355 import random
1356 import itertools
1357 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1358
1359 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" )
1360 main.log.report( "___________________________________________________________________________" )
1361 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1362 switches = []
1363 switchesComb = []
1364 for i in range( main.numMNswitches ):
1365 switches.append('s%d'%(i+1))
1366 switchesLinksComb = list(itertools.combinations(switches,2))
1367 main.randomLinks = random.sample(switchesLinksComb, 5 )
1368 print main.randomLinks
1369 main.step( "Cut links on random devices" )
1370
1371 for switch in main.randomLinks:
1372 main.Mininet1.link(
1373 END1=switch[0],
1374 END2=switch[1],
1375 OPTION="down")
Hari Krishna0ce0e152015-06-23 09:55:29 -07001376 time.sleep( link_sleep )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001377
1378 topology_output = main.ONOScli2.topology()
1379 linkDown = main.ONOSbench.checkStatus(
1380 topology_output, main.numMNswitches, str(
1381 int( main.numMNlinks ) - 5 * 2 ) )
1382 utilities.assert_equals(
1383 expect=main.TRUE,
1384 actual=linkDown,
1385 onpass="Link Down discovered properly",
1386 onfail="Link down was not discovered in " +
1387 str( link_sleep ) +
1388 " seconds" )
1389
1390 main.step( "Verify Ping across all hosts" )
1391 pingResultLinkDown = main.FALSE
1392 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001393 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001394 time2 = time.time()
1395 timeDiff = round( ( time2 - time1 ), 2 )
1396 main.log.report(
1397 "Time taken for Ping All: " +
1398 str( timeDiff ) +
1399 " seconds" )
1400 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1401 onpass="PING ALL PASS",
1402 onfail="PING ALL FAIL" )
1403
kelvin-onlab65a72d22015-03-26 13:46:32 -07001404 caseResult71 = pingResultLinkDown
1405 utilities.assert_equals( expect=main.TRUE, actual=caseResult71,
Hari Krishnab35c6d02015-03-18 11:13:51 -07001406 onpass="Random Link cut Test PASS",
1407 onfail="Random Link cut Test FAIL" )
1408
1409 def CASE82( self, main ):
1410 """
1411 Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo )
1412 """
1413 import random
1414 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1415
1416 main.log.report(
1417 "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" )
1418 main.log.report(
1419 "__________________________________________________________________" )
1420 main.case(
1421 "Host intents - Bring the core links up that are down and verify ping all" )
1422 main.step( "Bring randomly cut links on devices up" )
1423
1424 for switch in main.randomLinks:
1425 main.Mininet1.link(
1426 END1=switch[0],
1427 END2=switch[1],
1428 OPTION="up")
Hari Krishna0ce0e152015-06-23 09:55:29 -07001429 time.sleep( link_sleep )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001430
1431 topology_output = main.ONOScli2.topology()
1432 linkUp = main.ONOSbench.checkStatus(
1433 topology_output,
1434 main.numMNswitches,
1435 str( main.numMNlinks ) )
1436 utilities.assert_equals(
1437 expect=main.TRUE,
1438 actual=linkUp,
1439 onpass="Link up discovered properly",
1440 onfail="Link up was not discovered in " +
1441 str( link_sleep ) +
1442 " seconds" )
1443
1444 main.step( "Verify Ping across all hosts" )
1445 pingResultLinkUp = main.FALSE
1446 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001447 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001448 time2 = time.time()
1449 timeDiff = round( ( time2 - time1 ), 2 )
1450 main.log.report(
1451 "Time taken for Ping All: " +
1452 str( timeDiff ) +
1453 " seconds" )
1454 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1455 onpass="PING ALL PASS",
1456 onfail="PING ALL FAIL" )
1457
1458 caseResult82 = linkUp and pingResultLinkUp
1459 utilities.assert_equals( expect=main.TRUE, actual=caseResult82,
1460 onpass="Link Up Test PASS",
1461 onfail="Link Up Test FAIL" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001462
Hari Krishnab35c6d02015-03-18 11:13:51 -07001463 def CASE73( self, main ):
1464 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001465 Randomly bring some links down and verify ping all ( Point Intents-Chordal Topo)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001466 """
1467 import random
kelvin-onlab65a72d22015-03-26 13:46:32 -07001468 import itertools
Hari Krishnab35c6d02015-03-18 11:13:51 -07001469 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001470
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001471 main.log.report( "Randomly bring some core links down and verify ping all ( Point Intents-Chordal Topo)" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001472 main.log.report( "___________________________________________________________________________" )
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001473 main.case( "Point intents - Randomly bring some core links down and verify ping all" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001474 switches = []
1475 switchesComb = []
1476 for i in range( main.numMNswitches ):
1477 switches.append('s%d'%(i+1))
1478 switchesLinksComb = list(itertools.combinations(switches,2))
1479 main.randomLinks = random.sample(switchesLinksComb, 5 )
1480 print main.randomLinks
1481 main.step( "Cut links on random devices" )
1482
1483 for switch in main.randomLinks:
Hari Krishnab35c6d02015-03-18 11:13:51 -07001484 main.Mininet1.link(
1485 END1=switch[0],
1486 END2=switch[1],
kelvin-onlab65a72d22015-03-26 13:46:32 -07001487 OPTION="down")
Hari Krishna0ce0e152015-06-23 09:55:29 -07001488 time.sleep( link_sleep )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001489
1490 topology_output = main.ONOScli2.topology()
1491 linkDown = main.ONOSbench.checkStatus(
1492 topology_output, main.numMNswitches, str(
kelvin-onlab65a72d22015-03-26 13:46:32 -07001493 int( main.numMNlinks ) - 5 * 2 ) )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001494 utilities.assert_equals(
1495 expect=main.TRUE,
1496 actual=linkDown,
1497 onpass="Link Down discovered properly",
1498 onfail="Link down was not discovered in " +
1499 str( link_sleep ) +
1500 " seconds" )
1501
1502 main.step( "Verify Ping across all hosts" )
1503 pingResultLinkDown = main.FALSE
1504 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001505 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001506 time2 = time.time()
1507 timeDiff = round( ( time2 - time1 ), 2 )
1508 main.log.report(
1509 "Time taken for Ping All: " +
1510 str( timeDiff ) +
1511 " seconds" )
1512 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1513 onpass="PING ALL PASS",
1514 onfail="PING ALL FAIL" )
1515
kelvin-onlab65a72d22015-03-26 13:46:32 -07001516 caseResult73 = pingResultLinkDown
Hari Krishnab35c6d02015-03-18 11:13:51 -07001517 utilities.assert_equals( expect=main.TRUE, actual=caseResult73,
1518 onpass="Random Link cut Test PASS",
1519 onfail="Random Link cut Test FAIL" )
1520
1521 def CASE83( self, main ):
1522 """
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001523 Bring the core links up that are down and verify ping all ( Point Intents Chordal Topo )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001524 """
1525 import random
Hari Krishnab35c6d02015-03-18 11:13:51 -07001526 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001527
Hari Krishnab35c6d02015-03-18 11:13:51 -07001528 main.log.report(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001529 "Bring the core links up that are down and verify ping all ( Point Intents-Chordal Topo" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001530 main.log.report(
1531 "__________________________________________________________________" )
1532 main.case(
kelvin-onlabfbcd82f2015-04-02 12:06:00 -07001533 "Point intents - Bring the core links up that are down and verify ping all" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001534 main.step( "Bring randomly cut links on devices up" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001535
kelvin-onlab65a72d22015-03-26 13:46:32 -07001536 for switch in main.randomLinks:
Hari Krishnab35c6d02015-03-18 11:13:51 -07001537 main.Mininet1.link(
1538 END1=switch[0],
1539 END2=switch[1],
1540 OPTION="up")
Hari Krishna0ce0e152015-06-23 09:55:29 -07001541 time.sleep( link_sleep )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001542
1543 topology_output = main.ONOScli2.topology()
1544 linkUp = main.ONOSbench.checkStatus(
1545 topology_output,
1546 main.numMNswitches,
1547 str( main.numMNlinks ) )
1548 utilities.assert_equals(
1549 expect=main.TRUE,
1550 actual=linkUp,
1551 onpass="Link up discovered properly",
1552 onfail="Link up was not discovered in " +
1553 str( link_sleep ) +
1554 " seconds" )
1555
1556 main.step( "Verify Ping across all hosts" )
1557 pingResultLinkUp = main.FALSE
1558 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001559 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001560 time2 = time.time()
1561 timeDiff = round( ( time2 - time1 ), 2 )
1562 main.log.report(
1563 "Time taken for Ping All: " +
1564 str( timeDiff ) +
1565 " seconds" )
1566 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1567 onpass="PING ALL PASS",
1568 onfail="PING ALL FAIL" )
1569
1570 caseResult83 = linkUp and pingResultLinkUp
1571 utilities.assert_equals( expect=main.TRUE, actual=caseResult83,
1572 onpass="Link Up Test PASS",
1573 onfail="Link Up Test FAIL" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001574
1575 def CASE74( self, main ):
1576 """
1577 Randomly bring some core links down and verify ping all ( Host Intents-Spine Topo)
1578 """
1579 import random
1580 main.randomLink1 = []
1581 main.randomLink2 = []
1582 main.randomLink3 = []
1583 main.randomLink4 = []
1584 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1585 link1End2top = main.params[ 'SPINECORELINKS' ][ 'linkS9top' ].split( ',' )
1586 link1End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS9bot' ].split( ',' )
1587 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1588 link2End2top = main.params[ 'SPINECORELINKS' ][ 'linkS10top' ].split( ',' )
1589 link2End2bot = main.params[ 'SPINECORELINKS' ][ 'linkS10bot' ].split( ',' )
1590 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1591 main.pingTimeout = 400
1592
1593 main.log.report( "Bring some core links down and verify ping all (Host Intents-Spine Topo)" )
1594 main.log.report( "___________________________________________________________________________" )
1595
1596 linkIndex = range(4)
1597 linkIndexS9 = random.sample(linkIndex,1)[0]
1598 linkIndex.remove(linkIndexS9)
1599 linkIndexS10 = random.sample(linkIndex,1)[0]
1600 main.randomLink1 = link1End2top[linkIndexS9]
1601 main.randomLink2 = link2End2top[linkIndexS10]
1602 main.randomLink3 = random.sample(link1End2bot,1)[0]
1603 main.randomLink4 = random.sample(link2End2bot,1)[0]
kelvin-onlab77d6c302015-03-31 11:33:32 -07001604 # main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="down" )
1605 # main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="down" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001606 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="down" )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001607 time.sleep( link_sleep )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001608 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="down" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001609 time.sleep( link_sleep )
1610
1611 topology_output = main.ONOScli2.topology()
1612 linkDown = main.ONOSbench.checkStatus(
1613 topology_output, main.numMNswitches, str(
1614 int( main.numMNlinks ) - 8 ))
1615 utilities.assert_equals(
1616 expect=main.TRUE,
1617 actual=linkDown,
1618 onpass="Link Down discovered properly",
1619 onfail="Link down was not discovered in " +
1620 str( link_sleep ) +
1621 " seconds" )
1622
1623 main.step( "Verify Ping across all hosts" )
1624 pingResultLinkDown = main.FALSE
1625 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001626 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001627 time2 = time.time()
1628 timeDiff = round( ( time2 - time1 ), 2 )
1629 main.log.report(
1630 "Time taken for Ping All: " +
1631 str( timeDiff ) +
1632 " seconds" )
1633 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1634 onpass="PING ALL PASS",
1635 onfail="PING ALL FAIL" )
1636
1637 caseResult74 = linkDown and pingResultLinkDown
1638 utilities.assert_equals( expect=main.TRUE, actual=caseResult74,
1639 onpass="Random Link cut Test PASS",
1640 onfail="Random Link cut Test FAIL" )
1641
1642 def CASE84( self, main ):
1643 """
1644 Bring the core links up that are down and verify ping all ( Host Intents-Spine Topo )
1645 """
1646 import random
1647 link1End1 = main.params[ 'SPINECORELINKS' ][ 'linkS9' ]
1648 link2End1 = main.params[ 'SPINECORELINKS' ][ 'linkS10' ]
1649 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1650 main.log.report(
1651 "Bring the core links up that are down and verify ping all (Host Intents-Spine Topo" )
1652 main.log.report(
1653 "__________________________________________________________________" )
1654 main.case(
1655 "Host intents - Bring the core links up that are down and verify ping all" )
1656
kelvin-onlab77d6c302015-03-31 11:33:32 -07001657 #main.Mininet1.link( END1=link1End1, END2=main.randomLink1, OPTION="up" )
1658 #main.Mininet1.link( END1=link2End1, END2=main.randomLink2, OPTION="up" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001659 main.Mininet1.link( END1=link1End1, END2=main.randomLink3, OPTION="up" )
kelvin-onlab65a72d22015-03-26 13:46:32 -07001660 time.sleep( link_sleep )
Hari Krishna0ce0e152015-06-23 09:55:29 -07001661 main.Mininet1.link( END1=link2End1, END2=main.randomLink4, OPTION="up" )
1662 time.sleep( link_sleep )
1663
kelvin-onlab65a72d22015-03-26 13:46:32 -07001664 topology_output = main.ONOScli2.topology()
1665 linkUp = main.ONOSbench.checkStatus(
1666 topology_output,
1667 main.numMNswitches,
1668 str( main.numMNlinks ) )
1669 utilities.assert_equals(
1670 expect=main.TRUE,
1671 actual=linkUp,
1672 onpass="Link up discovered properly",
1673 onfail="Link up was not discovered in " +
1674 str( link_sleep ) +
1675 " seconds" )
1676
1677 main.step( "Verify Ping across all hosts" )
1678 pingResultLinkUp = main.FALSE
1679 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001680 pingResultLinkUp = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab65a72d22015-03-26 13:46:32 -07001681 time2 = time.time()
1682 timeDiff = round( ( time2 - time1 ), 2 )
1683 main.log.report(
1684 "Time taken for Ping All: " +
1685 str( timeDiff ) +
1686 " seconds" )
1687 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1688 onpass="PING ALL PASS",
1689 onfail="PING ALL FAIL" )
1690
1691 caseResult84 = linkUp and pingResultLinkUp
1692 utilities.assert_equals( expect=main.TRUE, actual=caseResult84,
1693 onpass="Link Up Test PASS",
1694 onfail="Link Up Test FAIL" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001695
1696 def CASE90( self ):
kelvin-onlab8a832582015-01-16 17:06:11 -08001697 """
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001698 Install 600 point intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -08001699 """
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001700 main.log.report( "Add 600 point intents and verify pingall (Att Topology)" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001701 main.log.report( "_______________________________________" )
1702 import itertools
1703 import time
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001704 main.case( "Install 600 point intents" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001705 main.step( "Add point Intents" )
1706 intentResult = main.TRUE
1707 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1708
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001709 intentIdList = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07001710 time1 = time.time()
Hari Krishnab35c6d02015-03-18 11:13:51 -07001711 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1712 pool = []
1713 for cli in main.CLIs:
1714 if i >= len( deviceCombos ):
1715 break
1716 t = main.Thread( target=cli.addPointIntent,
1717 threadID=main.threadID,
1718 name="addPointIntent",
Hari Krishna0ce0e152015-06-23 09:55:29 -07001719 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4",main.MACsDict.get(deviceCombos[i][0]),main.MACsDict.get(deviceCombos[i][1])])
1720 pool.append(t)
1721 #time.sleep(1)
1722 t.start()
1723 i = i + 1
1724 main.threadID = main.threadID + 1
1725 for thread in pool:
1726 thread.join()
1727 intentIdList.append(thread.result)
1728 time2 = time.time()
1729 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1730 intentResult = main.TRUE
1731 intentsJson = main.ONOScli2.intents()
1732 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1733 intentsJson = intentsJson)
1734 print getIntentStateResult
1735 # Takes awhile for all the onos to get the intents
1736 time.sleep(60)
1737 main.step( "Verify Ping across all hosts" )
1738 pingResult = main.FALSE
1739 time1 = time.time()
1740 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
1741 time2 = time.time()
1742 timeDiff = round( ( time2 - time1 ), 2 )
1743 main.log.report(
1744 "Time taken for Ping All: " +
1745 str( timeDiff ) +
1746 " seconds" )
1747 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1748 onpass="PING tALL PASS",
1749 onfail="PING ALL FAIL" )
1750
1751 case90Result = ( intentResult and pingResult )
1752
1753 utilities.assert_equals(
1754 expect=main.TRUE,
1755 actual=case90Result,
1756 onpass="Install 600 point Intents and Ping All test PASS",
1757 onfail="Install 600 point Intents and Ping All test FAIL" )
1758
1759 def CASE91( self ):
1760 """
1761 Install 600 point intents and verify ping all (Chordal Topology)
1762 """
1763 main.log.report( "Add 600 point intents and verify pingall (Chordal Topology)" )
1764 main.log.report( "_______________________________________" )
1765 import itertools
1766 import time
1767 main.case( "Install 600 point intents" )
1768 main.step( "Add point Intents" )
1769 intentResult = main.TRUE
1770 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1771
1772 intentIdList = []
1773 time1 = time.time()
1774 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1775 pool = []
1776 for cli in main.CLIs:
1777 if i >= len( deviceCombos ):
1778 break
1779 t = main.Thread( target=cli.addPointIntent,
1780 threadID=main.threadID,
1781 name="addPointIntent",
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001782 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
Hari Krishnab35c6d02015-03-18 11:13:51 -07001783 pool.append(t)
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001784 #time.sleep(1)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001785 t.start()
1786 i = i + 1
1787 main.threadID = main.threadID + 1
1788 for thread in pool:
1789 thread.join()
1790 intentIdList.append(thread.result)
1791 time2 = time.time()
1792 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1793 intentResult = main.TRUE
1794 intentsJson = main.ONOScli2.intents()
1795 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1796 intentsJson = intentsJson)
1797 print getIntentStateResult
1798 # Takes awhile for all the onos to get the intents
1799 time.sleep(30)
kelvin-onlab8a832582015-01-16 17:06:11 -08001800 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001801 pingResult = main.FALSE
1802 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001803 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001804 time2 = time.time()
1805 timeDiff = round( ( time2 - time1 ), 2 )
1806 main.log.report(
1807 "Time taken for Ping All: " +
1808 str( timeDiff ) +
1809 " seconds" )
1810 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1811 onpass="PING ALL PASS",
1812 onfail="PING ALL FAIL" )
1813
kelvin-onlab65a72d22015-03-26 13:46:32 -07001814 case91Result = ( intentResult and pingResult )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001815
1816 utilities.assert_equals(
1817 expect=main.TRUE,
kelvin-onlabd878fc22015-03-27 13:33:41 -07001818 actual=case91Result,
Hari Krishna0ce0e152015-06-23 09:55:29 -07001819 onpass="Install 600 point Intents and Ping All test PASS",
1820 onfail="Install 600 point Intents and Ping All test FAIL" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001821
1822 def CASE92( self ):
1823 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001824 Install 4556 point intents and verify ping all (Spine Topology)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001825 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001826 main.log.report( "Add 4556 point intents and verify pingall (Spine Topology)" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001827 main.log.report( "_______________________________________" )
1828 import itertools
1829 import time
kelvin-onlab77d6c302015-03-31 11:33:32 -07001830 main.case( "Install 4556 point intents" )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001831 main.step( "Add point Intents" )
1832 intentResult = main.TRUE
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001833 main.pingTimeout = 600
kelvin-onlab77d6c302015-03-31 11:33:32 -07001834 for i in range(len(main.hostMACs)):
1835 main.MACsDict[main.deviceDPIDs[i+10]] = main.hostMACs[i].split('/')[0]
1836 print main.MACsDict
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001837 deviceCombos = list( itertools.permutations( main.deviceDPIDs[10:], 2 ) )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001838 intentIdList = []
1839 time1 = time.time()
1840 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1841 pool = []
1842 for cli in main.CLIs:
1843 if i >= len( deviceCombos ):
1844 break
1845 t = main.Thread( target=cli.addPointIntent,
1846 threadID=main.threadID,
1847 name="addPointIntent",
1848 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
1849 pool.append(t)
1850 #time.sleep(1)
1851 t.start()
1852 i = i + 1
1853 main.threadID = main.threadID + 1
1854 for thread in pool:
1855 thread.join()
1856 intentIdList.append(thread.result)
1857 time2 = time.time()
1858 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1859 intentResult = main.TRUE
1860 intentsJson = main.ONOScli2.intents()
1861 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1862 intentsJson = intentsJson)
kelvin-onlab77d6c302015-03-31 11:33:32 -07001863 #print getIntentStateResult
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001864 # Takes awhile for all the onos to get the intents
kelvin-onlab77d6c302015-03-31 11:33:32 -07001865 time.sleep(60)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001866 main.step( "Verify Ping across all hosts" )
1867 pingResult = main.FALSE
1868 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001869 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001870 time2 = time.time()
1871 timeDiff = round( ( time2 - time1 ), 2 )
1872 main.log.report(
1873 "Time taken for Ping All: " +
1874 str( timeDiff ) +
1875 " seconds" )
1876 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1877 onpass="PING ALL PASS",
1878 onfail="PING ALL FAIL" )
1879
kelvin-onlab65a72d22015-03-26 13:46:32 -07001880 case92Result = ( intentResult and pingResult )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001881
1882 utilities.assert_equals(
1883 expect=main.TRUE,
kelvin-onlab65a72d22015-03-26 13:46:32 -07001884 actual=case92Result,
kelvin-onlab77d6c302015-03-31 11:33:32 -07001885 onpass="Install 4556 point Intents and Ping All test PASS",
1886 onfail="Install 4556 point Intents and Ping All test FAIL" )
1887
kelvin-onlabadfc8db2015-03-24 15:52:48 -07001888 def CASE93( self ):
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001889 """
kelvin-onlab77d6c302015-03-31 11:33:32 -07001890 Install multi-single point intents and verify Ping all works
1891 for att topology
1892 """
1893 import copy
1894 import time
1895 main.log.report( "Install multi-single point intents and verify Ping all" )
1896 main.log.report( "___________________________________________" )
1897 main.case( "Install multi-single point intents and Ping all" )
1898 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1899 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1900 intentIdList = []
1901 print "MACsDict", main.MACsDict
1902 time1 = time.time()
1903 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1904 pool = []
1905 for cli in main.CLIs:
1906 egressDevice = deviceDPIDsCopy[i]
1907 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1908 ingressDeviceList.remove(egressDevice)
1909 if i >= len( deviceDPIDsCopy ):
1910 break
1911 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1912 threadID=main.threadID,
1913 name="addMultipointToSinglepointIntent",
1914 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1915 pool.append(t)
1916 #time.sleep(1)
1917 t.start()
1918 i = i + 1
1919 main.threadID = main.threadID + 1
1920 for thread in pool:
1921 thread.join()
1922 intentIdList.append(thread.result)
1923 time2 = time.time()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001924 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1925 time.sleep(30)
1926 print "getting all intents ID"
1927 intentIdTemp = main.ONOScli1.getAllIntentsId()
1928 print intentIdTemp
1929 print len(intentIdList)
kelvin-onlab06ade552015-03-31 18:09:27 -07001930 print intentIdList
kelvin-onlab4df89f22015-04-13 18:10:23 -07001931 checkIntentStateResult = main.TRUE
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001932 print "Checking intents state"
kelvin-onlab4df89f22015-04-13 18:10:23 -07001933 checkIntentStateResult = main.ONOScli1.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1934 checkIntentStateResult = main.ONOScli2.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1935 checkIntentStateResult = main.ONOScli3.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1936 checkIntentStateResult = main.ONOScli4.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1937 checkIntentStateResult = main.ONOScli5.checkIntentState( intentsId = intentIdList ) and checkIntentStateResult
1938
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001939 if checkIntentStateResult:
1940 main.log.info( "All intents are installed correctly " )
kelvin-onlab4df89f22015-04-13 18:10:23 -07001941
1942 print "Checking flows state "
1943 checkFlowsState = main.ONOScli1.checkFlowsState()
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001944 time.sleep(50)
kelvin-onlab77d6c302015-03-31 11:33:32 -07001945 main.step( "Verify Ping across all hosts" )
1946 pingResult = main.FALSE
1947 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07001948 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab77d6c302015-03-31 11:33:32 -07001949 time2 = time.time()
1950 timeDiff = round( ( time2 - time1 ), 2 )
1951 main.log.report(
1952 "Time taken for Ping All: " +
1953 str( timeDiff ) +
1954 " seconds" )
kelvin-onlab4df89f22015-04-13 18:10:23 -07001955 checkFlowsState = main.ONOScli1.checkFlowsState()
kelvin-onlab77d6c302015-03-31 11:33:32 -07001956 case93Result = pingResult
1957 utilities.assert_equals(
1958 expect=main.TRUE,
1959 actual=case93Result,
1960 onpass="Install 25 multi to single point Intents and Ping All test PASS",
1961 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
1962
kelvin-onlab20c712a2015-03-31 12:55:34 -07001963 def CASE94( self ):
1964 """
1965 Install multi-single point intents and verify Ping all works
kelvin-onlabd9a8ed32015-04-03 13:55:28 -07001966 for Chordal topology
kelvin-onlab20c712a2015-03-31 12:55:34 -07001967 """
1968 import copy
1969 import time
1970 main.log.report( "Install multi-single point intents and verify Ping all" )
1971 main.log.report( "___________________________________________" )
1972 main.case( "Install multi-single point intents and Ping all" )
1973 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
1974 portIngressList = ['1']*(len(deviceDPIDsCopy) - 1)
1975 intentIdList = []
1976 print "MACsDict", main.MACsDict
1977 time1 = time.time()
1978 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
1979 pool = []
1980 for cli in main.CLIs:
1981 egressDevice = deviceDPIDsCopy[i]
1982 ingressDeviceList = copy.copy(deviceDPIDsCopy)
1983 ingressDeviceList.remove(egressDevice)
1984 if i >= len( deviceDPIDsCopy ):
1985 break
1986 t = main.Thread( target=cli.addMultipointToSinglepointIntent,
1987 threadID=main.threadID,
1988 name="addMultipointToSinglepointIntent",
1989 args =[ingressDeviceList,egressDevice,portIngressList,'1','IPV4','',main.MACsDict.get(egressDevice)])
1990 pool.append(t)
1991 #time.sleep(1)
1992 t.start()
1993 i = i + 1
1994 main.threadID = main.threadID + 1
1995 for thread in pool:
1996 thread.join()
1997 intentIdList.append(thread.result)
1998 time2 = time.time()
1999 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2000 time.sleep(5)
2001 main.step( "Verify Ping across all hosts" )
2002 pingResult = main.FALSE
2003 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002004 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlab20c712a2015-03-31 12:55:34 -07002005 time2 = time.time()
2006 timeDiff = round( ( time2 - time1 ), 2 )
2007 main.log.report(
2008 "Time taken for Ping All: " +
2009 str( timeDiff ) +
2010 " seconds" )
2011
2012 case94Result = pingResult
2013 utilities.assert_equals(
2014 expect=main.TRUE,
2015 actual=case94Result,
2016 onpass="Install 25 multi to single point Intents and Ping All test PASS",
2017 onfail="Install 25 multi to single point Intents and Ping All test FAIL" )
kelvin-onlab06ade552015-03-31 18:09:27 -07002018
2019 #def CASE95 multi-single point intent for Spine
2020
kelvin-onlab77d6c302015-03-31 11:33:32 -07002021 def CASE96( self ):
2022 """
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002023 Install single-multi point intents and verify Ping all works
2024 for att topology
2025 """
2026 import copy
2027 main.log.report( "Install single-multi point intents and verify Ping all" )
2028 main.log.report( "___________________________________________" )
2029 main.case( "Install single-multi point intents and Ping all" )
kelvin-onlab06ade552015-03-31 18:09:27 -07002030 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
2031 portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002032 intentIdList = []
kelvin-onlab06ade552015-03-31 18:09:27 -07002033 print "MACsDict", main.MACsDict
2034 time1 = time.time()
2035 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2036 pool = []
2037 for cli in main.CLIs:
2038 ingressDevice = deviceDPIDsCopy[i]
2039 egressDeviceList = copy.copy(deviceDPIDsCopy)
2040 egressDeviceList.remove(ingressDevice)
2041 if i >= len( deviceDPIDsCopy ):
2042 break
2043 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2044 threadID=main.threadID,
2045 name="addSinglepointToMultipointIntent",
2046 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice)])
2047 pool.append(t)
2048 #time.sleep(1)
2049 t.start()
2050 i = i + 1
2051 main.threadID = main.threadID + 1
2052 for thread in pool:
2053 thread.join()
2054 intentIdList.append(thread.result)
2055 time2 = time.time()
2056 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2057 time.sleep(5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002058 main.step( "Verify Ping across all hosts" )
2059 pingResult = main.FALSE
2060 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002061 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002062 time2 = time.time()
2063 timeDiff = round( ( time2 - time1 ), 2 )
2064 main.log.report(
2065 "Time taken for Ping All: " +
2066 str( timeDiff ) +
2067 " seconds" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002068
kelvin-onlab06ade552015-03-31 18:09:27 -07002069 case96Result = pingResult
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002070 utilities.assert_equals(
2071 expect=main.TRUE,
kelvin-onlab06ade552015-03-31 18:09:27 -07002072 actual=case96Result,
2073 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2074 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002075
kelvin-onlab77d6c302015-03-31 11:33:32 -07002076 def CASE97( self ):
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002077 """
2078 Install single-multi point intents and verify Ping all works
kelvin-onlab06ade552015-03-31 18:09:27 -07002079 for Chordal topology
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002080 """
2081 import copy
2082 main.log.report( "Install single-multi point intents and verify Ping all" )
2083 main.log.report( "___________________________________________" )
2084 main.case( "Install single-multi point intents and Ping all" )
kelvin-onlab06ade552015-03-31 18:09:27 -07002085 deviceDPIDsCopy = copy.copy(main.deviceDPIDs)
2086 portEgressList = ['1']*(len(deviceDPIDsCopy) - 1)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002087 intentIdList = []
kelvin-onlab06ade552015-03-31 18:09:27 -07002088 print "MACsDict", main.MACsDict
2089 time1 = time.time()
2090 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2091 pool = []
2092 for cli in main.CLIs:
2093 ingressDevice = deviceDPIDsCopy[i]
2094 egressDeviceList = copy.copy(deviceDPIDsCopy)
2095 egressDeviceList.remove(ingressDevice)
2096 if i >= len( deviceDPIDsCopy ):
2097 break
2098 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2099 threadID=main.threadID,
2100 name="addSinglepointToMultipointIntent",
2101 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',main.MACsDict.get(ingressDevice),''])
2102 pool.append(t)
2103 #time.sleep(1)
2104 t.start()
2105 i = i + 1
2106 main.threadID = main.threadID + 1
2107 for thread in pool:
2108 thread.join()
2109 intentIdList.append(thread.result)
2110 time2 = time.time()
2111 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2112 time.sleep(5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002113 main.step( "Verify Ping across all hosts" )
2114 pingResult = main.FALSE
2115 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002116 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002117 time2 = time.time()
2118 timeDiff = round( ( time2 - time1 ), 2 )
2119 main.log.report(
2120 "Time taken for Ping All: " +
2121 str( timeDiff ) +
2122 " seconds" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002123
kelvin-onlab06ade552015-03-31 18:09:27 -07002124 case97Result = pingResult
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002125 utilities.assert_equals(
2126 expect=main.TRUE,
kelvin-onlab06ade552015-03-31 18:09:27 -07002127 actual=case97Result,
2128 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2129 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002130
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07002131 def CASE98( self ):
2132 """
2133 Install single-multi point intents and verify Ping all works
2134 for Spine topology
2135 """
2136 import copy
2137 main.log.report( "Install single-multi point intents and verify Ping all" )
2138 main.log.report( "___________________________________________" )
2139 main.case( "Install single-multi point intents and Ping all" )
2140 deviceDPIDsCopy = copy.copy( main.deviceDPIDs )
2141 deviceDPIDsCopy = deviceDPIDsCopy[ 10: ]
2142 portEgressList = [ '1' ]*(len(deviceDPIDsCopy) - 1)
2143 intentIdList = []
2144 MACsDictCopy = {}
2145 for i in range( len( deviceDPIDsCopy ) ):
2146 MACsDictCopy[ deviceDPIDsCopy[ i ] ] = main.hostMACs[i].split( '/' )[ 0 ]
2147
2148 print "deviceDPIDsCopy", deviceDPIDsCopy
2149 print ""
2150 print "MACsDictCopy", MACsDictCopy
2151 time1 = time.time()
2152 for i in xrange(0,len(deviceDPIDsCopy),int(main.numCtrls)):
2153 pool = []
2154 for cli in main.CLIs:
2155 if i >= len( deviceDPIDsCopy ):
2156 break
2157 ingressDevice = deviceDPIDsCopy[i]
2158 egressDeviceList = copy.copy(deviceDPIDsCopy)
2159 egressDeviceList.remove(ingressDevice)
2160 t = main.Thread( target=cli.addSinglepointToMultipointIntent,
2161 threadID=main.threadID,
2162 name="addSinglepointToMultipointIntent",
2163 args =[ingressDevice,egressDeviceList,'1',portEgressList,'IPV4',MACsDictCopy.get(ingressDevice),''])
2164 pool.append(t)
2165 #time.sleep(1)
2166 t.start()
2167 i = i + 1
2168 main.threadID = main.threadID + 1
2169 for thread in pool:
2170 thread.join()
2171 intentIdList.append(thread.result)
2172 time2 = time.time()
2173 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
2174 time.sleep(5)
2175 main.step( "Verify Ping across all hosts" )
2176 pingResult = main.FALSE
2177 time1 = time.time()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002178 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout,shortCircuit=False,acceptableFailed=5)
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07002179 time2 = time.time()
2180 timeDiff = round( ( time2 - time1 ), 2 )
2181 main.log.report(
2182 "Time taken for Ping All: " +
2183 str( timeDiff ) +
2184 " seconds" )
2185
2186 case98Result = pingResult
2187 utilities.assert_equals(
2188 expect=main.TRUE,
2189 actual=case98Result,
2190 onpass="Install 25 single to multi point Intents and Ping All test PASS",
2191 onfail="Install 25 single to multi point Intents and Ping All test FAIL" )
2192
kelvin-onlab8a832582015-01-16 17:06:11 -08002193 def CASE10( self ):
kelvin-onlab7642bb12015-02-27 13:48:17 -08002194 import time
kelvin-onlab8a832582015-01-16 17:06:11 -08002195 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002196 Remove all Intents
kelvin-onlab8a832582015-01-16 17:06:11 -08002197 """
2198 main.log.report( "Remove all intents that were installed previously" )
2199 main.log.report( "______________________________________________" )
2200 main.log.info( "Remove all intents" )
2201 main.case( "Removing intents" )
2202 main.step( "Obtain the intent id's first" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002203 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -08002204 ansi_escape = re.compile( r'\x1b[^m]*m' )
2205 intentsList = ansi_escape.sub( '', intentsList )
2206 intentsList = intentsList.replace(
2207 " onos:intents | grep id=",
2208 "" ).replace(
2209 "id=",
2210 "" ).replace(
2211 "\r\r",
2212 "" )
2213 intentsList = intentsList.splitlines()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002214 #intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002215 intentIdList = []
2216 step1Result = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002217 moreIntents = main.TRUE
2218 removeIntentCount = 0
kelvin-onlab65a72d22015-03-26 13:46:32 -07002219 intentsCount = len(intentsList)
Hari Krishna0ce0e152015-06-23 09:55:29 -07002220 main.log.info ( "Current number of intents: " + str(intentsCount) )
kelvin-onlab8a832582015-01-16 17:06:11 -08002221 if ( len( intentsList ) > 1 ):
kelvin-onlab54400a92015-02-26 18:05:51 -08002222 results = main.TRUE
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002223 main.log.info("Removing intent...")
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002224 while moreIntents:
Hari Krishna0ce0e152015-06-23 09:55:29 -07002225 #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 -07002226 if removeIntentCount == 5:
2227 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002228 removeIntentCount = removeIntentCount + 1
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002229 intentsList1 = main.ONOScli1.getAllIntentIds()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002230 if len( intentsList1 ) == 0:
2231 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002232 ansi_escape = re.compile( r'\x1b[^m]*m' )
2233 intentsList1 = ansi_escape.sub( '', intentsList1 )
2234 intentsList1 = intentsList1.replace(
2235 " onos:intents | grep id=",
2236 "" ).replace(
2237 " state=",
2238 "" ).replace(
2239 "\r\r",
2240 "" )
2241 intentsList1 = intentsList1.splitlines()
Hari Krishna0ce0e152015-06-23 09:55:29 -07002242 #intentsList1 = intentsList1[ 1: ]
2243 main.log.info ( "Round %d intents to remove: " %(removeIntentCount) )
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002244 print intentsList1
2245 intentIdList1 = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07002246 if ( len( intentsList1 ) > 0 ):
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07002247 moreIntents = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002248 for i in range( len( intentsList1 ) ):
2249 intentsTemp1 = intentsList1[ i ].split( ',' )
2250 intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] )
Hari Krishna0ce0e152015-06-23 09:55:29 -07002251 main.log.info ( "Leftover Intent IDs: " + str(intentIdList1) )
2252 main.log.info ( "Length of Leftover Intents list: " + str(len(intentIdList1)) )
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002253 time1 = time.time()
2254 for i in xrange( 0, len( intentIdList1 ), int(main.numCtrls) ):
2255 pool = []
2256 for cli in main.CLIs:
2257 if i >= len( intentIdList1 ):
2258 break
2259 t = main.Thread( target=cli.removeIntent,
2260 threadID=main.threadID,
2261 name="removeIntent",
Hari Krishna0ce0e152015-06-23 09:55:29 -07002262 args=[intentIdList1[i],'org.onosproject.cli',False,False])
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002263 pool.append(t)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002264 t.start()
2265 i = i + 1
2266 main.threadID = main.threadID + 1
2267 for thread in pool:
2268 thread.join()
2269 intentIdList.append(thread.result)
Hari Krishna0ce0e152015-06-23 09:55:29 -07002270 #time.sleep(2)
kelvin-onlabadfc8db2015-03-24 15:52:48 -07002271 time2 = time.time()
2272 main.log.info("Time for removing host intents: %2f seconds" %(time2-time1))
Hari Krishnab35c6d02015-03-18 11:13:51 -07002273 time.sleep(10)
Hari Krishna0ce0e152015-06-23 09:55:29 -07002274 main.log.info("Purging WITHDRAWN Intents")
2275 purgeResult = main.TRUE
2276 for i in range( int( main.numCtrls) ):
2277 t = main.Thread( target=main.CLIs[i].purgeIntents,
2278 threadID=main.threadID,
2279 name="purgeIntents",
2280 args=[ ] )
2281 pool.append(t)
2282 t.start()
2283 main.threadID = main.threadID + 1
2284 for t in pool:
2285 t.join()
2286 purgeResult = purgeResult and t.result
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002287 else:
Hari Krishna0ce0e152015-06-23 09:55:29 -07002288 time.sleep(10)
Hari Krishnab35c6d02015-03-18 11:13:51 -07002289 if len( main.ONOScli1.intents()):
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07002290 continue
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002291 break
Hari Krishna0ce0e152015-06-23 09:55:29 -07002292 time.sleep(10)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002293 else:
kelvin-onlab65a72d22015-03-26 13:46:32 -07002294 print "Removed %d intents" %(intentsCount)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08002295 step1Result = main.TRUE
2296 else:
2297 print "No Intent IDs found in Intents list: ", intentsList
2298 step1Result = main.FALSE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002299
kelvin-onlabdc8719b2015-03-02 14:01:52 -08002300 print main.ONOScli1.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002301 caseResult10 = step1Result
2302 utilities.assert_equals( expect=main.TRUE, actual=caseResult10,
kelvin-onlab8a832582015-01-16 17:06:11 -08002303 onpass="Intent removal test successful",
2304 onfail="Intent removal test failed" )
Hari Krishna22c3d412015-02-17 16:48:12 -08002305
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07002306 def CASE12( self, main ):
Hari Krishna22c3d412015-02-17 16:48:12 -08002307 """
2308 Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it
2309 """
2310 import re
2311 import copy
2312 import time
2313
kelvin-onlab54400a92015-02-26 18:05:51 -08002314 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
2315 threadID = 0
2316
Hari Krishna22c3d412015-02-17 16:48:12 -08002317 main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" )
2318 main.log.report( "_____________________________________________________" )
2319 main.case( "Enable Intent based Reactive forwarding and Verify ping all" )
2320 main.step( "Enable intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002321 installResult = main.FALSE
2322 feature = "onos-app-ifwd"
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002323
kelvin-onlab54400a92015-02-26 18:05:51 -08002324 pool = []
2325 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002326 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08002327 t = main.Thread(target=cli,threadID=threadID,
2328 name="featureInstall",args=[feature])
2329 pool.append(t)
2330 t.start()
2331 threadID = threadID + 1
2332
2333 results = []
2334 for thread in pool:
2335 thread.join()
2336 results.append(thread.result)
2337 time2 = time.time()
2338
2339 if( all(result == main.TRUE for result in results) == False):
2340 main.log.info("Did not install onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07002341 #main.cleanup()
2342 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08002343 else:
2344 main.log.info("Successful feature:install onos-app-ifwd")
2345 installResult = main.TRUE
2346 main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1))
2347
Hari Krishna22c3d412015-02-17 16:48:12 -08002348 main.step( "Verify Pingall" )
2349 ping_result = main.FALSE
2350 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08002351 ping_result = main.Mininet1.pingall(timeout=600)
Hari Krishna22c3d412015-02-17 16:48:12 -08002352 time2 = time.time()
2353 timeDiff = round( ( time2 - time1 ), 2 )
2354 main.log.report(
2355 "Time taken for Ping All: " +
2356 str( timeDiff ) +
2357 " seconds" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002358
Hari Krishna22c3d412015-02-17 16:48:12 -08002359 if ping_result == main.TRUE:
2360 main.log.report( "Pingall Test in Reactive mode successful" )
2361 else:
2362 main.log.report( "Pingall Test in Reactive mode failed" )
2363
2364 main.step( "Disable Intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08002365 uninstallResult = main.FALSE
2366
kelvin-onlab54400a92015-02-26 18:05:51 -08002367 pool = []
2368 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002369 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08002370 t = main.Thread(target=cli,threadID=threadID,
2371 name="featureUninstall",args=[feature])
2372 pool.append(t)
2373 t.start()
2374 threadID = threadID + 1
2375
2376 results = []
2377 for thread in pool:
2378 thread.join()
2379 results.append(thread.result)
2380 time2 = time.time()
2381
2382 if( all(result == main.TRUE for result in results) == False):
2383 main.log.info("Did not uninstall onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07002384 uninstallResult = main.FALSE
2385 #main.cleanup()
2386 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08002387 else:
2388 main.log.info("Successful feature:uninstall onos-app-ifwd")
2389 uninstallResult = main.TRUE
2390 main.log.info("Time for feature:uninstall onos-app-ifwd: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08002391
2392 # Waiting for reative flows to be cleared.
2393 time.sleep( 10 )
2394
2395 case11Result = installResult and ping_result and uninstallResult
2396 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
2397 onpass="Intent based Reactive forwarding Pingall test PASS",
2398 onfail="Intent based Reactive forwarding Pingall test FAIL" )
2399
Hari Krishnab35c6d02015-03-18 11:13:51 -07002400 def CASE99(self):
2401 import time
2402 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
2403 main.step( "Stop ONOS on all Nodes" )
2404 stopResult = main.TRUE
2405 for i in range( 1, int( main.numCtrls ) + 1 ):
2406 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2407 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
2408 sresult = main.ONOSbench.onosStop( ONOS_ip )
2409 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2410 onpass="Test step PASS",
2411 onfail="Test step FAIL" )
2412 stopResult = ( stopResult and sresult )
2413
2414 main.step( "Start ONOS on all Nodes" )
2415 startResult = main.TRUE
2416 for i in range( 1, int( main.numCtrls ) + 1 ):
2417 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2418 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
2419 sresult = main.ONOSbench.onosStart( ONOS_ip )
2420 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2421 onpass="Test step PASS",
2422 onfail="Test step FAIL" )
2423 startResult = ( startResult and sresult )
2424
2425 main.step( "Start ONOS CLI on all nodes" )
2426 cliResult = main.TRUE
2427 time.sleep( 30 )
2428 main.log.step(" Start ONOS cli using thread ")
2429 pool = []
2430 time1 = time.time()
2431 for i in range( int( main.numCtrls ) ):
2432 t = main.Thread(target=main.CLIs[i].startOnosCli,
2433 threadID=main.threadID,
2434 name="startOnosCli",
2435 args=[main.nodes[i].ip_address])
2436 pool.append(t)
2437 t.start()
2438 main.threadID = main.threadID + 1
2439 for t in pool:
2440 t.join()
2441 cliResult = cliResult and t.result
2442 time2 = time.time()
2443
2444 if not cliResult:
2445 main.log.info("ONOS CLI did not start up properly")
2446 #main.cleanup()
2447 #main.exit()
2448 else:
2449 main.log.info("Successful CLI startup")
2450 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
2451
2452 case99Result = ( startResult and cliResult )
2453 time.sleep(30)
2454 utilities.assert_equals(
2455 expect=main.TRUE,
2456 actual=case99Result,
2457 onpass="Starting new Chordal topology test PASS",
2458 onfail="Starting new Chordal topology test FAIL" )
2459
2460
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002461
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002462
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07002463