blob: adbdb241a0e754b34fa1b78cc1b758845301df9d [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' ]
shahshreya842d8b92015-06-10 14:13:33 -070034 gitPull = main.params[ 'GIT' ][ 'pull' ]
shahshreyae6c7cf42014-11-26 16:39:01 -080035
shahshreyafac62b12015-01-20 16:16:13 -080036 main.case( "Setting up test environment" )
37 main.log.report(
38 "This testcase is testing setting up test environment" )
39 main.log.report( "__________________________________" )
shahshreyae6c7cf42014-11-26 16:39:01 -080040
shahshreyafac62b12015-01-20 16:16:13 -080041 main.step( "Applying cell variable to environment" )
42 cellResult = main.ONOSbench.setCell( cellName )
43 verifyResult = main.ONOSbench.verifyCell()
44
shahshreyab512cd02015-01-27 17:01:47 -080045 main.step( "Git checkout and get version" )
shahshreyaa47ebf42015-05-20 13:29:18 -070046 main.ONOSbench.gitCheckout( "master" )
shahshreya842d8b92015-06-10 14:13:33 -070047 if gitPull == 'True':
48 gitPullResult = main.ONOSbench.gitPull()
49 if gitPullResult == 1:
50 main.step( "Using mvn clean & install" )
51 main.ONOSbench.cleanInstall()
52 main.step( "Creating ONOS package" )
53 packageResult = main.ONOSbench.onosPackage()
54 elif gitPullResult == 0:
55 main.log.report(
56 "Git Pull Failed, look into logs for detailed reason" )
57 main.cleanup()
58 main.exit()
59 main.log.info( "git_pull_result = " + str( gitPullResult ))
60 else:
61 main.log.info( "Skipping git pull" )
shahshreyafac62b12015-01-20 16:16:13 -080062 main.ONOSbench.getVersion( report=True )
shahshreya234a1682015-05-27 15:41:56 -070063 packageResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -080064
shahshreyaa47ebf42015-05-20 13:29:18 -070065 main.step( "Uninstalling ONOS package" )
shahshreya234a1682015-05-27 15:41:56 -070066 onosInstallResult = main.ONOSbench.onosUninstall( ONOS1Ip )
shahshreyaa47ebf42015-05-20 13:29:18 -070067 if onosInstallResult == main.TRUE:
68 main.log.report( "Uninstalling ONOS package successful" )
69 else:
70 main.log.report( "Uninstalling ONOS package failed" )
71
shahshreyabf739d82015-06-10 11:22:31 -070072 time.sleep( 20 )
shahshreyafac62b12015-01-20 16:16:13 -080073 main.step( "Installing ONOS package" )
shahshreya234a1682015-05-27 15:41:56 -070074 onosInstallResult = main.ONOSbench.onosInstall( ONOS1Ip )
75 print onosInstallResult
shahshreyafac62b12015-01-20 16:16:13 -080076 if onosInstallResult == main.TRUE:
77 main.log.report( "Installing ONOS package successful" )
shahshreya4e13a062014-11-11 16:46:18 -080078 else:
shahshreyafac62b12015-01-20 16:16:13 -080079 main.log.report( "Installing ONOS package failed" )
shahshreya4e13a062014-11-11 16:46:18 -080080
shahshreyabf739d82015-06-10 11:22:31 -070081 time.sleep( 20 )
shahshreyafac62b12015-01-20 16:16:13 -080082 onos1Isup = main.ONOSbench.isup()
83 if onos1Isup == main.TRUE:
84 main.log.report( "ONOS instance is up and ready" )
shahshreya4e13a062014-11-11 16:46:18 -080085 else:
shahshreyafac62b12015-01-20 16:16:13 -080086 main.log.report( "ONOS instance may not be up" )
shahshreya4e13a062014-11-11 16:46:18 -080087
shahshreya234a1682015-05-27 15:41:56 -070088 startResult = main.TRUE
89 #main.step( "Starting ONOS service" )
90 #startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -080091
shahshreya234a1682015-05-27 15:41:56 -070092 main.ONOS2.startOnosCli( ONOS1Ip )
shahshreya82ecd282015-02-05 16:48:03 -080093 main.step( "Starting Mininet CLI..." )
94
95 # Starting the mininet using the old way
96 main.step( "Starting Mininet ..." )
97 netIsUp = main.Mininet1.startNet()
98 if netIsUp:
99 main.log.info("Mininet CLI is up")
100
shahshreyafac62b12015-01-20 16:16:13 -0800101 case1Result = ( packageResult and
102 cellResult and verifyResult
103 and onosInstallResult and
104 onos1Isup and startResult )
105 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
shahshreya9294c8d2015-01-21 15:54:16 -0800106 onpass="Test startup successful",
107 onfail="Test startup NOT successful" )
shahshreyafac62b12015-01-20 16:16:13 -0800108
109 def CASE2( self, main ):
110 """
shahshreya0e81ed92014-12-08 16:57:17 -0800111 Switch Down
shahshreyafac62b12015-01-20 16:16:13 -0800112 """
113 # NOTE: You should probably run a topology check after this
114 import time
shahshreya0e81ed92014-12-08 16:57:17 -0800115
shahshreyafac62b12015-01-20 16:16:13 -0800116 main.case( "Switch down discovery" )
117 main.log.report( "This testcase is testing a switch down discovery" )
118 main.log.report( "__________________________________" )
119
120 switchSleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
shahshreya0e81ed92014-12-08 16:57:17 -0800121
122 description = "Killing a switch to ensure it is discovered correctly"
shahshreyafac62b12015-01-20 16:16:13 -0800123 main.log.report( description )
124 main.case( description )
shahshreya0e81ed92014-12-08 16:57:17 -0800125
shahshreyafac62b12015-01-20 16:16:13 -0800126 # TODO: Make this switch parameterizable
127 main.step( "Kill s28 " )
128 main.log.report( "Deleting s28" )
129 # FIXME: use new dynamic topo functions
130 main.Mininet1.delSwitch( "s28" )
131 main.log.info(
132 "Waiting " +
133 str( switchSleep ) +
134 " seconds for switch down to be discovered" )
135 time.sleep( switchSleep )
136 # Peek at the deleted switch
137 device = main.ONOS2.getDevice( dpid="0028" )
shahshreya0e81ed92014-12-08 16:57:17 -0800138 print "device = ", device
shahshreyafac62b12015-01-20 16:16:13 -0800139 if device[ u'available' ] == 'False':
140 case2Result = main.FALSE
shahshreya0e81ed92014-12-08 16:57:17 -0800141 else:
shahshreyafac62b12015-01-20 16:16:13 -0800142 case2Result = main.TRUE
143 utilities.assert_equals( expect=main.TRUE, actual=case2Result,
shahshreya9294c8d2015-01-21 15:54:16 -0800144 onpass="Switch down discovery successful",
145 onfail="Switch down discovery failed" )
shahshreya0e81ed92014-12-08 16:57:17 -0800146
shahshreyadcb08e82015-02-25 10:16:42 -0800147 def CASE101( self, main ):
shahshreyafac62b12015-01-20 16:16:13 -0800148 """
shahshreya4e13a062014-11-11 16:46:18 -0800149 Cleanup sequence:
shahshreyafac62b12015-01-20 16:16:13 -0800150 onos-service <nodeIp> stop
shahshreya4e13a062014-11-11 16:46:18 -0800151 onos-uninstall
152
153 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800154
shahshreyafac62b12015-01-20 16:16:13 -0800155 """
156 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800157
shahshreyafac62b12015-01-20 16:16:13 -0800158 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800159
shahshreyafac62b12015-01-20 16:16:13 -0800160 main.step( "Testing ONOS kill function" )
161 killResult = main.ONOSbench.onosKill( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800162
shahshreyafac62b12015-01-20 16:16:13 -0800163 main.step( "Stopping ONOS service" )
164 stopResult = main.ONOSbench.onosStop( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800165
shahshreyafac62b12015-01-20 16:16:13 -0800166 main.step( "Uninstalling ONOS service" )
167 uninstallResult = main.ONOSbench.onosUninstall()
shahshreya4e13a062014-11-11 16:46:18 -0800168
shahshreyafac62b12015-01-20 16:16:13 -0800169 case11Result = killResult and stopResult and uninstallResult
170 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
shahshreya9294c8d2015-01-21 15:54:16 -0800171 onpass="Cleanup successful",
172 onfail="Cleanup failed" )
shahshreyafac62b12015-01-20 16:16:13 -0800173
174 def CASE3( self, main ):
175 """
shahshreya4e13a062014-11-11 16:46:18 -0800176 Test 'onos' command and its functionality in driver
shahshreyafac62b12015-01-20 16:16:13 -0800177 """
178 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800179
shahshreyafac62b12015-01-20 16:16:13 -0800180 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800181
shahshreyafac62b12015-01-20 16:16:13 -0800182 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800183 cmdstr1 = "system:name"
shahshreyafac62b12015-01-20 16:16:13 -0800184 cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
185 main.log.info( "onos command returned: " + cmdResult1 )
shahshreya4e13a062014-11-11 16:46:18 -0800186
shahshreyafac62b12015-01-20 16:16:13 -0800187 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800188 cmdstr2 = "onos:topology"
shahshreyafac62b12015-01-20 16:16:13 -0800189 cmdResult2 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
190 main.log.info( "onos command returned: " + cmdResult2 )
shahshreya4e13a062014-11-11 16:46:18 -0800191
shahshreyafac62b12015-01-20 16:16:13 -0800192 def CASE20( self ):
193 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800194 Exit from mininet cli
195 reinstall ONOS
shahshreyafac62b12015-01-20 16:16:13 -0800196 """
shahshreya234a1682015-05-27 15:41:56 -0700197 import time
shahshreyafac62b12015-01-20 16:16:13 -0800198 cellName = main.params[ 'ENV' ][ 'cellName' ]
199 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800200
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800201 main.log.report( "This testcase exits the mininet cli and reinstalls" +
202 "ONOS to switch over to Packet Optical topology" )
shahshreyafac62b12015-01-20 16:16:13 -0800203 main.log.report( "_____________________________________________" )
204 main.case( "Disconnecting mininet and restarting ONOS" )
shahshreya234a1682015-05-27 15:41:56 -0700205
shahshreyafac62b12015-01-20 16:16:13 -0800206 main.step( "Disconnecting mininet and restarting ONOS" )
shahshreya234a1682015-05-27 15:41:56 -0700207 step1Result = main.TRUE
shahshreyafac62b12015-01-20 16:16:13 -0800208 mininetDisconnect = main.Mininet1.disconnect()
shahshreya3140b1a2015-04-28 14:22:15 -0700209 print "mininetDisconnect = ", mininetDisconnect
shahshreya234a1682015-05-27 15:41:56 -0700210 step1Result = mininetDisconnect
211 utilities.assert_equals(
212 expect=main.TRUE,
213 actual=step1Result,
214 onpass="Mininet disconnect successfully",
215 onfail="Mininet failed to disconnect")
216 """
217 main.step( "Removing raft logs before a clean installation of ONOS" )
218 step2Result = main.TRUE
219 removeRaftLogsResult = main.ONOSbench.onosRemoveRaftLogs()
220 step2Result = removeRaftLogsResult
221 utilities.assert_equals(
222 expect=main.TRUE,
223 actual=step2Result,
224 onpass="Raft logs removed successfully",
225 onfail="Failed to remove raft logs")
226 """
shahshreyafac62b12015-01-20 16:16:13 -0800227 main.step( "Applying cell variable to environment" )
shahshreya234a1682015-05-27 15:41:56 -0700228 step3Result = main.TRUE
229 setCellResult = main.ONOSbench.setCell( cellName )
230 verifyCellResult = main.ONOSbench.verifyCell()
231 step3Result = setCellResult and verifyCellResult
232 utilities.assert_equals(
233 expect=main.TRUE,
234 actual=step3Result,
235 onpass="Cell applied successfully",
236 onfail="Failed to apply cell")
shahshreyafac62b12015-01-20 16:16:13 -0800237
shahshreya234a1682015-05-27 15:41:56 -0700238 main.step( "Uninstalling ONOS package" )
239 step4Result = main.TRUE
240 ONOSip1 = main.params[ 'CTRL' ][ 'ip1' ]
241 onosUninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOSip1)
242 step4Result = onosUninstallResult
243 utilities.assert_equals(
244 expect=main.TRUE,
245 actual=step4Result,
246 onpass="Successfully uninstalled ONOS",
247 onfail="Failed to uninstall ONOS")
248
249 time.sleep( 5 )
250 main.step( "Installing ONOS package" )
251 step5Result = main.TRUE
252 onosInstallResult = main.ONOSbench.onosInstall( node = ONOSip1 )
253 step5Result = onosInstallResult
254 utilities.assert_equals(
255 expect=main.TRUE,
256 actual=step5Result,
257 onpass="Successfully installed ONOS",
258 onfail="Failed to install ONOS")
shahshreyae6c7cf42014-11-26 16:39:01 -0800259
shahshreyafac62b12015-01-20 16:16:13 -0800260 onos1Isup = main.ONOSbench.isup()
261 if onos1Isup == main.TRUE:
262 main.log.report( "ONOS instance is up and ready" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800263 else:
shahshreyafac62b12015-01-20 16:16:13 -0800264 main.log.report( "ONOS instance may not be up" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800265
shahshreyafac62b12015-01-20 16:16:13 -0800266 main.step( "Starting ONOS service" )
shahshreya234a1682015-05-27 15:41:56 -0700267 step6Result = main.TRUE
shahshreyafac62b12015-01-20 16:16:13 -0800268 startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreya234a1682015-05-27 15:41:56 -0700269 step6Result = startResult
shahshreyafac62b12015-01-20 16:16:13 -0800270 utilities.assert_equals(
271 expect=main.TRUE,
shahshreya234a1682015-05-27 15:41:56 -0700272 actual=step6Result,
273 onpass="Successfully started ONOS",
274 onfail="Failed to start ONOS")
275
276 main.step( "Starting ONOS cli" )
277 step7Result = main.TRUE
278 cliResult = main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
279 step7Result = cliResult
280 utilities.assert_equals(
281 expect=main.TRUE,
282 actual=step7Result,
283 onpass="Successfully started ONOS cli",
284 onfail="Failed to start ONOS cli")
shahshreyafac62b12015-01-20 16:16:13 -0800285
286 def CASE21( self, main ):
287 """
288 On ONOS bench, run this command:
shahshreya1937ec12015-04-03 15:35:48 -0700289 sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1
290 which spawns packet optical topology and copies the links
shahshreyafac62b12015-01-20 16:16:13 -0800291 json file to the onos instance.
292 Note that in case of Packet Optical, the links are not learnt
293 from the topology, instead the links are learnt
shahshreyae6c7cf42014-11-26 16:39:01 -0800294 from the json config file
shahshreyafac62b12015-01-20 16:16:13 -0800295 """
shahshreya234a1682015-05-27 15:41:56 -0700296 import time
shahshreyafac62b12015-01-20 16:16:13 -0800297 main.log.report(
298 "This testcase starts the packet layer topology and REST" )
299 main.log.report( "_____________________________________________" )
300 main.case( "Starting LINC-OE and other components" )
shahshreya234a1682015-05-27 15:41:56 -0700301
302 main.step( "Activate optical app" )
303 step1Result = main.TRUE
304 activateOpticalResult = main.ONOS2.activateApp( "org.onosproject.optical" )
305 step1Result = activateOpticalResult
306 utilities.assert_equals(
307 expect=main.TRUE,
308 actual=step1Result,
309 onpass="Successfully activated optical app",
310 onfail="Failed to activate optical app")
311
shahshreyad524a942015-04-21 09:55:16 -0700312 appCheck = main.ONOS2.appToIDCheck()
313 if appCheck != main.TRUE:
314 main.log.warn( main.ONOS2.apps() )
315 main.log.warn( main.ONOS2.appIDs() )
316
shahshreya234a1682015-05-27 15:41:56 -0700317 main.step( "Starting mininet and LINC-OE" )
318 step2Result = main.TRUE
319 time.sleep( 10 )
shahshreya215c48f2015-04-06 15:55:55 -0700320 opticalMnScript = main.LincOE2.runOpticalMnScript(ctrllerIP = main.params[ 'CTRL' ][ 'ip1' ])
shahshreya234a1682015-05-27 15:41:56 -0700321 step2Result = opticalMnScript
shahshreyafac62b12015-01-20 16:16:13 -0800322 utilities.assert_equals(
323 expect=main.TRUE,
shahshreya234a1682015-05-27 15:41:56 -0700324 actual=step2Result,
325 onpass="Started the topology successfully ",
326 onfail="Failed to start the topology")
shahshreyae6c7cf42014-11-26 16:39:01 -0800327
shahshreyafac62b12015-01-20 16:16:13 -0800328 def CASE22( self, main ):
329 """
shahshreya1937ec12015-04-03 15:35:48 -0700330 Curretly we use, 10 optical switches(ROADM's) and
331 6 packet layer mininet switches each with one host.
332 Therefore, the roadmCount variable = 10,
333 packetLayerSWCount variable = 6, hostCount=6 and
shahshreyaa47ebf42015-05-20 13:29:18 -0700334 links=46.
shahshreya1937ec12015-04-03 15:35:48 -0700335 All this is hardcoded in the testcase. If the topology changes,
shahshreyafac62b12015-01-20 16:16:13 -0800336 these hardcoded values need to be changed
337 """
shahshreya234a1682015-05-27 15:41:56 -0700338 import time
shahshreyafac62b12015-01-20 16:16:13 -0800339 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800340 "This testcase compares the optical+packet topology against what" +
341 " is expected" )
shahshreyafac62b12015-01-20 16:16:13 -0800342 main.case( "Topology comparision" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800343
shahshreya234a1682015-05-27 15:41:56 -0700344 main.step( "Starts new ONOS cli" )
345 step1Result = main.TRUE
346 cliResult = main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ]\
347 [ 'ip1' ] )
348 step1Result = cliResult
349 utilities.assert_equals(
350 expect=main.TRUE,
351 actual=step1Result,
352 onpass="Successfully starts a new cli",
353 onfail="Failed to start new cli" )
354
355 main.step( "Compare topology" )
356 step2Result = main.TRUE
357 devicesResult = main.ONOS3.devices( jsonFormat=False )
358 print "devices_result :\n", devicesResult
shahshreyafac62b12015-01-20 16:16:13 -0800359 devicesLinewise = devicesResult.split( "\n" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800360 roadmCount = 0
361 packetLayerSWCount = 0
shahshreyafac62b12015-01-20 16:16:13 -0800362 for line in devicesLinewise:
363 components = line.split( "," )
364 availability = components[ 1 ].split( "=" )[ 1 ]
365 type = components[ 3 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800366 if availability == 'true' and type == 'ROADM':
367 roadmCount += 1
shahshreyafac62b12015-01-20 16:16:13 -0800368 elif availability == 'true' and type == 'SWITCH':
shahshreyae6c7cf42014-11-26 16:39:01 -0800369 packetLayerSWCount += 1
shahshreya1937ec12015-04-03 15:35:48 -0700370 if roadmCount == 10:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800371 print "Number of Optical Switches = %d and is" % roadmCount +\
372 " correctly detected"
shahshreyafac62b12015-01-20 16:16:13 -0800373 main.log.info(
374 "Number of Optical Switches = " +
375 str( roadmCount ) +
376 " and is correctly detected" )
377 opticalSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800378 else:
shahshreyafac62b12015-01-20 16:16:13 -0800379 print "Number of Optical Switches = %d and is wrong" % roadmCount
380 main.log.info(
381 "Number of Optical Switches = " +
382 str( roadmCount ) +
383 " and is wrong" )
384 opticalSWResult = main.FALSE
shahshreya1937ec12015-04-03 15:35:48 -0700385 if packetLayerSWCount == 6:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800386 print "Number of Packet layer or mininet Switches = %d "\
387 % packetLayerSWCount + "and is correctly detected"
shahshreyafac62b12015-01-20 16:16:13 -0800388 main.log.info(
389 "Number of Packet layer or mininet Switches = " +
390 str( packetLayerSWCount ) +
391 " and is correctly detected" )
392 packetSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800393 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800394 print "Number of Packet layer or mininet Switches = %d and"\
395 % packetLayerSWCount + " is wrong"
shahshreyafac62b12015-01-20 16:16:13 -0800396 main.log.info(
397 "Number of Packet layer or mininet Switches = " +
398 str( packetLayerSWCount ) +
399 " and is wrong" )
400 packetSWResult = main.FALSE
shahshreya234a1682015-05-27 15:41:56 -0700401 # sleeps for sometime so the state of the switches will be active
402 time.sleep( 30 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800403 print "_________________________________"
shahshreyafac62b12015-01-20 16:16:13 -0800404 linksResult = main.ONOS3.links( jsonFormat=False )
405 print "links_result = ", linksResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800406 print "_________________________________"
shahshreya234a1682015-05-27 15:41:56 -0700407 linkActiveCount = linksResult.count("state=ACTIVE")
shahshreya1937ec12015-04-03 15:35:48 -0700408 main.log.info( "linkActiveCount = " + str( linkActiveCount ))
shahshreyaa47ebf42015-05-20 13:29:18 -0700409 if linkActiveCount == 46:
shahshreya1937ec12015-04-03 15:35:48 -0700410 linkActiveResult = main.TRUE
411 main.log.info(
412 "Number of links in ACTIVE state are correct")
413 else:
414 linkActiveResult = main.FALSE
415 main.log.info(
416 "Number of links in ACTIVE state are wrong")
shahshreya234a1682015-05-27 15:41:56 -0700417 step2Result = opticalSWResult and packetSWResult and \
shahshreya1937ec12015-04-03 15:35:48 -0700418 linkActiveResult
shahshreyafac62b12015-01-20 16:16:13 -0800419 utilities.assert_equals(
420 expect=main.TRUE,
shahshreya234a1682015-05-27 15:41:56 -0700421 actual=step2Result,
422 onpass="Successfully loaded packet optical topology",
423 onfail="Failed to load packet optical topology" )
shahshreya0e81ed92014-12-08 16:57:17 -0800424
shahshreyafac62b12015-01-20 16:16:13 -0800425 def CASE23( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800426 import time
shahshreyafac62b12015-01-20 16:16:13 -0800427 """
428 Add bidirectional point intents between 2 packet layer( mininet )
429 devices and
shahshreyae6c7cf42014-11-26 16:39:01 -0800430 ping mininet hosts
shahshreyafac62b12015-01-20 16:16:13 -0800431 """
432 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800433 "This testcase adds bidirectional point intents between 2 " +
434 "packet layer( mininet ) devices and ping mininet hosts" )
shahshreya234a1682015-05-27 15:41:56 -0700435 main.case( "Install point intents between 2 packet layer device and " +
436 "ping the hosts" )
437
shahshreyafac62b12015-01-20 16:16:13 -0800438 main.step( "Adding point intents" )
shahshreyabf739d82015-06-10 11:22:31 -0700439 checkFlowResult = main.TRUE
shahshreya234a1682015-05-27 15:41:56 -0700440 step1Result = main.TRUE
441 main.pIntentsId = []
442 pIntent1 = main.ONOS3.addPointIntent(
shahshreyafac62b12015-01-20 16:16:13 -0800443 "of:0000ffffffff0001/1",
shahshreya1937ec12015-04-03 15:35:48 -0700444 "of:0000ffffffff0005/1" )
shahshreya234a1682015-05-27 15:41:56 -0700445 pIntent2 = main.ONOS3.addPointIntent(
shahshreya1937ec12015-04-03 15:35:48 -0700446 "of:0000ffffffff0005/1",
shahshreyafac62b12015-01-20 16:16:13 -0800447 "of:0000ffffffff0001/1" )
shahshreya234a1682015-05-27 15:41:56 -0700448 main.pIntentsId.append( pIntent1 )
449 main.pIntentsId.append( pIntent2 )
450 time.sleep( 10 )
451 main.log.info( "Checking intents state")
452 checkStateResult = main.ONOS3.checkIntentState(
453 intentsId = main.pIntentsId )
454 time.sleep( 10 )
455 main.log.info( "Checking flows state")
456 checkFlowResult = main.ONOS3.checkFlowsState()
shahshreyae6c7cf42014-11-26 16:39:01 -0800457 # Sleep for 30 seconds to provide time for the intent state to change
shahshreya234a1682015-05-27 15:41:56 -0700458 time.sleep( 10 )
459 main.log.info( "Checking intents state one more time")
460 checkStateResult = main.ONOS3.checkIntentState(
461 intentsId = main.pIntentsId )
462 step1Result = checkStateResult and checkFlowResult
shahshreyafac62b12015-01-20 16:16:13 -0800463 utilities.assert_equals(
464 expect=main.TRUE,
shahshreya234a1682015-05-27 15:41:56 -0700465 actual=step1Result,
466 onpass="Successfully added point intents",
467 onfail="Failed to add point intents")
468
469 main.step( "Ping h1 and h5" )
470 step2Result = main.TRUE
471 main.log.info( "\n\nh1 is Pinging h5" )
472 pingResult = main.LincOE2.pingHostOptical( src="h1", target="h5" )
473 step2Result = pingResult
474 utilities.assert_equals(
475 expect=main.TRUE,
476 actual=step2Result,
477 onpass="Successfully pinged h1 and h5",
478 onfail="Failed to ping between h1 and h5")
shahshreyae6c7cf42014-11-26 16:39:01 -0800479
shahshreyafac62b12015-01-20 16:16:13 -0800480 def CASE24( self, main ):
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800481 import time
482 import json
shahshreyafac62b12015-01-20 16:16:13 -0800483 """
shahshreya1937ec12015-04-03 15:35:48 -0700484 LINC uses its own switch IDs. You can use the following
485 command on the LINC console to find the mapping between
486 DPIDs and LINC IDs.
487 rp(application:get_all_key(linc)).
488
shahshreyafac62b12015-01-20 16:16:13 -0800489 Test Rerouting of Packet Optical by bringing a port down
shahshreya1937ec12015-04-03 15:35:48 -0700490 ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
491 so that link
492 ( between switch1 port20 - switch5 port50 ) is inactive
shahshreyafac62b12015-01-20 16:16:13 -0800493 and do a ping test. If rerouting is successful,
494 ping should pass. also check the flows
495 """
496 main.log.report(
497 "This testcase tests rerouting and pings mininet hosts" )
498 main.case( "Test rerouting and pings mininet hosts" )
shahshreya234a1682015-05-27 15:41:56 -0700499
shahshreya1937ec12015-04-03 15:35:48 -0700500 main.step( "Attach to the Linc-OE session" )
shahshreya234a1682015-05-27 15:41:56 -0700501 step1Result = main.TRUE
502 attachConsole = main.LincOE1.attachLincOESession()
503 step1Result = attachConsole
504 utilities.assert_equals(
505 expect=main.TRUE,
506 actual=step1Result,
507 onpass="Successfully attached Linc-OE session",
508 onfail="Failed to attached Linc-OE session")
shahshreya1937ec12015-04-03 15:35:48 -0700509
shahshreyafac62b12015-01-20 16:16:13 -0800510 main.step( "Bring a port down and verify the link state" )
shahshreya234a1682015-05-27 15:41:56 -0700511 step2Result = main.TRUE
shahshreya1937ec12015-04-03 15:35:48 -0700512 main.LincOE1.portDown( swId="9", ptId="20" )
shahshreyafac62b12015-01-20 16:16:13 -0800513 linksNonjson = main.ONOS3.links( jsonFormat=False )
514 main.log.info( "links = " + linksNonjson )
shahshreya234a1682015-05-27 15:41:56 -0700515 linkInactiveCount = linksNonjson.count( "state=INACTIVE" )
shahshreya1937ec12015-04-03 15:35:48 -0700516 main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
517 if linkInactiveCount == 2:
518 main.log.info(
519 "Number of links in INACTIVE state are correct")
520 else:
521 main.log.info(
522 "Number of links in INACTIVE state are wrong")
shahshreya0e81ed92014-12-08 16:57:17 -0800523 links = main.ONOS3.links()
shahshreyafac62b12015-01-20 16:16:13 -0800524 main.log.info( "links = " + links )
shahshreyafac62b12015-01-20 16:16:13 -0800525 linksResult = json.loads( links )
526 linksStateResult = main.FALSE
527 for item in linksResult:
528 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
shahshreya1937ec12015-04-03 15:35:48 -0700529 'src' ][ 'port' ] == "20":
530 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
531 'dst' ][ 'port' ] == "50":
shahshreyafac62b12015-01-20 16:16:13 -0800532 linksState = item[ 'state' ]
533 if linksState == "INACTIVE":
534 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800535 "Links state is inactive as expected due to one" +
536 " of the ports being down" )
shahshreyafac62b12015-01-20 16:16:13 -0800537 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800538 "Links state is inactive as expected due to one" +
539 " of the ports being down" )
shahshreyafac62b12015-01-20 16:16:13 -0800540 linksStateResult = main.TRUE
shahshreya0e81ed92014-12-08 16:57:17 -0800541 break
542 else:
shahshreyafac62b12015-01-20 16:16:13 -0800543 main.log.info(
544 "Links state is not inactive as expected" )
545 main.log.report(
546 "Links state is not inactive as expected" )
547 linksStateResult = main.FALSE
shahshreyafac62b12015-01-20 16:16:13 -0800548 time.sleep( 10 )
shahshreya234a1682015-05-27 15:41:56 -0700549 checkFlowsState = main.ONOS3.checkFlowsState()
550 step2Result = linksStateResult
551 utilities.assert_equals(
552 expect=main.TRUE,
553 actual=step2Result,
554 onpass="Successfuly brought down a link",
555 onfail="Failed to bring down a link")
shahshreya0e81ed92014-12-08 16:57:17 -0800556
shahshreyafac62b12015-01-20 16:16:13 -0800557 main.step( "Verify Rerouting by a ping test" )
shahshreya234a1682015-05-27 15:41:56 -0700558 step3Result = main.TRUE
shahshreya1937ec12015-04-03 15:35:48 -0700559 main.log.info( "\n\nh1 is Pinging h5" )
shahshreya234a1682015-05-27 15:41:56 -0700560 pingResult = main.LincOE2.pingHostOptical( src="h1", target="h5" )
561 step3Result = pingResult
562 utilities.assert_equals(
563 expect=main.TRUE,
564 actual=step3Result,
565 onpass="Successfully pinged h1 and h5",
566 onfail="Failed to ping between h1 and h5")
567
568 main.step( "Bring the downed port up and verify the link state" )
569 step4Result = main.TRUE
570 main.LincOE1.portUp( swId="9", ptId="20" )
571 linksNonjson = main.ONOS3.links( jsonFormat=False )
572 main.log.info( "links = " + linksNonjson )
573 linkInactiveCount = linksNonjson.count( "state=INACTIVE" )
574 main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
575 if linkInactiveCount == 0:
shahshreyafac62b12015-01-20 16:16:13 -0800576 main.log.info(
shahshreya234a1682015-05-27 15:41:56 -0700577 "Number of links in INACTIVE state are correct")
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800578 else:
shahshreya234a1682015-05-27 15:41:56 -0700579 main.log.info(
580 "Number of links in INACTIVE state are wrong")
581 step4Result = main.FALSE
582 utilities.assert_equals(
583 expect=main.TRUE,
584 actual=step4Result,
585 onpass="Successfully brought the port up",
586 onfail="Failed to bring the port up")
587 """
588 main.step( "Removing host intents" )
589 step5Result = main.TRUE
590 removeResult = main.TRUE
591 # Check remaining intents
592 intentsJson = json.loads( main.ONOS3.intents() )
593 main.ONOS3.removeIntent( intentId=intent1, purge=True )
594 main.ONOS3.removeIntent( intentId=intent2, purge=True )
595 for intents in intentsJson:
596 main.ONOS3.removeIntent( intentId=intents.get( 'id' ),
597 app='org.onosproject.optical',
598 purge=True )
599 print json.loads( main.ONOS3.intents() )
600 if len( json.loads( main.ONOS3.intents() ) ):
601 removeResult = main.FALSE
602 step5Result = removeResult
603 utilities.assert_equals( expect=main.TRUE,
604 actual=step5Result,
605 onpass="Successfully removed host intents",
606 onfail="Failed to remove host intents" )
607 """
608 def CASE10( self ):
609 main.log.report(
610 "This testcase uninstalls the reactive forwarding app" )
611 main.log.report( "__________________________________" )
612 main.case( "Uninstalling reactive forwarding app" )
613 main.step( "Uninstalling reactive forwarding app" )
614 step1Result = main.TRUE
615 # Unistall onos-app-fwd app to disable reactive forwarding
616 main.log.info( "deactivate reactive forwarding app" )
617 appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
618 appCheck = main.ONOS2.appToIDCheck()
619 if appCheck != main.TRUE:
620 main.log.warn( main.ONOS2.apps() )
621 main.log.warn( main.ONOS2.appIDs() )
622 step1Result = appUninstallResult
623 utilities.assert_equals(
624 expect=main.TRUE,
625 actual=step1Result,
626 onpass="Successfully deactivate reactive forwarding app",
627 onfail="Failed to deactivate reactive forwarding app")
628 # After reactive forwarding is disabled, the reactive flows on
629 # switches timeout in 10-15s
630 # So sleep for 15s
631 time.sleep( 15 )
632 flows = main.ONOS2.flows()
633 main.log.info( flows )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800634
shahshreya234a1682015-05-27 15:41:56 -0700635 def CASE25( self ):
636 """
637 Add host intents between 2 packet layer host
638 """
639 import time
640 import json
641 main.log.report( "Adding host intents between 2 optical layer host" )
642 main.case( "Test add host intents between optical layer host" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800643
shahshreya234a1682015-05-27 15:41:56 -0700644 main.step( "Discover host using arping" )
645 step1Result = main.TRUE
646 main.hostMACs = []
647 main.hostId = []
648 #Listing host MAC addresses
649 for i in range( 1 , 7 ):
650 main.hostMACs.append( "00:00:00:00:00:" +
651 str( hex( i )[ 2: ] ).zfill( 2 ).upper() )
652 for macs in main.hostMACs:
653 main.hostId.append( macs + "/-1" )
654 host1 = main.hostId[ 0 ]
655 host2 = main.hostId[ 1 ]
656 # Use arping to discover the hosts
657 main.LincOE2.arping( host = "h1" )
658 main.LincOE2.arping( host = "h2" )
659 time.sleep( 5 )
660 hostsDict = main.ONOS3.hosts()
661 if not len( hostsDict ):
662 step1Result = main.FALSE
663 # Adding host intent
664 utilities.assert_equals(
665 expect=main.TRUE,
666 actual=step1Result,
667 onpass="Hosts discovered",
668 onfail="Failed to discover hosts")
669
670 main.step( "Adding host intents to h1 and h2" )
671 step2Result = main.TRUE
672 intentsId = []
673 intent1 = main.ONOS3.addHostIntent( hostIdOne = host1,
674 hostIdTwo = host2 )
675 intentsId.append( intent1 )
676 time.sleep( 5 )
677 intent2 = main.ONOS3.addHostIntent( hostIdOne = host2,
678 hostIdTwo = host1 )
679 intentsId.append( intent2 )
680 # Checking intents state before pinging
681 main.log.info( "Checking intents state" )
682 time.sleep( 15 )
683 intentResult = main.ONOS3.checkIntentState( intentsId = intentsId )
684 #check intent state again if intents are not in installed state
685 if not intentResult:
686 intentResult = main.ONOS3.checkIntentState( intentsId = intentsId )
687 step2Result = intentResult
688 utilities.assert_equals( expect=main.TRUE,
689 actual=step2Result,
690 onpass="All intents are in INSTALLED state ",
691 onfail="Some of the intents are not in " +
692 "INSTALLED state " )
693
694 # pinging h1 to h2 and then ping h2 to h1
695 main.step( "Pinging h1 and h2" )
696 step3Result = main.TRUE
697 pingResult = main.TRUE
698 pingResult = main.LincOE2.pingHostOptical( src="h1", target="h2" )
699 pingResult = pingResult and main.LincOE2.pingHostOptical( src="h2",
700 target="h1" )
701 step3Result = pingResult
702 utilities.assert_equals( expect=main.TRUE,
703 actual=step3Result,
704 onpass="Pinged successfully between h1 and h2",
705 onfail="Pinged failed between h1 and h2" )
706 # Removed all added host intents
707 main.step( "Removing host intents" )
708 step4Result = main.TRUE
709 removeResult = main.TRUE
710 # Check remaining intents
711 intentsJson = json.loads( main.ONOS3.intents() )
712 main.ONOS3.removeIntent( intentId=intent1, purge=True )
713 main.ONOS3.removeIntent( intentId=intent2, purge=True )
714 for intents in intentsJson:
715 main.ONOS3.removeIntent( intentId=intents.get( 'id' ),
716 app='org.onosproject.optical',
717 purge=True )
718 print json.loads( main.ONOS3.intents() )
719 if len( json.loads( main.ONOS3.intents() ) ):
720 removeResult = main.FALSE
721 step4Result = removeResult
722 utilities.assert_equals( expect=main.TRUE,
723 actual=step4Result,
724 onpass="Successfully removed host intents",
725 onfail="Failed to remove host intents" )
shahshreya4e13a062014-11-11 16:46:18 -0800726
shahshreyafac62b12015-01-20 16:16:13 -0800727 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800728 import re
729 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800730 main.log.report( "This testcase is testing the assignment of" +
731 " all the switches to all the controllers and" +
shahshreyadcb08e82015-02-25 10:16:42 -0800732 " discovering the hosts in reactive mode" )
shahshreyafac62b12015-01-20 16:16:13 -0800733 main.log.report( "__________________________________" )
shahshreyaa47ebf42015-05-20 13:29:18 -0700734
shahshreyafac62b12015-01-20 16:16:13 -0800735 main.case( "Pingall Test" )
736 main.step( "Assigning switches to controllers" )
737 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
738 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
739 for i in range( 1, 29 ):
740 if i == 1:
741 main.Mininet1.assignSwController(
742 sw=str( i ),
743 ip1=ONOS1Ip,
744 port1=ONOS1Port )
745 elif i >= 2 and i < 5:
746 main.Mininet1.assignSwController(
747 sw=str( i ),
748 ip1=ONOS1Ip,
749 port1=ONOS1Port )
750 elif i >= 5 and i < 8:
751 main.Mininet1.assignSwController(
752 sw=str( i ),
753 ip1=ONOS1Ip,
754 port1=ONOS1Port )
755 elif i >= 8 and i < 18:
756 main.Mininet1.assignSwController(
757 sw=str( i ),
758 ip1=ONOS1Ip,
759 port1=ONOS1Port )
760 elif i >= 18 and i < 28:
761 main.Mininet1.assignSwController(
762 sw=str( i ),
763 ip1=ONOS1Ip,
764 port1=ONOS1Port )
shahshreya4e13a062014-11-11 16:46:18 -0800765 else:
shahshreyafac62b12015-01-20 16:16:13 -0800766 main.Mininet1.assignSwController(
767 sw=str( i ),
768 ip1=ONOS1Ip,
769 port1=ONOS1Port )
770 SwitchMastership = main.TRUE
771 for i in range( 1, 29 ):
772 if i == 1:
773 response = main.Mininet1.getSwController( "s" + str( i ) )
774 print( "Response is " + str( response ) )
775 if re.search( "tcp:" + ONOS1Ip, response ):
776 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800777 else:
shahshreyafac62b12015-01-20 16:16:13 -0800778 SwitchMastership = main.FALSE
779 elif i >= 2 and i < 5:
780 response = main.Mininet1.getSwController( "s" + str( i ) )
781 print( "Response is " + str( response ) )
782 if re.search( "tcp:" + ONOS1Ip, response ):
783 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800784 else:
shahshreyafac62b12015-01-20 16:16:13 -0800785 SwitchMastership = main.FALSE
786 elif i >= 5 and i < 8:
787 response = main.Mininet1.getSwController( "s" + str( i ) )
788 print( "Response is " + str( response ) )
789 if re.search( "tcp:" + ONOS1Ip, response ):
790 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800791 else:
shahshreyafac62b12015-01-20 16:16:13 -0800792 SwitchMastership = main.FALSE
793 elif i >= 8 and i < 18:
794 response = main.Mininet1.getSwController( "s" + str( i ) )
795 print( "Response is " + str( response ) )
796 if re.search( "tcp:" + ONOS1Ip, response ):
797 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800798 else:
shahshreyafac62b12015-01-20 16:16:13 -0800799 SwitchMastership = main.FALSE
800 elif i >= 18 and i < 28:
801 response = main.Mininet1.getSwController( "s" + str( i ) )
802 print( "Response is " + str( response ) )
803 if re.search( "tcp:" + ONOS1Ip, response ):
804 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800805 else:
shahshreyafac62b12015-01-20 16:16:13 -0800806 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800807 else:
shahshreyafac62b12015-01-20 16:16:13 -0800808 response = main.Mininet1.getSwController( "s" + str( i ) )
809 print( "Response is" + str( response ) )
810 if re.search( "tcp:" + ONOS1Ip, response ):
811 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800812 else:
shahshreyafac62b12015-01-20 16:16:13 -0800813 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800814
shahshreyafac62b12015-01-20 16:16:13 -0800815 if SwitchMastership == main.TRUE:
816 main.log.report( "Controller assignmnet successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800817 else:
shahshreyafac62b12015-01-20 16:16:13 -0800818 main.log.report( "Controller assignmnet failed" )
819 utilities.assert_equals(
820 expect=main.TRUE,
821 actual=SwitchMastership,
822 onpass="MasterControllers assigned correctly" )
823 """
824 for i in range ( 1,29 ):
825 main.Mininet1.assignSwController( sw=str( i ),count=5,
826 ip1=ONOS1Ip,port1=ONOS1Port,
827 ip2=ONOS2Ip,port2=ONOS2Port,
828 ip3=ONOS3Ip,port3=ONOS3Port,
829 ip4=ONOS4Ip,port4=ONOS4Port,
830 ip5=ONOS5Ip,port5=ONOS5Port )
831 """
832 # REACTIVE FWD test
shahshreyad524a942015-04-21 09:55:16 -0700833 main.log.info( "Activate fwd app" )
834 appInstallResult = main.ONOS2.activateApp( "org.onosproject.fwd" )
835 appCheck = main.ONOS2.appToIDCheck()
836 if appCheck != main.TRUE:
837 main.log.warn( main.ONOS2.apps() )
838 main.log.warn( main.ONOS2.appIDs() )
839 time.sleep( 10 )
shahshreya4e13a062014-11-11 16:46:18 -0800840
shahshreyafac62b12015-01-20 16:16:13 -0800841 main.step( "Get list of hosts from Mininet" )
Jon Hallb87f3db2015-07-06 03:10:27 -0700842 hostList = main.Mininet1.getHosts()
shahshreyafac62b12015-01-20 16:16:13 -0800843 main.log.info( hostList )
shahshreya4e13a062014-11-11 16:46:18 -0800844
shahshreyafac62b12015-01-20 16:16:13 -0800845 main.step( "Get host list in ONOS format" )
846 hostOnosList = main.ONOS2.getHostsId( hostList )
847 main.log.info( hostOnosList )
848 # time.sleep( 5 )
849
850 main.step( "Pingall" )
851 pingResult = main.FALSE
shahshreya82ecd282015-02-05 16:48:03 -0800852 time1 = time.time()
853 pingResult = main.Mininet1.pingall()
854 time2 = time.time()
855 print "Time for pingall: %2f seconds" % ( time2 - time1 )
shahshreya4e13a062014-11-11 16:46:18 -0800856
shahshreyafac62b12015-01-20 16:16:13 -0800857 # Start onos cli again because u might have dropped out of
858 # onos prompt to the shell prompt
859 # if there was no activity
860 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
861
862 case4Result = SwitchMastership and pingResult
863 if pingResult == main.TRUE:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800864 main.log.report( "Pingall Test in reactive mode to" +
865 " discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800866 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800867 main.log.report( "Pingall Test in reactive mode to" +
868 " discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800869
shahshreyafac62b12015-01-20 16:16:13 -0800870 utilities.assert_equals(
871 expect=main.TRUE,
872 actual=case4Result,
873 onpass="Controller assignment and Pingall Test successful",
874 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800875
shahshreyadcb08e82015-02-25 10:16:42 -0800876 def CASE11( self ):
877 # NOTE: This testcase require reactive forwarding mode enabled
878 # NOTE: in the beginning and then uninstall it before adding
879 # NOTE: point intents. Again the app is installed so that
880 # NOTE: testcase 10 can be ran successively
881 import time
882 main.log.report(
883 "This testcase moves a host from one switch to another to add" +
884 "point intents between them and then perform ping" )
885 main.log.report( "__________________________________" )
886 main.log.info( "Moving host from one switch to another" )
887 main.case( "Moving host from a device and attach it to another device" )
888 main.step( "Moving host h9 from device s9 and attach it to s8" )
889 main.Mininet1.moveHost(host = 'h9', oldSw = 's9', newSw = 's8')
890
shahshreyad524a942015-04-21 09:55:16 -0700891 main.log.info( "Activate fwd app" )
892 appInstallResult = main.ONOS2.activateApp( "org.onosproject.fwd" )
893 appCheck = main.ONOS2.appToIDCheck()
894 if appCheck != main.TRUE:
895 main.log.warn( main.ONOS2.apps() )
896 main.log.warn( main.ONOS2.appIDs() )
897
shahshreyaa47ebf42015-05-20 13:29:18 -0700898 time.sleep(25) #Time delay to have all the flows ready
shahshreyadcb08e82015-02-25 10:16:42 -0800899 main.step( "Pingall" )
900 pingResult = main.FALSE
901 time1 = time.time()
shahshreyad524a942015-04-21 09:55:16 -0700902 pingResult = main.Mininet1.pingall( timeout=120,
903 shortCircuit=True,
shahshreyaa47ebf42015-05-20 13:29:18 -0700904 acceptableFailed=20 )
shahshreyadcb08e82015-02-25 10:16:42 -0800905 time2 = time.time()
906 print "Time for pingall: %2f seconds" % ( time2 - time1 )
907
908 hosts = main.ONOS2.hosts( jsonFormat = False )
909 main.log.info( hosts )
910
shahshreyad524a942015-04-21 09:55:16 -0700911 main.log.info( "deactivate reactive forwarding app" )
912 appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
913 appCheck = main.ONOS2.appToIDCheck()
914 if appCheck != main.TRUE:
915 main.log.warn( main.ONOS2.apps() )
916 main.log.warn( main.ONOS2.appIDs() )
shahshreyadcb08e82015-02-25 10:16:42 -0800917
918 main.step( "Add point intents between hosts on the same device")
919 ptpIntentResult = main.ONOS2.addPointIntent(
920 "of:0000000000003008/1",
shahshreya234a1682015-05-27 15:41:56 -0700921 "of:0000000000003008/3",
922 ethType='IPV4',
923 ethSrc='00:00:00:00:00:08',
924 ethDst='00:00:00:00:00:09' )
shahshreyadcb08e82015-02-25 10:16:42 -0800925 if ptpIntentResult == main.TRUE:
926 getIntentResult = main.ONOS2.intents()
927 main.log.info( "Point to point intent install successful" )
928 # main.log.info( getIntentResult )
929
930 ptpIntentResult = main.ONOS2.addPointIntent(
931 "of:0000000000003008/3",
shahshreya234a1682015-05-27 15:41:56 -0700932 "of:0000000000003008/1",
933 ethType='IPV4',
934 ethSrc='00:00:00:00:00:09',
935 ethDst='00:00:00:00:00:08' )
shahshreyadcb08e82015-02-25 10:16:42 -0800936 if ptpIntentResult == main.TRUE:
937 getIntentResult = main.ONOS2.intents()
938 main.log.info( "Point to point intent install successful" )
939 # main.log.info( getIntentResult )
940
941 main.case( "Ping hosts on the same devices" )
942 ping = main.Mininet1.pingHost( src = 'h8', target = 'h9' )
943
944 '''
945 main.case( "Installing reactive forwarding app" )
946 # Install onos-app-fwd app to enable reactive forwarding
947 appUninstallResult = main.ONOS2.featureInstall( "onos-app-fwd" )
948 main.log.info( "onos-app-fwd installed" )
949 '''
950
951 if ping == main.FALSE:
952 main.log.report(
953 "Point intents for hosts on same devices haven't" +
954 " been installed correctly. Cleaning up" )
955 if ping == main.TRUE:
956 main.log.report(
957 "Point intents for hosts on same devices" +
958 "installed correctly. Cleaning up" )
959
shahshreyaa47ebf42015-05-20 13:29:18 -0700960 case11Result = ping
shahshreyadcb08e82015-02-25 10:16:42 -0800961 utilities.assert_equals(
shahshreya74cca802015-02-26 12:24:01 -0800962 expect = main.TRUE,
963 actual = case11Result,
964 onpass = "Point intents for hosts on same devices" +
shahshreyadcb08e82015-02-25 10:16:42 -0800965 "Ping Test successful",
shahshreya74cca802015-02-26 12:24:01 -0800966 onfail = "Point intents for hosts on same devices" +
shahshreyadcb08e82015-02-25 10:16:42 -0800967 "Ping Test NOT successful" )
shahshreya74cca802015-02-26 12:24:01 -0800968
shahshreya74cca802015-02-26 12:24:01 -0800969 def CASE12( self ):
970 """
shahshreya1937ec12015-04-03 15:35:48 -0700971 Verify the default flows on each switch in proactive mode
shahshreya74cca802015-02-26 12:24:01 -0800972 """
973 main.log.report( "This testcase is verifying num of default" +
974 " flows on each switch" )
975 main.log.report( "__________________________________" )
976 main.case( "Verify num of default flows on each switch" )
977 main.step( "Obtaining the device id's and flowrule count on them" )
978
979 case12Result = main.TRUE
980 idList = main.ONOS2.getAllDevicesId()
981 for id in idList:
982 count = main.ONOS2.FlowAddedCount( id )
shahshreya531e2b52015-02-26 12:40:46 -0800983 main.log.info("count = " +count)
984 if int(count) != 3:
shahshreya74cca802015-02-26 12:24:01 -0800985 case12Result = main.FALSE
986 break
shahshreya74cca802015-02-26 12:24:01 -0800987 utilities.assert_equals(
988 expect=main.TRUE,
989 actual=case12Result,
990 onpass = "Expected default num of flows exist",
991 onfail = "Expected default num of flows do not exist")
shahshreyadcb08e82015-02-25 10:16:42 -0800992
shahshreyafac62b12015-01-20 16:16:13 -0800993 def CASE6( self ):
shahshreyadcb08e82015-02-25 10:16:42 -0800994 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800995 main.log.report( "This testcase is testing the addition of" +
996 " host intents and then does pingall" )
shahshreyafac62b12015-01-20 16:16:13 -0800997 main.log.report( "__________________________________" )
998 main.case( "Obtaining host id's" )
999 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001000 hosts = main.ONOS2.hosts()
shahshreyafac62b12015-01-20 16:16:13 -08001001 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -08001002
shahshreyafac62b12015-01-20 16:16:13 -08001003 main.step( "Get all devices id" )
1004 devicesIdList = main.ONOS2.getAllDevicesId()
1005 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -08001006
shahshreyafac62b12015-01-20 16:16:13 -08001007 # ONOS displays the hosts in hex format unlike mininet which does
1008 # in decimal format
1009 # So take care while adding intents
1010 """
1011 main.step( "Add host-to-host intents for mininet hosts h8 and h18 or
1012 ONOS hosts h8 and h12" )
1013 hthIntentResult = main.ONOS2.addHostIntent(
1014 "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
1015 hthIntentResult = main.ONOS2.addHostIntent(
1016 "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
1017 hthIntentResult = main.ONOS2.addHostIntent(
1018 "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
1019 hthIntentResult = main.ONOS2.addHostIntent(
1020 "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
1021 hthIntentResult = main.ONOS2.addHostIntent(
1022 "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
1023 hthIntentResult = main.ONOS2.addHostIntent(
1024 "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
1025 hthIntentResult = main.ONOS2.addHostIntent(
1026 "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
1027 hthIntentResult = main.ONOS2.addHostIntent(
1028 "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
1029 hthIntentResult = main.ONOS2.addHostIntent(
1030 "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
1031 hthIntentResult = main.ONOS2.addHostIntent(
1032 "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
1033 print "______________________________________________________"
1034 """
shahshreya234a1682015-05-27 15:41:56 -07001035 intentsId = []
shahshreyafac62b12015-01-20 16:16:13 -08001036 for i in range( 8, 18 ):
1037 main.log.info(
1038 "Adding host intent between h" + str( i ) +
1039 " and h" + str( i + 10 ) )
1040 host1 = "00:00:00:00:00:" + \
1041 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1042 host2 = "00:00:00:00:00:" + \
1043 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
1044 # NOTE: get host can return None
shahshreya1937ec12015-04-03 15:35:48 -07001045 if host1:
1046 host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
1047 if host2:
1048 host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
1049 if host1Id and host2Id:
shahshreya234a1682015-05-27 15:41:56 -07001050 intentsId.append( main.ONOS2.addHostIntent( host1Id, host2Id ) )
shahshreyafac62b12015-01-20 16:16:13 -08001051
shahshreya234a1682015-05-27 15:41:56 -07001052 checkIntentResult = main.ONOS2.checkIntentState( intentsId )
shahshreyafac62b12015-01-20 16:16:13 -08001053 time.sleep( 10 )
1054 hIntents = main.ONOS2.intents( jsonFormat=False )
1055 main.log.info( "intents:" + hIntents )
shahshreyadcb08e82015-02-25 10:16:42 -08001056 flows = main.ONOS2.flows()
1057 main.log.info( "flows:" + flows )
shahshreya4e13a062014-11-11 16:46:18 -08001058
1059 count = 1
1060 i = 8
shahshreyafac62b12015-01-20 16:16:13 -08001061 PingResult = main.TRUE
1062 # while i<10:
1063 while i < 18:
1064 main.log.info(
1065 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1066 ping = main.Mininet1.pingHost(
1067 src="h" + str( i ), target="h" + str( i + 10 ) )
1068 if ping == main.FALSE and count < 5:
1069 count += 1
1070 # i = 8
1071 PingResult = main.FALSE
1072 main.log.report( "Ping between h" +
1073 str( i ) +
1074 " and h" +
1075 str( i +
1076 10 ) +
1077 " failed. Making attempt number " +
1078 str( count ) +
1079 " in 2 seconds" )
1080 time.sleep( 2 )
1081 elif ping == main.FALSE:
1082 main.log.report( "All ping attempts between h" +
1083 str( i ) +
1084 " and h" +
1085 str( i +
1086 10 ) +
1087 "have failed" )
1088 i = 19
1089 PingResult = main.FALSE
1090 elif ping == main.TRUE:
1091 main.log.info( "Ping test between h" +
1092 str( i ) +
1093 " and h" +
1094 str( i +
1095 10 ) +
1096 "passed!" )
1097 i += 1
1098 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001099 else:
shahshreyafac62b12015-01-20 16:16:13 -08001100 main.log.info( "Unknown error" )
1101 PingResult = main.ERROR
1102 if PingResult == main.FALSE:
1103 main.log.report(
shahshreya9294c8d2015-01-21 15:54:16 -08001104 "Ping all test after Host intent addition failed.Cleaning up" )
shahshreyafac62b12015-01-20 16:16:13 -08001105 # main.cleanup()
1106 # main.exit()
1107 if PingResult == main.TRUE:
1108 main.log.report(
1109 "Ping all test after Host intent addition successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001110
shahshreya234a1682015-05-27 15:41:56 -07001111 checkIntentResult = main.ONOS2.checkIntentState( intentsId )
1112
shahshreyafac62b12015-01-20 16:16:13 -08001113 case6Result = PingResult
1114 utilities.assert_equals(
1115 expect=main.TRUE,
1116 actual=case6Result,
1117 onpass="Pingall Test after Host intents addition successful",
1118 onfail="Pingall Test after Host intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001119
shahshreyafac62b12015-01-20 16:16:13 -08001120 def CASE5( self, main ):
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001121 """
1122 Check ONOS topology matches with mininet
1123 """
shahshreya4e13a062014-11-11 16:46:18 -08001124 import json
Jon Hallb87f3db2015-07-06 03:10:27 -07001125 # assumes that sts is already in you PYTHONPATH
1126 from sts.topology.teston_topology import TestONTopology
1127 # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001128 main.log.report( "This testcase is testing if all ONOS nodes" +
1129 " are in topology sync with mininet" )
shahshreyafac62b12015-01-20 16:16:13 -08001130 main.log.report( "__________________________________" )
1131 main.case( "Comparing Mininet topology with the topology of ONOS" )
1132 main.step( "Start continuous pings" )
1133 main.Mininet2.pingLong(
1134 src=main.params[ 'PING' ][ 'source1' ],
1135 target=main.params[ 'PING' ][ 'target1' ],
1136 pingTime=500 )
1137 main.Mininet2.pingLong(
1138 src=main.params[ 'PING' ][ 'source2' ],
1139 target=main.params[ 'PING' ][ 'target2' ],
1140 pingTime=500 )
1141 main.Mininet2.pingLong(
1142 src=main.params[ 'PING' ][ 'source3' ],
1143 target=main.params[ 'PING' ][ 'target3' ],
1144 pingTime=500 )
1145 main.Mininet2.pingLong(
1146 src=main.params[ 'PING' ][ 'source4' ],
1147 target=main.params[ 'PING' ][ 'target4' ],
1148 pingTime=500 )
1149 main.Mininet2.pingLong(
1150 src=main.params[ 'PING' ][ 'source5' ],
1151 target=main.params[ 'PING' ][ 'target5' ],
1152 pingTime=500 )
1153 main.Mininet2.pingLong(
1154 src=main.params[ 'PING' ][ 'source6' ],
1155 target=main.params[ 'PING' ][ 'target6' ],
1156 pingTime=500 )
1157 main.Mininet2.pingLong(
1158 src=main.params[ 'PING' ][ 'source7' ],
1159 target=main.params[ 'PING' ][ 'target7' ],
1160 pingTime=500 )
1161 main.Mininet2.pingLong(
1162 src=main.params[ 'PING' ][ 'source8' ],
1163 target=main.params[ 'PING' ][ 'target8' ],
1164 pingTime=500 )
1165 main.Mininet2.pingLong(
1166 src=main.params[ 'PING' ][ 'source9' ],
1167 target=main.params[ 'PING' ][ 'target9' ],
1168 pingTime=500 )
1169 main.Mininet2.pingLong(
1170 src=main.params[ 'PING' ][ 'source10' ],
1171 target=main.params[ 'PING' ][ 'target10' ],
1172 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -08001173
Jon Hallb87f3db2015-07-06 03:10:27 -07001174 main.step( "Create TestONTopology object" )
1175 global ctrls
1176 ctrls = []
1177 count = 1
1178 while True:
1179 temp = ()
1180 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
1181 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
1182 temp = temp + ( "ONOS" + str( count ), )
1183 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
1184 temp = temp + \
1185 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
1186 ctrls.append( temp )
1187 count = count + 1
1188 else:
1189 break
1190 global MNTopo
1191 Topo = TestONTopology(
1192 main.Mininet1,
1193 ctrls ) # can also add Intent API info for intent operations
1194 MNTopo = Topo
1195
shahshreyafac62b12015-01-20 16:16:13 -08001196 TopologyCheck = main.TRUE
1197 main.step( "Compare ONOS Topology to MN Topology" )
1198 devicesJson = main.ONOS2.devices()
1199 linksJson = main.ONOS2.links()
shahshreyabf739d82015-06-10 11:22:31 -07001200 portsJson = main.ONOS2.ports()
shahshreyafac62b12015-01-20 16:16:13 -08001201
1202 result1 = main.Mininet1.compareSwitches(
Jon Hallb87f3db2015-07-06 03:10:27 -07001203 MNTopo,
1204 json.loads( devicesJson ) )
shahshreyafac62b12015-01-20 16:16:13 -08001205 result2 = main.Mininet1.compareLinks(
Jon Hallb87f3db2015-07-06 03:10:27 -07001206 MNTopo,
1207 json.loads( linksJson ) )
shahshreyafac62b12015-01-20 16:16:13 -08001208
Jon Hallb87f3db2015-07-06 03:10:27 -07001209 result3 = main.Mininet1.comparePorts( MNTopo, json.loads( portsJson ) )
1210 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001211 result = result1 and result2
shahshreyafac62b12015-01-20 16:16:13 -08001212
shahshreya4e13a062014-11-11 16:46:18 -08001213 print "***********************"
1214 if result == main.TRUE:
shahshreyafac62b12015-01-20 16:16:13 -08001215 main.log.report( "ONOS" + " Topology matches MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001216 else:
shahshreyafac62b12015-01-20 16:16:13 -08001217 main.log.report( "ONOS" + " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001218
shahshreyafac62b12015-01-20 16:16:13 -08001219 utilities.assert_equals(
1220 expect=main.TRUE,
1221 actual=result,
1222 onpass="ONOS" +
1223 " Topology matches MN Topology",
1224 onfail="ONOS" +
1225 " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001226
shahshreyafac62b12015-01-20 16:16:13 -08001227 TopologyCheck = TopologyCheck and result
1228 utilities.assert_equals(
1229 expect=main.TRUE,
1230 actual=TopologyCheck,
1231 onpass="Topology checks passed",
1232 onfail="Topology checks failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001233
shahshreyafac62b12015-01-20 16:16:13 -08001234 def CASE7( self, main ):
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001235 """
1236 Link discovery test case. Checks if ONOS can discover a link
1237 down or up properly.
1238 """
1239
Jon Hallb87f3db2015-07-06 03:10:27 -07001240 from sts.topology.teston_topology import TestONTopology
1241
shahshreyafac62b12015-01-20 16:16:13 -08001242 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -08001243
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001244 main.log.report( "This testscase is killing a link to ensure that" +
1245 " link discovery is consistent" )
shahshreyafac62b12015-01-20 16:16:13 -08001246 main.log.report( "__________________________________" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001247 main.log.report( "Killing a link to ensure that link discovery" +
1248 " is consistent" )
1249 main.case( "Killing a link to Ensure that Link Discovery" +
1250 "is Working Properly" )
shahshreyafac62b12015-01-20 16:16:13 -08001251 """
1252 main.step( "Start continuous pings" )
shahshreya4e13a062014-11-11 16:46:18 -08001253
shahshreyafac62b12015-01-20 16:16:13 -08001254 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
1255 target=main.params[ 'PING' ][ 'target1' ],
1256 pingTime=500 )
1257 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
1258 target=main.params[ 'PING' ][ 'target2' ],
1259 pingTime=500 )
1260 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
1261 target=main.params[ 'PING' ][ 'target3' ],
1262 pingTime=500 )
1263 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
1264 target=main.params[ 'PING' ][ 'target4' ],
1265 pingTime=500 )
1266 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
1267 target=main.params[ 'PING' ][ 'target5' ],
1268 pingTime=500 )
1269 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
1270 target=main.params[ 'PING' ][ 'target6' ],
1271 pingTime=500 )
1272 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
1273 target=main.params[ 'PING' ][ 'target7' ],
1274 pingTime=500 )
1275 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
1276 target=main.params[ 'PING' ][ 'target8' ],
1277 pingTime=500 )
1278 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
1279 target=main.params[ 'PING' ][ 'target9' ],
1280 pingTime=500 )
1281 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
1282 target=main.params[ 'PING' ][ 'target10' ],
1283 pingTime=500 )
1284 """
1285 main.step( "Determine the current number of switches and links" )
1286 topologyOutput = main.ONOS2.topology()
1287 topologyResult = main.ONOS1.getTopology( topologyOutput )
shahshreyaa47ebf42015-05-20 13:29:18 -07001288 activeSwitches = topologyResult[ 'devices' ]
1289 links = topologyResult[ 'links' ]
shahshreyafac62b12015-01-20 16:16:13 -08001290 print "activeSwitches = ", type( activeSwitches )
1291 print "links = ", type( links )
1292 main.log.info(
1293 "Currently there are %s switches and %s links" %
1294 ( str( activeSwitches ), str( links ) ) )
1295
1296 main.step( "Kill Link between s3 and s28" )
1297 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
1298 time.sleep( linkSleep )
1299 topologyOutput = main.ONOS2.topology()
1300 LinkDown = main.ONOS1.checkStatus(
1301 topologyOutput, activeSwitches, str(
1302 int( links ) - 2 ) )
1303 if LinkDown == main.TRUE:
1304 main.log.report( "Link Down discovered properly" )
1305 utilities.assert_equals(
1306 expect=main.TRUE,
1307 actual=LinkDown,
1308 onpass="Link Down discovered properly",
1309 onfail="Link down was not discovered in " +
1310 str( linkSleep ) +
1311 " seconds" )
1312
1313 # Check ping result here..add code for it
1314
1315 main.step( "Bring link between s3 and s28 back up" )
1316 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
1317 time.sleep( linkSleep )
1318 topologyOutput = main.ONOS2.topology()
1319 LinkUp = main.ONOS1.checkStatus(
1320 topologyOutput,
1321 activeSwitches,
1322 str( links ) )
1323 if LinkUp == main.TRUE:
1324 main.log.report( "Link up discovered properly" )
1325 utilities.assert_equals(
1326 expect=main.TRUE,
1327 actual=LinkUp,
1328 onpass="Link up discovered properly",
1329 onfail="Link up was not discovered in " +
1330 str( linkSleep ) +
1331 " seconds" )
1332
1333 # NOTE Check ping result here..add code for it
1334
1335 main.step( "Compare ONOS Topology to MN Topology" )
Jon Hallb87f3db2015-07-06 03:10:27 -07001336 Topo = TestONTopology(
1337 main.Mininet1,
1338 ctrls ) # can also add Intent API info for intent operations
1339 MNTopo = Topo
1340 TopologyCheck = main.TRUE
shahshreyafac62b12015-01-20 16:16:13 -08001341
1342 devicesJson = main.ONOS2.devices()
1343 linksJson = main.ONOS2.links()
1344 portsJson = main.ONOS2.ports()
1345
1346 result1 = main.Mininet1.compareSwitches(
Jon Hallb87f3db2015-07-06 03:10:27 -07001347 MNTopo,
1348 json.loads( devicesJson ) )
shahshreyafac62b12015-01-20 16:16:13 -08001349 result2 = main.Mininet1.compareLinks(
Jon Hallb87f3db2015-07-06 03:10:27 -07001350 MNTopo,
1351 json.loads( linksJson ) )
1352 result3 = main.Mininet1.comparePorts( MNTopo, json.loads( portsJson ) )
shahshreyafac62b12015-01-20 16:16:13 -08001353
Jon Hallb87f3db2015-07-06 03:10:27 -07001354 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001355 result = result1 and result2
1356 print "***********************"
shahshreyafac62b12015-01-20 16:16:13 -08001357
shahshreya4e13a062014-11-11 16:46:18 -08001358 if result == main.TRUE:
shahshreyafac62b12015-01-20 16:16:13 -08001359 main.log.report( "ONOS" + " Topology matches MN Topology" )
1360 utilities.assert_equals(
1361 expect=main.TRUE,
1362 actual=result,
1363 onpass="ONOS" +
1364 " Topology matches MN Topology",
1365 onfail="ONOS" +
1366 " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001367
shahshreyafac62b12015-01-20 16:16:13 -08001368 TopologyCheck = TopologyCheck and result
1369 utilities.assert_equals(
1370 expect=main.TRUE,
1371 actual=TopologyCheck,
1372 onpass="Topology checks passed",
1373 onfail="Topology checks failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001374
shahshreyafac62b12015-01-20 16:16:13 -08001375 result = LinkDown and LinkUp and TopologyCheck
1376 utilities.assert_equals( expect=main.TRUE, actual=result,
shahshreya9294c8d2015-01-21 15:54:16 -08001377 onpass="Link failure is discovered correctly",
1378 onfail="Link Discovery failed" )
shahshreyafac62b12015-01-20 16:16:13 -08001379
1380 def CASE8( self ):
1381 """
shahshreya82ecd282015-02-05 16:48:03 -08001382 Intent removal
shahshreyafac62b12015-01-20 16:16:13 -08001383 """
Jon Hallb87f3db2015-07-06 03:10:27 -07001384 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001385 main.log.report( "This testcase removes any previously added intents" +
shahshreya82ecd282015-02-05 16:48:03 -08001386 " before adding any new set of intents" )
shahshreyafac62b12015-01-20 16:16:13 -08001387 main.log.report( "__________________________________" )
shahshreya82ecd282015-02-05 16:48:03 -08001388 main.log.info( "intent removal" )
1389 main.case( "Removing installed intents" )
shahshreyafac62b12015-01-20 16:16:13 -08001390 main.step( "Obtain the intent id's" )
shahshreya234a1682015-05-27 15:41:56 -07001391 currentIntents = main.ONOS2.intents( jsonFormat=False )
1392 main.log.info( "intent_result = " + currentIntents )
1393 intentLinewise = currentIntents.split( "\n" )
shahshreyafac62b12015-01-20 16:16:13 -08001394
shahshreyadcb08e82015-02-25 10:16:42 -08001395 intentList = [line for line in intentLinewise \
1396 if line.startswith( "id=")]
1397 intentids = [line.split( "," )[ 0 ].split( "=" )[ 1 ] for line in \
1398 intentList]
shahshreya4e13a062014-11-11 16:46:18 -08001399 for id in intentids:
1400 print "id = ", id
shahshreyafac62b12015-01-20 16:16:13 -08001401
1402 main.step(
1403 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -08001404 for id in intentids:
shahshreyaa47ebf42015-05-20 13:29:18 -07001405 main.ONOS2.removeIntent( intentId=id ,purge=True)
shahshreyae6c7cf42014-11-26 16:39:01 -08001406
shahshreya234a1682015-05-27 15:41:56 -07001407 remainingIntents = main.ONOS2.intents( jsonFormat=False )
1408 main.log.info( "intent_result = " + remainingIntents )
1409 if remainingIntents:
1410 main.log.info( "There are still remaining intents " )
1411 intentResult = main.FALSE
1412 else:
1413 intentResult = main.TRUE
1414
1415 intentList = [line for line in remainingIntents.split( "\n" ) \
shahshreyadcb08e82015-02-25 10:16:42 -08001416 if line.startswith( "id=")]
1417 intentState = [line.split( "," )[ 1 ].split( "=" )[ 1 ] for line in \
1418 intentList]
1419 for state in intentState:
1420 print state
1421
shahshreya234a1682015-05-27 15:41:56 -07001422 case8Result = main.TRUE
shahshreyadcb08e82015-02-25 10:16:42 -08001423 for state in intentState:
1424 if state != 'WITHDRAWN':
1425 case8Result = main.FALSE
1426 break
shahshreyafac62b12015-01-20 16:16:13 -08001427
1428 PingResult = main.TRUE
shahshreya234a1682015-05-27 15:41:56 -07001429 """
shahshreyafac62b12015-01-20 16:16:13 -08001430 if case8Result == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001431 i = 8
shahshreyafac62b12015-01-20 16:16:13 -08001432 while i < 18:
1433 main.log.info(
1434 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1435 ping = main.Mininet1.pingHost(
1436 src="h" + str( i ), target="h" + str( i + 10 ) )
1437 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001438 i = 19
shahshreyafac62b12015-01-20 16:16:13 -08001439 PingResult = PingResult and main.TRUE
1440 elif ping == main.FALSE:
1441 i += 1
1442 PingResult = PingResult and main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -08001443 else:
shahshreyafac62b12015-01-20 16:16:13 -08001444 main.log.info( "Unknown error" )
1445 PingResult = main.ERROR
shahshreya234a1682015-05-27 15:41:56 -07001446
shahshreyafac62b12015-01-20 16:16:13 -08001447 # Note: If the ping result failed, that means the intents have been
1448 # withdrawn correctly.
1449 if PingResult == main.TRUE:
shahshreya82ecd282015-02-05 16:48:03 -08001450 main.log.report( "Installed intents have not been withdrawn correctly" )
shahshreyafac62b12015-01-20 16:16:13 -08001451 # main.cleanup()
1452 # main.exit()
1453 if PingResult == main.FALSE:
shahshreya82ecd282015-02-05 16:48:03 -08001454 main.log.report( "Installed intents have been withdrawn correctly" )
shahshreya234a1682015-05-27 15:41:56 -07001455 """
shahshreya4e13a062014-11-11 16:46:18 -08001456
shahshreya234a1682015-05-27 15:41:56 -07001457 if case8Result:
shahshreyafac62b12015-01-20 16:16:13 -08001458 main.log.report( "Intent removal successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001459 else:
shahshreyafac62b12015-01-20 16:16:13 -08001460 main.log.report( "Intent removal failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001461
shahshreya234a1682015-05-27 15:41:56 -07001462 utilities.assert_equals( expect=main.TRUE, actual=case8Result,
shahshreya9294c8d2015-01-21 15:54:16 -08001463 onpass="Intent removal test passed",
1464 onfail="Intent removal test failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001465
shahshreyafac62b12015-01-20 16:16:13 -08001466 def CASE9( self ):
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001467 """
1468 Testing Point intents
1469 """
shahshreyafac62b12015-01-20 16:16:13 -08001470 main.log.report(
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001471 "This test case adds point intents and then does pingall" )
shahshreyafac62b12015-01-20 16:16:13 -08001472 main.log.report( "__________________________________" )
1473 main.log.info( "Adding point intents" )
1474 main.case(
shahshreya71162c62015-01-23 15:31:16 -08001475 "Adding bidirectional point for mn hosts" +
1476 "( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22, " +
1477 "h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001478 macsDict = {}
1479 for i in range( 1,29 ):
1480 macsDict[ 'h' + str( i ) ]= main.Mininet1.getMacAddress( host='h'+ str( i ) )
1481 print macsDict
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001482 main.step( "Add point intents for mn hosts h8 and h18 or" +
1483 "ONOS hosts h8 and h12" )
shahshreya3dc3ce62015-01-22 13:31:59 -08001484 # main.step(var1)
shahshreyafac62b12015-01-20 16:16:13 -08001485 ptpIntentResult = main.ONOS2.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -07001486 ingressDevice="of:0000000000003008/1",
1487 egressDevice="of:0000000000006018/1",
1488 ethType='IPV4',
1489 ethSrc=macsDict.get( 'h8' ))
shahshreyafac62b12015-01-20 16:16:13 -08001490 if ptpIntentResult == main.TRUE:
1491 getIntentResult = main.ONOS2.intents()
1492 main.log.info( "Point to point intent install successful" )
1493 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001494
shahshreyafac62b12015-01-20 16:16:13 -08001495 ptpIntentResult = main.ONOS2.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -07001496 ingressDevice="of:0000000000006018/1",
1497 egressDevice="of:0000000000003008/1",
1498 ethType='IPV4',
1499 ethSrc=macsDict.get( 'h18' ))
shahshreyafac62b12015-01-20 16:16:13 -08001500 if ptpIntentResult == main.TRUE:
1501 getIntentResult = main.ONOS2.intents()
1502 main.log.info( "Point to point intent install successful" )
1503 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001504
shahshreya9294c8d2015-01-21 15:54:16 -08001505 var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
1506 main.step(var2)
shahshreyafac62b12015-01-20 16:16:13 -08001507 ptpIntentResult = main.ONOS2.addPointIntent(
1508 "of:0000000000003009/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001509 "of:0000000000006019/1",
1510 ethType='IPV4',
1511 ethSrc=macsDict.get( 'h9' ))
shahshreyafac62b12015-01-20 16:16:13 -08001512 if ptpIntentResult == main.TRUE:
1513 getIntentResult = main.ONOS2.intents()
1514 main.log.info( "Point to point intent install successful" )
1515 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001516
shahshreyafac62b12015-01-20 16:16:13 -08001517 ptpIntentResult = main.ONOS2.addPointIntent(
1518 "of:0000000000006019/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001519 "of:0000000000003009/1",
1520 ethType='IPV4',
1521 ethSrc=macsDict.get( 'h19' ))
shahshreyafac62b12015-01-20 16:16:13 -08001522 if ptpIntentResult == main.TRUE:
1523 getIntentResult = main.ONOS2.intents()
1524 main.log.info( "Point to point intent install successful" )
1525 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001526
shahshreya9294c8d2015-01-21 15:54:16 -08001527 var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
1528 main.step(var3)
shahshreyafac62b12015-01-20 16:16:13 -08001529 ptpIntentResult = main.ONOS2.addPointIntent(
1530 "of:0000000000003010/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001531 "of:0000000000006020/1",
1532 ethType='IPV4',
1533 ethSrc=macsDict.get( 'h10' ))
1534
shahshreyafac62b12015-01-20 16:16:13 -08001535 if ptpIntentResult == main.TRUE:
1536 getIntentResult = main.ONOS2.intents()
1537 main.log.info( "Point to point intent install successful" )
1538 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001539
shahshreyafac62b12015-01-20 16:16:13 -08001540 ptpIntentResult = main.ONOS2.addPointIntent(
1541 "of:0000000000006020/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001542 "of:0000000000003010/1",
1543 ethType='IPV4',
1544 ethSrc=macsDict.get( 'h20' ))
1545
shahshreyafac62b12015-01-20 16:16:13 -08001546 if ptpIntentResult == main.TRUE:
1547 getIntentResult = main.ONOS2.intents()
1548 main.log.info( "Point to point intent install successful" )
1549 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001550
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001551 var4 = "Add point intents for mininet hosts h11 and h21 or" +\
1552 " ONOS hosts hB and h15"
shahshreya9294c8d2015-01-21 15:54:16 -08001553 main.case(var4)
shahshreyafac62b12015-01-20 16:16:13 -08001554 ptpIntentResult = main.ONOS2.addPointIntent(
1555 "of:0000000000003011/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001556 "of:0000000000006021/1",
1557 ethType='IPV4',
1558 ethSrc=macsDict.get( 'h11' ))
1559
shahshreyafac62b12015-01-20 16:16:13 -08001560 if ptpIntentResult == main.TRUE:
1561 getIntentResult = main.ONOS2.intents()
1562 main.log.info( "Point to point intent install successful" )
1563 # main.log.info( getIntentResult )
1564
1565 ptpIntentResult = main.ONOS2.addPointIntent(
1566 "of:0000000000006021/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001567 "of:0000000000003011/1",
1568 ethType='IPV4',
1569 ethSrc=macsDict.get( 'h21' ))
1570
shahshreyafac62b12015-01-20 16:16:13 -08001571 if ptpIntentResult == main.TRUE:
1572 getIntentResult = main.ONOS2.intents()
1573 main.log.info( "Point to point intent install successful" )
1574 # main.log.info( getIntentResult )
1575
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001576 var5 = "Add point intents for mininet hosts h12 and h22 " +\
1577 "ONOS hosts hC and h16"
shahshreya9294c8d2015-01-21 15:54:16 -08001578 main.case(var5)
shahshreyafac62b12015-01-20 16:16:13 -08001579 ptpIntentResult = main.ONOS2.addPointIntent(
1580 "of:0000000000003012/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001581 "of:0000000000006022/1",
1582 ethType='IPV4',
1583 ethSrc=macsDict.get( 'h12' ))
1584
shahshreyafac62b12015-01-20 16:16:13 -08001585 if ptpIntentResult == main.TRUE:
1586 getIntentResult = main.ONOS2.intents()
1587 main.log.info( "Point to point intent install successful" )
1588 # main.log.info( getIntentResult )
1589
1590 ptpIntentResult = main.ONOS2.addPointIntent(
1591 "of:0000000000006022/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001592 "of:0000000000003012/1",
1593 ethType='IPV4',
1594 ethSrc=macsDict.get( 'h22' ))
1595
shahshreyafac62b12015-01-20 16:16:13 -08001596 if ptpIntentResult == main.TRUE:
1597 getIntentResult = main.ONOS2.intents()
1598 main.log.info( "Point to point intent install successful" )
1599 # main.log.info( getIntentResult )
1600
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001601 var6 = "Add point intents for mininet hosts h13 and h23 or" +\
1602 " ONOS hosts hD and h17"
shahshreya9294c8d2015-01-21 15:54:16 -08001603 main.case(var6)
shahshreyafac62b12015-01-20 16:16:13 -08001604 ptpIntentResult = main.ONOS2.addPointIntent(
1605 "of:0000000000003013/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001606 "of:0000000000006023/1",
1607 ethType='IPV4',
1608 ethSrc=macsDict.get( 'h13' ))
1609
shahshreyafac62b12015-01-20 16:16:13 -08001610 if ptpIntentResult == main.TRUE:
1611 getIntentResult = main.ONOS2.intents()
1612 main.log.info( "Point to point intent install successful" )
1613 # main.log.info( getIntentResult )
1614
1615 ptpIntentResult = main.ONOS2.addPointIntent(
1616 "of:0000000000006023/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001617 "of:0000000000003013/1",
1618 ethType='IPV4',
1619 ethSrc=macsDict.get( 'h23' ))
1620
shahshreyafac62b12015-01-20 16:16:13 -08001621 if ptpIntentResult == main.TRUE:
1622 getIntentResult = main.ONOS2.intents()
1623 main.log.info( "Point to point intent install successful" )
1624 # main.log.info( getIntentResult )
1625
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001626 var7 = "Add point intents for mininet hosts h14 and h24 or" +\
1627 " ONOS hosts hE and h18"
shahshreya9294c8d2015-01-21 15:54:16 -08001628 main.case(var7)
shahshreyafac62b12015-01-20 16:16:13 -08001629 ptpIntentResult = main.ONOS2.addPointIntent(
1630 "of:0000000000003014/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001631 "of:0000000000006024/1",
1632 ethType='IPV4',
1633 ethSrc=macsDict.get( 'h14' ))
1634
shahshreyafac62b12015-01-20 16:16:13 -08001635 if ptpIntentResult == main.TRUE:
1636 getIntentResult = main.ONOS2.intents()
1637 main.log.info( "Point to point intent install successful" )
1638 # main.log.info( getIntentResult )
1639
1640 ptpIntentResult = main.ONOS2.addPointIntent(
1641 "of:0000000000006024/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001642 "of:0000000000003014/1",
1643 ethType='IPV4',
1644 ethSrc=macsDict.get( 'h24' ))
1645
shahshreyafac62b12015-01-20 16:16:13 -08001646 if ptpIntentResult == main.TRUE:
1647 getIntentResult = main.ONOS2.intents()
1648 main.log.info( "Point to point intent install successful" )
1649 # main.log.info( getIntentResult )
1650
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001651 var8 = "Add point intents for mininet hosts h15 and h25 or" +\
1652 " ONOS hosts hF and h19"
shahshreya9294c8d2015-01-21 15:54:16 -08001653 main.case(var8)
shahshreyafac62b12015-01-20 16:16:13 -08001654 ptpIntentResult = main.ONOS2.addPointIntent(
1655 "of:0000000000003015/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001656 "of:0000000000006025/1",
1657 ethType='IPV4',
1658 ethSrc=macsDict.get( 'h15' ))
1659
shahshreyafac62b12015-01-20 16:16:13 -08001660 if ptpIntentResult == main.TRUE:
1661 getIntentResult = main.ONOS2.intents()
1662 main.log.info( "Point to point intent install successful" )
1663 # main.log.info( getIntentResult )
1664
1665 ptpIntentResult = main.ONOS2.addPointIntent(
1666 "of:0000000000006025/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001667 "of:0000000000003015/1",
1668 ethType='IPV4',
1669 ethSrc=macsDict.get( 'h25' ))
1670
shahshreyafac62b12015-01-20 16:16:13 -08001671 if ptpIntentResult == main.TRUE:
1672 getIntentResult = main.ONOS2.intents()
1673 main.log.info( "Point to point intent install successful" )
1674 # main.log.info( getIntentResult )
1675
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001676 var9 = "Add intents for mininet hosts h16 and h26 or" +\
1677 " ONOS hosts h10 and h1A"
shahshreya9294c8d2015-01-21 15:54:16 -08001678 main.case(var9)
shahshreyafac62b12015-01-20 16:16:13 -08001679 ptpIntentResult = main.ONOS2.addPointIntent(
1680 "of:0000000000003016/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001681 "of:0000000000006026/1",
1682 ethType='IPV4',
1683 ethSrc=macsDict.get( 'h16' ))
1684
shahshreyafac62b12015-01-20 16:16:13 -08001685 if ptpIntentResult == main.TRUE:
1686 getIntentResult = main.ONOS2.intents()
1687 main.log.info( "Point to point intent install successful" )
1688 # main.log.info( getIntentResult )
1689
1690 ptpIntentResult = main.ONOS2.addPointIntent(
1691 "of:0000000000006026/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001692 "of:0000000000003016/1",
1693 ethType='IPV4',
1694 ethSrc=macsDict.get( 'h26' ))
1695
shahshreyafac62b12015-01-20 16:16:13 -08001696 if ptpIntentResult == main.TRUE:
1697 getIntentResult = main.ONOS2.intents()
1698 main.log.info( "Point to point intent install successful" )
1699 # main.log.info( getIntentResult )
1700
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001701 var10 = "Add point intents for mininet hosts h17 and h27 or" +\
1702 " ONOS hosts h11 and h1B"
shahshreya9294c8d2015-01-21 15:54:16 -08001703 main.case(var10)
shahshreyafac62b12015-01-20 16:16:13 -08001704 ptpIntentResult = main.ONOS2.addPointIntent(
1705 "of:0000000000003017/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001706 "of:0000000000006027/1",
1707 ethType='IPV4',
1708 ethSrc=macsDict.get( 'h17' ))
1709
shahshreyafac62b12015-01-20 16:16:13 -08001710 if ptpIntentResult == main.TRUE:
1711 getIntentResult = main.ONOS2.intents()
1712 main.log.info( "Point to point intent install successful" )
shahshreyadcb08e82015-02-25 10:16:42 -08001713 #main.log.info( getIntentResult )
shahshreyafac62b12015-01-20 16:16:13 -08001714
1715 ptpIntentResult = main.ONOS2.addPointIntent(
1716 "of:0000000000006027/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001717 "of:0000000000003017/1",
1718 ethType='IPV4',
1719 ethSrc=macsDict.get( 'h27' ))
1720
shahshreyafac62b12015-01-20 16:16:13 -08001721 if ptpIntentResult == main.TRUE:
1722 getIntentResult = main.ONOS2.intents()
1723 main.log.info( "Point to point intent install successful" )
shahshreyadcb08e82015-02-25 10:16:42 -08001724 #main.log.info( getIntentResult )
shahshreyafac62b12015-01-20 16:16:13 -08001725
1726 print(
1727 "___________________________________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001728
1729 flowHandle = main.ONOS2.flows()
shahshreya82ecd282015-02-05 16:48:03 -08001730 #main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001731
1732 count = 1
1733 i = 8
shahshreyafac62b12015-01-20 16:16:13 -08001734 PingResult = main.TRUE
1735 while i < 18:
1736 main.log.info(
1737 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1738 ping = main.Mininet1.pingHost(
1739 src="h" + str( i ), target="h" + str( i + 10 ) )
1740 if ping == main.FALSE and count < 5:
1741 count += 1
1742 # i = 8
1743 PingResult = main.FALSE
1744 main.log.report( "Ping between h" +
1745 str( i ) +
1746 " and h" +
1747 str( i +
1748 10 ) +
1749 " failed. Making attempt number " +
1750 str( count ) +
1751 " in 2 seconds" )
1752 time.sleep( 2 )
1753 elif ping == main.FALSE:
1754 main.log.report( "All ping attempts between h" +
1755 str( i ) +
1756 " and h" +
1757 str( i +
1758 10 ) +
1759 "have failed" )
1760 i = 19
1761 PingResult = main.FALSE
1762 elif ping == main.TRUE:
1763 main.log.info( "Ping test between h" +
1764 str( i ) +
1765 " and h" +
1766 str( i +
1767 10 ) +
1768 "passed!" )
1769 i += 1
1770 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001771 else:
shahshreyafac62b12015-01-20 16:16:13 -08001772 main.log.info( "Unknown error" )
1773 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001774
shahshreyafac62b12015-01-20 16:16:13 -08001775 if PingResult == main.FALSE:
1776 main.log.report(
1777 "Point intents have not ben installed correctly. Cleaning up" )
1778 # main.cleanup()
1779 # main.exit()
1780 if PingResult == main.TRUE:
1781 main.log.report( "Point Intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001782
shahshreyafac62b12015-01-20 16:16:13 -08001783 case9Result = PingResult
1784 utilities.assert_equals(
1785 expect=main.TRUE,
1786 actual=case9Result,
1787 onpass="Point intents addition and Pingall Test successful",
1788 onfail="Point intents addition and Pingall Test NOT successful" )