blob: 955d9962876125d0276e71f4d1b04505d677582a [file] [log] [blame]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001import time
2import sys
3import os
4import re
5import time
6import json
7import itertools
8
kelvin8ec71442015-01-15 16:57:00 -08009
Hari Krishnaa43d4e92014-12-19 13:22:40 -080010class OnosCHO:
kelvin8ec71442015-01-15 16:57:00 -080011
kelvin-onlab8a832582015-01-16 17:06:11 -080012 def __init__( self ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -080013 self.default = ''
kelvin8ec71442015-01-15 16:57:00 -080014
kelvin-onlab8a832582015-01-16 17:06:11 -080015 def CASE1( self, main ):
16 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -080017 Startup sequence:
18 git pull
19 mvn clean install
20 onos-package
21 cell <name>
22 onos-verify-cell
23 onos-install -f
24 onos-wait-for-start
kelvin-onlab8a832582015-01-16 17:06:11 -080025 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -080026 import time
kelvin-onlab78f7d2d2015-03-02 17:37:35 -080027
28 global intentState
kelvin-onlab54400a92015-02-26 18:05:51 -080029 main.threadID = 0
30 main.pingTimeout = 300
Hari Krishna22c3d412015-02-17 16:48:12 -080031 main.numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
32 main.ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
33 main.ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
34 main.ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
35 main.ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
36 main.ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
37 main.ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
38 main.ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
39 main.ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
40 main.ONOS4_port = main.params[ 'CTRL' ][ 'port4' ]
41 main.ONOS5_port = main.params[ 'CTRL' ][ 'port5' ]
kelvin-onlab8a832582015-01-16 17:06:11 -080042 cell_name = main.params[ 'ENV' ][ 'cellName' ]
43 git_pull = main.params[ 'GIT' ][ 'autoPull' ]
kelvin-onlab8a832582015-01-16 17:06:11 -080044 git_branch = main.params[ 'GIT' ][ 'branch' ]
kelvin-onlab78f7d2d2015-03-02 17:37:35 -080045
46 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
kelvin-onlab8a832582015-01-16 17:06:11 -0800105 main.step( "Removing copy-cat logs from ONOS nodes" )
Hari Krishnad97213e2015-01-24 19:30:14 -0800106 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 Krishnaa43d4e92014-12-19 13:22:40 -0800129
kelvin-onlab8a832582015-01-16 17:06:11 -0800130 main.step( "Start ONOS CLI on all nodes" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800131 cliResult = main.TRUE
kelvin8ec71442015-01-15 16:57:00 -0800132 karafTimeout = "3600000"
kelvin-onlab8a832582015-01-16 17:06:11 -0800133 # need to wait here for sometime. This will be removed once ONOS is
134 # stable enough
kelvin-onlab54400a92015-02-26 18:05:51 -0800135 time.sleep( 25 )
kelvin-onlab54400a92015-02-26 18:05:51 -0800136 main.log.step(" Start ONOS cli using thread ")
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800137 startCliResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800138 pool = []
139 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800140 for i in range( int( main.numCtrls) ):
141 t = main.Thread( target=main.CLIs[i].startOnosCli,
142 threadID=main.threadID,
143 name="startOnosCli",
144 args=[ main.nodes[i].ip_address ] )
kelvin-onlab54400a92015-02-26 18:05:51 -0800145 pool.append(t)
146 t.start()
147 main.threadID = main.threadID + 1
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800148 for t in pool:
149 t.join()
150 startCliResult = startCliResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -0800151 time2 = time.time()
152
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800153 if not startCliResult:
kelvin-onlab54400a92015-02-26 18:05:51 -0800154 main.log.info("ONOS CLI did not start up properly")
155 main.cleanup()
156 main.exit()
157 else:
158 main.log.info("Successful CLI startup")
159 startCliResult = main.TRUE
160 case1Result = installResult and uninstallResult and statusResult and startCliResult
161
162 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
kelvin-onlab8a832582015-01-16 17:06:11 -0800163 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
164 onpass="Set up test environment PASS",
165 onfail="Set up test environment FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800166
kelvin-onlab8a832582015-01-16 17:06:11 -0800167 def CASE2( self, main ):
168 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800169 This test loads a Topology (ATT) on Mininet 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 Krishna22c3d412015-02-17 16:48:12 -0800174 main.numMNswitches = int ( main.params[ 'TOPO1' ][ 'numSwitches' ] )
175 main.numMNlinks = int ( main.params[ 'TOPO1' ][ 'numLinks' ] )
176 main.numMNhosts = int ( main.params[ 'TOPO1' ][ 'numHosts' ] )
kelvin-onlab54400a92015-02-26 18:05:51 -0800177 main.pingTimeout = 60
kelvin-onlab8a832582015-01-16 17:06:11 -0800178 main.log.report(
179 "Assign and Balance all Mininet switches across controllers" )
180 main.log.report(
181 "_________________________________________________________" )
182 # need to wait here for sometime. This will be removed once ONOS is
183 # stable enough
184 time.sleep( 15 )
185 main.case(
186 "Assign and Balance all Mininet switches across controllers" )
187 main.step( "Assign switches to controllers" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800188 netStatus = main.Mininet1.startNet()
189 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
Hari Krishnad97213e2015-01-24 19:30:14 -0800190 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800191 sw=str( i ),
Hari Krishna22c3d412015-02-17 16:48:12 -0800192 count=int( main.numCtrls ),
193 ip1=main.ONOS1_ip,
194 port1=main.ONOS1_port,
195 ip2=main.ONOS2_ip,
196 port2=main.ONOS2_port,
197 ip3=main.ONOS3_ip,
198 port3=main.ONOS3_port,
199 ip4=main.ONOS4_ip,
200 port4=main.ONOS4_port,
201 ip5=main.ONOS5_ip,
202 port5=main.ONOS5_port )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800203
204 switch_mastership = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -0800205 for i in range( 1, ( main.numMNswitches + 1 ) ):
Hari Krishnad97213e2015-01-24 19:30:14 -0800206 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800207 print( "Response is " + str( response ) )
Hari Krishna22c3d412015-02-17 16:48:12 -0800208 if re.search( "tcp:" + main.ONOS1_ip, response ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800209 switch_mastership = switch_mastership and main.TRUE
210 else:
211 switch_mastership = main.FALSE
212
213 if switch_mastership == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800214 main.log.report( "Controller assignment successfull" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800215 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800216 main.log.report( "Controller assignment failed" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800217 time.sleep( 15 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800218
Hari Krishna22c3d412015-02-17 16:48:12 -0800219 #main.step( "Balance devices across controllers" )
220 #for i in range( int( main.numCtrls ) ):
221 # balanceResult = main.ONOScli1.balanceMasters()
kelvin-onlab8a832582015-01-16 17:06:11 -0800222 # giving some breathing time for ONOS to complete re-balance
Hari Krishna22c3d412015-02-17 16:48:12 -0800223 # time.sleep( 3 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800224
Hari Krishna22c3d412015-02-17 16:48:12 -0800225 #utilities.assert_equals(
226 # expect=main.TRUE,
227 # actual=balanceResult,
228 # onpass="Assign and Balance devices test PASS",
229 #onfail="Assign and Balance devices test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800230
kelvin-onlab8a832582015-01-16 17:06:11 -0800231 def CASE3( self, main ):
232 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800233 This Test case will be extended to collect and store more data related
234 ONOS state.
kelvin-onlab8a832582015-01-16 17:06:11 -0800235 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800236 import re
237 import copy
Hari Krishna22c3d412015-02-17 16:48:12 -0800238 main.deviceDPIDs = []
239 main.hostMACs = []
240 main.deviceLinks = []
241 main.deviceActiveLinksCount = []
242 main.devicePortsEnabledCount = []
kelvin-onlab54400a92015-02-26 18:05:51 -0800243
kelvin-onlab8a832582015-01-16 17:06:11 -0800244 main.log.report(
245 "Collect and Store topology details from ONOS before running any Tests" )
246 main.log.report(
247 "____________________________________________________________________" )
248 main.case( "Collect and Store Topology Deatils from ONOS" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800249 main.step( "Collect and store current number of switches and links" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800250 topology_output = main.ONOScli1.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800251 topology_result = main.ONOSbench.getTopology( topology_output )
Hari Krishna22c3d412015-02-17 16:48:12 -0800252 numOnosDevices = topology_result[ 'devices' ]
253 numOnosLinks = topology_result[ 'links' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800254
kelvin-onlab54400a92015-02-26 18:05:51 -0800255 if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks >= int(numOnosLinks) ) ):
Hari Krishna22c3d412015-02-17 16:48:12 -0800256 main.step( "Store Device DPIDs" )
257 for i in range( 1, (main.numMNswitches+1) ):
258 main.deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) )
259 print "Device DPIDs in Store: \n", str( main.deviceDPIDs )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800260
Hari Krishna22c3d412015-02-17 16:48:12 -0800261 main.step( "Store Host MACs" )
262 for i in range( 1, ( main.numMNhosts + 1 ) ):
263 main.hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" )
264 print "Host MACs in Store: \n", str( main.hostMACs )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800265
Hari Krishna22c3d412015-02-17 16:48:12 -0800266 main.step( "Collect and store all Devices Links" )
267 linksResult = main.ONOScli1.links( jsonFormat=False )
268 ansi_escape = re.compile( r'\x1b[^m]*m' )
269 linksResult = ansi_escape.sub( '', linksResult )
270 linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" )
271 linksResult = linksResult.splitlines()
272 linksResult = linksResult[ 1: ]
273 main.deviceLinks = copy.copy( linksResult )
274 print "Device Links Stored: \n", str( main.deviceLinks )
275 # this will be asserted to check with the params provided count of
276 # links
277 print "Length of Links Store", len( main.deviceLinks )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800278
Hari Krishna22c3d412015-02-17 16:48:12 -0800279 main.step( "Collect and store each Device ports enabled Count" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800280 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800281 for i in xrange(1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800282 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800283 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800284 dpid = "of:00000000000000" + format( i,'02x' )
285 t = main.Thread(target = cli.getDevicePortsEnabledCount,threadID = main.threadID, name = "getDevicePortsEnabledCount",args = [dpid])
286 t.start()
287 pool.append(t)
288 i = i + 1
289 main.threadID = main.threadID + 1
290 for thread in pool:
291 thread.join()
292 portResult = thread.result
293 portTemp = re.split( r'\t+', portResult )
294 portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
295 main.devicePortsEnabledCount.append( portCount )
Hari Krishna22c3d412015-02-17 16:48:12 -0800296 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
kelvin-onlab54400a92015-02-26 18:05:51 -0800297 time2 = time.time()
298 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800299
Hari Krishna22c3d412015-02-17 16:48:12 -0800300 main.step( "Collect and store each Device active links Count" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800301 time1 = time.time()
302
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800303 for i in xrange( 1,( main.numMNswitches + 1 ), int( main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800304 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800305 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800306 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800307 t = main.Thread( target = cli.getDeviceLinksActiveCount,
308 threadID = main.threadID,
309 name = "getDevicePortsEnabledCount",
310 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800311 t.start()
312 pool.append(t)
313 i = i + 1
314 main.threadID = main.threadID + 1
315 for thread in pool:
316 thread.join()
317 linkCountResult = thread.result
318 linkCountTemp = re.split( r'\t+', linkCountResult )
319 linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
320 main.deviceActiveLinksCount.append( linkCount )
321 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
322 time2 = time.time()
323 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800324
325 else:
326 main.log.info("Devices (expected): %s, Links (expected): %s" %
327 ( str( main.numMNswitches ), str( main.numMNlinks ) ) )
328 main.log.info("Devices (actual): %s, Links (actual): %s" %
329 ( numOnosDevices , numOnosLinks ) )
330 main.log.info("Topology does not match, exiting CHO test...")
kelvin-onlab54400a92015-02-26 18:05:51 -0800331 #time.sleep(300)
332 main.cleanup()
333 main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800334
kelvin-onlab8a832582015-01-16 17:06:11 -0800335 # just returning TRUE for now as this one just collects data
Hari Krishna22c3d412015-02-17 16:48:12 -0800336 case3Result = main.TRUE
337 utilities.assert_equals( expect=main.TRUE, actual=case3Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800338 onpass="Saving ONOS topology data test PASS",
339 onfail="Saving ONOS topology data test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800340
kelvin-onlab8a832582015-01-16 17:06:11 -0800341 def CASE4( self, main ):
342 """
343 Enable onos-app-fwd, Verify Reactive forwarding through ping all and Disable it
344 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800345 import re
346 import copy
347 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800348 main.log.report( "Enable Reactive forwarding and Verify ping all" )
349 main.log.report( "______________________________________________" )
350 main.case( "Enable Reactive forwarding and Verify ping all" )
351 main.step( "Enable Reactive forwarding" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800352 installResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800353 feature = "onos-app-fwd"
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800354
kelvin-onlab54400a92015-02-26 18:05:51 -0800355 pool = []
356 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800357 for cli in main.CLIs:
358 t = main.Thread( target=cli.featureInstall,
359 threadID=main.threadID,
360 name="featureInstall",
361 args=['onos-app-fwd'])
kelvin-onlab54400a92015-02-26 18:05:51 -0800362 pool.append(t)
363 t.start()
364 main.threadID = main.threadID + 1
365
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800366 installResult = main.TRUE
367 for t in pool:
368 t.join()
369 installResult = installResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -0800370 time2 = time.time()
371
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800372 if not installResult:
kelvin-onlab54400a92015-02-26 18:05:51 -0800373 main.log.info("Did not install onos-app-fwd feature properly")
374 main.cleanup()
375 main.exit()
376 else:
377 main.log.info("Successful feature:install onos-app-fwd")
kelvin-onlab54400a92015-02-26 18:05:51 -0800378 main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1))
379
kelvin-onlab8a832582015-01-16 17:06:11 -0800380 time.sleep( 5 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800381
kelvin-onlab8a832582015-01-16 17:06:11 -0800382 main.step( "Verify Pingall" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800383 ping_result = main.FALSE
384 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800385 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800386 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800387 timeDiff = round( ( time2 - time1 ), 2 )
388 main.log.report(
389 "Time taken for Ping All: " +
390 str( timeDiff ) +
391 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800392
393 if ping_result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800394 main.log.report( "Pingall Test in Reactive mode successful" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800395 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800396 main.log.report( "Pingall Test in Reactive mode failed" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800397
kelvin-onlab8a832582015-01-16 17:06:11 -0800398 main.step( "Disable Reactive forwarding" )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800399 uninstallResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800400 pool = []
401 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800402 for cli in main.CLIs:
403 t = main.Thread( target=cli.featureUninstall,
404 threadID=main.threadID,
405 name="featureUninstall",
406 args=['onos-app-fwd'])
kelvin-onlab54400a92015-02-26 18:05:51 -0800407 pool.append(t)
408 t.start()
409 main.threadID = main.threadID + 1
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800410 for t in pool:
411 t.join()
412 uninstallResult = uninstallResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -0800413 time2 = time.time()
414
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800415 if not uninstallResult:
kelvin-onlab54400a92015-02-26 18:05:51 -0800416 main.log.info("Did not uninstall onos-app-fwd feature properly")
417 main.cleanup()
418 main.exit()
419 else:
420 main.log.info("Successful feature:uninstall onos-app-fwd")
kelvin-onlab54400a92015-02-26 18:05:51 -0800421 main.log.info("Time for feature:uninstall onos-app-fwd: %2f seconds" %(time2-time1))
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800422
kelvin-onlab8a832582015-01-16 17:06:11 -0800423 # Waiting for reative flows to be cleared.
kelvin-onlab54400a92015-02-26 18:05:51 -0800424 time.sleep( 5 )
425 case4Result = installResult and uninstallResult and ping_result
426 utilities.assert_equals( expect=main.TRUE, actual=case4Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800427 onpass="Reactive Mode Pingall test PASS",
428 onfail="Reactive Mode Pingall test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800429
kelvin-onlab8a832582015-01-16 17:06:11 -0800430 def CASE5( self, main ):
431 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800432 Compare current ONOS topology with reference data
kelvin-onlab8a832582015-01-16 17:06:11 -0800433 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800434 import re
kelvin-onlab54400a92015-02-26 18:05:51 -0800435
Hari Krishna22c3d412015-02-17 16:48:12 -0800436 devicesDPIDTemp = []
437 hostMACsTemp = []
438 deviceLinksTemp = []
439 deviceActiveLinksCountTemp = []
440 devicePortsEnabledCountTemp = []
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800441
kelvin-onlab8a832582015-01-16 17:06:11 -0800442 main.log.report(
443 "Compare ONOS topology with reference data in Stores" )
444 main.log.report( "__________________________________________________" )
445 main.case( "Compare ONOS topology with reference data" )
446
447 main.step( "Compare current Device ports enabled with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800448 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800449 for i in xrange( 1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800450 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800451 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800452 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800453 t = main.Thread(target = cli.getDevicePortsEnabledCount,
454 threadID = main.threadID,
455 name = "getDevicePortsEnabledCount",
456 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800457 t.start()
458 pool.append(t)
459 i = i + 1
460 main.threadID = main.threadID + 1
461 for thread in pool:
462 thread.join()
463 portResult = thread.result
464 portTemp = re.split( r'\t+', portResult )
465 portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
466 devicePortsEnabledCountTemp.append( portCount )
467 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
468 time2 = time.time()
469 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800470 main.log.info (
471 "Device Enabled ports EXPECTED: %s" %
472 str( main.devicePortsEnabledCount ) )
473 main.log.info (
474 "Device Enabled ports ACTUAL: %s" %
475 str( devicePortsEnabledCountTemp ) )
kelvin-onlab54400a92015-02-26 18:05:51 -0800476
Hari Krishna22c3d412015-02-17 16:48:12 -0800477 if ( cmp( main.devicePortsEnabledCount,
478 devicePortsEnabledCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800479 stepResult1 = main.TRUE
480 else:
481 stepResult1 = main.FALSE
482
kelvin-onlab8a832582015-01-16 17:06:11 -0800483 main.step( "Compare Device active links with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800484 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800485 for i in xrange( 1, ( main.numMNswitches + 1) , int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800486 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800487 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800488 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800489 t = main.Thread(target = cli.getDeviceLinksActiveCount,
490 threadID = main.threadID,
491 name = "getDevicePortsEnabledCount",
492 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800493 t.start()
494 pool.append(t)
495 i = i + 1
496 main.threadID = main.threadID + 1
497 for thread in pool:
498 thread.join()
499 linkCountResult = thread.result
500 linkCountTemp = re.split( r'\t+', linkCountResult )
501 linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
502 deviceActiveLinksCountTemp.append( linkCount )
503 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
504 time2 = time.time()
505 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800506 main.log.info (
507 "Device Active links EXPECTED: %s" %
508 str( main.deviceActiveLinksCount ) )
509 main.log.info (
510 "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) )
511 if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800512 stepResult2 = main.TRUE
513 else:
514 stepResult2 = main.FALSE
515
kelvin-onlab8a832582015-01-16 17:06:11 -0800516 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800517 place holder for comparing devices, hosts, paths and intents if required.
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800518 Links and ports data would be incorrect with out devices anyways.
kelvin-onlab8a832582015-01-16 17:06:11 -0800519 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800520 case5Result = ( stepResult1 and stepResult2 )
521 utilities.assert_equals( expect=main.TRUE, actual=case5Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800522 onpass="Compare Topology test PASS",
523 onfail="Compare Topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800524
kelvin-onlab8a832582015-01-16 17:06:11 -0800525 def CASE6( self ):
526 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800527 Install 300 host intents and verify ping all
kelvin-onlab8a832582015-01-16 17:06:11 -0800528 """
529 main.log.report( "Add 300 host intents and verify pingall" )
530 main.log.report( "_______________________________________" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800531 import itertools
kelvin-onlab54400a92015-02-26 18:05:51 -0800532
kelvin-onlab8a832582015-01-16 17:06:11 -0800533 main.case( "Install 300 host intents" )
534 main.step( "Add host Intents" )
535 intentResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800536 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800537
kelvin-onlab54400a92015-02-26 18:05:51 -0800538 intentIdList = []
539 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800540 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800541 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800542 for cli in main.CLIs:
543 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800544 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800545 t = main.Thread( target=cli.addHostIntent,
546 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -0800547 name="addHostIntent",
548 args=[hostCombos[i][0],hostCombos[i][1]])
549 pool.append(t)
550 t.start()
551 i = i + 1
552 main.threadID = main.threadID + 1
553 for thread in pool:
554 thread.join()
555 intentIdList.append(thread.result)
556 time2 = time.time()
557 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
558 intentResult = main.TRUE
559 intentsJson = main.ONOScli2.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800560 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
kelvin-onlab54400a92015-02-26 18:05:51 -0800561 intentsJson = intentsJson)
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800562 print getIntentStateResult
563
kelvin-onlab8a832582015-01-16 17:06:11 -0800564 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800565 pingResult = main.FALSE
566 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800567 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800568 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800569 timeDiff = round( ( time2 - time1 ), 2 )
570 main.log.report(
571 "Time taken for Ping All: " +
572 str( timeDiff ) +
573 " seconds" )
574 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
575 onpass="PING ALL PASS",
576 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800577
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800578 case6Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -0800579
kelvin-onlab8a832582015-01-16 17:06:11 -0800580 utilities.assert_equals(
581 expect=main.TRUE,
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800582 actual=case6Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800583 onpass="Install 300 Host Intents and Ping All test PASS",
584 onfail="Install 300 Host Intents and Ping All test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800585
kelvin-onlab8a832582015-01-16 17:06:11 -0800586 def CASE70( self, main ):
587 """
588 Randomly bring some core links down and verify ping all ( Host Intents Scenario )
589 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800590 import random
Hari Krishna22c3d412015-02-17 16:48:12 -0800591 main.randomLink1 = []
592 main.randomLink2 = []
593 main.randomLink3 = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800594 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
595 link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
596 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
597 link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' )
598 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
599 link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' )
600 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
601 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800602
Hari Krishnad97213e2015-01-24 19:30:14 -0800603 main.log.report( "Host intents - Randomly bring some core links down and verify ping all" )
604 main.log.report( "_________________________________________________________________" )
605 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
606 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800607 if ( int( switchLinksToToggle ) ==
608 0 or int( switchLinksToToggle ) > 5 ):
Hari Krishna46997e02015-01-27 11:23:07 -0800609 main.log.info( "Please check your PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800610 main.cleanup()
611 main.exit()
612 else:
Hari Krishnad97213e2015-01-24 19:30:14 -0800613 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 -0800614
kelvin-onlab8a832582015-01-16 17:06:11 -0800615 main.step( "Cut links on Core devices using user provided range" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800616 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
617 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
618 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800619 for i in range( int( switchLinksToToggle ) ):
620 main.Mininet1.link(
621 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800622 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800623 OPTION="down" )
624 main.Mininet1.link(
625 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800626 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800627 OPTION="down" )
628 main.Mininet1.link(
629 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800630 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800631 OPTION="down" )
632 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800633
634 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800635 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -0800636 topology_output, main.numMNswitches, str(
637 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800638 utilities.assert_equals(
639 expect=main.TRUE,
640 actual=linkDown,
641 onpass="Link Down discovered properly",
642 onfail="Link down was not discovered in " +
643 str( link_sleep ) +
644 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800645
kelvin-onlab8a832582015-01-16 17:06:11 -0800646 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800647 pingResultLinkDown = main.FALSE
648 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800649 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800650 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800651 timeDiff = round( ( time2 - time1 ), 2 )
652 main.log.report(
653 "Time taken for Ping All: " +
654 str( timeDiff ) +
655 " seconds" )
656 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
657 onpass="PING ALL PASS",
658 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800659
Hari Krishna22c3d412015-02-17 16:48:12 -0800660 caseResult70 = linkDown and pingResultLinkDown
661 utilities.assert_equals( expect=main.TRUE, actual=caseResult70,
kelvin-onlab8a832582015-01-16 17:06:11 -0800662 onpass="Random Link cut Test PASS",
663 onfail="Random Link cut Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800664
kelvin-onlab8a832582015-01-16 17:06:11 -0800665 def CASE80( self, main ):
666 """
667 Bring the core links up that are down and verify ping all ( Host Intents Scenario )
668 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800669 import random
kelvin-onlab8a832582015-01-16 17:06:11 -0800670 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
671 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
672 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
673 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
674 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800675
kelvin-onlab8a832582015-01-16 17:06:11 -0800676 main.log.report(
677 "Host intents - Bring the core links up that are down and verify ping all" )
678 main.log.report(
679 "__________________________________________________________________" )
680 main.case(
681 "Host intents - Bring the core links up that are down and verify ping all" )
682 main.step( "Bring randomly cut links on Core devices up" )
683 for i in range( int( switchLinksToToggle ) ):
684 main.Mininet1.link(
685 END1=link1End1,
kelvin-onlab54400a92015-02-26 18:05:51 -0800686 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800687 OPTION="up" )
688 main.Mininet1.link(
689 END1=link2End1,
kelvin-onlab54400a92015-02-26 18:05:51 -0800690 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800691 OPTION="up" )
692 main.Mininet1.link(
693 END1=link3End1,
kelvin-onlab54400a92015-02-26 18:05:51 -0800694 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800695 OPTION="up" )
696 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800697
698 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800699 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -0800700 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -0800701 main.numMNswitches,
702 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800703 utilities.assert_equals(
704 expect=main.TRUE,
705 actual=linkUp,
706 onpass="Link up discovered properly",
707 onfail="Link up was not discovered in " +
708 str( link_sleep ) +
709 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800710
kelvin-onlab8a832582015-01-16 17:06:11 -0800711 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800712 pingResultLinkUp = main.FALSE
713 time1 = time.time()
714 pingResultLinkUp = main.Mininet1.pingall()
715 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800716 timeDiff = round( ( time2 - time1 ), 2 )
717 main.log.report(
718 "Time taken for Ping All: " +
719 str( timeDiff ) +
720 " seconds" )
721 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
722 onpass="PING ALL PASS",
723 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800724
Hari Krishna22c3d412015-02-17 16:48:12 -0800725 caseResult80 = linkUp and pingResultLinkUp
726 utilities.assert_equals( expect=main.TRUE, actual=caseResult80,
kelvin-onlab8a832582015-01-16 17:06:11 -0800727 onpass="Link Up Test PASS",
728 onfail="Link Up Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800729
kelvin-onlab8a832582015-01-16 17:06:11 -0800730 def CASE71( self, main ):
731 """
732 Randomly bring some core links down and verify ping all ( Point Intents Scenario )
733 """
kelvin8ec71442015-01-15 16:57:00 -0800734 import random
Hari Krishna22c3d412015-02-17 16:48:12 -0800735 main.randomLink1 = []
736 main.randomLink2 = []
737 main.randomLink3 = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800738 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
739 link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
740 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
741 link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' )
742 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
743 link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' )
744 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
745 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin8ec71442015-01-15 16:57:00 -0800746
Hari Krishnad97213e2015-01-24 19:30:14 -0800747 main.log.report( "Point Intents - Randomly bring some core links down and verify ping all" )
748 main.log.report( "__________________________________________________________________" )
749 main.case( "Point Intents - Randomly bring some core links down and verify ping all" )
750 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800751 if ( int( switchLinksToToggle ) ==
752 0 or int( switchLinksToToggle ) > 5 ):
753 main.log.info(
754 "Please check you PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
kelvin8ec71442015-01-15 16:57:00 -0800755 main.cleanup()
756 main.exit()
757 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800758 main.log.info(
759 "User provided Core switch links range to toggle is correct, proceeding to run the test" )
kelvin8ec71442015-01-15 16:57:00 -0800760
kelvin-onlab8a832582015-01-16 17:06:11 -0800761 main.step( "Cut links on Core devices using user provided range" )
762 randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
763 randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
764 randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
765 for i in range( int( switchLinksToToggle ) ):
766 main.Mininet1.link(
767 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800768 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800769 OPTION="down" )
770 main.Mininet1.link(
771 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800772 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800773 OPTION="down" )
774 main.Mininet1.link(
775 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800776 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800777 OPTION="down" )
778 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -0800779
780 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800781 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -0800782 topology_output, main.numSwitches, str(
783 int( main.numLinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800784 utilities.assert_equals(
785 expect=main.TRUE,
786 actual=linkDown,
787 onpass="Link Down discovered properly",
788 onfail="Link down was not discovered in " +
789 str( link_sleep ) +
790 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -0800791
kelvin-onlab8a832582015-01-16 17:06:11 -0800792 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -0800793 pingResultLinkDown = main.FALSE
794 time1 = time.time()
795 pingResultLinkDown = main.Mininet1.pingall()
796 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800797 timeDiff = round( ( time2 - time1 ), 2 )
798 main.log.report(
799 "Time taken for Ping All: " +
800 str( timeDiff ) +
801 " seconds" )
802 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
803 onpass="PING ALL PASS",
804 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -0800805
806 caseResult7 = linkDown and pingResultLinkDown
kelvin-onlab8a832582015-01-16 17:06:11 -0800807 utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
808 onpass="Random Link cut Test PASS",
809 onfail="Random Link cut Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -0800810
kelvin-onlab8a832582015-01-16 17:06:11 -0800811 def CASE81( self, main ):
812 """
813 Bring the core links up that are down and verify ping all ( Point Intents Scenario )
814 """
kelvin8ec71442015-01-15 16:57:00 -0800815 import random
kelvin-onlab8a832582015-01-16 17:06:11 -0800816 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
817 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
818 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
819 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
820 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
kelvin8ec71442015-01-15 16:57:00 -0800821
kelvin-onlab8a832582015-01-16 17:06:11 -0800822 main.log.report(
823 "Point intents - Bring the core links up that are down and verify ping all" )
824 main.log.report(
825 "___________________________________________________________________" )
826 main.case(
827 "Point intents - Bring the core links up that are down and verify ping all" )
828 main.step( "Bring randomly cut links on Core devices up" )
829 for i in range( int( switchLinksToToggle ) ):
830 main.Mininet1.link(
831 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800832 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800833 OPTION="up" )
834 main.Mininet1.link(
835 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800836 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800837 OPTION="up" )
838 main.Mininet1.link(
839 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800840 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800841 OPTION="up" )
842 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -0800843
844 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800845 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -0800846 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -0800847 main.numMNswitches,
848 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800849 utilities.assert_equals(
850 expect=main.TRUE,
851 actual=linkUp,
852 onpass="Link up discovered properly",
853 onfail="Link up was not discovered in " +
854 str( link_sleep ) +
855 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -0800856
kelvin-onlab8a832582015-01-16 17:06:11 -0800857 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -0800858 pingResultLinkUp = main.FALSE
859 time1 = time.time()
860 pingResultLinkUp = main.Mininet1.pingall()
861 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800862 timeDiff = round( ( time2 - time1 ), 2 )
863 main.log.report(
864 "Time taken for Ping All: " +
865 str( timeDiff ) +
866 " seconds" )
867 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
868 onpass="PING ALL PASS",
869 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -0800870
Hari Krishna22c3d412015-02-17 16:48:12 -0800871 caseResult81 = linkUp and pingResultLinkUp
872 utilities.assert_equals( expect=main.TRUE, actual=caseResult81,
kelvin-onlab8a832582015-01-16 17:06:11 -0800873 onpass="Link Up Test PASS",
874 onfail="Link Up Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -0800875
kelvin-onlab8a832582015-01-16 17:06:11 -0800876 def CASE9( self ):
877 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800878 Install 114 point intents and verify Ping all works
kelvin-onlab8a832582015-01-16 17:06:11 -0800879 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800880 import copy
kelvin-onlab8a832582015-01-16 17:06:11 -0800881 main.log.report( "Install 114 point intents and verify Ping all" )
882 main.log.report( "___________________________________________" )
883 main.case( "Install 114 point intents and Ping all" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800884 deviceLinksCopy = copy.copy( main.deviceLinks )
kelvin-onlab8a832582015-01-16 17:06:11 -0800885 main.step( "Install 114 point intents" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800886 for i in range( len( deviceLinksCopy ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800887 pointLink = str(
Hari Krishna22c3d412015-02-17 16:48:12 -0800888 deviceLinksCopy[ i ] ).replace(
kelvin-onlab8a832582015-01-16 17:06:11 -0800889 "src=",
890 "" ).replace(
891 "dst=",
892 "" ).split( ',' )
893 point1 = pointLink[ 0 ].split( '/' )
894 point2 = pointLink[ 1 ].split( '/' )
Hari Krishnad97213e2015-01-24 19:30:14 -0800895 installResult = main.ONOScli1.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -0800896 point1[ 0 ], point2[ 0 ], int(
897 point1[ 1 ] ), int(
898 point2[ 1 ] ) )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800899 if installResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800900 print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800901
kelvin-onlab8a832582015-01-16 17:06:11 -0800902 main.step( "Obtain the intent id's" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800903 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -0800904 ansi_escape = re.compile( r'\x1b[^m]*m' )
905 intentsList = ansi_escape.sub( '', intentsList )
906 intentsList = intentsList.replace(
907 " onos:intents | grep id=",
908 "" ).replace(
909 "id=",
910 "" ).replace(
911 "\r\r",
912 "" )
913 intentsList = intentsList.splitlines()
914 intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800915 intentIdList = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800916 for i in range( len( intentsList ) ):
917 intentsTemp = intentsList[ i ].split( ',' )
918 intentIdList.append( intentsTemp[ 0 ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800919 print "Intent IDs: ", intentIdList
kelvin-onlab8a832582015-01-16 17:06:11 -0800920 print "Total Intents installed: ", len( intentIdList )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800921
kelvin-onlab8a832582015-01-16 17:06:11 -0800922 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800923 pingResult = main.FALSE
924 time1 = time.time()
925 pingResult = main.Mininet1.pingall()
926 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800927 timeDiff = round( ( time2 - time1 ), 2 )
928 main.log.report(
929 "Time taken for Ping All: " +
930 str( timeDiff ) +
931 " seconds" )
932 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
933 onpass="PING ALL PASS",
934 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800935
936 case8_result = installResult and pingResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800937 utilities.assert_equals(
938 expect=main.TRUE,
939 actual=case8_result,
940 onpass="Ping all test after Point intents addition successful",
941 onfail="Ping all test after Point intents addition failed" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800942
kelvin-onlab8a832582015-01-16 17:06:11 -0800943 def CASE10( self ):
kelvin-onlab7642bb12015-02-27 13:48:17 -0800944 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800945 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800946 Remove all Intents
kelvin-onlab8a832582015-01-16 17:06:11 -0800947 """
948 main.log.report( "Remove all intents that were installed previously" )
949 main.log.report( "______________________________________________" )
950 main.log.info( "Remove all intents" )
951 main.case( "Removing intents" )
952 main.step( "Obtain the intent id's first" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800953 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -0800954 ansi_escape = re.compile( r'\x1b[^m]*m' )
955 intentsList = ansi_escape.sub( '', intentsList )
956 intentsList = intentsList.replace(
957 " onos:intents | grep id=",
958 "" ).replace(
959 "id=",
960 "" ).replace(
961 "\r\r",
962 "" )
963 intentsList = intentsList.splitlines()
964 intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800965 intentIdList = []
966 step1Result = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800967 if ( len( intentsList ) > 1 ):
968 for i in range( len( intentsList ) ):
969 intentsTemp = intentsList[ i ].split( ',' )
970 intentIdList.append( intentsTemp[ 0 ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800971 print "Intent IDs: ", intentIdList
kelvin-onlab54400a92015-02-26 18:05:51 -0800972
kelvin-onlab54400a92015-02-26 18:05:51 -0800973 results = main.TRUE
974 time1 = time.time()
975
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800976 for i in xrange(0,len( intentIdList ), int(main.numCtrls)):
kelvin-onlab54400a92015-02-26 18:05:51 -0800977 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800978 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800979 if i >= len(intentIdList):
980 break
981 print "Removing intent id (round 1) :", intentIdList[ i ]
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800982 t = main.Thread(target=cli.removeIntent,
983 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -0800984 name="removeIntent",
kelvin-onlab7642bb12015-02-27 13:48:17 -0800985 args=[intentIdList[i],'org.onosproject.cli',False,False])
kelvin-onlab54400a92015-02-26 18:05:51 -0800986 pool.append(t)
987 t.start()
988 i = i + 1
989 main.threadID = main.threadID + 1
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800990 for t in pool:
991 t.join()
992 results = results and t.result
kelvin-onlabdc8719b2015-03-02 14:01:52 -0800993
kelvin-onlab54400a92015-02-26 18:05:51 -0800994 time2 = time.time()
995 main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1))
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800996
kelvin-onlab8a832582015-01-16 17:06:11 -0800997 main.log.info(
998 "Verify all intents are removed and if any leftovers try remove one more time" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800999 intentsList1 = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -08001000 ansi_escape = re.compile( r'\x1b[^m]*m' )
1001 intentsList1 = ansi_escape.sub( '', intentsList1 )
1002 intentsList1 = intentsList1.replace(
1003 " onos:intents | grep id=",
1004 "" ).replace(
1005 " state=",
1006 "" ).replace(
1007 "\r\r",
1008 "" )
1009 intentsList1 = intentsList1.splitlines()
1010 intentsList1 = intentsList1[ 1: ]
kelvin-onlab7642bb12015-02-27 13:48:17 -08001011
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001012 print "Round 2 (leftover) intents to remove: ", intentsList1
1013 intentIdList1 = []
kelvin-onlab8a832582015-01-16 17:06:11 -08001014 if ( len( intentsList1 ) > 1 ):
1015 for i in range( len( intentsList1 ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001016 intentsTemp1 = intentsList1[ i ].split( ',' )
kelvin-onlabf9c71282015-02-27 10:41:41 -08001017 intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001018 print "Leftover Intent IDs: ", intentIdList1
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001019 for i in xrange(0, len( intentIdList1 ), int(main.numCtrls)):
kelvin-onlab54400a92015-02-26 18:05:51 -08001020 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001021 for cli in main.CLIs:
kelvin-onlabfd3d76e2015-02-27 11:23:21 -08001022 if i >= len(intentIdList1):
kelvin-onlab54400a92015-02-26 18:05:51 -08001023 break
1024 print "Removing intent id (round 2) :", intentIdList1[ i ]
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001025 t = main.Thread(target=cli.removeIntent,threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -08001026 name="removeIntent",
kelvin-onlab7642bb12015-02-27 13:48:17 -08001027 args=[intentIdList1[i],'org.onosproject.cli',True,False])
kelvin-onlab54400a92015-02-26 18:05:51 -08001028 pool.append(t)
1029 t.start()
1030 i = i + 1
1031 main.threadID = main.threadID + 1
1032
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001033 for t in pool:
1034 t.join()
1035 results = results and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -08001036 step1Result = results
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001037 else:
1038 print "There are no more intents that need to be removed"
1039 step1Result = main.TRUE
1040 else:
1041 print "No Intent IDs found in Intents list: ", intentsList
1042 step1Result = main.FALSE
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001043
kelvin-onlabdc8719b2015-03-02 14:01:52 -08001044 print main.ONOScli1.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001045 caseResult10 = step1Result
1046 utilities.assert_equals( expect=main.TRUE, actual=caseResult10,
kelvin-onlab8a832582015-01-16 17:06:11 -08001047 onpass="Intent removal test successful",
1048 onfail="Intent removal test failed" )
Hari Krishna22c3d412015-02-17 16:48:12 -08001049
1050 def CASE11( self, main ):
1051 """
1052 Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it
1053 """
1054 import re
1055 import copy
1056 import time
1057
kelvin-onlab54400a92015-02-26 18:05:51 -08001058 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
1059 threadID = 0
1060
Hari Krishna22c3d412015-02-17 16:48:12 -08001061 main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" )
1062 main.log.report( "_____________________________________________________" )
1063 main.case( "Enable Intent based Reactive forwarding and Verify ping all" )
1064 main.step( "Enable intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001065 installResult = main.FALSE
1066 feature = "onos-app-ifwd"
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001067
kelvin-onlab54400a92015-02-26 18:05:51 -08001068 pool = []
1069 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001070 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08001071 t = main.Thread(target=cli,threadID=threadID,
1072 name="featureInstall",args=[feature])
1073 pool.append(t)
1074 t.start()
1075 threadID = threadID + 1
1076
1077 results = []
1078 for thread in pool:
1079 thread.join()
1080 results.append(thread.result)
1081 time2 = time.time()
1082
1083 if( all(result == main.TRUE for result in results) == False):
1084 main.log.info("Did not install onos-app-ifwd feature properly")
1085 main.cleanup()
1086 main.exit()
1087 else:
1088 main.log.info("Successful feature:install onos-app-ifwd")
1089 installResult = main.TRUE
1090 main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1))
1091
Hari Krishna22c3d412015-02-17 16:48:12 -08001092 main.step( "Verify Pingall" )
1093 ping_result = main.FALSE
1094 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08001095 ping_result = main.Mininet1.pingall(timeout=600)
Hari Krishna22c3d412015-02-17 16:48:12 -08001096 time2 = time.time()
1097 timeDiff = round( ( time2 - time1 ), 2 )
1098 main.log.report(
1099 "Time taken for Ping All: " +
1100 str( timeDiff ) +
1101 " seconds" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001102
Hari Krishna22c3d412015-02-17 16:48:12 -08001103 if ping_result == main.TRUE:
1104 main.log.report( "Pingall Test in Reactive mode successful" )
1105 else:
1106 main.log.report( "Pingall Test in Reactive mode failed" )
1107
1108 main.step( "Disable Intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001109 uninstallResult = main.FALSE
1110
kelvin-onlab54400a92015-02-26 18:05:51 -08001111 pool = []
1112 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001113 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08001114 t = main.Thread(target=cli,threadID=threadID,
1115 name="featureUninstall",args=[feature])
1116 pool.append(t)
1117 t.start()
1118 threadID = threadID + 1
1119
1120 results = []
1121 for thread in pool:
1122 thread.join()
1123 results.append(thread.result)
1124 time2 = time.time()
1125
1126 if( all(result == main.TRUE for result in results) == False):
1127 main.log.info("Did not uninstall onos-app-ifwd feature properly")
1128 main.cleanup()
1129 main.exit()
1130 else:
1131 main.log.info("Successful feature:uninstall onos-app-ifwd")
1132 uninstallResult = main.TRUE
1133 main.log.info("Time for feature:uninstall onos-app-ifwd: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08001134
1135 # Waiting for reative flows to be cleared.
1136 time.sleep( 10 )
1137
1138 case11Result = installResult and ping_result and uninstallResult
1139 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
1140 onpass="Intent based Reactive forwarding Pingall test PASS",
1141 onfail="Intent based Reactive forwarding Pingall test FAIL" )
1142
1143 def CASE12( self, main ):
1144 """
1145 This test script Loads a new Topology (Chordal) on CHO setup and balances all switches
1146 """
1147 import re
1148 import time
1149 import copy
kelvin-onlab54400a92015-02-26 18:05:51 -08001150
Hari Krishna22c3d412015-02-17 16:48:12 -08001151
kelvin-onlab54400a92015-02-26 18:05:51 -08001152 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
Hari Krishna22c3d412015-02-17 16:48:12 -08001153 newTopo = main.params['TOPO2']['topo']
1154 main.numMNswitches = int ( main.params[ 'TOPO2' ][ 'numSwitches' ] )
1155 main.numMNlinks = int ( main.params[ 'TOPO2' ][ 'numLinks' ] )
1156 main.numMNhosts = int ( main.params[ 'TOPO2' ][ 'numHosts' ] )
kelvin-onlab54400a92015-02-26 18:05:51 -08001157 main.pingTimeout = 60
Hari Krishna22c3d412015-02-17 16:48:12 -08001158 main.log.report(
1159 "Load Chordal topology and Balance all Mininet switches across controllers" )
1160 main.log.report(
1161 "________________________________________________________________________" )
1162 # need to wait here for sometime until ONOS bootup
1163 time.sleep( 15 )
1164 main.case(
1165 "Assign and Balance all Mininet switches across controllers" )
1166 main.step( "Stop any previous Mininet network topology" )
1167 stopStatus = main.Mininet1.stopNet()
1168
1169 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
1170 main.step( "Stop ONOS on all Nodes" )
1171 stopResult = main.TRUE
1172 for i in range( 1, int( main.numCtrls ) + 1 ):
1173 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
1174 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
1175 sresult = main.ONOSbench.onosStop( ONOS_ip )
1176 utilities.assert_equals( expect=main.TRUE, actual=sresult,
1177 onpass="Test step PASS",
1178 onfail="Test step FAIL" )
1179 stopResult = ( stopResult and sresult )
1180
1181 main.step( "Start Mininet with Chordal topology" )
1182 startStatus = main.Mininet1.startNet(topoFile = newTopo)
1183
1184 main.step( "Assign switches to controllers" )
1185 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
1186 main.Mininet1.assignSwController(
1187 sw=str( i ),
1188 count=int( main.numCtrls ),
1189 ip1=main.ONOS1_ip,
1190 port1=main.ONOS1_port,
1191 ip2=main.ONOS2_ip,
1192 port2=main.ONOS2_port,
1193 ip3=main.ONOS3_ip,
1194 port3=main.ONOS3_port,
1195 ip4=main.ONOS4_ip,
1196 port4=main.ONOS4_port,
1197 ip5=main.ONOS5_ip,
1198 port5=main.ONOS5_port )
1199
1200 switch_mastership = main.TRUE
1201 for i in range( 1, ( main.numMNswitches + 1 ) ):
1202 response = main.Mininet1.getSwController( "s" + str( i ) )
1203 print( "Response is " + str( response ) )
1204 if re.search( "tcp:" + main.ONOS1_ip, response ):
1205 switch_mastership = switch_mastership and main.TRUE
1206 else:
1207 switch_mastership = main.FALSE
1208
1209 if switch_mastership == main.TRUE:
1210 main.log.report( "Controller assignment successfull" )
1211 else:
1212 main.log.report( "Controller assignment failed" )
1213 time.sleep( 5 )
1214
1215 main.step( "Start ONOS on all Nodes" )
1216 startResult = main.TRUE
1217 for i in range( 1, int( main.numCtrls ) + 1 ):
1218 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
1219 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
1220 sresult = main.ONOSbench.onosStart( ONOS_ip )
1221 utilities.assert_equals( expect=main.TRUE, actual=sresult,
1222 onpass="Test step PASS",
1223 onfail="Test step FAIL" )
1224 startResult = ( startResult and sresult )
1225
1226 main.step( "Start ONOS CLI on all nodes" )
1227 cliResult = main.TRUE
1228 #karafTimeout = "3600000" # This is not needed here as it is already set before.
1229 # need to wait here sometime for ONOS to bootup.
1230 time.sleep( 30 )
kelvin-onlab54400a92015-02-26 18:05:51 -08001231
1232 main.log.step(" Start ONOS cli using thread ")
kelvin-onlab54400a92015-02-26 18:05:51 -08001233 pool = []
1234 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001235 for i in range( int( main.numCtrls ) ):
1236 t = main.Thread(target=cli.startOnosCli,
1237 threadID=main.threadID,
1238 name="startOnosCli",
1239 args=[nodes[i].ip_address])
kelvin-onlab54400a92015-02-26 18:05:51 -08001240 pool.append(t)
1241 t.start()
1242 main.threadID = main.threadID + 1
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001243 for t in pool:
1244 t.join()
1245 cliResult = cliResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -08001246 time2 = time.time()
1247
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001248 if not cliResult:
kelvin-onlab54400a92015-02-26 18:05:51 -08001249 main.log.info("ONOS CLI did not start up properly")
1250 main.cleanup()
1251 main.exit()
1252 else:
1253 main.log.info("Successful CLI startup")
kelvin-onlab54400a92015-02-26 18:05:51 -08001254 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08001255
1256 main.step( "Balance devices across controllers" )
1257 for i in range( int( main.numCtrls ) ):
1258 balanceResult = main.ONOScli1.balanceMasters()
1259 # giving some breathing time for ONOS to complete re-balance
1260 time.sleep( 3 )
1261
1262 case12Result = ( startResult and cliResult )
1263 utilities.assert_equals(
1264 expect=main.TRUE,
1265 actual=case12Result,
1266 onpass="Starting new Chordal topology test PASS",
1267 onfail="Starting new Chordal topology test FAIL" )
1268
1269 def CASE13( self, main ):
1270 """
1271 This test script Loads a new Topology (Spine) on CHO setup and balances all switches
1272 """
1273 import re
1274 import time
1275 import copy
1276
1277 newTopo = main.params['TOPO3']['topo']
1278 main.numMNswitches = int ( main.params[ 'TOPO3' ][ 'numSwitches' ] )
1279 main.numMNlinks = int ( main.params[ 'TOPO3' ][ 'numLinks' ] )
1280 main.numMNhosts = int ( main.params[ 'TOPO3' ][ 'numHosts' ] )
kelvin-onlab54400a92015-02-26 18:05:51 -08001281 main.pingTimeout = 600
Hari Krishna22c3d412015-02-17 16:48:12 -08001282 main.log.report(
1283 "Load Spine and Leaf topology and Balance all Mininet switches across controllers" )
1284 main.log.report(
1285 "________________________________________________________________________" )
1286 # need to wait here for sometime until ONOS bootup
1287 time.sleep( 15 )
1288 main.case(
1289 "Assign and Balance all Mininet switches across controllers" )
1290 main.step( "Stop any previous Mininet network topology" )
1291 stopStatus = main.Mininet1.stopNet()
1292
1293 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
1294 main.step( "Stop ONOS on all Nodes" )
1295 stopResult = main.TRUE
1296 for i in range( 1, int( main.numCtrls ) + 1 ):
1297 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
1298 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
1299 sresult = main.ONOSbench.onosStop( ONOS_ip )
1300 utilities.assert_equals( expect=main.TRUE, actual=sresult,
1301 onpass="Test step PASS",
1302 onfail="Test step FAIL" )
1303 stopResult = ( stopResult and sresult )
1304
1305 main.step( "Start Mininet with Spine topology" )
1306 startStatus = main.Mininet1.startNet(topoFile = newTopo)
1307
1308 main.step( "Assign switches to controllers" )
1309 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
1310 main.Mininet1.assignSwController(
1311 sw=str( i ),
1312 count=int( main.numCtrls ),
1313 ip1=main.ONOS1_ip,
1314 port1=main.ONOS1_port,
1315 ip2=main.ONOS2_ip,
1316 port2=main.ONOS2_port,
1317 ip3=main.ONOS3_ip,
1318 port3=main.ONOS3_port,
1319 ip4=main.ONOS4_ip,
1320 port4=main.ONOS4_port,
1321 ip5=main.ONOS5_ip,
1322 port5=main.ONOS5_port )
1323
1324 switch_mastership = main.TRUE
1325 for i in range( 1, ( main.numMNswitches + 1 ) ):
1326 response = main.Mininet1.getSwController( "s" + str( i ) )
1327 print( "Response is " + str( response ) )
1328 if re.search( "tcp:" + main.ONOS1_ip, response ):
1329 switch_mastership = switch_mastership and main.TRUE
1330 else:
1331 switch_mastership = main.FALSE
1332
1333 if switch_mastership == main.TRUE:
1334 main.log.report( "Controller assignment successfull" )
1335 else:
1336 main.log.report( "Controller assignment failed" )
1337 time.sleep( 5 )
1338
1339 main.step( "Start ONOS on all Nodes" )
1340 startResult = main.TRUE
1341 for i in range( 1, int( main.numCtrls ) + 1 ):
1342 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
1343 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
1344 sresult = main.ONOSbench.onosStart( ONOS_ip )
1345 utilities.assert_equals( expect=main.TRUE, actual=sresult,
1346 onpass="Test step PASS",
1347 onfail="Test step FAIL" )
1348 startResult = ( startResult and sresult )
1349
1350 main.step( "Start ONOS CLI on all nodes" )
1351 cliResult = main.TRUE
1352 #karafTimeout = "3600000" # This is not needed here as it is already set before.
1353 # need to wait here sometime for ONOS to bootup.
1354 time.sleep( 30 )
kelvin-onlab54400a92015-02-26 18:05:51 -08001355
1356 main.log.step(" Start ONOS cli using thread ")
kelvin-onlab54400a92015-02-26 18:05:51 -08001357 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001358 for i in range( int( main.numCtrls ) ):
1359 t = main.Thread(target=cli.startOnosCli,
1360 threadID=main.threadID,
1361 name="startOnosCli",
1362 args=[nodes[i].ip_address])
kelvin-onlab54400a92015-02-26 18:05:51 -08001363 pool.append(t)
1364 t.start()
1365 main.threadID = main.threadID + 1
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001366 for t in pool:
1367 t.join()
1368 cliResult = cliResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -08001369 time2 = time.time()
1370
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001371 if not cliResult:
kelvin-onlab54400a92015-02-26 18:05:51 -08001372 main.log.info("ONOS CLI did not start up properly")
1373 main.cleanup()
1374 main.exit()
1375 else:
1376 main.log.info("Successful CLI startup")
kelvin-onlab54400a92015-02-26 18:05:51 -08001377 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
1378
1379 main.step( "Balance devices across controllers" )
1380 for i in range( int( main.numCtrls ) ):
1381 balanceResult = main.ONOScli1.balanceMasters()
1382 # giving some breathing time for ONOS to complete re-balance
1383 time.sleep( 3 )
Hari Krishna22c3d412015-02-17 16:48:12 -08001384
1385 main.step( "Balance devices across controllers" )
1386 for i in range( int( main.numCtrls ) ):
1387 balanceResult = main.ONOScli1.balanceMasters()
1388 # giving some breathing time for ONOS to complete re-balance
1389 time.sleep( 3 )
1390
1391 case13Result = ( startResult and cliResult )
1392 utilities.assert_equals(
1393 expect=main.TRUE,
1394 actual=case13Result,
1395 onpass="Starting new Spine topology test PASS",
1396 onfail="Starting new Spine topology test FAIL" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001397
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001398 def CASE14( self ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001399 """
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001400 Install 300 host intents and verify ping all for Chordal Topology
kelvin-onlab54400a92015-02-26 18:05:51 -08001401 """
1402 main.log.report( "Add 300 host intents and verify pingall" )
1403 main.log.report( "_______________________________________" )
1404 import itertools
1405
1406 main.case( "Install 300 host intents" )
1407 main.step( "Add host Intents" )
1408 intentResult = main.TRUE
1409 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
1410
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001411 intentIdList = []
kelvin-onlab54400a92015-02-26 18:05:51 -08001412 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001413
1414 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001415 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001416 for cli in main.CLIs:
1417 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001418 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001419 t = main.Thread( target=cli.addHostIntent,
1420 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -08001421 name="addHostIntent",
1422 args=[hostCombos[i][0],hostCombos[i][1]])
1423 pool.append(t)
1424 t.start()
1425 i = i + 1
1426 main.threadID = main.threadID + 1
kelvin-onlab54400a92015-02-26 18:05:51 -08001427 for thread in pool:
1428 thread.join()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001429 intentIdList.append(thread.result)
kelvin-onlab54400a92015-02-26 18:05:51 -08001430 time2 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08001431 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001432 intentResult = main.TRUE
1433 intentsJson = main.ONOScli2.intents()
1434 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1435 intentsJson = intentsJson)
1436 print getIntentStateResult
1437
kelvin-onlab54400a92015-02-26 18:05:51 -08001438 main.step( "Verify Ping across all hosts" )
1439 pingResult = main.FALSE
1440 time1 = time.time()
1441 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1442 time2 = time.time()
1443 timeDiff = round( ( time2 - time1 ), 2 )
1444 main.log.report(
1445 "Time taken for Ping All: " +
1446 str( timeDiff ) +
1447 " seconds" )
1448 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1449 onpass="PING ALL PASS",
1450 onfail="PING ALL FAIL" )
1451
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001452 case14Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -08001453
kelvin-onlab54400a92015-02-26 18:05:51 -08001454 utilities.assert_equals(
1455 expect=main.TRUE,
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001456 actual=case14Result,
kelvin-onlab54400a92015-02-26 18:05:51 -08001457 onpass="Install 300 Host Intents and Ping All test PASS",
1458 onfail="Install 300 Host Intents and Ping All test FAIL" )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001459
1460 def CASE15( self ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001461 """
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001462 Install 300 host intents and verify ping all for Spine Topology
kelvin-onlab54400a92015-02-26 18:05:51 -08001463 """
1464 main.log.report( "Add 300 host intents and verify pingall" )
1465 main.log.report( "_______________________________________" )
1466 import itertools
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001467
kelvin-onlab54400a92015-02-26 18:05:51 -08001468 main.case( "Install 300 host intents" )
1469 main.step( "Add host Intents" )
1470 intentResult = main.TRUE
1471 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
1472
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001473 intentIdList = []
kelvin-onlab54400a92015-02-26 18:05:51 -08001474 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001475 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001476 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001477 for cli in main.CLIs:
1478 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001479 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001480 t = main.Thread( target=cli.addHostIntent,
1481 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -08001482 name="addHostIntent",
1483 args=[hostCombos[i][0],hostCombos[i][1]])
1484 pool.append(t)
1485 t.start()
1486 i = i + 1
1487 main.threadID = main.threadID + 1
kelvin-onlab54400a92015-02-26 18:05:51 -08001488 for thread in pool:
1489 thread.join()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001490 intentIdList.append(thread.result)
kelvin-onlab54400a92015-02-26 18:05:51 -08001491 time2 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08001492 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001493 intentResult = main.TRUE
1494 intentsJson = main.ONOScli2.intents()
1495 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1496 intentsJson = intentsJson)
1497 print getIntentStateResult
1498
kelvin-onlab54400a92015-02-26 18:05:51 -08001499 main.step( "Verify Ping across all hosts" )
1500 pingResult = main.FALSE
1501 time1 = time.time()
1502 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1503 time2 = time.time()
1504 timeDiff = round( ( time2 - time1 ), 2 )
1505 main.log.report(
1506 "Time taken for Ping All: " +
1507 str( timeDiff ) +
1508 " seconds" )
1509 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1510 onpass="PING ALL PASS",
1511 onfail="PING ALL FAIL" )
1512
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001513 case15Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -08001514
kelvin-onlab54400a92015-02-26 18:05:51 -08001515 utilities.assert_equals(
1516 expect=main.TRUE,
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001517 actual=case15Result,
kelvin-onlab54400a92015-02-26 18:05:51 -08001518 onpass="Install 300 Host Intents and Ping All test PASS",
1519 onfail="Install 300 Host Intents and Ping All test FAIL" )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001520