blob: 6666007cbe00d87d9c254687ce35c6f626d96afa [file] [log] [blame]
shahshreya4e13a062014-11-11 16:46:18 -08001
shahshreyafac62b12015-01-20 16:16:13 -08002# Testing the basic functionality of ONOS Next
3# For sanity and driver functionality excercises only.
shahshreya4e13a062014-11-11 16:46:18 -08004
5import time
shahshreyafac62b12015-01-20 16:16:13 -08006# import sys
7# import os
8# import re
shahshreya4e13a062014-11-11 16:46:18 -08009import json
10
shahshreyafac62b12015-01-20 16:16:13 -080011time.sleep( 1 )
12
13
shahshreya4e13a062014-11-11 16:46:18 -080014class ProdFunc:
shahshreyafac62b12015-01-20 16:16:13 -080015
16 def __init__( self ):
shahshreya4e13a062014-11-11 16:46:18 -080017 self.default = ''
18
shahshreyafac62b12015-01-20 16:16:13 -080019 def CASE1( self, main ):
shahshreya82ecd282015-02-05 16:48:03 -080020 import time
shahshreyafac62b12015-01-20 16:16:13 -080021 """
shahshreya4e13a062014-11-11 16:46:18 -080022 Startup sequence:
shahshreyae6c7cf42014-11-26 16:39:01 -080023 cell <name>
24 onos-verify-cell
25 onos-remove-raft-log
shahshreya4e13a062014-11-11 16:46:18 -080026 git pull
27 mvn clean install
28 onos-package
shahshreya4e13a062014-11-11 16:46:18 -080029 onos-install -f
30 onos-wait-for-start
shahshreyafac62b12015-01-20 16:16:13 -080031 """
32 cellName = main.params[ 'ENV' ][ 'cellName' ]
33 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreyae6c7cf42014-11-26 16:39:01 -080034
shahshreyafac62b12015-01-20 16:16:13 -080035 main.case( "Setting up test environment" )
36 main.log.report(
37 "This testcase is testing setting up test environment" )
38 main.log.report( "__________________________________" )
shahshreyae6c7cf42014-11-26 16:39:01 -080039
shahshreyafac62b12015-01-20 16:16:13 -080040 main.step( "Applying cell variable to environment" )
41 cellResult = main.ONOSbench.setCell( cellName )
42 verifyResult = main.ONOSbench.verifyCell()
43
44 main.step( "Removing raft logs before a clen installation of ONOS" )
45 main.ONOSbench.onosRemoveRaftLogs()
46
shahshreyab512cd02015-01-27 17:01:47 -080047 main.step( "Git checkout and get version" )
48 #main.ONOSbench.gitCheckout( "master" )
shahshreyafac62b12015-01-20 16:16:13 -080049 gitPullResult = main.ONOSbench.gitPull()
shahshreya82ecd282015-02-05 16:48:03 -080050 main.log.info( "git_pull_result = " + str( gitPullResult ))
shahshreyafac62b12015-01-20 16:16:13 -080051 main.ONOSbench.getVersion( report=True )
52
53 if gitPullResult == 1:
54 main.step( "Using mvn clean & install" )
55 main.ONOSbench.cleanInstall()
56 elif gitPullResult == 0:
57 main.log.report(
58 "Git Pull Failed, look into logs for detailed reason" )
shahshreya0e81ed92014-12-08 16:57:17 -080059 main.cleanup()
shahshreyafac62b12015-01-20 16:16:13 -080060 main.exit()
shahshreya4e13a062014-11-11 16:46:18 -080061
shahshreyafac62b12015-01-20 16:16:13 -080062 main.step( "Creating ONOS package" )
63 packageResult = main.ONOSbench.onosPackage()
shahshreya4e13a062014-11-11 16:46:18 -080064
shahshreyafac62b12015-01-20 16:16:13 -080065 main.step( "Installing ONOS package" )
66 onosInstallResult = main.ONOSbench.onosInstall()
67 if onosInstallResult == main.TRUE:
68 main.log.report( "Installing ONOS package successful" )
shahshreya4e13a062014-11-11 16:46:18 -080069 else:
shahshreyafac62b12015-01-20 16:16:13 -080070 main.log.report( "Installing ONOS package failed" )
shahshreya4e13a062014-11-11 16:46:18 -080071
shahshreyafac62b12015-01-20 16:16:13 -080072 onos1Isup = main.ONOSbench.isup()
73 if onos1Isup == main.TRUE:
74 main.log.report( "ONOS instance is up and ready" )
shahshreya4e13a062014-11-11 16:46:18 -080075 else:
shahshreyafac62b12015-01-20 16:16:13 -080076 main.log.report( "ONOS instance may not be up" )
shahshreya4e13a062014-11-11 16:46:18 -080077
shahshreyafac62b12015-01-20 16:16:13 -080078 main.step( "Starting ONOS service" )
79 startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -080080
shahshreyafac62b12015-01-20 16:16:13 -080081 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
shahshreya82ecd282015-02-05 16:48:03 -080082 main.step( "Starting Mininet CLI..." )
83
84 # Starting the mininet using the old way
85 main.step( "Starting Mininet ..." )
86 netIsUp = main.Mininet1.startNet()
87 if netIsUp:
88 main.log.info("Mininet CLI is up")
89
shahshreyafac62b12015-01-20 16:16:13 -080090 case1Result = ( packageResult and
91 cellResult and verifyResult
92 and onosInstallResult and
93 onos1Isup and startResult )
94 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
shahshreya9294c8d2015-01-21 15:54:16 -080095 onpass="Test startup successful",
96 onfail="Test startup NOT successful" )
shahshreyafac62b12015-01-20 16:16:13 -080097
98 def CASE2( self, main ):
99 """
shahshreya0e81ed92014-12-08 16:57:17 -0800100 Switch Down
shahshreyafac62b12015-01-20 16:16:13 -0800101 """
102 # NOTE: You should probably run a topology check after this
103 import time
shahshreya0e81ed92014-12-08 16:57:17 -0800104
shahshreyafac62b12015-01-20 16:16:13 -0800105 main.case( "Switch down discovery" )
106 main.log.report( "This testcase is testing a switch down discovery" )
107 main.log.report( "__________________________________" )
108
109 switchSleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
shahshreya0e81ed92014-12-08 16:57:17 -0800110
111 description = "Killing a switch to ensure it is discovered correctly"
shahshreyafac62b12015-01-20 16:16:13 -0800112 main.log.report( description )
113 main.case( description )
shahshreya0e81ed92014-12-08 16:57:17 -0800114
shahshreyafac62b12015-01-20 16:16:13 -0800115 # TODO: Make this switch parameterizable
116 main.step( "Kill s28 " )
117 main.log.report( "Deleting s28" )
118 # FIXME: use new dynamic topo functions
119 main.Mininet1.delSwitch( "s28" )
120 main.log.info(
121 "Waiting " +
122 str( switchSleep ) +
123 " seconds for switch down to be discovered" )
124 time.sleep( switchSleep )
125 # Peek at the deleted switch
126 device = main.ONOS2.getDevice( dpid="0028" )
shahshreya0e81ed92014-12-08 16:57:17 -0800127 print "device = ", device
shahshreyafac62b12015-01-20 16:16:13 -0800128 if device[ u'available' ] == 'False':
129 case2Result = main.FALSE
shahshreya0e81ed92014-12-08 16:57:17 -0800130 else:
shahshreyafac62b12015-01-20 16:16:13 -0800131 case2Result = main.TRUE
132 utilities.assert_equals( expect=main.TRUE, actual=case2Result,
shahshreya9294c8d2015-01-21 15:54:16 -0800133 onpass="Switch down discovery successful",
134 onfail="Switch down discovery failed" )
shahshreya0e81ed92014-12-08 16:57:17 -0800135
shahshreyadcb08e82015-02-25 10:16:42 -0800136 def CASE101( self, main ):
shahshreyafac62b12015-01-20 16:16:13 -0800137 """
shahshreya4e13a062014-11-11 16:46:18 -0800138 Cleanup sequence:
shahshreyafac62b12015-01-20 16:16:13 -0800139 onos-service <nodeIp> stop
shahshreya4e13a062014-11-11 16:46:18 -0800140 onos-uninstall
141
142 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800143
shahshreyafac62b12015-01-20 16:16:13 -0800144 """
145 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800146
shahshreyafac62b12015-01-20 16:16:13 -0800147 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800148
shahshreyafac62b12015-01-20 16:16:13 -0800149 main.step( "Testing ONOS kill function" )
150 killResult = main.ONOSbench.onosKill( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800151
shahshreyafac62b12015-01-20 16:16:13 -0800152 main.step( "Stopping ONOS service" )
153 stopResult = main.ONOSbench.onosStop( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800154
shahshreyafac62b12015-01-20 16:16:13 -0800155 main.step( "Uninstalling ONOS service" )
156 uninstallResult = main.ONOSbench.onosUninstall()
shahshreya4e13a062014-11-11 16:46:18 -0800157
shahshreyafac62b12015-01-20 16:16:13 -0800158 case11Result = killResult and stopResult and uninstallResult
159 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
shahshreya9294c8d2015-01-21 15:54:16 -0800160 onpass="Cleanup successful",
161 onfail="Cleanup failed" )
shahshreyafac62b12015-01-20 16:16:13 -0800162
163 def CASE3( self, main ):
164 """
shahshreya4e13a062014-11-11 16:46:18 -0800165 Test 'onos' command and its functionality in driver
shahshreyafac62b12015-01-20 16:16:13 -0800166 """
167 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800168
shahshreyafac62b12015-01-20 16:16:13 -0800169 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800170
shahshreyafac62b12015-01-20 16:16:13 -0800171 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800172 cmdstr1 = "system:name"
shahshreyafac62b12015-01-20 16:16:13 -0800173 cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
174 main.log.info( "onos command returned: " + cmdResult1 )
shahshreya4e13a062014-11-11 16:46:18 -0800175
shahshreyafac62b12015-01-20 16:16:13 -0800176 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800177 cmdstr2 = "onos:topology"
shahshreyafac62b12015-01-20 16:16:13 -0800178 cmdResult2 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
179 main.log.info( "onos command returned: " + cmdResult2 )
shahshreya4e13a062014-11-11 16:46:18 -0800180
shahshreyafac62b12015-01-20 16:16:13 -0800181 def CASE20( self ):
182 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800183 Exit from mininet cli
184 reinstall ONOS
shahshreyafac62b12015-01-20 16:16:13 -0800185 """
186 cellName = main.params[ 'ENV' ][ 'cellName' ]
187 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800188
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800189 main.log.report( "This testcase exits the mininet cli and reinstalls" +
190 "ONOS to switch over to Packet Optical topology" )
shahshreyafac62b12015-01-20 16:16:13 -0800191 main.log.report( "_____________________________________________" )
192 main.case( "Disconnecting mininet and restarting ONOS" )
193 main.step( "Disconnecting mininet and restarting ONOS" )
194 mininetDisconnect = main.Mininet1.disconnect()
shahshreya82ecd282015-02-05 16:48:03 -0800195 print "mininetDisconnect = ", mininetDisconnect
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800196
shahshreyafac62b12015-01-20 16:16:13 -0800197 main.step( "Removing raft logs before a clen installation of ONOS" )
198 main.ONOSbench.onosRemoveRaftLogs()
shahshreyae6c7cf42014-11-26 16:39:01 -0800199
shahshreyafac62b12015-01-20 16:16:13 -0800200 main.step( "Applying cell variable to environment" )
201 cellResult = main.ONOSbench.setCell( cellName )
202 verifyResult = main.ONOSbench.verifyCell()
203
204 onosInstallResult = main.ONOSbench.onosInstall()
205 if onosInstallResult == main.TRUE:
206 main.log.report( "Installing ONOS package successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800207 else:
shahshreyafac62b12015-01-20 16:16:13 -0800208 main.log.report( "Installing ONOS package failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800209
shahshreyafac62b12015-01-20 16:16:13 -0800210 onos1Isup = main.ONOSbench.isup()
211 if onos1Isup == main.TRUE:
212 main.log.report( "ONOS instance is up and ready" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800213 else:
shahshreyafac62b12015-01-20 16:16:13 -0800214 main.log.report( "ONOS instance may not be up" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800215
shahshreyafac62b12015-01-20 16:16:13 -0800216 main.step( "Starting ONOS service" )
217 startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreyae6c7cf42014-11-26 16:39:01 -0800218
shahshreyafac62b12015-01-20 16:16:13 -0800219 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
220 case20Result = mininetDisconnect and cellResult and verifyResult \
221 and onosInstallResult and onos1Isup and \
222 startResult
223 utilities.assert_equals(
224 expect=main.TRUE,
225 actual=case20Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800226 onpass= "Exiting functionality mininet topology and reinstalling" +
227 " ONOS successful",
228 onfail= "Exiting functionality mininet topology and reinstalling" +
229 " ONOS failed" )
shahshreyafac62b12015-01-20 16:16:13 -0800230
231 def CASE21( self, main ):
232 """
233 On ONOS bench, run this command:
234 ./~/ONOS/tools/test/bin/onos-topo-cfg
235 which starts the rest and copies the links
236 json file to the onos instance.
237 Note that in case of Packet Optical, the links are not learnt
238 from the topology, instead the links are learnt
shahshreyae6c7cf42014-11-26 16:39:01 -0800239 from the json config file
shahshreyafac62b12015-01-20 16:16:13 -0800240 """
241 main.log.report(
242 "This testcase starts the packet layer topology and REST" )
243 main.log.report( "_____________________________________________" )
244 main.case( "Starting LINC-OE and other components" )
245 main.step( "Starting LINC-OE and other components" )
246 startConsoleResult = main.LincOE1.startConsole()
247 opticalMnScript = main.LincOE2.runOpticalMnScript()
248 onosTopoCfgResult = main.ONOSbench.runOnosTopoCfg(
249 instanceName=main.params[ 'CTRL' ][ 'ip1' ],
250 jsonFile=main.params[ 'OPTICAL' ][ 'jsonfile' ] )
shahshreyae6c7cf42014-11-26 16:39:01 -0800251
shahshreyafac62b12015-01-20 16:16:13 -0800252 print "start_console_result =", startConsoleResult
253 print "optical_mn_script = ", opticalMnScript
254 print "onos_topo_cfg_result =", onosTopoCfgResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800255
shahshreyafac62b12015-01-20 16:16:13 -0800256 case21Result = startConsoleResult and opticalMnScript and \
257 onosTopoCfgResult
258 utilities.assert_equals(
259 expect=main.TRUE,
260 actual=case21Result,
261 onpass="Packet optical topology spawned successsfully",
262 onfail="Packet optical topology spawning failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800263
shahshreyafac62b12015-01-20 16:16:13 -0800264 def CASE22( self, main ):
265 """
266 Curretly we use, 4 linear switch optical topology and
267 2 packet layer mininet switches each with one host.
268 Therefore, the roadmCount variable = 4,
269 packetLayerSWCount variable = 2 and hostCount = 2
270 and this is hardcoded in the testcase. If the topology changes,
271 these hardcoded values need to be changed
272 """
273 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800274 "This testcase compares the optical+packet topology against what" +
275 " is expected" )
shahshreyafac62b12015-01-20 16:16:13 -0800276 main.case( "Topology comparision" )
277 main.step( "Topology comparision" )
278 main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
279 devicesResult = main.ONOS3.devices( jsonFormat=False )
shahshreyae6c7cf42014-11-26 16:39:01 -0800280
shahshreyafac62b12015-01-20 16:16:13 -0800281 print "devices_result = ", devicesResult
282 devicesLinewise = devicesResult.split( "\n" )
shahshreya82ecd282015-02-05 16:48:03 -0800283 devicesLinewise = devicesLinewise[ 1: ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800284 roadmCount = 0
285 packetLayerSWCount = 0
shahshreyafac62b12015-01-20 16:16:13 -0800286 for line in devicesLinewise:
287 components = line.split( "," )
288 availability = components[ 1 ].split( "=" )[ 1 ]
289 type = components[ 3 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800290 if availability == 'true' and type == 'ROADM':
291 roadmCount += 1
shahshreyafac62b12015-01-20 16:16:13 -0800292 elif availability == 'true' and type == 'SWITCH':
shahshreyae6c7cf42014-11-26 16:39:01 -0800293 packetLayerSWCount += 1
294 if roadmCount == 4:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800295 print "Number of Optical Switches = %d and is" % roadmCount +\
296 " correctly detected"
shahshreyafac62b12015-01-20 16:16:13 -0800297 main.log.info(
298 "Number of Optical Switches = " +
299 str( roadmCount ) +
300 " and is correctly detected" )
301 opticalSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800302 else:
shahshreyafac62b12015-01-20 16:16:13 -0800303 print "Number of Optical Switches = %d and is wrong" % roadmCount
304 main.log.info(
305 "Number of Optical Switches = " +
306 str( roadmCount ) +
307 " and is wrong" )
308 opticalSWResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800309
310 if packetLayerSWCount == 2:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800311 print "Number of Packet layer or mininet Switches = %d "\
312 % packetLayerSWCount + "and is correctly detected"
shahshreyafac62b12015-01-20 16:16:13 -0800313 main.log.info(
314 "Number of Packet layer or mininet Switches = " +
315 str( packetLayerSWCount ) +
316 " and is correctly detected" )
317 packetSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800318 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800319 print "Number of Packet layer or mininet Switches = %d and"\
320 % packetLayerSWCount + " is wrong"
shahshreyafac62b12015-01-20 16:16:13 -0800321 main.log.info(
322 "Number of Packet layer or mininet Switches = " +
323 str( packetLayerSWCount ) +
324 " and is wrong" )
325 packetSWResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800326 print "_________________________________"
shahshreyafac62b12015-01-20 16:16:13 -0800327
328 linksResult = main.ONOS3.links( jsonFormat=False )
329 print "links_result = ", linksResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800330 print "_________________________________"
shahshreyafac62b12015-01-20 16:16:13 -0800331
332 # NOTE:Since only point intents are added, there is no
333 # requirement to discover the hosts
334 # Therfore, the below portion of the code is commented.
335 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800336 #Discover hosts using pingall
shahshreyafac62b12015-01-20 16:16:13 -0800337 pingallResult = main.LincOE2.pingall()
338
339 hostsResult = main.ONOS3.hosts( jsonFormat=False )
340 main.log.info( "hosts_result = "+hostsResult )
341 main.log.info( "_________________________________" )
342 hostsLinewise = hostsResult.split( "\n" )
343 hostsLinewise = hostsLinewise[ 1:-1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800344 hostCount = 0
shahshreyafac62b12015-01-20 16:16:13 -0800345 for line in hostsLinewise:
346 hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800347 hostCount +=1
348 if hostCount ==2:
349 print "Number of hosts = %d and is correctly detected" %hostCount
shahshreyafac62b12015-01-20 16:16:13 -0800350 main.log.info( "Number of hosts = " + str( hostCount ) +" and \
351 is correctly detected" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800352 hostDiscovery = main.TRUE
353 else:
354 print "Number of hosts = %d and is wrong" %hostCount
shahshreyafac62b12015-01-20 16:16:13 -0800355 main.log.info( "Number of hosts = " + str( hostCount ) +" and \
356 is wrong" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800357 hostDiscovery = main.FALSE
shahshreyafac62b12015-01-20 16:16:13 -0800358 """
359 case22Result = opticalSWResult and packetSWResult
360 utilities.assert_equals(
361 expect=main.TRUE,
362 actual=case22Result,
363 onpass="Packet optical topology discovery successful",
364 onfail="Packet optical topology discovery failed" )
shahshreya0e81ed92014-12-08 16:57:17 -0800365
shahshreyafac62b12015-01-20 16:16:13 -0800366 def CASE23( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800367 import time
shahshreyafac62b12015-01-20 16:16:13 -0800368 """
369 Add bidirectional point intents between 2 packet layer( mininet )
370 devices and
shahshreyae6c7cf42014-11-26 16:39:01 -0800371 ping mininet hosts
shahshreyafac62b12015-01-20 16:16:13 -0800372 """
373 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800374 "This testcase adds bidirectional point intents between 2 " +
375 "packet layer( mininet ) devices and ping mininet hosts" )
shahshreyafac62b12015-01-20 16:16:13 -0800376 main.case( "Topology comparision" )
377 main.step( "Adding point intents" )
378 ptpIntentResult = main.ONOS3.addPointIntent(
379 "of:0000ffffffff0001/1",
380 "of:0000ffffffff0002/1" )
381 if ptpIntentResult == main.TRUE:
382 main.ONOS3.intents( jsonFormat=False )
383 main.log.info( "Point to point intent install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800384
shahshreyafac62b12015-01-20 16:16:13 -0800385 ptpIntentResult = main.ONOS3.addPointIntent(
386 "of:0000ffffffff0002/1",
387 "of:0000ffffffff0001/1" )
388 if ptpIntentResult == main.TRUE:
389 main.ONOS3.intents( jsonFormat=False )
390 main.log.info( "Point to point intent install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800391
shahshreyafac62b12015-01-20 16:16:13 -0800392 time.sleep( 10 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800393 flowHandle = main.ONOS3.flows()
shahshreyafac62b12015-01-20 16:16:13 -0800394 main.log.info( "flows :" + flowHandle )
shahshreyae6c7cf42014-11-26 16:39:01 -0800395
396 # Sleep for 30 seconds to provide time for the intent state to change
shahshreyafac62b12015-01-20 16:16:13 -0800397 time.sleep( 30 )
398 intentHandle = main.ONOS3.intents( jsonFormat=False )
399 main.log.info( "intents :" + intentHandle )
400
401 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800402 count = 1
shahshreyafac62b12015-01-20 16:16:13 -0800403 main.log.info( "\n\nh1 is Pinging h2" )
404 ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
405 # ping = main.LincOE2.pinghost()
406 if ping == main.FALSE and count < 5:
407 count += 1
408 PingResult = main.FALSE
409 main.log.info(
410 "Ping between h1 and h2 failed. Making attempt number " +
411 str( count ) +
412 " in 2 seconds" )
413 time.sleep( 2 )
414 elif ping == main.FALSE:
415 main.log.info( "All ping attempts between h1 and h2 have failed" )
416 PingResult = main.FALSE
417 elif ping == main.TRUE:
418 main.log.info( "Ping test between h1 and h2 passed!" )
419 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800420 else:
shahshreyafac62b12015-01-20 16:16:13 -0800421 main.log.info( "Unknown error" )
422 PingResult = main.ERROR
shahshreyae6c7cf42014-11-26 16:39:01 -0800423
shahshreyafac62b12015-01-20 16:16:13 -0800424 if PingResult == main.FALSE:
425 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800426 "Point intents for packet optical have not ben installed" +
427 " correctly. Cleaning up" )
shahshreyafac62b12015-01-20 16:16:13 -0800428 if PingResult == main.TRUE:
429 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800430 "Point Intents for packet optical have been " +
431 "installed correctly" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800432
shahshreyafac62b12015-01-20 16:16:13 -0800433 case23Result = PingResult
434 utilities.assert_equals(
435 expect=main.TRUE,
436 actual=case23Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800437 onpass= "Point intents addition for packet optical and" +
438 "Pingall Test successful",
439 onfail= "Point intents addition for packet optical and" +
440 "Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800441
shahshreyafac62b12015-01-20 16:16:13 -0800442 def CASE24( self, main ):
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800443 import time
444 import json
shahshreyafac62b12015-01-20 16:16:13 -0800445 """
446 Test Rerouting of Packet Optical by bringing a port down
447 ( port 22 ) of a switch( switchID=1 ), so that link
448 ( between switch1 port22 - switch4-port30 ) is inactive
449 and do a ping test. If rerouting is successful,
450 ping should pass. also check the flows
451 """
452 main.log.report(
453 "This testcase tests rerouting and pings mininet hosts" )
454 main.case( "Test rerouting and pings mininet hosts" )
455 main.step( "Bring a port down and verify the link state" )
456 main.LincOE1.portDown( swId="1", ptId="22" )
457 linksNonjson = main.ONOS3.links( jsonFormat=False )
458 main.log.info( "links = " + linksNonjson )
shahshreyae6c7cf42014-11-26 16:39:01 -0800459
shahshreya0e81ed92014-12-08 16:57:17 -0800460 links = main.ONOS3.links()
shahshreyafac62b12015-01-20 16:16:13 -0800461 main.log.info( "links = " + links )
462
463 linksResult = json.loads( links )
464 linksStateResult = main.FALSE
465 for item in linksResult:
466 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
467 'src' ][ 'port' ] == "22":
468 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff04" and item[
469 'dst' ][ 'port' ] == "30":
470 linksState = item[ 'state' ]
471 if linksState == "INACTIVE":
472 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800473 "Links state is inactive as expected due to one" +
474 " of the ports being down" )
shahshreyafac62b12015-01-20 16:16:13 -0800475 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800476 "Links state is inactive as expected due to one" +
477 " of the ports being down" )
shahshreyafac62b12015-01-20 16:16:13 -0800478 linksStateResult = main.TRUE
shahshreya0e81ed92014-12-08 16:57:17 -0800479 break
480 else:
shahshreyafac62b12015-01-20 16:16:13 -0800481 main.log.info(
482 "Links state is not inactive as expected" )
483 main.log.report(
484 "Links state is not inactive as expected" )
485 linksStateResult = main.FALSE
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800486
shahshreyafac62b12015-01-20 16:16:13 -0800487 print "links_state_result = ", linksStateResult
488 time.sleep( 10 )
shahshreya0e81ed92014-12-08 16:57:17 -0800489 flowHandle = main.ONOS3.flows()
shahshreyafac62b12015-01-20 16:16:13 -0800490 main.log.info( "flows :" + flowHandle )
shahshreya0e81ed92014-12-08 16:57:17 -0800491
shahshreyafac62b12015-01-20 16:16:13 -0800492 main.step( "Verify Rerouting by a ping test" )
493 PingResult = main.TRUE
494 count = 1
495 main.log.info( "\n\nh1 is Pinging h2" )
496 ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
497 # ping = main.LincOE2.pinghost()
498 if ping == main.FALSE and count < 5:
499 count += 1
500 PingResult = main.FALSE
501 main.log.info(
502 "Ping between h1 and h2 failed. Making attempt number " +
503 str( count ) +
504 " in 2 seconds" )
505 time.sleep( 2 )
506 elif ping == main.FALSE:
507 main.log.info( "All ping attempts between h1 and h2 have failed" )
508 PingResult = main.FALSE
509 elif ping == main.TRUE:
510 main.log.info( "Ping test between h1 and h2 passed!" )
511 PingResult = main.TRUE
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800512 else:
shahshreyafac62b12015-01-20 16:16:13 -0800513 main.log.info( "Unknown error" )
514 PingResult = main.ERROR
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800515
shahshreyafac62b12015-01-20 16:16:13 -0800516 if PingResult == main.TRUE:
517 main.log.report( "Ping test successful " )
518 if PingResult == main.FALSE:
519 main.log.report( "Ping test failed" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800520
shahshreyafac62b12015-01-20 16:16:13 -0800521 case24Result = PingResult and linksStateResult
522 utilities.assert_equals( expect=main.TRUE, actual=case24Result,
shahshreya9294c8d2015-01-21 15:54:16 -0800523 onpass="Packet optical rerouting successful",
524 onfail="Packet optical rerouting failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800525
shahshreyafac62b12015-01-20 16:16:13 -0800526 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800527 import re
528 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800529 main.log.report( "This testcase is testing the assignment of" +
530 " all the switches to all the controllers and" +
shahshreyadcb08e82015-02-25 10:16:42 -0800531 " discovering the hosts in reactive mode" )
shahshreyafac62b12015-01-20 16:16:13 -0800532 main.log.report( "__________________________________" )
533 main.case( "Pingall Test" )
534 main.step( "Assigning switches to controllers" )
535 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
536 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
537 for i in range( 1, 29 ):
538 if i == 1:
539 main.Mininet1.assignSwController(
540 sw=str( i ),
541 ip1=ONOS1Ip,
542 port1=ONOS1Port )
543 elif i >= 2 and i < 5:
544 main.Mininet1.assignSwController(
545 sw=str( i ),
546 ip1=ONOS1Ip,
547 port1=ONOS1Port )
548 elif i >= 5 and i < 8:
549 main.Mininet1.assignSwController(
550 sw=str( i ),
551 ip1=ONOS1Ip,
552 port1=ONOS1Port )
553 elif i >= 8 and i < 18:
554 main.Mininet1.assignSwController(
555 sw=str( i ),
556 ip1=ONOS1Ip,
557 port1=ONOS1Port )
558 elif i >= 18 and i < 28:
559 main.Mininet1.assignSwController(
560 sw=str( i ),
561 ip1=ONOS1Ip,
562 port1=ONOS1Port )
shahshreya4e13a062014-11-11 16:46:18 -0800563 else:
shahshreyafac62b12015-01-20 16:16:13 -0800564 main.Mininet1.assignSwController(
565 sw=str( i ),
566 ip1=ONOS1Ip,
567 port1=ONOS1Port )
568 SwitchMastership = main.TRUE
569 for i in range( 1, 29 ):
570 if i == 1:
571 response = main.Mininet1.getSwController( "s" + str( i ) )
572 print( "Response is " + str( response ) )
573 if re.search( "tcp:" + ONOS1Ip, response ):
574 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800575 else:
shahshreyafac62b12015-01-20 16:16:13 -0800576 SwitchMastership = main.FALSE
577 elif i >= 2 and i < 5:
578 response = main.Mininet1.getSwController( "s" + str( i ) )
579 print( "Response is " + str( response ) )
580 if re.search( "tcp:" + ONOS1Ip, response ):
581 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800582 else:
shahshreyafac62b12015-01-20 16:16:13 -0800583 SwitchMastership = main.FALSE
584 elif i >= 5 and i < 8:
585 response = main.Mininet1.getSwController( "s" + str( i ) )
586 print( "Response is " + str( response ) )
587 if re.search( "tcp:" + ONOS1Ip, response ):
588 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800589 else:
shahshreyafac62b12015-01-20 16:16:13 -0800590 SwitchMastership = main.FALSE
591 elif i >= 8 and i < 18:
592 response = main.Mininet1.getSwController( "s" + str( i ) )
593 print( "Response is " + str( response ) )
594 if re.search( "tcp:" + ONOS1Ip, response ):
595 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800596 else:
shahshreyafac62b12015-01-20 16:16:13 -0800597 SwitchMastership = main.FALSE
598 elif i >= 18 and i < 28:
599 response = main.Mininet1.getSwController( "s" + str( i ) )
600 print( "Response is " + str( response ) )
601 if re.search( "tcp:" + ONOS1Ip, response ):
602 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800603 else:
shahshreyafac62b12015-01-20 16:16:13 -0800604 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800605 else:
shahshreyafac62b12015-01-20 16:16:13 -0800606 response = main.Mininet1.getSwController( "s" + str( i ) )
607 print( "Response is" + str( response ) )
608 if re.search( "tcp:" + ONOS1Ip, response ):
609 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800610 else:
shahshreyafac62b12015-01-20 16:16:13 -0800611 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800612
shahshreyafac62b12015-01-20 16:16:13 -0800613 if SwitchMastership == main.TRUE:
614 main.log.report( "Controller assignmnet successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800615 else:
shahshreyafac62b12015-01-20 16:16:13 -0800616 main.log.report( "Controller assignmnet failed" )
617 utilities.assert_equals(
618 expect=main.TRUE,
619 actual=SwitchMastership,
620 onpass="MasterControllers assigned correctly" )
621 """
622 for i in range ( 1,29 ):
623 main.Mininet1.assignSwController( sw=str( i ),count=5,
624 ip1=ONOS1Ip,port1=ONOS1Port,
625 ip2=ONOS2Ip,port2=ONOS2Port,
626 ip3=ONOS3Ip,port3=ONOS3Port,
627 ip4=ONOS4Ip,port4=ONOS4Port,
628 ip5=ONOS5Ip,port5=ONOS5Port )
629 """
630 # REACTIVE FWD test
shahshreya4e13a062014-11-11 16:46:18 -0800631
shahshreyafac62b12015-01-20 16:16:13 -0800632 main.step( "Get list of hosts from Mininet" )
633 hostList = main.Mininet1.getHosts()
634 main.log.info( hostList )
shahshreya4e13a062014-11-11 16:46:18 -0800635
shahshreyafac62b12015-01-20 16:16:13 -0800636 main.step( "Get host list in ONOS format" )
637 hostOnosList = main.ONOS2.getHostsId( hostList )
638 main.log.info( hostOnosList )
639 # time.sleep( 5 )
640
641 main.step( "Pingall" )
642 pingResult = main.FALSE
shahshreya82ecd282015-02-05 16:48:03 -0800643 time1 = time.time()
644 pingResult = main.Mininet1.pingall()
645 time2 = time.time()
646 print "Time for pingall: %2f seconds" % ( time2 - time1 )
shahshreya4e13a062014-11-11 16:46:18 -0800647
shahshreyafac62b12015-01-20 16:16:13 -0800648 # Start onos cli again because u might have dropped out of
649 # onos prompt to the shell prompt
650 # if there was no activity
651 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
652
653 case4Result = SwitchMastership and pingResult
654 if pingResult == main.TRUE:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800655 main.log.report( "Pingall Test in reactive mode to" +
656 " discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800657 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800658 main.log.report( "Pingall Test in reactive mode to" +
659 " discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800660
shahshreyafac62b12015-01-20 16:16:13 -0800661 utilities.assert_equals(
662 expect=main.TRUE,
663 actual=case4Result,
664 onpass="Controller assignment and Pingall Test successful",
665 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800666
shahshreyafac62b12015-01-20 16:16:13 -0800667 def CASE10( self ):
668 main.log.report(
669 "This testcase uninstalls the reactive forwarding app" )
670 main.log.report( "__________________________________" )
671 main.case( "Uninstalling reactive forwarding app" )
672 # Unistall onos-app-fwd app to disable reactive forwarding
673 appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
674 main.log.info( "onos-app-fwd uninstalled" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800675
shahshreyafac62b12015-01-20 16:16:13 -0800676 # After reactive forwarding is disabled, the reactive flows on
677 # switches timeout in 10-15s
678 # So sleep for 15s
679 time.sleep( 15 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800680
681 flows = main.ONOS2.flows()
shahshreyafac62b12015-01-20 16:16:13 -0800682 main.log.info( flows )
shahshreyae6c7cf42014-11-26 16:39:01 -0800683
shahshreyafac62b12015-01-20 16:16:13 -0800684 case10Result = appUninstallResult
685 utilities.assert_equals(
686 expect=main.TRUE,
687 actual=case10Result,
688 onpass="Reactive forwarding app uninstallation successful",
689 onfail="Reactive forwarding app uninstallation failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800690
shahshreyadcb08e82015-02-25 10:16:42 -0800691
692 def CASE11( self ):
693 # NOTE: This testcase require reactive forwarding mode enabled
694 # NOTE: in the beginning and then uninstall it before adding
695 # NOTE: point intents. Again the app is installed so that
696 # NOTE: testcase 10 can be ran successively
697 import time
698 main.log.report(
699 "This testcase moves a host from one switch to another to add" +
700 "point intents between them and then perform ping" )
701 main.log.report( "__________________________________" )
702 main.log.info( "Moving host from one switch to another" )
703 main.case( "Moving host from a device and attach it to another device" )
704 main.step( "Moving host h9 from device s9 and attach it to s8" )
705 main.Mininet1.moveHost(host = 'h9', oldSw = 's9', newSw = 's8')
706
707 time.sleep(15) #Time delay to have all the flows ready
708 main.step( "Pingall" )
709 pingResult = main.FALSE
710 time1 = time.time()
711 pingResult = main.Mininet1.pingall()
712 time2 = time.time()
713 print "Time for pingall: %2f seconds" % ( time2 - time1 )
714
715 hosts = main.ONOS2.hosts( jsonFormat = False )
716 main.log.info( hosts )
717
718 main.case( "Uninstalling reactive forwarding app" )
719 # Unistall onos-app-fwd app to disable reactive forwarding
720 appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
721 main.log.info( "onos-app-fwd uninstalled" )
722
723 main.step( "Add point intents between hosts on the same device")
724 ptpIntentResult = main.ONOS2.addPointIntent(
725 "of:0000000000003008/1",
726 "of:0000000000003008/3" )
727 if ptpIntentResult == main.TRUE:
728 getIntentResult = main.ONOS2.intents()
729 main.log.info( "Point to point intent install successful" )
730 # main.log.info( getIntentResult )
731
732 ptpIntentResult = main.ONOS2.addPointIntent(
733 "of:0000000000003008/3",
734 "of:0000000000003008/1" )
735 if ptpIntentResult == main.TRUE:
736 getIntentResult = main.ONOS2.intents()
737 main.log.info( "Point to point intent install successful" )
738 # main.log.info( getIntentResult )
739
740 main.case( "Ping hosts on the same devices" )
741 ping = main.Mininet1.pingHost( src = 'h8', target = 'h9' )
742
743 '''
744 main.case( "Installing reactive forwarding app" )
745 # Install onos-app-fwd app to enable reactive forwarding
746 appUninstallResult = main.ONOS2.featureInstall( "onos-app-fwd" )
747 main.log.info( "onos-app-fwd installed" )
748 '''
749
750 if ping == main.FALSE:
751 main.log.report(
752 "Point intents for hosts on same devices haven't" +
753 " been installed correctly. Cleaning up" )
754 if ping == main.TRUE:
755 main.log.report(
756 "Point intents for hosts on same devices" +
757 "installed correctly. Cleaning up" )
758
759 case11Result = ping and pingResult
760 utilities.assert_equals(
761 expect=main.TRUE,
762 actual=case11Result,
763 onpass= "Point intents for hosts on same devices" +
764 "Ping Test successful",
765 onfail= "Point intents for hosts on same devices" +
766 "Ping Test NOT successful" )
767
768
shahshreyafac62b12015-01-20 16:16:13 -0800769 def CASE6( self ):
shahshreyadcb08e82015-02-25 10:16:42 -0800770 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800771 main.log.report( "This testcase is testing the addition of" +
772 " host intents and then does pingall" )
shahshreyafac62b12015-01-20 16:16:13 -0800773 main.log.report( "__________________________________" )
774 main.case( "Obtaining host id's" )
775 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800776 hosts = main.ONOS2.hosts()
shahshreyafac62b12015-01-20 16:16:13 -0800777 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800778
shahshreyafac62b12015-01-20 16:16:13 -0800779 main.step( "Get all devices id" )
780 devicesIdList = main.ONOS2.getAllDevicesId()
781 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -0800782
shahshreyafac62b12015-01-20 16:16:13 -0800783 # ONOS displays the hosts in hex format unlike mininet which does
784 # in decimal format
785 # So take care while adding intents
786 """
787 main.step( "Add host-to-host intents for mininet hosts h8 and h18 or
788 ONOS hosts h8 and h12" )
789 hthIntentResult = main.ONOS2.addHostIntent(
790 "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
791 hthIntentResult = main.ONOS2.addHostIntent(
792 "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
793 hthIntentResult = main.ONOS2.addHostIntent(
794 "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
795 hthIntentResult = main.ONOS2.addHostIntent(
796 "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
797 hthIntentResult = main.ONOS2.addHostIntent(
798 "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
799 hthIntentResult = main.ONOS2.addHostIntent(
800 "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
801 hthIntentResult = main.ONOS2.addHostIntent(
802 "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
803 hthIntentResult = main.ONOS2.addHostIntent(
804 "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
805 hthIntentResult = main.ONOS2.addHostIntent(
806 "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
807 hthIntentResult = main.ONOS2.addHostIntent(
808 "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
809 print "______________________________________________________"
810 """
811 for i in range( 8, 18 ):
812 main.log.info(
813 "Adding host intent between h" + str( i ) +
814 " and h" + str( i + 10 ) )
815 host1 = "00:00:00:00:00:" + \
816 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
817 host2 = "00:00:00:00:00:" + \
818 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
819 # NOTE: get host can return None
820 # TODO: handle this
821 host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
shahshreyadcb08e82015-02-25 10:16:42 -0800822
shahshreyafac62b12015-01-20 16:16:13 -0800823 host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
824 main.ONOS2.addHostIntent( host1Id, host2Id )
825
826 time.sleep( 10 )
827 hIntents = main.ONOS2.intents( jsonFormat=False )
828 main.log.info( "intents:" + hIntents )
shahshreyadcb08e82015-02-25 10:16:42 -0800829 flows = main.ONOS2.flows()
830 main.log.info( "flows:" + flows )
shahshreya4e13a062014-11-11 16:46:18 -0800831
832 count = 1
833 i = 8
shahshreyafac62b12015-01-20 16:16:13 -0800834 PingResult = main.TRUE
835 # while i<10:
836 while i < 18:
837 main.log.info(
838 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
839 ping = main.Mininet1.pingHost(
840 src="h" + str( i ), target="h" + str( i + 10 ) )
841 if ping == main.FALSE and count < 5:
842 count += 1
843 # i = 8
844 PingResult = main.FALSE
845 main.log.report( "Ping between h" +
846 str( i ) +
847 " and h" +
848 str( i +
849 10 ) +
850 " failed. Making attempt number " +
851 str( count ) +
852 " in 2 seconds" )
853 time.sleep( 2 )
854 elif ping == main.FALSE:
855 main.log.report( "All ping attempts between h" +
856 str( i ) +
857 " and h" +
858 str( i +
859 10 ) +
860 "have failed" )
861 i = 19
862 PingResult = main.FALSE
863 elif ping == main.TRUE:
864 main.log.info( "Ping test between h" +
865 str( i ) +
866 " and h" +
867 str( i +
868 10 ) +
869 "passed!" )
870 i += 1
871 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800872 else:
shahshreyafac62b12015-01-20 16:16:13 -0800873 main.log.info( "Unknown error" )
874 PingResult = main.ERROR
875 if PingResult == main.FALSE:
876 main.log.report(
shahshreya9294c8d2015-01-21 15:54:16 -0800877 "Ping all test after Host intent addition failed.Cleaning up" )
shahshreyafac62b12015-01-20 16:16:13 -0800878 # main.cleanup()
879 # main.exit()
880 if PingResult == main.TRUE:
881 main.log.report(
882 "Ping all test after Host intent addition successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800883
shahshreyafac62b12015-01-20 16:16:13 -0800884 case6Result = PingResult
885 utilities.assert_equals(
886 expect=main.TRUE,
887 actual=case6Result,
888 onpass="Pingall Test after Host intents addition successful",
889 onfail="Pingall Test after Host intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800890
shahshreyafac62b12015-01-20 16:16:13 -0800891 def CASE5( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800892 import json
shahshreyafac62b12015-01-20 16:16:13 -0800893 # assumes that sts is already in you PYTHONPATH
shahshreya9294c8d2015-01-21 15:54:16 -0800894 from sts.topology.teston_topology import TestONTopology
shahshreyafac62b12015-01-20 16:16:13 -0800895 # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800896 main.log.report( "This testcase is testing if all ONOS nodes" +
897 " are in topology sync with mininet" )
shahshreyafac62b12015-01-20 16:16:13 -0800898 main.log.report( "__________________________________" )
899 main.case( "Comparing Mininet topology with the topology of ONOS" )
900 main.step( "Start continuous pings" )
901 main.Mininet2.pingLong(
902 src=main.params[ 'PING' ][ 'source1' ],
903 target=main.params[ 'PING' ][ 'target1' ],
904 pingTime=500 )
905 main.Mininet2.pingLong(
906 src=main.params[ 'PING' ][ 'source2' ],
907 target=main.params[ 'PING' ][ 'target2' ],
908 pingTime=500 )
909 main.Mininet2.pingLong(
910 src=main.params[ 'PING' ][ 'source3' ],
911 target=main.params[ 'PING' ][ 'target3' ],
912 pingTime=500 )
913 main.Mininet2.pingLong(
914 src=main.params[ 'PING' ][ 'source4' ],
915 target=main.params[ 'PING' ][ 'target4' ],
916 pingTime=500 )
917 main.Mininet2.pingLong(
918 src=main.params[ 'PING' ][ 'source5' ],
919 target=main.params[ 'PING' ][ 'target5' ],
920 pingTime=500 )
921 main.Mininet2.pingLong(
922 src=main.params[ 'PING' ][ 'source6' ],
923 target=main.params[ 'PING' ][ 'target6' ],
924 pingTime=500 )
925 main.Mininet2.pingLong(
926 src=main.params[ 'PING' ][ 'source7' ],
927 target=main.params[ 'PING' ][ 'target7' ],
928 pingTime=500 )
929 main.Mininet2.pingLong(
930 src=main.params[ 'PING' ][ 'source8' ],
931 target=main.params[ 'PING' ][ 'target8' ],
932 pingTime=500 )
933 main.Mininet2.pingLong(
934 src=main.params[ 'PING' ][ 'source9' ],
935 target=main.params[ 'PING' ][ 'target9' ],
936 pingTime=500 )
937 main.Mininet2.pingLong(
938 src=main.params[ 'PING' ][ 'source10' ],
939 target=main.params[ 'PING' ][ 'target10' ],
940 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -0800941
shahshreyafac62b12015-01-20 16:16:13 -0800942 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800943 global ctrls
944 ctrls = []
945 count = 1
946 while True:
947 temp = ()
shahshreyafac62b12015-01-20 16:16:13 -0800948 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
949 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
950 temp = temp + ( "ONOS" + str( count ), )
951 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
952 temp = temp + \
953 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
954 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800955 count = count + 1
956 else:
957 break
958 global MNTopo
shahshreyafac62b12015-01-20 16:16:13 -0800959 Topo = TestONTopology(
960 main.Mininet1,
961 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800962 MNTopo = Topo
963
shahshreyafac62b12015-01-20 16:16:13 -0800964 TopologyCheck = main.TRUE
965 main.step( "Compare ONOS Topology to MN Topology" )
966 devicesJson = main.ONOS2.devices()
967 linksJson = main.ONOS2.links()
968 # portsJson = main.ONOS2.ports()
969
970 result1 = main.Mininet1.compareSwitches(
971 MNTopo,
972 json.loads( devicesJson ) )
973 result2 = main.Mininet1.compareLinks(
974 MNTopo,
975 json.loads( linksJson ) )
976 # result3 = main.Mininet1.comparePorts(
977 # MNTopo, json.loads( portsJson ) )
978
979 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -0800980 result = result1 and result2
shahshreyafac62b12015-01-20 16:16:13 -0800981
shahshreya4e13a062014-11-11 16:46:18 -0800982 print "***********************"
983 if result == main.TRUE:
shahshreyafac62b12015-01-20 16:16:13 -0800984 main.log.report( "ONOS" + " Topology matches MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -0800985 else:
shahshreyafac62b12015-01-20 16:16:13 -0800986 main.log.report( "ONOS" + " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -0800987
shahshreyafac62b12015-01-20 16:16:13 -0800988 utilities.assert_equals(
989 expect=main.TRUE,
990 actual=result,
991 onpass="ONOS" +
992 " Topology matches MN Topology",
993 onfail="ONOS" +
994 " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -0800995
shahshreyafac62b12015-01-20 16:16:13 -0800996 TopologyCheck = TopologyCheck and result
997 utilities.assert_equals(
998 expect=main.TRUE,
999 actual=TopologyCheck,
1000 onpass="Topology checks passed",
1001 onfail="Topology checks failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001002
shahshreyafac62b12015-01-20 16:16:13 -08001003 def CASE7( self, main ):
shahshreya9294c8d2015-01-21 15:54:16 -08001004 from sts.topology.teston_topology import TestONTopology
shahshreya4e13a062014-11-11 16:46:18 -08001005
shahshreyafac62b12015-01-20 16:16:13 -08001006 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -08001007
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001008 main.log.report( "This testscase is killing a link to ensure that" +
1009 " link discovery is consistent" )
shahshreyafac62b12015-01-20 16:16:13 -08001010 main.log.report( "__________________________________" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001011 main.log.report( "Killing a link to ensure that link discovery" +
1012 " is consistent" )
1013 main.case( "Killing a link to Ensure that Link Discovery" +
1014 "is Working Properly" )
shahshreyafac62b12015-01-20 16:16:13 -08001015 """
1016 main.step( "Start continuous pings" )
shahshreya4e13a062014-11-11 16:46:18 -08001017
shahshreyafac62b12015-01-20 16:16:13 -08001018 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
1019 target=main.params[ 'PING' ][ 'target1' ],
1020 pingTime=500 )
1021 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
1022 target=main.params[ 'PING' ][ 'target2' ],
1023 pingTime=500 )
1024 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
1025 target=main.params[ 'PING' ][ 'target3' ],
1026 pingTime=500 )
1027 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
1028 target=main.params[ 'PING' ][ 'target4' ],
1029 pingTime=500 )
1030 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
1031 target=main.params[ 'PING' ][ 'target5' ],
1032 pingTime=500 )
1033 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
1034 target=main.params[ 'PING' ][ 'target6' ],
1035 pingTime=500 )
1036 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
1037 target=main.params[ 'PING' ][ 'target7' ],
1038 pingTime=500 )
1039 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
1040 target=main.params[ 'PING' ][ 'target8' ],
1041 pingTime=500 )
1042 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
1043 target=main.params[ 'PING' ][ 'target9' ],
1044 pingTime=500 )
1045 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
1046 target=main.params[ 'PING' ][ 'target10' ],
1047 pingTime=500 )
1048 """
1049 main.step( "Determine the current number of switches and links" )
1050 topologyOutput = main.ONOS2.topology()
1051 topologyResult = main.ONOS1.getTopology( topologyOutput )
1052 activeSwitches = topologyResult[ 'devices' ]
1053 links = topologyResult[ 'links' ]
1054 print "activeSwitches = ", type( activeSwitches )
1055 print "links = ", type( links )
1056 main.log.info(
1057 "Currently there are %s switches and %s links" %
1058 ( str( activeSwitches ), str( links ) ) )
1059
1060 main.step( "Kill Link between s3 and s28" )
1061 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
1062 time.sleep( linkSleep )
1063 topologyOutput = main.ONOS2.topology()
1064 LinkDown = main.ONOS1.checkStatus(
1065 topologyOutput, activeSwitches, str(
1066 int( links ) - 2 ) )
1067 if LinkDown == main.TRUE:
1068 main.log.report( "Link Down discovered properly" )
1069 utilities.assert_equals(
1070 expect=main.TRUE,
1071 actual=LinkDown,
1072 onpass="Link Down discovered properly",
1073 onfail="Link down was not discovered in " +
1074 str( linkSleep ) +
1075 " seconds" )
1076
1077 # Check ping result here..add code for it
1078
1079 main.step( "Bring link between s3 and s28 back up" )
1080 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
1081 time.sleep( linkSleep )
1082 topologyOutput = main.ONOS2.topology()
1083 LinkUp = main.ONOS1.checkStatus(
1084 topologyOutput,
1085 activeSwitches,
1086 str( links ) )
1087 if LinkUp == main.TRUE:
1088 main.log.report( "Link up discovered properly" )
1089 utilities.assert_equals(
1090 expect=main.TRUE,
1091 actual=LinkUp,
1092 onpass="Link up discovered properly",
1093 onfail="Link up was not discovered in " +
1094 str( linkSleep ) +
1095 " seconds" )
1096
1097 # NOTE Check ping result here..add code for it
1098
1099 main.step( "Compare ONOS Topology to MN Topology" )
1100 Topo = TestONTopology(
1101 main.Mininet1,
1102 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -08001103 MNTopo = Topo
shahshreyafac62b12015-01-20 16:16:13 -08001104 TopologyCheck = main.TRUE
1105
1106 devicesJson = main.ONOS2.devices()
1107 linksJson = main.ONOS2.links()
1108 portsJson = main.ONOS2.ports()
1109
1110 result1 = main.Mininet1.compareSwitches(
1111 MNTopo,
1112 json.loads( devicesJson ) )
1113 result2 = main.Mininet1.compareLinks(
1114 MNTopo,
1115 json.loads( linksJson ) )
1116 # result3 = main.Mininet1.comparePorts(
1117 # MNTopo, json.loads( portsJson ) )
1118
1119 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001120 result = result1 and result2
1121 print "***********************"
shahshreyafac62b12015-01-20 16:16:13 -08001122
shahshreya4e13a062014-11-11 16:46:18 -08001123 if result == main.TRUE:
shahshreyafac62b12015-01-20 16:16:13 -08001124 main.log.report( "ONOS" + " Topology matches MN Topology" )
1125 utilities.assert_equals(
1126 expect=main.TRUE,
1127 actual=result,
1128 onpass="ONOS" +
1129 " Topology matches MN Topology",
1130 onfail="ONOS" +
1131 " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001132
shahshreyafac62b12015-01-20 16:16:13 -08001133 TopologyCheck = TopologyCheck and result
1134 utilities.assert_equals(
1135 expect=main.TRUE,
1136 actual=TopologyCheck,
1137 onpass="Topology checks passed",
1138 onfail="Topology checks failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001139
shahshreyafac62b12015-01-20 16:16:13 -08001140 result = LinkDown and LinkUp and TopologyCheck
1141 utilities.assert_equals( expect=main.TRUE, actual=result,
shahshreya9294c8d2015-01-21 15:54:16 -08001142 onpass="Link failure is discovered correctly",
1143 onfail="Link Discovery failed" )
shahshreyafac62b12015-01-20 16:16:13 -08001144
1145 def CASE8( self ):
1146 """
shahshreya82ecd282015-02-05 16:48:03 -08001147 Intent removal
shahshreyafac62b12015-01-20 16:16:13 -08001148 """
shahshreya82ecd282015-02-05 16:48:03 -08001149 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001150 main.log.report( "This testcase removes any previously added intents" +
shahshreya82ecd282015-02-05 16:48:03 -08001151 " before adding any new set of intents" )
shahshreyafac62b12015-01-20 16:16:13 -08001152 main.log.report( "__________________________________" )
shahshreya82ecd282015-02-05 16:48:03 -08001153 main.log.info( "intent removal" )
1154 main.case( "Removing installed intents" )
shahshreyafac62b12015-01-20 16:16:13 -08001155 main.step( "Obtain the intent id's" )
1156 intentResult = main.ONOS2.intents( jsonFormat=False )
1157 main.log.info( "intent_result = " + intentResult )
shahshreyafac62b12015-01-20 16:16:13 -08001158 intentLinewise = intentResult.split( "\n" )
shahshreyafac62b12015-01-20 16:16:13 -08001159
shahshreyadcb08e82015-02-25 10:16:42 -08001160 intentList = [line for line in intentLinewise \
1161 if line.startswith( "id=")]
1162 intentids = [line.split( "," )[ 0 ].split( "=" )[ 1 ] for line in \
1163 intentList]
shahshreya4e13a062014-11-11 16:46:18 -08001164 for id in intentids:
1165 print "id = ", id
shahshreyafac62b12015-01-20 16:16:13 -08001166
1167 main.step(
1168 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -08001169 for id in intentids:
shahshreyafac62b12015-01-20 16:16:13 -08001170 main.ONOS2.removeIntent( intentId=id )
shahshreyae6c7cf42014-11-26 16:39:01 -08001171
shahshreyafac62b12015-01-20 16:16:13 -08001172 intentResult = main.ONOS2.intents( jsonFormat=False )
1173 main.log.info( "intent_result = " + intentResult )
shahshreyadcb08e82015-02-25 10:16:42 -08001174
1175 intentList = [line for line in intentResult.split( "\n" ) \
1176 if line.startswith( "id=")]
1177 intentState = [line.split( "," )[ 1 ].split( "=" )[ 1 ] for line in \
1178 intentList]
1179 for state in intentState:
1180 print state
1181
1182 case8Result = main.TRUE
1183 for state in intentState:
1184 if state != 'WITHDRAWN':
1185 case8Result = main.FALSE
1186 break
1187
shahshreyafac62b12015-01-20 16:16:13 -08001188 if case8Result == main.TRUE:
1189 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001190 else:
shahshreyafac62b12015-01-20 16:16:13 -08001191 main.log.report( "Intent removal failed" )
1192
1193 PingResult = main.TRUE
1194 if case8Result == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001195 i = 8
shahshreyafac62b12015-01-20 16:16:13 -08001196 while i < 18:
1197 main.log.info(
1198 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1199 ping = main.Mininet1.pingHost(
1200 src="h" + str( i ), target="h" + str( i + 10 ) )
1201 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001202 i = 19
shahshreyafac62b12015-01-20 16:16:13 -08001203 PingResult = PingResult and main.TRUE
1204 elif ping == main.FALSE:
1205 i += 1
1206 PingResult = PingResult and main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -08001207 else:
shahshreyafac62b12015-01-20 16:16:13 -08001208 main.log.info( "Unknown error" )
1209 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001210
shahshreyafac62b12015-01-20 16:16:13 -08001211 # Note: If the ping result failed, that means the intents have been
1212 # withdrawn correctly.
1213 if PingResult == main.TRUE:
shahshreya82ecd282015-02-05 16:48:03 -08001214 main.log.report( "Installed intents have not been withdrawn correctly" )
shahshreyafac62b12015-01-20 16:16:13 -08001215 # main.cleanup()
1216 # main.exit()
1217 if PingResult == main.FALSE:
shahshreya82ecd282015-02-05 16:48:03 -08001218 main.log.report( "Installed intents have been withdrawn correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001219
shahshreyafac62b12015-01-20 16:16:13 -08001220 case8Result = case8Result and PingResult
shahshreyae6c7cf42014-11-26 16:39:01 -08001221
shahshreyafac62b12015-01-20 16:16:13 -08001222 if case8Result == main.FALSE:
1223 main.log.report( "Intent removal successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001224 else:
shahshreyafac62b12015-01-20 16:16:13 -08001225 main.log.report( "Intent removal failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001226
shahshreyafac62b12015-01-20 16:16:13 -08001227 utilities.assert_equals( expect=main.FALSE, actual=case8Result,
shahshreya9294c8d2015-01-21 15:54:16 -08001228 onpass="Intent removal test passed",
1229 onfail="Intent removal test failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001230
shahshreyafac62b12015-01-20 16:16:13 -08001231 def CASE9( self ):
1232 main.log.report(
1233 "This testcase adds point intents and then does pingall" )
1234 main.log.report( "__________________________________" )
1235 main.log.info( "Adding point intents" )
1236 main.case(
shahshreya71162c62015-01-23 15:31:16 -08001237 "Adding bidirectional point for mn hosts" +
1238 "( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22, " +
1239 "h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
shahshreya3dc3ce62015-01-22 13:31:59 -08001240
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001241 main.step( "Add point intents for mn hosts h8 and h18 or" +
1242 "ONOS hosts h8 and h12" )
shahshreya3dc3ce62015-01-22 13:31:59 -08001243 # main.step(var1)
shahshreyafac62b12015-01-20 16:16:13 -08001244 ptpIntentResult = main.ONOS2.addPointIntent(
1245 "of:0000000000003008/1",
1246 "of:0000000000006018/1" )
1247 if ptpIntentResult == main.TRUE:
1248 getIntentResult = main.ONOS2.intents()
1249 main.log.info( "Point to point intent install successful" )
1250 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001251
shahshreyafac62b12015-01-20 16:16:13 -08001252 ptpIntentResult = main.ONOS2.addPointIntent(
1253 "of:0000000000006018/1",
1254 "of:0000000000003008/1" )
1255 if ptpIntentResult == main.TRUE:
1256 getIntentResult = main.ONOS2.intents()
1257 main.log.info( "Point to point intent install successful" )
1258 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001259
shahshreya9294c8d2015-01-21 15:54:16 -08001260 var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
1261 main.step(var2)
shahshreyafac62b12015-01-20 16:16:13 -08001262 ptpIntentResult = main.ONOS2.addPointIntent(
1263 "of:0000000000003009/1",
1264 "of:0000000000006019/1" )
1265 if ptpIntentResult == main.TRUE:
1266 getIntentResult = main.ONOS2.intents()
1267 main.log.info( "Point to point intent install successful" )
1268 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001269
shahshreyafac62b12015-01-20 16:16:13 -08001270 ptpIntentResult = main.ONOS2.addPointIntent(
1271 "of:0000000000006019/1",
1272 "of:0000000000003009/1" )
1273 if ptpIntentResult == main.TRUE:
1274 getIntentResult = main.ONOS2.intents()
1275 main.log.info( "Point to point intent install successful" )
1276 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001277
shahshreya9294c8d2015-01-21 15:54:16 -08001278 var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
1279 main.step(var3)
shahshreyafac62b12015-01-20 16:16:13 -08001280 ptpIntentResult = main.ONOS2.addPointIntent(
1281 "of:0000000000003010/1",
1282 "of:0000000000006020/1" )
1283 if ptpIntentResult == main.TRUE:
1284 getIntentResult = main.ONOS2.intents()
1285 main.log.info( "Point to point intent install successful" )
1286 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001287
shahshreyafac62b12015-01-20 16:16:13 -08001288 ptpIntentResult = main.ONOS2.addPointIntent(
1289 "of:0000000000006020/1",
1290 "of:0000000000003010/1" )
1291 if ptpIntentResult == main.TRUE:
1292 getIntentResult = main.ONOS2.intents()
1293 main.log.info( "Point to point intent install successful" )
1294 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001295
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001296 var4 = "Add point intents for mininet hosts h11 and h21 or" +\
1297 " ONOS hosts hB and h15"
shahshreya9294c8d2015-01-21 15:54:16 -08001298 main.case(var4)
shahshreyafac62b12015-01-20 16:16:13 -08001299 ptpIntentResult = main.ONOS2.addPointIntent(
1300 "of:0000000000003011/1",
1301 "of:0000000000006021/1" )
1302 if ptpIntentResult == main.TRUE:
1303 getIntentResult = main.ONOS2.intents()
1304 main.log.info( "Point to point intent install successful" )
1305 # main.log.info( getIntentResult )
1306
1307 ptpIntentResult = main.ONOS2.addPointIntent(
1308 "of:0000000000006021/1",
1309 "of:0000000000003011/1" )
1310 if ptpIntentResult == main.TRUE:
1311 getIntentResult = main.ONOS2.intents()
1312 main.log.info( "Point to point intent install successful" )
1313 # main.log.info( getIntentResult )
1314
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001315 var5 = "Add point intents for mininet hosts h12 and h22 " +\
1316 "ONOS hosts hC and h16"
shahshreya9294c8d2015-01-21 15:54:16 -08001317 main.case(var5)
shahshreyafac62b12015-01-20 16:16:13 -08001318 ptpIntentResult = main.ONOS2.addPointIntent(
1319 "of:0000000000003012/1",
1320 "of:0000000000006022/1" )
1321 if ptpIntentResult == main.TRUE:
1322 getIntentResult = main.ONOS2.intents()
1323 main.log.info( "Point to point intent install successful" )
1324 # main.log.info( getIntentResult )
1325
1326 ptpIntentResult = main.ONOS2.addPointIntent(
1327 "of:0000000000006022/1",
1328 "of:0000000000003012/1" )
1329 if ptpIntentResult == main.TRUE:
1330 getIntentResult = main.ONOS2.intents()
1331 main.log.info( "Point to point intent install successful" )
1332 # main.log.info( getIntentResult )
1333
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001334 var6 = "Add point intents for mininet hosts h13 and h23 or" +\
1335 " ONOS hosts hD and h17"
shahshreya9294c8d2015-01-21 15:54:16 -08001336 main.case(var6)
shahshreyafac62b12015-01-20 16:16:13 -08001337 ptpIntentResult = main.ONOS2.addPointIntent(
1338 "of:0000000000003013/1",
1339 "of:0000000000006023/1" )
1340 if ptpIntentResult == main.TRUE:
1341 getIntentResult = main.ONOS2.intents()
1342 main.log.info( "Point to point intent install successful" )
1343 # main.log.info( getIntentResult )
1344
1345 ptpIntentResult = main.ONOS2.addPointIntent(
1346 "of:0000000000006023/1",
1347 "of:0000000000003013/1" )
1348 if ptpIntentResult == main.TRUE:
1349 getIntentResult = main.ONOS2.intents()
1350 main.log.info( "Point to point intent install successful" )
1351 # main.log.info( getIntentResult )
1352
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001353 var7 = "Add point intents for mininet hosts h14 and h24 or" +\
1354 " ONOS hosts hE and h18"
shahshreya9294c8d2015-01-21 15:54:16 -08001355 main.case(var7)
shahshreyafac62b12015-01-20 16:16:13 -08001356 ptpIntentResult = main.ONOS2.addPointIntent(
1357 "of:0000000000003014/1",
1358 "of:0000000000006024/1" )
1359 if ptpIntentResult == main.TRUE:
1360 getIntentResult = main.ONOS2.intents()
1361 main.log.info( "Point to point intent install successful" )
1362 # main.log.info( getIntentResult )
1363
1364 ptpIntentResult = main.ONOS2.addPointIntent(
1365 "of:0000000000006024/1",
1366 "of:0000000000003014/1" )
1367 if ptpIntentResult == main.TRUE:
1368 getIntentResult = main.ONOS2.intents()
1369 main.log.info( "Point to point intent install successful" )
1370 # main.log.info( getIntentResult )
1371
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001372 var8 = "Add point intents for mininet hosts h15 and h25 or" +\
1373 " ONOS hosts hF and h19"
shahshreya9294c8d2015-01-21 15:54:16 -08001374 main.case(var8)
shahshreyafac62b12015-01-20 16:16:13 -08001375 ptpIntentResult = main.ONOS2.addPointIntent(
1376 "of:0000000000003015/1",
1377 "of:0000000000006025/1" )
1378 if ptpIntentResult == main.TRUE:
1379 getIntentResult = main.ONOS2.intents()
1380 main.log.info( "Point to point intent install successful" )
1381 # main.log.info( getIntentResult )
1382
1383 ptpIntentResult = main.ONOS2.addPointIntent(
1384 "of:0000000000006025/1",
1385 "of:0000000000003015/1" )
1386 if ptpIntentResult == main.TRUE:
1387 getIntentResult = main.ONOS2.intents()
1388 main.log.info( "Point to point intent install successful" )
1389 # main.log.info( getIntentResult )
1390
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001391 var9 = "Add intents for mininet hosts h16 and h26 or" +\
1392 " ONOS hosts h10 and h1A"
shahshreya9294c8d2015-01-21 15:54:16 -08001393 main.case(var9)
shahshreyafac62b12015-01-20 16:16:13 -08001394 ptpIntentResult = main.ONOS2.addPointIntent(
1395 "of:0000000000003016/1",
1396 "of:0000000000006026/1" )
1397 if ptpIntentResult == main.TRUE:
1398 getIntentResult = main.ONOS2.intents()
1399 main.log.info( "Point to point intent install successful" )
1400 # main.log.info( getIntentResult )
1401
1402 ptpIntentResult = main.ONOS2.addPointIntent(
1403 "of:0000000000006026/1",
1404 "of:0000000000003016/1" )
1405 if ptpIntentResult == main.TRUE:
1406 getIntentResult = main.ONOS2.intents()
1407 main.log.info( "Point to point intent install successful" )
1408 # main.log.info( getIntentResult )
1409
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001410 var10 = "Add point intents for mininet hosts h17 and h27 or" +\
1411 " ONOS hosts h11 and h1B"
shahshreya9294c8d2015-01-21 15:54:16 -08001412 main.case(var10)
shahshreyafac62b12015-01-20 16:16:13 -08001413 ptpIntentResult = main.ONOS2.addPointIntent(
1414 "of:0000000000003017/1",
1415 "of:0000000000006027/1" )
1416 if ptpIntentResult == main.TRUE:
1417 getIntentResult = main.ONOS2.intents()
1418 main.log.info( "Point to point intent install successful" )
shahshreyadcb08e82015-02-25 10:16:42 -08001419 #main.log.info( getIntentResult )
shahshreyafac62b12015-01-20 16:16:13 -08001420
1421 ptpIntentResult = main.ONOS2.addPointIntent(
1422 "of:0000000000006027/1",
1423 "of:0000000000003017/1" )
1424 if ptpIntentResult == main.TRUE:
1425 getIntentResult = main.ONOS2.intents()
1426 main.log.info( "Point to point intent install successful" )
shahshreyadcb08e82015-02-25 10:16:42 -08001427 #main.log.info( getIntentResult )
shahshreyafac62b12015-01-20 16:16:13 -08001428
1429 print(
1430 "___________________________________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001431
1432 flowHandle = main.ONOS2.flows()
shahshreya82ecd282015-02-05 16:48:03 -08001433 #main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001434
1435 count = 1
1436 i = 8
shahshreyafac62b12015-01-20 16:16:13 -08001437 PingResult = main.TRUE
1438 while i < 18:
1439 main.log.info(
1440 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1441 ping = main.Mininet1.pingHost(
1442 src="h" + str( i ), target="h" + str( i + 10 ) )
1443 if ping == main.FALSE and count < 5:
1444 count += 1
1445 # i = 8
1446 PingResult = main.FALSE
1447 main.log.report( "Ping between h" +
1448 str( i ) +
1449 " and h" +
1450 str( i +
1451 10 ) +
1452 " failed. Making attempt number " +
1453 str( count ) +
1454 " in 2 seconds" )
1455 time.sleep( 2 )
1456 elif ping == main.FALSE:
1457 main.log.report( "All ping attempts between h" +
1458 str( i ) +
1459 " and h" +
1460 str( i +
1461 10 ) +
1462 "have failed" )
1463 i = 19
1464 PingResult = main.FALSE
1465 elif ping == main.TRUE:
1466 main.log.info( "Ping test between h" +
1467 str( i ) +
1468 " and h" +
1469 str( i +
1470 10 ) +
1471 "passed!" )
1472 i += 1
1473 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001474 else:
shahshreyafac62b12015-01-20 16:16:13 -08001475 main.log.info( "Unknown error" )
1476 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001477
shahshreyafac62b12015-01-20 16:16:13 -08001478 if PingResult == main.FALSE:
1479 main.log.report(
1480 "Point intents have not ben installed correctly. Cleaning up" )
1481 # main.cleanup()
1482 # main.exit()
1483 if PingResult == main.TRUE:
1484 main.log.report( "Point Intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001485
shahshreyafac62b12015-01-20 16:16:13 -08001486 case9Result = PingResult
1487 utilities.assert_equals(
1488 expect=main.TRUE,
1489 actual=case9Result,
1490 onpass="Point intents addition and Pingall Test successful",
1491 onfail="Point intents addition and Pingall Test NOT successful" )