blob: dc5e5ce3a2f29e30a0b3bb3fdb7f89beb94f7bd5 [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" )
kelvin-onlab01f1b2c2015-03-11 10:41:06 -0700166 time.sleep(30)
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-onlabc3ab3012015-03-10 15:04:46 -0700943 def CASE90( self ):
944 """
945 Install single-multi point intents and verify Ping all works
946 for att topology
947 """
948 import copy
949 main.log.report( "Install single-multi point intents and verify Ping all" )
950 main.log.report( "___________________________________________" )
951 main.case( "Install single-multi point intents and Ping all" )
952 deviceLinksCopy = copy.copy( main.deviceLinks )
953 main.step( "Install single-multi point intents" )
954 for i in range( len( deviceLinksCopy ) ):
955 pointLink = str(
956 deviceLinksCopy[ i ] ).replace(
957 "src=",
958 "" ).replace(
959 "dst=",
960 "" ).split( ',' )
961 point1 = pointLink[ 0 ].split( '/' )
962 point2 = pointLink[ 1 ].split( '/' )
963 installResult = main.ONOScli1.addPointIntent(
964 point1[ 0 ], point2[ 0 ], int(
965 point1[ 1 ] ), int(
966 point2[ 1 ] ) )
967 if installResult == main.TRUE:
968 print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
969
970 main.step( "Obtain the intent id's" )
971 intentsList = main.ONOScli1.getAllIntentIds()
972 ansi_escape = re.compile( r'\x1b[^m]*m' )
973 intentsList = ansi_escape.sub( '', intentsList )
974 intentsList = intentsList.replace(
975 " onos:intents | grep id=",
976 "" ).replace(
977 "id=",
978 "" ).replace(
979 "\r\r",
980 "" )
981 intentsList = intentsList.splitlines()
982 intentsList = intentsList[ 1: ]
983 intentIdList = []
984 for i in range( len( intentsList ) ):
985 intentsTemp = intentsList[ i ].split( ',' )
986 intentIdList.append( intentsTemp[ 0 ] )
987 print "Intent IDs: ", intentIdList
988 print "Total Intents installed: ", len( intentIdList )
989
990 main.step( "Verify Ping across all hosts" )
991 pingResult = main.FALSE
992 time1 = time.time()
993 pingResult = main.Mininet1.pingall()
994 time2 = time.time()
995 timeDiff = round( ( time2 - time1 ), 2 )
996 main.log.report(
997 "Time taken for Ping All: " +
998 str( timeDiff ) +
999 " seconds" )
1000 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1001 onpass="PING ALL PASS",
1002 onfail="PING ALL FAIL" )
1003
1004 case8_result = installResult and pingResult
1005 utilities.assert_equals(
1006 expect=main.TRUE,
1007 actual=case8_result,
1008 onpass="Ping all test after Point intents addition successful",
1009 onfail="Ping all test after Point intents addition failed" )
1010
1011 def CASE91( self ):
1012 """
1013 Install single-multi point intents and verify Ping all works
1014 """
1015 import copy
1016 main.log.report( "Install single-multi point intents and verify Ping all" )
1017 main.log.report( "___________________________________________" )
1018 main.case( "Install single-multi point intents and Ping all" )
1019 deviceLinksCopy = copy.copy( main.deviceLinks )
1020 main.step( "Install single-multi point intents" )
1021 for i in range( len( deviceLinksCopy ) ):
1022 pointLink = str(
1023 deviceLinksCopy[ i ] ).replace(
1024 "src=",
1025 "" ).replace(
1026 "dst=",
1027 "" ).split( ',' )
1028 point1 = pointLink[ 0 ].split( '/' )
1029 point2 = pointLink[ 1 ].split( '/' )
1030 installResult = main.ONOScli1.addPointIntent(
1031 point1[ 0 ], point2[ 0 ], int(
1032 point1[ 1 ] ), int(
1033 point2[ 1 ] ) )
1034 if installResult == main.TRUE:
1035 print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
1036
1037 main.step( "Obtain the intent id's" )
1038 intentsList = main.ONOScli1.getAllIntentIds()
1039 ansi_escape = re.compile( r'\x1b[^m]*m' )
1040 intentsList = ansi_escape.sub( '', intentsList )
1041 intentsList = intentsList.replace(
1042 " onos:intents | grep id=",
1043 "" ).replace(
1044 "id=",
1045 "" ).replace(
1046 "\r\r",
1047 "" )
1048 intentsList = intentsList.splitlines()
1049 intentsList = intentsList[ 1: ]
1050 intentIdList = []
1051 for i in range( len( intentsList ) ):
1052 intentsTemp = intentsList[ i ].split( ',' )
1053 intentIdList.append( intentsTemp[ 0 ] )
1054 print "Intent IDs: ", intentIdList
1055 print "Total Intents installed: ", len( intentIdList )
1056
1057 main.step( "Verify Ping across all hosts" )
1058 pingResult = main.FALSE
1059 time1 = time.time()
1060 pingResult = main.Mininet1.pingall()
1061 time2 = time.time()
1062 timeDiff = round( ( time2 - time1 ), 2 )
1063 main.log.report(
1064 "Time taken for Ping All: " +
1065 str( timeDiff ) +
1066 " seconds" )
1067 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1068 onpass="PING ALL PASS",
1069 onfail="PING ALL FAIL" )
1070
1071 case8_result = installResult and pingResult
1072 utilities.assert_equals(
1073 expect=main.TRUE,
1074 actual=case8_result,
1075 onpass="Ping all test after Point intents addition successful",
1076 onfail="Ping all test after Point intents addition failed" )
1077
1078 def CASE92( self ):
1079 """
1080 Install 114 point intents and verify Ping all works
1081 """
1082 import copy
1083 main.log.report( "Install 114 point intents and verify Ping all" )
1084 main.log.report( "___________________________________________" )
1085 main.case( "Install 114 point intents and Ping all" )
1086 deviceLinksCopy = copy.copy( main.deviceLinks )
1087 main.step( "Install 114 point intents" )
1088 for i in range( len( deviceLinksCopy ) ):
1089 pointLink = str(
1090 deviceLinksCopy[ i ] ).replace(
1091 "src=",
1092 "" ).replace(
1093 "dst=",
1094 "" ).split( ',' )
1095 point1 = pointLink[ 0 ].split( '/' )
1096 point2 = pointLink[ 1 ].split( '/' )
1097 installResult = main.ONOScli1.addPointIntent(
1098 point1[ 0 ], point2[ 0 ], int(
1099 point1[ 1 ] ), int(
1100 point2[ 1 ] ) )
1101 if installResult == main.TRUE:
1102 print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
1103
1104 main.step( "Obtain the intent id's" )
1105 intentsList = main.ONOScli1.getAllIntentIds()
1106 ansi_escape = re.compile( r'\x1b[^m]*m' )
1107 intentsList = ansi_escape.sub( '', intentsList )
1108 intentsList = intentsList.replace(
1109 " onos:intents | grep id=",
1110 "" ).replace(
1111 "id=",
1112 "" ).replace(
1113 "\r\r",
1114 "" )
1115 intentsList = intentsList.splitlines()
1116 intentsList = intentsList[ 1: ]
1117 intentIdList = []
1118 for i in range( len( intentsList ) ):
1119 intentsTemp = intentsList[ i ].split( ',' )
1120 intentIdList.append( intentsTemp[ 0 ] )
1121 print "Intent IDs: ", intentIdList
1122 print "Total Intents installed: ", len( intentIdList )
1123
1124 main.step( "Verify Ping across all hosts" )
1125 pingResult = main.FALSE
1126 time1 = time.time()
1127 pingResult = main.Mininet1.pingall()
1128 time2 = time.time()
1129 timeDiff = round( ( time2 - time1 ), 2 )
1130 main.log.report(
1131 "Time taken for Ping All: " +
1132 str( timeDiff ) +
1133 " seconds" )
1134 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1135 onpass="PING ALL PASS",
1136 onfail="PING ALL FAIL" )
1137
1138 case8_result = installResult and pingResult
1139 utilities.assert_equals(
1140 expect=main.TRUE,
1141 actual=case8_result,
1142 onpass="Ping all test after Point intents addition successful",
1143 onfail="Ping all test after Point intents addition failed" )
1144
kelvin-onlab8a832582015-01-16 17:06:11 -08001145 def CASE10( self ):
kelvin-onlab7642bb12015-02-27 13:48:17 -08001146 import time
kelvin-onlab8a832582015-01-16 17:06:11 -08001147 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001148 Remove all Intents
kelvin-onlab8a832582015-01-16 17:06:11 -08001149 """
1150 main.log.report( "Remove all intents that were installed previously" )
1151 main.log.report( "______________________________________________" )
1152 main.log.info( "Remove all intents" )
1153 main.case( "Removing intents" )
1154 main.step( "Obtain the intent id's first" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001155 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -08001156 ansi_escape = re.compile( r'\x1b[^m]*m' )
1157 intentsList = ansi_escape.sub( '', intentsList )
1158 intentsList = intentsList.replace(
1159 " onos:intents | grep id=",
1160 "" ).replace(
1161 "id=",
1162 "" ).replace(
1163 "\r\r",
1164 "" )
1165 intentsList = intentsList.splitlines()
1166 intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001167 intentIdList = []
1168 step1Result = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001169 moreIntents = main.TRUE
1170 removeIntentCount = 0
1171 print "Current number of intents" , len(intentsList)
kelvin-onlab8a832582015-01-16 17:06:11 -08001172 if ( len( intentsList ) > 1 ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001173 results = main.TRUE
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07001174 main.log.info("Removing intent...")
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001175 while moreIntents:
1176 removeIntentCount = removeIntentCount + 1
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001177 intentsList1 = main.ONOScli1.getAllIntentIds()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07001178 if len( intentsList1 ) == 0:
1179 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001180 ansi_escape = re.compile( r'\x1b[^m]*m' )
1181 intentsList1 = ansi_escape.sub( '', intentsList1 )
1182 intentsList1 = intentsList1.replace(
1183 " onos:intents | grep id=",
1184 "" ).replace(
1185 " state=",
1186 "" ).replace(
1187 "\r\r",
1188 "" )
1189 intentsList1 = intentsList1.splitlines()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07001190 intentsList1 = intentsList1[ 1: ]
1191 print "Round %d intents to remove: " %(removeIntentCount)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001192 print intentsList1
1193 intentIdList1 = []
1194 if ( len( intentsList1 ) > 1 ):
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07001195 moreIntents = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001196 for i in range( len( intentsList1 ) ):
1197 intentsTemp1 = intentsList1[ i ].split( ',' )
1198 intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] )
1199 print "Leftover Intent IDs: ", intentIdList1
1200 print len(intentIdList1)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001201 for intent in intentIdList1:
kelvin-onlab36c02b12015-03-11 11:25:55 -07001202 main.CLIs[0].removeIntent(intent,'org.onosproject.cli',True,False)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001203 else:
1204 break
1205 if removeIntentCount == 5:
1206 break
kelvin-onlab36c02b12015-03-11 11:25:55 -07001207
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001208 else:
1209 print "There are no more intents that need to be removed"
1210 step1Result = main.TRUE
1211 else:
1212 print "No Intent IDs found in Intents list: ", intentsList
1213 step1Result = main.FALSE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001214
kelvin-onlabdc8719b2015-03-02 14:01:52 -08001215 print main.ONOScli1.intents()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07001216 # time.sleep(300)
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001217 caseResult10 = step1Result
1218 utilities.assert_equals( expect=main.TRUE, actual=caseResult10,
kelvin-onlab8a832582015-01-16 17:06:11 -08001219 onpass="Intent removal test successful",
1220 onfail="Intent removal test failed" )
Hari Krishna22c3d412015-02-17 16:48:12 -08001221
1222 def CASE11( self, main ):
1223 """
1224 Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it
1225 """
1226 import re
1227 import copy
1228 import time
1229
kelvin-onlab54400a92015-02-26 18:05:51 -08001230 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
1231 threadID = 0
1232
Hari Krishna22c3d412015-02-17 16:48:12 -08001233 main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" )
1234 main.log.report( "_____________________________________________________" )
1235 main.case( "Enable Intent based Reactive forwarding and Verify ping all" )
1236 main.step( "Enable intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001237 installResult = main.FALSE
1238 feature = "onos-app-ifwd"
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001239
kelvin-onlab54400a92015-02-26 18:05:51 -08001240 pool = []
1241 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001242 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08001243 t = main.Thread(target=cli,threadID=threadID,
1244 name="featureInstall",args=[feature])
1245 pool.append(t)
1246 t.start()
1247 threadID = threadID + 1
1248
1249 results = []
1250 for thread in pool:
1251 thread.join()
1252 results.append(thread.result)
1253 time2 = time.time()
1254
1255 if( all(result == main.TRUE for result in results) == False):
1256 main.log.info("Did not install onos-app-ifwd feature properly")
1257 main.cleanup()
1258 main.exit()
1259 else:
1260 main.log.info("Successful feature:install onos-app-ifwd")
1261 installResult = main.TRUE
1262 main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1))
1263
Hari Krishna22c3d412015-02-17 16:48:12 -08001264 main.step( "Verify Pingall" )
1265 ping_result = main.FALSE
1266 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08001267 ping_result = main.Mininet1.pingall(timeout=600)
Hari Krishna22c3d412015-02-17 16:48:12 -08001268 time2 = time.time()
1269 timeDiff = round( ( time2 - time1 ), 2 )
1270 main.log.report(
1271 "Time taken for Ping All: " +
1272 str( timeDiff ) +
1273 " seconds" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001274
Hari Krishna22c3d412015-02-17 16:48:12 -08001275 if ping_result == main.TRUE:
1276 main.log.report( "Pingall Test in Reactive mode successful" )
1277 else:
1278 main.log.report( "Pingall Test in Reactive mode failed" )
1279
1280 main.step( "Disable Intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001281 uninstallResult = main.FALSE
1282
kelvin-onlab54400a92015-02-26 18:05:51 -08001283 pool = []
1284 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001285 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08001286 t = main.Thread(target=cli,threadID=threadID,
1287 name="featureUninstall",args=[feature])
1288 pool.append(t)
1289 t.start()
1290 threadID = threadID + 1
1291
1292 results = []
1293 for thread in pool:
1294 thread.join()
1295 results.append(thread.result)
1296 time2 = time.time()
1297
1298 if( all(result == main.TRUE for result in results) == False):
1299 main.log.info("Did not uninstall onos-app-ifwd feature properly")
1300 main.cleanup()
1301 main.exit()
1302 else:
1303 main.log.info("Successful feature:uninstall onos-app-ifwd")
1304 uninstallResult = main.TRUE
1305 main.log.info("Time for feature:uninstall onos-app-ifwd: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08001306
1307 # Waiting for reative flows to be cleared.
1308 time.sleep( 10 )
1309
1310 case11Result = installResult and ping_result and uninstallResult
1311 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
1312 onpass="Intent based Reactive forwarding Pingall test PASS",
1313 onfail="Intent based Reactive forwarding Pingall test FAIL" )
1314
1315 def CASE12( self, main ):
1316 """
1317 This test script Loads a new Topology (Chordal) on CHO setup and balances all switches
1318 """
1319 import re
1320 import time
1321 import copy
kelvin-onlab54400a92015-02-26 18:05:51 -08001322
Hari Krishna22c3d412015-02-17 16:48:12 -08001323
kelvin-onlab54400a92015-02-26 18:05:51 -08001324 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
Hari Krishna22c3d412015-02-17 16:48:12 -08001325 newTopo = main.params['TOPO2']['topo']
1326 main.numMNswitches = int ( main.params[ 'TOPO2' ][ 'numSwitches' ] )
1327 main.numMNlinks = int ( main.params[ 'TOPO2' ][ 'numLinks' ] )
1328 main.numMNhosts = int ( main.params[ 'TOPO2' ][ 'numHosts' ] )
kelvin-onlab54400a92015-02-26 18:05:51 -08001329 main.pingTimeout = 60
Hari Krishna22c3d412015-02-17 16:48:12 -08001330 main.log.report(
1331 "Load Chordal topology and Balance all Mininet switches across controllers" )
1332 main.log.report(
1333 "________________________________________________________________________" )
1334 # need to wait here for sometime until ONOS bootup
1335 time.sleep( 15 )
1336 main.case(
1337 "Assign and Balance all Mininet switches across controllers" )
1338 main.step( "Stop any previous Mininet network topology" )
1339 stopStatus = main.Mininet1.stopNet()
1340
1341 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
1342 main.step( "Stop ONOS on all Nodes" )
1343 stopResult = main.TRUE
1344 for i in range( 1, int( main.numCtrls ) + 1 ):
1345 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
1346 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
1347 sresult = main.ONOSbench.onosStop( ONOS_ip )
1348 utilities.assert_equals( expect=main.TRUE, actual=sresult,
1349 onpass="Test step PASS",
1350 onfail="Test step FAIL" )
1351 stopResult = ( stopResult and sresult )
1352
1353 main.step( "Start Mininet with Chordal topology" )
1354 startStatus = main.Mininet1.startNet(topoFile = newTopo)
1355
1356 main.step( "Assign switches to controllers" )
1357 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
1358 main.Mininet1.assignSwController(
1359 sw=str( i ),
1360 count=int( main.numCtrls ),
1361 ip1=main.ONOS1_ip,
1362 port1=main.ONOS1_port,
1363 ip2=main.ONOS2_ip,
1364 port2=main.ONOS2_port,
1365 ip3=main.ONOS3_ip,
1366 port3=main.ONOS3_port,
1367 ip4=main.ONOS4_ip,
1368 port4=main.ONOS4_port,
1369 ip5=main.ONOS5_ip,
1370 port5=main.ONOS5_port )
1371
1372 switch_mastership = main.TRUE
1373 for i in range( 1, ( main.numMNswitches + 1 ) ):
1374 response = main.Mininet1.getSwController( "s" + str( i ) )
1375 print( "Response is " + str( response ) )
1376 if re.search( "tcp:" + main.ONOS1_ip, response ):
1377 switch_mastership = switch_mastership and main.TRUE
1378 else:
1379 switch_mastership = main.FALSE
1380
1381 if switch_mastership == main.TRUE:
1382 main.log.report( "Controller assignment successfull" )
1383 else:
1384 main.log.report( "Controller assignment failed" )
1385 time.sleep( 5 )
1386
1387 main.step( "Start ONOS on all Nodes" )
1388 startResult = main.TRUE
1389 for i in range( 1, int( main.numCtrls ) + 1 ):
1390 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
1391 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
1392 sresult = main.ONOSbench.onosStart( ONOS_ip )
1393 utilities.assert_equals( expect=main.TRUE, actual=sresult,
1394 onpass="Test step PASS",
1395 onfail="Test step FAIL" )
1396 startResult = ( startResult and sresult )
1397
1398 main.step( "Start ONOS CLI on all nodes" )
1399 cliResult = main.TRUE
1400 #karafTimeout = "3600000" # This is not needed here as it is already set before.
1401 # need to wait here sometime for ONOS to bootup.
1402 time.sleep( 30 )
kelvin-onlab54400a92015-02-26 18:05:51 -08001403
1404 main.log.step(" Start ONOS cli using thread ")
kelvin-onlab54400a92015-02-26 18:05:51 -08001405 pool = []
1406 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001407 for i in range( int( main.numCtrls ) ):
1408 t = main.Thread(target=cli.startOnosCli,
1409 threadID=main.threadID,
1410 name="startOnosCli",
1411 args=[nodes[i].ip_address])
kelvin-onlab54400a92015-02-26 18:05:51 -08001412 pool.append(t)
1413 t.start()
1414 main.threadID = main.threadID + 1
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001415 for t in pool:
1416 t.join()
1417 cliResult = cliResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -08001418 time2 = time.time()
1419
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001420 if not cliResult:
kelvin-onlab54400a92015-02-26 18:05:51 -08001421 main.log.info("ONOS CLI did not start up properly")
1422 main.cleanup()
1423 main.exit()
1424 else:
1425 main.log.info("Successful CLI startup")
kelvin-onlab54400a92015-02-26 18:05:51 -08001426 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08001427
1428 main.step( "Balance devices across controllers" )
1429 for i in range( int( main.numCtrls ) ):
1430 balanceResult = main.ONOScli1.balanceMasters()
1431 # giving some breathing time for ONOS to complete re-balance
1432 time.sleep( 3 )
1433
1434 case12Result = ( startResult and cliResult )
1435 utilities.assert_equals(
1436 expect=main.TRUE,
1437 actual=case12Result,
1438 onpass="Starting new Chordal topology test PASS",
1439 onfail="Starting new Chordal topology test FAIL" )
1440
1441 def CASE13( self, main ):
1442 """
1443 This test script Loads a new Topology (Spine) on CHO setup and balances all switches
1444 """
1445 import re
1446 import time
1447 import copy
1448
1449 newTopo = main.params['TOPO3']['topo']
1450 main.numMNswitches = int ( main.params[ 'TOPO3' ][ 'numSwitches' ] )
1451 main.numMNlinks = int ( main.params[ 'TOPO3' ][ 'numLinks' ] )
1452 main.numMNhosts = int ( main.params[ 'TOPO3' ][ 'numHosts' ] )
kelvin-onlab54400a92015-02-26 18:05:51 -08001453 main.pingTimeout = 600
Hari Krishna22c3d412015-02-17 16:48:12 -08001454 main.log.report(
1455 "Load Spine and Leaf topology and Balance all Mininet switches across controllers" )
1456 main.log.report(
1457 "________________________________________________________________________" )
1458 # need to wait here for sometime until ONOS bootup
1459 time.sleep( 15 )
1460 main.case(
1461 "Assign and Balance all Mininet switches across controllers" )
1462 main.step( "Stop any previous Mininet network topology" )
1463 stopStatus = main.Mininet1.stopNet()
1464
1465 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
1466 main.step( "Stop ONOS on all Nodes" )
1467 stopResult = main.TRUE
1468 for i in range( 1, int( main.numCtrls ) + 1 ):
1469 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
1470 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
1471 sresult = main.ONOSbench.onosStop( ONOS_ip )
1472 utilities.assert_equals( expect=main.TRUE, actual=sresult,
1473 onpass="Test step PASS",
1474 onfail="Test step FAIL" )
1475 stopResult = ( stopResult and sresult )
1476
1477 main.step( "Start Mininet with Spine topology" )
1478 startStatus = main.Mininet1.startNet(topoFile = newTopo)
1479
1480 main.step( "Assign switches to controllers" )
1481 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
1482 main.Mininet1.assignSwController(
1483 sw=str( i ),
1484 count=int( main.numCtrls ),
1485 ip1=main.ONOS1_ip,
1486 port1=main.ONOS1_port,
1487 ip2=main.ONOS2_ip,
1488 port2=main.ONOS2_port,
1489 ip3=main.ONOS3_ip,
1490 port3=main.ONOS3_port,
1491 ip4=main.ONOS4_ip,
1492 port4=main.ONOS4_port,
1493 ip5=main.ONOS5_ip,
1494 port5=main.ONOS5_port )
1495
1496 switch_mastership = main.TRUE
1497 for i in range( 1, ( main.numMNswitches + 1 ) ):
1498 response = main.Mininet1.getSwController( "s" + str( i ) )
1499 print( "Response is " + str( response ) )
1500 if re.search( "tcp:" + main.ONOS1_ip, response ):
1501 switch_mastership = switch_mastership and main.TRUE
1502 else:
1503 switch_mastership = main.FALSE
1504
1505 if switch_mastership == main.TRUE:
1506 main.log.report( "Controller assignment successfull" )
1507 else:
1508 main.log.report( "Controller assignment failed" )
1509 time.sleep( 5 )
1510
1511 main.step( "Start ONOS on all Nodes" )
1512 startResult = main.TRUE
1513 for i in range( 1, int( main.numCtrls ) + 1 ):
1514 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
1515 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
1516 sresult = main.ONOSbench.onosStart( ONOS_ip )
1517 utilities.assert_equals( expect=main.TRUE, actual=sresult,
1518 onpass="Test step PASS",
1519 onfail="Test step FAIL" )
1520 startResult = ( startResult and sresult )
1521
1522 main.step( "Start ONOS CLI on all nodes" )
1523 cliResult = main.TRUE
1524 #karafTimeout = "3600000" # This is not needed here as it is already set before.
1525 # need to wait here sometime for ONOS to bootup.
1526 time.sleep( 30 )
kelvin-onlab54400a92015-02-26 18:05:51 -08001527
1528 main.log.step(" Start ONOS cli using thread ")
kelvin-onlab54400a92015-02-26 18:05:51 -08001529 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001530 for i in range( int( main.numCtrls ) ):
1531 t = main.Thread(target=cli.startOnosCli,
1532 threadID=main.threadID,
1533 name="startOnosCli",
1534 args=[nodes[i].ip_address])
kelvin-onlab54400a92015-02-26 18:05:51 -08001535 pool.append(t)
1536 t.start()
1537 main.threadID = main.threadID + 1
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001538 for t in pool:
1539 t.join()
1540 cliResult = cliResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -08001541 time2 = time.time()
1542
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001543 if not cliResult:
kelvin-onlab54400a92015-02-26 18:05:51 -08001544 main.log.info("ONOS CLI did not start up properly")
1545 main.cleanup()
1546 main.exit()
1547 else:
1548 main.log.info("Successful CLI startup")
kelvin-onlab54400a92015-02-26 18:05:51 -08001549 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
1550
1551 main.step( "Balance devices across controllers" )
1552 for i in range( int( main.numCtrls ) ):
1553 balanceResult = main.ONOScli1.balanceMasters()
1554 # giving some breathing time for ONOS to complete re-balance
1555 time.sleep( 3 )
Hari Krishna22c3d412015-02-17 16:48:12 -08001556
1557 main.step( "Balance devices across controllers" )
1558 for i in range( int( main.numCtrls ) ):
1559 balanceResult = main.ONOScli1.balanceMasters()
1560 # giving some breathing time for ONOS to complete re-balance
1561 time.sleep( 3 )
1562
1563 case13Result = ( startResult and cliResult )
1564 utilities.assert_equals(
1565 expect=main.TRUE,
1566 actual=case13Result,
1567 onpass="Starting new Spine topology test PASS",
1568 onfail="Starting new Spine topology test FAIL" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001569
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001570 def CASE14( self ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001571 """
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001572 Install 300 host intents and verify ping all for Chordal Topology
kelvin-onlab54400a92015-02-26 18:05:51 -08001573 """
1574 main.log.report( "Add 300 host intents and verify pingall" )
1575 main.log.report( "_______________________________________" )
1576 import itertools
1577
1578 main.case( "Install 300 host intents" )
1579 main.step( "Add host Intents" )
1580 intentResult = main.TRUE
1581 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
1582
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001583 intentIdList = []
kelvin-onlab54400a92015-02-26 18:05:51 -08001584 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001585
1586 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001587 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001588 for cli in main.CLIs:
1589 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001590 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001591 t = main.Thread( target=cli.addHostIntent,
1592 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -08001593 name="addHostIntent",
1594 args=[hostCombos[i][0],hostCombos[i][1]])
1595 pool.append(t)
1596 t.start()
1597 i = i + 1
1598 main.threadID = main.threadID + 1
kelvin-onlab54400a92015-02-26 18:05:51 -08001599 for thread in pool:
1600 thread.join()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001601 intentIdList.append(thread.result)
kelvin-onlab54400a92015-02-26 18:05:51 -08001602 time2 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08001603 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001604 intentResult = main.TRUE
1605 intentsJson = main.ONOScli2.intents()
1606 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1607 intentsJson = intentsJson)
1608 print getIntentStateResult
1609
kelvin-onlab54400a92015-02-26 18:05:51 -08001610 main.step( "Verify Ping across all hosts" )
1611 pingResult = main.FALSE
1612 time1 = time.time()
1613 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1614 time2 = time.time()
1615 timeDiff = round( ( time2 - time1 ), 2 )
1616 main.log.report(
1617 "Time taken for Ping All: " +
1618 str( timeDiff ) +
1619 " seconds" )
1620 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1621 onpass="PING ALL PASS",
1622 onfail="PING ALL FAIL" )
1623
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001624 case14Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -08001625
kelvin-onlab54400a92015-02-26 18:05:51 -08001626 utilities.assert_equals(
1627 expect=main.TRUE,
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001628 actual=case14Result,
kelvin-onlab54400a92015-02-26 18:05:51 -08001629 onpass="Install 300 Host Intents and Ping All test PASS",
1630 onfail="Install 300 Host Intents and Ping All test FAIL" )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001631
1632 def CASE15( self ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001633 """
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001634 Install 300 host intents and verify ping all for Spine Topology
kelvin-onlab54400a92015-02-26 18:05:51 -08001635 """
1636 main.log.report( "Add 300 host intents and verify pingall" )
1637 main.log.report( "_______________________________________" )
1638 import itertools
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001639
kelvin-onlab54400a92015-02-26 18:05:51 -08001640 main.case( "Install 300 host intents" )
1641 main.step( "Add host Intents" )
1642 intentResult = main.TRUE
1643 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
1644
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001645 intentIdList = []
kelvin-onlab54400a92015-02-26 18:05:51 -08001646 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001647 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001648 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001649 for cli in main.CLIs:
1650 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001651 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001652 t = main.Thread( target=cli.addHostIntent,
1653 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -08001654 name="addHostIntent",
1655 args=[hostCombos[i][0],hostCombos[i][1]])
1656 pool.append(t)
1657 t.start()
1658 i = i + 1
1659 main.threadID = main.threadID + 1
kelvin-onlab54400a92015-02-26 18:05:51 -08001660 for thread in pool:
1661 thread.join()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001662 intentIdList.append(thread.result)
kelvin-onlab54400a92015-02-26 18:05:51 -08001663 time2 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08001664 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001665 intentResult = main.TRUE
1666 intentsJson = main.ONOScli2.intents()
1667 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1668 intentsJson = intentsJson)
1669 print getIntentStateResult
1670
kelvin-onlab54400a92015-02-26 18:05:51 -08001671 main.step( "Verify Ping across all hosts" )
1672 pingResult = main.FALSE
1673 time1 = time.time()
1674 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1675 time2 = time.time()
1676 timeDiff = round( ( time2 - time1 ), 2 )
1677 main.log.report(
1678 "Time taken for Ping All: " +
1679 str( timeDiff ) +
1680 " seconds" )
1681 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1682 onpass="PING ALL PASS",
1683 onfail="PING ALL FAIL" )
1684
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001685 case15Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -08001686
kelvin-onlab54400a92015-02-26 18:05:51 -08001687 utilities.assert_equals(
1688 expect=main.TRUE,
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001689 actual=case15Result,
kelvin-onlab54400a92015-02-26 18:05:51 -08001690 onpass="Install 300 Host Intents and Ping All test PASS",
1691 onfail="Install 300 Host Intents and Ping All test FAIL" )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001692
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001693