blob: 9c2c2717107d323e02b75b435157101a96b6b745 [file] [log] [blame]
shahshreya4e13a062014-11-11 16:46:18 -08001
shahshreyafac62b12015-01-20 16:16:13 -08002# Testing the basic functionality of ONOS Next
3# For sanity and driver functionality excercises only.
shahshreya4e13a062014-11-11 16:46:18 -08004
5import time
shahshreyafac62b12015-01-20 16:16:13 -08006# import sys
7# import os
8# import re
shahshreya4e13a062014-11-11 16:46:18 -08009import json
10
shahshreyafac62b12015-01-20 16:16:13 -080011time.sleep( 1 )
12
13
shahshreya4e13a062014-11-11 16:46:18 -080014class ProdFunc:
shahshreyafac62b12015-01-20 16:16:13 -080015
16 def __init__( self ):
shahshreya4e13a062014-11-11 16:46:18 -080017 self.default = ''
18
shahshreyafac62b12015-01-20 16:16:13 -080019 def CASE1( self, main ):
shahshreya82ecd282015-02-05 16:48:03 -080020 import time
shahshreyafac62b12015-01-20 16:16:13 -080021 """
shahshreya4e13a062014-11-11 16:46:18 -080022 Startup sequence:
shahshreyae6c7cf42014-11-26 16:39:01 -080023 cell <name>
24 onos-verify-cell
25 onos-remove-raft-log
shahshreya4e13a062014-11-11 16:46:18 -080026 git pull
27 mvn clean install
28 onos-package
shahshreya4e13a062014-11-11 16:46:18 -080029 onos-install -f
30 onos-wait-for-start
shahshreyafac62b12015-01-20 16:16:13 -080031 """
32 cellName = main.params[ 'ENV' ][ 'cellName' ]
33 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreyae6c7cf42014-11-26 16:39:01 -080034
shahshreyafac62b12015-01-20 16:16:13 -080035 main.case( "Setting up test environment" )
36 main.log.report(
37 "This testcase is testing setting up test environment" )
38 main.log.report( "__________________________________" )
shahshreyae6c7cf42014-11-26 16:39:01 -080039
shahshreyafac62b12015-01-20 16:16:13 -080040 main.step( "Applying cell variable to environment" )
41 cellResult = main.ONOSbench.setCell( cellName )
42 verifyResult = main.ONOSbench.verifyCell()
43
shahshreyab512cd02015-01-27 17:01:47 -080044 main.step( "Git checkout and get version" )
shahshreyaa47ebf42015-05-20 13:29:18 -070045 main.ONOSbench.gitCheckout( "master" )
shahshreyafac62b12015-01-20 16:16:13 -080046 gitPullResult = main.ONOSbench.gitPull()
shahshreya82ecd282015-02-05 16:48:03 -080047 main.log.info( "git_pull_result = " + str( gitPullResult ))
shahshreyafac62b12015-01-20 16:16:13 -080048 main.ONOSbench.getVersion( report=True )
49
shahshreya234a1682015-05-27 15:41:56 -070050 packageResult = main.TRUE
shahshreyafac62b12015-01-20 16:16:13 -080051 if gitPullResult == 1:
52 main.step( "Using mvn clean & install" )
53 main.ONOSbench.cleanInstall()
shahshreya234a1682015-05-27 15:41:56 -070054 main.step( "Creating ONOS package" )
55 packageResult = main.ONOSbench.onosPackage()
shahshreyafac62b12015-01-20 16:16:13 -080056 elif gitPullResult == 0:
57 main.log.report(
58 "Git Pull Failed, look into logs for detailed reason" )
shahshreya0e81ed92014-12-08 16:57:17 -080059 main.cleanup()
shahshreyafac62b12015-01-20 16:16:13 -080060 main.exit()
shahshreya4e13a062014-11-11 16:46:18 -080061
shahshreya4e13a062014-11-11 16:46:18 -080062
shahshreyaa47ebf42015-05-20 13:29:18 -070063 main.step( "Uninstalling ONOS package" )
shahshreya234a1682015-05-27 15:41:56 -070064 onosInstallResult = main.ONOSbench.onosUninstall( ONOS1Ip )
shahshreyaa47ebf42015-05-20 13:29:18 -070065 if onosInstallResult == main.TRUE:
66 main.log.report( "Uninstalling ONOS package successful" )
67 else:
68 main.log.report( "Uninstalling ONOS package failed" )
69
shahshreyabf739d82015-06-10 11:22:31 -070070 time.sleep( 20 )
shahshreyafac62b12015-01-20 16:16:13 -080071 main.step( "Installing ONOS package" )
shahshreya234a1682015-05-27 15:41:56 -070072 onosInstallResult = main.ONOSbench.onosInstall( ONOS1Ip )
73 print onosInstallResult
shahshreyafac62b12015-01-20 16:16:13 -080074 if onosInstallResult == main.TRUE:
75 main.log.report( "Installing ONOS package successful" )
shahshreya4e13a062014-11-11 16:46:18 -080076 else:
shahshreyafac62b12015-01-20 16:16:13 -080077 main.log.report( "Installing ONOS package failed" )
shahshreya4e13a062014-11-11 16:46:18 -080078
shahshreyabf739d82015-06-10 11:22:31 -070079 time.sleep( 20 )
shahshreyafac62b12015-01-20 16:16:13 -080080 onos1Isup = main.ONOSbench.isup()
81 if onos1Isup == main.TRUE:
82 main.log.report( "ONOS instance is up and ready" )
shahshreya4e13a062014-11-11 16:46:18 -080083 else:
shahshreyafac62b12015-01-20 16:16:13 -080084 main.log.report( "ONOS instance may not be up" )
shahshreya4e13a062014-11-11 16:46:18 -080085
shahshreya234a1682015-05-27 15:41:56 -070086 startResult = main.TRUE
87 #main.step( "Starting ONOS service" )
88 #startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -080089
shahshreya234a1682015-05-27 15:41:56 -070090 main.ONOS2.startOnosCli( ONOS1Ip )
shahshreya82ecd282015-02-05 16:48:03 -080091 main.step( "Starting Mininet CLI..." )
92
93 # Starting the mininet using the old way
94 main.step( "Starting Mininet ..." )
95 netIsUp = main.Mininet1.startNet()
96 if netIsUp:
97 main.log.info("Mininet CLI is up")
98
shahshreyafac62b12015-01-20 16:16:13 -080099 case1Result = ( packageResult and
100 cellResult and verifyResult
101 and onosInstallResult and
102 onos1Isup and startResult )
103 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
shahshreya9294c8d2015-01-21 15:54:16 -0800104 onpass="Test startup successful",
105 onfail="Test startup NOT successful" )
shahshreyafac62b12015-01-20 16:16:13 -0800106
107 def CASE2( self, main ):
108 """
shahshreya0e81ed92014-12-08 16:57:17 -0800109 Switch Down
shahshreyafac62b12015-01-20 16:16:13 -0800110 """
111 # NOTE: You should probably run a topology check after this
112 import time
shahshreya0e81ed92014-12-08 16:57:17 -0800113
shahshreyafac62b12015-01-20 16:16:13 -0800114 main.case( "Switch down discovery" )
115 main.log.report( "This testcase is testing a switch down discovery" )
116 main.log.report( "__________________________________" )
117
118 switchSleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
shahshreya0e81ed92014-12-08 16:57:17 -0800119
120 description = "Killing a switch to ensure it is discovered correctly"
shahshreyafac62b12015-01-20 16:16:13 -0800121 main.log.report( description )
122 main.case( description )
shahshreya0e81ed92014-12-08 16:57:17 -0800123
shahshreyafac62b12015-01-20 16:16:13 -0800124 # TODO: Make this switch parameterizable
125 main.step( "Kill s28 " )
126 main.log.report( "Deleting s28" )
127 # FIXME: use new dynamic topo functions
128 main.Mininet1.delSwitch( "s28" )
129 main.log.info(
130 "Waiting " +
131 str( switchSleep ) +
132 " seconds for switch down to be discovered" )
133 time.sleep( switchSleep )
134 # Peek at the deleted switch
135 device = main.ONOS2.getDevice( dpid="0028" )
shahshreya0e81ed92014-12-08 16:57:17 -0800136 print "device = ", device
shahshreyafac62b12015-01-20 16:16:13 -0800137 if device[ u'available' ] == 'False':
138 case2Result = main.FALSE
shahshreya0e81ed92014-12-08 16:57:17 -0800139 else:
shahshreyafac62b12015-01-20 16:16:13 -0800140 case2Result = main.TRUE
141 utilities.assert_equals( expect=main.TRUE, actual=case2Result,
shahshreya9294c8d2015-01-21 15:54:16 -0800142 onpass="Switch down discovery successful",
143 onfail="Switch down discovery failed" )
shahshreya0e81ed92014-12-08 16:57:17 -0800144
shahshreyadcb08e82015-02-25 10:16:42 -0800145 def CASE101( self, main ):
shahshreyafac62b12015-01-20 16:16:13 -0800146 """
shahshreya4e13a062014-11-11 16:46:18 -0800147 Cleanup sequence:
shahshreyafac62b12015-01-20 16:16:13 -0800148 onos-service <nodeIp> stop
shahshreya4e13a062014-11-11 16:46:18 -0800149 onos-uninstall
150
151 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800152
shahshreyafac62b12015-01-20 16:16:13 -0800153 """
154 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800155
shahshreyafac62b12015-01-20 16:16:13 -0800156 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800157
shahshreyafac62b12015-01-20 16:16:13 -0800158 main.step( "Testing ONOS kill function" )
159 killResult = main.ONOSbench.onosKill( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800160
shahshreyafac62b12015-01-20 16:16:13 -0800161 main.step( "Stopping ONOS service" )
162 stopResult = main.ONOSbench.onosStop( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800163
shahshreyafac62b12015-01-20 16:16:13 -0800164 main.step( "Uninstalling ONOS service" )
165 uninstallResult = main.ONOSbench.onosUninstall()
shahshreya4e13a062014-11-11 16:46:18 -0800166
shahshreyafac62b12015-01-20 16:16:13 -0800167 case11Result = killResult and stopResult and uninstallResult
168 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
shahshreya9294c8d2015-01-21 15:54:16 -0800169 onpass="Cleanup successful",
170 onfail="Cleanup failed" )
shahshreyafac62b12015-01-20 16:16:13 -0800171
172 def CASE3( self, main ):
173 """
shahshreya4e13a062014-11-11 16:46:18 -0800174 Test 'onos' command and its functionality in driver
shahshreyafac62b12015-01-20 16:16:13 -0800175 """
176 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800177
shahshreyafac62b12015-01-20 16:16:13 -0800178 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800179
shahshreyafac62b12015-01-20 16:16:13 -0800180 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800181 cmdstr1 = "system:name"
shahshreyafac62b12015-01-20 16:16:13 -0800182 cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
183 main.log.info( "onos command returned: " + cmdResult1 )
shahshreya4e13a062014-11-11 16:46:18 -0800184
shahshreyafac62b12015-01-20 16:16:13 -0800185 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800186 cmdstr2 = "onos:topology"
shahshreyafac62b12015-01-20 16:16:13 -0800187 cmdResult2 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
188 main.log.info( "onos command returned: " + cmdResult2 )
shahshreya4e13a062014-11-11 16:46:18 -0800189
shahshreyafac62b12015-01-20 16:16:13 -0800190 def CASE20( self ):
191 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800192 Exit from mininet cli
193 reinstall ONOS
shahshreyafac62b12015-01-20 16:16:13 -0800194 """
shahshreya234a1682015-05-27 15:41:56 -0700195 import time
shahshreyafac62b12015-01-20 16:16:13 -0800196 cellName = main.params[ 'ENV' ][ 'cellName' ]
197 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800198
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800199 main.log.report( "This testcase exits the mininet cli and reinstalls" +
200 "ONOS to switch over to Packet Optical topology" )
shahshreyafac62b12015-01-20 16:16:13 -0800201 main.log.report( "_____________________________________________" )
202 main.case( "Disconnecting mininet and restarting ONOS" )
shahshreya234a1682015-05-27 15:41:56 -0700203
shahshreyafac62b12015-01-20 16:16:13 -0800204 main.step( "Disconnecting mininet and restarting ONOS" )
shahshreya234a1682015-05-27 15:41:56 -0700205 step1Result = main.TRUE
shahshreyafac62b12015-01-20 16:16:13 -0800206 mininetDisconnect = main.Mininet1.disconnect()
shahshreya3140b1a2015-04-28 14:22:15 -0700207 print "mininetDisconnect = ", mininetDisconnect
shahshreya234a1682015-05-27 15:41:56 -0700208 step1Result = mininetDisconnect
209 utilities.assert_equals(
210 expect=main.TRUE,
211 actual=step1Result,
212 onpass="Mininet disconnect successfully",
213 onfail="Mininet failed to disconnect")
214 """
215 main.step( "Removing raft logs before a clean installation of ONOS" )
216 step2Result = main.TRUE
217 removeRaftLogsResult = main.ONOSbench.onosRemoveRaftLogs()
218 step2Result = removeRaftLogsResult
219 utilities.assert_equals(
220 expect=main.TRUE,
221 actual=step2Result,
222 onpass="Raft logs removed successfully",
223 onfail="Failed to remove raft logs")
224 """
shahshreyafac62b12015-01-20 16:16:13 -0800225 main.step( "Applying cell variable to environment" )
shahshreya234a1682015-05-27 15:41:56 -0700226 step3Result = main.TRUE
227 setCellResult = main.ONOSbench.setCell( cellName )
228 verifyCellResult = main.ONOSbench.verifyCell()
229 step3Result = setCellResult and verifyCellResult
230 utilities.assert_equals(
231 expect=main.TRUE,
232 actual=step3Result,
233 onpass="Cell applied successfully",
234 onfail="Failed to apply cell")
shahshreyafac62b12015-01-20 16:16:13 -0800235
shahshreya234a1682015-05-27 15:41:56 -0700236 main.step( "Uninstalling ONOS package" )
237 step4Result = main.TRUE
238 ONOSip1 = main.params[ 'CTRL' ][ 'ip1' ]
239 onosUninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOSip1)
240 step4Result = onosUninstallResult
241 utilities.assert_equals(
242 expect=main.TRUE,
243 actual=step4Result,
244 onpass="Successfully uninstalled ONOS",
245 onfail="Failed to uninstall ONOS")
246
247 time.sleep( 5 )
248 main.step( "Installing ONOS package" )
249 step5Result = main.TRUE
250 onosInstallResult = main.ONOSbench.onosInstall( node = ONOSip1 )
251 step5Result = onosInstallResult
252 utilities.assert_equals(
253 expect=main.TRUE,
254 actual=step5Result,
255 onpass="Successfully installed ONOS",
256 onfail="Failed to install ONOS")
shahshreyae6c7cf42014-11-26 16:39:01 -0800257
shahshreyafac62b12015-01-20 16:16:13 -0800258 onos1Isup = main.ONOSbench.isup()
259 if onos1Isup == main.TRUE:
260 main.log.report( "ONOS instance is up and ready" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800261 else:
shahshreyafac62b12015-01-20 16:16:13 -0800262 main.log.report( "ONOS instance may not be up" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800263
shahshreyafac62b12015-01-20 16:16:13 -0800264 main.step( "Starting ONOS service" )
shahshreya234a1682015-05-27 15:41:56 -0700265 step6Result = main.TRUE
shahshreyafac62b12015-01-20 16:16:13 -0800266 startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreya234a1682015-05-27 15:41:56 -0700267 step6Result = startResult
shahshreyafac62b12015-01-20 16:16:13 -0800268 utilities.assert_equals(
269 expect=main.TRUE,
shahshreya234a1682015-05-27 15:41:56 -0700270 actual=step6Result,
271 onpass="Successfully started ONOS",
272 onfail="Failed to start ONOS")
273
274 main.step( "Starting ONOS cli" )
275 step7Result = main.TRUE
276 cliResult = main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
277 step7Result = cliResult
278 utilities.assert_equals(
279 expect=main.TRUE,
280 actual=step7Result,
281 onpass="Successfully started ONOS cli",
282 onfail="Failed to start ONOS cli")
shahshreyafac62b12015-01-20 16:16:13 -0800283
284 def CASE21( self, main ):
285 """
286 On ONOS bench, run this command:
shahshreya1937ec12015-04-03 15:35:48 -0700287 sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1
288 which spawns packet optical topology and copies the links
shahshreyafac62b12015-01-20 16:16:13 -0800289 json file to the onos instance.
290 Note that in case of Packet Optical, the links are not learnt
291 from the topology, instead the links are learnt
shahshreyae6c7cf42014-11-26 16:39:01 -0800292 from the json config file
shahshreyafac62b12015-01-20 16:16:13 -0800293 """
shahshreya234a1682015-05-27 15:41:56 -0700294 import time
shahshreyafac62b12015-01-20 16:16:13 -0800295 main.log.report(
296 "This testcase starts the packet layer topology and REST" )
297 main.log.report( "_____________________________________________" )
298 main.case( "Starting LINC-OE and other components" )
shahshreya234a1682015-05-27 15:41:56 -0700299
300 main.step( "Activate optical app" )
301 step1Result = main.TRUE
302 activateOpticalResult = main.ONOS2.activateApp( "org.onosproject.optical" )
303 step1Result = activateOpticalResult
304 utilities.assert_equals(
305 expect=main.TRUE,
306 actual=step1Result,
307 onpass="Successfully activated optical app",
308 onfail="Failed to activate optical app")
309
shahshreyad524a942015-04-21 09:55:16 -0700310 appCheck = main.ONOS2.appToIDCheck()
311 if appCheck != main.TRUE:
312 main.log.warn( main.ONOS2.apps() )
313 main.log.warn( main.ONOS2.appIDs() )
314
shahshreya234a1682015-05-27 15:41:56 -0700315 main.step( "Starting mininet and LINC-OE" )
316 step2Result = main.TRUE
317 time.sleep( 10 )
shahshreya215c48f2015-04-06 15:55:55 -0700318 opticalMnScript = main.LincOE2.runOpticalMnScript(ctrllerIP = main.params[ 'CTRL' ][ 'ip1' ])
shahshreya234a1682015-05-27 15:41:56 -0700319 step2Result = opticalMnScript
shahshreyafac62b12015-01-20 16:16:13 -0800320 utilities.assert_equals(
321 expect=main.TRUE,
shahshreya234a1682015-05-27 15:41:56 -0700322 actual=step2Result,
323 onpass="Started the topology successfully ",
324 onfail="Failed to start the topology")
shahshreyae6c7cf42014-11-26 16:39:01 -0800325
shahshreyafac62b12015-01-20 16:16:13 -0800326 def CASE22( self, main ):
327 """
shahshreya1937ec12015-04-03 15:35:48 -0700328 Curretly we use, 10 optical switches(ROADM's) and
329 6 packet layer mininet switches each with one host.
330 Therefore, the roadmCount variable = 10,
331 packetLayerSWCount variable = 6, hostCount=6 and
shahshreyaa47ebf42015-05-20 13:29:18 -0700332 links=46.
shahshreya1937ec12015-04-03 15:35:48 -0700333 All this is hardcoded in the testcase. If the topology changes,
shahshreyafac62b12015-01-20 16:16:13 -0800334 these hardcoded values need to be changed
335 """
shahshreya234a1682015-05-27 15:41:56 -0700336 import time
shahshreyafac62b12015-01-20 16:16:13 -0800337 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800338 "This testcase compares the optical+packet topology against what" +
339 " is expected" )
shahshreyafac62b12015-01-20 16:16:13 -0800340 main.case( "Topology comparision" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800341
shahshreya234a1682015-05-27 15:41:56 -0700342 main.step( "Starts new ONOS cli" )
343 step1Result = main.TRUE
344 cliResult = main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ]\
345 [ 'ip1' ] )
346 step1Result = cliResult
347 utilities.assert_equals(
348 expect=main.TRUE,
349 actual=step1Result,
350 onpass="Successfully starts a new cli",
351 onfail="Failed to start new cli" )
352
353 main.step( "Compare topology" )
354 step2Result = main.TRUE
355 devicesResult = main.ONOS3.devices( jsonFormat=False )
356 print "devices_result :\n", devicesResult
shahshreyafac62b12015-01-20 16:16:13 -0800357 devicesLinewise = devicesResult.split( "\n" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800358 roadmCount = 0
359 packetLayerSWCount = 0
shahshreyafac62b12015-01-20 16:16:13 -0800360 for line in devicesLinewise:
361 components = line.split( "," )
362 availability = components[ 1 ].split( "=" )[ 1 ]
363 type = components[ 3 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800364 if availability == 'true' and type == 'ROADM':
365 roadmCount += 1
shahshreyafac62b12015-01-20 16:16:13 -0800366 elif availability == 'true' and type == 'SWITCH':
shahshreyae6c7cf42014-11-26 16:39:01 -0800367 packetLayerSWCount += 1
shahshreya1937ec12015-04-03 15:35:48 -0700368 if roadmCount == 10:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800369 print "Number of Optical Switches = %d and is" % roadmCount +\
370 " correctly detected"
shahshreyafac62b12015-01-20 16:16:13 -0800371 main.log.info(
372 "Number of Optical Switches = " +
373 str( roadmCount ) +
374 " and is correctly detected" )
375 opticalSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800376 else:
shahshreyafac62b12015-01-20 16:16:13 -0800377 print "Number of Optical Switches = %d and is wrong" % roadmCount
378 main.log.info(
379 "Number of Optical Switches = " +
380 str( roadmCount ) +
381 " and is wrong" )
382 opticalSWResult = main.FALSE
shahshreya1937ec12015-04-03 15:35:48 -0700383 if packetLayerSWCount == 6:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800384 print "Number of Packet layer or mininet Switches = %d "\
385 % packetLayerSWCount + "and is correctly detected"
shahshreyafac62b12015-01-20 16:16:13 -0800386 main.log.info(
387 "Number of Packet layer or mininet Switches = " +
388 str( packetLayerSWCount ) +
389 " and is correctly detected" )
390 packetSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800391 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800392 print "Number of Packet layer or mininet Switches = %d and"\
393 % packetLayerSWCount + " is wrong"
shahshreyafac62b12015-01-20 16:16:13 -0800394 main.log.info(
395 "Number of Packet layer or mininet Switches = " +
396 str( packetLayerSWCount ) +
397 " and is wrong" )
398 packetSWResult = main.FALSE
shahshreya234a1682015-05-27 15:41:56 -0700399 # sleeps for sometime so the state of the switches will be active
400 time.sleep( 30 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800401 print "_________________________________"
shahshreyafac62b12015-01-20 16:16:13 -0800402 linksResult = main.ONOS3.links( jsonFormat=False )
403 print "links_result = ", linksResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800404 print "_________________________________"
shahshreya234a1682015-05-27 15:41:56 -0700405 linkActiveCount = linksResult.count("state=ACTIVE")
shahshreya1937ec12015-04-03 15:35:48 -0700406 main.log.info( "linkActiveCount = " + str( linkActiveCount ))
shahshreyaa47ebf42015-05-20 13:29:18 -0700407 if linkActiveCount == 46:
shahshreya1937ec12015-04-03 15:35:48 -0700408 linkActiveResult = main.TRUE
409 main.log.info(
410 "Number of links in ACTIVE state are correct")
411 else:
412 linkActiveResult = main.FALSE
413 main.log.info(
414 "Number of links in ACTIVE state are wrong")
shahshreya234a1682015-05-27 15:41:56 -0700415 step2Result = opticalSWResult and packetSWResult and \
shahshreya1937ec12015-04-03 15:35:48 -0700416 linkActiveResult
shahshreyafac62b12015-01-20 16:16:13 -0800417 utilities.assert_equals(
418 expect=main.TRUE,
shahshreya234a1682015-05-27 15:41:56 -0700419 actual=step2Result,
420 onpass="Successfully loaded packet optical topology",
421 onfail="Failed to load packet optical topology" )
shahshreya0e81ed92014-12-08 16:57:17 -0800422
shahshreyafac62b12015-01-20 16:16:13 -0800423 def CASE23( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800424 import time
shahshreyafac62b12015-01-20 16:16:13 -0800425 """
426 Add bidirectional point intents between 2 packet layer( mininet )
427 devices and
shahshreyae6c7cf42014-11-26 16:39:01 -0800428 ping mininet hosts
shahshreyafac62b12015-01-20 16:16:13 -0800429 """
430 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800431 "This testcase adds bidirectional point intents between 2 " +
432 "packet layer( mininet ) devices and ping mininet hosts" )
shahshreya234a1682015-05-27 15:41:56 -0700433 main.case( "Install point intents between 2 packet layer device and " +
434 "ping the hosts" )
435
shahshreyafac62b12015-01-20 16:16:13 -0800436 main.step( "Adding point intents" )
shahshreyabf739d82015-06-10 11:22:31 -0700437 checkFlowResult = main.TRUE
shahshreya234a1682015-05-27 15:41:56 -0700438 step1Result = main.TRUE
439 main.pIntentsId = []
440 pIntent1 = main.ONOS3.addPointIntent(
shahshreyafac62b12015-01-20 16:16:13 -0800441 "of:0000ffffffff0001/1",
shahshreya1937ec12015-04-03 15:35:48 -0700442 "of:0000ffffffff0005/1" )
shahshreya234a1682015-05-27 15:41:56 -0700443 pIntent2 = main.ONOS3.addPointIntent(
shahshreya1937ec12015-04-03 15:35:48 -0700444 "of:0000ffffffff0005/1",
shahshreyafac62b12015-01-20 16:16:13 -0800445 "of:0000ffffffff0001/1" )
shahshreya234a1682015-05-27 15:41:56 -0700446 main.pIntentsId.append( pIntent1 )
447 main.pIntentsId.append( pIntent2 )
448 time.sleep( 10 )
449 main.log.info( "Checking intents state")
450 checkStateResult = main.ONOS3.checkIntentState(
451 intentsId = main.pIntentsId )
452 time.sleep( 10 )
453 main.log.info( "Checking flows state")
454 checkFlowResult = main.ONOS3.checkFlowsState()
shahshreyae6c7cf42014-11-26 16:39:01 -0800455 # Sleep for 30 seconds to provide time for the intent state to change
shahshreya234a1682015-05-27 15:41:56 -0700456 time.sleep( 10 )
457 main.log.info( "Checking intents state one more time")
458 checkStateResult = main.ONOS3.checkIntentState(
459 intentsId = main.pIntentsId )
460 step1Result = checkStateResult and checkFlowResult
shahshreyafac62b12015-01-20 16:16:13 -0800461 utilities.assert_equals(
462 expect=main.TRUE,
shahshreya234a1682015-05-27 15:41:56 -0700463 actual=step1Result,
464 onpass="Successfully added point intents",
465 onfail="Failed to add point intents")
466
467 main.step( "Ping h1 and h5" )
468 step2Result = main.TRUE
469 main.log.info( "\n\nh1 is Pinging h5" )
470 pingResult = main.LincOE2.pingHostOptical( src="h1", target="h5" )
471 step2Result = pingResult
472 utilities.assert_equals(
473 expect=main.TRUE,
474 actual=step2Result,
475 onpass="Successfully pinged h1 and h5",
476 onfail="Failed to ping between h1 and h5")
shahshreyae6c7cf42014-11-26 16:39:01 -0800477
shahshreyafac62b12015-01-20 16:16:13 -0800478 def CASE24( self, main ):
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800479 import time
480 import json
shahshreyafac62b12015-01-20 16:16:13 -0800481 """
shahshreya1937ec12015-04-03 15:35:48 -0700482 LINC uses its own switch IDs. You can use the following
483 command on the LINC console to find the mapping between
484 DPIDs and LINC IDs.
485 rp(application:get_all_key(linc)).
486
shahshreyafac62b12015-01-20 16:16:13 -0800487 Test Rerouting of Packet Optical by bringing a port down
shahshreya1937ec12015-04-03 15:35:48 -0700488 ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
489 so that link
490 ( between switch1 port20 - switch5 port50 ) is inactive
shahshreyafac62b12015-01-20 16:16:13 -0800491 and do a ping test. If rerouting is successful,
492 ping should pass. also check the flows
493 """
494 main.log.report(
495 "This testcase tests rerouting and pings mininet hosts" )
496 main.case( "Test rerouting and pings mininet hosts" )
shahshreya234a1682015-05-27 15:41:56 -0700497
shahshreya1937ec12015-04-03 15:35:48 -0700498 main.step( "Attach to the Linc-OE session" )
shahshreya234a1682015-05-27 15:41:56 -0700499 step1Result = main.TRUE
500 attachConsole = main.LincOE1.attachLincOESession()
501 step1Result = attachConsole
502 utilities.assert_equals(
503 expect=main.TRUE,
504 actual=step1Result,
505 onpass="Successfully attached Linc-OE session",
506 onfail="Failed to attached Linc-OE session")
shahshreya1937ec12015-04-03 15:35:48 -0700507
shahshreyafac62b12015-01-20 16:16:13 -0800508 main.step( "Bring a port down and verify the link state" )
shahshreya234a1682015-05-27 15:41:56 -0700509 step2Result = main.TRUE
shahshreya1937ec12015-04-03 15:35:48 -0700510 main.LincOE1.portDown( swId="9", ptId="20" )
shahshreyafac62b12015-01-20 16:16:13 -0800511 linksNonjson = main.ONOS3.links( jsonFormat=False )
512 main.log.info( "links = " + linksNonjson )
shahshreya234a1682015-05-27 15:41:56 -0700513 linkInactiveCount = linksNonjson.count( "state=INACTIVE" )
shahshreya1937ec12015-04-03 15:35:48 -0700514 main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
515 if linkInactiveCount == 2:
516 main.log.info(
517 "Number of links in INACTIVE state are correct")
518 else:
519 main.log.info(
520 "Number of links in INACTIVE state are wrong")
shahshreya0e81ed92014-12-08 16:57:17 -0800521 links = main.ONOS3.links()
shahshreyafac62b12015-01-20 16:16:13 -0800522 main.log.info( "links = " + links )
shahshreyafac62b12015-01-20 16:16:13 -0800523 linksResult = json.loads( links )
524 linksStateResult = main.FALSE
525 for item in linksResult:
526 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
shahshreya1937ec12015-04-03 15:35:48 -0700527 'src' ][ 'port' ] == "20":
528 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
529 'dst' ][ 'port' ] == "50":
shahshreyafac62b12015-01-20 16:16:13 -0800530 linksState = item[ 'state' ]
531 if linksState == "INACTIVE":
532 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800533 "Links state is inactive as expected due to one" +
534 " of the ports being down" )
shahshreyafac62b12015-01-20 16:16:13 -0800535 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800536 "Links state is inactive as expected due to one" +
537 " of the ports being down" )
shahshreyafac62b12015-01-20 16:16:13 -0800538 linksStateResult = main.TRUE
shahshreya0e81ed92014-12-08 16:57:17 -0800539 break
540 else:
shahshreyafac62b12015-01-20 16:16:13 -0800541 main.log.info(
542 "Links state is not inactive as expected" )
543 main.log.report(
544 "Links state is not inactive as expected" )
545 linksStateResult = main.FALSE
shahshreyafac62b12015-01-20 16:16:13 -0800546 time.sleep( 10 )
shahshreya234a1682015-05-27 15:41:56 -0700547 checkFlowsState = main.ONOS3.checkFlowsState()
548 step2Result = linksStateResult
549 utilities.assert_equals(
550 expect=main.TRUE,
551 actual=step2Result,
552 onpass="Successfuly brought down a link",
553 onfail="Failed to bring down a link")
shahshreya0e81ed92014-12-08 16:57:17 -0800554
shahshreyafac62b12015-01-20 16:16:13 -0800555 main.step( "Verify Rerouting by a ping test" )
shahshreya234a1682015-05-27 15:41:56 -0700556 step3Result = main.TRUE
shahshreya1937ec12015-04-03 15:35:48 -0700557 main.log.info( "\n\nh1 is Pinging h5" )
shahshreya234a1682015-05-27 15:41:56 -0700558 pingResult = main.LincOE2.pingHostOptical( src="h1", target="h5" )
559 step3Result = pingResult
560 utilities.assert_equals(
561 expect=main.TRUE,
562 actual=step3Result,
563 onpass="Successfully pinged h1 and h5",
564 onfail="Failed to ping between h1 and h5")
565
566 main.step( "Bring the downed port up and verify the link state" )
567 step4Result = main.TRUE
568 main.LincOE1.portUp( swId="9", ptId="20" )
569 linksNonjson = main.ONOS3.links( jsonFormat=False )
570 main.log.info( "links = " + linksNonjson )
571 linkInactiveCount = linksNonjson.count( "state=INACTIVE" )
572 main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
573 if linkInactiveCount == 0:
shahshreyafac62b12015-01-20 16:16:13 -0800574 main.log.info(
shahshreya234a1682015-05-27 15:41:56 -0700575 "Number of links in INACTIVE state are correct")
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800576 else:
shahshreya234a1682015-05-27 15:41:56 -0700577 main.log.info(
578 "Number of links in INACTIVE state are wrong")
579 step4Result = main.FALSE
580 utilities.assert_equals(
581 expect=main.TRUE,
582 actual=step4Result,
583 onpass="Successfully brought the port up",
584 onfail="Failed to bring the port up")
585 """
586 main.step( "Removing host intents" )
587 step5Result = main.TRUE
588 removeResult = main.TRUE
589 # Check remaining intents
590 intentsJson = json.loads( main.ONOS3.intents() )
591 main.ONOS3.removeIntent( intentId=intent1, purge=True )
592 main.ONOS3.removeIntent( intentId=intent2, purge=True )
593 for intents in intentsJson:
594 main.ONOS3.removeIntent( intentId=intents.get( 'id' ),
595 app='org.onosproject.optical',
596 purge=True )
597 print json.loads( main.ONOS3.intents() )
598 if len( json.loads( main.ONOS3.intents() ) ):
599 removeResult = main.FALSE
600 step5Result = removeResult
601 utilities.assert_equals( expect=main.TRUE,
602 actual=step5Result,
603 onpass="Successfully removed host intents",
604 onfail="Failed to remove host intents" )
605 """
606 def CASE10( self ):
607 main.log.report(
608 "This testcase uninstalls the reactive forwarding app" )
609 main.log.report( "__________________________________" )
610 main.case( "Uninstalling reactive forwarding app" )
611 main.step( "Uninstalling reactive forwarding app" )
612 step1Result = main.TRUE
613 # Unistall onos-app-fwd app to disable reactive forwarding
614 main.log.info( "deactivate reactive forwarding app" )
615 appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
616 appCheck = main.ONOS2.appToIDCheck()
617 if appCheck != main.TRUE:
618 main.log.warn( main.ONOS2.apps() )
619 main.log.warn( main.ONOS2.appIDs() )
620 step1Result = appUninstallResult
621 utilities.assert_equals(
622 expect=main.TRUE,
623 actual=step1Result,
624 onpass="Successfully deactivate reactive forwarding app",
625 onfail="Failed to deactivate reactive forwarding app")
626 # After reactive forwarding is disabled, the reactive flows on
627 # switches timeout in 10-15s
628 # So sleep for 15s
629 time.sleep( 15 )
630 flows = main.ONOS2.flows()
631 main.log.info( flows )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800632
shahshreya234a1682015-05-27 15:41:56 -0700633 def CASE25( self ):
634 """
635 Add host intents between 2 packet layer host
636 """
637 import time
638 import json
639 main.log.report( "Adding host intents between 2 optical layer host" )
640 main.case( "Test add host intents between optical layer host" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800641
shahshreya234a1682015-05-27 15:41:56 -0700642 main.step( "Discover host using arping" )
643 step1Result = main.TRUE
644 main.hostMACs = []
645 main.hostId = []
646 #Listing host MAC addresses
647 for i in range( 1 , 7 ):
648 main.hostMACs.append( "00:00:00:00:00:" +
649 str( hex( i )[ 2: ] ).zfill( 2 ).upper() )
650 for macs in main.hostMACs:
651 main.hostId.append( macs + "/-1" )
652 host1 = main.hostId[ 0 ]
653 host2 = main.hostId[ 1 ]
654 # Use arping to discover the hosts
655 main.LincOE2.arping( host = "h1" )
656 main.LincOE2.arping( host = "h2" )
657 time.sleep( 5 )
658 hostsDict = main.ONOS3.hosts()
659 if not len( hostsDict ):
660 step1Result = main.FALSE
661 # Adding host intent
662 utilities.assert_equals(
663 expect=main.TRUE,
664 actual=step1Result,
665 onpass="Hosts discovered",
666 onfail="Failed to discover hosts")
667
668 main.step( "Adding host intents to h1 and h2" )
669 step2Result = main.TRUE
670 intentsId = []
671 intent1 = main.ONOS3.addHostIntent( hostIdOne = host1,
672 hostIdTwo = host2 )
673 intentsId.append( intent1 )
674 time.sleep( 5 )
675 intent2 = main.ONOS3.addHostIntent( hostIdOne = host2,
676 hostIdTwo = host1 )
677 intentsId.append( intent2 )
678 # Checking intents state before pinging
679 main.log.info( "Checking intents state" )
680 time.sleep( 15 )
681 intentResult = main.ONOS3.checkIntentState( intentsId = intentsId )
682 #check intent state again if intents are not in installed state
683 if not intentResult:
684 intentResult = main.ONOS3.checkIntentState( intentsId = intentsId )
685 step2Result = intentResult
686 utilities.assert_equals( expect=main.TRUE,
687 actual=step2Result,
688 onpass="All intents are in INSTALLED state ",
689 onfail="Some of the intents are not in " +
690 "INSTALLED state " )
691
692 # pinging h1 to h2 and then ping h2 to h1
693 main.step( "Pinging h1 and h2" )
694 step3Result = main.TRUE
695 pingResult = main.TRUE
696 pingResult = main.LincOE2.pingHostOptical( src="h1", target="h2" )
697 pingResult = pingResult and main.LincOE2.pingHostOptical( src="h2",
698 target="h1" )
699 step3Result = pingResult
700 utilities.assert_equals( expect=main.TRUE,
701 actual=step3Result,
702 onpass="Pinged successfully between h1 and h2",
703 onfail="Pinged failed between h1 and h2" )
704 # Removed all added host intents
705 main.step( "Removing host intents" )
706 step4Result = main.TRUE
707 removeResult = main.TRUE
708 # Check remaining intents
709 intentsJson = json.loads( main.ONOS3.intents() )
710 main.ONOS3.removeIntent( intentId=intent1, purge=True )
711 main.ONOS3.removeIntent( intentId=intent2, purge=True )
712 for intents in intentsJson:
713 main.ONOS3.removeIntent( intentId=intents.get( 'id' ),
714 app='org.onosproject.optical',
715 purge=True )
716 print json.loads( main.ONOS3.intents() )
717 if len( json.loads( main.ONOS3.intents() ) ):
718 removeResult = main.FALSE
719 step4Result = removeResult
720 utilities.assert_equals( expect=main.TRUE,
721 actual=step4Result,
722 onpass="Successfully removed host intents",
723 onfail="Failed to remove host intents" )
shahshreya4e13a062014-11-11 16:46:18 -0800724
shahshreyafac62b12015-01-20 16:16:13 -0800725 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800726 import re
727 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800728 main.log.report( "This testcase is testing the assignment of" +
729 " all the switches to all the controllers and" +
shahshreyadcb08e82015-02-25 10:16:42 -0800730 " discovering the hosts in reactive mode" )
shahshreyafac62b12015-01-20 16:16:13 -0800731 main.log.report( "__________________________________" )
shahshreyaa47ebf42015-05-20 13:29:18 -0700732
shahshreyafac62b12015-01-20 16:16:13 -0800733 main.case( "Pingall Test" )
734 main.step( "Assigning switches to controllers" )
735 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
736 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
737 for i in range( 1, 29 ):
738 if i == 1:
739 main.Mininet1.assignSwController(
740 sw=str( i ),
741 ip1=ONOS1Ip,
742 port1=ONOS1Port )
743 elif i >= 2 and i < 5:
744 main.Mininet1.assignSwController(
745 sw=str( i ),
746 ip1=ONOS1Ip,
747 port1=ONOS1Port )
748 elif i >= 5 and i < 8:
749 main.Mininet1.assignSwController(
750 sw=str( i ),
751 ip1=ONOS1Ip,
752 port1=ONOS1Port )
753 elif i >= 8 and i < 18:
754 main.Mininet1.assignSwController(
755 sw=str( i ),
756 ip1=ONOS1Ip,
757 port1=ONOS1Port )
758 elif i >= 18 and i < 28:
759 main.Mininet1.assignSwController(
760 sw=str( i ),
761 ip1=ONOS1Ip,
762 port1=ONOS1Port )
shahshreya4e13a062014-11-11 16:46:18 -0800763 else:
shahshreyafac62b12015-01-20 16:16:13 -0800764 main.Mininet1.assignSwController(
765 sw=str( i ),
766 ip1=ONOS1Ip,
767 port1=ONOS1Port )
768 SwitchMastership = main.TRUE
769 for i in range( 1, 29 ):
770 if i == 1:
771 response = main.Mininet1.getSwController( "s" + str( i ) )
772 print( "Response is " + str( response ) )
773 if re.search( "tcp:" + ONOS1Ip, response ):
774 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800775 else:
shahshreyafac62b12015-01-20 16:16:13 -0800776 SwitchMastership = main.FALSE
777 elif i >= 2 and i < 5:
778 response = main.Mininet1.getSwController( "s" + str( i ) )
779 print( "Response is " + str( response ) )
780 if re.search( "tcp:" + ONOS1Ip, response ):
781 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800782 else:
shahshreyafac62b12015-01-20 16:16:13 -0800783 SwitchMastership = main.FALSE
784 elif i >= 5 and i < 8:
785 response = main.Mininet1.getSwController( "s" + str( i ) )
786 print( "Response is " + str( response ) )
787 if re.search( "tcp:" + ONOS1Ip, response ):
788 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800789 else:
shahshreyafac62b12015-01-20 16:16:13 -0800790 SwitchMastership = main.FALSE
791 elif i >= 8 and i < 18:
792 response = main.Mininet1.getSwController( "s" + str( i ) )
793 print( "Response is " + str( response ) )
794 if re.search( "tcp:" + ONOS1Ip, response ):
795 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800796 else:
shahshreyafac62b12015-01-20 16:16:13 -0800797 SwitchMastership = main.FALSE
798 elif i >= 18 and i < 28:
799 response = main.Mininet1.getSwController( "s" + str( i ) )
800 print( "Response is " + str( response ) )
801 if re.search( "tcp:" + ONOS1Ip, response ):
802 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800803 else:
shahshreyafac62b12015-01-20 16:16:13 -0800804 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800805 else:
shahshreyafac62b12015-01-20 16:16:13 -0800806 response = main.Mininet1.getSwController( "s" + str( i ) )
807 print( "Response is" + str( response ) )
808 if re.search( "tcp:" + ONOS1Ip, response ):
809 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800810 else:
shahshreyafac62b12015-01-20 16:16:13 -0800811 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800812
shahshreyafac62b12015-01-20 16:16:13 -0800813 if SwitchMastership == main.TRUE:
814 main.log.report( "Controller assignmnet successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800815 else:
shahshreyafac62b12015-01-20 16:16:13 -0800816 main.log.report( "Controller assignmnet failed" )
817 utilities.assert_equals(
818 expect=main.TRUE,
819 actual=SwitchMastership,
820 onpass="MasterControllers assigned correctly" )
821 """
822 for i in range ( 1,29 ):
823 main.Mininet1.assignSwController( sw=str( i ),count=5,
824 ip1=ONOS1Ip,port1=ONOS1Port,
825 ip2=ONOS2Ip,port2=ONOS2Port,
826 ip3=ONOS3Ip,port3=ONOS3Port,
827 ip4=ONOS4Ip,port4=ONOS4Port,
828 ip5=ONOS5Ip,port5=ONOS5Port )
829 """
830 # REACTIVE FWD test
shahshreyad524a942015-04-21 09:55:16 -0700831 main.log.info( "Activate fwd app" )
832 appInstallResult = main.ONOS2.activateApp( "org.onosproject.fwd" )
833 appCheck = main.ONOS2.appToIDCheck()
834 if appCheck != main.TRUE:
835 main.log.warn( main.ONOS2.apps() )
836 main.log.warn( main.ONOS2.appIDs() )
837 time.sleep( 10 )
shahshreya4e13a062014-11-11 16:46:18 -0800838
shahshreyafac62b12015-01-20 16:16:13 -0800839 main.step( "Get list of hosts from Mininet" )
840 hostList = main.Mininet1.getHosts()
841 main.log.info( hostList )
shahshreya4e13a062014-11-11 16:46:18 -0800842
shahshreyafac62b12015-01-20 16:16:13 -0800843 main.step( "Get host list in ONOS format" )
844 hostOnosList = main.ONOS2.getHostsId( hostList )
845 main.log.info( hostOnosList )
846 # time.sleep( 5 )
847
848 main.step( "Pingall" )
849 pingResult = main.FALSE
shahshreya82ecd282015-02-05 16:48:03 -0800850 time1 = time.time()
851 pingResult = main.Mininet1.pingall()
852 time2 = time.time()
853 print "Time for pingall: %2f seconds" % ( time2 - time1 )
shahshreya4e13a062014-11-11 16:46:18 -0800854
shahshreyafac62b12015-01-20 16:16:13 -0800855 # Start onos cli again because u might have dropped out of
856 # onos prompt to the shell prompt
857 # if there was no activity
858 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
859
860 case4Result = SwitchMastership and pingResult
861 if pingResult == main.TRUE:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800862 main.log.report( "Pingall Test in reactive mode to" +
863 " discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800864 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800865 main.log.report( "Pingall Test in reactive mode to" +
866 " discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800867
shahshreyafac62b12015-01-20 16:16:13 -0800868 utilities.assert_equals(
869 expect=main.TRUE,
870 actual=case4Result,
871 onpass="Controller assignment and Pingall Test successful",
872 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800873
shahshreyadcb08e82015-02-25 10:16:42 -0800874 def CASE11( self ):
875 # NOTE: This testcase require reactive forwarding mode enabled
876 # NOTE: in the beginning and then uninstall it before adding
877 # NOTE: point intents. Again the app is installed so that
878 # NOTE: testcase 10 can be ran successively
879 import time
880 main.log.report(
881 "This testcase moves a host from one switch to another to add" +
882 "point intents between them and then perform ping" )
883 main.log.report( "__________________________________" )
884 main.log.info( "Moving host from one switch to another" )
885 main.case( "Moving host from a device and attach it to another device" )
886 main.step( "Moving host h9 from device s9 and attach it to s8" )
887 main.Mininet1.moveHost(host = 'h9', oldSw = 's9', newSw = 's8')
888
shahshreyad524a942015-04-21 09:55:16 -0700889 main.log.info( "Activate fwd app" )
890 appInstallResult = main.ONOS2.activateApp( "org.onosproject.fwd" )
891 appCheck = main.ONOS2.appToIDCheck()
892 if appCheck != main.TRUE:
893 main.log.warn( main.ONOS2.apps() )
894 main.log.warn( main.ONOS2.appIDs() )
895
shahshreyaa47ebf42015-05-20 13:29:18 -0700896 time.sleep(25) #Time delay to have all the flows ready
shahshreyadcb08e82015-02-25 10:16:42 -0800897 main.step( "Pingall" )
898 pingResult = main.FALSE
899 time1 = time.time()
shahshreyad524a942015-04-21 09:55:16 -0700900 pingResult = main.Mininet1.pingall( timeout=120,
901 shortCircuit=True,
shahshreyaa47ebf42015-05-20 13:29:18 -0700902 acceptableFailed=20 )
shahshreyadcb08e82015-02-25 10:16:42 -0800903 time2 = time.time()
904 print "Time for pingall: %2f seconds" % ( time2 - time1 )
905
906 hosts = main.ONOS2.hosts( jsonFormat = False )
907 main.log.info( hosts )
908
shahshreyad524a942015-04-21 09:55:16 -0700909 main.log.info( "deactivate reactive forwarding app" )
910 appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
911 appCheck = main.ONOS2.appToIDCheck()
912 if appCheck != main.TRUE:
913 main.log.warn( main.ONOS2.apps() )
914 main.log.warn( main.ONOS2.appIDs() )
shahshreyadcb08e82015-02-25 10:16:42 -0800915
916 main.step( "Add point intents between hosts on the same device")
917 ptpIntentResult = main.ONOS2.addPointIntent(
918 "of:0000000000003008/1",
shahshreya234a1682015-05-27 15:41:56 -0700919 "of:0000000000003008/3",
920 ethType='IPV4',
921 ethSrc='00:00:00:00:00:08',
922 ethDst='00:00:00:00:00:09' )
shahshreyadcb08e82015-02-25 10:16:42 -0800923 if ptpIntentResult == main.TRUE:
924 getIntentResult = main.ONOS2.intents()
925 main.log.info( "Point to point intent install successful" )
926 # main.log.info( getIntentResult )
927
928 ptpIntentResult = main.ONOS2.addPointIntent(
929 "of:0000000000003008/3",
shahshreya234a1682015-05-27 15:41:56 -0700930 "of:0000000000003008/1",
931 ethType='IPV4',
932 ethSrc='00:00:00:00:00:09',
933 ethDst='00:00:00:00:00:08' )
shahshreyadcb08e82015-02-25 10:16:42 -0800934 if ptpIntentResult == main.TRUE:
935 getIntentResult = main.ONOS2.intents()
936 main.log.info( "Point to point intent install successful" )
937 # main.log.info( getIntentResult )
938
939 main.case( "Ping hosts on the same devices" )
940 ping = main.Mininet1.pingHost( src = 'h8', target = 'h9' )
941
942 '''
943 main.case( "Installing reactive forwarding app" )
944 # Install onos-app-fwd app to enable reactive forwarding
945 appUninstallResult = main.ONOS2.featureInstall( "onos-app-fwd" )
946 main.log.info( "onos-app-fwd installed" )
947 '''
948
949 if ping == main.FALSE:
950 main.log.report(
951 "Point intents for hosts on same devices haven't" +
952 " been installed correctly. Cleaning up" )
953 if ping == main.TRUE:
954 main.log.report(
955 "Point intents for hosts on same devices" +
956 "installed correctly. Cleaning up" )
957
shahshreyaa47ebf42015-05-20 13:29:18 -0700958 case11Result = ping
shahshreyadcb08e82015-02-25 10:16:42 -0800959 utilities.assert_equals(
shahshreya74cca802015-02-26 12:24:01 -0800960 expect = main.TRUE,
961 actual = case11Result,
962 onpass = "Point intents for hosts on same devices" +
shahshreyadcb08e82015-02-25 10:16:42 -0800963 "Ping Test successful",
shahshreya74cca802015-02-26 12:24:01 -0800964 onfail = "Point intents for hosts on same devices" +
shahshreyadcb08e82015-02-25 10:16:42 -0800965 "Ping Test NOT successful" )
shahshreya74cca802015-02-26 12:24:01 -0800966
shahshreya74cca802015-02-26 12:24:01 -0800967 def CASE12( self ):
968 """
shahshreya1937ec12015-04-03 15:35:48 -0700969 Verify the default flows on each switch in proactive mode
shahshreya74cca802015-02-26 12:24:01 -0800970 """
971 main.log.report( "This testcase is verifying num of default" +
972 " flows on each switch" )
973 main.log.report( "__________________________________" )
974 main.case( "Verify num of default flows on each switch" )
975 main.step( "Obtaining the device id's and flowrule count on them" )
976
977 case12Result = main.TRUE
978 idList = main.ONOS2.getAllDevicesId()
979 for id in idList:
980 count = main.ONOS2.FlowAddedCount( id )
shahshreya531e2b52015-02-26 12:40:46 -0800981 main.log.info("count = " +count)
982 if int(count) != 3:
shahshreya74cca802015-02-26 12:24:01 -0800983 case12Result = main.FALSE
984 break
shahshreya74cca802015-02-26 12:24:01 -0800985 utilities.assert_equals(
986 expect=main.TRUE,
987 actual=case12Result,
988 onpass = "Expected default num of flows exist",
989 onfail = "Expected default num of flows do not exist")
shahshreyadcb08e82015-02-25 10:16:42 -0800990
shahshreyafac62b12015-01-20 16:16:13 -0800991 def CASE6( self ):
shahshreyadcb08e82015-02-25 10:16:42 -0800992 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800993 main.log.report( "This testcase is testing the addition of" +
994 " host intents and then does pingall" )
shahshreyafac62b12015-01-20 16:16:13 -0800995 main.log.report( "__________________________________" )
996 main.case( "Obtaining host id's" )
997 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800998 hosts = main.ONOS2.hosts()
shahshreyafac62b12015-01-20 16:16:13 -0800999 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -08001000
shahshreyafac62b12015-01-20 16:16:13 -08001001 main.step( "Get all devices id" )
1002 devicesIdList = main.ONOS2.getAllDevicesId()
1003 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -08001004
shahshreyafac62b12015-01-20 16:16:13 -08001005 # ONOS displays the hosts in hex format unlike mininet which does
1006 # in decimal format
1007 # So take care while adding intents
1008 """
1009 main.step( "Add host-to-host intents for mininet hosts h8 and h18 or
1010 ONOS hosts h8 and h12" )
1011 hthIntentResult = main.ONOS2.addHostIntent(
1012 "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
1013 hthIntentResult = main.ONOS2.addHostIntent(
1014 "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
1015 hthIntentResult = main.ONOS2.addHostIntent(
1016 "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
1017 hthIntentResult = main.ONOS2.addHostIntent(
1018 "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
1019 hthIntentResult = main.ONOS2.addHostIntent(
1020 "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
1021 hthIntentResult = main.ONOS2.addHostIntent(
1022 "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
1023 hthIntentResult = main.ONOS2.addHostIntent(
1024 "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
1025 hthIntentResult = main.ONOS2.addHostIntent(
1026 "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
1027 hthIntentResult = main.ONOS2.addHostIntent(
1028 "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
1029 hthIntentResult = main.ONOS2.addHostIntent(
1030 "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
1031 print "______________________________________________________"
1032 """
shahshreya234a1682015-05-27 15:41:56 -07001033 intentsId = []
shahshreyafac62b12015-01-20 16:16:13 -08001034 for i in range( 8, 18 ):
1035 main.log.info(
1036 "Adding host intent between h" + str( i ) +
1037 " and h" + str( i + 10 ) )
1038 host1 = "00:00:00:00:00:" + \
1039 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1040 host2 = "00:00:00:00:00:" + \
1041 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
1042 # NOTE: get host can return None
shahshreya1937ec12015-04-03 15:35:48 -07001043 if host1:
1044 host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
1045 if host2:
1046 host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
1047 if host1Id and host2Id:
shahshreya234a1682015-05-27 15:41:56 -07001048 intentsId.append( main.ONOS2.addHostIntent( host1Id, host2Id ) )
shahshreyafac62b12015-01-20 16:16:13 -08001049
shahshreya234a1682015-05-27 15:41:56 -07001050 checkIntentResult = main.ONOS2.checkIntentState( intentsId )
shahshreyafac62b12015-01-20 16:16:13 -08001051 time.sleep( 10 )
1052 hIntents = main.ONOS2.intents( jsonFormat=False )
1053 main.log.info( "intents:" + hIntents )
shahshreyadcb08e82015-02-25 10:16:42 -08001054 flows = main.ONOS2.flows()
1055 main.log.info( "flows:" + flows )
shahshreya4e13a062014-11-11 16:46:18 -08001056
1057 count = 1
1058 i = 8
shahshreyafac62b12015-01-20 16:16:13 -08001059 PingResult = main.TRUE
1060 # while i<10:
1061 while i < 18:
1062 main.log.info(
1063 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1064 ping = main.Mininet1.pingHost(
1065 src="h" + str( i ), target="h" + str( i + 10 ) )
1066 if ping == main.FALSE and count < 5:
1067 count += 1
1068 # i = 8
1069 PingResult = main.FALSE
1070 main.log.report( "Ping between h" +
1071 str( i ) +
1072 " and h" +
1073 str( i +
1074 10 ) +
1075 " failed. Making attempt number " +
1076 str( count ) +
1077 " in 2 seconds" )
1078 time.sleep( 2 )
1079 elif ping == main.FALSE:
1080 main.log.report( "All ping attempts between h" +
1081 str( i ) +
1082 " and h" +
1083 str( i +
1084 10 ) +
1085 "have failed" )
1086 i = 19
1087 PingResult = main.FALSE
1088 elif ping == main.TRUE:
1089 main.log.info( "Ping test between h" +
1090 str( i ) +
1091 " and h" +
1092 str( i +
1093 10 ) +
1094 "passed!" )
1095 i += 1
1096 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001097 else:
shahshreyafac62b12015-01-20 16:16:13 -08001098 main.log.info( "Unknown error" )
1099 PingResult = main.ERROR
1100 if PingResult == main.FALSE:
1101 main.log.report(
shahshreya9294c8d2015-01-21 15:54:16 -08001102 "Ping all test after Host intent addition failed.Cleaning up" )
shahshreyafac62b12015-01-20 16:16:13 -08001103 # main.cleanup()
1104 # main.exit()
1105 if PingResult == main.TRUE:
1106 main.log.report(
1107 "Ping all test after Host intent addition successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001108
shahshreya234a1682015-05-27 15:41:56 -07001109 checkIntentResult = main.ONOS2.checkIntentState( intentsId )
1110
shahshreyafac62b12015-01-20 16:16:13 -08001111 case6Result = PingResult
1112 utilities.assert_equals(
1113 expect=main.TRUE,
1114 actual=case6Result,
1115 onpass="Pingall Test after Host intents addition successful",
1116 onfail="Pingall Test after Host intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001117
shahshreyafac62b12015-01-20 16:16:13 -08001118 def CASE5( self, main ):
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001119 """
1120 Check ONOS topology matches with mininet
1121 """
shahshreya4e13a062014-11-11 16:46:18 -08001122 import json
shahshreyafac62b12015-01-20 16:16:13 -08001123 # assumes that sts is already in you PYTHONPATH
shahshreya9294c8d2015-01-21 15:54:16 -08001124 from sts.topology.teston_topology import TestONTopology
shahshreyafac62b12015-01-20 16:16:13 -08001125 # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001126 main.log.report( "This testcase is testing if all ONOS nodes" +
1127 " are in topology sync with mininet" )
shahshreyafac62b12015-01-20 16:16:13 -08001128 main.log.report( "__________________________________" )
1129 main.case( "Comparing Mininet topology with the topology of ONOS" )
1130 main.step( "Start continuous pings" )
1131 main.Mininet2.pingLong(
1132 src=main.params[ 'PING' ][ 'source1' ],
1133 target=main.params[ 'PING' ][ 'target1' ],
1134 pingTime=500 )
1135 main.Mininet2.pingLong(
1136 src=main.params[ 'PING' ][ 'source2' ],
1137 target=main.params[ 'PING' ][ 'target2' ],
1138 pingTime=500 )
1139 main.Mininet2.pingLong(
1140 src=main.params[ 'PING' ][ 'source3' ],
1141 target=main.params[ 'PING' ][ 'target3' ],
1142 pingTime=500 )
1143 main.Mininet2.pingLong(
1144 src=main.params[ 'PING' ][ 'source4' ],
1145 target=main.params[ 'PING' ][ 'target4' ],
1146 pingTime=500 )
1147 main.Mininet2.pingLong(
1148 src=main.params[ 'PING' ][ 'source5' ],
1149 target=main.params[ 'PING' ][ 'target5' ],
1150 pingTime=500 )
1151 main.Mininet2.pingLong(
1152 src=main.params[ 'PING' ][ 'source6' ],
1153 target=main.params[ 'PING' ][ 'target6' ],
1154 pingTime=500 )
1155 main.Mininet2.pingLong(
1156 src=main.params[ 'PING' ][ 'source7' ],
1157 target=main.params[ 'PING' ][ 'target7' ],
1158 pingTime=500 )
1159 main.Mininet2.pingLong(
1160 src=main.params[ 'PING' ][ 'source8' ],
1161 target=main.params[ 'PING' ][ 'target8' ],
1162 pingTime=500 )
1163 main.Mininet2.pingLong(
1164 src=main.params[ 'PING' ][ 'source9' ],
1165 target=main.params[ 'PING' ][ 'target9' ],
1166 pingTime=500 )
1167 main.Mininet2.pingLong(
1168 src=main.params[ 'PING' ][ 'source10' ],
1169 target=main.params[ 'PING' ][ 'target10' ],
1170 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -08001171
shahshreyafac62b12015-01-20 16:16:13 -08001172 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -08001173 global ctrls
1174 ctrls = []
1175 count = 1
1176 while True:
1177 temp = ()
shahshreyafac62b12015-01-20 16:16:13 -08001178 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
1179 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
1180 temp = temp + ( "ONOS" + str( count ), )
1181 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
1182 temp = temp + \
1183 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
1184 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -08001185 count = count + 1
1186 else:
1187 break
1188 global MNTopo
shahshreyafac62b12015-01-20 16:16:13 -08001189 Topo = TestONTopology(
1190 main.Mininet1,
1191 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -08001192 MNTopo = Topo
1193
shahshreyafac62b12015-01-20 16:16:13 -08001194 TopologyCheck = main.TRUE
1195 main.step( "Compare ONOS Topology to MN Topology" )
1196 devicesJson = main.ONOS2.devices()
1197 linksJson = main.ONOS2.links()
shahshreyabf739d82015-06-10 11:22:31 -07001198 portsJson = main.ONOS2.ports()
shahshreyafac62b12015-01-20 16:16:13 -08001199
1200 result1 = main.Mininet1.compareSwitches(
1201 MNTopo,
1202 json.loads( devicesJson ) )
1203 result2 = main.Mininet1.compareLinks(
1204 MNTopo,
1205 json.loads( linksJson ) )
shahshreyafac62b12015-01-20 16:16:13 -08001206
shahshreyabf739d82015-06-10 11:22:31 -07001207 result3 = main.Mininet1.comparePorts( MNTopo, json.loads( portsJson ) )
shahshreyafac62b12015-01-20 16:16:13 -08001208 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001209 result = result1 and result2
shahshreyafac62b12015-01-20 16:16:13 -08001210
shahshreya4e13a062014-11-11 16:46:18 -08001211 print "***********************"
1212 if result == main.TRUE:
shahshreyafac62b12015-01-20 16:16:13 -08001213 main.log.report( "ONOS" + " Topology matches MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001214 else:
shahshreyafac62b12015-01-20 16:16:13 -08001215 main.log.report( "ONOS" + " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001216
shahshreyafac62b12015-01-20 16:16:13 -08001217 utilities.assert_equals(
1218 expect=main.TRUE,
1219 actual=result,
1220 onpass="ONOS" +
1221 " Topology matches MN Topology",
1222 onfail="ONOS" +
1223 " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001224
shahshreyafac62b12015-01-20 16:16:13 -08001225 TopologyCheck = TopologyCheck and result
1226 utilities.assert_equals(
1227 expect=main.TRUE,
1228 actual=TopologyCheck,
1229 onpass="Topology checks passed",
1230 onfail="Topology checks failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001231
shahshreyafac62b12015-01-20 16:16:13 -08001232 def CASE7( self, main ):
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001233 """
1234 Link discovery test case. Checks if ONOS can discover a link
1235 down or up properly.
1236 """
1237
shahshreya9294c8d2015-01-21 15:54:16 -08001238 from sts.topology.teston_topology import TestONTopology
shahshreya4e13a062014-11-11 16:46:18 -08001239
shahshreyafac62b12015-01-20 16:16:13 -08001240 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -08001241
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001242 main.log.report( "This testscase is killing a link to ensure that" +
1243 " link discovery is consistent" )
shahshreyafac62b12015-01-20 16:16:13 -08001244 main.log.report( "__________________________________" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001245 main.log.report( "Killing a link to ensure that link discovery" +
1246 " is consistent" )
1247 main.case( "Killing a link to Ensure that Link Discovery" +
1248 "is Working Properly" )
shahshreyafac62b12015-01-20 16:16:13 -08001249 """
1250 main.step( "Start continuous pings" )
shahshreya4e13a062014-11-11 16:46:18 -08001251
shahshreyafac62b12015-01-20 16:16:13 -08001252 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
1253 target=main.params[ 'PING' ][ 'target1' ],
1254 pingTime=500 )
1255 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
1256 target=main.params[ 'PING' ][ 'target2' ],
1257 pingTime=500 )
1258 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
1259 target=main.params[ 'PING' ][ 'target3' ],
1260 pingTime=500 )
1261 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
1262 target=main.params[ 'PING' ][ 'target4' ],
1263 pingTime=500 )
1264 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
1265 target=main.params[ 'PING' ][ 'target5' ],
1266 pingTime=500 )
1267 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
1268 target=main.params[ 'PING' ][ 'target6' ],
1269 pingTime=500 )
1270 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
1271 target=main.params[ 'PING' ][ 'target7' ],
1272 pingTime=500 )
1273 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
1274 target=main.params[ 'PING' ][ 'target8' ],
1275 pingTime=500 )
1276 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
1277 target=main.params[ 'PING' ][ 'target9' ],
1278 pingTime=500 )
1279 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
1280 target=main.params[ 'PING' ][ 'target10' ],
1281 pingTime=500 )
1282 """
1283 main.step( "Determine the current number of switches and links" )
1284 topologyOutput = main.ONOS2.topology()
1285 topologyResult = main.ONOS1.getTopology( topologyOutput )
shahshreyaa47ebf42015-05-20 13:29:18 -07001286 activeSwitches = topologyResult[ 'devices' ]
1287 links = topologyResult[ 'links' ]
shahshreyafac62b12015-01-20 16:16:13 -08001288 print "activeSwitches = ", type( activeSwitches )
1289 print "links = ", type( links )
1290 main.log.info(
1291 "Currently there are %s switches and %s links" %
1292 ( str( activeSwitches ), str( links ) ) )
1293
1294 main.step( "Kill Link between s3 and s28" )
1295 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
1296 time.sleep( linkSleep )
1297 topologyOutput = main.ONOS2.topology()
1298 LinkDown = main.ONOS1.checkStatus(
1299 topologyOutput, activeSwitches, str(
1300 int( links ) - 2 ) )
1301 if LinkDown == main.TRUE:
1302 main.log.report( "Link Down discovered properly" )
1303 utilities.assert_equals(
1304 expect=main.TRUE,
1305 actual=LinkDown,
1306 onpass="Link Down discovered properly",
1307 onfail="Link down was not discovered in " +
1308 str( linkSleep ) +
1309 " seconds" )
1310
1311 # Check ping result here..add code for it
1312
1313 main.step( "Bring link between s3 and s28 back up" )
1314 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
1315 time.sleep( linkSleep )
1316 topologyOutput = main.ONOS2.topology()
1317 LinkUp = main.ONOS1.checkStatus(
1318 topologyOutput,
1319 activeSwitches,
1320 str( links ) )
1321 if LinkUp == main.TRUE:
1322 main.log.report( "Link up discovered properly" )
1323 utilities.assert_equals(
1324 expect=main.TRUE,
1325 actual=LinkUp,
1326 onpass="Link up discovered properly",
1327 onfail="Link up was not discovered in " +
1328 str( linkSleep ) +
1329 " seconds" )
1330
1331 # NOTE Check ping result here..add code for it
1332
1333 main.step( "Compare ONOS Topology to MN Topology" )
1334 Topo = TestONTopology(
1335 main.Mininet1,
1336 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -08001337 MNTopo = Topo
shahshreyafac62b12015-01-20 16:16:13 -08001338 TopologyCheck = main.TRUE
1339
1340 devicesJson = main.ONOS2.devices()
1341 linksJson = main.ONOS2.links()
1342 portsJson = main.ONOS2.ports()
1343
1344 result1 = main.Mininet1.compareSwitches(
1345 MNTopo,
1346 json.loads( devicesJson ) )
1347 result2 = main.Mininet1.compareLinks(
1348 MNTopo,
1349 json.loads( linksJson ) )
shahshreyabf739d82015-06-10 11:22:31 -07001350 result3 = main.Mininet1.comparePorts( MNTopo, json.loads( portsJson ) )
shahshreyafac62b12015-01-20 16:16:13 -08001351
1352 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001353 result = result1 and result2
1354 print "***********************"
shahshreyafac62b12015-01-20 16:16:13 -08001355
shahshreya4e13a062014-11-11 16:46:18 -08001356 if result == main.TRUE:
shahshreyafac62b12015-01-20 16:16:13 -08001357 main.log.report( "ONOS" + " Topology matches MN Topology" )
1358 utilities.assert_equals(
1359 expect=main.TRUE,
1360 actual=result,
1361 onpass="ONOS" +
1362 " Topology matches MN Topology",
1363 onfail="ONOS" +
1364 " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001365
shahshreyafac62b12015-01-20 16:16:13 -08001366 TopologyCheck = TopologyCheck and result
1367 utilities.assert_equals(
1368 expect=main.TRUE,
1369 actual=TopologyCheck,
1370 onpass="Topology checks passed",
1371 onfail="Topology checks failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001372
shahshreyafac62b12015-01-20 16:16:13 -08001373 result = LinkDown and LinkUp and TopologyCheck
1374 utilities.assert_equals( expect=main.TRUE, actual=result,
shahshreya9294c8d2015-01-21 15:54:16 -08001375 onpass="Link failure is discovered correctly",
1376 onfail="Link Discovery failed" )
shahshreyafac62b12015-01-20 16:16:13 -08001377
1378 def CASE8( self ):
1379 """
shahshreya82ecd282015-02-05 16:48:03 -08001380 Intent removal
shahshreyafac62b12015-01-20 16:16:13 -08001381 """
shahshreya82ecd282015-02-05 16:48:03 -08001382 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001383 main.log.report( "This testcase removes any previously added intents" +
shahshreya82ecd282015-02-05 16:48:03 -08001384 " before adding any new set of intents" )
shahshreyafac62b12015-01-20 16:16:13 -08001385 main.log.report( "__________________________________" )
shahshreya82ecd282015-02-05 16:48:03 -08001386 main.log.info( "intent removal" )
1387 main.case( "Removing installed intents" )
shahshreyafac62b12015-01-20 16:16:13 -08001388 main.step( "Obtain the intent id's" )
shahshreya234a1682015-05-27 15:41:56 -07001389 currentIntents = main.ONOS2.intents( jsonFormat=False )
1390 main.log.info( "intent_result = " + currentIntents )
1391 intentLinewise = currentIntents.split( "\n" )
shahshreyafac62b12015-01-20 16:16:13 -08001392
shahshreyadcb08e82015-02-25 10:16:42 -08001393 intentList = [line for line in intentLinewise \
1394 if line.startswith( "id=")]
1395 intentids = [line.split( "," )[ 0 ].split( "=" )[ 1 ] for line in \
1396 intentList]
shahshreya4e13a062014-11-11 16:46:18 -08001397 for id in intentids:
1398 print "id = ", id
shahshreyafac62b12015-01-20 16:16:13 -08001399
1400 main.step(
1401 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -08001402 for id in intentids:
shahshreyaa47ebf42015-05-20 13:29:18 -07001403 main.ONOS2.removeIntent( intentId=id ,purge=True)
shahshreyae6c7cf42014-11-26 16:39:01 -08001404
shahshreya234a1682015-05-27 15:41:56 -07001405 remainingIntents = main.ONOS2.intents( jsonFormat=False )
1406 main.log.info( "intent_result = " + remainingIntents )
1407 if remainingIntents:
1408 main.log.info( "There are still remaining intents " )
1409 intentResult = main.FALSE
1410 else:
1411 intentResult = main.TRUE
1412
1413 intentList = [line for line in remainingIntents.split( "\n" ) \
shahshreyadcb08e82015-02-25 10:16:42 -08001414 if line.startswith( "id=")]
1415 intentState = [line.split( "," )[ 1 ].split( "=" )[ 1 ] for line in \
1416 intentList]
1417 for state in intentState:
1418 print state
1419
shahshreya234a1682015-05-27 15:41:56 -07001420 case8Result = main.TRUE
shahshreyadcb08e82015-02-25 10:16:42 -08001421 for state in intentState:
1422 if state != 'WITHDRAWN':
1423 case8Result = main.FALSE
1424 break
shahshreyafac62b12015-01-20 16:16:13 -08001425
1426 PingResult = main.TRUE
shahshreya234a1682015-05-27 15:41:56 -07001427 """
shahshreyafac62b12015-01-20 16:16:13 -08001428 if case8Result == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001429 i = 8
shahshreyafac62b12015-01-20 16:16:13 -08001430 while i < 18:
1431 main.log.info(
1432 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1433 ping = main.Mininet1.pingHost(
1434 src="h" + str( i ), target="h" + str( i + 10 ) )
1435 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001436 i = 19
shahshreyafac62b12015-01-20 16:16:13 -08001437 PingResult = PingResult and main.TRUE
1438 elif ping == main.FALSE:
1439 i += 1
1440 PingResult = PingResult and main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -08001441 else:
shahshreyafac62b12015-01-20 16:16:13 -08001442 main.log.info( "Unknown error" )
1443 PingResult = main.ERROR
shahshreya234a1682015-05-27 15:41:56 -07001444
shahshreyafac62b12015-01-20 16:16:13 -08001445 # Note: If the ping result failed, that means the intents have been
1446 # withdrawn correctly.
1447 if PingResult == main.TRUE:
shahshreya82ecd282015-02-05 16:48:03 -08001448 main.log.report( "Installed intents have not been withdrawn correctly" )
shahshreyafac62b12015-01-20 16:16:13 -08001449 # main.cleanup()
1450 # main.exit()
1451 if PingResult == main.FALSE:
shahshreya82ecd282015-02-05 16:48:03 -08001452 main.log.report( "Installed intents have been withdrawn correctly" )
shahshreya234a1682015-05-27 15:41:56 -07001453 """
shahshreya4e13a062014-11-11 16:46:18 -08001454
shahshreya234a1682015-05-27 15:41:56 -07001455 if case8Result:
shahshreyafac62b12015-01-20 16:16:13 -08001456 main.log.report( "Intent removal successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001457 else:
shahshreyafac62b12015-01-20 16:16:13 -08001458 main.log.report( "Intent removal failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001459
shahshreya234a1682015-05-27 15:41:56 -07001460 utilities.assert_equals( expect=main.TRUE, actual=case8Result,
shahshreya9294c8d2015-01-21 15:54:16 -08001461 onpass="Intent removal test passed",
1462 onfail="Intent removal test failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001463
shahshreyafac62b12015-01-20 16:16:13 -08001464 def CASE9( self ):
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001465 """
1466 Testing Point intents
1467 """
shahshreyafac62b12015-01-20 16:16:13 -08001468 main.log.report(
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001469 "This test case adds point intents and then does pingall" )
shahshreyafac62b12015-01-20 16:16:13 -08001470 main.log.report( "__________________________________" )
1471 main.log.info( "Adding point intents" )
1472 main.case(
shahshreya71162c62015-01-23 15:31:16 -08001473 "Adding bidirectional point for mn hosts" +
1474 "( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22, " +
1475 "h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001476 macsDict = {}
1477 for i in range( 1,29 ):
1478 macsDict[ 'h' + str( i ) ]= main.Mininet1.getMacAddress( host='h'+ str( i ) )
1479 print macsDict
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001480 main.step( "Add point intents for mn hosts h8 and h18 or" +
1481 "ONOS hosts h8 and h12" )
shahshreya3dc3ce62015-01-22 13:31:59 -08001482 # main.step(var1)
shahshreyafac62b12015-01-20 16:16:13 -08001483 ptpIntentResult = main.ONOS2.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -07001484 ingressDevice="of:0000000000003008/1",
1485 egressDevice="of:0000000000006018/1",
1486 ethType='IPV4',
1487 ethSrc=macsDict.get( 'h8' ))
shahshreyafac62b12015-01-20 16:16:13 -08001488 if ptpIntentResult == main.TRUE:
1489 getIntentResult = main.ONOS2.intents()
1490 main.log.info( "Point to point intent install successful" )
1491 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001492
shahshreyafac62b12015-01-20 16:16:13 -08001493 ptpIntentResult = main.ONOS2.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -07001494 ingressDevice="of:0000000000006018/1",
1495 egressDevice="of:0000000000003008/1",
1496 ethType='IPV4',
1497 ethSrc=macsDict.get( 'h18' ))
shahshreyafac62b12015-01-20 16:16:13 -08001498 if ptpIntentResult == main.TRUE:
1499 getIntentResult = main.ONOS2.intents()
1500 main.log.info( "Point to point intent install successful" )
1501 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001502
shahshreya9294c8d2015-01-21 15:54:16 -08001503 var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
1504 main.step(var2)
shahshreyafac62b12015-01-20 16:16:13 -08001505 ptpIntentResult = main.ONOS2.addPointIntent(
1506 "of:0000000000003009/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001507 "of:0000000000006019/1",
1508 ethType='IPV4',
1509 ethSrc=macsDict.get( 'h9' ))
shahshreyafac62b12015-01-20 16:16:13 -08001510 if ptpIntentResult == main.TRUE:
1511 getIntentResult = main.ONOS2.intents()
1512 main.log.info( "Point to point intent install successful" )
1513 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001514
shahshreyafac62b12015-01-20 16:16:13 -08001515 ptpIntentResult = main.ONOS2.addPointIntent(
1516 "of:0000000000006019/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001517 "of:0000000000003009/1",
1518 ethType='IPV4',
1519 ethSrc=macsDict.get( 'h19' ))
shahshreyafac62b12015-01-20 16:16:13 -08001520 if ptpIntentResult == main.TRUE:
1521 getIntentResult = main.ONOS2.intents()
1522 main.log.info( "Point to point intent install successful" )
1523 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001524
shahshreya9294c8d2015-01-21 15:54:16 -08001525 var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
1526 main.step(var3)
shahshreyafac62b12015-01-20 16:16:13 -08001527 ptpIntentResult = main.ONOS2.addPointIntent(
1528 "of:0000000000003010/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001529 "of:0000000000006020/1",
1530 ethType='IPV4',
1531 ethSrc=macsDict.get( 'h10' ))
1532
shahshreyafac62b12015-01-20 16:16:13 -08001533 if ptpIntentResult == main.TRUE:
1534 getIntentResult = main.ONOS2.intents()
1535 main.log.info( "Point to point intent install successful" )
1536 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001537
shahshreyafac62b12015-01-20 16:16:13 -08001538 ptpIntentResult = main.ONOS2.addPointIntent(
1539 "of:0000000000006020/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001540 "of:0000000000003010/1",
1541 ethType='IPV4',
1542 ethSrc=macsDict.get( 'h20' ))
1543
shahshreyafac62b12015-01-20 16:16:13 -08001544 if ptpIntentResult == main.TRUE:
1545 getIntentResult = main.ONOS2.intents()
1546 main.log.info( "Point to point intent install successful" )
1547 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001548
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001549 var4 = "Add point intents for mininet hosts h11 and h21 or" +\
1550 " ONOS hosts hB and h15"
shahshreya9294c8d2015-01-21 15:54:16 -08001551 main.case(var4)
shahshreyafac62b12015-01-20 16:16:13 -08001552 ptpIntentResult = main.ONOS2.addPointIntent(
1553 "of:0000000000003011/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001554 "of:0000000000006021/1",
1555 ethType='IPV4',
1556 ethSrc=macsDict.get( 'h11' ))
1557
shahshreyafac62b12015-01-20 16:16:13 -08001558 if ptpIntentResult == main.TRUE:
1559 getIntentResult = main.ONOS2.intents()
1560 main.log.info( "Point to point intent install successful" )
1561 # main.log.info( getIntentResult )
1562
1563 ptpIntentResult = main.ONOS2.addPointIntent(
1564 "of:0000000000006021/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001565 "of:0000000000003011/1",
1566 ethType='IPV4',
1567 ethSrc=macsDict.get( 'h21' ))
1568
shahshreyafac62b12015-01-20 16:16:13 -08001569 if ptpIntentResult == main.TRUE:
1570 getIntentResult = main.ONOS2.intents()
1571 main.log.info( "Point to point intent install successful" )
1572 # main.log.info( getIntentResult )
1573
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001574 var5 = "Add point intents for mininet hosts h12 and h22 " +\
1575 "ONOS hosts hC and h16"
shahshreya9294c8d2015-01-21 15:54:16 -08001576 main.case(var5)
shahshreyafac62b12015-01-20 16:16:13 -08001577 ptpIntentResult = main.ONOS2.addPointIntent(
1578 "of:0000000000003012/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001579 "of:0000000000006022/1",
1580 ethType='IPV4',
1581 ethSrc=macsDict.get( 'h12' ))
1582
shahshreyafac62b12015-01-20 16:16:13 -08001583 if ptpIntentResult == main.TRUE:
1584 getIntentResult = main.ONOS2.intents()
1585 main.log.info( "Point to point intent install successful" )
1586 # main.log.info( getIntentResult )
1587
1588 ptpIntentResult = main.ONOS2.addPointIntent(
1589 "of:0000000000006022/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001590 "of:0000000000003012/1",
1591 ethType='IPV4',
1592 ethSrc=macsDict.get( 'h22' ))
1593
shahshreyafac62b12015-01-20 16:16:13 -08001594 if ptpIntentResult == main.TRUE:
1595 getIntentResult = main.ONOS2.intents()
1596 main.log.info( "Point to point intent install successful" )
1597 # main.log.info( getIntentResult )
1598
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001599 var6 = "Add point intents for mininet hosts h13 and h23 or" +\
1600 " ONOS hosts hD and h17"
shahshreya9294c8d2015-01-21 15:54:16 -08001601 main.case(var6)
shahshreyafac62b12015-01-20 16:16:13 -08001602 ptpIntentResult = main.ONOS2.addPointIntent(
1603 "of:0000000000003013/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001604 "of:0000000000006023/1",
1605 ethType='IPV4',
1606 ethSrc=macsDict.get( 'h13' ))
1607
shahshreyafac62b12015-01-20 16:16:13 -08001608 if ptpIntentResult == main.TRUE:
1609 getIntentResult = main.ONOS2.intents()
1610 main.log.info( "Point to point intent install successful" )
1611 # main.log.info( getIntentResult )
1612
1613 ptpIntentResult = main.ONOS2.addPointIntent(
1614 "of:0000000000006023/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001615 "of:0000000000003013/1",
1616 ethType='IPV4',
1617 ethSrc=macsDict.get( 'h23' ))
1618
shahshreyafac62b12015-01-20 16:16:13 -08001619 if ptpIntentResult == main.TRUE:
1620 getIntentResult = main.ONOS2.intents()
1621 main.log.info( "Point to point intent install successful" )
1622 # main.log.info( getIntentResult )
1623
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001624 var7 = "Add point intents for mininet hosts h14 and h24 or" +\
1625 " ONOS hosts hE and h18"
shahshreya9294c8d2015-01-21 15:54:16 -08001626 main.case(var7)
shahshreyafac62b12015-01-20 16:16:13 -08001627 ptpIntentResult = main.ONOS2.addPointIntent(
1628 "of:0000000000003014/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001629 "of:0000000000006024/1",
1630 ethType='IPV4',
1631 ethSrc=macsDict.get( 'h14' ))
1632
shahshreyafac62b12015-01-20 16:16:13 -08001633 if ptpIntentResult == main.TRUE:
1634 getIntentResult = main.ONOS2.intents()
1635 main.log.info( "Point to point intent install successful" )
1636 # main.log.info( getIntentResult )
1637
1638 ptpIntentResult = main.ONOS2.addPointIntent(
1639 "of:0000000000006024/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001640 "of:0000000000003014/1",
1641 ethType='IPV4',
1642 ethSrc=macsDict.get( 'h24' ))
1643
shahshreyafac62b12015-01-20 16:16:13 -08001644 if ptpIntentResult == main.TRUE:
1645 getIntentResult = main.ONOS2.intents()
1646 main.log.info( "Point to point intent install successful" )
1647 # main.log.info( getIntentResult )
1648
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001649 var8 = "Add point intents for mininet hosts h15 and h25 or" +\
1650 " ONOS hosts hF and h19"
shahshreya9294c8d2015-01-21 15:54:16 -08001651 main.case(var8)
shahshreyafac62b12015-01-20 16:16:13 -08001652 ptpIntentResult = main.ONOS2.addPointIntent(
1653 "of:0000000000003015/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001654 "of:0000000000006025/1",
1655 ethType='IPV4',
1656 ethSrc=macsDict.get( 'h15' ))
1657
shahshreyafac62b12015-01-20 16:16:13 -08001658 if ptpIntentResult == main.TRUE:
1659 getIntentResult = main.ONOS2.intents()
1660 main.log.info( "Point to point intent install successful" )
1661 # main.log.info( getIntentResult )
1662
1663 ptpIntentResult = main.ONOS2.addPointIntent(
1664 "of:0000000000006025/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001665 "of:0000000000003015/1",
1666 ethType='IPV4',
1667 ethSrc=macsDict.get( 'h25' ))
1668
shahshreyafac62b12015-01-20 16:16:13 -08001669 if ptpIntentResult == main.TRUE:
1670 getIntentResult = main.ONOS2.intents()
1671 main.log.info( "Point to point intent install successful" )
1672 # main.log.info( getIntentResult )
1673
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001674 var9 = "Add intents for mininet hosts h16 and h26 or" +\
1675 " ONOS hosts h10 and h1A"
shahshreya9294c8d2015-01-21 15:54:16 -08001676 main.case(var9)
shahshreyafac62b12015-01-20 16:16:13 -08001677 ptpIntentResult = main.ONOS2.addPointIntent(
1678 "of:0000000000003016/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001679 "of:0000000000006026/1",
1680 ethType='IPV4',
1681 ethSrc=macsDict.get( 'h16' ))
1682
shahshreyafac62b12015-01-20 16:16:13 -08001683 if ptpIntentResult == main.TRUE:
1684 getIntentResult = main.ONOS2.intents()
1685 main.log.info( "Point to point intent install successful" )
1686 # main.log.info( getIntentResult )
1687
1688 ptpIntentResult = main.ONOS2.addPointIntent(
1689 "of:0000000000006026/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001690 "of:0000000000003016/1",
1691 ethType='IPV4',
1692 ethSrc=macsDict.get( 'h26' ))
1693
shahshreyafac62b12015-01-20 16:16:13 -08001694 if ptpIntentResult == main.TRUE:
1695 getIntentResult = main.ONOS2.intents()
1696 main.log.info( "Point to point intent install successful" )
1697 # main.log.info( getIntentResult )
1698
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001699 var10 = "Add point intents for mininet hosts h17 and h27 or" +\
1700 " ONOS hosts h11 and h1B"
shahshreya9294c8d2015-01-21 15:54:16 -08001701 main.case(var10)
shahshreyafac62b12015-01-20 16:16:13 -08001702 ptpIntentResult = main.ONOS2.addPointIntent(
1703 "of:0000000000003017/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001704 "of:0000000000006027/1",
1705 ethType='IPV4',
1706 ethSrc=macsDict.get( 'h17' ))
1707
shahshreyafac62b12015-01-20 16:16:13 -08001708 if ptpIntentResult == main.TRUE:
1709 getIntentResult = main.ONOS2.intents()
1710 main.log.info( "Point to point intent install successful" )
shahshreyadcb08e82015-02-25 10:16:42 -08001711 #main.log.info( getIntentResult )
shahshreyafac62b12015-01-20 16:16:13 -08001712
1713 ptpIntentResult = main.ONOS2.addPointIntent(
1714 "of:0000000000006027/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001715 "of:0000000000003017/1",
1716 ethType='IPV4',
1717 ethSrc=macsDict.get( 'h27' ))
1718
shahshreyafac62b12015-01-20 16:16:13 -08001719 if ptpIntentResult == main.TRUE:
1720 getIntentResult = main.ONOS2.intents()
1721 main.log.info( "Point to point intent install successful" )
shahshreyadcb08e82015-02-25 10:16:42 -08001722 #main.log.info( getIntentResult )
shahshreyafac62b12015-01-20 16:16:13 -08001723
1724 print(
1725 "___________________________________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001726
1727 flowHandle = main.ONOS2.flows()
shahshreya82ecd282015-02-05 16:48:03 -08001728 #main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001729
1730 count = 1
1731 i = 8
shahshreyafac62b12015-01-20 16:16:13 -08001732 PingResult = main.TRUE
1733 while i < 18:
1734 main.log.info(
1735 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1736 ping = main.Mininet1.pingHost(
1737 src="h" + str( i ), target="h" + str( i + 10 ) )
1738 if ping == main.FALSE and count < 5:
1739 count += 1
1740 # i = 8
1741 PingResult = main.FALSE
1742 main.log.report( "Ping between h" +
1743 str( i ) +
1744 " and h" +
1745 str( i +
1746 10 ) +
1747 " failed. Making attempt number " +
1748 str( count ) +
1749 " in 2 seconds" )
1750 time.sleep( 2 )
1751 elif ping == main.FALSE:
1752 main.log.report( "All ping attempts between h" +
1753 str( i ) +
1754 " and h" +
1755 str( i +
1756 10 ) +
1757 "have failed" )
1758 i = 19
1759 PingResult = main.FALSE
1760 elif ping == main.TRUE:
1761 main.log.info( "Ping test between h" +
1762 str( i ) +
1763 " and h" +
1764 str( i +
1765 10 ) +
1766 "passed!" )
1767 i += 1
1768 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001769 else:
shahshreyafac62b12015-01-20 16:16:13 -08001770 main.log.info( "Unknown error" )
1771 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001772
shahshreyafac62b12015-01-20 16:16:13 -08001773 if PingResult == main.FALSE:
1774 main.log.report(
1775 "Point intents have not ben installed correctly. Cleaning up" )
1776 # main.cleanup()
1777 # main.exit()
1778 if PingResult == main.TRUE:
1779 main.log.report( "Point Intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001780
shahshreyafac62b12015-01-20 16:16:13 -08001781 case9Result = PingResult
1782 utilities.assert_equals(
1783 expect=main.TRUE,
1784 actual=case9Result,
1785 onpass="Point intents addition and Pingall Test successful",
1786 onfail="Point intents addition and Pingall Test NOT successful" )