blob: 93dc11b67150845fb2ca38fd0e405b2f0756b396 [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 Krishnaef1bd4e2015-03-12 16:55:30 -0700252 numOnosDevices = topology_result[ 'deviceCount' ]
253 numOnosLinks = topology_result[ 'linkCount' ]
254 print numOnosDevices
255 print numOnosLinks
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800256
kelvin-onlab54400a92015-02-26 18:05:51 -0800257 if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks >= int(numOnosLinks) ) ):
Hari Krishna22c3d412015-02-17 16:48:12 -0800258 main.step( "Store Device DPIDs" )
259 for i in range( 1, (main.numMNswitches+1) ):
260 main.deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) )
261 print "Device DPIDs in Store: \n", str( main.deviceDPIDs )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800262
Hari Krishna22c3d412015-02-17 16:48:12 -0800263 main.step( "Store Host MACs" )
264 for i in range( 1, ( main.numMNhosts + 1 ) ):
265 main.hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" )
266 print "Host MACs in Store: \n", str( main.hostMACs )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800267
Hari Krishna22c3d412015-02-17 16:48:12 -0800268 main.step( "Collect and store all Devices Links" )
269 linksResult = main.ONOScli1.links( jsonFormat=False )
270 ansi_escape = re.compile( r'\x1b[^m]*m' )
271 linksResult = ansi_escape.sub( '', linksResult )
272 linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" )
273 linksResult = linksResult.splitlines()
274 linksResult = linksResult[ 1: ]
275 main.deviceLinks = copy.copy( linksResult )
276 print "Device Links Stored: \n", str( main.deviceLinks )
277 # this will be asserted to check with the params provided count of
278 # links
279 print "Length of Links Store", len( main.deviceLinks )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800280
Hari Krishna22c3d412015-02-17 16:48:12 -0800281 main.step( "Collect and store each Device ports enabled Count" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800282 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800283 for i in xrange(1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800284 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800285 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800286 dpid = "of:00000000000000" + format( i,'02x' )
287 t = main.Thread(target = cli.getDevicePortsEnabledCount,threadID = main.threadID, name = "getDevicePortsEnabledCount",args = [dpid])
288 t.start()
289 pool.append(t)
290 i = i + 1
291 main.threadID = main.threadID + 1
292 for thread in pool:
293 thread.join()
294 portResult = thread.result
295 portTemp = re.split( r'\t+', portResult )
296 portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
297 main.devicePortsEnabledCount.append( portCount )
Hari Krishna22c3d412015-02-17 16:48:12 -0800298 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
kelvin-onlab54400a92015-02-26 18:05:51 -0800299 time2 = time.time()
300 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800301
Hari Krishna22c3d412015-02-17 16:48:12 -0800302 main.step( "Collect and store each Device active links Count" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800303 time1 = time.time()
304
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800305 for i in xrange( 1,( main.numMNswitches + 1 ), int( main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800306 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800307 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800308 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800309 t = main.Thread( target = cli.getDeviceLinksActiveCount,
310 threadID = main.threadID,
311 name = "getDevicePortsEnabledCount",
312 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800313 t.start()
314 pool.append(t)
315 i = i + 1
316 main.threadID = main.threadID + 1
317 for thread in pool:
318 thread.join()
319 linkCountResult = thread.result
320 linkCountTemp = re.split( r'\t+', linkCountResult )
321 linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
322 main.deviceActiveLinksCount.append( linkCount )
323 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
324 time2 = time.time()
325 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800326
327 else:
328 main.log.info("Devices (expected): %s, Links (expected): %s" %
329 ( str( main.numMNswitches ), str( main.numMNlinks ) ) )
330 main.log.info("Devices (actual): %s, Links (actual): %s" %
331 ( numOnosDevices , numOnosLinks ) )
332 main.log.info("Topology does not match, exiting CHO test...")
kelvin-onlab54400a92015-02-26 18:05:51 -0800333 #time.sleep(300)
334 main.cleanup()
335 main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800336
kelvin-onlab8a832582015-01-16 17:06:11 -0800337 # just returning TRUE for now as this one just collects data
Hari Krishna22c3d412015-02-17 16:48:12 -0800338 case3Result = main.TRUE
339 utilities.assert_equals( expect=main.TRUE, actual=case3Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800340 onpass="Saving ONOS topology data test PASS",
341 onfail="Saving ONOS topology data test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800342
kelvin-onlab8a832582015-01-16 17:06:11 -0800343 def CASE4( self, main ):
344 """
345 Enable onos-app-fwd, Verify Reactive forwarding through ping all and Disable it
346 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800347 import re
348 import copy
349 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800350 main.log.report( "Enable Reactive forwarding and Verify ping all" )
351 main.log.report( "______________________________________________" )
352 main.case( "Enable Reactive forwarding and Verify ping all" )
353 main.step( "Enable Reactive forwarding" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800354 installResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800355 feature = "onos-app-fwd"
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800356
kelvin-onlab54400a92015-02-26 18:05:51 -0800357 pool = []
358 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800359 for cli in main.CLIs:
360 t = main.Thread( target=cli.featureInstall,
361 threadID=main.threadID,
362 name="featureInstall",
363 args=['onos-app-fwd'])
kelvin-onlab54400a92015-02-26 18:05:51 -0800364 pool.append(t)
365 t.start()
366 main.threadID = main.threadID + 1
367
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800368 installResult = main.TRUE
369 for t in pool:
370 t.join()
371 installResult = installResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -0800372 time2 = time.time()
373
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800374 if not installResult:
kelvin-onlab54400a92015-02-26 18:05:51 -0800375 main.log.info("Did not install onos-app-fwd feature properly")
376 main.cleanup()
377 main.exit()
378 else:
379 main.log.info("Successful feature:install onos-app-fwd")
kelvin-onlab54400a92015-02-26 18:05:51 -0800380 main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1))
381
kelvin-onlab8a832582015-01-16 17:06:11 -0800382 time.sleep( 5 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800383
kelvin-onlab8a832582015-01-16 17:06:11 -0800384 main.step( "Verify Pingall" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800385 ping_result = main.FALSE
386 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800387 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800388 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800389 timeDiff = round( ( time2 - time1 ), 2 )
390 main.log.report(
391 "Time taken for Ping All: " +
392 str( timeDiff ) +
393 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800394
395 if ping_result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800396 main.log.report( "Pingall Test in Reactive mode successful" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800397 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800398 main.log.report( "Pingall Test in Reactive mode failed" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800399
kelvin-onlab8a832582015-01-16 17:06:11 -0800400 main.step( "Disable Reactive forwarding" )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800401 uninstallResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800402 pool = []
403 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800404 for cli in main.CLIs:
405 t = main.Thread( target=cli.featureUninstall,
406 threadID=main.threadID,
407 name="featureUninstall",
408 args=['onos-app-fwd'])
kelvin-onlab54400a92015-02-26 18:05:51 -0800409 pool.append(t)
410 t.start()
411 main.threadID = main.threadID + 1
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800412 for t in pool:
413 t.join()
414 uninstallResult = uninstallResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -0800415 time2 = time.time()
416
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800417 if not uninstallResult:
kelvin-onlab54400a92015-02-26 18:05:51 -0800418 main.log.info("Did not uninstall onos-app-fwd feature properly")
419 main.cleanup()
420 main.exit()
421 else:
422 main.log.info("Successful feature:uninstall onos-app-fwd")
kelvin-onlab54400a92015-02-26 18:05:51 -0800423 main.log.info("Time for feature:uninstall onos-app-fwd: %2f seconds" %(time2-time1))
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800424
kelvin-onlab8a832582015-01-16 17:06:11 -0800425 # Waiting for reative flows to be cleared.
kelvin-onlab54400a92015-02-26 18:05:51 -0800426 time.sleep( 5 )
427 case4Result = installResult and uninstallResult and ping_result
428 utilities.assert_equals( expect=main.TRUE, actual=case4Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800429 onpass="Reactive Mode Pingall test PASS",
430 onfail="Reactive Mode Pingall test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800431
kelvin-onlab8a832582015-01-16 17:06:11 -0800432 def CASE5( self, main ):
433 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800434 Compare current ONOS topology with reference data
kelvin-onlab8a832582015-01-16 17:06:11 -0800435 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800436 import re
kelvin-onlab54400a92015-02-26 18:05:51 -0800437
Hari Krishna22c3d412015-02-17 16:48:12 -0800438 devicesDPIDTemp = []
439 hostMACsTemp = []
440 deviceLinksTemp = []
441 deviceActiveLinksCountTemp = []
442 devicePortsEnabledCountTemp = []
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800443
kelvin-onlab8a832582015-01-16 17:06:11 -0800444 main.log.report(
445 "Compare ONOS topology with reference data in Stores" )
446 main.log.report( "__________________________________________________" )
447 main.case( "Compare ONOS topology with reference data" )
448
449 main.step( "Compare current Device ports enabled with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800450 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800451 for i in xrange( 1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800452 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800453 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800454 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800455 t = main.Thread(target = cli.getDevicePortsEnabledCount,
456 threadID = main.threadID,
457 name = "getDevicePortsEnabledCount",
458 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800459 t.start()
460 pool.append(t)
461 i = i + 1
462 main.threadID = main.threadID + 1
463 for thread in pool:
464 thread.join()
465 portResult = thread.result
466 portTemp = re.split( r'\t+', portResult )
467 portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
468 devicePortsEnabledCountTemp.append( portCount )
469 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
470 time2 = time.time()
471 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800472 main.log.info (
473 "Device Enabled ports EXPECTED: %s" %
474 str( main.devicePortsEnabledCount ) )
475 main.log.info (
476 "Device Enabled ports ACTUAL: %s" %
477 str( devicePortsEnabledCountTemp ) )
kelvin-onlab54400a92015-02-26 18:05:51 -0800478
Hari Krishna22c3d412015-02-17 16:48:12 -0800479 if ( cmp( main.devicePortsEnabledCount,
480 devicePortsEnabledCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800481 stepResult1 = main.TRUE
482 else:
483 stepResult1 = main.FALSE
484
kelvin-onlab8a832582015-01-16 17:06:11 -0800485 main.step( "Compare Device active links with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800486 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800487 for i in xrange( 1, ( main.numMNswitches + 1) , int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800488 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800489 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800490 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800491 t = main.Thread(target = cli.getDeviceLinksActiveCount,
492 threadID = main.threadID,
493 name = "getDevicePortsEnabledCount",
494 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800495 t.start()
496 pool.append(t)
497 i = i + 1
498 main.threadID = main.threadID + 1
499 for thread in pool:
500 thread.join()
501 linkCountResult = thread.result
502 linkCountTemp = re.split( r'\t+', linkCountResult )
503 linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
504 deviceActiveLinksCountTemp.append( linkCount )
505 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
506 time2 = time.time()
507 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800508 main.log.info (
509 "Device Active links EXPECTED: %s" %
510 str( main.deviceActiveLinksCount ) )
511 main.log.info (
512 "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) )
513 if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800514 stepResult2 = main.TRUE
515 else:
516 stepResult2 = main.FALSE
517
kelvin-onlab8a832582015-01-16 17:06:11 -0800518 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800519 place holder for comparing devices, hosts, paths and intents if required.
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800520 Links and ports data would be incorrect with out devices anyways.
kelvin-onlab8a832582015-01-16 17:06:11 -0800521 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800522 case5Result = ( stepResult1 and stepResult2 )
523 utilities.assert_equals( expect=main.TRUE, actual=case5Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800524 onpass="Compare Topology test PASS",
525 onfail="Compare Topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800526
kelvin-onlab8a832582015-01-16 17:06:11 -0800527 def CASE6( self ):
528 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800529 Install 300 host intents and verify ping all
kelvin-onlab8a832582015-01-16 17:06:11 -0800530 """
531 main.log.report( "Add 300 host intents and verify pingall" )
532 main.log.report( "_______________________________________" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800533 import itertools
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700534 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800535 main.case( "Install 300 host intents" )
536 main.step( "Add host Intents" )
537 intentResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800538 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800539
kelvin-onlab54400a92015-02-26 18:05:51 -0800540 intentIdList = []
541 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800542 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800543 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800544 for cli in main.CLIs:
545 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800546 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800547 t = main.Thread( target=cli.addHostIntent,
548 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -0800549 name="addHostIntent",
550 args=[hostCombos[i][0],hostCombos[i][1]])
551 pool.append(t)
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700552 time.sleep(1)
kelvin-onlab54400a92015-02-26 18:05:51 -0800553 t.start()
554 i = i + 1
555 main.threadID = main.threadID + 1
556 for thread in pool:
557 thread.join()
558 intentIdList.append(thread.result)
559 time2 = time.time()
560 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
561 intentResult = main.TRUE
562 intentsJson = main.ONOScli2.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800563 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
kelvin-onlab54400a92015-02-26 18:05:51 -0800564 intentsJson = intentsJson)
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800565 print getIntentStateResult
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700566 time.sleep(30)
kelvin-onlab8a832582015-01-16 17:06:11 -0800567 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800568 pingResult = main.FALSE
569 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800570 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800571 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800572 timeDiff = round( ( time2 - time1 ), 2 )
573 main.log.report(
574 "Time taken for Ping All: " +
575 str( timeDiff ) +
576 " seconds" )
577 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
578 onpass="PING ALL PASS",
579 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800580
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800581 case6Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -0800582
kelvin-onlab8a832582015-01-16 17:06:11 -0800583 utilities.assert_equals(
584 expect=main.TRUE,
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800585 actual=case6Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800586 onpass="Install 300 Host Intents and Ping All test PASS",
587 onfail="Install 300 Host Intents and Ping All test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800588
kelvin-onlab8a832582015-01-16 17:06:11 -0800589 def CASE70( self, main ):
590 """
591 Randomly bring some core links down and verify ping all ( Host Intents Scenario )
592 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800593 import random
Hari Krishna22c3d412015-02-17 16:48:12 -0800594 main.randomLink1 = []
595 main.randomLink2 = []
596 main.randomLink3 = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800597 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
598 link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
599 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
600 link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' )
601 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
602 link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' )
603 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
604 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800605
Hari Krishnad97213e2015-01-24 19:30:14 -0800606 main.log.report( "Host intents - Randomly bring some core links down and verify ping all" )
607 main.log.report( "_________________________________________________________________" )
608 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
609 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800610 if ( int( switchLinksToToggle ) ==
611 0 or int( switchLinksToToggle ) > 5 ):
Hari Krishna46997e02015-01-27 11:23:07 -0800612 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 -0800613 main.cleanup()
614 main.exit()
615 else:
Hari Krishnad97213e2015-01-24 19:30:14 -0800616 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 -0800617
kelvin-onlab8a832582015-01-16 17:06:11 -0800618 main.step( "Cut links on Core devices using user provided range" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800619 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
620 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
621 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800622 for i in range( int( switchLinksToToggle ) ):
623 main.Mininet1.link(
624 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800625 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800626 OPTION="down" )
627 main.Mininet1.link(
628 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800629 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800630 OPTION="down" )
631 main.Mininet1.link(
632 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800633 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800634 OPTION="down" )
635 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800636
637 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800638 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -0800639 topology_output, main.numMNswitches, str(
640 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800641 utilities.assert_equals(
642 expect=main.TRUE,
643 actual=linkDown,
644 onpass="Link Down discovered properly",
645 onfail="Link down was not discovered in " +
646 str( link_sleep ) +
647 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800648
kelvin-onlab8a832582015-01-16 17:06:11 -0800649 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800650 pingResultLinkDown = main.FALSE
651 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800652 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800653 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800654 timeDiff = round( ( time2 - time1 ), 2 )
655 main.log.report(
656 "Time taken for Ping All: " +
657 str( timeDiff ) +
658 " seconds" )
659 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
660 onpass="PING ALL PASS",
661 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800662
Hari Krishna22c3d412015-02-17 16:48:12 -0800663 caseResult70 = linkDown and pingResultLinkDown
664 utilities.assert_equals( expect=main.TRUE, actual=caseResult70,
kelvin-onlab8a832582015-01-16 17:06:11 -0800665 onpass="Random Link cut Test PASS",
666 onfail="Random Link cut Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800667
kelvin-onlab8a832582015-01-16 17:06:11 -0800668 def CASE80( self, main ):
669 """
670 Bring the core links up that are down and verify ping all ( Host Intents Scenario )
671 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800672 import random
kelvin-onlab8a832582015-01-16 17:06:11 -0800673 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
674 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
675 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
676 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
677 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800678
kelvin-onlab8a832582015-01-16 17:06:11 -0800679 main.log.report(
680 "Host intents - Bring the core links up that are down and verify ping all" )
681 main.log.report(
682 "__________________________________________________________________" )
683 main.case(
684 "Host intents - Bring the core links up that are down and verify ping all" )
685 main.step( "Bring randomly cut links on Core devices up" )
686 for i in range( int( switchLinksToToggle ) ):
687 main.Mininet1.link(
688 END1=link1End1,
kelvin-onlab54400a92015-02-26 18:05:51 -0800689 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800690 OPTION="up" )
691 main.Mininet1.link(
692 END1=link2End1,
kelvin-onlab54400a92015-02-26 18:05:51 -0800693 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800694 OPTION="up" )
695 main.Mininet1.link(
696 END1=link3End1,
kelvin-onlab54400a92015-02-26 18:05:51 -0800697 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800698 OPTION="up" )
699 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800700
701 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800702 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -0800703 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -0800704 main.numMNswitches,
705 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800706 utilities.assert_equals(
707 expect=main.TRUE,
708 actual=linkUp,
709 onpass="Link up discovered properly",
710 onfail="Link up was not discovered in " +
711 str( link_sleep ) +
712 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800713
kelvin-onlab8a832582015-01-16 17:06:11 -0800714 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800715 pingResultLinkUp = main.FALSE
716 time1 = time.time()
717 pingResultLinkUp = main.Mininet1.pingall()
718 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800719 timeDiff = round( ( time2 - time1 ), 2 )
720 main.log.report(
721 "Time taken for Ping All: " +
722 str( timeDiff ) +
723 " seconds" )
724 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
725 onpass="PING ALL PASS",
726 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800727
Hari Krishna22c3d412015-02-17 16:48:12 -0800728 caseResult80 = linkUp and pingResultLinkUp
729 utilities.assert_equals( expect=main.TRUE, actual=caseResult80,
kelvin-onlab8a832582015-01-16 17:06:11 -0800730 onpass="Link Up Test PASS",
731 onfail="Link Up Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800732
kelvin-onlab8a832582015-01-16 17:06:11 -0800733 def CASE71( self, main ):
734 """
735 Randomly bring some core links down and verify ping all ( Point Intents Scenario )
736 """
kelvin8ec71442015-01-15 16:57:00 -0800737 import random
Hari Krishna22c3d412015-02-17 16:48:12 -0800738 main.randomLink1 = []
739 main.randomLink2 = []
740 main.randomLink3 = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800741 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
742 link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
743 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
744 link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' )
745 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
746 link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' )
747 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
748 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin8ec71442015-01-15 16:57:00 -0800749
Hari Krishnad97213e2015-01-24 19:30:14 -0800750 main.log.report( "Point Intents - Randomly bring some core links down and verify ping all" )
751 main.log.report( "__________________________________________________________________" )
752 main.case( "Point Intents - Randomly bring some core links down and verify ping all" )
753 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800754 if ( int( switchLinksToToggle ) ==
755 0 or int( switchLinksToToggle ) > 5 ):
756 main.log.info(
757 "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 -0800758 main.cleanup()
759 main.exit()
760 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800761 main.log.info(
762 "User provided Core switch links range to toggle is correct, proceeding to run the test" )
kelvin8ec71442015-01-15 16:57:00 -0800763
kelvin-onlab8a832582015-01-16 17:06:11 -0800764 main.step( "Cut links on Core devices using user provided range" )
765 randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
766 randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
767 randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
768 for i in range( int( switchLinksToToggle ) ):
769 main.Mininet1.link(
770 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800771 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800772 OPTION="down" )
773 main.Mininet1.link(
774 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800775 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800776 OPTION="down" )
777 main.Mininet1.link(
778 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800779 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800780 OPTION="down" )
781 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -0800782
783 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800784 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -0800785 topology_output, main.numSwitches, str(
786 int( main.numLinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800787 utilities.assert_equals(
788 expect=main.TRUE,
789 actual=linkDown,
790 onpass="Link Down discovered properly",
791 onfail="Link down was not discovered in " +
792 str( link_sleep ) +
793 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -0800794
kelvin-onlab8a832582015-01-16 17:06:11 -0800795 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -0800796 pingResultLinkDown = main.FALSE
797 time1 = time.time()
798 pingResultLinkDown = main.Mininet1.pingall()
799 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800800 timeDiff = round( ( time2 - time1 ), 2 )
801 main.log.report(
802 "Time taken for Ping All: " +
803 str( timeDiff ) +
804 " seconds" )
805 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
806 onpass="PING ALL PASS",
807 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -0800808
809 caseResult7 = linkDown and pingResultLinkDown
kelvin-onlab8a832582015-01-16 17:06:11 -0800810 utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
811 onpass="Random Link cut Test PASS",
812 onfail="Random Link cut Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -0800813
kelvin-onlab8a832582015-01-16 17:06:11 -0800814 def CASE81( self, main ):
815 """
816 Bring the core links up that are down and verify ping all ( Point Intents Scenario )
817 """
kelvin8ec71442015-01-15 16:57:00 -0800818 import random
kelvin-onlab8a832582015-01-16 17:06:11 -0800819 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
820 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
821 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
822 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
823 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
kelvin8ec71442015-01-15 16:57:00 -0800824
kelvin-onlab8a832582015-01-16 17:06:11 -0800825 main.log.report(
826 "Point intents - Bring the core links up that are down and verify ping all" )
827 main.log.report(
828 "___________________________________________________________________" )
829 main.case(
830 "Point intents - Bring the core links up that are down and verify ping all" )
831 main.step( "Bring randomly cut links on Core devices up" )
832 for i in range( int( switchLinksToToggle ) ):
833 main.Mininet1.link(
834 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800835 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800836 OPTION="up" )
837 main.Mininet1.link(
838 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800839 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800840 OPTION="up" )
841 main.Mininet1.link(
842 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800843 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800844 OPTION="up" )
845 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -0800846
847 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800848 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -0800849 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -0800850 main.numMNswitches,
851 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800852 utilities.assert_equals(
853 expect=main.TRUE,
854 actual=linkUp,
855 onpass="Link up discovered properly",
856 onfail="Link up was not discovered in " +
857 str( link_sleep ) +
858 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -0800859
kelvin-onlab8a832582015-01-16 17:06:11 -0800860 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -0800861 pingResultLinkUp = main.FALSE
862 time1 = time.time()
863 pingResultLinkUp = main.Mininet1.pingall()
864 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800865 timeDiff = round( ( time2 - time1 ), 2 )
866 main.log.report(
867 "Time taken for Ping All: " +
868 str( timeDiff ) +
869 " seconds" )
870 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
871 onpass="PING ALL PASS",
872 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -0800873
Hari Krishna22c3d412015-02-17 16:48:12 -0800874 caseResult81 = linkUp and pingResultLinkUp
875 utilities.assert_equals( expect=main.TRUE, actual=caseResult81,
kelvin-onlab8a832582015-01-16 17:06:11 -0800876 onpass="Link Up Test PASS",
877 onfail="Link Up Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -0800878
kelvin-onlab8a832582015-01-16 17:06:11 -0800879 def CASE9( self ):
880 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800881 Install 114 point intents and verify Ping all works
kelvin-onlab8a832582015-01-16 17:06:11 -0800882 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800883 import copy
kelvin-onlab8a832582015-01-16 17:06:11 -0800884 main.log.report( "Install 114 point intents and verify Ping all" )
885 main.log.report( "___________________________________________" )
886 main.case( "Install 114 point intents and Ping all" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800887 deviceLinksCopy = copy.copy( main.deviceLinks )
kelvin-onlab8a832582015-01-16 17:06:11 -0800888 main.step( "Install 114 point intents" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800889 for i in range( len( deviceLinksCopy ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800890 pointLink = str(
Hari Krishna22c3d412015-02-17 16:48:12 -0800891 deviceLinksCopy[ i ] ).replace(
kelvin-onlab8a832582015-01-16 17:06:11 -0800892 "src=",
893 "" ).replace(
894 "dst=",
895 "" ).split( ',' )
896 point1 = pointLink[ 0 ].split( '/' )
897 point2 = pointLink[ 1 ].split( '/' )
Hari Krishnad97213e2015-01-24 19:30:14 -0800898 installResult = main.ONOScli1.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -0800899 point1[ 0 ], point2[ 0 ], int(
900 point1[ 1 ] ), int(
901 point2[ 1 ] ) )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800902 if installResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800903 print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800904
kelvin-onlab8a832582015-01-16 17:06:11 -0800905 main.step( "Obtain the intent id's" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800906 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -0800907 ansi_escape = re.compile( r'\x1b[^m]*m' )
908 intentsList = ansi_escape.sub( '', intentsList )
909 intentsList = intentsList.replace(
910 " onos:intents | grep id=",
911 "" ).replace(
912 "id=",
913 "" ).replace(
914 "\r\r",
915 "" )
916 intentsList = intentsList.splitlines()
917 intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800918 intentIdList = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800919 for i in range( len( intentsList ) ):
920 intentsTemp = intentsList[ i ].split( ',' )
921 intentIdList.append( intentsTemp[ 0 ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800922 print "Intent IDs: ", intentIdList
kelvin-onlab8a832582015-01-16 17:06:11 -0800923 print "Total Intents installed: ", len( intentIdList )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800924
kelvin-onlab8a832582015-01-16 17:06:11 -0800925 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800926 pingResult = main.FALSE
927 time1 = time.time()
928 pingResult = main.Mininet1.pingall()
929 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800930 timeDiff = round( ( time2 - time1 ), 2 )
931 main.log.report(
932 "Time taken for Ping All: " +
933 str( timeDiff ) +
934 " seconds" )
935 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
936 onpass="PING ALL PASS",
937 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800938
939 case8_result = installResult and pingResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800940 utilities.assert_equals(
941 expect=main.TRUE,
942 actual=case8_result,
943 onpass="Ping all test after Point intents addition successful",
944 onfail="Ping all test after Point intents addition failed" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800945
kelvin-onlabc3ab3012015-03-10 15:04:46 -0700946 def CASE90( self ):
947 """
948 Install single-multi point intents and verify Ping all works
949 for att topology
950 """
951 import copy
952 main.log.report( "Install single-multi point intents and verify Ping all" )
953 main.log.report( "___________________________________________" )
954 main.case( "Install single-multi point intents and Ping all" )
955 deviceLinksCopy = copy.copy( main.deviceLinks )
956 main.step( "Install single-multi point intents" )
957 for i in range( len( deviceLinksCopy ) ):
958 pointLink = str(
959 deviceLinksCopy[ i ] ).replace(
960 "src=",
961 "" ).replace(
962 "dst=",
963 "" ).split( ',' )
964 point1 = pointLink[ 0 ].split( '/' )
965 point2 = pointLink[ 1 ].split( '/' )
966 installResult = main.ONOScli1.addPointIntent(
967 point1[ 0 ], point2[ 0 ], int(
968 point1[ 1 ] ), int(
969 point2[ 1 ] ) )
970 if installResult == main.TRUE:
971 print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
972
973 main.step( "Obtain the intent id's" )
974 intentsList = main.ONOScli1.getAllIntentIds()
975 ansi_escape = re.compile( r'\x1b[^m]*m' )
976 intentsList = ansi_escape.sub( '', intentsList )
977 intentsList = intentsList.replace(
978 " onos:intents | grep id=",
979 "" ).replace(
980 "id=",
981 "" ).replace(
982 "\r\r",
983 "" )
984 intentsList = intentsList.splitlines()
985 intentsList = intentsList[ 1: ]
986 intentIdList = []
987 for i in range( len( intentsList ) ):
988 intentsTemp = intentsList[ i ].split( ',' )
989 intentIdList.append( intentsTemp[ 0 ] )
990 print "Intent IDs: ", intentIdList
991 print "Total Intents installed: ", len( intentIdList )
992
993 main.step( "Verify Ping across all hosts" )
994 pingResult = main.FALSE
995 time1 = time.time()
996 pingResult = main.Mininet1.pingall()
997 time2 = time.time()
998 timeDiff = round( ( time2 - time1 ), 2 )
999 main.log.report(
1000 "Time taken for Ping All: " +
1001 str( timeDiff ) +
1002 " seconds" )
1003 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1004 onpass="PING ALL PASS",
1005 onfail="PING ALL FAIL" )
1006
1007 case8_result = installResult and pingResult
1008 utilities.assert_equals(
1009 expect=main.TRUE,
1010 actual=case8_result,
1011 onpass="Ping all test after Point intents addition successful",
1012 onfail="Ping all test after Point intents addition failed" )
1013
1014 def CASE91( self ):
1015 """
1016 Install single-multi point intents and verify Ping all works
1017 """
1018 import copy
1019 main.log.report( "Install single-multi point intents and verify Ping all" )
1020 main.log.report( "___________________________________________" )
1021 main.case( "Install single-multi point intents and Ping all" )
1022 deviceLinksCopy = copy.copy( main.deviceLinks )
1023 main.step( "Install single-multi point intents" )
1024 for i in range( len( deviceLinksCopy ) ):
1025 pointLink = str(
1026 deviceLinksCopy[ i ] ).replace(
1027 "src=",
1028 "" ).replace(
1029 "dst=",
1030 "" ).split( ',' )
1031 point1 = pointLink[ 0 ].split( '/' )
1032 point2 = pointLink[ 1 ].split( '/' )
1033 installResult = main.ONOScli1.addPointIntent(
1034 point1[ 0 ], point2[ 0 ], int(
1035 point1[ 1 ] ), int(
1036 point2[ 1 ] ) )
1037 if installResult == main.TRUE:
1038 print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
1039
1040 main.step( "Obtain the intent id's" )
1041 intentsList = main.ONOScli1.getAllIntentIds()
1042 ansi_escape = re.compile( r'\x1b[^m]*m' )
1043 intentsList = ansi_escape.sub( '', intentsList )
1044 intentsList = intentsList.replace(
1045 " onos:intents | grep id=",
1046 "" ).replace(
1047 "id=",
1048 "" ).replace(
1049 "\r\r",
1050 "" )
1051 intentsList = intentsList.splitlines()
1052 intentsList = intentsList[ 1: ]
1053 intentIdList = []
1054 for i in range( len( intentsList ) ):
1055 intentsTemp = intentsList[ i ].split( ',' )
1056 intentIdList.append( intentsTemp[ 0 ] )
1057 print "Intent IDs: ", intentIdList
1058 print "Total Intents installed: ", len( intentIdList )
1059
1060 main.step( "Verify Ping across all hosts" )
1061 pingResult = main.FALSE
1062 time1 = time.time()
1063 pingResult = main.Mininet1.pingall()
1064 time2 = time.time()
1065 timeDiff = round( ( time2 - time1 ), 2 )
1066 main.log.report(
1067 "Time taken for Ping All: " +
1068 str( timeDiff ) +
1069 " seconds" )
1070 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1071 onpass="PING ALL PASS",
1072 onfail="PING ALL FAIL" )
1073
1074 case8_result = installResult and pingResult
1075 utilities.assert_equals(
1076 expect=main.TRUE,
1077 actual=case8_result,
1078 onpass="Ping all test after Point intents addition successful",
1079 onfail="Ping all test after Point intents addition failed" )
1080
1081 def CASE92( self ):
1082 """
1083 Install 114 point intents and verify Ping all works
1084 """
1085 import copy
1086 main.log.report( "Install 114 point intents and verify Ping all" )
1087 main.log.report( "___________________________________________" )
1088 main.case( "Install 114 point intents and Ping all" )
1089 deviceLinksCopy = copy.copy( main.deviceLinks )
1090 main.step( "Install 114 point intents" )
1091 for i in range( len( deviceLinksCopy ) ):
1092 pointLink = str(
1093 deviceLinksCopy[ i ] ).replace(
1094 "src=",
1095 "" ).replace(
1096 "dst=",
1097 "" ).split( ',' )
1098 point1 = pointLink[ 0 ].split( '/' )
1099 point2 = pointLink[ 1 ].split( '/' )
1100 installResult = main.ONOScli1.addPointIntent(
1101 point1[ 0 ], point2[ 0 ], int(
1102 point1[ 1 ] ), int(
1103 point2[ 1 ] ) )
1104 if installResult == main.TRUE:
1105 print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
1106
1107 main.step( "Obtain the intent id's" )
1108 intentsList = main.ONOScli1.getAllIntentIds()
1109 ansi_escape = re.compile( r'\x1b[^m]*m' )
1110 intentsList = ansi_escape.sub( '', intentsList )
1111 intentsList = intentsList.replace(
1112 " onos:intents | grep id=",
1113 "" ).replace(
1114 "id=",
1115 "" ).replace(
1116 "\r\r",
1117 "" )
1118 intentsList = intentsList.splitlines()
1119 intentsList = intentsList[ 1: ]
1120 intentIdList = []
1121 for i in range( len( intentsList ) ):
1122 intentsTemp = intentsList[ i ].split( ',' )
1123 intentIdList.append( intentsTemp[ 0 ] )
1124 print "Intent IDs: ", intentIdList
1125 print "Total Intents installed: ", len( intentIdList )
1126
1127 main.step( "Verify Ping across all hosts" )
1128 pingResult = main.FALSE
1129 time1 = time.time()
1130 pingResult = main.Mininet1.pingall()
1131 time2 = time.time()
1132 timeDiff = round( ( time2 - time1 ), 2 )
1133 main.log.report(
1134 "Time taken for Ping All: " +
1135 str( timeDiff ) +
1136 " seconds" )
1137 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1138 onpass="PING ALL PASS",
1139 onfail="PING ALL FAIL" )
1140
1141 case8_result = installResult and pingResult
1142 utilities.assert_equals(
1143 expect=main.TRUE,
1144 actual=case8_result,
1145 onpass="Ping all test after Point intents addition successful",
1146 onfail="Ping all test after Point intents addition failed" )
1147
kelvin-onlab8a832582015-01-16 17:06:11 -08001148 def CASE10( self ):
kelvin-onlab7642bb12015-02-27 13:48:17 -08001149 import time
kelvin-onlab8a832582015-01-16 17:06:11 -08001150 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001151 Remove all Intents
kelvin-onlab8a832582015-01-16 17:06:11 -08001152 """
1153 main.log.report( "Remove all intents that were installed previously" )
1154 main.log.report( "______________________________________________" )
1155 main.log.info( "Remove all intents" )
1156 main.case( "Removing intents" )
1157 main.step( "Obtain the intent id's first" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001158 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -08001159 ansi_escape = re.compile( r'\x1b[^m]*m' )
1160 intentsList = ansi_escape.sub( '', intentsList )
1161 intentsList = intentsList.replace(
1162 " onos:intents | grep id=",
1163 "" ).replace(
1164 "id=",
1165 "" ).replace(
1166 "\r\r",
1167 "" )
1168 intentsList = intentsList.splitlines()
1169 intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001170 intentIdList = []
1171 step1Result = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001172 moreIntents = main.TRUE
1173 removeIntentCount = 0
1174 print "Current number of intents" , len(intentsList)
kelvin-onlab8a832582015-01-16 17:06:11 -08001175 if ( len( intentsList ) > 1 ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001176 results = main.TRUE
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07001177 main.log.info("Removing intent...")
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001178 while moreIntents:
1179 removeIntentCount = removeIntentCount + 1
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001180 intentsList1 = main.ONOScli1.getAllIntentIds()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07001181 if len( intentsList1 ) == 0:
1182 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001183 ansi_escape = re.compile( r'\x1b[^m]*m' )
1184 intentsList1 = ansi_escape.sub( '', intentsList1 )
1185 intentsList1 = intentsList1.replace(
1186 " onos:intents | grep id=",
1187 "" ).replace(
1188 " state=",
1189 "" ).replace(
1190 "\r\r",
1191 "" )
1192 intentsList1 = intentsList1.splitlines()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07001193 intentsList1 = intentsList1[ 1: ]
1194 print "Round %d intents to remove: " %(removeIntentCount)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001195 print intentsList1
1196 intentIdList1 = []
1197 if ( len( intentsList1 ) > 1 ):
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07001198 moreIntents = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001199 for i in range( len( intentsList1 ) ):
1200 intentsTemp1 = intentsList1[ i ].split( ',' )
1201 intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] )
1202 print "Leftover Intent IDs: ", intentIdList1
1203 print len(intentIdList1)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001204 for intent in intentIdList1:
kelvin-onlab36c02b12015-03-11 11:25:55 -07001205 main.CLIs[0].removeIntent(intent,'org.onosproject.cli',True,False)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001206 else:
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07001207 time.sleep(15)
1208 if len(main.ONOScli1.intents()):
1209 continue
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001210 break
1211 if removeIntentCount == 5:
1212 break
kelvin-onlab36c02b12015-03-11 11:25:55 -07001213
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001214 else:
1215 print "There are no more intents that need to be removed"
1216 step1Result = main.TRUE
1217 else:
1218 print "No Intent IDs found in Intents list: ", intentsList
1219 step1Result = main.FALSE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001220
kelvin-onlabdc8719b2015-03-02 14:01:52 -08001221 print main.ONOScli1.intents()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07001222 # time.sleep(300)
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001223 caseResult10 = step1Result
1224 utilities.assert_equals( expect=main.TRUE, actual=caseResult10,
kelvin-onlab8a832582015-01-16 17:06:11 -08001225 onpass="Intent removal test successful",
1226 onfail="Intent removal test failed" )
Hari Krishna22c3d412015-02-17 16:48:12 -08001227
1228 def CASE11( self, main ):
1229 """
1230 Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it
1231 """
1232 import re
1233 import copy
1234 import time
1235
kelvin-onlab54400a92015-02-26 18:05:51 -08001236 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
1237 threadID = 0
1238
Hari Krishna22c3d412015-02-17 16:48:12 -08001239 main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" )
1240 main.log.report( "_____________________________________________________" )
1241 main.case( "Enable Intent based Reactive forwarding and Verify ping all" )
1242 main.step( "Enable intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001243 installResult = main.FALSE
1244 feature = "onos-app-ifwd"
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001245
kelvin-onlab54400a92015-02-26 18:05:51 -08001246 pool = []
1247 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001248 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08001249 t = main.Thread(target=cli,threadID=threadID,
1250 name="featureInstall",args=[feature])
1251 pool.append(t)
1252 t.start()
1253 threadID = threadID + 1
1254
1255 results = []
1256 for thread in pool:
1257 thread.join()
1258 results.append(thread.result)
1259 time2 = time.time()
1260
1261 if( all(result == main.TRUE for result in results) == False):
1262 main.log.info("Did not install onos-app-ifwd feature properly")
1263 main.cleanup()
1264 main.exit()
1265 else:
1266 main.log.info("Successful feature:install onos-app-ifwd")
1267 installResult = main.TRUE
1268 main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1))
1269
Hari Krishna22c3d412015-02-17 16:48:12 -08001270 main.step( "Verify Pingall" )
1271 ping_result = main.FALSE
1272 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08001273 ping_result = main.Mininet1.pingall(timeout=600)
Hari Krishna22c3d412015-02-17 16:48:12 -08001274 time2 = time.time()
1275 timeDiff = round( ( time2 - time1 ), 2 )
1276 main.log.report(
1277 "Time taken for Ping All: " +
1278 str( timeDiff ) +
1279 " seconds" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001280
Hari Krishna22c3d412015-02-17 16:48:12 -08001281 if ping_result == main.TRUE:
1282 main.log.report( "Pingall Test in Reactive mode successful" )
1283 else:
1284 main.log.report( "Pingall Test in Reactive mode failed" )
1285
1286 main.step( "Disable Intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001287 uninstallResult = main.FALSE
1288
kelvin-onlab54400a92015-02-26 18:05:51 -08001289 pool = []
1290 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001291 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08001292 t = main.Thread(target=cli,threadID=threadID,
1293 name="featureUninstall",args=[feature])
1294 pool.append(t)
1295 t.start()
1296 threadID = threadID + 1
1297
1298 results = []
1299 for thread in pool:
1300 thread.join()
1301 results.append(thread.result)
1302 time2 = time.time()
1303
1304 if( all(result == main.TRUE for result in results) == False):
1305 main.log.info("Did not uninstall onos-app-ifwd feature properly")
1306 main.cleanup()
1307 main.exit()
1308 else:
1309 main.log.info("Successful feature:uninstall onos-app-ifwd")
1310 uninstallResult = main.TRUE
1311 main.log.info("Time for feature:uninstall onos-app-ifwd: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08001312
1313 # Waiting for reative flows to be cleared.
1314 time.sleep( 10 )
1315
1316 case11Result = installResult and ping_result and uninstallResult
1317 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
1318 onpass="Intent based Reactive forwarding Pingall test PASS",
1319 onfail="Intent based Reactive forwarding Pingall test FAIL" )
1320
1321 def CASE12( self, main ):
1322 """
1323 This test script Loads a new Topology (Chordal) on CHO setup and balances all switches
1324 """
1325 import re
1326 import time
1327 import copy
1328
kelvin-onlab54400a92015-02-26 18:05:51 -08001329 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
Hari Krishna22c3d412015-02-17 16:48:12 -08001330 newTopo = main.params['TOPO2']['topo']
1331 main.numMNswitches = int ( main.params[ 'TOPO2' ][ 'numSwitches' ] )
1332 main.numMNlinks = int ( main.params[ 'TOPO2' ][ 'numLinks' ] )
1333 main.numMNhosts = int ( main.params[ 'TOPO2' ][ 'numHosts' ] )
kelvin-onlab54400a92015-02-26 18:05:51 -08001334 main.pingTimeout = 60
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07001335
1336 time.sleep(60)
Hari Krishna22c3d412015-02-17 16:48:12 -08001337 main.log.report(
1338 "Load Chordal topology and Balance all Mininet switches across controllers" )
1339 main.log.report(
1340 "________________________________________________________________________" )
1341 # need to wait here for sometime until ONOS bootup
1342 time.sleep( 15 )
1343 main.case(
1344 "Assign and Balance all Mininet switches across controllers" )
1345 main.step( "Stop any previous Mininet network topology" )
1346 stopStatus = main.Mininet1.stopNet()
1347
1348 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
1349 main.step( "Stop ONOS on all Nodes" )
1350 stopResult = main.TRUE
1351 for i in range( 1, int( main.numCtrls ) + 1 ):
1352 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
1353 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
1354 sresult = main.ONOSbench.onosStop( ONOS_ip )
1355 utilities.assert_equals( expect=main.TRUE, actual=sresult,
1356 onpass="Test step PASS",
1357 onfail="Test step FAIL" )
1358 stopResult = ( stopResult and sresult )
1359
1360 main.step( "Start Mininet with Chordal topology" )
1361 startStatus = main.Mininet1.startNet(topoFile = newTopo)
1362
1363 main.step( "Assign switches to controllers" )
1364 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
1365 main.Mininet1.assignSwController(
1366 sw=str( i ),
1367 count=int( main.numCtrls ),
1368 ip1=main.ONOS1_ip,
1369 port1=main.ONOS1_port,
1370 ip2=main.ONOS2_ip,
1371 port2=main.ONOS2_port,
1372 ip3=main.ONOS3_ip,
1373 port3=main.ONOS3_port,
1374 ip4=main.ONOS4_ip,
1375 port4=main.ONOS4_port,
1376 ip5=main.ONOS5_ip,
1377 port5=main.ONOS5_port )
1378
1379 switch_mastership = main.TRUE
1380 for i in range( 1, ( main.numMNswitches + 1 ) ):
1381 response = main.Mininet1.getSwController( "s" + str( i ) )
1382 print( "Response is " + str( response ) )
1383 if re.search( "tcp:" + main.ONOS1_ip, response ):
1384 switch_mastership = switch_mastership and main.TRUE
1385 else:
1386 switch_mastership = main.FALSE
1387
1388 if switch_mastership == main.TRUE:
1389 main.log.report( "Controller assignment successfull" )
1390 else:
1391 main.log.report( "Controller assignment failed" )
1392 time.sleep( 5 )
1393
1394 main.step( "Start ONOS on all Nodes" )
1395 startResult = main.TRUE
1396 for i in range( 1, int( main.numCtrls ) + 1 ):
1397 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
1398 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
1399 sresult = main.ONOSbench.onosStart( ONOS_ip )
1400 utilities.assert_equals( expect=main.TRUE, actual=sresult,
1401 onpass="Test step PASS",
1402 onfail="Test step FAIL" )
1403 startResult = ( startResult and sresult )
1404
1405 main.step( "Start ONOS CLI on all nodes" )
1406 cliResult = main.TRUE
1407 #karafTimeout = "3600000" # This is not needed here as it is already set before.
1408 # need to wait here sometime for ONOS to bootup.
1409 time.sleep( 30 )
kelvin-onlab54400a92015-02-26 18:05:51 -08001410
1411 main.log.step(" Start ONOS cli using thread ")
kelvin-onlab54400a92015-02-26 18:05:51 -08001412 pool = []
1413 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001414 for i in range( int( main.numCtrls ) ):
1415 t = main.Thread(target=cli.startOnosCli,
1416 threadID=main.threadID,
1417 name="startOnosCli",
1418 args=[nodes[i].ip_address])
kelvin-onlab54400a92015-02-26 18:05:51 -08001419 pool.append(t)
1420 t.start()
1421 main.threadID = main.threadID + 1
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001422 for t in pool:
1423 t.join()
1424 cliResult = cliResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -08001425 time2 = time.time()
1426
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001427 if not cliResult:
kelvin-onlab54400a92015-02-26 18:05:51 -08001428 main.log.info("ONOS CLI did not start up properly")
1429 main.cleanup()
1430 main.exit()
1431 else:
1432 main.log.info("Successful CLI startup")
kelvin-onlab54400a92015-02-26 18:05:51 -08001433 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08001434
1435 main.step( "Balance devices across controllers" )
1436 for i in range( int( main.numCtrls ) ):
1437 balanceResult = main.ONOScli1.balanceMasters()
1438 # giving some breathing time for ONOS to complete re-balance
1439 time.sleep( 3 )
1440
1441 case12Result = ( startResult and cliResult )
1442 utilities.assert_equals(
1443 expect=main.TRUE,
1444 actual=case12Result,
1445 onpass="Starting new Chordal topology test PASS",
1446 onfail="Starting new Chordal topology test FAIL" )
1447
1448 def CASE13( self, main ):
1449 """
1450 This test script Loads a new Topology (Spine) on CHO setup and balances all switches
1451 """
1452 import re
1453 import time
1454 import copy
1455
1456 newTopo = main.params['TOPO3']['topo']
1457 main.numMNswitches = int ( main.params[ 'TOPO3' ][ 'numSwitches' ] )
1458 main.numMNlinks = int ( main.params[ 'TOPO3' ][ 'numLinks' ] )
1459 main.numMNhosts = int ( main.params[ 'TOPO3' ][ 'numHosts' ] )
kelvin-onlab54400a92015-02-26 18:05:51 -08001460 main.pingTimeout = 600
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07001461
1462 time.sleep(60)
Hari Krishna22c3d412015-02-17 16:48:12 -08001463 main.log.report(
1464 "Load Spine and Leaf topology and Balance all Mininet switches across controllers" )
1465 main.log.report(
1466 "________________________________________________________________________" )
1467 # need to wait here for sometime until ONOS bootup
1468 time.sleep( 15 )
1469 main.case(
1470 "Assign and Balance all Mininet switches across controllers" )
1471 main.step( "Stop any previous Mininet network topology" )
1472 stopStatus = main.Mininet1.stopNet()
1473
1474 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
1475 main.step( "Stop ONOS on all Nodes" )
1476 stopResult = main.TRUE
1477 for i in range( 1, int( main.numCtrls ) + 1 ):
1478 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
1479 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
1480 sresult = main.ONOSbench.onosStop( ONOS_ip )
1481 utilities.assert_equals( expect=main.TRUE, actual=sresult,
1482 onpass="Test step PASS",
1483 onfail="Test step FAIL" )
1484 stopResult = ( stopResult and sresult )
1485
1486 main.step( "Start Mininet with Spine topology" )
1487 startStatus = main.Mininet1.startNet(topoFile = newTopo)
1488
1489 main.step( "Assign switches to controllers" )
1490 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
1491 main.Mininet1.assignSwController(
1492 sw=str( i ),
1493 count=int( main.numCtrls ),
1494 ip1=main.ONOS1_ip,
1495 port1=main.ONOS1_port,
1496 ip2=main.ONOS2_ip,
1497 port2=main.ONOS2_port,
1498 ip3=main.ONOS3_ip,
1499 port3=main.ONOS3_port,
1500 ip4=main.ONOS4_ip,
1501 port4=main.ONOS4_port,
1502 ip5=main.ONOS5_ip,
1503 port5=main.ONOS5_port )
1504
1505 switch_mastership = main.TRUE
1506 for i in range( 1, ( main.numMNswitches + 1 ) ):
1507 response = main.Mininet1.getSwController( "s" + str( i ) )
1508 print( "Response is " + str( response ) )
1509 if re.search( "tcp:" + main.ONOS1_ip, response ):
1510 switch_mastership = switch_mastership and main.TRUE
1511 else:
1512 switch_mastership = main.FALSE
1513
1514 if switch_mastership == main.TRUE:
1515 main.log.report( "Controller assignment successfull" )
1516 else:
1517 main.log.report( "Controller assignment failed" )
1518 time.sleep( 5 )
1519
1520 main.step( "Start ONOS on all Nodes" )
1521 startResult = main.TRUE
1522 for i in range( 1, int( main.numCtrls ) + 1 ):
1523 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
1524 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
1525 sresult = main.ONOSbench.onosStart( ONOS_ip )
1526 utilities.assert_equals( expect=main.TRUE, actual=sresult,
1527 onpass="Test step PASS",
1528 onfail="Test step FAIL" )
1529 startResult = ( startResult and sresult )
1530
1531 main.step( "Start ONOS CLI on all nodes" )
1532 cliResult = main.TRUE
1533 #karafTimeout = "3600000" # This is not needed here as it is already set before.
1534 # need to wait here sometime for ONOS to bootup.
1535 time.sleep( 30 )
kelvin-onlab54400a92015-02-26 18:05:51 -08001536
1537 main.log.step(" Start ONOS cli using thread ")
kelvin-onlab54400a92015-02-26 18:05:51 -08001538 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001539 for i in range( int( main.numCtrls ) ):
1540 t = main.Thread(target=cli.startOnosCli,
1541 threadID=main.threadID,
1542 name="startOnosCli",
1543 args=[nodes[i].ip_address])
kelvin-onlab54400a92015-02-26 18:05:51 -08001544 pool.append(t)
1545 t.start()
1546 main.threadID = main.threadID + 1
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001547 for t in pool:
1548 t.join()
1549 cliResult = cliResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -08001550 time2 = time.time()
1551
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001552 if not cliResult:
kelvin-onlab54400a92015-02-26 18:05:51 -08001553 main.log.info("ONOS CLI did not start up properly")
1554 main.cleanup()
1555 main.exit()
1556 else:
1557 main.log.info("Successful CLI startup")
kelvin-onlab54400a92015-02-26 18:05:51 -08001558 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
1559
1560 main.step( "Balance devices across controllers" )
1561 for i in range( int( main.numCtrls ) ):
1562 balanceResult = main.ONOScli1.balanceMasters()
1563 # giving some breathing time for ONOS to complete re-balance
1564 time.sleep( 3 )
Hari Krishna22c3d412015-02-17 16:48:12 -08001565
1566 main.step( "Balance devices across controllers" )
1567 for i in range( int( main.numCtrls ) ):
1568 balanceResult = main.ONOScli1.balanceMasters()
1569 # giving some breathing time for ONOS to complete re-balance
1570 time.sleep( 3 )
1571
1572 case13Result = ( startResult and cliResult )
1573 utilities.assert_equals(
1574 expect=main.TRUE,
1575 actual=case13Result,
1576 onpass="Starting new Spine topology test PASS",
1577 onfail="Starting new Spine topology test FAIL" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001578
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001579 def CASE14( self ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001580 """
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001581 Install 300 host intents and verify ping all for Chordal Topology
kelvin-onlab54400a92015-02-26 18:05:51 -08001582 """
1583 main.log.report( "Add 300 host intents and verify pingall" )
1584 main.log.report( "_______________________________________" )
1585 import itertools
1586
1587 main.case( "Install 300 host intents" )
1588 main.step( "Add host Intents" )
1589 intentResult = main.TRUE
1590 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
1591
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001592 intentIdList = []
kelvin-onlab54400a92015-02-26 18:05:51 -08001593 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001594
1595 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001596 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001597 for cli in main.CLIs:
1598 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001599 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001600 t = main.Thread( target=cli.addHostIntent,
1601 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -08001602 name="addHostIntent",
1603 args=[hostCombos[i][0],hostCombos[i][1]])
1604 pool.append(t)
1605 t.start()
1606 i = i + 1
1607 main.threadID = main.threadID + 1
kelvin-onlab54400a92015-02-26 18:05:51 -08001608 for thread in pool:
1609 thread.join()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001610 intentIdList.append(thread.result)
kelvin-onlab54400a92015-02-26 18:05:51 -08001611 time2 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08001612 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001613 intentResult = main.TRUE
1614 intentsJson = main.ONOScli2.intents()
1615 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1616 intentsJson = intentsJson)
1617 print getIntentStateResult
1618
kelvin-onlab54400a92015-02-26 18:05:51 -08001619 main.step( "Verify Ping across all hosts" )
1620 pingResult = main.FALSE
1621 time1 = time.time()
1622 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1623 time2 = time.time()
1624 timeDiff = round( ( time2 - time1 ), 2 )
1625 main.log.report(
1626 "Time taken for Ping All: " +
1627 str( timeDiff ) +
1628 " seconds" )
1629 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1630 onpass="PING ALL PASS",
1631 onfail="PING ALL FAIL" )
1632
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001633 case14Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -08001634
kelvin-onlab54400a92015-02-26 18:05:51 -08001635 utilities.assert_equals(
1636 expect=main.TRUE,
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001637 actual=case14Result,
kelvin-onlab54400a92015-02-26 18:05:51 -08001638 onpass="Install 300 Host Intents and Ping All test PASS",
1639 onfail="Install 300 Host Intents and Ping All test FAIL" )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001640
1641 def CASE15( self ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001642 """
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001643 Install 300 host intents and verify ping all for Spine Topology
kelvin-onlab54400a92015-02-26 18:05:51 -08001644 """
1645 main.log.report( "Add 300 host intents and verify pingall" )
1646 main.log.report( "_______________________________________" )
1647 import itertools
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001648
kelvin-onlab54400a92015-02-26 18:05:51 -08001649 main.case( "Install 300 host intents" )
1650 main.step( "Add host Intents" )
1651 intentResult = main.TRUE
1652 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
1653
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001654 intentIdList = []
kelvin-onlab54400a92015-02-26 18:05:51 -08001655 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001656 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001657 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001658 for cli in main.CLIs:
1659 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001660 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001661 t = main.Thread( target=cli.addHostIntent,
1662 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -08001663 name="addHostIntent",
1664 args=[hostCombos[i][0],hostCombos[i][1]])
1665 pool.append(t)
1666 t.start()
1667 i = i + 1
1668 main.threadID = main.threadID + 1
kelvin-onlab54400a92015-02-26 18:05:51 -08001669 for thread in pool:
1670 thread.join()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001671 intentIdList.append(thread.result)
kelvin-onlab54400a92015-02-26 18:05:51 -08001672 time2 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08001673 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001674 intentResult = main.TRUE
1675 intentsJson = main.ONOScli2.intents()
1676 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1677 intentsJson = intentsJson)
1678 print getIntentStateResult
1679
kelvin-onlab54400a92015-02-26 18:05:51 -08001680 main.step( "Verify Ping across all hosts" )
1681 pingResult = main.FALSE
1682 time1 = time.time()
1683 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1684 time2 = time.time()
1685 timeDiff = round( ( time2 - time1 ), 2 )
1686 main.log.report(
1687 "Time taken for Ping All: " +
1688 str( timeDiff ) +
1689 " seconds" )
1690 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1691 onpass="PING ALL PASS",
1692 onfail="PING ALL FAIL" )
1693
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001694 case15Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -08001695
kelvin-onlab54400a92015-02-26 18:05:51 -08001696 utilities.assert_equals(
1697 expect=main.TRUE,
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001698 actual=case15Result,
kelvin-onlab54400a92015-02-26 18:05:51 -08001699 onpass="Install 300 Host Intents and Ping All test PASS",
1700 onfail="Install 300 Host Intents and Ping All test FAIL" )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001701
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001702