blob: 7c0987217edad9daaf078f9c285348edaca4a7e3 [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' ]
Hari Krishnab35c6d02015-03-18 11:13:51 -070045 main.newTopo = ""
kelvin-onlab78f7d2d2015-03-02 17:37:35 -080046 main.CLIs = []
47 main.nodes = []
48 for i in range( 1, int(main.numCtrls) + 1 ):
49 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
50 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
51
kelvin-onlab8a832582015-01-16 17:06:11 -080052 main.case( "Set up test environment" )
53 main.log.report( "Set up test environment" )
54 main.log.report( "_______________________" )
55
56 main.step( "Git checkout and pull " + git_branch )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080057 if git_pull == 'on':
Hari Krishnad97213e2015-01-24 19:30:14 -080058 checkout_result = main.ONOSbench.gitCheckout( git_branch )
59 pull_result = main.ONOSbench.gitPull()
kelvin-onlab8a832582015-01-16 17:06:11 -080060 cp_result = ( checkout_result and pull_result )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080061 else:
62 checkout_result = main.TRUE
63 pull_result = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -080064 main.log.info( "Skipped git checkout and pull" )
65 cp_result = ( checkout_result and pull_result )
66 utilities.assert_equals( expect=main.TRUE, actual=cp_result,
67 onpass="Test step PASS",
68 onfail="Test step FAIL" )
69
70 main.step( "mvn clean & install" )
Hari Krishna22c3d412015-02-17 16:48:12 -080071 if git_pull == 'on':
72 mvn_result = main.ONOSbench.cleanInstall()
73 utilities.assert_equals( expect=main.TRUE, actual=mvn_result,
kelvin-onlab8a832582015-01-16 17:06:11 -080074 onpass="Test step PASS",
75 onfail="Test step FAIL" )
Hari Krishna22c3d412015-02-17 16:48:12 -080076 else:
77 mvn_result = main.TRUE
78 main.log.info("Skipped mvn clean install as git pull is disabled in params file")
Hari Krishnaa43d4e92014-12-19 13:22:40 -080079
Hari Krishnad97213e2015-01-24 19:30:14 -080080 main.ONOSbench.getVersion( report=True )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080081
kelvin-onlab8a832582015-01-16 17:06:11 -080082 main.step( "Apply Cell environment for ONOS" )
Hari Krishnad97213e2015-01-24 19:30:14 -080083 cell_result = main.ONOSbench.setCell( cell_name )
kelvin-onlab8a832582015-01-16 17:06:11 -080084 utilities.assert_equals( expect=main.TRUE, actual=cell_result,
85 onpass="Test step PASS",
86 onfail="Test step FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080087
kelvin-onlab8a832582015-01-16 17:06:11 -080088 main.step( "Create ONOS package" )
Hari Krishnad97213e2015-01-24 19:30:14 -080089 packageResult = main.ONOSbench.onosPackage()
kelvin-onlab8a832582015-01-16 17:06:11 -080090 utilities.assert_equals( expect=main.TRUE, actual=packageResult,
91 onpass="Test step PASS",
92 onfail="Test step FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -080093
kelvin-onlab8a832582015-01-16 17:06:11 -080094 main.step( "Uninstall ONOS package on all Nodes" )
95 uninstallResult = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -080096 for i in range( 1, int( main.numCtrls ) + 1 ):
kelvin-onlab8a832582015-01-16 17:06:11 -080097 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
kelvin-onlab54400a92015-02-26 18:05:51 -080098 main.log.info( "Uninstalling package on ONOS Node IP: " + ONOS_ip )
Hari Krishnad97213e2015-01-24 19:30:14 -080099 u_result = main.ONOSbench.onosUninstall( ONOS_ip )
kelvin-onlab8a832582015-01-16 17:06:11 -0800100 utilities.assert_equals( expect=main.TRUE, actual=u_result,
101 onpass="Test step PASS",
102 onfail="Test step FAIL" )
103 uninstallResult = ( uninstallResult and u_result )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800104
Hari Krishnab35c6d02015-03-18 11:13:51 -0700105 #main.step( "Removing copy-cat logs from ONOS nodes" )
106 #main.ONOSbench.onosRemoveRaftLogs()
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800107
kelvin-onlab8a832582015-01-16 17:06:11 -0800108 main.step( "Install ONOS package on all Nodes" )
109 installResult = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -0800110 for i in range( 1, int( main.numCtrls ) + 1 ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800111 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
112 main.log.info( "Intsalling package on ONOS Node IP: " + ONOS_ip )
Hari Krishnad97213e2015-01-24 19:30:14 -0800113 i_result = main.ONOSbench.onosInstall( node=ONOS_ip )
kelvin-onlab8a832582015-01-16 17:06:11 -0800114 utilities.assert_equals( expect=main.TRUE, actual=i_result,
115 onpass="Test step PASS",
116 onfail="Test step FAIL" )
117 installResult = ( installResult and i_result )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800118
kelvin-onlab8a832582015-01-16 17:06:11 -0800119 main.step( "Verify ONOS nodes UP status" )
120 statusResult = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -0800121 for i in range( 1, int( main.numCtrls ) + 1 ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800122 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
123 main.log.info( "ONOS Node " + ONOS_ip + " status:" )
Hari Krishnad97213e2015-01-24 19:30:14 -0800124 onos_status = main.ONOSbench.onosStatus( node=ONOS_ip )
kelvin-onlab8a832582015-01-16 17:06:11 -0800125 utilities.assert_equals( expect=main.TRUE, actual=onos_status,
126 onpass="Test step PASS",
127 onfail="Test step FAIL" )
128 statusResult = ( statusResult and onos_status )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700129
kelvin-onlab8a832582015-01-16 17:06:11 -0800130 main.step( "Start ONOS CLI on all nodes" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800131 cliResult = main.TRUE
kelvin8ec71442015-01-15 16:57:00 -0800132 karafTimeout = "3600000"
kelvin-onlab8a832582015-01-16 17:06:11 -0800133 # need to wait here for sometime. This will be removed once ONOS is
134 # stable enough
kelvin-onlab54400a92015-02-26 18:05:51 -0800135 time.sleep( 25 )
kelvin-onlab54400a92015-02-26 18:05:51 -0800136 main.log.step(" Start ONOS cli using thread ")
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800137 startCliResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800138 pool = []
139 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800140 for i in range( int( main.numCtrls) ):
141 t = main.Thread( target=main.CLIs[i].startOnosCli,
142 threadID=main.threadID,
143 name="startOnosCli",
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")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700155 #main.cleanup()
156 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -0800157 else:
158 main.log.info("Successful CLI startup")
159 startCliResult = main.TRUE
160 case1Result = installResult and uninstallResult and statusResult and startCliResult
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)
Hari Krishnab35c6d02015-03-18 11:13:51 -0700167
kelvin-onlab8a832582015-01-16 17:06:11 -0800168 def CASE2( self, main ):
169 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700170 This test script Loads a new Topology (Att) on CHO setup and balances all switches
kelvin-onlab8a832582015-01-16 17:06:11 -0800171 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800172 import re
173 import time
174 import copy
Hari Krishnab35c6d02015-03-18 11:13:51 -0700175
Hari Krishna22c3d412015-02-17 16:48:12 -0800176 main.numMNswitches = int ( main.params[ 'TOPO1' ][ 'numSwitches' ] )
177 main.numMNlinks = int ( main.params[ 'TOPO1' ][ 'numLinks' ] )
178 main.numMNhosts = int ( main.params[ 'TOPO1' ][ 'numHosts' ] )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700179 main.pingTimeout = 60
kelvin-onlab8a832582015-01-16 17:06:11 -0800180 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -0700181 "Load Att topology and Balance all Mininet switches across controllers" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800182 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -0700183 "________________________________________________________________________" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800184 main.case(
185 "Assign and Balance all Mininet switches across controllers" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700186 main.step( "Stop any previous Mininet network topology" )
187 cliResult = main.TRUE
188 if main.newTopo == main.params['TOPO3']['topo']:
189 stopStatus = main.Mininet1.stopNet( fileName = "topoSpine" )
190
191 main.step( "Start Mininet with Att topology" )
192 main.newTopo = main.params['TOPO1']['topo']
193 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
194
kelvin-onlab8a832582015-01-16 17:06:11 -0800195 main.step( "Assign switches to controllers" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800196 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
Hari Krishnad97213e2015-01-24 19:30:14 -0800197 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800198 sw=str( i ),
Hari Krishna22c3d412015-02-17 16:48:12 -0800199 count=int( main.numCtrls ),
200 ip1=main.ONOS1_ip,
201 port1=main.ONOS1_port,
202 ip2=main.ONOS2_ip,
203 port2=main.ONOS2_port,
204 ip3=main.ONOS3_ip,
205 port3=main.ONOS3_port,
206 ip4=main.ONOS4_ip,
207 port4=main.ONOS4_port,
208 ip5=main.ONOS5_ip,
209 port5=main.ONOS5_port )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800210
211 switch_mastership = main.TRUE
Hari Krishna22c3d412015-02-17 16:48:12 -0800212 for i in range( 1, ( main.numMNswitches + 1 ) ):
Hari Krishnad97213e2015-01-24 19:30:14 -0800213 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800214 print( "Response is " + str( response ) )
Hari Krishna22c3d412015-02-17 16:48:12 -0800215 if re.search( "tcp:" + main.ONOS1_ip, response ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800216 switch_mastership = switch_mastership and main.TRUE
217 else:
218 switch_mastership = main.FALSE
219
220 if switch_mastership == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800221 main.log.report( "Controller assignment successfull" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800222 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800223 main.log.report( "Controller assignment failed" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700224 time.sleep( 5 )
225 #Don't balance master for now..
226 """
227 main.step( "Balance devices across controllers" )
228 for i in range( int( main.numCtrls ) ):
229 balanceResult = main.ONOScli1.balanceMasters()
kelvin-onlab8a832582015-01-16 17:06:11 -0800230 # giving some breathing time for ONOS to complete re-balance
Hari Krishnab35c6d02015-03-18 11:13:51 -0700231 time.sleep( 3 )
232 """
233 case2Result = ( switch_mastership and startStatus )
234 time.sleep(45)
235 utilities.assert_equals(
236 expect=main.TRUE,
237 actual=case2Result,
238 onpass="Starting new Att topology test PASS",
239 onfail="Starting new Att topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800240
kelvin-onlab8a832582015-01-16 17:06:11 -0800241 def CASE3( self, main ):
242 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800243 This Test case will be extended to collect and store more data related
244 ONOS state.
kelvin-onlab8a832582015-01-16 17:06:11 -0800245 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800246 import re
247 import copy
Hari Krishna22c3d412015-02-17 16:48:12 -0800248 main.deviceDPIDs = []
249 main.hostMACs = []
250 main.deviceLinks = []
251 main.deviceActiveLinksCount = []
252 main.devicePortsEnabledCount = []
kelvin-onlab54400a92015-02-26 18:05:51 -0800253
kelvin-onlab8a832582015-01-16 17:06:11 -0800254 main.log.report(
255 "Collect and Store topology details from ONOS before running any Tests" )
256 main.log.report(
257 "____________________________________________________________________" )
Hari Krishna5afb4cc2015-03-23 15:35:15 -0700258 main.case( "Collect and Store Topology Details from ONOS" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800259 main.step( "Collect and store current number of switches and links" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800260 topology_output = main.ONOScli1.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800261 topology_result = main.ONOSbench.getTopology( topology_output )
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700262 numOnosDevices = topology_result[ 'deviceCount' ]
263 numOnosLinks = topology_result[ 'linkCount' ]
Hari Krishnab35c6d02015-03-18 11:13:51 -0700264 topoResult = main.TRUE
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800265
kelvin-onlab54400a92015-02-26 18:05:51 -0800266 if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks >= int(numOnosLinks) ) ):
Hari Krishna22c3d412015-02-17 16:48:12 -0800267 main.step( "Store Device DPIDs" )
268 for i in range( 1, (main.numMNswitches+1) ):
269 main.deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) )
270 print "Device DPIDs in Store: \n", str( main.deviceDPIDs )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800271
Hari Krishna22c3d412015-02-17 16:48:12 -0800272 main.step( "Store Host MACs" )
273 for i in range( 1, ( main.numMNhosts + 1 ) ):
274 main.hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" )
275 print "Host MACs in Store: \n", str( main.hostMACs )
Hari Krishna5afb4cc2015-03-23 15:35:15 -0700276 main.MACsDict = {}
277 for i in range(len(main.deviceDPIDs)):
278 main.MACsDict[main.deviceDPIDs[i]] = main.hostMACs[i].split('/')[0]
279 print main.MACsDict
Hari Krishna22c3d412015-02-17 16:48:12 -0800280 main.step( "Collect and store all Devices Links" )
281 linksResult = main.ONOScli1.links( jsonFormat=False )
282 ansi_escape = re.compile( r'\x1b[^m]*m' )
283 linksResult = ansi_escape.sub( '', linksResult )
284 linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" )
285 linksResult = linksResult.splitlines()
286 linksResult = linksResult[ 1: ]
287 main.deviceLinks = copy.copy( linksResult )
288 print "Device Links Stored: \n", str( main.deviceLinks )
289 # this will be asserted to check with the params provided count of
290 # links
291 print "Length of Links Store", len( main.deviceLinks )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800292
Hari Krishna22c3d412015-02-17 16:48:12 -0800293 main.step( "Collect and store each Device ports enabled Count" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800294 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800295 for i in xrange(1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800296 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800297 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800298 dpid = "of:00000000000000" + format( i,'02x' )
299 t = main.Thread(target = cli.getDevicePortsEnabledCount,threadID = main.threadID, name = "getDevicePortsEnabledCount",args = [dpid])
300 t.start()
301 pool.append(t)
302 i = i + 1
303 main.threadID = main.threadID + 1
304 for thread in pool:
305 thread.join()
306 portResult = thread.result
307 portTemp = re.split( r'\t+', portResult )
308 portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
309 main.devicePortsEnabledCount.append( portCount )
Hari Krishna22c3d412015-02-17 16:48:12 -0800310 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
kelvin-onlab54400a92015-02-26 18:05:51 -0800311 time2 = time.time()
312 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800313
Hari Krishna22c3d412015-02-17 16:48:12 -0800314 main.step( "Collect and store each Device active links Count" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800315 time1 = time.time()
316
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800317 for i in xrange( 1,( main.numMNswitches + 1 ), int( main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800318 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800319 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800320 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800321 t = main.Thread( target = cli.getDeviceLinksActiveCount,
322 threadID = main.threadID,
323 name = "getDevicePortsEnabledCount",
324 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800325 t.start()
326 pool.append(t)
327 i = i + 1
328 main.threadID = main.threadID + 1
329 for thread in pool:
330 thread.join()
331 linkCountResult = thread.result
332 linkCountTemp = re.split( r'\t+', linkCountResult )
333 linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
334 main.deviceActiveLinksCount.append( linkCount )
335 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
336 time2 = time.time()
337 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800338
339 else:
340 main.log.info("Devices (expected): %s, Links (expected): %s" %
341 ( str( main.numMNswitches ), str( main.numMNlinks ) ) )
342 main.log.info("Devices (actual): %s, Links (actual): %s" %
343 ( numOnosDevices , numOnosLinks ) )
344 main.log.info("Topology does not match, exiting CHO test...")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700345 topoResult = main.FALSE
346
kelvin-onlab54400a92015-02-26 18:05:51 -0800347 #time.sleep(300)
Hari Krishnab35c6d02015-03-18 11:13:51 -0700348 #main.cleanup()
349 #main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800350
kelvin-onlab8a832582015-01-16 17:06:11 -0800351 # just returning TRUE for now as this one just collects data
Hari Krishnab35c6d02015-03-18 11:13:51 -0700352 case3Result = topoResult
Hari Krishna22c3d412015-02-17 16:48:12 -0800353 utilities.assert_equals( expect=main.TRUE, actual=case3Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800354 onpass="Saving ONOS topology data test PASS",
355 onfail="Saving ONOS topology data test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800356
kelvin-onlab8a832582015-01-16 17:06:11 -0800357 def CASE4( self, main ):
358 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700359 Verify Reactive forwarding (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -0800360 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800361 import re
362 import copy
363 import time
Hari Krishnab35c6d02015-03-18 11:13:51 -0700364 main.log.report( "Verify Reactive forwarding (Att Topology)" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800365 main.log.report( "______________________________________________" )
366 main.case( "Enable Reactive forwarding and Verify ping all" )
367 main.step( "Enable Reactive forwarding" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800368 installResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800369 feature = "onos-app-fwd"
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800370
kelvin-onlab54400a92015-02-26 18:05:51 -0800371 pool = []
372 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800373 for cli in main.CLIs:
374 t = main.Thread( target=cli.featureInstall,
375 threadID=main.threadID,
376 name="featureInstall",
377 args=['onos-app-fwd'])
kelvin-onlab54400a92015-02-26 18:05:51 -0800378 pool.append(t)
379 t.start()
380 main.threadID = main.threadID + 1
381
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800382 installResult = main.TRUE
383 for t in pool:
384 t.join()
385 installResult = installResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -0800386 time2 = time.time()
387
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800388 if not installResult:
kelvin-onlab54400a92015-02-26 18:05:51 -0800389 main.log.info("Did not install onos-app-fwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700390 #main.cleanup()
391 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -0800392 else:
393 main.log.info("Successful feature:install onos-app-fwd")
kelvin-onlab54400a92015-02-26 18:05:51 -0800394 main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1))
395
kelvin-onlab8a832582015-01-16 17:06:11 -0800396 time.sleep( 5 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800397
kelvin-onlab8a832582015-01-16 17:06:11 -0800398 main.step( "Verify Pingall" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800399 ping_result = main.FALSE
400 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800401 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800402 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800403 timeDiff = round( ( time2 - time1 ), 2 )
404 main.log.report(
405 "Time taken for Ping All: " +
406 str( timeDiff ) +
407 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800408
409 if ping_result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800410 main.log.report( "Pingall Test in Reactive mode successful" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800411 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800412 main.log.report( "Pingall Test in Reactive mode failed" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800413
kelvin-onlab8a832582015-01-16 17:06:11 -0800414 main.step( "Disable Reactive forwarding" )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800415 uninstallResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800416 pool = []
417 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800418 for cli in main.CLIs:
419 t = main.Thread( target=cli.featureUninstall,
420 threadID=main.threadID,
421 name="featureUninstall",
422 args=['onos-app-fwd'])
kelvin-onlab54400a92015-02-26 18:05:51 -0800423 pool.append(t)
424 t.start()
425 main.threadID = main.threadID + 1
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800426 for t in pool:
427 t.join()
428 uninstallResult = uninstallResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -0800429 time2 = time.time()
430
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800431 if not uninstallResult:
kelvin-onlab54400a92015-02-26 18:05:51 -0800432 main.log.info("Did not uninstall onos-app-fwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700433 #main.cleanup()
434 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -0800435 else:
436 main.log.info("Successful feature:uninstall onos-app-fwd")
kelvin-onlab54400a92015-02-26 18:05:51 -0800437 main.log.info("Time for feature:uninstall onos-app-fwd: %2f seconds" %(time2-time1))
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800438
kelvin-onlab8a832582015-01-16 17:06:11 -0800439 # Waiting for reative flows to be cleared.
Hari Krishnab35c6d02015-03-18 11:13:51 -0700440 time.sleep( 20 )
441 case4Result = installResult and uninstallResult and ping_result
442 utilities.assert_equals( expect=main.TRUE, actual=case4Result,
443 onpass="Reactive Mode Pingall test PASS",
444 onfail="Reactive Mode Pingall test FAIL" )
445
446 def CASE41( self, main ):
447 """
448 Verify Reactive forwarding (Chordal Topology)
449 """
450 import re
451 import copy
452 import time
453 main.log.report( "Verify Reactive forwarding (Chordal Topology)" )
454 main.log.report( "______________________________________________" )
455 main.case( "Enable Reactive forwarding and Verify ping all" )
456 main.step( "Enable Reactive forwarding" )
457 installResult = main.TRUE
458 feature = "onos-app-fwd"
459
460 pool = []
461 time1 = time.time()
462 for cli in main.CLIs:
463 t = main.Thread( target=cli.featureInstall,
464 threadID=main.threadID,
465 name="featureInstall",
466 args=['onos-app-fwd'])
467 pool.append(t)
468 t.start()
469 main.threadID = main.threadID + 1
470
471 installResult = main.TRUE
472 for t in pool:
473 t.join()
474 installResult = installResult and t.result
475 time2 = time.time()
476
477 if not installResult:
478 main.log.info("Did not install onos-app-fwd feature properly")
479 #main.cleanup()
480 #main.exit()
481 else:
482 main.log.info("Successful feature:install onos-app-fwd")
483 main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1))
484
kelvin-onlab54400a92015-02-26 18:05:51 -0800485 time.sleep( 5 )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700486
487 main.step( "Verify Pingall" )
488 ping_result = main.FALSE
489 time1 = time.time()
490 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout)
491 time2 = time.time()
492 timeDiff = round( ( time2 - time1 ), 2 )
493 main.log.report(
494 "Time taken for Ping All: " +
495 str( timeDiff ) +
496 " seconds" )
497
498 if ping_result == main.TRUE:
499 main.log.report( "Pingall Test in Reactive mode successful" )
500 else:
501 main.log.report( "Pingall Test in Reactive mode failed" )
502
503 main.step( "Disable Reactive forwarding" )
504 uninstallResult = main.TRUE
505 pool = []
506 time1 = time.time()
507 for cli in main.CLIs:
508 t = main.Thread( target=cli.featureUninstall,
509 threadID=main.threadID,
510 name="featureUninstall",
511 args=['onos-app-fwd'])
512 pool.append(t)
513 t.start()
514 main.threadID = main.threadID + 1
515 for t in pool:
516 t.join()
517 uninstallResult = uninstallResult and t.result
518 time2 = time.time()
519
520 if not uninstallResult:
521 main.log.info("Did not uninstall onos-app-fwd feature properly")
522 #main.cleanup()
523 #main.exit()
524 else:
525 main.log.info("Successful feature:uninstall onos-app-fwd")
526 main.log.info("Time for feature:uninstall onos-app-fwd: %2f seconds" %(time2-time1))
527
528 # Waiting for reative flows to be cleared.
529 time.sleep( 20 )
530 case4Result = installResult and uninstallResult and ping_result
531 utilities.assert_equals( expect=main.TRUE, actual=case4Result,
532 onpass="Reactive Mode Pingall test PASS",
533 onfail="Reactive Mode Pingall test FAIL" )
534
535 def CASE42( self, main ):
536 """
537 Verify Reactive forwarding (Spine Topology)
538 """
539 import re
540 import copy
541 import time
542 main.log.report( "Verify Reactive forwarding (Spine Topology)" )
543 main.log.report( "______________________________________________" )
544 main.case( "Enable Reactive forwarding and Verify ping all" )
545 main.step( "Enable Reactive forwarding" )
546 installResult = main.TRUE
547 feature = "onos-app-fwd"
548
549 pool = []
550 time1 = time.time()
551 for cli in main.CLIs:
552 t = main.Thread( target=cli.featureInstall,
553 threadID=main.threadID,
554 name="featureInstall",
555 args=['onos-app-fwd'])
556 pool.append(t)
557 t.start()
558 main.threadID = main.threadID + 1
559
560 installResult = main.TRUE
561 for t in pool:
562 t.join()
563 installResult = installResult and t.result
564 time2 = time.time()
565
566 if not installResult:
567 main.log.info("Did not install onos-app-fwd feature properly")
568 #main.cleanup()
569 #main.exit()
570 else:
571 main.log.info("Successful feature:install onos-app-fwd")
572 main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1))
573
574 time.sleep( 5 )
575
576 main.step( "Verify Pingall" )
577 ping_result = main.FALSE
578 time1 = time.time()
579 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout)
580 time2 = time.time()
581 timeDiff = round( ( time2 - time1 ), 2 )
582 main.log.report(
583 "Time taken for Ping All: " +
584 str( timeDiff ) +
585 " seconds" )
586
587 if ping_result == main.TRUE:
588 main.log.report( "Pingall Test in Reactive mode successful" )
589 else:
590 main.log.report( "Pingall Test in Reactive mode failed" )
591
592 main.step( "Disable Reactive forwarding" )
593 uninstallResult = main.TRUE
594 pool = []
595 time1 = time.time()
596 for cli in main.CLIs:
597 t = main.Thread( target=cli.featureUninstall,
598 threadID=main.threadID,
599 name="featureUninstall",
600 args=['onos-app-fwd'])
601 pool.append(t)
602 t.start()
603 main.threadID = main.threadID + 1
604 for t in pool:
605 t.join()
606 uninstallResult = uninstallResult and t.result
607 time2 = time.time()
608
609 if not uninstallResult:
610 main.log.info("Did not uninstall onos-app-fwd feature properly")
611 #main.cleanup()
612 #main.exit()
613 else:
614 main.log.info("Successful feature:uninstall onos-app-fwd")
615 main.log.info("Time for feature:uninstall onos-app-fwd: %2f seconds" %(time2-time1))
616
617 # Waiting for reative flows to be cleared.
618 time.sleep( 20 )
kelvin-onlab54400a92015-02-26 18:05:51 -0800619 case4Result = installResult and uninstallResult and ping_result
620 utilities.assert_equals( expect=main.TRUE, actual=case4Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800621 onpass="Reactive Mode Pingall test PASS",
622 onfail="Reactive Mode Pingall test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800623
kelvin-onlab8a832582015-01-16 17:06:11 -0800624 def CASE5( self, main ):
625 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800626 Compare current ONOS topology with reference data
kelvin-onlab8a832582015-01-16 17:06:11 -0800627 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800628 import re
kelvin-onlab54400a92015-02-26 18:05:51 -0800629
Hari Krishna22c3d412015-02-17 16:48:12 -0800630 devicesDPIDTemp = []
631 hostMACsTemp = []
632 deviceLinksTemp = []
633 deviceActiveLinksCountTemp = []
634 devicePortsEnabledCountTemp = []
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800635
kelvin-onlab8a832582015-01-16 17:06:11 -0800636 main.log.report(
637 "Compare ONOS topology with reference data in Stores" )
638 main.log.report( "__________________________________________________" )
639 main.case( "Compare ONOS topology with reference data" )
640
641 main.step( "Compare current Device ports enabled with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800642 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800643 for i in xrange( 1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800644 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800645 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800646 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800647 t = main.Thread(target = cli.getDevicePortsEnabledCount,
648 threadID = main.threadID,
649 name = "getDevicePortsEnabledCount",
650 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800651 t.start()
652 pool.append(t)
653 i = i + 1
654 main.threadID = main.threadID + 1
655 for thread in pool:
656 thread.join()
657 portResult = thread.result
658 portTemp = re.split( r'\t+', portResult )
659 portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
660 devicePortsEnabledCountTemp.append( portCount )
661 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
662 time2 = time.time()
663 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800664 main.log.info (
665 "Device Enabled ports EXPECTED: %s" %
666 str( main.devicePortsEnabledCount ) )
667 main.log.info (
668 "Device Enabled ports ACTUAL: %s" %
669 str( devicePortsEnabledCountTemp ) )
kelvin-onlab54400a92015-02-26 18:05:51 -0800670
Hari Krishna22c3d412015-02-17 16:48:12 -0800671 if ( cmp( main.devicePortsEnabledCount,
672 devicePortsEnabledCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800673 stepResult1 = main.TRUE
674 else:
675 stepResult1 = main.FALSE
676
kelvin-onlab8a832582015-01-16 17:06:11 -0800677 main.step( "Compare Device active links with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800678 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800679 for i in xrange( 1, ( main.numMNswitches + 1) , int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800680 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800681 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800682 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800683 t = main.Thread(target = cli.getDeviceLinksActiveCount,
684 threadID = main.threadID,
685 name = "getDevicePortsEnabledCount",
686 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800687 t.start()
688 pool.append(t)
689 i = i + 1
690 main.threadID = main.threadID + 1
691 for thread in pool:
692 thread.join()
693 linkCountResult = thread.result
694 linkCountTemp = re.split( r'\t+', linkCountResult )
695 linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
696 deviceActiveLinksCountTemp.append( linkCount )
697 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
698 time2 = time.time()
699 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800700 main.log.info (
701 "Device Active links EXPECTED: %s" %
702 str( main.deviceActiveLinksCount ) )
703 main.log.info (
704 "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) )
705 if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800706 stepResult2 = main.TRUE
707 else:
708 stepResult2 = main.FALSE
709
kelvin-onlab8a832582015-01-16 17:06:11 -0800710 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800711 place holder for comparing devices, hosts, paths and intents if required.
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800712 Links and ports data would be incorrect with out devices anyways.
kelvin-onlab8a832582015-01-16 17:06:11 -0800713 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800714 case5Result = ( stepResult1 and stepResult2 )
715 utilities.assert_equals( expect=main.TRUE, actual=case5Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800716 onpass="Compare Topology test PASS",
717 onfail="Compare Topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800718
kelvin-onlab8a832582015-01-16 17:06:11 -0800719 def CASE6( self ):
720 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700721 Install 300 host intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -0800722 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700723 main.log.report( "Add 300 host intents and verify pingall (Att Topology)" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800724 main.log.report( "_______________________________________" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800725 import itertools
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700726 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800727 main.case( "Install 300 host intents" )
728 main.step( "Add host Intents" )
729 intentResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800730 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800731
kelvin-onlab54400a92015-02-26 18:05:51 -0800732 intentIdList = []
733 time1 = time.time()
Hari Krishnab35c6d02015-03-18 11:13:51 -0700734 """
735 for i in xrange(0 ,len(hostCombos)):
736 tempId = ONOScli1.addHostIntent( hostCombos[i][0],hostCombos[i][1]] )
737 intentIdList.append(hostCombos[i][0],hostCombos[i][1]])
738 """
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800739 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800740 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800741 for cli in main.CLIs:
742 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800743 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800744 t = main.Thread( target=cli.addHostIntent,
745 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -0800746 name="addHostIntent",
747 args=[hostCombos[i][0],hostCombos[i][1]])
748 pool.append(t)
Hari Krishnab35c6d02015-03-18 11:13:51 -0700749 #time.sleep(1)
kelvin-onlab54400a92015-02-26 18:05:51 -0800750 t.start()
751 i = i + 1
752 main.threadID = main.threadID + 1
753 for thread in pool:
754 thread.join()
755 intentIdList.append(thread.result)
756 time2 = time.time()
Hari Krishnab35c6d02015-03-18 11:13:51 -0700757 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
kelvin-onlab54400a92015-02-26 18:05:51 -0800758 intentResult = main.TRUE
759 intentsJson = main.ONOScli2.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800760 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
kelvin-onlab54400a92015-02-26 18:05:51 -0800761 intentsJson = intentsJson)
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800762 print getIntentStateResult
Hari Krishnab35c6d02015-03-18 11:13:51 -0700763 # Takes awhile for all the onos to get the intents
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700764 time.sleep(30)
kelvin-onlab8a832582015-01-16 17:06:11 -0800765 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800766 pingResult = main.FALSE
767 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800768 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800769 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800770 timeDiff = round( ( time2 - time1 ), 2 )
771 main.log.report(
772 "Time taken for Ping All: " +
773 str( timeDiff ) +
774 " seconds" )
775 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
776 onpass="PING ALL PASS",
777 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800778
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800779 case6Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -0800780
kelvin-onlab8a832582015-01-16 17:06:11 -0800781 utilities.assert_equals(
782 expect=main.TRUE,
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800783 actual=case6Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800784 onpass="Install 300 Host Intents and Ping All test PASS",
785 onfail="Install 300 Host Intents and Ping All test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800786
kelvin-onlab8a832582015-01-16 17:06:11 -0800787 def CASE70( self, main ):
788 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700789 Randomly bring some core links down and verify ping all ( Host Intents-Att Topo)
kelvin-onlab8a832582015-01-16 17:06:11 -0800790 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800791 import random
Hari Krishna22c3d412015-02-17 16:48:12 -0800792 main.randomLink1 = []
793 main.randomLink2 = []
794 main.randomLink3 = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800795 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
796 link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
797 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
798 link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' )
799 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
800 link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' )
801 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
802 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800803
Hari Krishnab35c6d02015-03-18 11:13:51 -0700804 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" )
805 main.log.report( "___________________________________________________________________________" )
Hari Krishnad97213e2015-01-24 19:30:14 -0800806 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
807 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800808 if ( int( switchLinksToToggle ) ==
809 0 or int( switchLinksToToggle ) > 5 ):
Hari Krishna46997e02015-01-27 11:23:07 -0800810 main.log.info( "Please check your PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700811 #main.cleanup()
812 #main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800813 else:
Hari Krishnad97213e2015-01-24 19:30:14 -0800814 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 -0800815
kelvin-onlab8a832582015-01-16 17:06:11 -0800816 main.step( "Cut links on Core devices using user provided range" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800817 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
818 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
819 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800820 for i in range( int( switchLinksToToggle ) ):
821 main.Mininet1.link(
822 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800823 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800824 OPTION="down" )
825 main.Mininet1.link(
826 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800827 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800828 OPTION="down" )
829 main.Mininet1.link(
830 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800831 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800832 OPTION="down" )
833 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800834
835 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800836 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -0800837 topology_output, main.numMNswitches, str(
838 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800839 utilities.assert_equals(
840 expect=main.TRUE,
841 actual=linkDown,
842 onpass="Link Down discovered properly",
843 onfail="Link down was not discovered in " +
844 str( link_sleep ) +
845 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800846
kelvin-onlab8a832582015-01-16 17:06:11 -0800847 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800848 pingResultLinkDown = main.FALSE
849 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800850 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800851 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800852 timeDiff = round( ( time2 - time1 ), 2 )
853 main.log.report(
854 "Time taken for Ping All: " +
855 str( timeDiff ) +
856 " seconds" )
857 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
858 onpass="PING ALL PASS",
859 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800860
Hari Krishna22c3d412015-02-17 16:48:12 -0800861 caseResult70 = linkDown and pingResultLinkDown
862 utilities.assert_equals( expect=main.TRUE, actual=caseResult70,
kelvin-onlab8a832582015-01-16 17:06:11 -0800863 onpass="Random Link cut Test PASS",
864 onfail="Random Link cut Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800865
kelvin-onlab8a832582015-01-16 17:06:11 -0800866 def CASE80( self, main ):
867 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700868 Bring the core links up that are down and verify ping all ( Host Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -0800869 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800870 import random
kelvin-onlab8a832582015-01-16 17:06:11 -0800871 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
872 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
873 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
874 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
875 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800876
kelvin-onlab8a832582015-01-16 17:06:11 -0800877 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -0700878 "Bring the core links up that are down and verify ping all (Host Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800879 main.log.report(
880 "__________________________________________________________________" )
881 main.case(
882 "Host intents - Bring the core links up that are down and verify ping all" )
883 main.step( "Bring randomly cut links on Core devices up" )
884 for i in range( int( switchLinksToToggle ) ):
885 main.Mininet1.link(
886 END1=link1End1,
kelvin-onlab54400a92015-02-26 18:05:51 -0800887 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800888 OPTION="up" )
889 main.Mininet1.link(
890 END1=link2End1,
kelvin-onlab54400a92015-02-26 18:05:51 -0800891 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800892 OPTION="up" )
893 main.Mininet1.link(
894 END1=link3End1,
kelvin-onlab54400a92015-02-26 18:05:51 -0800895 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800896 OPTION="up" )
897 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800898
899 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800900 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -0800901 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -0800902 main.numMNswitches,
903 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800904 utilities.assert_equals(
905 expect=main.TRUE,
906 actual=linkUp,
907 onpass="Link up discovered properly",
908 onfail="Link up was not discovered in " +
909 str( link_sleep ) +
910 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800911
kelvin-onlab8a832582015-01-16 17:06:11 -0800912 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800913 pingResultLinkUp = main.FALSE
914 time1 = time.time()
915 pingResultLinkUp = main.Mininet1.pingall()
916 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800917 timeDiff = round( ( time2 - time1 ), 2 )
918 main.log.report(
919 "Time taken for Ping All: " +
920 str( timeDiff ) +
921 " seconds" )
922 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
923 onpass="PING ALL PASS",
924 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800925
Hari Krishna22c3d412015-02-17 16:48:12 -0800926 caseResult80 = linkUp and pingResultLinkUp
927 utilities.assert_equals( expect=main.TRUE, actual=caseResult80,
kelvin-onlab8a832582015-01-16 17:06:11 -0800928 onpass="Link Up Test PASS",
929 onfail="Link Up Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800930
kelvin-onlab8a832582015-01-16 17:06:11 -0800931 def CASE71( self, main ):
932 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700933 Randomly bring some core links down and verify ping all ( Point Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -0800934 """
kelvin8ec71442015-01-15 16:57:00 -0800935 import random
Hari Krishna22c3d412015-02-17 16:48:12 -0800936 main.randomLink1 = []
937 main.randomLink2 = []
938 main.randomLink3 = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800939 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
940 link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
941 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
942 link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' )
943 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
944 link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' )
945 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
946 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin8ec71442015-01-15 16:57:00 -0800947
Hari Krishnab35c6d02015-03-18 11:13:51 -0700948 main.log.report( "Randomly bring some core links down and verify ping all (Point Intents-Att Topo" )
Hari Krishnad97213e2015-01-24 19:30:14 -0800949 main.log.report( "__________________________________________________________________" )
950 main.case( "Point Intents - Randomly bring some core links down and verify ping all" )
951 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800952 if ( int( switchLinksToToggle ) ==
953 0 or int( switchLinksToToggle ) > 5 ):
954 main.log.info(
955 "Please check you PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700956 #main.cleanup()
957 #main.exit()
kelvin8ec71442015-01-15 16:57:00 -0800958 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800959 main.log.info(
960 "User provided Core switch links range to toggle is correct, proceeding to run the test" )
kelvin8ec71442015-01-15 16:57:00 -0800961
kelvin-onlab8a832582015-01-16 17:06:11 -0800962 main.step( "Cut links on Core devices using user provided range" )
963 randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
964 randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
965 randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
966 for i in range( int( switchLinksToToggle ) ):
967 main.Mininet1.link(
968 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800969 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800970 OPTION="down" )
971 main.Mininet1.link(
972 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800973 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800974 OPTION="down" )
975 main.Mininet1.link(
976 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800977 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800978 OPTION="down" )
979 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -0800980
981 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800982 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -0800983 topology_output, main.numSwitches, str(
984 int( main.numLinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800985 utilities.assert_equals(
986 expect=main.TRUE,
987 actual=linkDown,
988 onpass="Link Down discovered properly",
989 onfail="Link down was not discovered in " +
990 str( link_sleep ) +
991 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -0800992
kelvin-onlab8a832582015-01-16 17:06:11 -0800993 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -0800994 pingResultLinkDown = main.FALSE
995 time1 = time.time()
996 pingResultLinkDown = main.Mininet1.pingall()
997 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800998 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=pingResultLinkDown,
1004 onpass="PING ALL PASS",
1005 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001006
1007 caseResult7 = linkDown and pingResultLinkDown
kelvin-onlab8a832582015-01-16 17:06:11 -08001008 utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
1009 onpass="Random Link cut Test PASS",
1010 onfail="Random Link cut Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001011
kelvin-onlab8a832582015-01-16 17:06:11 -08001012 def CASE81( self, main ):
1013 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001014 Bring the core links up that are down and verify ping all ( Point Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -08001015 """
kelvin8ec71442015-01-15 16:57:00 -08001016 import random
kelvin-onlab8a832582015-01-16 17:06:11 -08001017 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
1018 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
1019 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
1020 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1021 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
kelvin8ec71442015-01-15 16:57:00 -08001022
kelvin-onlab8a832582015-01-16 17:06:11 -08001023 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -07001024 "Bring the core links up that are down and verify ping all (Point Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001025 main.log.report(
1026 "___________________________________________________________________" )
1027 main.case(
1028 "Point intents - Bring the core links up that are down and verify ping all" )
1029 main.step( "Bring randomly cut links on Core devices up" )
1030 for i in range( int( switchLinksToToggle ) ):
1031 main.Mininet1.link(
1032 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001033 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001034 OPTION="up" )
1035 main.Mininet1.link(
1036 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001037 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001038 OPTION="up" )
1039 main.Mininet1.link(
1040 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001041 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001042 OPTION="up" )
1043 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -08001044
1045 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001046 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -08001047 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -08001048 main.numMNswitches,
1049 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001050 utilities.assert_equals(
1051 expect=main.TRUE,
1052 actual=linkUp,
1053 onpass="Link up discovered properly",
1054 onfail="Link up was not discovered in " +
1055 str( link_sleep ) +
1056 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -08001057
kelvin-onlab8a832582015-01-16 17:06:11 -08001058 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -08001059 pingResultLinkUp = main.FALSE
1060 time1 = time.time()
1061 pingResultLinkUp = main.Mininet1.pingall()
1062 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001063 timeDiff = round( ( time2 - time1 ), 2 )
1064 main.log.report(
1065 "Time taken for Ping All: " +
1066 str( timeDiff ) +
1067 " seconds" )
1068 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1069 onpass="PING ALL PASS",
1070 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001071
Hari Krishna22c3d412015-02-17 16:48:12 -08001072 caseResult81 = linkUp and pingResultLinkUp
1073 utilities.assert_equals( expect=main.TRUE, actual=caseResult81,
kelvin-onlab8a832582015-01-16 17:06:11 -08001074 onpass="Link Up Test PASS",
1075 onfail="Link Up Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001076
Hari Krishnab35c6d02015-03-18 11:13:51 -07001077 def CASE72( self, main ):
1078 """
1079 Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo)
1080 """
1081 import random
1082 import itertools
1083 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1084
1085 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" )
1086 main.log.report( "___________________________________________________________________________" )
1087 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1088 switches = []
1089 switchesComb = []
1090 for i in range( main.numMNswitches ):
1091 switches.append('s%d'%(i+1))
1092 switchesLinksComb = list(itertools.combinations(switches,2))
1093 main.randomLinks = random.sample(switchesLinksComb, 5 )
1094 print main.randomLinks
1095 main.step( "Cut links on random devices" )
1096
1097 for switch in main.randomLinks:
1098 main.Mininet1.link(
1099 END1=switch[0],
1100 END2=switch[1],
1101 OPTION="down")
1102 time.sleep( link_sleep )
1103
1104 topology_output = main.ONOScli2.topology()
1105 linkDown = main.ONOSbench.checkStatus(
1106 topology_output, main.numMNswitches, str(
1107 int( main.numMNlinks ) - 5 * 2 ) )
1108 utilities.assert_equals(
1109 expect=main.TRUE,
1110 actual=linkDown,
1111 onpass="Link Down discovered properly",
1112 onfail="Link down was not discovered in " +
1113 str( link_sleep ) +
1114 " seconds" )
1115
1116 main.step( "Verify Ping across all hosts" )
1117 pingResultLinkDown = main.FALSE
1118 time1 = time.time()
1119 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
1120 time2 = time.time()
1121 timeDiff = round( ( time2 - time1 ), 2 )
1122 main.log.report(
1123 "Time taken for Ping All: " +
1124 str( timeDiff ) +
1125 " seconds" )
1126 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1127 onpass="PING ALL PASS",
1128 onfail="PING ALL FAIL" )
1129
1130 caseResult72 = pingResultLinkDown
1131 utilities.assert_equals( expect=main.TRUE, actual=caseResult72,
1132 onpass="Random Link cut Test PASS",
1133 onfail="Random Link cut Test FAIL" )
1134
1135 def CASE82( self, main ):
1136 """
1137 Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo )
1138 """
1139 import random
1140 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1141
1142 main.log.report(
1143 "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" )
1144 main.log.report(
1145 "__________________________________________________________________" )
1146 main.case(
1147 "Host intents - Bring the core links up that are down and verify ping all" )
1148 main.step( "Bring randomly cut links on devices up" )
1149
1150 for switch in main.randomLinks:
1151 main.Mininet1.link(
1152 END1=switch[0],
1153 END2=switch[1],
1154 OPTION="up")
1155
1156 time.sleep( link_sleep )
1157
1158 topology_output = main.ONOScli2.topology()
1159 linkUp = main.ONOSbench.checkStatus(
1160 topology_output,
1161 main.numMNswitches,
1162 str( main.numMNlinks ) )
1163 utilities.assert_equals(
1164 expect=main.TRUE,
1165 actual=linkUp,
1166 onpass="Link up discovered properly",
1167 onfail="Link up was not discovered in " +
1168 str( link_sleep ) +
1169 " seconds" )
1170
1171 main.step( "Verify Ping across all hosts" )
1172 pingResultLinkUp = main.FALSE
1173 time1 = time.time()
1174 pingResultLinkUp = main.Mininet1.pingall()
1175 time2 = time.time()
1176 timeDiff = round( ( time2 - time1 ), 2 )
1177 main.log.report(
1178 "Time taken for Ping All: " +
1179 str( timeDiff ) +
1180 " seconds" )
1181 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1182 onpass="PING ALL PASS",
1183 onfail="PING ALL FAIL" )
1184
1185 caseResult82 = linkUp and pingResultLinkUp
1186 utilities.assert_equals( expect=main.TRUE, actual=caseResult82,
1187 onpass="Link Up Test PASS",
1188 onfail="Link Up Test FAIL" )
1189
1190 def CASE73( self, main ):
1191 """
1192 Randomly bring some core links down and verify ping all ( Host Intents-Spine Topo)
1193 """
1194 import random
1195 main.pingTimeout = 600
1196 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1197
1198 main.log.report( "Bring some core links down and verify ping all (Host Intents-Spine Topo)" )
1199 main.log.report( "___________________________________________________________________________" )
1200
1201 main.someLinks = [('s1','s9'),('s3','s9'),('s6','s10'),('s8','s10')]
1202 for switch in main.someLinks:
1203 main.Mininet1.link(
1204 END1=switch[0],
1205 END2=switch[1],
1206 OPTION="down" )
1207 time.sleep( link_sleep )
1208
1209 topology_output = main.ONOScli2.topology()
1210 linkDown = main.ONOSbench.checkStatus(
1211 topology_output, main.numMNswitches, str(
1212 int( main.numMNlinks ) - 8 ))
1213 utilities.assert_equals(
1214 expect=main.TRUE,
1215 actual=linkDown,
1216 onpass="Link Down discovered properly",
1217 onfail="Link down was not discovered in " +
1218 str( link_sleep ) +
1219 " seconds" )
1220
1221 main.step( "Verify Ping across all hosts" )
1222 pingResultLinkDown = main.FALSE
1223 time1 = time.time()
1224 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
1225 time2 = time.time()
1226 timeDiff = round( ( time2 - time1 ), 2 )
1227 main.log.report(
1228 "Time taken for Ping All: " +
1229 str( timeDiff ) +
1230 " seconds" )
1231 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1232 onpass="PING ALL PASS",
1233 onfail="PING ALL FAIL" )
1234
1235 caseResult73 = linkDown and pingResultLinkDown
1236 utilities.assert_equals( expect=main.TRUE, actual=caseResult73,
1237 onpass="Random Link cut Test PASS",
1238 onfail="Random Link cut Test FAIL" )
1239
1240 def CASE83( self, main ):
1241 """
1242 Bring the core links up that are down and verify ping all ( Host Intents-Spine Topo )
1243 """
1244 import random
1245
1246 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1247 main.log.report(
1248 "Bring the core links up that are down and verify ping all (Host Intents-Spine Topo" )
1249 main.log.report(
1250 "__________________________________________________________________" )
1251 main.case(
1252 "Host intents - Bring the core links up that are down and verify ping all" )
1253
1254 for switch in main.someLinks:
1255 main.Mininet1.link(
1256 END1=switch[0],
1257 END2=switch[1],
1258 OPTION="up")
1259 time.sleep( link_sleep )
1260
1261 topology_output = main.ONOScli2.topology()
1262 linkUp = main.ONOSbench.checkStatus(
1263 topology_output,
1264 main.numMNswitches,
1265 str( main.numMNlinks ) )
1266 utilities.assert_equals(
1267 expect=main.TRUE,
1268 actual=linkUp,
1269 onpass="Link up discovered properly",
1270 onfail="Link up was not discovered in " +
1271 str( link_sleep ) +
1272 " seconds" )
1273
1274 main.step( "Verify Ping across all hosts" )
1275 pingResultLinkUp = main.FALSE
1276 time1 = time.time()
1277 pingResultLinkUp = main.Mininet1.pingall()
1278 time2 = time.time()
1279 timeDiff = round( ( time2 - time1 ), 2 )
1280 main.log.report(
1281 "Time taken for Ping All: " +
1282 str( timeDiff ) +
1283 " seconds" )
1284 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1285 onpass="PING ALL PASS",
1286 onfail="PING ALL FAIL" )
1287
1288 caseResult83 = linkUp and pingResultLinkUp
1289 utilities.assert_equals( expect=main.TRUE, actual=caseResult83,
1290 onpass="Link Up Test PASS",
1291 onfail="Link Up Test FAIL" )
1292
kelvin-onlab8a832582015-01-16 17:06:11 -08001293 def CASE9( self ):
1294 """
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001295 Install 600 point intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -08001296 """
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001297 main.log.report( "Add 600 point intents and verify pingall (Att Topology)" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001298 main.log.report( "_______________________________________" )
1299 import itertools
1300 import time
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001301 main.case( "Install 600 point intents" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001302 main.step( "Add point Intents" )
1303 intentResult = main.TRUE
1304 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1305
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001306 intentIdList = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07001307 time1 = time.time()
1308 """
1309 for i in xrange(0 ,len(hostCombos)):
1310 tempId = ONOScli1.addHostIntent( hostCombos[i][0],hostCombos[i][1]] )
1311 intentIdList.append(hostCombos[i][0],hostCombos[i][1]])
1312 """
1313 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1314 pool = []
1315 for cli in main.CLIs:
1316 if i >= len( deviceCombos ):
1317 break
1318 t = main.Thread( target=cli.addPointIntent,
1319 threadID=main.threadID,
1320 name="addPointIntent",
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001321 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4","",main.MACsDict.get(deviceCombos[i][1])])
Hari Krishnab35c6d02015-03-18 11:13:51 -07001322 pool.append(t)
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001323 #time.sleep(1)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001324 t.start()
1325 i = i + 1
1326 main.threadID = main.threadID + 1
1327 for thread in pool:
1328 thread.join()
1329 intentIdList.append(thread.result)
1330 time2 = time.time()
1331 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1332 intentResult = main.TRUE
1333 intentsJson = main.ONOScli2.intents()
1334 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1335 intentsJson = intentsJson)
1336 print getIntentStateResult
1337 # Takes awhile for all the onos to get the intents
1338 time.sleep(30)
kelvin-onlab8a832582015-01-16 17:06:11 -08001339 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001340 pingResult = main.FALSE
1341 time1 = time.time()
Hari Krishnab35c6d02015-03-18 11:13:51 -07001342 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001343 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001344 timeDiff = round( ( time2 - time1 ), 2 )
1345 main.log.report(
1346 "Time taken for Ping All: " +
1347 str( timeDiff ) +
1348 " seconds" )
1349 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1350 onpass="PING ALL PASS",
1351 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001352
Hari Krishnab35c6d02015-03-18 11:13:51 -07001353 case6Result = ( intentResult and pingResult )
1354
kelvin-onlab8a832582015-01-16 17:06:11 -08001355 utilities.assert_equals(
1356 expect=main.TRUE,
Hari Krishnab35c6d02015-03-18 11:13:51 -07001357 actual=case6Result,
Hari Krishna5afb4cc2015-03-23 15:35:15 -07001358 onpass="Install 600 point Intents and Ping All test PASS",
1359 onfail="Install 600 point Intents and Ping All test FAIL" )
1360 main.cleanup()
1361 main.exit()
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001362 def CASE90( self ):
1363 """
1364 Install single-multi point intents and verify Ping all works
1365 for att topology
1366 """
1367 import copy
1368 main.log.report( "Install single-multi point intents and verify Ping all" )
1369 main.log.report( "___________________________________________" )
1370 main.case( "Install single-multi point intents and Ping all" )
1371 deviceLinksCopy = copy.copy( main.deviceLinks )
1372 main.step( "Install single-multi point intents" )
1373 for i in range( len( deviceLinksCopy ) ):
1374 pointLink = str(
1375 deviceLinksCopy[ i ] ).replace(
1376 "src=",
1377 "" ).replace(
1378 "dst=",
1379 "" ).split( ',' )
1380 point1 = pointLink[ 0 ].split( '/' )
1381 point2 = pointLink[ 1 ].split( '/' )
1382 installResult = main.ONOScli1.addPointIntent(
1383 point1[ 0 ], point2[ 0 ], int(
1384 point1[ 1 ] ), int(
1385 point2[ 1 ] ) )
1386 if installResult == main.TRUE:
1387 print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
1388
1389 main.step( "Obtain the intent id's" )
1390 intentsList = main.ONOScli1.getAllIntentIds()
1391 ansi_escape = re.compile( r'\x1b[^m]*m' )
1392 intentsList = ansi_escape.sub( '', intentsList )
1393 intentsList = intentsList.replace(
1394 " onos:intents | grep id=",
1395 "" ).replace(
1396 "id=",
1397 "" ).replace(
1398 "\r\r",
1399 "" )
1400 intentsList = intentsList.splitlines()
1401 intentsList = intentsList[ 1: ]
1402 intentIdList = []
1403 for i in range( len( intentsList ) ):
1404 intentsTemp = intentsList[ i ].split( ',' )
1405 intentIdList.append( intentsTemp[ 0 ] )
1406 print "Intent IDs: ", intentIdList
1407 print "Total Intents installed: ", len( intentIdList )
1408
1409 main.step( "Verify Ping across all hosts" )
1410 pingResult = main.FALSE
1411 time1 = time.time()
1412 pingResult = main.Mininet1.pingall()
1413 time2 = time.time()
1414 timeDiff = round( ( time2 - time1 ), 2 )
1415 main.log.report(
1416 "Time taken for Ping All: " +
1417 str( timeDiff ) +
1418 " seconds" )
1419 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1420 onpass="PING ALL PASS",
1421 onfail="PING ALL FAIL" )
1422
1423 case8_result = installResult and pingResult
1424 utilities.assert_equals(
1425 expect=main.TRUE,
1426 actual=case8_result,
1427 onpass="Ping all test after Point intents addition successful",
1428 onfail="Ping all test after Point intents addition failed" )
1429
1430 def CASE91( self ):
1431 """
1432 Install single-multi point intents and verify Ping all works
1433 """
1434 import copy
1435 main.log.report( "Install single-multi point intents and verify Ping all" )
1436 main.log.report( "___________________________________________" )
1437 main.case( "Install single-multi point intents and Ping all" )
1438 deviceLinksCopy = copy.copy( main.deviceLinks )
1439 main.step( "Install single-multi point intents" )
1440 for i in range( len( deviceLinksCopy ) ):
1441 pointLink = str(
1442 deviceLinksCopy[ i ] ).replace(
1443 "src=",
1444 "" ).replace(
1445 "dst=",
1446 "" ).split( ',' )
1447 point1 = pointLink[ 0 ].split( '/' )
1448 point2 = pointLink[ 1 ].split( '/' )
1449 installResult = main.ONOScli1.addPointIntent(
1450 point1[ 0 ], point2[ 0 ], int(
1451 point1[ 1 ] ), int(
1452 point2[ 1 ] ) )
1453 if installResult == main.TRUE:
1454 print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
1455
1456 main.step( "Obtain the intent id's" )
1457 intentsList = main.ONOScli1.getAllIntentIds()
1458 ansi_escape = re.compile( r'\x1b[^m]*m' )
1459 intentsList = ansi_escape.sub( '', intentsList )
1460 intentsList = intentsList.replace(
1461 " onos:intents | grep id=",
1462 "" ).replace(
1463 "id=",
1464 "" ).replace(
1465 "\r\r",
1466 "" )
1467 intentsList = intentsList.splitlines()
1468 intentsList = intentsList[ 1: ]
1469 intentIdList = []
1470 for i in range( len( intentsList ) ):
1471 intentsTemp = intentsList[ i ].split( ',' )
1472 intentIdList.append( intentsTemp[ 0 ] )
1473 print "Intent IDs: ", intentIdList
1474 print "Total Intents installed: ", len( intentIdList )
1475
1476 main.step( "Verify Ping across all hosts" )
1477 pingResult = main.FALSE
1478 time1 = time.time()
1479 pingResult = main.Mininet1.pingall()
1480 time2 = time.time()
1481 timeDiff = round( ( time2 - time1 ), 2 )
1482 main.log.report(
1483 "Time taken for Ping All: " +
1484 str( timeDiff ) +
1485 " seconds" )
1486 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1487 onpass="PING ALL PASS",
1488 onfail="PING ALL FAIL" )
1489
1490 case8_result = installResult and pingResult
1491 utilities.assert_equals(
1492 expect=main.TRUE,
1493 actual=case8_result,
1494 onpass="Ping all test after Point intents addition successful",
1495 onfail="Ping all test after Point intents addition failed" )
1496
1497 def CASE92( self ):
1498 """
1499 Install 114 point intents and verify Ping all works
1500 """
1501 import copy
1502 main.log.report( "Install 114 point intents and verify Ping all" )
1503 main.log.report( "___________________________________________" )
1504 main.case( "Install 114 point intents and Ping all" )
1505 deviceLinksCopy = copy.copy( main.deviceLinks )
1506 main.step( "Install 114 point intents" )
1507 for i in range( len( deviceLinksCopy ) ):
1508 pointLink = str(
1509 deviceLinksCopy[ i ] ).replace(
1510 "src=",
1511 "" ).replace(
1512 "dst=",
1513 "" ).split( ',' )
1514 point1 = pointLink[ 0 ].split( '/' )
1515 point2 = pointLink[ 1 ].split( '/' )
1516 installResult = main.ONOScli1.addPointIntent(
1517 point1[ 0 ], point2[ 0 ], int(
1518 point1[ 1 ] ), int(
1519 point2[ 1 ] ) )
1520 if installResult == main.TRUE:
1521 print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
1522
1523 main.step( "Obtain the intent id's" )
1524 intentsList = main.ONOScli1.getAllIntentIds()
1525 ansi_escape = re.compile( r'\x1b[^m]*m' )
1526 intentsList = ansi_escape.sub( '', intentsList )
1527 intentsList = intentsList.replace(
1528 " onos:intents | grep id=",
1529 "" ).replace(
1530 "id=",
1531 "" ).replace(
1532 "\r\r",
1533 "" )
1534 intentsList = intentsList.splitlines()
1535 intentsList = intentsList[ 1: ]
1536 intentIdList = []
1537 for i in range( len( intentsList ) ):
1538 intentsTemp = intentsList[ i ].split( ',' )
1539 intentIdList.append( intentsTemp[ 0 ] )
1540 print "Intent IDs: ", intentIdList
1541 print "Total Intents installed: ", len( intentIdList )
1542
1543 main.step( "Verify Ping across all hosts" )
1544 pingResult = main.FALSE
1545 time1 = time.time()
1546 pingResult = main.Mininet1.pingall()
1547 time2 = time.time()
1548 timeDiff = round( ( time2 - time1 ), 2 )
1549 main.log.report(
1550 "Time taken for Ping All: " +
1551 str( timeDiff ) +
1552 " seconds" )
1553 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1554 onpass="PING ALL PASS",
1555 onfail="PING ALL FAIL" )
1556
1557 case8_result = installResult and pingResult
1558 utilities.assert_equals(
1559 expect=main.TRUE,
1560 actual=case8_result,
1561 onpass="Ping all test after Point intents addition successful",
1562 onfail="Ping all test after Point intents addition failed" )
1563
kelvin-onlab8a832582015-01-16 17:06:11 -08001564 def CASE10( self ):
kelvin-onlab7642bb12015-02-27 13:48:17 -08001565 import time
kelvin-onlab8a832582015-01-16 17:06:11 -08001566 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001567 Remove all Intents
kelvin-onlab8a832582015-01-16 17:06:11 -08001568 """
1569 main.log.report( "Remove all intents that were installed previously" )
1570 main.log.report( "______________________________________________" )
1571 main.log.info( "Remove all intents" )
1572 main.case( "Removing intents" )
1573 main.step( "Obtain the intent id's first" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001574 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -08001575 ansi_escape = re.compile( r'\x1b[^m]*m' )
1576 intentsList = ansi_escape.sub( '', intentsList )
1577 intentsList = intentsList.replace(
1578 " onos:intents | grep id=",
1579 "" ).replace(
1580 "id=",
1581 "" ).replace(
1582 "\r\r",
1583 "" )
1584 intentsList = intentsList.splitlines()
1585 intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001586 intentIdList = []
1587 step1Result = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001588 moreIntents = main.TRUE
1589 removeIntentCount = 0
1590 print "Current number of intents" , len(intentsList)
kelvin-onlab8a832582015-01-16 17:06:11 -08001591 if ( len( intentsList ) > 1 ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001592 results = main.TRUE
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07001593 main.log.info("Removing intent...")
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001594 while moreIntents:
Hari Krishnab35c6d02015-03-18 11:13:51 -07001595 if removeIntentCount == 5:
1596 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001597 removeIntentCount = removeIntentCount + 1
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001598 intentsList1 = main.ONOScli1.getAllIntentIds()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07001599 if len( intentsList1 ) == 0:
1600 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001601 ansi_escape = re.compile( r'\x1b[^m]*m' )
1602 intentsList1 = ansi_escape.sub( '', intentsList1 )
1603 intentsList1 = intentsList1.replace(
1604 " onos:intents | grep id=",
1605 "" ).replace(
1606 " state=",
1607 "" ).replace(
1608 "\r\r",
1609 "" )
1610 intentsList1 = intentsList1.splitlines()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07001611 intentsList1 = intentsList1[ 1: ]
1612 print "Round %d intents to remove: " %(removeIntentCount)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001613 print intentsList1
1614 intentIdList1 = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07001615 if ( len( intentsList1 ) > 0 ):
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07001616 moreIntents = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001617 for i in range( len( intentsList1 ) ):
1618 intentsTemp1 = intentsList1[ i ].split( ',' )
1619 intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] )
1620 print "Leftover Intent IDs: ", intentIdList1
1621 print len(intentIdList1)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001622 for intent in intentIdList1:
kelvin-onlab36c02b12015-03-11 11:25:55 -07001623 main.CLIs[0].removeIntent(intent,'org.onosproject.cli',True,False)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001624 time.sleep(10)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001625 else:
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07001626 time.sleep(15)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001627 if len( main.ONOScli1.intents()):
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07001628 continue
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001629 break
kelvin-onlab36c02b12015-03-11 11:25:55 -07001630
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001631 else:
1632 print "There are no more intents that need to be removed"
1633 step1Result = main.TRUE
1634 else:
1635 print "No Intent IDs found in Intents list: ", intentsList
1636 step1Result = main.FALSE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001637
kelvin-onlabdc8719b2015-03-02 14:01:52 -08001638 print main.ONOScli1.intents()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07001639 # time.sleep(300)
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001640 caseResult10 = step1Result
1641 utilities.assert_equals( expect=main.TRUE, actual=caseResult10,
kelvin-onlab8a832582015-01-16 17:06:11 -08001642 onpass="Intent removal test successful",
1643 onfail="Intent removal test failed" )
Hari Krishna22c3d412015-02-17 16:48:12 -08001644
1645 def CASE11( self, main ):
1646 """
1647 Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it
1648 """
1649 import re
1650 import copy
1651 import time
1652
kelvin-onlab54400a92015-02-26 18:05:51 -08001653 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
1654 threadID = 0
1655
Hari Krishna22c3d412015-02-17 16:48:12 -08001656 main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" )
1657 main.log.report( "_____________________________________________________" )
1658 main.case( "Enable Intent based Reactive forwarding and Verify ping all" )
1659 main.step( "Enable intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001660 installResult = main.FALSE
1661 feature = "onos-app-ifwd"
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001662
kelvin-onlab54400a92015-02-26 18:05:51 -08001663 pool = []
1664 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001665 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08001666 t = main.Thread(target=cli,threadID=threadID,
1667 name="featureInstall",args=[feature])
1668 pool.append(t)
1669 t.start()
1670 threadID = threadID + 1
1671
1672 results = []
1673 for thread in pool:
1674 thread.join()
1675 results.append(thread.result)
1676 time2 = time.time()
1677
1678 if( all(result == main.TRUE for result in results) == False):
1679 main.log.info("Did not install onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07001680 #main.cleanup()
1681 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08001682 else:
1683 main.log.info("Successful feature:install onos-app-ifwd")
1684 installResult = main.TRUE
1685 main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1))
1686
Hari Krishna22c3d412015-02-17 16:48:12 -08001687 main.step( "Verify Pingall" )
1688 ping_result = main.FALSE
1689 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08001690 ping_result = main.Mininet1.pingall(timeout=600)
Hari Krishna22c3d412015-02-17 16:48:12 -08001691 time2 = time.time()
1692 timeDiff = round( ( time2 - time1 ), 2 )
1693 main.log.report(
1694 "Time taken for Ping All: " +
1695 str( timeDiff ) +
1696 " seconds" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001697
Hari Krishna22c3d412015-02-17 16:48:12 -08001698 if ping_result == main.TRUE:
1699 main.log.report( "Pingall Test in Reactive mode successful" )
1700 else:
1701 main.log.report( "Pingall Test in Reactive mode failed" )
1702
1703 main.step( "Disable Intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001704 uninstallResult = main.FALSE
1705
kelvin-onlab54400a92015-02-26 18:05:51 -08001706 pool = []
1707 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001708 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08001709 t = main.Thread(target=cli,threadID=threadID,
1710 name="featureUninstall",args=[feature])
1711 pool.append(t)
1712 t.start()
1713 threadID = threadID + 1
1714
1715 results = []
1716 for thread in pool:
1717 thread.join()
1718 results.append(thread.result)
1719 time2 = time.time()
1720
1721 if( all(result == main.TRUE for result in results) == False):
1722 main.log.info("Did not uninstall onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07001723 uninstallResult = main.FALSE
1724 #main.cleanup()
1725 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08001726 else:
1727 main.log.info("Successful feature:uninstall onos-app-ifwd")
1728 uninstallResult = main.TRUE
1729 main.log.info("Time for feature:uninstall onos-app-ifwd: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08001730
1731 # Waiting for reative flows to be cleared.
1732 time.sleep( 10 )
1733
1734 case11Result = installResult and ping_result and uninstallResult
1735 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
1736 onpass="Intent based Reactive forwarding Pingall test PASS",
1737 onfail="Intent based Reactive forwarding Pingall test FAIL" )
1738
1739 def CASE12( self, main ):
1740 """
1741 This test script Loads a new Topology (Chordal) on CHO setup and balances all switches
1742 """
1743 import re
1744 import time
1745 import copy
1746
Hari Krishnab35c6d02015-03-18 11:13:51 -07001747 main.newTopo = main.params['TOPO2']['topo']
Hari Krishna22c3d412015-02-17 16:48:12 -08001748 main.numMNswitches = int ( main.params[ 'TOPO2' ][ 'numSwitches' ] )
1749 main.numMNlinks = int ( main.params[ 'TOPO2' ][ 'numLinks' ] )
1750 main.numMNhosts = int ( main.params[ 'TOPO2' ][ 'numHosts' ] )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001751 main.pingTimeout = 120
Hari Krishna22c3d412015-02-17 16:48:12 -08001752 main.log.report(
1753 "Load Chordal topology and Balance all Mininet switches across controllers" )
1754 main.log.report(
1755 "________________________________________________________________________" )
Hari Krishna22c3d412015-02-17 16:48:12 -08001756 main.case(
1757 "Assign and Balance all Mininet switches across controllers" )
1758 main.step( "Stop any previous Mininet network topology" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001759 stopStatus = main.Mininet1.stopNet(fileName = "topoChordal" )
1760 time.sleep(10)
Hari Krishna22c3d412015-02-17 16:48:12 -08001761 main.step( "Start Mininet with Chordal topology" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001762 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
1763 time.sleep(15)
Hari Krishna22c3d412015-02-17 16:48:12 -08001764 main.step( "Assign switches to controllers" )
1765 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
1766 main.Mininet1.assignSwController(
1767 sw=str( i ),
1768 count=int( main.numCtrls ),
1769 ip1=main.ONOS1_ip,
1770 port1=main.ONOS1_port,
1771 ip2=main.ONOS2_ip,
1772 port2=main.ONOS2_port,
1773 ip3=main.ONOS3_ip,
1774 port3=main.ONOS3_port,
1775 ip4=main.ONOS4_ip,
1776 port4=main.ONOS4_port,
1777 ip5=main.ONOS5_ip,
1778 port5=main.ONOS5_port )
1779
1780 switch_mastership = main.TRUE
1781 for i in range( 1, ( main.numMNswitches + 1 ) ):
1782 response = main.Mininet1.getSwController( "s" + str( i ) )
1783 print( "Response is " + str( response ) )
1784 if re.search( "tcp:" + main.ONOS1_ip, response ):
1785 switch_mastership = switch_mastership and main.TRUE
1786 else:
1787 switch_mastership = main.FALSE
1788
1789 if switch_mastership == main.TRUE:
1790 main.log.report( "Controller assignment successfull" )
1791 else:
1792 main.log.report( "Controller assignment failed" )
1793 time.sleep( 5 )
kelvin-onlab54400a92015-02-26 18:05:51 -08001794
Hari Krishnab35c6d02015-03-18 11:13:51 -07001795 #Don't balance master for now..
1796 """
Hari Krishna22c3d412015-02-17 16:48:12 -08001797 main.step( "Balance devices across controllers" )
1798 for i in range( int( main.numCtrls ) ):
1799 balanceResult = main.ONOScli1.balanceMasters()
1800 # giving some breathing time for ONOS to complete re-balance
1801 time.sleep( 3 )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001802 """
1803 case12Result = switch_mastership
1804 time.sleep(30)
Hari Krishna22c3d412015-02-17 16:48:12 -08001805 utilities.assert_equals(
1806 expect=main.TRUE,
1807 actual=case12Result,
1808 onpass="Starting new Chordal topology test PASS",
1809 onfail="Starting new Chordal topology test FAIL" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001810
Hari Krishna22c3d412015-02-17 16:48:12 -08001811 def CASE13( self, main ):
1812 """
1813 This test script Loads a new Topology (Spine) on CHO setup and balances all switches
1814 """
1815 import re
1816 import time
1817 import copy
1818
Hari Krishnab35c6d02015-03-18 11:13:51 -07001819 main.newTopo = main.params['TOPO3']['topo']
Hari Krishna22c3d412015-02-17 16:48:12 -08001820 main.numMNswitches = int ( main.params[ 'TOPO3' ][ 'numSwitches' ] )
1821 main.numMNlinks = int ( main.params[ 'TOPO3' ][ 'numLinks' ] )
1822 main.numMNhosts = int ( main.params[ 'TOPO3' ][ 'numHosts' ] )
kelvin-onlab54400a92015-02-26 18:05:51 -08001823 main.pingTimeout = 600
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07001824
Hari Krishna22c3d412015-02-17 16:48:12 -08001825 main.log.report(
1826 "Load Spine and Leaf topology and Balance all Mininet switches across controllers" )
1827 main.log.report(
1828 "________________________________________________________________________" )
1829 # need to wait here for sometime until ONOS bootup
Hari Krishna22c3d412015-02-17 16:48:12 -08001830 main.case(
1831 "Assign and Balance all Mininet switches across controllers" )
1832 main.step( "Stop any previous Mininet network topology" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001833 stopStatus = main.Mininet1.stopNet(fileName = "topoSpine" )
Hari Krishna22c3d412015-02-17 16:48:12 -08001834 main.step( "Start Mininet with Spine topology" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001835 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
1836 time.sleep(20)
Hari Krishna22c3d412015-02-17 16:48:12 -08001837 main.step( "Assign switches to controllers" )
1838 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
1839 main.Mininet1.assignSwController(
1840 sw=str( i ),
Hari Krishnab35c6d02015-03-18 11:13:51 -07001841 count= 1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001842 ip1=main.ONOS1_ip,
1843 port1=main.ONOS1_port,
1844 ip2=main.ONOS2_ip,
1845 port2=main.ONOS2_port,
1846 ip3=main.ONOS3_ip,
1847 port3=main.ONOS3_port,
1848 ip4=main.ONOS4_ip,
1849 port4=main.ONOS4_port,
1850 ip5=main.ONOS5_ip,
1851 port5=main.ONOS5_port )
1852
1853 switch_mastership = main.TRUE
1854 for i in range( 1, ( main.numMNswitches + 1 ) ):
1855 response = main.Mininet1.getSwController( "s" + str( i ) )
1856 print( "Response is " + str( response ) )
1857 if re.search( "tcp:" + main.ONOS1_ip, response ):
1858 switch_mastership = switch_mastership and main.TRUE
1859 else:
1860 switch_mastership = main.FALSE
Hari Krishnab35c6d02015-03-18 11:13:51 -07001861
Hari Krishna22c3d412015-02-17 16:48:12 -08001862 if switch_mastership == main.TRUE:
1863 main.log.report( "Controller assignment successfull" )
1864 else:
1865 main.log.report( "Controller assignment failed" )
1866 time.sleep( 5 )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001867 """
kelvin-onlab54400a92015-02-26 18:05:51 -08001868 main.step( "Balance devices across controllers" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001869
kelvin-onlab54400a92015-02-26 18:05:51 -08001870 for i in range( int( main.numCtrls ) ):
1871 balanceResult = main.ONOScli1.balanceMasters()
1872 # giving some breathing time for ONOS to complete re-balance
1873 time.sleep( 3 )
Hari Krishna22c3d412015-02-17 16:48:12 -08001874
1875 main.step( "Balance devices across controllers" )
1876 for i in range( int( main.numCtrls ) ):
1877 balanceResult = main.ONOScli1.balanceMasters()
1878 # giving some breathing time for ONOS to complete re-balance
1879 time.sleep( 3 )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001880 """
1881 case13Result = switch_mastership
1882 time.sleep(30)
Hari Krishna22c3d412015-02-17 16:48:12 -08001883 utilities.assert_equals(
1884 expect=main.TRUE,
1885 actual=case13Result,
1886 onpass="Starting new Spine topology test PASS",
1887 onfail="Starting new Spine topology test FAIL" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001888
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001889 def CASE14( self ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001890 """
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001891 Install 300 host intents and verify ping all for Chordal Topology
kelvin-onlab54400a92015-02-26 18:05:51 -08001892 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001893 main.log.report( "Add 300 host intents and verify pingall (Chordal Topo)" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001894 main.log.report( "_______________________________________" )
1895 import itertools
1896
1897 main.case( "Install 300 host intents" )
1898 main.step( "Add host Intents" )
1899 intentResult = main.TRUE
1900 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
1901
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001902 intentIdList = []
kelvin-onlab54400a92015-02-26 18:05:51 -08001903 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001904
1905 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001906 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001907 for cli in main.CLIs:
1908 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001909 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001910 t = main.Thread( target=cli.addHostIntent,
1911 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -08001912 name="addHostIntent",
1913 args=[hostCombos[i][0],hostCombos[i][1]])
1914 pool.append(t)
1915 t.start()
1916 i = i + 1
1917 main.threadID = main.threadID + 1
kelvin-onlab54400a92015-02-26 18:05:51 -08001918 for thread in pool:
1919 thread.join()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001920 intentIdList.append(thread.result)
kelvin-onlab54400a92015-02-26 18:05:51 -08001921 time2 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08001922 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001923 intentResult = main.TRUE
1924 intentsJson = main.ONOScli2.intents()
1925 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1926 intentsJson = intentsJson)
1927 print getIntentStateResult
1928
kelvin-onlab54400a92015-02-26 18:05:51 -08001929 main.step( "Verify Ping across all hosts" )
1930 pingResult = main.FALSE
1931 time1 = time.time()
1932 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1933 time2 = time.time()
1934 timeDiff = round( ( time2 - time1 ), 2 )
1935 main.log.report(
1936 "Time taken for Ping All: " +
1937 str( timeDiff ) +
1938 " seconds" )
1939 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1940 onpass="PING ALL PASS",
1941 onfail="PING ALL FAIL" )
1942
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001943 case14Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -08001944
kelvin-onlab54400a92015-02-26 18:05:51 -08001945 utilities.assert_equals(
1946 expect=main.TRUE,
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001947 actual=case14Result,
kelvin-onlab54400a92015-02-26 18:05:51 -08001948 onpass="Install 300 Host Intents and Ping All test PASS",
1949 onfail="Install 300 Host Intents and Ping All test FAIL" )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001950
1951 def CASE15( self ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001952 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001953 Install 2278 host intents and verify ping all for Spine Topology
kelvin-onlab54400a92015-02-26 18:05:51 -08001954 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001955 main.log.report( "Add 2278 host intents and verify pingall (Spine Topo)" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001956 main.log.report( "_______________________________________" )
1957 import itertools
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001958
Hari Krishnab35c6d02015-03-18 11:13:51 -07001959 main.case( "Install 2278 host intents" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001960 main.step( "Add host Intents" )
1961 intentResult = main.TRUE
1962 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001963 main.pingTimeout = 300
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001964 intentIdList = []
kelvin-onlab54400a92015-02-26 18:05:51 -08001965 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001966 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001967 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001968 for cli in main.CLIs:
1969 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001970 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001971 t = main.Thread( target=cli.addHostIntent,
1972 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -08001973 name="addHostIntent",
1974 args=[hostCombos[i][0],hostCombos[i][1]])
1975 pool.append(t)
1976 t.start()
1977 i = i + 1
1978 main.threadID = main.threadID + 1
kelvin-onlab54400a92015-02-26 18:05:51 -08001979 for thread in pool:
1980 thread.join()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001981 intentIdList.append(thread.result)
kelvin-onlab54400a92015-02-26 18:05:51 -08001982 time2 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08001983 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001984 intentResult = main.TRUE
1985 intentsJson = main.ONOScli2.intents()
1986 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1987 intentsJson = intentsJson)
1988 print getIntentStateResult
1989
kelvin-onlab54400a92015-02-26 18:05:51 -08001990 main.step( "Verify Ping across all hosts" )
1991 pingResult = main.FALSE
1992 time1 = time.time()
1993 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1994 time2 = time.time()
1995 timeDiff = round( ( time2 - time1 ), 2 )
1996 main.log.report(
1997 "Time taken for Ping All: " +
1998 str( timeDiff ) +
1999 " seconds" )
2000 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
2001 onpass="PING ALL PASS",
2002 onfail="PING ALL FAIL" )
2003
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002004 case15Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -08002005
kelvin-onlab54400a92015-02-26 18:05:51 -08002006 utilities.assert_equals(
2007 expect=main.TRUE,
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002008 actual=case15Result,
Hari Krishnab35c6d02015-03-18 11:13:51 -07002009 onpass="Install 2278 Host Intents and Ping All test PASS",
2010 onfail="Install 2278 Host Intents and Ping All test FAIL" )
2011
2012 def CASE99(self):
2013 import time
2014 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
2015 main.step( "Stop ONOS on all Nodes" )
2016 stopResult = main.TRUE
2017 for i in range( 1, int( main.numCtrls ) + 1 ):
2018 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2019 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
2020 sresult = main.ONOSbench.onosStop( ONOS_ip )
2021 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2022 onpass="Test step PASS",
2023 onfail="Test step FAIL" )
2024 stopResult = ( stopResult and sresult )
2025
2026 main.step( "Start ONOS on all Nodes" )
2027 startResult = main.TRUE
2028 for i in range( 1, int( main.numCtrls ) + 1 ):
2029 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2030 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
2031 sresult = main.ONOSbench.onosStart( ONOS_ip )
2032 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2033 onpass="Test step PASS",
2034 onfail="Test step FAIL" )
2035 startResult = ( startResult and sresult )
2036
2037 main.step( "Start ONOS CLI on all nodes" )
2038 cliResult = main.TRUE
2039 time.sleep( 30 )
2040 main.log.step(" Start ONOS cli using thread ")
2041 pool = []
2042 time1 = time.time()
2043 for i in range( int( main.numCtrls ) ):
2044 t = main.Thread(target=main.CLIs[i].startOnosCli,
2045 threadID=main.threadID,
2046 name="startOnosCli",
2047 args=[main.nodes[i].ip_address])
2048 pool.append(t)
2049 t.start()
2050 main.threadID = main.threadID + 1
2051 for t in pool:
2052 t.join()
2053 cliResult = cliResult and t.result
2054 time2 = time.time()
2055
2056 if not cliResult:
2057 main.log.info("ONOS CLI did not start up properly")
2058 #main.cleanup()
2059 #main.exit()
2060 else:
2061 main.log.info("Successful CLI startup")
2062 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
2063
2064 case99Result = ( startResult and cliResult )
2065 time.sleep(30)
2066 utilities.assert_equals(
2067 expect=main.TRUE,
2068 actual=case99Result,
2069 onpass="Starting new Chordal topology test PASS",
2070 onfail="Starting new Chordal topology test FAIL" )
2071
2072
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002073
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002074