blob: 3a28e2bf4d72f9f72382d4dde8bacace59976918 [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 ):
20 """
shahshreya4e13a062014-11-11 16:46:18 -080021 Startup sequence:
shahshreyae6c7cf42014-11-26 16:39:01 -080022 cell <name>
23 onos-verify-cell
24 onos-remove-raft-log
shahshreya4e13a062014-11-11 16:46:18 -080025 git pull
26 mvn clean install
27 onos-package
shahshreya4e13a062014-11-11 16:46:18 -080028 onos-install -f
29 onos-wait-for-start
shahshreyafac62b12015-01-20 16:16:13 -080030 """
31 cellName = main.params[ 'ENV' ][ 'cellName' ]
32 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreyae6c7cf42014-11-26 16:39:01 -080033
shahshreyafac62b12015-01-20 16:16:13 -080034 main.case( "Setting up test environment" )
35 main.log.report(
36 "This testcase is testing setting up test environment" )
37 main.log.report( "__________________________________" )
shahshreyae6c7cf42014-11-26 16:39:01 -080038
shahshreyafac62b12015-01-20 16:16:13 -080039 main.step( "Applying cell variable to environment" )
40 cellResult = main.ONOSbench.setCell( cellName )
41 verifyResult = main.ONOSbench.verifyCell()
42
43 main.step( "Removing raft logs before a clen installation of ONOS" )
44 main.ONOSbench.onosRemoveRaftLogs()
45
46 main.step( "Git checkout and pull master and get version" )
47 main.ONOSbench.gitCheckout( "master" )
48 gitPullResult = main.ONOSbench.gitPull()
49 main.log.info( "git_pull_result = " + gitPullResult )
50 main.ONOSbench.getVersion( report=True )
51
52 if gitPullResult == 1:
53 main.step( "Using mvn clean & install" )
54 main.ONOSbench.cleanInstall()
55 elif gitPullResult == 0:
56 main.log.report(
57 "Git Pull Failed, look into logs for detailed reason" )
shahshreya0e81ed92014-12-08 16:57:17 -080058 main.cleanup()
shahshreyafac62b12015-01-20 16:16:13 -080059 main.exit()
shahshreya4e13a062014-11-11 16:46:18 -080060
shahshreyafac62b12015-01-20 16:16:13 -080061 main.step( "Creating ONOS package" )
62 packageResult = main.ONOSbench.onosPackage()
shahshreya4e13a062014-11-11 16:46:18 -080063
shahshreyafac62b12015-01-20 16:16:13 -080064 main.step( "Installing ONOS package" )
65 onosInstallResult = main.ONOSbench.onosInstall()
66 if onosInstallResult == main.TRUE:
67 main.log.report( "Installing ONOS package successful" )
shahshreya4e13a062014-11-11 16:46:18 -080068 else:
shahshreyafac62b12015-01-20 16:16:13 -080069 main.log.report( "Installing ONOS package failed" )
shahshreya4e13a062014-11-11 16:46:18 -080070
shahshreyafac62b12015-01-20 16:16:13 -080071 onos1Isup = main.ONOSbench.isup()
72 if onos1Isup == main.TRUE:
73 main.log.report( "ONOS instance is up and ready" )
shahshreya4e13a062014-11-11 16:46:18 -080074 else:
shahshreyafac62b12015-01-20 16:16:13 -080075 main.log.report( "ONOS instance may not be up" )
shahshreya4e13a062014-11-11 16:46:18 -080076
shahshreyafac62b12015-01-20 16:16:13 -080077 main.step( "Starting ONOS service" )
78 startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -080079
shahshreyafac62b12015-01-20 16:16:13 -080080 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
81
82 case1Result = ( packageResult and
83 cellResult and verifyResult
84 and onosInstallResult and
85 onos1Isup and startResult )
86 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
shahshreya9294c8d2015-01-21 15:54:16 -080087 onpass="Test startup successful",
88 onfail="Test startup NOT successful" )
shahshreyafac62b12015-01-20 16:16:13 -080089
90 def CASE2( self, main ):
91 """
shahshreya0e81ed92014-12-08 16:57:17 -080092 Switch Down
shahshreyafac62b12015-01-20 16:16:13 -080093 """
94 # NOTE: You should probably run a topology check after this
95 import time
shahshreya0e81ed92014-12-08 16:57:17 -080096
shahshreyafac62b12015-01-20 16:16:13 -080097 main.case( "Switch down discovery" )
98 main.log.report( "This testcase is testing a switch down discovery" )
99 main.log.report( "__________________________________" )
100
101 switchSleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
shahshreya0e81ed92014-12-08 16:57:17 -0800102
103 description = "Killing a switch to ensure it is discovered correctly"
shahshreyafac62b12015-01-20 16:16:13 -0800104 main.log.report( description )
105 main.case( description )
shahshreya0e81ed92014-12-08 16:57:17 -0800106
shahshreyafac62b12015-01-20 16:16:13 -0800107 # TODO: Make this switch parameterizable
108 main.step( "Kill s28 " )
109 main.log.report( "Deleting s28" )
110 # FIXME: use new dynamic topo functions
111 main.Mininet1.delSwitch( "s28" )
112 main.log.info(
113 "Waiting " +
114 str( switchSleep ) +
115 " seconds for switch down to be discovered" )
116 time.sleep( switchSleep )
117 # Peek at the deleted switch
118 device = main.ONOS2.getDevice( dpid="0028" )
shahshreya0e81ed92014-12-08 16:57:17 -0800119 print "device = ", device
shahshreyafac62b12015-01-20 16:16:13 -0800120 if device[ u'available' ] == 'False':
121 case2Result = main.FALSE
shahshreya0e81ed92014-12-08 16:57:17 -0800122 else:
shahshreyafac62b12015-01-20 16:16:13 -0800123 case2Result = main.TRUE
124 utilities.assert_equals( expect=main.TRUE, actual=case2Result,
shahshreya9294c8d2015-01-21 15:54:16 -0800125 onpass="Switch down discovery successful",
126 onfail="Switch down discovery failed" )
shahshreya0e81ed92014-12-08 16:57:17 -0800127
shahshreyafac62b12015-01-20 16:16:13 -0800128 def CASE11( self, main ):
129 """
shahshreya4e13a062014-11-11 16:46:18 -0800130 Cleanup sequence:
shahshreyafac62b12015-01-20 16:16:13 -0800131 onos-service <nodeIp> stop
shahshreya4e13a062014-11-11 16:46:18 -0800132 onos-uninstall
133
134 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800135
shahshreyafac62b12015-01-20 16:16:13 -0800136 """
137 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800138
shahshreyafac62b12015-01-20 16:16:13 -0800139 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800140
shahshreyafac62b12015-01-20 16:16:13 -0800141 main.step( "Testing ONOS kill function" )
142 killResult = main.ONOSbench.onosKill( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800143
shahshreyafac62b12015-01-20 16:16:13 -0800144 main.step( "Stopping ONOS service" )
145 stopResult = main.ONOSbench.onosStop( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800146
shahshreyafac62b12015-01-20 16:16:13 -0800147 main.step( "Uninstalling ONOS service" )
148 uninstallResult = main.ONOSbench.onosUninstall()
shahshreya4e13a062014-11-11 16:46:18 -0800149
shahshreyafac62b12015-01-20 16:16:13 -0800150 case11Result = killResult and stopResult and uninstallResult
151 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
shahshreya9294c8d2015-01-21 15:54:16 -0800152 onpass="Cleanup successful",
153 onfail="Cleanup failed" )
shahshreyafac62b12015-01-20 16:16:13 -0800154
155 def CASE3( self, main ):
156 """
shahshreya4e13a062014-11-11 16:46:18 -0800157 Test 'onos' command and its functionality in driver
shahshreyafac62b12015-01-20 16:16:13 -0800158 """
159 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800160
shahshreyafac62b12015-01-20 16:16:13 -0800161 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800162
shahshreyafac62b12015-01-20 16:16:13 -0800163 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800164 cmdstr1 = "system:name"
shahshreyafac62b12015-01-20 16:16:13 -0800165 cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
166 main.log.info( "onos command returned: " + cmdResult1 )
shahshreya4e13a062014-11-11 16:46:18 -0800167
shahshreyafac62b12015-01-20 16:16:13 -0800168 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800169 cmdstr2 = "onos:topology"
shahshreyafac62b12015-01-20 16:16:13 -0800170 cmdResult2 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
171 main.log.info( "onos command returned: " + cmdResult2 )
shahshreya4e13a062014-11-11 16:46:18 -0800172
shahshreyafac62b12015-01-20 16:16:13 -0800173 def CASE20( self ):
174 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800175 Exit from mininet cli
176 reinstall ONOS
shahshreyafac62b12015-01-20 16:16:13 -0800177 """
178 cellName = main.params[ 'ENV' ][ 'cellName' ]
179 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800180
shahshreyafac62b12015-01-20 16:16:13 -0800181 main.log.report( "This testcase exits the mininet cli and reinstalls\
182 ONOS to switch over to Packet Optical topology" )
183 main.log.report( "_____________________________________________" )
184 main.case( "Disconnecting mininet and restarting ONOS" )
185 main.step( "Disconnecting mininet and restarting ONOS" )
186 mininetDisconnect = main.Mininet1.disconnect()
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800187
shahshreyafac62b12015-01-20 16:16:13 -0800188 main.step( "Removing raft logs before a clen installation of ONOS" )
189 main.ONOSbench.onosRemoveRaftLogs()
shahshreyae6c7cf42014-11-26 16:39:01 -0800190
shahshreyafac62b12015-01-20 16:16:13 -0800191 main.step( "Applying cell variable to environment" )
192 cellResult = main.ONOSbench.setCell( cellName )
193 verifyResult = main.ONOSbench.verifyCell()
194
195 onosInstallResult = main.ONOSbench.onosInstall()
196 if onosInstallResult == main.TRUE:
197 main.log.report( "Installing ONOS package successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800198 else:
shahshreyafac62b12015-01-20 16:16:13 -0800199 main.log.report( "Installing ONOS package failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800200
shahshreyafac62b12015-01-20 16:16:13 -0800201 onos1Isup = main.ONOSbench.isup()
202 if onos1Isup == main.TRUE:
203 main.log.report( "ONOS instance is up and ready" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800204 else:
shahshreyafac62b12015-01-20 16:16:13 -0800205 main.log.report( "ONOS instance may not be up" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800206
shahshreyafac62b12015-01-20 16:16:13 -0800207 main.step( "Starting ONOS service" )
208 startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreyae6c7cf42014-11-26 16:39:01 -0800209
shahshreyafac62b12015-01-20 16:16:13 -0800210 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
211 case20Result = mininetDisconnect and cellResult and verifyResult \
212 and onosInstallResult and onos1Isup and \
213 startResult
214 utilities.assert_equals(
215 expect=main.TRUE,
216 actual=case20Result,
217 onpass="Exiting functionality mininet topology and reinstalling \
218 ONOS successful",
219 onfail="Exiting functionality mininet topology and reinstalling \
220 ONOS failed" )
221
222 def CASE21( self, main ):
223 """
224 On ONOS bench, run this command:
225 ./~/ONOS/tools/test/bin/onos-topo-cfg
226 which starts the rest and copies the links
227 json file to the onos instance.
228 Note that in case of Packet Optical, the links are not learnt
229 from the topology, instead the links are learnt
shahshreyae6c7cf42014-11-26 16:39:01 -0800230 from the json config file
shahshreyafac62b12015-01-20 16:16:13 -0800231 """
232 main.log.report(
233 "This testcase starts the packet layer topology and REST" )
234 main.log.report( "_____________________________________________" )
235 main.case( "Starting LINC-OE and other components" )
236 main.step( "Starting LINC-OE and other components" )
237 startConsoleResult = main.LincOE1.startConsole()
238 opticalMnScript = main.LincOE2.runOpticalMnScript()
239 onosTopoCfgResult = main.ONOSbench.runOnosTopoCfg(
240 instanceName=main.params[ 'CTRL' ][ 'ip1' ],
241 jsonFile=main.params[ 'OPTICAL' ][ 'jsonfile' ] )
shahshreyae6c7cf42014-11-26 16:39:01 -0800242
shahshreyafac62b12015-01-20 16:16:13 -0800243 print "start_console_result =", startConsoleResult
244 print "optical_mn_script = ", opticalMnScript
245 print "onos_topo_cfg_result =", onosTopoCfgResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800246
shahshreyafac62b12015-01-20 16:16:13 -0800247 case21Result = startConsoleResult and opticalMnScript and \
248 onosTopoCfgResult
249 utilities.assert_equals(
250 expect=main.TRUE,
251 actual=case21Result,
252 onpass="Packet optical topology spawned successsfully",
253 onfail="Packet optical topology spawning failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800254
shahshreyafac62b12015-01-20 16:16:13 -0800255 def CASE22( self, main ):
256 """
257 Curretly we use, 4 linear switch optical topology and
258 2 packet layer mininet switches each with one host.
259 Therefore, the roadmCount variable = 4,
260 packetLayerSWCount variable = 2 and hostCount = 2
261 and this is hardcoded in the testcase. If the topology changes,
262 these hardcoded values need to be changed
263 """
264 main.log.report(
265 "This testcase compares the optical+packet topology against what\
266 is expected" )
267 main.case( "Topology comparision" )
268 main.step( "Topology comparision" )
269 main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
270 devicesResult = main.ONOS3.devices( jsonFormat=False )
shahshreyae6c7cf42014-11-26 16:39:01 -0800271
shahshreyafac62b12015-01-20 16:16:13 -0800272 print "devices_result = ", devicesResult
273 devicesLinewise = devicesResult.split( "\n" )
274 devicesLinewise = devicesLinewise[ 1:-1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800275 roadmCount = 0
276 packetLayerSWCount = 0
shahshreyafac62b12015-01-20 16:16:13 -0800277 for line in devicesLinewise:
278 components = line.split( "," )
279 availability = components[ 1 ].split( "=" )[ 1 ]
280 type = components[ 3 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800281 if availability == 'true' and type == 'ROADM':
282 roadmCount += 1
shahshreyafac62b12015-01-20 16:16:13 -0800283 elif availability == 'true' and type == 'SWITCH':
shahshreyae6c7cf42014-11-26 16:39:01 -0800284 packetLayerSWCount += 1
285 if roadmCount == 4:
shahshreyafac62b12015-01-20 16:16:13 -0800286 print "Number of Optical Switches = %d and is \
287 correctly detected" % roadmCount
288 main.log.info(
289 "Number of Optical Switches = " +
290 str( roadmCount ) +
291 " and is correctly detected" )
292 opticalSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800293 else:
shahshreyafac62b12015-01-20 16:16:13 -0800294 print "Number of Optical Switches = %d and is wrong" % roadmCount
295 main.log.info(
296 "Number of Optical Switches = " +
297 str( roadmCount ) +
298 " and is wrong" )
299 opticalSWResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800300
301 if packetLayerSWCount == 2:
shahshreyafac62b12015-01-20 16:16:13 -0800302 print "Number of Packet layer or mininet Switches = %d and \
303 is correctly detected" % packetLayerSWCount
304 main.log.info(
305 "Number of Packet layer or mininet Switches = " +
306 str( packetLayerSWCount ) +
307 " and is correctly detected" )
308 packetSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800309 else:
shahshreyafac62b12015-01-20 16:16:13 -0800310 print "Number of Packet layer or mininet Switches = %d and \
311 is wrong" % packetLayerSWCount
312 main.log.info(
313 "Number of Packet layer or mininet Switches = " +
314 str( packetLayerSWCount ) +
315 " and is wrong" )
316 packetSWResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800317 print "_________________________________"
shahshreyafac62b12015-01-20 16:16:13 -0800318
319 linksResult = main.ONOS3.links( jsonFormat=False )
320 print "links_result = ", linksResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800321 print "_________________________________"
shahshreyafac62b12015-01-20 16:16:13 -0800322
323 # NOTE:Since only point intents are added, there is no
324 # requirement to discover the hosts
325 # Therfore, the below portion of the code is commented.
326 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800327 #Discover hosts using pingall
shahshreyafac62b12015-01-20 16:16:13 -0800328 pingallResult = main.LincOE2.pingall()
329
330 hostsResult = main.ONOS3.hosts( jsonFormat=False )
331 main.log.info( "hosts_result = "+hostsResult )
332 main.log.info( "_________________________________" )
333 hostsLinewise = hostsResult.split( "\n" )
334 hostsLinewise = hostsLinewise[ 1:-1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800335 hostCount = 0
shahshreyafac62b12015-01-20 16:16:13 -0800336 for line in hostsLinewise:
337 hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800338 hostCount +=1
339 if hostCount ==2:
340 print "Number of hosts = %d and is correctly detected" %hostCount
shahshreyafac62b12015-01-20 16:16:13 -0800341 main.log.info( "Number of hosts = " + str( hostCount ) +" and \
342 is correctly detected" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800343 hostDiscovery = main.TRUE
344 else:
345 print "Number of hosts = %d and is wrong" %hostCount
shahshreyafac62b12015-01-20 16:16:13 -0800346 main.log.info( "Number of hosts = " + str( hostCount ) +" and \
347 is wrong" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800348 hostDiscovery = main.FALSE
shahshreyafac62b12015-01-20 16:16:13 -0800349 """
350 case22Result = opticalSWResult and packetSWResult
351 utilities.assert_equals(
352 expect=main.TRUE,
353 actual=case22Result,
354 onpass="Packet optical topology discovery successful",
355 onfail="Packet optical topology discovery failed" )
shahshreya0e81ed92014-12-08 16:57:17 -0800356
shahshreyafac62b12015-01-20 16:16:13 -0800357 def CASE23( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800358 import time
shahshreyafac62b12015-01-20 16:16:13 -0800359 """
360 Add bidirectional point intents between 2 packet layer( mininet )
361 devices and
shahshreyae6c7cf42014-11-26 16:39:01 -0800362 ping mininet hosts
shahshreyafac62b12015-01-20 16:16:13 -0800363 """
364 main.log.report(
365 "This testcase adds bidirectional point intents between 2 \
366 packet layer( mininet ) devices and ping mininet hosts" )
367 main.case( "Topology comparision" )
368 main.step( "Adding point intents" )
369 ptpIntentResult = main.ONOS3.addPointIntent(
370 "of:0000ffffffff0001/1",
371 "of:0000ffffffff0002/1" )
372 if ptpIntentResult == main.TRUE:
373 main.ONOS3.intents( jsonFormat=False )
374 main.log.info( "Point to point intent install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800375
shahshreyafac62b12015-01-20 16:16:13 -0800376 ptpIntentResult = main.ONOS3.addPointIntent(
377 "of:0000ffffffff0002/1",
378 "of:0000ffffffff0001/1" )
379 if ptpIntentResult == main.TRUE:
380 main.ONOS3.intents( jsonFormat=False )
381 main.log.info( "Point to point intent install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800382
shahshreyafac62b12015-01-20 16:16:13 -0800383 time.sleep( 10 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800384 flowHandle = main.ONOS3.flows()
shahshreyafac62b12015-01-20 16:16:13 -0800385 main.log.info( "flows :" + flowHandle )
shahshreyae6c7cf42014-11-26 16:39:01 -0800386
387 # Sleep for 30 seconds to provide time for the intent state to change
shahshreyafac62b12015-01-20 16:16:13 -0800388 time.sleep( 30 )
389 intentHandle = main.ONOS3.intents( jsonFormat=False )
390 main.log.info( "intents :" + intentHandle )
391
392 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800393 count = 1
shahshreyafac62b12015-01-20 16:16:13 -0800394 main.log.info( "\n\nh1 is Pinging h2" )
395 ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
396 # ping = main.LincOE2.pinghost()
397 if ping == main.FALSE and count < 5:
398 count += 1
399 PingResult = main.FALSE
400 main.log.info(
401 "Ping between h1 and h2 failed. Making attempt number " +
402 str( count ) +
403 " in 2 seconds" )
404 time.sleep( 2 )
405 elif ping == main.FALSE:
406 main.log.info( "All ping attempts between h1 and h2 have failed" )
407 PingResult = main.FALSE
408 elif ping == main.TRUE:
409 main.log.info( "Ping test between h1 and h2 passed!" )
410 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800411 else:
shahshreyafac62b12015-01-20 16:16:13 -0800412 main.log.info( "Unknown error" )
413 PingResult = main.ERROR
shahshreyae6c7cf42014-11-26 16:39:01 -0800414
shahshreyafac62b12015-01-20 16:16:13 -0800415 if PingResult == main.FALSE:
416 main.log.report(
417 "Point intents for packet optical have not ben installed\
418 correctly. Cleaning up" )
419 if PingResult == main.TRUE:
420 main.log.report(
421 "Point Intents for packet optical have been\
422 installed correctly" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800423
shahshreyafac62b12015-01-20 16:16:13 -0800424 case23Result = PingResult
425 utilities.assert_equals(
426 expect=main.TRUE,
427 actual=case23Result,
428 onpass="Point intents addition for packet optical and\
429 Pingall Test successful",
430 onfail="Point intents addition for packet optical and\
431 Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800432
shahshreyafac62b12015-01-20 16:16:13 -0800433 def CASE24( self, main ):
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800434 import time
435 import json
shahshreyafac62b12015-01-20 16:16:13 -0800436 """
437 Test Rerouting of Packet Optical by bringing a port down
438 ( port 22 ) of a switch( switchID=1 ), so that link
439 ( between switch1 port22 - switch4-port30 ) is inactive
440 and do a ping test. If rerouting is successful,
441 ping should pass. also check the flows
442 """
443 main.log.report(
444 "This testcase tests rerouting and pings mininet hosts" )
445 main.case( "Test rerouting and pings mininet hosts" )
446 main.step( "Bring a port down and verify the link state" )
447 main.LincOE1.portDown( swId="1", ptId="22" )
448 linksNonjson = main.ONOS3.links( jsonFormat=False )
449 main.log.info( "links = " + linksNonjson )
shahshreyae6c7cf42014-11-26 16:39:01 -0800450
shahshreya0e81ed92014-12-08 16:57:17 -0800451 links = main.ONOS3.links()
shahshreyafac62b12015-01-20 16:16:13 -0800452 main.log.info( "links = " + links )
453
454 linksResult = json.loads( links )
455 linksStateResult = main.FALSE
456 for item in linksResult:
457 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
458 'src' ][ 'port' ] == "22":
459 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff04" and item[
460 'dst' ][ 'port' ] == "30":
461 linksState = item[ 'state' ]
462 if linksState == "INACTIVE":
463 main.log.info(
464 "Links state is inactive as expected due to one \
465 of the ports being down" )
466 main.log.report(
467 "Links state is inactive as expected due to one \
468 of the ports being down" )
469 linksStateResult = main.TRUE
shahshreya0e81ed92014-12-08 16:57:17 -0800470 break
471 else:
shahshreyafac62b12015-01-20 16:16:13 -0800472 main.log.info(
473 "Links state is not inactive as expected" )
474 main.log.report(
475 "Links state is not inactive as expected" )
476 linksStateResult = main.FALSE
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800477
shahshreyafac62b12015-01-20 16:16:13 -0800478 print "links_state_result = ", linksStateResult
479 time.sleep( 10 )
shahshreya0e81ed92014-12-08 16:57:17 -0800480 flowHandle = main.ONOS3.flows()
shahshreyafac62b12015-01-20 16:16:13 -0800481 main.log.info( "flows :" + flowHandle )
shahshreya0e81ed92014-12-08 16:57:17 -0800482
shahshreyafac62b12015-01-20 16:16:13 -0800483 main.step( "Verify Rerouting by a ping test" )
484 PingResult = main.TRUE
485 count = 1
486 main.log.info( "\n\nh1 is Pinging h2" )
487 ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
488 # ping = main.LincOE2.pinghost()
489 if ping == main.FALSE and count < 5:
490 count += 1
491 PingResult = main.FALSE
492 main.log.info(
493 "Ping between h1 and h2 failed. Making attempt number " +
494 str( count ) +
495 " in 2 seconds" )
496 time.sleep( 2 )
497 elif ping == main.FALSE:
498 main.log.info( "All ping attempts between h1 and h2 have failed" )
499 PingResult = main.FALSE
500 elif ping == main.TRUE:
501 main.log.info( "Ping test between h1 and h2 passed!" )
502 PingResult = main.TRUE
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800503 else:
shahshreyafac62b12015-01-20 16:16:13 -0800504 main.log.info( "Unknown error" )
505 PingResult = main.ERROR
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800506
shahshreyafac62b12015-01-20 16:16:13 -0800507 if PingResult == main.TRUE:
508 main.log.report( "Ping test successful " )
509 if PingResult == main.FALSE:
510 main.log.report( "Ping test failed" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800511
shahshreyafac62b12015-01-20 16:16:13 -0800512 case24Result = PingResult and linksStateResult
513 utilities.assert_equals( expect=main.TRUE, actual=case24Result,
shahshreya9294c8d2015-01-21 15:54:16 -0800514 onpass="Packet optical rerouting successful",
515 onfail="Packet optical rerouting failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800516
shahshreyafac62b12015-01-20 16:16:13 -0800517 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800518 import re
519 import time
shahshreyafac62b12015-01-20 16:16:13 -0800520 main.log.report( "This testcase is testing the assignment of \
521 all the switches to all the controllers and \
522 discovering the hists in reactive mode" )
523 main.log.report( "__________________________________" )
524 main.case( "Pingall Test" )
525 main.step( "Assigning switches to controllers" )
526 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
527 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
528 for i in range( 1, 29 ):
529 if i == 1:
530 main.Mininet1.assignSwController(
531 sw=str( i ),
532 ip1=ONOS1Ip,
533 port1=ONOS1Port )
534 elif i >= 2 and i < 5:
535 main.Mininet1.assignSwController(
536 sw=str( i ),
537 ip1=ONOS1Ip,
538 port1=ONOS1Port )
539 elif i >= 5 and i < 8:
540 main.Mininet1.assignSwController(
541 sw=str( i ),
542 ip1=ONOS1Ip,
543 port1=ONOS1Port )
544 elif i >= 8 and i < 18:
545 main.Mininet1.assignSwController(
546 sw=str( i ),
547 ip1=ONOS1Ip,
548 port1=ONOS1Port )
549 elif i >= 18 and i < 28:
550 main.Mininet1.assignSwController(
551 sw=str( i ),
552 ip1=ONOS1Ip,
553 port1=ONOS1Port )
shahshreya4e13a062014-11-11 16:46:18 -0800554 else:
shahshreyafac62b12015-01-20 16:16:13 -0800555 main.Mininet1.assignSwController(
556 sw=str( i ),
557 ip1=ONOS1Ip,
558 port1=ONOS1Port )
559 SwitchMastership = main.TRUE
560 for i in range( 1, 29 ):
561 if i == 1:
562 response = main.Mininet1.getSwController( "s" + str( i ) )
563 print( "Response is " + str( response ) )
564 if re.search( "tcp:" + ONOS1Ip, response ):
565 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800566 else:
shahshreyafac62b12015-01-20 16:16:13 -0800567 SwitchMastership = main.FALSE
568 elif i >= 2 and i < 5:
569 response = main.Mininet1.getSwController( "s" + str( i ) )
570 print( "Response is " + str( response ) )
571 if re.search( "tcp:" + ONOS1Ip, response ):
572 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800573 else:
shahshreyafac62b12015-01-20 16:16:13 -0800574 SwitchMastership = main.FALSE
575 elif i >= 5 and i < 8:
576 response = main.Mininet1.getSwController( "s" + str( i ) )
577 print( "Response is " + str( response ) )
578 if re.search( "tcp:" + ONOS1Ip, response ):
579 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800580 else:
shahshreyafac62b12015-01-20 16:16:13 -0800581 SwitchMastership = main.FALSE
582 elif i >= 8 and i < 18:
583 response = main.Mininet1.getSwController( "s" + str( i ) )
584 print( "Response is " + str( response ) )
585 if re.search( "tcp:" + ONOS1Ip, response ):
586 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800587 else:
shahshreyafac62b12015-01-20 16:16:13 -0800588 SwitchMastership = main.FALSE
589 elif i >= 18 and i < 28:
590 response = main.Mininet1.getSwController( "s" + str( i ) )
591 print( "Response is " + str( response ) )
592 if re.search( "tcp:" + ONOS1Ip, response ):
593 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800594 else:
shahshreyafac62b12015-01-20 16:16:13 -0800595 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800596 else:
shahshreyafac62b12015-01-20 16:16:13 -0800597 response = main.Mininet1.getSwController( "s" + str( i ) )
598 print( "Response is" + str( response ) )
599 if re.search( "tcp:" + ONOS1Ip, response ):
600 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800601 else:
shahshreyafac62b12015-01-20 16:16:13 -0800602 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800603
shahshreyafac62b12015-01-20 16:16:13 -0800604 if SwitchMastership == main.TRUE:
605 main.log.report( "Controller assignmnet successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800606 else:
shahshreyafac62b12015-01-20 16:16:13 -0800607 main.log.report( "Controller assignmnet failed" )
608 utilities.assert_equals(
609 expect=main.TRUE,
610 actual=SwitchMastership,
611 onpass="MasterControllers assigned correctly" )
612 """
613 for i in range ( 1,29 ):
614 main.Mininet1.assignSwController( sw=str( i ),count=5,
615 ip1=ONOS1Ip,port1=ONOS1Port,
616 ip2=ONOS2Ip,port2=ONOS2Port,
617 ip3=ONOS3Ip,port3=ONOS3Port,
618 ip4=ONOS4Ip,port4=ONOS4Port,
619 ip5=ONOS5Ip,port5=ONOS5Port )
620 """
621 # REACTIVE FWD test
shahshreya4e13a062014-11-11 16:46:18 -0800622
shahshreyafac62b12015-01-20 16:16:13 -0800623 main.step( "Get list of hosts from Mininet" )
624 hostList = main.Mininet1.getHosts()
625 main.log.info( hostList )
shahshreya4e13a062014-11-11 16:46:18 -0800626
shahshreyafac62b12015-01-20 16:16:13 -0800627 main.step( "Get host list in ONOS format" )
628 hostOnosList = main.ONOS2.getHostsId( hostList )
629 main.log.info( hostOnosList )
630 # time.sleep( 5 )
631
632 main.step( "Pingall" )
633 pingResult = main.FALSE
634 while pingResult == main.FALSE:
shahshreya4e13a062014-11-11 16:46:18 -0800635 time1 = time.time()
shahshreyafac62b12015-01-20 16:16:13 -0800636 pingResult = main.Mininet1.pingall()
shahshreya4e13a062014-11-11 16:46:18 -0800637 time2 = time.time()
shahshreyafac62b12015-01-20 16:16:13 -0800638 print "Time for pingall: %2f seconds" % ( time2 - time1 )
shahshreya4e13a062014-11-11 16:46:18 -0800639
shahshreyafac62b12015-01-20 16:16:13 -0800640 # Start onos cli again because u might have dropped out of
641 # onos prompt to the shell prompt
642 # if there was no activity
643 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
644
645 case4Result = SwitchMastership and pingResult
646 if pingResult == main.TRUE:
647 main.log.report( "Pingall Test in reactive mode to \
648 discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800649 else:
shahshreyafac62b12015-01-20 16:16:13 -0800650 main.log.report( "Pingall Test in reactive mode to \
651 discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800652
shahshreyafac62b12015-01-20 16:16:13 -0800653 utilities.assert_equals(
654 expect=main.TRUE,
655 actual=case4Result,
656 onpass="Controller assignment and Pingall Test successful",
657 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800658
shahshreyafac62b12015-01-20 16:16:13 -0800659 def CASE10( self ):
660 main.log.report(
661 "This testcase uninstalls the reactive forwarding app" )
662 main.log.report( "__________________________________" )
663 main.case( "Uninstalling reactive forwarding app" )
664 # Unistall onos-app-fwd app to disable reactive forwarding
665 appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
666 main.log.info( "onos-app-fwd uninstalled" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800667
shahshreyafac62b12015-01-20 16:16:13 -0800668 # After reactive forwarding is disabled, the reactive flows on
669 # switches timeout in 10-15s
670 # So sleep for 15s
671 time.sleep( 15 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800672
673 flows = main.ONOS2.flows()
shahshreyafac62b12015-01-20 16:16:13 -0800674 main.log.info( flows )
shahshreyae6c7cf42014-11-26 16:39:01 -0800675
shahshreyafac62b12015-01-20 16:16:13 -0800676 case10Result = appUninstallResult
677 utilities.assert_equals(
678 expect=main.TRUE,
679 actual=case10Result,
680 onpass="Reactive forwarding app uninstallation successful",
681 onfail="Reactive forwarding app uninstallation failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800682
shahshreyafac62b12015-01-20 16:16:13 -0800683 def CASE6( self ):
684 main.log.report( "This testcase is testing the addition of \
685 host intents and then does pingall" )
686 main.log.report( "__________________________________" )
687 main.case( "Obtaining host id's" )
688 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800689 hosts = main.ONOS2.hosts()
shahshreyafac62b12015-01-20 16:16:13 -0800690 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800691
shahshreyafac62b12015-01-20 16:16:13 -0800692 main.step( "Get all devices id" )
693 devicesIdList = main.ONOS2.getAllDevicesId()
694 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -0800695
shahshreyafac62b12015-01-20 16:16:13 -0800696 # ONOS displays the hosts in hex format unlike mininet which does
697 # in decimal format
698 # So take care while adding intents
699 """
700 main.step( "Add host-to-host intents for mininet hosts h8 and h18 or
701 ONOS hosts h8 and h12" )
702 hthIntentResult = main.ONOS2.addHostIntent(
703 "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
704 hthIntentResult = main.ONOS2.addHostIntent(
705 "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
706 hthIntentResult = main.ONOS2.addHostIntent(
707 "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
708 hthIntentResult = main.ONOS2.addHostIntent(
709 "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
710 hthIntentResult = main.ONOS2.addHostIntent(
711 "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
712 hthIntentResult = main.ONOS2.addHostIntent(
713 "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
714 hthIntentResult = main.ONOS2.addHostIntent(
715 "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
716 hthIntentResult = main.ONOS2.addHostIntent(
717 "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
718 hthIntentResult = main.ONOS2.addHostIntent(
719 "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
720 hthIntentResult = main.ONOS2.addHostIntent(
721 "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
722 print "______________________________________________________"
723 """
724 for i in range( 8, 18 ):
725 main.log.info(
726 "Adding host intent between h" + str( i ) +
727 " and h" + str( i + 10 ) )
728 host1 = "00:00:00:00:00:" + \
729 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
730 host2 = "00:00:00:00:00:" + \
731 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
732 # NOTE: get host can return None
733 # TODO: handle this
734 host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
735 host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
736 main.ONOS2.addHostIntent( host1Id, host2Id )
737
738 time.sleep( 10 )
739 hIntents = main.ONOS2.intents( jsonFormat=False )
740 main.log.info( "intents:" + hIntents )
741 main.ONOS2.flows()
shahshreya4e13a062014-11-11 16:46:18 -0800742
743 count = 1
744 i = 8
shahshreyafac62b12015-01-20 16:16:13 -0800745 PingResult = main.TRUE
746 # while i<10:
747 while i < 18:
748 main.log.info(
749 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
750 ping = main.Mininet1.pingHost(
751 src="h" + str( i ), target="h" + str( i + 10 ) )
752 if ping == main.FALSE and count < 5:
753 count += 1
754 # i = 8
755 PingResult = main.FALSE
756 main.log.report( "Ping between h" +
757 str( i ) +
758 " and h" +
759 str( i +
760 10 ) +
761 " failed. Making attempt number " +
762 str( count ) +
763 " in 2 seconds" )
764 time.sleep( 2 )
765 elif ping == main.FALSE:
766 main.log.report( "All ping attempts between h" +
767 str( i ) +
768 " and h" +
769 str( i +
770 10 ) +
771 "have failed" )
772 i = 19
773 PingResult = main.FALSE
774 elif ping == main.TRUE:
775 main.log.info( "Ping test between h" +
776 str( i ) +
777 " and h" +
778 str( i +
779 10 ) +
780 "passed!" )
781 i += 1
782 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800783 else:
shahshreyafac62b12015-01-20 16:16:13 -0800784 main.log.info( "Unknown error" )
785 PingResult = main.ERROR
786 if PingResult == main.FALSE:
787 main.log.report(
shahshreya9294c8d2015-01-21 15:54:16 -0800788 "Ping all test after Host intent addition failed.Cleaning up" )
shahshreyafac62b12015-01-20 16:16:13 -0800789 # main.cleanup()
790 # main.exit()
791 if PingResult == main.TRUE:
792 main.log.report(
793 "Ping all test after Host intent addition successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800794
shahshreyafac62b12015-01-20 16:16:13 -0800795 case6Result = PingResult
796 utilities.assert_equals(
797 expect=main.TRUE,
798 actual=case6Result,
799 onpass="Pingall Test after Host intents addition successful",
800 onfail="Pingall Test after Host intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800801
shahshreyafac62b12015-01-20 16:16:13 -0800802 def CASE5( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800803 import json
shahshreyafac62b12015-01-20 16:16:13 -0800804 # assumes that sts is already in you PYTHONPATH
shahshreya9294c8d2015-01-21 15:54:16 -0800805 from sts.topology.teston_topology import TestONTopology
shahshreyafac62b12015-01-20 16:16:13 -0800806 # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
807 main.log.report( "This testcase is testing if all ONOS nodes \
808 are in topology sync with mininet" )
809 main.log.report( "__________________________________" )
810 main.case( "Comparing Mininet topology with the topology of ONOS" )
811 main.step( "Start continuous pings" )
812 main.Mininet2.pingLong(
813 src=main.params[ 'PING' ][ 'source1' ],
814 target=main.params[ 'PING' ][ 'target1' ],
815 pingTime=500 )
816 main.Mininet2.pingLong(
817 src=main.params[ 'PING' ][ 'source2' ],
818 target=main.params[ 'PING' ][ 'target2' ],
819 pingTime=500 )
820 main.Mininet2.pingLong(
821 src=main.params[ 'PING' ][ 'source3' ],
822 target=main.params[ 'PING' ][ 'target3' ],
823 pingTime=500 )
824 main.Mininet2.pingLong(
825 src=main.params[ 'PING' ][ 'source4' ],
826 target=main.params[ 'PING' ][ 'target4' ],
827 pingTime=500 )
828 main.Mininet2.pingLong(
829 src=main.params[ 'PING' ][ 'source5' ],
830 target=main.params[ 'PING' ][ 'target5' ],
831 pingTime=500 )
832 main.Mininet2.pingLong(
833 src=main.params[ 'PING' ][ 'source6' ],
834 target=main.params[ 'PING' ][ 'target6' ],
835 pingTime=500 )
836 main.Mininet2.pingLong(
837 src=main.params[ 'PING' ][ 'source7' ],
838 target=main.params[ 'PING' ][ 'target7' ],
839 pingTime=500 )
840 main.Mininet2.pingLong(
841 src=main.params[ 'PING' ][ 'source8' ],
842 target=main.params[ 'PING' ][ 'target8' ],
843 pingTime=500 )
844 main.Mininet2.pingLong(
845 src=main.params[ 'PING' ][ 'source9' ],
846 target=main.params[ 'PING' ][ 'target9' ],
847 pingTime=500 )
848 main.Mininet2.pingLong(
849 src=main.params[ 'PING' ][ 'source10' ],
850 target=main.params[ 'PING' ][ 'target10' ],
851 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -0800852
shahshreyafac62b12015-01-20 16:16:13 -0800853 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800854 global ctrls
855 ctrls = []
856 count = 1
857 while True:
858 temp = ()
shahshreyafac62b12015-01-20 16:16:13 -0800859 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
860 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
861 temp = temp + ( "ONOS" + str( count ), )
862 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
863 temp = temp + \
864 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
865 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800866 count = count + 1
867 else:
868 break
869 global MNTopo
shahshreyafac62b12015-01-20 16:16:13 -0800870 Topo = TestONTopology(
871 main.Mininet1,
872 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800873 MNTopo = Topo
874
shahshreyafac62b12015-01-20 16:16:13 -0800875 TopologyCheck = main.TRUE
876 main.step( "Compare ONOS Topology to MN Topology" )
877 devicesJson = main.ONOS2.devices()
878 linksJson = main.ONOS2.links()
879 # portsJson = main.ONOS2.ports()
880
881 result1 = main.Mininet1.compareSwitches(
882 MNTopo,
883 json.loads( devicesJson ) )
884 result2 = main.Mininet1.compareLinks(
885 MNTopo,
886 json.loads( linksJson ) )
887 # result3 = main.Mininet1.comparePorts(
888 # MNTopo, json.loads( portsJson ) )
889
890 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -0800891 result = result1 and result2
shahshreyafac62b12015-01-20 16:16:13 -0800892
shahshreya4e13a062014-11-11 16:46:18 -0800893 print "***********************"
894 if result == main.TRUE:
shahshreyafac62b12015-01-20 16:16:13 -0800895 main.log.report( "ONOS" + " Topology matches MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -0800896 else:
shahshreyafac62b12015-01-20 16:16:13 -0800897 main.log.report( "ONOS" + " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -0800898
shahshreyafac62b12015-01-20 16:16:13 -0800899 utilities.assert_equals(
900 expect=main.TRUE,
901 actual=result,
902 onpass="ONOS" +
903 " Topology matches MN Topology",
904 onfail="ONOS" +
905 " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -0800906
shahshreyafac62b12015-01-20 16:16:13 -0800907 TopologyCheck = TopologyCheck and result
908 utilities.assert_equals(
909 expect=main.TRUE,
910 actual=TopologyCheck,
911 onpass="Topology checks passed",
912 onfail="Topology checks failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800913
shahshreyafac62b12015-01-20 16:16:13 -0800914 def CASE7( self, main ):
shahshreya9294c8d2015-01-21 15:54:16 -0800915 from sts.topology.teston_topology import TestONTopology
shahshreya4e13a062014-11-11 16:46:18 -0800916
shahshreyafac62b12015-01-20 16:16:13 -0800917 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800918
shahshreyafac62b12015-01-20 16:16:13 -0800919 main.log.report( "This testscase is killing a link to ensure that \
920 link discovery is consistent" )
921 main.log.report( "__________________________________" )
922 main.log.report( "Killing a link to ensure that link discovery \
923 is consistent" )
924 main.case( "Killing a link to Ensure that Link Discovery \
925 is Working Properly" )
926 """
927 main.step( "Start continuous pings" )
shahshreya4e13a062014-11-11 16:46:18 -0800928
shahshreyafac62b12015-01-20 16:16:13 -0800929 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
930 target=main.params[ 'PING' ][ 'target1' ],
931 pingTime=500 )
932 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
933 target=main.params[ 'PING' ][ 'target2' ],
934 pingTime=500 )
935 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
936 target=main.params[ 'PING' ][ 'target3' ],
937 pingTime=500 )
938 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
939 target=main.params[ 'PING' ][ 'target4' ],
940 pingTime=500 )
941 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
942 target=main.params[ 'PING' ][ 'target5' ],
943 pingTime=500 )
944 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
945 target=main.params[ 'PING' ][ 'target6' ],
946 pingTime=500 )
947 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
948 target=main.params[ 'PING' ][ 'target7' ],
949 pingTime=500 )
950 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
951 target=main.params[ 'PING' ][ 'target8' ],
952 pingTime=500 )
953 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
954 target=main.params[ 'PING' ][ 'target9' ],
955 pingTime=500 )
956 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
957 target=main.params[ 'PING' ][ 'target10' ],
958 pingTime=500 )
959 """
960 main.step( "Determine the current number of switches and links" )
961 topologyOutput = main.ONOS2.topology()
962 topologyResult = main.ONOS1.getTopology( topologyOutput )
963 activeSwitches = topologyResult[ 'devices' ]
964 links = topologyResult[ 'links' ]
965 print "activeSwitches = ", type( activeSwitches )
966 print "links = ", type( links )
967 main.log.info(
968 "Currently there are %s switches and %s links" %
969 ( str( activeSwitches ), str( links ) ) )
970
971 main.step( "Kill Link between s3 and s28" )
972 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
973 time.sleep( linkSleep )
974 topologyOutput = main.ONOS2.topology()
975 LinkDown = main.ONOS1.checkStatus(
976 topologyOutput, activeSwitches, str(
977 int( links ) - 2 ) )
978 if LinkDown == main.TRUE:
979 main.log.report( "Link Down discovered properly" )
980 utilities.assert_equals(
981 expect=main.TRUE,
982 actual=LinkDown,
983 onpass="Link Down discovered properly",
984 onfail="Link down was not discovered in " +
985 str( linkSleep ) +
986 " seconds" )
987
988 # Check ping result here..add code for it
989
990 main.step( "Bring link between s3 and s28 back up" )
991 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
992 time.sleep( linkSleep )
993 topologyOutput = main.ONOS2.topology()
994 LinkUp = main.ONOS1.checkStatus(
995 topologyOutput,
996 activeSwitches,
997 str( links ) )
998 if LinkUp == main.TRUE:
999 main.log.report( "Link up discovered properly" )
1000 utilities.assert_equals(
1001 expect=main.TRUE,
1002 actual=LinkUp,
1003 onpass="Link up discovered properly",
1004 onfail="Link up was not discovered in " +
1005 str( linkSleep ) +
1006 " seconds" )
1007
1008 # NOTE Check ping result here..add code for it
1009
1010 main.step( "Compare ONOS Topology to MN Topology" )
1011 Topo = TestONTopology(
1012 main.Mininet1,
1013 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -08001014 MNTopo = Topo
shahshreyafac62b12015-01-20 16:16:13 -08001015 TopologyCheck = main.TRUE
1016
1017 devicesJson = main.ONOS2.devices()
1018 linksJson = main.ONOS2.links()
1019 portsJson = main.ONOS2.ports()
1020
1021 result1 = main.Mininet1.compareSwitches(
1022 MNTopo,
1023 json.loads( devicesJson ) )
1024 result2 = main.Mininet1.compareLinks(
1025 MNTopo,
1026 json.loads( linksJson ) )
1027 # result3 = main.Mininet1.comparePorts(
1028 # MNTopo, json.loads( portsJson ) )
1029
1030 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001031 result = result1 and result2
1032 print "***********************"
shahshreyafac62b12015-01-20 16:16:13 -08001033
shahshreya4e13a062014-11-11 16:46:18 -08001034 if result == main.TRUE:
shahshreyafac62b12015-01-20 16:16:13 -08001035 main.log.report( "ONOS" + " Topology matches MN Topology" )
1036 utilities.assert_equals(
1037 expect=main.TRUE,
1038 actual=result,
1039 onpass="ONOS" +
1040 " Topology matches MN Topology",
1041 onfail="ONOS" +
1042 " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001043
shahshreyafac62b12015-01-20 16:16:13 -08001044 TopologyCheck = TopologyCheck and result
1045 utilities.assert_equals(
1046 expect=main.TRUE,
1047 actual=TopologyCheck,
1048 onpass="Topology checks passed",
1049 onfail="Topology checks failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001050
shahshreyafac62b12015-01-20 16:16:13 -08001051 result = LinkDown and LinkUp and TopologyCheck
1052 utilities.assert_equals( expect=main.TRUE, actual=result,
shahshreya9294c8d2015-01-21 15:54:16 -08001053 onpass="Link failure is discovered correctly",
1054 onfail="Link Discovery failed" )
shahshreyafac62b12015-01-20 16:16:13 -08001055
1056 def CASE8( self ):
1057 """
shahshreya4e13a062014-11-11 16:46:18 -08001058 Host intents removal
shahshreyafac62b12015-01-20 16:16:13 -08001059 """
1060 main.log.report( "This testcase removes any previously added intents \
1061 before adding the same intents or point intents" )
1062 main.log.report( "__________________________________" )
1063 main.log.info( "Host intents removal" )
1064 main.case( "Removing host intents" )
1065 main.step( "Obtain the intent id's" )
1066 intentResult = main.ONOS2.intents( jsonFormat=False )
1067 main.log.info( "intent_result = " + intentResult )
1068
1069 intentLinewise = intentResult.split( "\n" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001070 intentList = []
shahshreyafac62b12015-01-20 16:16:13 -08001071 for line in intentLinewise:
1072 if line.startswith( "id=" ):
1073 intentList.append( line )
1074
shahshreyae6c7cf42014-11-26 16:39:01 -08001075 intentids = []
1076 for line in intentList:
shahshreyafac62b12015-01-20 16:16:13 -08001077 intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
shahshreya4e13a062014-11-11 16:46:18 -08001078 for id in intentids:
1079 print "id = ", id
shahshreyafac62b12015-01-20 16:16:13 -08001080
1081 main.step(
1082 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -08001083 for id in intentids:
shahshreyafac62b12015-01-20 16:16:13 -08001084 main.ONOS2.removeIntent( intentId=id )
shahshreyae6c7cf42014-11-26 16:39:01 -08001085
shahshreyafac62b12015-01-20 16:16:13 -08001086 intentResult = main.ONOS2.intents( jsonFormat=False )
1087 main.log.info( "intent_result = " + intentResult )
1088
1089 case8Result = main.TRUE
1090 if case8Result == main.TRUE:
1091 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001092 else:
shahshreyafac62b12015-01-20 16:16:13 -08001093 main.log.report( "Intent removal failed" )
1094
1095 PingResult = main.TRUE
1096 if case8Result == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001097 i = 8
shahshreyafac62b12015-01-20 16:16:13 -08001098 while i < 18:
1099 main.log.info(
1100 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1101 ping = main.Mininet1.pingHost(
1102 src="h" + str( i ), target="h" + str( i + 10 ) )
1103 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001104 i = 19
shahshreyafac62b12015-01-20 16:16:13 -08001105 PingResult = PingResult and main.TRUE
1106 elif ping == main.FALSE:
1107 i += 1
1108 PingResult = PingResult and main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -08001109 else:
shahshreyafac62b12015-01-20 16:16:13 -08001110 main.log.info( "Unknown error" )
1111 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001112
shahshreyafac62b12015-01-20 16:16:13 -08001113 # Note: If the ping result failed, that means the intents have been
1114 # withdrawn correctly.
1115 if PingResult == main.TRUE:
1116 main.log.report( "Host intents have not been withdrawn correctly" )
1117 # main.cleanup()
1118 # main.exit()
1119 if PingResult == main.FALSE:
1120 main.log.report( "Host intents have been withdrawn correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001121
shahshreyafac62b12015-01-20 16:16:13 -08001122 case8Result = case8Result and PingResult
shahshreyae6c7cf42014-11-26 16:39:01 -08001123
shahshreyafac62b12015-01-20 16:16:13 -08001124 if case8Result == main.FALSE:
1125 main.log.report( "Intent removal successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001126 else:
shahshreyafac62b12015-01-20 16:16:13 -08001127 main.log.report( "Intent removal failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001128
shahshreyafac62b12015-01-20 16:16:13 -08001129 utilities.assert_equals( expect=main.FALSE, actual=case8Result,
shahshreya9294c8d2015-01-21 15:54:16 -08001130 onpass="Intent removal test passed",
1131 onfail="Intent removal test failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001132
shahshreyafac62b12015-01-20 16:16:13 -08001133 def CASE9( self ):
1134 main.log.report(
1135 "This testcase adds point intents and then does pingall" )
1136 main.log.report( "__________________________________" )
1137 main.log.info( "Adding point intents" )
1138 main.case(
shahshreya3dc3ce62015-01-22 13:31:59 -08001139 '''Adding bidirectional point for mn hosts
1140 ( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22,
1141 h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )''' )
1142
1143 main.step( "Add point intents for mn hosts h8 and h18 or \
1144 ONOS hosts h8 and h12" )
1145 # main.step(var1)
shahshreyafac62b12015-01-20 16:16:13 -08001146 ptpIntentResult = main.ONOS2.addPointIntent(
1147 "of:0000000000003008/1",
1148 "of:0000000000006018/1" )
1149 if ptpIntentResult == main.TRUE:
1150 getIntentResult = main.ONOS2.intents()
1151 main.log.info( "Point to point intent install successful" )
1152 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001153
shahshreyafac62b12015-01-20 16:16:13 -08001154 ptpIntentResult = main.ONOS2.addPointIntent(
1155 "of:0000000000006018/1",
1156 "of:0000000000003008/1" )
1157 if ptpIntentResult == main.TRUE:
1158 getIntentResult = main.ONOS2.intents()
1159 main.log.info( "Point to point intent install successful" )
1160 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001161
shahshreya9294c8d2015-01-21 15:54:16 -08001162 var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
1163 main.step(var2)
shahshreyafac62b12015-01-20 16:16:13 -08001164 ptpIntentResult = main.ONOS2.addPointIntent(
1165 "of:0000000000003009/1",
1166 "of:0000000000006019/1" )
1167 if ptpIntentResult == main.TRUE:
1168 getIntentResult = main.ONOS2.intents()
1169 main.log.info( "Point to point intent install successful" )
1170 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001171
shahshreyafac62b12015-01-20 16:16:13 -08001172 ptpIntentResult = main.ONOS2.addPointIntent(
1173 "of:0000000000006019/1",
1174 "of:0000000000003009/1" )
1175 if ptpIntentResult == main.TRUE:
1176 getIntentResult = main.ONOS2.intents()
1177 main.log.info( "Point to point intent install successful" )
1178 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001179
shahshreya9294c8d2015-01-21 15:54:16 -08001180 var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
1181 main.step(var3)
shahshreyafac62b12015-01-20 16:16:13 -08001182 ptpIntentResult = main.ONOS2.addPointIntent(
1183 "of:0000000000003010/1",
1184 "of:0000000000006020/1" )
1185 if ptpIntentResult == main.TRUE:
1186 getIntentResult = main.ONOS2.intents()
1187 main.log.info( "Point to point intent install successful" )
1188 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001189
shahshreyafac62b12015-01-20 16:16:13 -08001190 ptpIntentResult = main.ONOS2.addPointIntent(
1191 "of:0000000000006020/1",
1192 "of:0000000000003010/1" )
1193 if ptpIntentResult == main.TRUE:
1194 getIntentResult = main.ONOS2.intents()
1195 main.log.info( "Point to point intent install successful" )
1196 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001197
shahshreya9294c8d2015-01-21 15:54:16 -08001198 var4 = "Add point intents for mininet hosts h11 and h21 or \
1199 ONOS hosts hB and h15"
1200 main.case(var4)
shahshreyafac62b12015-01-20 16:16:13 -08001201 ptpIntentResult = main.ONOS2.addPointIntent(
1202 "of:0000000000003011/1",
1203 "of:0000000000006021/1" )
1204 if ptpIntentResult == main.TRUE:
1205 getIntentResult = main.ONOS2.intents()
1206 main.log.info( "Point to point intent install successful" )
1207 # main.log.info( getIntentResult )
1208
1209 ptpIntentResult = main.ONOS2.addPointIntent(
1210 "of:0000000000006021/1",
1211 "of:0000000000003011/1" )
1212 if ptpIntentResult == main.TRUE:
1213 getIntentResult = main.ONOS2.intents()
1214 main.log.info( "Point to point intent install successful" )
1215 # main.log.info( getIntentResult )
1216
shahshreya9294c8d2015-01-21 15:54:16 -08001217 var5 = "Add point intents for mininet hosts h12 and h22 \
1218 ONOS hosts hC and h16"
1219 main.case(var5)
shahshreyafac62b12015-01-20 16:16:13 -08001220 ptpIntentResult = main.ONOS2.addPointIntent(
1221 "of:0000000000003012/1",
1222 "of:0000000000006022/1" )
1223 if ptpIntentResult == main.TRUE:
1224 getIntentResult = main.ONOS2.intents()
1225 main.log.info( "Point to point intent install successful" )
1226 # main.log.info( getIntentResult )
1227
1228 ptpIntentResult = main.ONOS2.addPointIntent(
1229 "of:0000000000006022/1",
1230 "of:0000000000003012/1" )
1231 if ptpIntentResult == main.TRUE:
1232 getIntentResult = main.ONOS2.intents()
1233 main.log.info( "Point to point intent install successful" )
1234 # main.log.info( getIntentResult )
1235
shahshreya9294c8d2015-01-21 15:54:16 -08001236 var6 = "Add point intents for mininet hosts h13 and h23 or \
1237 ONOS hosts hD and h17"
1238 main.case(var6)
shahshreyafac62b12015-01-20 16:16:13 -08001239 ptpIntentResult = main.ONOS2.addPointIntent(
1240 "of:0000000000003013/1",
1241 "of:0000000000006023/1" )
1242 if ptpIntentResult == main.TRUE:
1243 getIntentResult = main.ONOS2.intents()
1244 main.log.info( "Point to point intent install successful" )
1245 # main.log.info( getIntentResult )
1246
1247 ptpIntentResult = main.ONOS2.addPointIntent(
1248 "of:0000000000006023/1",
1249 "of:0000000000003013/1" )
1250 if ptpIntentResult == main.TRUE:
1251 getIntentResult = main.ONOS2.intents()
1252 main.log.info( "Point to point intent install successful" )
1253 # main.log.info( getIntentResult )
1254
shahshreya9294c8d2015-01-21 15:54:16 -08001255 var7 = "Add point intents for mininet hosts h14 and h24 or \
1256 ONOS hosts hE and h18"
1257 main.case(var7)
shahshreyafac62b12015-01-20 16:16:13 -08001258 ptpIntentResult = main.ONOS2.addPointIntent(
1259 "of:0000000000003014/1",
1260 "of:0000000000006024/1" )
1261 if ptpIntentResult == main.TRUE:
1262 getIntentResult = main.ONOS2.intents()
1263 main.log.info( "Point to point intent install successful" )
1264 # main.log.info( getIntentResult )
1265
1266 ptpIntentResult = main.ONOS2.addPointIntent(
1267 "of:0000000000006024/1",
1268 "of:0000000000003014/1" )
1269 if ptpIntentResult == main.TRUE:
1270 getIntentResult = main.ONOS2.intents()
1271 main.log.info( "Point to point intent install successful" )
1272 # main.log.info( getIntentResult )
1273
shahshreya9294c8d2015-01-21 15:54:16 -08001274 var8 = "Add point intents for mininet hosts h15 and h25 or \
1275 ONOS hosts hF and h19"
1276 main.case(var8)
shahshreyafac62b12015-01-20 16:16:13 -08001277 ptpIntentResult = main.ONOS2.addPointIntent(
1278 "of:0000000000003015/1",
1279 "of:0000000000006025/1" )
1280 if ptpIntentResult == main.TRUE:
1281 getIntentResult = main.ONOS2.intents()
1282 main.log.info( "Point to point intent install successful" )
1283 # main.log.info( getIntentResult )
1284
1285 ptpIntentResult = main.ONOS2.addPointIntent(
1286 "of:0000000000006025/1",
1287 "of:0000000000003015/1" )
1288 if ptpIntentResult == main.TRUE:
1289 getIntentResult = main.ONOS2.intents()
1290 main.log.info( "Point to point intent install successful" )
1291 # main.log.info( getIntentResult )
1292
shahshreya9294c8d2015-01-21 15:54:16 -08001293 var9 = "Add intents for mininet hosts h16 and h26 or \
1294 ONOS hosts h10 and h1A"
1295 main.case(var9)
shahshreyafac62b12015-01-20 16:16:13 -08001296 ptpIntentResult = main.ONOS2.addPointIntent(
1297 "of:0000000000003016/1",
1298 "of:0000000000006026/1" )
1299 if ptpIntentResult == main.TRUE:
1300 getIntentResult = main.ONOS2.intents()
1301 main.log.info( "Point to point intent install successful" )
1302 # main.log.info( getIntentResult )
1303
1304 ptpIntentResult = main.ONOS2.addPointIntent(
1305 "of:0000000000006026/1",
1306 "of:0000000000003016/1" )
1307 if ptpIntentResult == main.TRUE:
1308 getIntentResult = main.ONOS2.intents()
1309 main.log.info( "Point to point intent install successful" )
1310 # main.log.info( getIntentResult )
1311
shahshreya9294c8d2015-01-21 15:54:16 -08001312 var10 = "Add point intents for mininet hosts h17 and h27 or \
1313 ONOS hosts h11 and h1B"
1314 main.case(var10)
shahshreyafac62b12015-01-20 16:16:13 -08001315 ptpIntentResult = main.ONOS2.addPointIntent(
1316 "of:0000000000003017/1",
1317 "of:0000000000006027/1" )
1318 if ptpIntentResult == main.TRUE:
1319 getIntentResult = main.ONOS2.intents()
1320 main.log.info( "Point to point intent install successful" )
1321 main.log.info( getIntentResult )
1322
1323 ptpIntentResult = main.ONOS2.addPointIntent(
1324 "of:0000000000006027/1",
1325 "of:0000000000003017/1" )
1326 if ptpIntentResult == main.TRUE:
1327 getIntentResult = main.ONOS2.intents()
1328 main.log.info( "Point to point intent install successful" )
1329 main.log.info( getIntentResult )
1330
1331 print(
1332 "___________________________________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001333
1334 flowHandle = main.ONOS2.flows()
shahshreyafac62b12015-01-20 16:16:13 -08001335 # print "flowHandle = ", flowHandle
1336 main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001337
1338 count = 1
1339 i = 8
shahshreyafac62b12015-01-20 16:16:13 -08001340 PingResult = main.TRUE
1341 while i < 18:
1342 main.log.info(
1343 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1344 ping = main.Mininet1.pingHost(
1345 src="h" + str( i ), target="h" + str( i + 10 ) )
1346 if ping == main.FALSE and count < 5:
1347 count += 1
1348 # i = 8
1349 PingResult = main.FALSE
1350 main.log.report( "Ping between h" +
1351 str( i ) +
1352 " and h" +
1353 str( i +
1354 10 ) +
1355 " failed. Making attempt number " +
1356 str( count ) +
1357 " in 2 seconds" )
1358 time.sleep( 2 )
1359 elif ping == main.FALSE:
1360 main.log.report( "All ping attempts between h" +
1361 str( i ) +
1362 " and h" +
1363 str( i +
1364 10 ) +
1365 "have failed" )
1366 i = 19
1367 PingResult = main.FALSE
1368 elif ping == main.TRUE:
1369 main.log.info( "Ping test between h" +
1370 str( i ) +
1371 " and h" +
1372 str( i +
1373 10 ) +
1374 "passed!" )
1375 i += 1
1376 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001377 else:
shahshreyafac62b12015-01-20 16:16:13 -08001378 main.log.info( "Unknown error" )
1379 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001380
shahshreyafac62b12015-01-20 16:16:13 -08001381 if PingResult == main.FALSE:
1382 main.log.report(
1383 "Point intents have not ben installed correctly. Cleaning up" )
1384 # main.cleanup()
1385 # main.exit()
1386 if PingResult == main.TRUE:
1387 main.log.report( "Point Intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001388
shahshreyafac62b12015-01-20 16:16:13 -08001389 case9Result = PingResult
1390 utilities.assert_equals(
1391 expect=main.TRUE,
1392 actual=case9Result,
1393 onpass="Point intents addition and Pingall Test successful",
1394 onfail="Point intents addition and Pingall Test NOT successful" )