blob: d7b1e4d0a7c225cf3bca2a56b4b3ff508abe68c2 [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 "____________________________________________________________________" )
258 main.case( "Collect and Store Topology Deatils 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 Krishnaa43d4e92014-12-19 13:22:40 -0800276
Hari Krishna22c3d412015-02-17 16:48:12 -0800277 main.step( "Collect and store all Devices Links" )
278 linksResult = main.ONOScli1.links( jsonFormat=False )
279 ansi_escape = re.compile( r'\x1b[^m]*m' )
280 linksResult = ansi_escape.sub( '', linksResult )
281 linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" )
282 linksResult = linksResult.splitlines()
283 linksResult = linksResult[ 1: ]
284 main.deviceLinks = copy.copy( linksResult )
285 print "Device Links Stored: \n", str( main.deviceLinks )
286 # this will be asserted to check with the params provided count of
287 # links
288 print "Length of Links Store", len( main.deviceLinks )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800289
Hari Krishna22c3d412015-02-17 16:48:12 -0800290 main.step( "Collect and store each Device ports enabled Count" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800291 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800292 for i in xrange(1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800293 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800294 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800295 dpid = "of:00000000000000" + format( i,'02x' )
296 t = main.Thread(target = cli.getDevicePortsEnabledCount,threadID = main.threadID, name = "getDevicePortsEnabledCount",args = [dpid])
297 t.start()
298 pool.append(t)
299 i = i + 1
300 main.threadID = main.threadID + 1
301 for thread in pool:
302 thread.join()
303 portResult = thread.result
304 portTemp = re.split( r'\t+', portResult )
305 portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
306 main.devicePortsEnabledCount.append( portCount )
Hari Krishna22c3d412015-02-17 16:48:12 -0800307 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
kelvin-onlab54400a92015-02-26 18:05:51 -0800308 time2 = time.time()
309 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800310
Hari Krishna22c3d412015-02-17 16:48:12 -0800311 main.step( "Collect and store each Device active links Count" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800312 time1 = time.time()
313
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800314 for i in xrange( 1,( main.numMNswitches + 1 ), int( main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800315 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800316 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800317 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800318 t = main.Thread( target = cli.getDeviceLinksActiveCount,
319 threadID = main.threadID,
320 name = "getDevicePortsEnabledCount",
321 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800322 t.start()
323 pool.append(t)
324 i = i + 1
325 main.threadID = main.threadID + 1
326 for thread in pool:
327 thread.join()
328 linkCountResult = thread.result
329 linkCountTemp = re.split( r'\t+', linkCountResult )
330 linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
331 main.deviceActiveLinksCount.append( linkCount )
332 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
333 time2 = time.time()
334 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800335
336 else:
337 main.log.info("Devices (expected): %s, Links (expected): %s" %
338 ( str( main.numMNswitches ), str( main.numMNlinks ) ) )
339 main.log.info("Devices (actual): %s, Links (actual): %s" %
340 ( numOnosDevices , numOnosLinks ) )
341 main.log.info("Topology does not match, exiting CHO test...")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700342 topoResult = main.FALSE
343
kelvin-onlab54400a92015-02-26 18:05:51 -0800344 #time.sleep(300)
Hari Krishnab35c6d02015-03-18 11:13:51 -0700345 #main.cleanup()
346 #main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800347
kelvin-onlab8a832582015-01-16 17:06:11 -0800348 # just returning TRUE for now as this one just collects data
Hari Krishnab35c6d02015-03-18 11:13:51 -0700349 case3Result = topoResult
Hari Krishna22c3d412015-02-17 16:48:12 -0800350 utilities.assert_equals( expect=main.TRUE, actual=case3Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800351 onpass="Saving ONOS topology data test PASS",
352 onfail="Saving ONOS topology data test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800353
kelvin-onlab8a832582015-01-16 17:06:11 -0800354 def CASE4( self, main ):
355 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700356 Verify Reactive forwarding (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -0800357 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800358 import re
359 import copy
360 import time
Hari Krishnab35c6d02015-03-18 11:13:51 -0700361 main.log.report( "Verify Reactive forwarding (Att Topology)" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800362 main.log.report( "______________________________________________" )
363 main.case( "Enable Reactive forwarding and Verify ping all" )
364 main.step( "Enable Reactive forwarding" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800365 installResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800366 feature = "onos-app-fwd"
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800367
kelvin-onlab54400a92015-02-26 18:05:51 -0800368 pool = []
369 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800370 for cli in main.CLIs:
371 t = main.Thread( target=cli.featureInstall,
372 threadID=main.threadID,
373 name="featureInstall",
374 args=['onos-app-fwd'])
kelvin-onlab54400a92015-02-26 18:05:51 -0800375 pool.append(t)
376 t.start()
377 main.threadID = main.threadID + 1
378
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800379 installResult = main.TRUE
380 for t in pool:
381 t.join()
382 installResult = installResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -0800383 time2 = time.time()
384
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800385 if not installResult:
kelvin-onlab54400a92015-02-26 18:05:51 -0800386 main.log.info("Did not install onos-app-fwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700387 #main.cleanup()
388 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -0800389 else:
390 main.log.info("Successful feature:install onos-app-fwd")
kelvin-onlab54400a92015-02-26 18:05:51 -0800391 main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1))
392
kelvin-onlab8a832582015-01-16 17:06:11 -0800393 time.sleep( 5 )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800394
kelvin-onlab8a832582015-01-16 17:06:11 -0800395 main.step( "Verify Pingall" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800396 ping_result = main.FALSE
397 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800398 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800399 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800400 timeDiff = round( ( time2 - time1 ), 2 )
401 main.log.report(
402 "Time taken for Ping All: " +
403 str( timeDiff ) +
404 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800405
406 if ping_result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800407 main.log.report( "Pingall Test in Reactive mode successful" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800408 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800409 main.log.report( "Pingall Test in Reactive mode failed" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800410
kelvin-onlab8a832582015-01-16 17:06:11 -0800411 main.step( "Disable Reactive forwarding" )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800412 uninstallResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800413 pool = []
414 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800415 for cli in main.CLIs:
416 t = main.Thread( target=cli.featureUninstall,
417 threadID=main.threadID,
418 name="featureUninstall",
419 args=['onos-app-fwd'])
kelvin-onlab54400a92015-02-26 18:05:51 -0800420 pool.append(t)
421 t.start()
422 main.threadID = main.threadID + 1
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800423 for t in pool:
424 t.join()
425 uninstallResult = uninstallResult and t.result
kelvin-onlab54400a92015-02-26 18:05:51 -0800426 time2 = time.time()
427
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800428 if not uninstallResult:
kelvin-onlab54400a92015-02-26 18:05:51 -0800429 main.log.info("Did not uninstall onos-app-fwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -0700430 #main.cleanup()
431 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -0800432 else:
433 main.log.info("Successful feature:uninstall onos-app-fwd")
kelvin-onlab54400a92015-02-26 18:05:51 -0800434 main.log.info("Time for feature:uninstall onos-app-fwd: %2f seconds" %(time2-time1))
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800435
kelvin-onlab8a832582015-01-16 17:06:11 -0800436 # Waiting for reative flows to be cleared.
Hari Krishnab35c6d02015-03-18 11:13:51 -0700437 time.sleep( 20 )
438 case4Result = installResult and uninstallResult and ping_result
439 utilities.assert_equals( expect=main.TRUE, actual=case4Result,
440 onpass="Reactive Mode Pingall test PASS",
441 onfail="Reactive Mode Pingall test FAIL" )
442
443 def CASE41( self, main ):
444 """
445 Verify Reactive forwarding (Chordal Topology)
446 """
447 import re
448 import copy
449 import time
450 main.log.report( "Verify Reactive forwarding (Chordal Topology)" )
451 main.log.report( "______________________________________________" )
452 main.case( "Enable Reactive forwarding and Verify ping all" )
453 main.step( "Enable Reactive forwarding" )
454 installResult = main.TRUE
455 feature = "onos-app-fwd"
456
457 pool = []
458 time1 = time.time()
459 for cli in main.CLIs:
460 t = main.Thread( target=cli.featureInstall,
461 threadID=main.threadID,
462 name="featureInstall",
463 args=['onos-app-fwd'])
464 pool.append(t)
465 t.start()
466 main.threadID = main.threadID + 1
467
468 installResult = main.TRUE
469 for t in pool:
470 t.join()
471 installResult = installResult and t.result
472 time2 = time.time()
473
474 if not installResult:
475 main.log.info("Did not install onos-app-fwd feature properly")
476 #main.cleanup()
477 #main.exit()
478 else:
479 main.log.info("Successful feature:install onos-app-fwd")
480 main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1))
481
kelvin-onlab54400a92015-02-26 18:05:51 -0800482 time.sleep( 5 )
Hari Krishnab35c6d02015-03-18 11:13:51 -0700483
484 main.step( "Verify Pingall" )
485 ping_result = main.FALSE
486 time1 = time.time()
487 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout)
488 time2 = time.time()
489 timeDiff = round( ( time2 - time1 ), 2 )
490 main.log.report(
491 "Time taken for Ping All: " +
492 str( timeDiff ) +
493 " seconds" )
494
495 if ping_result == main.TRUE:
496 main.log.report( "Pingall Test in Reactive mode successful" )
497 else:
498 main.log.report( "Pingall Test in Reactive mode failed" )
499
500 main.step( "Disable Reactive forwarding" )
501 uninstallResult = main.TRUE
502 pool = []
503 time1 = time.time()
504 for cli in main.CLIs:
505 t = main.Thread( target=cli.featureUninstall,
506 threadID=main.threadID,
507 name="featureUninstall",
508 args=['onos-app-fwd'])
509 pool.append(t)
510 t.start()
511 main.threadID = main.threadID + 1
512 for t in pool:
513 t.join()
514 uninstallResult = uninstallResult and t.result
515 time2 = time.time()
516
517 if not uninstallResult:
518 main.log.info("Did not uninstall onos-app-fwd feature properly")
519 #main.cleanup()
520 #main.exit()
521 else:
522 main.log.info("Successful feature:uninstall onos-app-fwd")
523 main.log.info("Time for feature:uninstall onos-app-fwd: %2f seconds" %(time2-time1))
524
525 # Waiting for reative flows to be cleared.
526 time.sleep( 20 )
527 case4Result = installResult and uninstallResult and ping_result
528 utilities.assert_equals( expect=main.TRUE, actual=case4Result,
529 onpass="Reactive Mode Pingall test PASS",
530 onfail="Reactive Mode Pingall test FAIL" )
531
532 def CASE42( self, main ):
533 """
534 Verify Reactive forwarding (Spine Topology)
535 """
536 import re
537 import copy
538 import time
539 main.log.report( "Verify Reactive forwarding (Spine Topology)" )
540 main.log.report( "______________________________________________" )
541 main.case( "Enable Reactive forwarding and Verify ping all" )
542 main.step( "Enable Reactive forwarding" )
543 installResult = main.TRUE
544 feature = "onos-app-fwd"
545
546 pool = []
547 time1 = time.time()
548 for cli in main.CLIs:
549 t = main.Thread( target=cli.featureInstall,
550 threadID=main.threadID,
551 name="featureInstall",
552 args=['onos-app-fwd'])
553 pool.append(t)
554 t.start()
555 main.threadID = main.threadID + 1
556
557 installResult = main.TRUE
558 for t in pool:
559 t.join()
560 installResult = installResult and t.result
561 time2 = time.time()
562
563 if not installResult:
564 main.log.info("Did not install onos-app-fwd feature properly")
565 #main.cleanup()
566 #main.exit()
567 else:
568 main.log.info("Successful feature:install onos-app-fwd")
569 main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1))
570
571 time.sleep( 5 )
572
573 main.step( "Verify Pingall" )
574 ping_result = main.FALSE
575 time1 = time.time()
576 ping_result = main.Mininet1.pingall(timeout=main.pingTimeout)
577 time2 = time.time()
578 timeDiff = round( ( time2 - time1 ), 2 )
579 main.log.report(
580 "Time taken for Ping All: " +
581 str( timeDiff ) +
582 " seconds" )
583
584 if ping_result == main.TRUE:
585 main.log.report( "Pingall Test in Reactive mode successful" )
586 else:
587 main.log.report( "Pingall Test in Reactive mode failed" )
588
589 main.step( "Disable Reactive forwarding" )
590 uninstallResult = main.TRUE
591 pool = []
592 time1 = time.time()
593 for cli in main.CLIs:
594 t = main.Thread( target=cli.featureUninstall,
595 threadID=main.threadID,
596 name="featureUninstall",
597 args=['onos-app-fwd'])
598 pool.append(t)
599 t.start()
600 main.threadID = main.threadID + 1
601 for t in pool:
602 t.join()
603 uninstallResult = uninstallResult and t.result
604 time2 = time.time()
605
606 if not uninstallResult:
607 main.log.info("Did not uninstall onos-app-fwd feature properly")
608 #main.cleanup()
609 #main.exit()
610 else:
611 main.log.info("Successful feature:uninstall onos-app-fwd")
612 main.log.info("Time for feature:uninstall onos-app-fwd: %2f seconds" %(time2-time1))
613
614 # Waiting for reative flows to be cleared.
615 time.sleep( 20 )
kelvin-onlab54400a92015-02-26 18:05:51 -0800616 case4Result = installResult and uninstallResult and ping_result
617 utilities.assert_equals( expect=main.TRUE, actual=case4Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800618 onpass="Reactive Mode Pingall test PASS",
619 onfail="Reactive Mode Pingall test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800620
kelvin-onlab8a832582015-01-16 17:06:11 -0800621 def CASE5( self, main ):
622 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800623 Compare current ONOS topology with reference data
kelvin-onlab8a832582015-01-16 17:06:11 -0800624 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800625 import re
kelvin-onlab54400a92015-02-26 18:05:51 -0800626
Hari Krishna22c3d412015-02-17 16:48:12 -0800627 devicesDPIDTemp = []
628 hostMACsTemp = []
629 deviceLinksTemp = []
630 deviceActiveLinksCountTemp = []
631 devicePortsEnabledCountTemp = []
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800632
kelvin-onlab8a832582015-01-16 17:06:11 -0800633 main.log.report(
634 "Compare ONOS topology with reference data in Stores" )
635 main.log.report( "__________________________________________________" )
636 main.case( "Compare ONOS topology with reference data" )
637
638 main.step( "Compare current Device ports enabled with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800639 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800640 for i in xrange( 1,(main.numMNswitches + 1), int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800641 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800642 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800643 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800644 t = main.Thread(target = cli.getDevicePortsEnabledCount,
645 threadID = main.threadID,
646 name = "getDevicePortsEnabledCount",
647 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800648 t.start()
649 pool.append(t)
650 i = i + 1
651 main.threadID = main.threadID + 1
652 for thread in pool:
653 thread.join()
654 portResult = thread.result
655 portTemp = re.split( r'\t+', portResult )
656 portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
657 devicePortsEnabledCountTemp.append( portCount )
658 print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
659 time2 = time.time()
660 main.log.info("Time for counting enabled ports of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800661 main.log.info (
662 "Device Enabled ports EXPECTED: %s" %
663 str( main.devicePortsEnabledCount ) )
664 main.log.info (
665 "Device Enabled ports ACTUAL: %s" %
666 str( devicePortsEnabledCountTemp ) )
kelvin-onlab54400a92015-02-26 18:05:51 -0800667
Hari Krishna22c3d412015-02-17 16:48:12 -0800668 if ( cmp( main.devicePortsEnabledCount,
669 devicePortsEnabledCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800670 stepResult1 = main.TRUE
671 else:
672 stepResult1 = main.FALSE
673
kelvin-onlab8a832582015-01-16 17:06:11 -0800674 main.step( "Compare Device active links with reference" )
kelvin-onlab54400a92015-02-26 18:05:51 -0800675 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800676 for i in xrange( 1, ( main.numMNswitches + 1) , int( main.numCtrls ) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800677 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800678 for cli in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -0800679 dpid = "of:00000000000000" + format( i,'02x' )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800680 t = main.Thread(target = cli.getDeviceLinksActiveCount,
681 threadID = main.threadID,
682 name = "getDevicePortsEnabledCount",
683 args = [dpid])
kelvin-onlab54400a92015-02-26 18:05:51 -0800684 t.start()
685 pool.append(t)
686 i = i + 1
687 main.threadID = main.threadID + 1
688 for thread in pool:
689 thread.join()
690 linkCountResult = thread.result
691 linkCountTemp = re.split( r'\t+', linkCountResult )
692 linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
693 deviceActiveLinksCountTemp.append( linkCount )
694 print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
695 time2 = time.time()
696 main.log.info("Time for counting all enabled links of the switches: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -0800697 main.log.info (
698 "Device Active links EXPECTED: %s" %
699 str( main.deviceActiveLinksCount ) )
700 main.log.info (
701 "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) )
702 if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ):
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800703 stepResult2 = main.TRUE
704 else:
705 stepResult2 = main.FALSE
706
kelvin-onlab8a832582015-01-16 17:06:11 -0800707 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800708 place holder for comparing devices, hosts, paths and intents if required.
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800709 Links and ports data would be incorrect with out devices anyways.
kelvin-onlab8a832582015-01-16 17:06:11 -0800710 """
Hari Krishna22c3d412015-02-17 16:48:12 -0800711 case5Result = ( stepResult1 and stepResult2 )
712 utilities.assert_equals( expect=main.TRUE, actual=case5Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800713 onpass="Compare Topology test PASS",
714 onfail="Compare Topology test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800715
kelvin-onlab8a832582015-01-16 17:06:11 -0800716 def CASE6( self ):
717 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700718 Install 300 host intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -0800719 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700720 main.log.report( "Add 300 host intents and verify pingall (Att Topology)" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800721 main.log.report( "_______________________________________" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800722 import itertools
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700723 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800724 main.case( "Install 300 host intents" )
725 main.step( "Add host Intents" )
726 intentResult = main.TRUE
kelvin-onlab54400a92015-02-26 18:05:51 -0800727 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800728
kelvin-onlab54400a92015-02-26 18:05:51 -0800729 intentIdList = []
730 time1 = time.time()
Hari Krishnab35c6d02015-03-18 11:13:51 -0700731 """
732 for i in xrange(0 ,len(hostCombos)):
733 tempId = ONOScli1.addHostIntent( hostCombos[i][0],hostCombos[i][1]] )
734 intentIdList.append(hostCombos[i][0],hostCombos[i][1]])
735 """
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800736 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800737 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800738 for cli in main.CLIs:
739 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -0800740 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800741 t = main.Thread( target=cli.addHostIntent,
742 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -0800743 name="addHostIntent",
744 args=[hostCombos[i][0],hostCombos[i][1]])
745 pool.append(t)
Hari Krishnab35c6d02015-03-18 11:13:51 -0700746 #time.sleep(1)
kelvin-onlab54400a92015-02-26 18:05:51 -0800747 t.start()
748 i = i + 1
749 main.threadID = main.threadID + 1
750 for thread in pool:
751 thread.join()
752 intentIdList.append(thread.result)
753 time2 = time.time()
Hari Krishnab35c6d02015-03-18 11:13:51 -0700754 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
kelvin-onlab54400a92015-02-26 18:05:51 -0800755 intentResult = main.TRUE
756 intentsJson = main.ONOScli2.intents()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800757 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
kelvin-onlab54400a92015-02-26 18:05:51 -0800758 intentsJson = intentsJson)
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800759 print getIntentStateResult
Hari Krishnab35c6d02015-03-18 11:13:51 -0700760 # Takes awhile for all the onos to get the intents
Hari Krishnaef1bd4e2015-03-12 16:55:30 -0700761 time.sleep(30)
kelvin-onlab8a832582015-01-16 17:06:11 -0800762 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800763 pingResult = main.FALSE
764 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800765 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800766 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800767 timeDiff = round( ( time2 - time1 ), 2 )
768 main.log.report(
769 "Time taken for Ping All: " +
770 str( timeDiff ) +
771 " seconds" )
772 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
773 onpass="PING ALL PASS",
774 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800775
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800776 case6Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -0800777
kelvin-onlab8a832582015-01-16 17:06:11 -0800778 utilities.assert_equals(
779 expect=main.TRUE,
kelvin-onlab78f7d2d2015-03-02 17:37:35 -0800780 actual=case6Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800781 onpass="Install 300 Host Intents and Ping All test PASS",
782 onfail="Install 300 Host Intents and Ping All test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800783
kelvin-onlab8a832582015-01-16 17:06:11 -0800784 def CASE70( self, main ):
785 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700786 Randomly bring some core links down and verify ping all ( Host Intents-Att Topo)
kelvin-onlab8a832582015-01-16 17:06:11 -0800787 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800788 import random
Hari Krishna22c3d412015-02-17 16:48:12 -0800789 main.randomLink1 = []
790 main.randomLink2 = []
791 main.randomLink3 = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800792 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
793 link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
794 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
795 link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' )
796 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
797 link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' )
798 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
799 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800800
Hari Krishnab35c6d02015-03-18 11:13:51 -0700801 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" )
802 main.log.report( "___________________________________________________________________________" )
Hari Krishnad97213e2015-01-24 19:30:14 -0800803 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
804 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800805 if ( int( switchLinksToToggle ) ==
806 0 or int( switchLinksToToggle ) > 5 ):
Hari Krishna46997e02015-01-27 11:23:07 -0800807 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 -0700808 #main.cleanup()
809 #main.exit()
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800810 else:
Hari Krishnad97213e2015-01-24 19:30:14 -0800811 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 -0800812
kelvin-onlab8a832582015-01-16 17:06:11 -0800813 main.step( "Cut links on Core devices using user provided range" )
Hari Krishna22c3d412015-02-17 16:48:12 -0800814 main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
815 main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
816 main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800817 for i in range( int( switchLinksToToggle ) ):
818 main.Mininet1.link(
819 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800820 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800821 OPTION="down" )
822 main.Mininet1.link(
823 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800824 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800825 OPTION="down" )
826 main.Mininet1.link(
827 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800828 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800829 OPTION="down" )
830 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800831
832 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800833 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -0800834 topology_output, main.numMNswitches, str(
835 int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800836 utilities.assert_equals(
837 expect=main.TRUE,
838 actual=linkDown,
839 onpass="Link Down discovered properly",
840 onfail="Link down was not discovered in " +
841 str( link_sleep ) +
842 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800843
kelvin-onlab8a832582015-01-16 17:06:11 -0800844 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800845 pingResultLinkDown = main.FALSE
846 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -0800847 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800848 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800849 timeDiff = round( ( time2 - time1 ), 2 )
850 main.log.report(
851 "Time taken for Ping All: " +
852 str( timeDiff ) +
853 " seconds" )
854 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
855 onpass="PING ALL PASS",
856 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800857
Hari Krishna22c3d412015-02-17 16:48:12 -0800858 caseResult70 = linkDown and pingResultLinkDown
859 utilities.assert_equals( expect=main.TRUE, actual=caseResult70,
kelvin-onlab8a832582015-01-16 17:06:11 -0800860 onpass="Random Link cut Test PASS",
861 onfail="Random Link cut Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800862
kelvin-onlab8a832582015-01-16 17:06:11 -0800863 def CASE80( self, main ):
864 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700865 Bring the core links up that are down and verify ping all ( Host Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -0800866 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800867 import random
kelvin-onlab8a832582015-01-16 17:06:11 -0800868 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
869 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
870 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
871 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
872 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800873
kelvin-onlab8a832582015-01-16 17:06:11 -0800874 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -0700875 "Bring the core links up that are down and verify ping all (Host Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800876 main.log.report(
877 "__________________________________________________________________" )
878 main.case(
879 "Host intents - Bring the core links up that are down and verify ping all" )
880 main.step( "Bring randomly cut links on Core devices up" )
881 for i in range( int( switchLinksToToggle ) ):
882 main.Mininet1.link(
883 END1=link1End1,
kelvin-onlab54400a92015-02-26 18:05:51 -0800884 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800885 OPTION="up" )
886 main.Mininet1.link(
887 END1=link2End1,
kelvin-onlab54400a92015-02-26 18:05:51 -0800888 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800889 OPTION="up" )
890 main.Mininet1.link(
891 END1=link3End1,
kelvin-onlab54400a92015-02-26 18:05:51 -0800892 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800893 OPTION="up" )
894 time.sleep( link_sleep )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800895
896 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800897 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -0800898 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -0800899 main.numMNswitches,
900 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800901 utilities.assert_equals(
902 expect=main.TRUE,
903 actual=linkUp,
904 onpass="Link up discovered properly",
905 onfail="Link up was not discovered in " +
906 str( link_sleep ) +
907 " seconds" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800908
kelvin-onlab8a832582015-01-16 17:06:11 -0800909 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800910 pingResultLinkUp = main.FALSE
911 time1 = time.time()
912 pingResultLinkUp = main.Mininet1.pingall()
913 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800914 timeDiff = round( ( time2 - time1 ), 2 )
915 main.log.report(
916 "Time taken for Ping All: " +
917 str( timeDiff ) +
918 " seconds" )
919 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
920 onpass="PING ALL PASS",
921 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800922
Hari Krishna22c3d412015-02-17 16:48:12 -0800923 caseResult80 = linkUp and pingResultLinkUp
924 utilities.assert_equals( expect=main.TRUE, actual=caseResult80,
kelvin-onlab8a832582015-01-16 17:06:11 -0800925 onpass="Link Up Test PASS",
926 onfail="Link Up Test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -0800927
kelvin-onlab8a832582015-01-16 17:06:11 -0800928 def CASE71( self, main ):
929 """
Hari Krishnab35c6d02015-03-18 11:13:51 -0700930 Randomly bring some core links down and verify ping all ( Point Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -0800931 """
kelvin8ec71442015-01-15 16:57:00 -0800932 import random
Hari Krishna22c3d412015-02-17 16:48:12 -0800933 main.randomLink1 = []
934 main.randomLink2 = []
935 main.randomLink3 = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800936 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
937 link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
938 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
939 link2End2 = main.params[ 'CORELINKS' ][ 'linkS14b' ].split( ',' )
940 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
941 link3End2 = main.params[ 'CORELINKS' ][ 'linkS18b' ].split( ',' )
942 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
943 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
kelvin8ec71442015-01-15 16:57:00 -0800944
Hari Krishnab35c6d02015-03-18 11:13:51 -0700945 main.log.report( "Randomly bring some core links down and verify ping all (Point Intents-Att Topo" )
Hari Krishnad97213e2015-01-24 19:30:14 -0800946 main.log.report( "__________________________________________________________________" )
947 main.case( "Point Intents - Randomly bring some core links down and verify ping all" )
948 main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800949 if ( int( switchLinksToToggle ) ==
950 0 or int( switchLinksToToggle ) > 5 ):
951 main.log.info(
952 "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 -0700953 #main.cleanup()
954 #main.exit()
kelvin8ec71442015-01-15 16:57:00 -0800955 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800956 main.log.info(
957 "User provided Core switch links range to toggle is correct, proceeding to run the test" )
kelvin8ec71442015-01-15 16:57:00 -0800958
kelvin-onlab8a832582015-01-16 17:06:11 -0800959 main.step( "Cut links on Core devices using user provided range" )
960 randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
961 randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
962 randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
963 for i in range( int( switchLinksToToggle ) ):
964 main.Mininet1.link(
965 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800966 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800967 OPTION="down" )
968 main.Mininet1.link(
969 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800970 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800971 OPTION="down" )
972 main.Mininet1.link(
973 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -0800974 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -0800975 OPTION="down" )
976 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -0800977
978 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -0800979 linkDown = main.ONOSbench.checkStatus(
Hari Krishna22c3d412015-02-17 16:48:12 -0800980 topology_output, main.numSwitches, str(
981 int( main.numLinks ) - int( switchLinksToToggle ) * 6 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800982 utilities.assert_equals(
983 expect=main.TRUE,
984 actual=linkDown,
985 onpass="Link Down discovered properly",
986 onfail="Link down was not discovered in " +
987 str( link_sleep ) +
988 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -0800989
kelvin-onlab8a832582015-01-16 17:06:11 -0800990 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -0800991 pingResultLinkDown = main.FALSE
992 time1 = time.time()
993 pingResultLinkDown = main.Mininet1.pingall()
994 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800995 timeDiff = round( ( time2 - time1 ), 2 )
996 main.log.report(
997 "Time taken for Ping All: " +
998 str( timeDiff ) +
999 " seconds" )
1000 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1001 onpass="PING ALL PASS",
1002 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001003
1004 caseResult7 = linkDown and pingResultLinkDown
kelvin-onlab8a832582015-01-16 17:06:11 -08001005 utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
1006 onpass="Random Link cut Test PASS",
1007 onfail="Random Link cut Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001008
kelvin-onlab8a832582015-01-16 17:06:11 -08001009 def CASE81( self, main ):
1010 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001011 Bring the core links up that are down and verify ping all ( Point Intents-Att Topo )
kelvin-onlab8a832582015-01-16 17:06:11 -08001012 """
kelvin8ec71442015-01-15 16:57:00 -08001013 import random
kelvin-onlab8a832582015-01-16 17:06:11 -08001014 link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
1015 link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
1016 link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
1017 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1018 switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
kelvin8ec71442015-01-15 16:57:00 -08001019
kelvin-onlab8a832582015-01-16 17:06:11 -08001020 main.log.report(
Hari Krishnab35c6d02015-03-18 11:13:51 -07001021 "Bring the core links up that are down and verify ping all (Point Intents-Att Topo" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001022 main.log.report(
1023 "___________________________________________________________________" )
1024 main.case(
1025 "Point intents - Bring the core links up that are down and verify ping all" )
1026 main.step( "Bring randomly cut links on Core devices up" )
1027 for i in range( int( switchLinksToToggle ) ):
1028 main.Mininet1.link(
1029 END1=link1End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001030 END2=main.randomLink1[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001031 OPTION="up" )
1032 main.Mininet1.link(
1033 END1=link2End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001034 END2=main.randomLink2[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001035 OPTION="up" )
1036 main.Mininet1.link(
1037 END1=link3End1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001038 END2=main.randomLink3[ i ],
kelvin-onlab8a832582015-01-16 17:06:11 -08001039 OPTION="up" )
1040 time.sleep( link_sleep )
kelvin8ec71442015-01-15 16:57:00 -08001041
1042 topology_output = main.ONOScli2.topology()
Hari Krishnad97213e2015-01-24 19:30:14 -08001043 linkUp = main.ONOSbench.checkStatus(
kelvin-onlab8a832582015-01-16 17:06:11 -08001044 topology_output,
Hari Krishna22c3d412015-02-17 16:48:12 -08001045 main.numMNswitches,
1046 str( main.numMNlinks ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001047 utilities.assert_equals(
1048 expect=main.TRUE,
1049 actual=linkUp,
1050 onpass="Link up discovered properly",
1051 onfail="Link up was not discovered in " +
1052 str( link_sleep ) +
1053 " seconds" )
kelvin8ec71442015-01-15 16:57:00 -08001054
kelvin-onlab8a832582015-01-16 17:06:11 -08001055 main.step( "Verify Ping across all hosts" )
kelvin8ec71442015-01-15 16:57:00 -08001056 pingResultLinkUp = main.FALSE
1057 time1 = time.time()
1058 pingResultLinkUp = main.Mininet1.pingall()
1059 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001060 timeDiff = round( ( time2 - time1 ), 2 )
1061 main.log.report(
1062 "Time taken for Ping All: " +
1063 str( timeDiff ) +
1064 " seconds" )
1065 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1066 onpass="PING ALL PASS",
1067 onfail="PING ALL FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001068
Hari Krishna22c3d412015-02-17 16:48:12 -08001069 caseResult81 = linkUp and pingResultLinkUp
1070 utilities.assert_equals( expect=main.TRUE, actual=caseResult81,
kelvin-onlab8a832582015-01-16 17:06:11 -08001071 onpass="Link Up Test PASS",
1072 onfail="Link Up Test FAIL" )
kelvin8ec71442015-01-15 16:57:00 -08001073
Hari Krishnab35c6d02015-03-18 11:13:51 -07001074 def CASE72( self, main ):
1075 """
1076 Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo)
1077 """
1078 import random
1079 import itertools
1080 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1081
1082 main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" )
1083 main.log.report( "___________________________________________________________________________" )
1084 main.case( "Host intents - Randomly bring some core links down and verify ping all" )
1085 switches = []
1086 switchesComb = []
1087 for i in range( main.numMNswitches ):
1088 switches.append('s%d'%(i+1))
1089 switchesLinksComb = list(itertools.combinations(switches,2))
1090 main.randomLinks = random.sample(switchesLinksComb, 5 )
1091 print main.randomLinks
1092 main.step( "Cut links on random devices" )
1093
1094 for switch in main.randomLinks:
1095 main.Mininet1.link(
1096 END1=switch[0],
1097 END2=switch[1],
1098 OPTION="down")
1099 time.sleep( link_sleep )
1100
1101 topology_output = main.ONOScli2.topology()
1102 linkDown = main.ONOSbench.checkStatus(
1103 topology_output, main.numMNswitches, str(
1104 int( main.numMNlinks ) - 5 * 2 ) )
1105 utilities.assert_equals(
1106 expect=main.TRUE,
1107 actual=linkDown,
1108 onpass="Link Down discovered properly",
1109 onfail="Link down was not discovered in " +
1110 str( link_sleep ) +
1111 " seconds" )
1112
1113 main.step( "Verify Ping across all hosts" )
1114 pingResultLinkDown = main.FALSE
1115 time1 = time.time()
1116 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
1117 time2 = time.time()
1118 timeDiff = round( ( time2 - time1 ), 2 )
1119 main.log.report(
1120 "Time taken for Ping All: " +
1121 str( timeDiff ) +
1122 " seconds" )
1123 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1124 onpass="PING ALL PASS",
1125 onfail="PING ALL FAIL" )
1126
1127 caseResult72 = pingResultLinkDown
1128 utilities.assert_equals( expect=main.TRUE, actual=caseResult72,
1129 onpass="Random Link cut Test PASS",
1130 onfail="Random Link cut Test FAIL" )
1131
1132 def CASE82( self, main ):
1133 """
1134 Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo )
1135 """
1136 import random
1137 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1138
1139 main.log.report(
1140 "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" )
1141 main.log.report(
1142 "__________________________________________________________________" )
1143 main.case(
1144 "Host intents - Bring the core links up that are down and verify ping all" )
1145 main.step( "Bring randomly cut links on devices up" )
1146
1147 for switch in main.randomLinks:
1148 main.Mininet1.link(
1149 END1=switch[0],
1150 END2=switch[1],
1151 OPTION="up")
1152
1153 time.sleep( link_sleep )
1154
1155 topology_output = main.ONOScli2.topology()
1156 linkUp = main.ONOSbench.checkStatus(
1157 topology_output,
1158 main.numMNswitches,
1159 str( main.numMNlinks ) )
1160 utilities.assert_equals(
1161 expect=main.TRUE,
1162 actual=linkUp,
1163 onpass="Link up discovered properly",
1164 onfail="Link up was not discovered in " +
1165 str( link_sleep ) +
1166 " seconds" )
1167
1168 main.step( "Verify Ping across all hosts" )
1169 pingResultLinkUp = main.FALSE
1170 time1 = time.time()
1171 pingResultLinkUp = main.Mininet1.pingall()
1172 time2 = time.time()
1173 timeDiff = round( ( time2 - time1 ), 2 )
1174 main.log.report(
1175 "Time taken for Ping All: " +
1176 str( timeDiff ) +
1177 " seconds" )
1178 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1179 onpass="PING ALL PASS",
1180 onfail="PING ALL FAIL" )
1181
1182 caseResult82 = linkUp and pingResultLinkUp
1183 utilities.assert_equals( expect=main.TRUE, actual=caseResult82,
1184 onpass="Link Up Test PASS",
1185 onfail="Link Up Test FAIL" )
1186
1187 def CASE73( self, main ):
1188 """
1189 Randomly bring some core links down and verify ping all ( Host Intents-Spine Topo)
1190 """
1191 import random
1192 main.pingTimeout = 600
1193 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1194
1195 main.log.report( "Bring some core links down and verify ping all (Host Intents-Spine Topo)" )
1196 main.log.report( "___________________________________________________________________________" )
1197
1198 main.someLinks = [('s1','s9'),('s3','s9'),('s6','s10'),('s8','s10')]
1199 for switch in main.someLinks:
1200 main.Mininet1.link(
1201 END1=switch[0],
1202 END2=switch[1],
1203 OPTION="down" )
1204 time.sleep( link_sleep )
1205
1206 topology_output = main.ONOScli2.topology()
1207 linkDown = main.ONOSbench.checkStatus(
1208 topology_output, main.numMNswitches, str(
1209 int( main.numMNlinks ) - 8 ))
1210 utilities.assert_equals(
1211 expect=main.TRUE,
1212 actual=linkDown,
1213 onpass="Link Down discovered properly",
1214 onfail="Link down was not discovered in " +
1215 str( link_sleep ) +
1216 " seconds" )
1217
1218 main.step( "Verify Ping across all hosts" )
1219 pingResultLinkDown = main.FALSE
1220 time1 = time.time()
1221 pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
1222 time2 = time.time()
1223 timeDiff = round( ( time2 - time1 ), 2 )
1224 main.log.report(
1225 "Time taken for Ping All: " +
1226 str( timeDiff ) +
1227 " seconds" )
1228 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
1229 onpass="PING ALL PASS",
1230 onfail="PING ALL FAIL" )
1231
1232 caseResult73 = linkDown and pingResultLinkDown
1233 utilities.assert_equals( expect=main.TRUE, actual=caseResult73,
1234 onpass="Random Link cut Test PASS",
1235 onfail="Random Link cut Test FAIL" )
1236
1237 def CASE83( self, main ):
1238 """
1239 Bring the core links up that are down and verify ping all ( Host Intents-Spine Topo )
1240 """
1241 import random
1242
1243 link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
1244 main.log.report(
1245 "Bring the core links up that are down and verify ping all (Host Intents-Spine Topo" )
1246 main.log.report(
1247 "__________________________________________________________________" )
1248 main.case(
1249 "Host intents - Bring the core links up that are down and verify ping all" )
1250
1251 for switch in main.someLinks:
1252 main.Mininet1.link(
1253 END1=switch[0],
1254 END2=switch[1],
1255 OPTION="up")
1256 time.sleep( link_sleep )
1257
1258 topology_output = main.ONOScli2.topology()
1259 linkUp = main.ONOSbench.checkStatus(
1260 topology_output,
1261 main.numMNswitches,
1262 str( main.numMNlinks ) )
1263 utilities.assert_equals(
1264 expect=main.TRUE,
1265 actual=linkUp,
1266 onpass="Link up discovered properly",
1267 onfail="Link up was not discovered in " +
1268 str( link_sleep ) +
1269 " seconds" )
1270
1271 main.step( "Verify Ping across all hosts" )
1272 pingResultLinkUp = main.FALSE
1273 time1 = time.time()
1274 pingResultLinkUp = main.Mininet1.pingall()
1275 time2 = time.time()
1276 timeDiff = round( ( time2 - time1 ), 2 )
1277 main.log.report(
1278 "Time taken for Ping All: " +
1279 str( timeDiff ) +
1280 " seconds" )
1281 utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
1282 onpass="PING ALL PASS",
1283 onfail="PING ALL FAIL" )
1284
1285 caseResult83 = linkUp and pingResultLinkUp
1286 utilities.assert_equals( expect=main.TRUE, actual=caseResult83,
1287 onpass="Link Up Test PASS",
1288 onfail="Link Up Test FAIL" )
1289
kelvin-onlab8a832582015-01-16 17:06:11 -08001290 def CASE9( self ):
1291 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001292 Install 300 point intents and verify ping all (Att Topology)
kelvin-onlab8a832582015-01-16 17:06:11 -08001293 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001294 main.log.report( "Add 300 point intents and verify pingall (Att Topology)" )
1295 main.log.report( "_______________________________________" )
1296 import itertools
1297 import time
1298 main.case( "Install 300 point intents" )
1299 main.step( "Add point Intents" )
1300 intentResult = main.TRUE
1301 deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) )
1302
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001303 intentIdList = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07001304 time1 = time.time()
1305 """
1306 for i in xrange(0 ,len(hostCombos)):
1307 tempId = ONOScli1.addHostIntent( hostCombos[i][0],hostCombos[i][1]] )
1308 intentIdList.append(hostCombos[i][0],hostCombos[i][1]])
1309 """
1310 for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
1311 pool = []
1312 for cli in main.CLIs:
1313 if i >= len( deviceCombos ):
1314 break
1315 t = main.Thread( target=cli.addPointIntent,
1316 threadID=main.threadID,
1317 name="addPointIntent",
1318 args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4"])
1319 pool.append(t)
1320 time.sleep(1)
1321 t.start()
1322 i = i + 1
1323 main.threadID = main.threadID + 1
1324 for thread in pool:
1325 thread.join()
1326 intentIdList.append(thread.result)
1327 time2 = time.time()
1328 main.log.info("Time for adding point intents: %2f seconds" %(time2-time1))
1329 intentResult = main.TRUE
1330 intentsJson = main.ONOScli2.intents()
1331 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1332 intentsJson = intentsJson)
1333 print getIntentStateResult
1334 # Takes awhile for all the onos to get the intents
1335 time.sleep(30)
kelvin-onlab8a832582015-01-16 17:06:11 -08001336 main.step( "Verify Ping across all hosts" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001337 pingResult = main.FALSE
1338 time1 = time.time()
Hari Krishnab35c6d02015-03-18 11:13:51 -07001339 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001340 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -08001341 timeDiff = round( ( time2 - time1 ), 2 )
1342 main.log.report(
1343 "Time taken for Ping All: " +
1344 str( timeDiff ) +
1345 " seconds" )
1346 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1347 onpass="PING ALL PASS",
1348 onfail="PING ALL FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001349
Hari Krishnab35c6d02015-03-18 11:13:51 -07001350 case6Result = ( intentResult and pingResult )
1351
kelvin-onlab8a832582015-01-16 17:06:11 -08001352 utilities.assert_equals(
1353 expect=main.TRUE,
Hari Krishnab35c6d02015-03-18 11:13:51 -07001354 actual=case6Result,
1355 onpass="Install 300 point Intents and Ping All test PASS",
1356 onfail="Install 300 point Intents and Ping All test FAIL" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001357
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001358 def CASE90( self ):
1359 """
1360 Install single-multi point intents and verify Ping all works
1361 for att topology
1362 """
1363 import copy
1364 main.log.report( "Install single-multi point intents and verify Ping all" )
1365 main.log.report( "___________________________________________" )
1366 main.case( "Install single-multi point intents and Ping all" )
1367 deviceLinksCopy = copy.copy( main.deviceLinks )
1368 main.step( "Install single-multi point intents" )
1369 for i in range( len( deviceLinksCopy ) ):
1370 pointLink = str(
1371 deviceLinksCopy[ i ] ).replace(
1372 "src=",
1373 "" ).replace(
1374 "dst=",
1375 "" ).split( ',' )
1376 point1 = pointLink[ 0 ].split( '/' )
1377 point2 = pointLink[ 1 ].split( '/' )
1378 installResult = main.ONOScli1.addPointIntent(
1379 point1[ 0 ], point2[ 0 ], int(
1380 point1[ 1 ] ), int(
1381 point2[ 1 ] ) )
1382 if installResult == main.TRUE:
1383 print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
1384
1385 main.step( "Obtain the intent id's" )
1386 intentsList = main.ONOScli1.getAllIntentIds()
1387 ansi_escape = re.compile( r'\x1b[^m]*m' )
1388 intentsList = ansi_escape.sub( '', intentsList )
1389 intentsList = intentsList.replace(
1390 " onos:intents | grep id=",
1391 "" ).replace(
1392 "id=",
1393 "" ).replace(
1394 "\r\r",
1395 "" )
1396 intentsList = intentsList.splitlines()
1397 intentsList = intentsList[ 1: ]
1398 intentIdList = []
1399 for i in range( len( intentsList ) ):
1400 intentsTemp = intentsList[ i ].split( ',' )
1401 intentIdList.append( intentsTemp[ 0 ] )
1402 print "Intent IDs: ", intentIdList
1403 print "Total Intents installed: ", len( intentIdList )
1404
1405 main.step( "Verify Ping across all hosts" )
1406 pingResult = main.FALSE
1407 time1 = time.time()
1408 pingResult = main.Mininet1.pingall()
1409 time2 = time.time()
1410 timeDiff = round( ( time2 - time1 ), 2 )
1411 main.log.report(
1412 "Time taken for Ping All: " +
1413 str( timeDiff ) +
1414 " seconds" )
1415 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1416 onpass="PING ALL PASS",
1417 onfail="PING ALL FAIL" )
1418
1419 case8_result = installResult and pingResult
1420 utilities.assert_equals(
1421 expect=main.TRUE,
1422 actual=case8_result,
1423 onpass="Ping all test after Point intents addition successful",
1424 onfail="Ping all test after Point intents addition failed" )
1425
1426 def CASE91( self ):
1427 """
1428 Install single-multi point intents and verify Ping all works
1429 """
1430 import copy
1431 main.log.report( "Install single-multi point intents and verify Ping all" )
1432 main.log.report( "___________________________________________" )
1433 main.case( "Install single-multi point intents and Ping all" )
1434 deviceLinksCopy = copy.copy( main.deviceLinks )
1435 main.step( "Install single-multi point intents" )
1436 for i in range( len( deviceLinksCopy ) ):
1437 pointLink = str(
1438 deviceLinksCopy[ i ] ).replace(
1439 "src=",
1440 "" ).replace(
1441 "dst=",
1442 "" ).split( ',' )
1443 point1 = pointLink[ 0 ].split( '/' )
1444 point2 = pointLink[ 1 ].split( '/' )
1445 installResult = main.ONOScli1.addPointIntent(
1446 point1[ 0 ], point2[ 0 ], int(
1447 point1[ 1 ] ), int(
1448 point2[ 1 ] ) )
1449 if installResult == main.TRUE:
1450 print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
1451
1452 main.step( "Obtain the intent id's" )
1453 intentsList = main.ONOScli1.getAllIntentIds()
1454 ansi_escape = re.compile( r'\x1b[^m]*m' )
1455 intentsList = ansi_escape.sub( '', intentsList )
1456 intentsList = intentsList.replace(
1457 " onos:intents | grep id=",
1458 "" ).replace(
1459 "id=",
1460 "" ).replace(
1461 "\r\r",
1462 "" )
1463 intentsList = intentsList.splitlines()
1464 intentsList = intentsList[ 1: ]
1465 intentIdList = []
1466 for i in range( len( intentsList ) ):
1467 intentsTemp = intentsList[ i ].split( ',' )
1468 intentIdList.append( intentsTemp[ 0 ] )
1469 print "Intent IDs: ", intentIdList
1470 print "Total Intents installed: ", len( intentIdList )
1471
1472 main.step( "Verify Ping across all hosts" )
1473 pingResult = main.FALSE
1474 time1 = time.time()
1475 pingResult = main.Mininet1.pingall()
1476 time2 = time.time()
1477 timeDiff = round( ( time2 - time1 ), 2 )
1478 main.log.report(
1479 "Time taken for Ping All: " +
1480 str( timeDiff ) +
1481 " seconds" )
1482 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1483 onpass="PING ALL PASS",
1484 onfail="PING ALL FAIL" )
1485
1486 case8_result = installResult and pingResult
1487 utilities.assert_equals(
1488 expect=main.TRUE,
1489 actual=case8_result,
1490 onpass="Ping all test after Point intents addition successful",
1491 onfail="Ping all test after Point intents addition failed" )
1492
1493 def CASE92( self ):
1494 """
1495 Install 114 point intents and verify Ping all works
1496 """
1497 import copy
1498 main.log.report( "Install 114 point intents and verify Ping all" )
1499 main.log.report( "___________________________________________" )
1500 main.case( "Install 114 point intents and Ping all" )
1501 deviceLinksCopy = copy.copy( main.deviceLinks )
1502 main.step( "Install 114 point intents" )
1503 for i in range( len( deviceLinksCopy ) ):
1504 pointLink = str(
1505 deviceLinksCopy[ i ] ).replace(
1506 "src=",
1507 "" ).replace(
1508 "dst=",
1509 "" ).split( ',' )
1510 point1 = pointLink[ 0 ].split( '/' )
1511 point2 = pointLink[ 1 ].split( '/' )
1512 installResult = main.ONOScli1.addPointIntent(
1513 point1[ 0 ], point2[ 0 ], int(
1514 point1[ 1 ] ), int(
1515 point2[ 1 ] ) )
1516 if installResult == main.TRUE:
1517 print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
1518
1519 main.step( "Obtain the intent id's" )
1520 intentsList = main.ONOScli1.getAllIntentIds()
1521 ansi_escape = re.compile( r'\x1b[^m]*m' )
1522 intentsList = ansi_escape.sub( '', intentsList )
1523 intentsList = intentsList.replace(
1524 " onos:intents | grep id=",
1525 "" ).replace(
1526 "id=",
1527 "" ).replace(
1528 "\r\r",
1529 "" )
1530 intentsList = intentsList.splitlines()
1531 intentsList = intentsList[ 1: ]
1532 intentIdList = []
1533 for i in range( len( intentsList ) ):
1534 intentsTemp = intentsList[ i ].split( ',' )
1535 intentIdList.append( intentsTemp[ 0 ] )
1536 print "Intent IDs: ", intentIdList
1537 print "Total Intents installed: ", len( intentIdList )
1538
1539 main.step( "Verify Ping across all hosts" )
1540 pingResult = main.FALSE
1541 time1 = time.time()
1542 pingResult = main.Mininet1.pingall()
1543 time2 = time.time()
1544 timeDiff = round( ( time2 - time1 ), 2 )
1545 main.log.report(
1546 "Time taken for Ping All: " +
1547 str( timeDiff ) +
1548 " seconds" )
1549 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1550 onpass="PING ALL PASS",
1551 onfail="PING ALL FAIL" )
1552
1553 case8_result = installResult and pingResult
1554 utilities.assert_equals(
1555 expect=main.TRUE,
1556 actual=case8_result,
1557 onpass="Ping all test after Point intents addition successful",
1558 onfail="Ping all test after Point intents addition failed" )
1559
kelvin-onlab8a832582015-01-16 17:06:11 -08001560 def CASE10( self ):
kelvin-onlab7642bb12015-02-27 13:48:17 -08001561 import time
kelvin-onlab8a832582015-01-16 17:06:11 -08001562 """
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001563 Remove all Intents
kelvin-onlab8a832582015-01-16 17:06:11 -08001564 """
1565 main.log.report( "Remove all intents that were installed previously" )
1566 main.log.report( "______________________________________________" )
1567 main.log.info( "Remove all intents" )
1568 main.case( "Removing intents" )
1569 main.step( "Obtain the intent id's first" )
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001570 intentsList = main.ONOScli1.getAllIntentIds()
kelvin-onlab8a832582015-01-16 17:06:11 -08001571 ansi_escape = re.compile( r'\x1b[^m]*m' )
1572 intentsList = ansi_escape.sub( '', intentsList )
1573 intentsList = intentsList.replace(
1574 " onos:intents | grep id=",
1575 "" ).replace(
1576 "id=",
1577 "" ).replace(
1578 "\r\r",
1579 "" )
1580 intentsList = intentsList.splitlines()
1581 intentsList = intentsList[ 1: ]
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001582 intentIdList = []
1583 step1Result = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001584 moreIntents = main.TRUE
1585 removeIntentCount = 0
1586 print "Current number of intents" , len(intentsList)
kelvin-onlab8a832582015-01-16 17:06:11 -08001587 if ( len( intentsList ) > 1 ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001588 results = main.TRUE
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07001589 main.log.info("Removing intent...")
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001590 while moreIntents:
Hari Krishnab35c6d02015-03-18 11:13:51 -07001591 if removeIntentCount == 5:
1592 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001593 removeIntentCount = removeIntentCount + 1
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001594 intentsList1 = main.ONOScli1.getAllIntentIds()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07001595 if len( intentsList1 ) == 0:
1596 break
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001597 ansi_escape = re.compile( r'\x1b[^m]*m' )
1598 intentsList1 = ansi_escape.sub( '', intentsList1 )
1599 intentsList1 = intentsList1.replace(
1600 " onos:intents | grep id=",
1601 "" ).replace(
1602 " state=",
1603 "" ).replace(
1604 "\r\r",
1605 "" )
1606 intentsList1 = intentsList1.splitlines()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07001607 intentsList1 = intentsList1[ 1: ]
1608 print "Round %d intents to remove: " %(removeIntentCount)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001609 print intentsList1
1610 intentIdList1 = []
Hari Krishnab35c6d02015-03-18 11:13:51 -07001611 if ( len( intentsList1 ) > 0 ):
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07001612 moreIntents = main.TRUE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001613 for i in range( len( intentsList1 ) ):
1614 intentsTemp1 = intentsList1[ i ].split( ',' )
1615 intentIdList1.append( intentsTemp1[ 0 ].split('=')[1] )
1616 print "Leftover Intent IDs: ", intentIdList1
1617 print len(intentIdList1)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001618 for intent in intentIdList1:
kelvin-onlab36c02b12015-03-11 11:25:55 -07001619 main.CLIs[0].removeIntent(intent,'org.onosproject.cli',True,False)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001620 time.sleep(10)
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001621 else:
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07001622 time.sleep(15)
Hari Krishnab35c6d02015-03-18 11:13:51 -07001623 if len( main.ONOScli1.intents()):
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07001624 continue
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001625 break
kelvin-onlab36c02b12015-03-11 11:25:55 -07001626
Hari Krishnaa43d4e92014-12-19 13:22:40 -08001627 else:
1628 print "There are no more intents that need to be removed"
1629 step1Result = main.TRUE
1630 else:
1631 print "No Intent IDs found in Intents list: ", intentsList
1632 step1Result = main.FALSE
kelvin-onlabc3ab3012015-03-10 15:04:46 -07001633
kelvin-onlabdc8719b2015-03-02 14:01:52 -08001634 print main.ONOScli1.intents()
kelvin-onlab01f1b2c2015-03-11 10:41:06 -07001635 # time.sleep(300)
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001636 caseResult10 = step1Result
1637 utilities.assert_equals( expect=main.TRUE, actual=caseResult10,
kelvin-onlab8a832582015-01-16 17:06:11 -08001638 onpass="Intent removal test successful",
1639 onfail="Intent removal test failed" )
Hari Krishna22c3d412015-02-17 16:48:12 -08001640
1641 def CASE11( self, main ):
1642 """
1643 Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it
1644 """
1645 import re
1646 import copy
1647 import time
1648
kelvin-onlab54400a92015-02-26 18:05:51 -08001649 Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
1650 threadID = 0
1651
Hari Krishna22c3d412015-02-17 16:48:12 -08001652 main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" )
1653 main.log.report( "_____________________________________________________" )
1654 main.case( "Enable Intent based Reactive forwarding and Verify ping all" )
1655 main.step( "Enable intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001656 installResult = main.FALSE
1657 feature = "onos-app-ifwd"
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001658
kelvin-onlab54400a92015-02-26 18:05:51 -08001659 pool = []
1660 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001661 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08001662 t = main.Thread(target=cli,threadID=threadID,
1663 name="featureInstall",args=[feature])
1664 pool.append(t)
1665 t.start()
1666 threadID = threadID + 1
1667
1668 results = []
1669 for thread in pool:
1670 thread.join()
1671 results.append(thread.result)
1672 time2 = time.time()
1673
1674 if( all(result == main.TRUE for result in results) == False):
1675 main.log.info("Did not install onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07001676 #main.cleanup()
1677 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08001678 else:
1679 main.log.info("Successful feature:install onos-app-ifwd")
1680 installResult = main.TRUE
1681 main.log.info("Time for feature:install onos-app-ifwd: %2f seconds" %(time2-time1))
1682
Hari Krishna22c3d412015-02-17 16:48:12 -08001683 main.step( "Verify Pingall" )
1684 ping_result = main.FALSE
1685 time1 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08001686 ping_result = main.Mininet1.pingall(timeout=600)
Hari Krishna22c3d412015-02-17 16:48:12 -08001687 time2 = time.time()
1688 timeDiff = round( ( time2 - time1 ), 2 )
1689 main.log.report(
1690 "Time taken for Ping All: " +
1691 str( timeDiff ) +
1692 " seconds" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001693
Hari Krishna22c3d412015-02-17 16:48:12 -08001694 if ping_result == main.TRUE:
1695 main.log.report( "Pingall Test in Reactive mode successful" )
1696 else:
1697 main.log.report( "Pingall Test in Reactive mode failed" )
1698
1699 main.step( "Disable Intent based Reactive forwarding" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001700 uninstallResult = main.FALSE
1701
kelvin-onlab54400a92015-02-26 18:05:51 -08001702 pool = []
1703 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001704 for cli,feature in main.CLIs:
kelvin-onlab54400a92015-02-26 18:05:51 -08001705 t = main.Thread(target=cli,threadID=threadID,
1706 name="featureUninstall",args=[feature])
1707 pool.append(t)
1708 t.start()
1709 threadID = threadID + 1
1710
1711 results = []
1712 for thread in pool:
1713 thread.join()
1714 results.append(thread.result)
1715 time2 = time.time()
1716
1717 if( all(result == main.TRUE for result in results) == False):
1718 main.log.info("Did not uninstall onos-app-ifwd feature properly")
Hari Krishnab35c6d02015-03-18 11:13:51 -07001719 uninstallResult = main.FALSE
1720 #main.cleanup()
1721 #main.exit()
kelvin-onlab54400a92015-02-26 18:05:51 -08001722 else:
1723 main.log.info("Successful feature:uninstall onos-app-ifwd")
1724 uninstallResult = main.TRUE
1725 main.log.info("Time for feature:uninstall onos-app-ifwd: %2f seconds" %(time2-time1))
Hari Krishna22c3d412015-02-17 16:48:12 -08001726
1727 # Waiting for reative flows to be cleared.
1728 time.sleep( 10 )
1729
1730 case11Result = installResult and ping_result and uninstallResult
1731 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
1732 onpass="Intent based Reactive forwarding Pingall test PASS",
1733 onfail="Intent based Reactive forwarding Pingall test FAIL" )
1734
1735 def CASE12( self, main ):
1736 """
1737 This test script Loads a new Topology (Chordal) on CHO setup and balances all switches
1738 """
1739 import re
1740 import time
1741 import copy
1742
Hari Krishnab35c6d02015-03-18 11:13:51 -07001743 main.newTopo = main.params['TOPO2']['topo']
Hari Krishna22c3d412015-02-17 16:48:12 -08001744 main.numMNswitches = int ( main.params[ 'TOPO2' ][ 'numSwitches' ] )
1745 main.numMNlinks = int ( main.params[ 'TOPO2' ][ 'numLinks' ] )
1746 main.numMNhosts = int ( main.params[ 'TOPO2' ][ 'numHosts' ] )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001747 main.pingTimeout = 120
Hari Krishna22c3d412015-02-17 16:48:12 -08001748 main.log.report(
1749 "Load Chordal topology and Balance all Mininet switches across controllers" )
1750 main.log.report(
1751 "________________________________________________________________________" )
Hari Krishna22c3d412015-02-17 16:48:12 -08001752 main.case(
1753 "Assign and Balance all Mininet switches across controllers" )
1754 main.step( "Stop any previous Mininet network topology" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001755 stopStatus = main.Mininet1.stopNet(fileName = "topoChordal" )
1756 time.sleep(10)
Hari Krishna22c3d412015-02-17 16:48:12 -08001757 main.step( "Start Mininet with Chordal topology" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001758 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
1759 time.sleep(15)
Hari Krishna22c3d412015-02-17 16:48:12 -08001760 main.step( "Assign switches to controllers" )
1761 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
1762 main.Mininet1.assignSwController(
1763 sw=str( i ),
1764 count=int( main.numCtrls ),
1765 ip1=main.ONOS1_ip,
1766 port1=main.ONOS1_port,
1767 ip2=main.ONOS2_ip,
1768 port2=main.ONOS2_port,
1769 ip3=main.ONOS3_ip,
1770 port3=main.ONOS3_port,
1771 ip4=main.ONOS4_ip,
1772 port4=main.ONOS4_port,
1773 ip5=main.ONOS5_ip,
1774 port5=main.ONOS5_port )
1775
1776 switch_mastership = main.TRUE
1777 for i in range( 1, ( main.numMNswitches + 1 ) ):
1778 response = main.Mininet1.getSwController( "s" + str( i ) )
1779 print( "Response is " + str( response ) )
1780 if re.search( "tcp:" + main.ONOS1_ip, response ):
1781 switch_mastership = switch_mastership and main.TRUE
1782 else:
1783 switch_mastership = main.FALSE
1784
1785 if switch_mastership == main.TRUE:
1786 main.log.report( "Controller assignment successfull" )
1787 else:
1788 main.log.report( "Controller assignment failed" )
1789 time.sleep( 5 )
kelvin-onlab54400a92015-02-26 18:05:51 -08001790
Hari Krishnab35c6d02015-03-18 11:13:51 -07001791 #Don't balance master for now..
1792 """
Hari Krishna22c3d412015-02-17 16:48:12 -08001793 main.step( "Balance devices across controllers" )
1794 for i in range( int( main.numCtrls ) ):
1795 balanceResult = main.ONOScli1.balanceMasters()
1796 # giving some breathing time for ONOS to complete re-balance
1797 time.sleep( 3 )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001798 """
1799 case12Result = switch_mastership
1800 time.sleep(30)
Hari Krishna22c3d412015-02-17 16:48:12 -08001801 utilities.assert_equals(
1802 expect=main.TRUE,
1803 actual=case12Result,
1804 onpass="Starting new Chordal topology test PASS",
1805 onfail="Starting new Chordal topology test FAIL" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001806
Hari Krishna22c3d412015-02-17 16:48:12 -08001807 def CASE13( self, main ):
1808 """
1809 This test script Loads a new Topology (Spine) on CHO setup and balances all switches
1810 """
1811 import re
1812 import time
1813 import copy
1814
Hari Krishnab35c6d02015-03-18 11:13:51 -07001815 main.newTopo = main.params['TOPO3']['topo']
Hari Krishna22c3d412015-02-17 16:48:12 -08001816 main.numMNswitches = int ( main.params[ 'TOPO3' ][ 'numSwitches' ] )
1817 main.numMNlinks = int ( main.params[ 'TOPO3' ][ 'numLinks' ] )
1818 main.numMNhosts = int ( main.params[ 'TOPO3' ][ 'numHosts' ] )
kelvin-onlab54400a92015-02-26 18:05:51 -08001819 main.pingTimeout = 600
Hari Krishnaef1bd4e2015-03-12 16:55:30 -07001820
Hari Krishna22c3d412015-02-17 16:48:12 -08001821 main.log.report(
1822 "Load Spine and Leaf topology and Balance all Mininet switches across controllers" )
1823 main.log.report(
1824 "________________________________________________________________________" )
1825 # need to wait here for sometime until ONOS bootup
Hari Krishna22c3d412015-02-17 16:48:12 -08001826 main.case(
1827 "Assign and Balance all Mininet switches across controllers" )
1828 main.step( "Stop any previous Mininet network topology" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001829 stopStatus = main.Mininet1.stopNet(fileName = "topoSpine" )
Hari Krishna22c3d412015-02-17 16:48:12 -08001830 main.step( "Start Mininet with Spine topology" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001831 startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
1832 time.sleep(20)
Hari Krishna22c3d412015-02-17 16:48:12 -08001833 main.step( "Assign switches to controllers" )
1834 for i in range( 1, ( main.numMNswitches + 1 ) ): # 1 to ( num of switches +1 )
1835 main.Mininet1.assignSwController(
1836 sw=str( i ),
Hari Krishnab35c6d02015-03-18 11:13:51 -07001837 count= 1,
Hari Krishna22c3d412015-02-17 16:48:12 -08001838 ip1=main.ONOS1_ip,
1839 port1=main.ONOS1_port,
1840 ip2=main.ONOS2_ip,
1841 port2=main.ONOS2_port,
1842 ip3=main.ONOS3_ip,
1843 port3=main.ONOS3_port,
1844 ip4=main.ONOS4_ip,
1845 port4=main.ONOS4_port,
1846 ip5=main.ONOS5_ip,
1847 port5=main.ONOS5_port )
1848
1849 switch_mastership = main.TRUE
1850 for i in range( 1, ( main.numMNswitches + 1 ) ):
1851 response = main.Mininet1.getSwController( "s" + str( i ) )
1852 print( "Response is " + str( response ) )
1853 if re.search( "tcp:" + main.ONOS1_ip, response ):
1854 switch_mastership = switch_mastership and main.TRUE
1855 else:
1856 switch_mastership = main.FALSE
Hari Krishnab35c6d02015-03-18 11:13:51 -07001857
Hari Krishna22c3d412015-02-17 16:48:12 -08001858 if switch_mastership == main.TRUE:
1859 main.log.report( "Controller assignment successfull" )
1860 else:
1861 main.log.report( "Controller assignment failed" )
1862 time.sleep( 5 )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001863 """
kelvin-onlab54400a92015-02-26 18:05:51 -08001864 main.step( "Balance devices across controllers" )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001865
kelvin-onlab54400a92015-02-26 18:05:51 -08001866 for i in range( int( main.numCtrls ) ):
1867 balanceResult = main.ONOScli1.balanceMasters()
1868 # giving some breathing time for ONOS to complete re-balance
1869 time.sleep( 3 )
Hari Krishna22c3d412015-02-17 16:48:12 -08001870
1871 main.step( "Balance devices across controllers" )
1872 for i in range( int( main.numCtrls ) ):
1873 balanceResult = main.ONOScli1.balanceMasters()
1874 # giving some breathing time for ONOS to complete re-balance
1875 time.sleep( 3 )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001876 """
1877 case13Result = switch_mastership
1878 time.sleep(30)
Hari Krishna22c3d412015-02-17 16:48:12 -08001879 utilities.assert_equals(
1880 expect=main.TRUE,
1881 actual=case13Result,
1882 onpass="Starting new Spine topology test PASS",
1883 onfail="Starting new Spine topology test FAIL" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001884
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001885 def CASE14( self ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001886 """
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001887 Install 300 host intents and verify ping all for Chordal Topology
kelvin-onlab54400a92015-02-26 18:05:51 -08001888 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001889 main.log.report( "Add 300 host intents and verify pingall (Chordal Topo)" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001890 main.log.report( "_______________________________________" )
1891 import itertools
1892
1893 main.case( "Install 300 host intents" )
1894 main.step( "Add host Intents" )
1895 intentResult = main.TRUE
1896 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
1897
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001898 intentIdList = []
kelvin-onlab54400a92015-02-26 18:05:51 -08001899 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001900
1901 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001902 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001903 for cli in main.CLIs:
1904 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001905 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001906 t = main.Thread( target=cli.addHostIntent,
1907 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -08001908 name="addHostIntent",
1909 args=[hostCombos[i][0],hostCombos[i][1]])
1910 pool.append(t)
1911 t.start()
1912 i = i + 1
1913 main.threadID = main.threadID + 1
kelvin-onlab54400a92015-02-26 18:05:51 -08001914 for thread in pool:
1915 thread.join()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001916 intentIdList.append(thread.result)
kelvin-onlab54400a92015-02-26 18:05:51 -08001917 time2 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08001918 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001919 intentResult = main.TRUE
1920 intentsJson = main.ONOScli2.intents()
1921 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1922 intentsJson = intentsJson)
1923 print getIntentStateResult
1924
kelvin-onlab54400a92015-02-26 18:05:51 -08001925 main.step( "Verify Ping across all hosts" )
1926 pingResult = main.FALSE
1927 time1 = time.time()
1928 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1929 time2 = time.time()
1930 timeDiff = round( ( time2 - time1 ), 2 )
1931 main.log.report(
1932 "Time taken for Ping All: " +
1933 str( timeDiff ) +
1934 " seconds" )
1935 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1936 onpass="PING ALL PASS",
1937 onfail="PING ALL FAIL" )
1938
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001939 case14Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -08001940
kelvin-onlab54400a92015-02-26 18:05:51 -08001941 utilities.assert_equals(
1942 expect=main.TRUE,
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001943 actual=case14Result,
kelvin-onlab54400a92015-02-26 18:05:51 -08001944 onpass="Install 300 Host Intents and Ping All test PASS",
1945 onfail="Install 300 Host Intents and Ping All test FAIL" )
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001946
1947 def CASE15( self ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001948 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001949 Install 2278 host intents and verify ping all for Spine Topology
kelvin-onlab54400a92015-02-26 18:05:51 -08001950 """
Hari Krishnab35c6d02015-03-18 11:13:51 -07001951 main.log.report( "Add 2278 host intents and verify pingall (Spine Topo)" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001952 main.log.report( "_______________________________________" )
1953 import itertools
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001954
Hari Krishnab35c6d02015-03-18 11:13:51 -07001955 main.case( "Install 2278 host intents" )
kelvin-onlab54400a92015-02-26 18:05:51 -08001956 main.step( "Add host Intents" )
1957 intentResult = main.TRUE
1958 hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
Hari Krishnab35c6d02015-03-18 11:13:51 -07001959 main.pingTimeout = 300
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001960 intentIdList = []
kelvin-onlab54400a92015-02-26 18:05:51 -08001961 time1 = time.time()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001962 for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001963 pool = []
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001964 for cli in main.CLIs:
1965 if i >= len( hostCombos ):
kelvin-onlab54400a92015-02-26 18:05:51 -08001966 break
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001967 t = main.Thread( target=cli.addHostIntent,
1968 threadID=main.threadID,
kelvin-onlab54400a92015-02-26 18:05:51 -08001969 name="addHostIntent",
1970 args=[hostCombos[i][0],hostCombos[i][1]])
1971 pool.append(t)
1972 t.start()
1973 i = i + 1
1974 main.threadID = main.threadID + 1
kelvin-onlab54400a92015-02-26 18:05:51 -08001975 for thread in pool:
1976 thread.join()
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001977 intentIdList.append(thread.result)
kelvin-onlab54400a92015-02-26 18:05:51 -08001978 time2 = time.time()
kelvin-onlab54400a92015-02-26 18:05:51 -08001979 main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08001980 intentResult = main.TRUE
1981 intentsJson = main.ONOScli2.intents()
1982 getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
1983 intentsJson = intentsJson)
1984 print getIntentStateResult
1985
kelvin-onlab54400a92015-02-26 18:05:51 -08001986 main.step( "Verify Ping across all hosts" )
1987 pingResult = main.FALSE
1988 time1 = time.time()
1989 pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
1990 time2 = time.time()
1991 timeDiff = round( ( time2 - time1 ), 2 )
1992 main.log.report(
1993 "Time taken for Ping All: " +
1994 str( timeDiff ) +
1995 " seconds" )
1996 utilities.assert_equals( expect=main.TRUE, actual=pingResult,
1997 onpass="PING ALL PASS",
1998 onfail="PING ALL FAIL" )
1999
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002000 case15Result = ( intentResult and pingResult )
kelvin-onlab54400a92015-02-26 18:05:51 -08002001
kelvin-onlab54400a92015-02-26 18:05:51 -08002002 utilities.assert_equals(
2003 expect=main.TRUE,
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002004 actual=case15Result,
Hari Krishnab35c6d02015-03-18 11:13:51 -07002005 onpass="Install 2278 Host Intents and Ping All test PASS",
2006 onfail="Install 2278 Host Intents and Ping All test FAIL" )
2007
2008 def CASE99(self):
2009 import time
2010 # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
2011 main.step( "Stop ONOS on all Nodes" )
2012 stopResult = main.TRUE
2013 for i in range( 1, int( main.numCtrls ) + 1 ):
2014 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2015 main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
2016 sresult = main.ONOSbench.onosStop( ONOS_ip )
2017 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2018 onpass="Test step PASS",
2019 onfail="Test step FAIL" )
2020 stopResult = ( stopResult and sresult )
2021
2022 main.step( "Start ONOS on all Nodes" )
2023 startResult = main.TRUE
2024 for i in range( 1, int( main.numCtrls ) + 1 ):
2025 ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
2026 main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
2027 sresult = main.ONOSbench.onosStart( ONOS_ip )
2028 utilities.assert_equals( expect=main.TRUE, actual=sresult,
2029 onpass="Test step PASS",
2030 onfail="Test step FAIL" )
2031 startResult = ( startResult and sresult )
2032
2033 main.step( "Start ONOS CLI on all nodes" )
2034 cliResult = main.TRUE
2035 time.sleep( 30 )
2036 main.log.step(" Start ONOS cli using thread ")
2037 pool = []
2038 time1 = time.time()
2039 for i in range( int( main.numCtrls ) ):
2040 t = main.Thread(target=main.CLIs[i].startOnosCli,
2041 threadID=main.threadID,
2042 name="startOnosCli",
2043 args=[main.nodes[i].ip_address])
2044 pool.append(t)
2045 t.start()
2046 main.threadID = main.threadID + 1
2047 for t in pool:
2048 t.join()
2049 cliResult = cliResult and t.result
2050 time2 = time.time()
2051
2052 if not cliResult:
2053 main.log.info("ONOS CLI did not start up properly")
2054 #main.cleanup()
2055 #main.exit()
2056 else:
2057 main.log.info("Successful CLI startup")
2058 main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
2059
2060 case99Result = ( startResult and cliResult )
2061 time.sleep(30)
2062 utilities.assert_equals(
2063 expect=main.TRUE,
2064 actual=case99Result,
2065 onpass="Starting new Chordal topology test PASS",
2066 onfail="Starting new Chordal topology test FAIL" )
2067
2068
kelvin-onlab78f7d2d2015-03-02 17:37:35 -08002069
kelvin-onlabc3ab3012015-03-10 15:04:46 -07002070