blob: db7bc4e25eb4c2667947ed3d212e2aab5f824e43 [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 = ''
14 global deviceDPIDs
15 global hostMACs
16 global deviceLinks
17 global deviceActiveLinksCount
18 global devicePortsEnabledCount
19 global installedIntents
20 global randomLink1, randomLink2, randomLink3, numSwitches, numLinks
kelvin8ec71442015-01-15 16:57:00 -080021
kelvin-onlab8a832582015-01-16 17:06:11 -080022 def CASE1( self, main ):
23 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -080024 Startup sequence:
25 git pull
26 mvn clean install
27 onos-package
28 cell <name>
29 onos-verify-cell
30 onos-install -f
31 onos-wait-for-start
kelvin-onlab8a832582015-01-16 17:06:11 -080032 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -080033 import time
kelvin-onlab8a832582015-01-16 17:06:11 -080034 cell_name = main.params[ 'ENV' ][ 'cellName' ]
35 git_pull = main.params[ 'GIT' ][ 'autoPull' ]
36 numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
37 git_branch = main.params[ 'GIT' ][ 'branch' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -080038
kelvin-onlab8a832582015-01-16 17:06:11 -080039 main.case( "Set up test environment" )
40 main.log.report( "Set up test environment" )
41 main.log.report( "_______________________" )
42
43 main.step( "Git checkout and pull " + git_branch )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080044 if git_pull == 'on':
Hari Krishnad97213e2015-01-24 19:30:14 -080045 checkout_result = main.ONOSbench.gitCheckout( git_branch )
46 pull_result = main.ONOSbench.gitPull()
kelvin-onlab8a832582015-01-16 17:06:11 -080047 cp_result = ( checkout_result and pull_result )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080048 else:
49 checkout_result = main.TRUE
50 pull_result = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -080051 main.log.info( "Skipped git checkout and pull" )
52 cp_result = ( checkout_result and pull_result )
53 utilities.assert_equals( expect=main.TRUE, actual=cp_result,
54 onpass="Test step PASS",
55 onfail="Test step FAIL" )
56
57 main.step( "mvn clean & install" )
Hari Krishnad97213e2015-01-24 19:30:14 -080058 mvn_result = main.ONOSbench.cleanInstall()
kelvin-onlab8a832582015-01-16 17:06:11 -080059 utilities.assert_equals( expect=main.TRUE, actual=mvn_result,
60 onpass="Test step PASS",
61 onfail="Test step FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080062
Hari Krishnad97213e2015-01-24 19:30:14 -080063 main.ONOSbench.getVersion( report=True )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080064
kelvin-onlab8a832582015-01-16 17:06:11 -080065 main.step( "Apply Cell environment for ONOS" )
Hari Krishnad97213e2015-01-24 19:30:14 -080066 cell_result = main.ONOSbench.setCell( cell_name )
kelvin-onlab8a832582015-01-16 17:06:11 -080067 utilities.assert_equals( expect=main.TRUE, actual=cell_result,
68 onpass="Test step PASS",
69 onfail="Test step FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080070
kelvin-onlab8a832582015-01-16 17:06:11 -080071 main.step( "Create ONOS package" )
Hari Krishnad97213e2015-01-24 19:30:14 -080072 packageResult = main.ONOSbench.onosPackage()
kelvin-onlab8a832582015-01-16 17:06:11 -080073 utilities.assert_equals( expect=main.TRUE, actual=packageResult,
74 onpass="Test step PASS",
75 onfail="Test step FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080076
kelvin-onlab8a832582015-01-16 17:06:11 -080077 main.step( "Uninstall ONOS package on all Nodes" )
78 uninstallResult = main.TRUE
79 for i in range( 1, int( numCtrls ) + 1 ):
80 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
81 main.log.info( "Unintsalling package on ONOS Node IP: " + ONOS_ip )
Hari Krishnad97213e2015-01-24 19:30:14 -080082 u_result = main.ONOSbench.onosUninstall( ONOS_ip )
kelvin-onlab8a832582015-01-16 17:06:11 -080083 utilities.assert_equals( expect=main.TRUE, actual=u_result,
84 onpass="Test step PASS",
85 onfail="Test step FAIL" )
86 uninstallResult = ( uninstallResult and u_result )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080087
kelvin-onlab8a832582015-01-16 17:06:11 -080088 main.step( "Removing copy-cat logs from ONOS nodes" )
Hari Krishnad97213e2015-01-24 19:30:14 -080089 main.ONOSbench.onosRemoveRaftLogs()
Hari Krishnaa43d4e92014-12-19 13:22:40 -080090
kelvin-onlab8a832582015-01-16 17:06:11 -080091 main.step( "Install ONOS package on all Nodes" )
92 installResult = main.TRUE
93 for i in range( 1, int( numCtrls ) + 1 ):
94 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
95 main.log.info( "Intsalling package on ONOS Node IP: " + ONOS_ip )
Hari Krishnad97213e2015-01-24 19:30:14 -080096 i_result = main.ONOSbench.onosInstall( node=ONOS_ip )
kelvin-onlab8a832582015-01-16 17:06:11 -080097 utilities.assert_equals( expect=main.TRUE, actual=i_result,
98 onpass="Test step PASS",
99 onfail="Test step FAIL" )
100 installResult = ( installResult and i_result )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800101
kelvin-onlab8a832582015-01-16 17:06:11 -0800102 main.step( "Verify ONOS nodes UP status" )
103 statusResult = main.TRUE
104 for i in range( 1, int( numCtrls ) + 1 ):
105 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
106 main.log.info( "ONOS Node " + ONOS_ip + " status:" )
Hari Krishnad97213e2015-01-24 19:30:14 -0800107 onos_status = main.ONOSbench.onosStatus( node=ONOS_ip )
kelvin-onlab8a832582015-01-16 17:06:11 -0800108 utilities.assert_equals( expect=main.TRUE, actual=onos_status,
109 onpass="Test step PASS",
110 onfail="Test step FAIL" )
111 statusResult = ( statusResult and onos_status )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800112
kelvin-onlab8a832582015-01-16 17:06:11 -0800113 main.step( "Start ONOS CLI on all nodes" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800114 cliResult = main.TRUE
kelvin8ec71442015-01-15 16:57:00 -0800115 karafTimeout = "3600000"
kelvin-onlab8a832582015-01-16 17:06:11 -0800116 # need to wait here for sometime. This will be removed once ONOS is
117 # stable enough
118 time.sleep( 15 )
119 for i in range( 1, int( numCtrls ) + 1 ):
120 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
121 ONOScli = 'ONOScli' + str( i )
122 main.log.info( "ONOS Node " + ONOS_ip + " cli start:" )
123 exec "startcli=main." + ONOScli + \
Hari Krishnad97213e2015-01-24 19:30:14 -0800124 ".startOnosCli(ONOS_ip, karafTimeout=karafTimeout)"
kelvin-onlab8a832582015-01-16 17:06:11 -0800125 utilities.assert_equals( expect=main.TRUE, actual=startcli,
126 onpass="Test step PASS",
127 onfail="Test step FAIL" )
128 cliResult = ( cliResult and startcli )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800129
kelvin-onlab8a832582015-01-16 17:06:11 -0800130 case1Result = ( cp_result and cell_result
131 and packageResult and installResult and statusResult and cliResult )
132 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
133 onpass="Set up test environment PASS",
134 onfail="Set up test environment FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800135
kelvin-onlab8a832582015-01-16 17:06:11 -0800136 def CASE2( self, main ):
137 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800138 This test script still needs more refactoring
kelvin-onlab8a832582015-01-16 17:06:11 -0800139 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800140 import re
141 import time
142 import copy
kelvin-onlab8a832582015-01-16 17:06:11 -0800143 numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
144 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
145 ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
146 ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
147 ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
148 ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
149 ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
150 ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
151 ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
152 ONOS4_port = main.params[ 'CTRL' ][ 'port4' ]
153 ONOS5_port = main.params[ 'CTRL' ][ 'port5' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800154
kelvin-onlab8a832582015-01-16 17:06:11 -0800155 numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
156 main.log.report(
157 "Assign and Balance all Mininet switches across controllers" )
158 main.log.report(
159 "_________________________________________________________" )
160 # need to wait here for sometime. This will be removed once ONOS is
161 # stable enough
162 time.sleep( 15 )
163 main.case(
164 "Assign and Balance all Mininet switches across controllers" )
165 main.step( "Assign switches to controllers" )
166 for i in range( 1, 26 ): # 1 to ( num of switches +1 )
Hari Krishnad97213e2015-01-24 19:30:14 -0800167 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800168 sw=str( i ),
169 count=int( numCtrls ),
170 ip1=ONOS1_ip,
171 port1=ONOS1_port,
172 ip2=ONOS2_ip,
173 port2=ONOS2_port,
174 ip3=ONOS3_ip,
175 port3=ONOS3_port,
176 ip4=ONOS4_ip,
177 port4=ONOS4_port,
178 ip5=ONOS5_ip,
179 port5=ONOS5_port )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800180
181 switch_mastership = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800182 for i in range( 1, 26 ):
Hari Krishnad97213e2015-01-24 19:30:14 -0800183 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800184 print( "Response is " + str( response ) )
185 if re.search( "tcp:" + ONOS1_ip, response ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800186 switch_mastership = switch_mastership and main.TRUE
187 else:
188 switch_mastership = main.FALSE
189
190 if switch_mastership == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800191 main.log.report( "Controller assignment successfull" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800192 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800193 main.log.report( "Controller assignment failed" )
194 time.sleep( 5 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800195
kelvin-onlab8a832582015-01-16 17:06:11 -0800196 main.step( "Balance devices across controllers" )
197 for i in range( int( numCtrls ) ):
Hari Krishnad97213e2015-01-24 19:30:14 -0800198 balanceResult = main.ONOScli1.balanceMasters()
kelvin-onlab8a832582015-01-16 17:06:11 -0800199 # giving some breathing time for ONOS to complete re-balance
200 time.sleep( 3 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800201
kelvin-onlab8a832582015-01-16 17:06:11 -0800202 utilities.assert_equals(
203 expect=main.TRUE,
204 actual=balanceResult,
205 onpass="Assign and Balance devices test PASS",
206 onfail="Assign and Balance devices test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800207
kelvin-onlab8a832582015-01-16 17:06:11 -0800208 def CASE3( self, main ):
209 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800210 This Test case will be extended to collect and store more data related
211 ONOS state.
kelvin-onlab8a832582015-01-16 17:06:11 -0800212 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800213 import re
214 import copy
215 deviceDPIDs = []
216 hostMACs = []
217 deviceLinks = []
218 deviceActiveLinksCount = []
219 devicePortsEnabledCount = []
220
kelvin-onlab8a832582015-01-16 17:06:11 -0800221 main.log.report(
222 "Collect and Store topology details from ONOS before running any Tests" )
223 main.log.report(
224 "____________________________________________________________________" )
225 main.case( "Collect and Store Topology Deatils from ONOS" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800226
kelvin-onlab8a832582015-01-16 17:06:11 -0800227 main.step( "Collect and store current number of switches and links" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800228 topology_output = main.ONOScli1.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800229 topology_result = main.ONOSbench.getTopology( topology_output )
kelvin-onlab8a832582015-01-16 17:06:11 -0800230 numSwitches = topology_result[ 'devices' ]
231 numLinks = topology_result[ 'links' ]
232 main.log.info(
233 "Currently there are %s switches and %s links" %
234 ( str( numSwitches ), str( numLinks ) ) )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800235
kelvin-onlab8a832582015-01-16 17:06:11 -0800236 main.step( "Store Device DPIDs" )
237 for i in range( 1, 26 ):
238 deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) )
239 print "Device DPIDs in Store: \n", str( deviceDPIDs )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800240
kelvin-onlab8a832582015-01-16 17:06:11 -0800241 main.step( "Store Host MACs" )
242 for i in range( 1, 26 ):
243 hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" )
244 print "Host MACs in Store: \n", str( hostMACs )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800245
kelvin-onlab8a832582015-01-16 17:06:11 -0800246 main.step( "Collect and store all Devices Links" )
Hari Krishnad97213e2015-01-24 19:30:14 -0800247 linksResult = main.ONOScli1.links( jsonFormat=False )
kelvin-onlab8a832582015-01-16 17:06:11 -0800248 ansi_escape = re.compile( r'\x1b[^m]*m' )
249 linksResult = ansi_escape.sub( '', linksResult )
250 linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" )
251 linksResult = linksResult.splitlines()
252 linksResult = linksResult[ 1: ]
253 deviceLinks = copy.copy( linksResult )
254 print "Device Links Stored: \n", str( deviceLinks )
255 # this will be asserted to check with the params provided count of
256 # links
257 print "Length of Links Store", len( deviceLinks )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800258
kelvin-onlab8a832582015-01-16 17:06:11 -0800259 main.step( "Collect and store each Device ports enabled Count" )
260 for i in range( 1, 26 ):
261 portResult = main.ONOScli1.getDevicePortsEnabledCount(
Hari Krishnad97213e2015-01-24 19:30:14 -0800262 "of:00000000000000" + format( i,'02x' ) )
263 print portResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800264 portTemp = re.split( r'\t+', portResult )
265 portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
266 devicePortsEnabledCount.append( portCount )
267 print "Device Enabled Port Counts Stored: \n", str( devicePortsEnabledCount )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800268
kelvin-onlab8a832582015-01-16 17:06:11 -0800269 main.step( "Collect and store each Device active links Count" )
270 for i in range( 1, 26 ):
271 linkCountResult = main.ONOScli1.getDeviceLinksActiveCount(
Hari Krishnad97213e2015-01-24 19:30:14 -0800272 "of:00000000000000" + format( i,'02x' ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800273 linkCountTemp = re.split( r'\t+', linkCountResult )
274 linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
275 deviceActiveLinksCount.append( linkCount )
276 print "Device Active Links Count Stored: \n", str( deviceActiveLinksCount )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800277
kelvin-onlab8a832582015-01-16 17:06:11 -0800278 # just returning TRUE for now as this one just collects data
279 caseResult = main.TRUE
280 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
281 onpass="Saving ONOS topology data test PASS",
282 onfail="Saving ONOS topology data test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800283
kelvin-onlab8a832582015-01-16 17:06:11 -0800284 def CASE4( self, main ):
285 """
286 Enable onos-app-fwd, Verify Reactive forwarding through ping all and Disable it
287 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800288 import re
289 import copy
290 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800291 numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
292 main.log.report( "Enable Reactive forwarding and Verify ping all" )
293 main.log.report( "______________________________________________" )
294 main.case( "Enable Reactive forwarding and Verify ping all" )
295 main.step( "Enable Reactive forwarding" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800296 installResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800297 for i in range( 1, int( numCtrls ) + 1 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800298 onosFeature = 'onos-app-fwd'
kelvin-onlab8a832582015-01-16 17:06:11 -0800299 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
300 ONOScli = 'ONOScli' + str( i )
301 main.log.info( "Enabling Reactive mode on ONOS Node " + ONOS_ip )
Hari Krishnad97213e2015-01-24 19:30:14 -0800302 exec "inResult=main." + ONOScli + ".featureInstall(onosFeature)"
kelvin-onlab8a832582015-01-16 17:06:11 -0800303 time.sleep( 3 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800304 installResult = inResult and installResult
305
kelvin-onlab8a832582015-01-16 17:06:11 -0800306 time.sleep( 5 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800307
kelvin-onlab8a832582015-01-16 17:06:11 -0800308 main.step( "Verify Pingall" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800309 ping_result = main.FALSE
310 time1 = time.time()
311 ping_result = main.Mininet1.pingall()
312 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800313 timeDiff = round( ( time2 - time1 ), 2 )
314 main.log.report(
315 "Time taken for Ping All: " +
316 str( timeDiff ) +
317 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800318
319 if ping_result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800320 main.log.report( "Pingall Test in Reactive mode successful" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800321 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800322 main.log.report( "Pingall Test in Reactive mode failed" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800323
kelvin-onlab8a832582015-01-16 17:06:11 -0800324 main.step( "Disable Reactive forwarding" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800325 uninstallResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800326 for i in range( 1, int( numCtrls ) + 1 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800327 onosFeature = 'onos-app-fwd'
kelvin-onlab8a832582015-01-16 17:06:11 -0800328 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
329 ONOScli = 'ONOScli' + str( i )
330 main.log.info( "Disabling Reactive mode on ONOS Node " + ONOS_ip )
Hari Krishnad97213e2015-01-24 19:30:14 -0800331 exec "unResult=main." + ONOScli + ".featureUninstall(onosFeature)"
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800332 uninstallResult = unResult and uninstallResult
333
kelvin-onlab8a832582015-01-16 17:06:11 -0800334 # Waiting for reative flows to be cleared.
335 time.sleep( 10 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800336
337 case3Result = installResult and ping_result and uninstallResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800338 utilities.assert_equals( expect=main.TRUE, actual=case3Result,
339 onpass="Reactive Mode Pingall test PASS",
340 onfail="Reactive Mode Pingall test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800341
kelvin-onlab8a832582015-01-16 17:06:11 -0800342 def CASE5( self, main ):
343 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800344 Compare current ONOS topology with reference data
kelvin-onlab8a832582015-01-16 17:06:11 -0800345 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800346 import re
347 devicesDPID_tmp = []
348 hostMACs_tmp = []
349 deviceLinks_tmp = []
350 deviceActiveLinksCount_tmp = []
351 devicePortsEnabledCount_tmp = []
352
kelvin-onlab8a832582015-01-16 17:06:11 -0800353 main.log.report(
354 "Compare ONOS topology with reference data in Stores" )
355 main.log.report( "__________________________________________________" )
356 main.case( "Compare ONOS topology with reference data" )
357
358 main.step( "Compare current Device ports enabled with reference" )
359 for i in range( 1, 26 ):
360 portResult = main.ONOScli1.getDevicePortsEnabledCount(
361 "of:00000000000000" +
362 format(
363 i,
364 '02x' ) )
365 portTemp = re.split( r'\t+', portResult )
366 portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
367 devicePortsEnabledCount_tmp.append( portCount )
368 time.sleep( 2 )
369 print (
370 "Device Enabled ports EXPECTED: \n" +
371 str( devicePortsEnabledCount ) )
372 print (
373 "Device Enabled ports ACTUAL: \n" +
374 str( devicePortsEnabledCount_tmp ) )
375 if ( cmp( devicePortsEnabledCount,
376 devicePortsEnabledCount_tmp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800377 stepResult1 = main.TRUE
378 else:
379 stepResult1 = main.FALSE
380
kelvin-onlab8a832582015-01-16 17:06:11 -0800381 main.step( "Compare Device active links with reference" )
382 for i in range( 1, 26 ):
383 linkResult = main.ONOScli1.getDeviceLinksActiveCount(
384 "of:00000000000000" +
385 format(
386 i,
387 '02x' ) )
388 linkTemp = re.split( r'\t+', linkResult )
389 linkCount = linkTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
390 deviceActiveLinksCount_tmp.append( linkCount )
391 time.sleep( 3 )
392 print (
393 "Device Active links EXPECTED: \n" +
394 str( deviceActiveLinksCount ) )
395 print (
396 "Device Active links ACTUAL: \n" +
397 str( deviceActiveLinksCount_tmp ) )
398 if ( cmp( deviceActiveLinksCount, deviceActiveLinksCount_tmp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800399 stepResult2 = main.TRUE
400 else:
401 stepResult2 = main.FALSE
402
kelvin-onlab8a832582015-01-16 17:06:11 -0800403 """
404 place holder for comparing devices, hosts and paths if required.
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800405 Links and ports data would be incorrect with out devices anyways.
kelvin-onlab8a832582015-01-16 17:06:11 -0800406 """
407 caseResult = ( stepResult1 and stepResult2 )
408 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
409 onpass="Compare Topology test PASS",
410 onfail="Compare Topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800411 if caseResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800412 main.log.report( "Compare Topology test Pass" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800413
kelvin-onlab8a832582015-01-16 17:06:11 -0800414 def CASE6( self ):
415 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800416 Install 300 host intents and verify ping all
kelvin-onlab8a832582015-01-16 17:06:11 -0800417 """
418 main.log.report( "Add 300 host intents and verify pingall" )
419 main.log.report( "_______________________________________" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800420 import itertools
kelvin-onlab8a832582015-01-16 17:06:11 -0800421 main.case( "Install 300 host intents" )
422 main.step( "Add host Intents" )
423 intentResult = main.TRUE
424 hostCombos = list( itertools.combinations( hostMACs, 2 ) )
425 for i in range( len( hostCombos ) ):
Hari Krishnad97213e2015-01-24 19:30:14 -0800426 iResult = main.ONOScli1.addHostIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -0800427 hostCombos[ i ][ 0 ],
428 hostCombos[ i ][ 1 ] )
429 intentResult = ( intentResult and iResult )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800430
kelvin-onlab8a832582015-01-16 17:06:11 -0800431 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800432 pingResult = main.FALSE
433 time1 = time.time()
434 pingResult = main.Mininet1.pingall()
435 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800436 timeDiff = round( ( time2 - time1 ), 2 )
437 main.log.report(
438 "Time taken for Ping All: " +
439 str( timeDiff ) +
440 " seconds" )
441 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
442 onpass="PING ALL PASS",
443 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800444
kelvin-onlab8a832582015-01-16 17:06:11 -0800445 case4Result = ( intentResult and pingResult )
Hari Krishna46997e02015-01-27 11:23:07 -0800446 #case4Result = pingResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800447 utilities.assert_equals(
448 expect=main.TRUE,
449 actual=case4Result,
450 onpass="Install 300 Host Intents and Ping All test PASS",
451 onfail="Install 300 Host Intents and Ping All test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800452
kelvin-onlab8a832582015-01-16 17:06:11 -0800453 def CASE70( self, main ):
454 """
455 Randomly bring some core links down and verify ping all ( Host Intents Scenario )
456 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800457 import random
kelvin-onlab8a832582015-01-16 17:06:11 -0800458 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
459 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
460 link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
461 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
462 link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' )
463 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
464 link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' )
465 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
466 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800467
Hari Krishnad97213e2015-01-24 19:30:14 -0800468 main.log.report( "Host intents - Randomly bring some core links down and verify ping all" )
469 main.log.report( "_________________________________________________________________" )
470 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
471 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800472 if ( int( switchLinksToToggle ) ==
473 0 or int( switchLinksToToggle ) > 5 ):
Hari Krishna46997e02015-01-27 11:23:07 -0800474 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 -0800475 main.cleanup()
476 main.exit()
477 else:
Hari Krishnad97213e2015-01-24 19:30:14 -0800478 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 -0800479
kelvin-onlab8a832582015-01-16 17:06:11 -0800480 main.step( "Cut links on Core devices using user provided range" )
481 randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
482 randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
483 randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
484 for i in range( int( switchLinksToToggle ) ):
485 main.Mininet1.link(
486 END1=link1End1,
487 END2=randomLink1[ i ],
488 OPTION="down" )
489 main.Mininet1.link(
490 END1=link2End1,
491 END2=randomLink2[ i ],
492 OPTION="down" )
493 main.Mininet1.link(
494 END1=link3End1,
495 END2=randomLink3[ i ],
496 OPTION="down" )
497 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800498
499 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800500 linkDown = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -0800501 topology_output, numSwitches, str(
502 int( numLinks ) - int( switchLinksToToggle ) * 6 ) )
503 utilities.assert_equals(
504 expect=main.TRUE,
505 actual=linkDown,
506 onpass="Link Down discovered properly",
507 onfail="Link down was not discovered in " +
508 str( link_sleep ) +
509 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800510
kelvin-onlab8a832582015-01-16 17:06:11 -0800511 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800512 pingResultLinkDown = main.FALSE
513 time1 = time.time()
514 pingResultLinkDown = main.Mininet1.pingall()
515 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800516 timeDiff = round( ( time2 - time1 ), 2 )
517 main.log.report(
518 "Time taken for Ping All: " +
519 str( timeDiff ) +
520 " seconds" )
521 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
522 onpass="PING ALL PASS",
523 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800524
525 caseResult7 = linkDown and pingResultLinkDown
kelvin-onlab8a832582015-01-16 17:06:11 -0800526 utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
527 onpass="Random Link cut Test PASS",
528 onfail="Random Link cut Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800529
kelvin-onlab8a832582015-01-16 17:06:11 -0800530 def CASE80( self, main ):
531 """
532 Bring the core links up that are down and verify ping all ( Host Intents Scenario )
533 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800534 import random
kelvin-onlab8a832582015-01-16 17:06:11 -0800535 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
536 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
537 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
538 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
539 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
540 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800541
kelvin-onlab8a832582015-01-16 17:06:11 -0800542 main.log.report(
543 "Host intents - Bring the core links up that are down and verify ping all" )
544 main.log.report(
545 "__________________________________________________________________" )
546 main.case(
547 "Host intents - Bring the core links up that are down and verify ping all" )
548 main.step( "Bring randomly cut links on Core devices up" )
549 for i in range( int( switchLinksToToggle ) ):
550 main.Mininet1.link(
551 END1=link1End1,
552 END2=randomLink1[ i ],
553 OPTION="up" )
554 main.Mininet1.link(
555 END1=link2End1,
556 END2=randomLink2[ i ],
557 OPTION="up" )
558 main.Mininet1.link(
559 END1=link3End1,
560 END2=randomLink3[ i ],
561 OPTION="up" )
562 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800563
564 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800565 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -0800566 topology_output,
567 numSwitches,
568 str( numLinks ) )
569 utilities.assert_equals(
570 expect=main.TRUE,
571 actual=linkUp,
572 onpass="Link up discovered properly",
573 onfail="Link up was not discovered in " +
574 str( link_sleep ) +
575 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800576
kelvin-onlab8a832582015-01-16 17:06:11 -0800577 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800578 pingResultLinkUp = main.FALSE
579 time1 = time.time()
580 pingResultLinkUp = main.Mininet1.pingall()
581 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800582 timeDiff = round( ( time2 - time1 ), 2 )
583 main.log.report(
584 "Time taken for Ping All: " +
585 str( timeDiff ) +
586 " seconds" )
587 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
588 onpass="PING ALL PASS",
589 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800590
591 caseResult8 = linkUp and pingResultLinkUp
kelvin-onlab8a832582015-01-16 17:06:11 -0800592 utilities.assert_equals( expect=main.TRUE, actual=caseResult8,
593 onpass="Link Up Test PASS",
594 onfail="Link Up Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800595
kelvin-onlab8a832582015-01-16 17:06:11 -0800596 def CASE71( self, main ):
597 """
598 Randomly bring some core links down and verify ping all ( Point Intents Scenario )
599 """
kelvin8ec71442015-01-15 16:57:00 -0800600 import random
kelvin-onlab8a832582015-01-16 17:06:11 -0800601 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
602 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
603 link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
604 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
605 link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' )
606 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
607 link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' )
608 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
609 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin8ec71442015-01-15 16:57:00 -0800610
Hari Krishnad97213e2015-01-24 19:30:14 -0800611 main.log.report( "Point Intents - Randomly bring some core links down and verify ping all" )
612 main.log.report( "__________________________________________________________________" )
613 main.case( "Point Intents - Randomly bring some core links down and verify ping all" )
614 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800615 if ( int( switchLinksToToggle ) ==
616 0 or int( switchLinksToToggle ) > 5 ):
617 main.log.info(
618 "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 -0800619 main.cleanup()
620 main.exit()
621 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800622 main.log.info(
623 "User provided Core switch links range to toggle is correct, proceeding to run the test" )
kelvin8ec71442015-01-15 16:57:00 -0800624
kelvin-onlab8a832582015-01-16 17:06:11 -0800625 main.step( "Cut links on Core devices using user provided range" )
626 randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
627 randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
628 randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
629 for i in range( int( switchLinksToToggle ) ):
630 main.Mininet1.link(
631 END1=link1End1,
632 END2=randomLink1[ i ],
633 OPTION="down" )
634 main.Mininet1.link(
635 END1=link2End1,
636 END2=randomLink2[ i ],
637 OPTION="down" )
638 main.Mininet1.link(
639 END1=link3End1,
640 END2=randomLink3[ i ],
641 OPTION="down" )
642 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -0800643
644 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800645 linkDown = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -0800646 topology_output, numSwitches, str(
647 int( numLinks ) - int( switchLinksToToggle ) * 6 ) )
648 utilities.assert_equals(
649 expect=main.TRUE,
650 actual=linkDown,
651 onpass="Link Down discovered properly",
652 onfail="Link down was not discovered in " +
653 str( link_sleep ) +
654 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -0800655
kelvin-onlab8a832582015-01-16 17:06:11 -0800656 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -0800657 pingResultLinkDown = main.FALSE
658 time1 = time.time()
659 pingResultLinkDown = main.Mininet1.pingall()
660 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800661 timeDiff = round( ( time2 - time1 ), 2 )
662 main.log.report(
663 "Time taken for Ping All: " +
664 str( timeDiff ) +
665 " seconds" )
666 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
667 onpass="PING ALL PASS",
668 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -0800669
670 caseResult7 = linkDown and pingResultLinkDown
kelvin-onlab8a832582015-01-16 17:06:11 -0800671 utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
672 onpass="Random Link cut Test PASS",
673 onfail="Random Link cut Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -0800674
kelvin-onlab8a832582015-01-16 17:06:11 -0800675 def CASE81( self, main ):
676 """
677 Bring the core links up that are down and verify ping all ( Point Intents Scenario )
678 """
kelvin8ec71442015-01-15 16:57:00 -0800679 import random
kelvin-onlab8a832582015-01-16 17:06:11 -0800680 ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
681 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
682 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
683 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
684 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
685 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
kelvin8ec71442015-01-15 16:57:00 -0800686
kelvin-onlab8a832582015-01-16 17:06:11 -0800687 main.log.report(
688 "Point intents - Bring the core links up that are down and verify ping all" )
689 main.log.report(
690 "___________________________________________________________________" )
691 main.case(
692 "Point intents - Bring the core links up that are down and verify ping all" )
693 main.step( "Bring randomly cut links on Core devices up" )
694 for i in range( int( switchLinksToToggle ) ):
695 main.Mininet1.link(
696 END1=link1End1,
697 END2=randomLink1[ i ],
698 OPTION="up" )
699 main.Mininet1.link(
700 END1=link2End1,
701 END2=randomLink2[ i ],
702 OPTION="up" )
703 main.Mininet1.link(
704 END1=link3End1,
705 END2=randomLink3[ i ],
706 OPTION="up" )
707 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -0800708
709 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800710 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -0800711 topology_output,
712 numSwitches,
713 str( numLinks ) )
714 utilities.assert_equals(
715 expect=main.TRUE,
716 actual=linkUp,
717 onpass="Link up discovered properly",
718 onfail="Link up was not discovered in " +
719 str( link_sleep ) +
720 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -0800721
kelvin-onlab8a832582015-01-16 17:06:11 -0800722 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -0800723 pingResultLinkUp = main.FALSE
724 time1 = time.time()
725 pingResultLinkUp = main.Mininet1.pingall()
726 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800727 timeDiff = round( ( time2 - time1 ), 2 )
728 main.log.report(
729 "Time taken for Ping All: " +
730 str( timeDiff ) +
731 " seconds" )
732 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
733 onpass="PING ALL PASS",
734 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -0800735
736 caseResult8 = linkUp and pingResultLinkUp
kelvin-onlab8a832582015-01-16 17:06:11 -0800737 utilities.assert_equals( expect=main.TRUE, actual=caseResult8,
738 onpass="Link Up Test PASS",
739 onfail="Link Up Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -0800740
kelvin-onlab8a832582015-01-16 17:06:11 -0800741 def CASE9( self ):
742 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800743 Install 114 point intents and verify Ping all works
kelvin-onlab8a832582015-01-16 17:06:11 -0800744 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800745 import copy
kelvin-onlab8a832582015-01-16 17:06:11 -0800746 main.log.report( "Install 114 point intents and verify Ping all" )
747 main.log.report( "___________________________________________" )
748 main.case( "Install 114 point intents and Ping all" )
749 deviceLinks_copy = copy.copy( deviceLinks )
750 main.step( "Install 114 point intents" )
751 for i in range( len( deviceLinks_copy ) ):
752 pointLink = str(
753 deviceLinks_copy[ i ] ).replace(
754 "src=",
755 "" ).replace(
756 "dst=",
757 "" ).split( ',' )
758 point1 = pointLink[ 0 ].split( '/' )
759 point2 = pointLink[ 1 ].split( '/' )
Hari Krishnad97213e2015-01-24 19:30:14 -0800760 installResult = main.ONOScli1.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -0800761 point1[ 0 ], point2[ 0 ], int(
762 point1[ 1 ] ), int(
763 point2[ 1 ] ) )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800764 if installResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800765 print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800766
kelvin-onlab8a832582015-01-16 17:06:11 -0800767 main.step( "Obtain the intent id's" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800768 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -0800769 ansi_escape = re.compile( r'\x1b[^m]*m' )
770 intentsList = ansi_escape.sub( '', intentsList )
771 intentsList = intentsList.replace(
772 " onos:intents | grep id=",
773 "" ).replace(
774 "id=",
775 "" ).replace(
776 "\r\r",
777 "" )
778 intentsList = intentsList.splitlines()
779 intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800780 intentIdList = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800781 for i in range( len( intentsList ) ):
782 intentsTemp = intentsList[ i ].split( ',' )
783 intentIdList.append( intentsTemp[ 0 ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800784 print "Intent IDs: ", intentIdList
kelvin-onlab8a832582015-01-16 17:06:11 -0800785 print "Total Intents installed: ", len( intentIdList )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800786
kelvin-onlab8a832582015-01-16 17:06:11 -0800787 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800788 pingResult = main.FALSE
789 time1 = time.time()
790 pingResult = main.Mininet1.pingall()
791 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800792 timeDiff = round( ( time2 - time1 ), 2 )
793 main.log.report(
794 "Time taken for Ping All: " +
795 str( timeDiff ) +
796 " seconds" )
797 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
798 onpass="PING ALL PASS",
799 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800800
801 case8_result = installResult and pingResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800802 utilities.assert_equals(
803 expect=main.TRUE,
804 actual=case8_result,
805 onpass="Ping all test after Point intents addition successful",
806 onfail="Ping all test after Point intents addition failed" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800807
kelvin-onlab8a832582015-01-16 17:06:11 -0800808 def CASE10( self ):
809 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800810 Remove all Intents
kelvin-onlab8a832582015-01-16 17:06:11 -0800811 """
812 main.log.report( "Remove all intents that were installed previously" )
813 main.log.report( "______________________________________________" )
814 main.log.info( "Remove all intents" )
815 main.case( "Removing intents" )
816 main.step( "Obtain the intent id's first" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800817 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -0800818 ansi_escape = re.compile( r'\x1b[^m]*m' )
819 intentsList = ansi_escape.sub( '', intentsList )
820 intentsList = intentsList.replace(
821 " onos:intents | grep id=",
822 "" ).replace(
823 "id=",
824 "" ).replace(
825 "\r\r",
826 "" )
827 intentsList = intentsList.splitlines()
828 intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800829 intentIdList = []
830 step1Result = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800831 if ( len( intentsList ) > 1 ):
832 for i in range( len( intentsList ) ):
833 intentsTemp = intentsList[ i ].split( ',' )
834 intentIdList.append( intentsTemp[ 0 ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800835 print "Intent IDs: ", intentIdList
kelvin-onlab8a832582015-01-16 17:06:11 -0800836 for id in range( len( intentIdList ) ):
837 print "Removing intent id (round 1) :", intentIdList[ id ]
Hari Krishna46997e02015-01-27 11:23:07 -0800838 main.ONOScli1.removeIntent( intentId=intentIdList[ id ] )
kelvin-onlab8a832582015-01-16 17:06:11 -0800839 time.sleep( 1 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800840
kelvin-onlab8a832582015-01-16 17:06:11 -0800841 main.log.info(
842 "Verify all intents are removed and if any leftovers try remove one more time" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800843 intentsList1 = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -0800844 ansi_escape = re.compile( r'\x1b[^m]*m' )
845 intentsList1 = ansi_escape.sub( '', intentsList1 )
846 intentsList1 = intentsList1.replace(
847 " onos:intents | grep id=",
848 "" ).replace(
849 " state=",
850 "" ).replace(
851 "\r\r",
852 "" )
853 intentsList1 = intentsList1.splitlines()
854 intentsList1 = intentsList1[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800855 print "Round 2 (leftover) intents to remove: ", intentsList1
856 intentIdList1 = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800857 if ( len( intentsList1 ) > 1 ):
858 for i in range( len( intentsList1 ) ):
859 intentsTemp1 = intentsList[ i ].split( ',' )
860 intentIdList1.append( intentsTemp1[ 0 ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800861 print "Leftover Intent IDs: ", intentIdList1
kelvin-onlab8a832582015-01-16 17:06:11 -0800862 for id in range( len( intentIdList1 ) ):
863 print "Removing intent id (round 2):", intentIdList1[ id ]
Hari Krishnad97213e2015-01-24 19:30:14 -0800864 main.ONOScli1.removeIntent(
Hari Krishna46997e02015-01-27 11:23:07 -0800865 intentId=intentIdList1[ id ] )
kelvin-onlab8a832582015-01-16 17:06:11 -0800866 time.sleep( 2 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800867 else:
868 print "There are no more intents that need to be removed"
869 step1Result = main.TRUE
870 else:
871 print "No Intent IDs found in Intents list: ", intentsList
872 step1Result = main.FALSE
873
874 caseResult7 = step1Result
kelvin-onlab8a832582015-01-16 17:06:11 -0800875 utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
876 onpass="Intent removal test successful",
877 onfail="Intent removal test failed" )