blob: 71c60fec680e5fad8b5c0ef71fb80a2d7bf23620 [file] [log] [blame]
shahshreya4e13a062014-11-11 16:46:18 -08001
shahshreyafac62b12015-01-20 16:16:13 -08002# Testing the basic functionality of ONOS Next
3# For sanity and driver functionality excercises only.
shahshreya4e13a062014-11-11 16:46:18 -08004
5import time
shahshreyafac62b12015-01-20 16:16:13 -08006# import sys
7# import os
8# import re
shahshreya4e13a062014-11-11 16:46:18 -08009import json
10
shahshreyafac62b12015-01-20 16:16:13 -080011time.sleep( 1 )
12
13
shahshreya4e13a062014-11-11 16:46:18 -080014class ProdFunc:
shahshreyafac62b12015-01-20 16:16:13 -080015
16 def __init__( self ):
shahshreya4e13a062014-11-11 16:46:18 -080017 self.default = ''
18
shahshreyafac62b12015-01-20 16:16:13 -080019 def CASE1( self, main ):
shahshreya82ecd282015-02-05 16:48:03 -080020 import time
shahshreyafac62b12015-01-20 16:16:13 -080021 """
shahshreya4e13a062014-11-11 16:46:18 -080022 Startup sequence:
shahshreyae6c7cf42014-11-26 16:39:01 -080023 cell <name>
24 onos-verify-cell
25 onos-remove-raft-log
shahshreya4e13a062014-11-11 16:46:18 -080026 git pull
27 mvn clean install
28 onos-package
shahshreya4e13a062014-11-11 16:46:18 -080029 onos-install -f
30 onos-wait-for-start
shahshreyafac62b12015-01-20 16:16:13 -080031 """
32 cellName = main.params[ 'ENV' ][ 'cellName' ]
33 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreyae6c7cf42014-11-26 16:39:01 -080034
shahshreyafac62b12015-01-20 16:16:13 -080035 main.case( "Setting up test environment" )
36 main.log.report(
37 "This testcase is testing setting up test environment" )
38 main.log.report( "__________________________________" )
shahshreyae6c7cf42014-11-26 16:39:01 -080039
shahshreyafac62b12015-01-20 16:16:13 -080040 main.step( "Applying cell variable to environment" )
41 cellResult = main.ONOSbench.setCell( cellName )
42 verifyResult = main.ONOSbench.verifyCell()
43
shahshreyab512cd02015-01-27 17:01:47 -080044 main.step( "Git checkout and get version" )
shahshreyaa47ebf42015-05-20 13:29:18 -070045 main.ONOSbench.gitCheckout( "master" )
shahshreyafac62b12015-01-20 16:16:13 -080046 gitPullResult = main.ONOSbench.gitPull()
shahshreya82ecd282015-02-05 16:48:03 -080047 main.log.info( "git_pull_result = " + str( gitPullResult ))
shahshreyafac62b12015-01-20 16:16:13 -080048 main.ONOSbench.getVersion( report=True )
49
shahshreya234a1682015-05-27 15:41:56 -070050 packageResult = main.TRUE
shahshreyafac62b12015-01-20 16:16:13 -080051 if gitPullResult == 1:
52 main.step( "Using mvn clean & install" )
53 main.ONOSbench.cleanInstall()
shahshreya234a1682015-05-27 15:41:56 -070054 main.step( "Creating ONOS package" )
55 packageResult = main.ONOSbench.onosPackage()
shahshreyafac62b12015-01-20 16:16:13 -080056 elif gitPullResult == 0:
57 main.log.report(
58 "Git Pull Failed, look into logs for detailed reason" )
shahshreya0e81ed92014-12-08 16:57:17 -080059 main.cleanup()
shahshreyafac62b12015-01-20 16:16:13 -080060 main.exit()
shahshreya4e13a062014-11-11 16:46:18 -080061
shahshreya4e13a062014-11-11 16:46:18 -080062
shahshreyaa47ebf42015-05-20 13:29:18 -070063 main.step( "Uninstalling ONOS package" )
shahshreya234a1682015-05-27 15:41:56 -070064 onosInstallResult = main.ONOSbench.onosUninstall( ONOS1Ip )
shahshreyaa47ebf42015-05-20 13:29:18 -070065 if onosInstallResult == main.TRUE:
66 main.log.report( "Uninstalling ONOS package successful" )
67 else:
68 main.log.report( "Uninstalling ONOS package failed" )
69
shahshreyafac62b12015-01-20 16:16:13 -080070 main.step( "Installing ONOS package" )
shahshreya234a1682015-05-27 15:41:56 -070071 onosInstallResult = main.ONOSbench.onosInstall( ONOS1Ip )
72 print onosInstallResult
shahshreyafac62b12015-01-20 16:16:13 -080073 if onosInstallResult == main.TRUE:
74 main.log.report( "Installing ONOS package successful" )
shahshreya4e13a062014-11-11 16:46:18 -080075 else:
shahshreyafac62b12015-01-20 16:16:13 -080076 main.log.report( "Installing ONOS package failed" )
shahshreya4e13a062014-11-11 16:46:18 -080077
shahshreyafac62b12015-01-20 16:16:13 -080078 onos1Isup = main.ONOSbench.isup()
79 if onos1Isup == main.TRUE:
80 main.log.report( "ONOS instance is up and ready" )
shahshreya4e13a062014-11-11 16:46:18 -080081 else:
shahshreyafac62b12015-01-20 16:16:13 -080082 main.log.report( "ONOS instance may not be up" )
shahshreya4e13a062014-11-11 16:46:18 -080083
shahshreya234a1682015-05-27 15:41:56 -070084 startResult = main.TRUE
85 #main.step( "Starting ONOS service" )
86 #startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -080087
shahshreya234a1682015-05-27 15:41:56 -070088 main.ONOS2.startOnosCli( ONOS1Ip )
shahshreya82ecd282015-02-05 16:48:03 -080089 main.step( "Starting Mininet CLI..." )
90
91 # Starting the mininet using the old way
92 main.step( "Starting Mininet ..." )
93 netIsUp = main.Mininet1.startNet()
94 if netIsUp:
95 main.log.info("Mininet CLI is up")
96
shahshreyafac62b12015-01-20 16:16:13 -080097 case1Result = ( packageResult and
98 cellResult and verifyResult
99 and onosInstallResult and
100 onos1Isup and startResult )
101 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
shahshreya9294c8d2015-01-21 15:54:16 -0800102 onpass="Test startup successful",
103 onfail="Test startup NOT successful" )
shahshreyafac62b12015-01-20 16:16:13 -0800104
105 def CASE2( self, main ):
106 """
shahshreya0e81ed92014-12-08 16:57:17 -0800107 Switch Down
shahshreyafac62b12015-01-20 16:16:13 -0800108 """
109 # NOTE: You should probably run a topology check after this
110 import time
shahshreya0e81ed92014-12-08 16:57:17 -0800111
shahshreyafac62b12015-01-20 16:16:13 -0800112 main.case( "Switch down discovery" )
113 main.log.report( "This testcase is testing a switch down discovery" )
114 main.log.report( "__________________________________" )
115
116 switchSleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
shahshreya0e81ed92014-12-08 16:57:17 -0800117
118 description = "Killing a switch to ensure it is discovered correctly"
shahshreyafac62b12015-01-20 16:16:13 -0800119 main.log.report( description )
120 main.case( description )
shahshreya0e81ed92014-12-08 16:57:17 -0800121
shahshreyafac62b12015-01-20 16:16:13 -0800122 # TODO: Make this switch parameterizable
123 main.step( "Kill s28 " )
124 main.log.report( "Deleting s28" )
125 # FIXME: use new dynamic topo functions
126 main.Mininet1.delSwitch( "s28" )
127 main.log.info(
128 "Waiting " +
129 str( switchSleep ) +
130 " seconds for switch down to be discovered" )
131 time.sleep( switchSleep )
132 # Peek at the deleted switch
133 device = main.ONOS2.getDevice( dpid="0028" )
shahshreya0e81ed92014-12-08 16:57:17 -0800134 print "device = ", device
shahshreyafac62b12015-01-20 16:16:13 -0800135 if device[ u'available' ] == 'False':
136 case2Result = main.FALSE
shahshreya0e81ed92014-12-08 16:57:17 -0800137 else:
shahshreyafac62b12015-01-20 16:16:13 -0800138 case2Result = main.TRUE
139 utilities.assert_equals( expect=main.TRUE, actual=case2Result,
shahshreya9294c8d2015-01-21 15:54:16 -0800140 onpass="Switch down discovery successful",
141 onfail="Switch down discovery failed" )
shahshreya0e81ed92014-12-08 16:57:17 -0800142
shahshreyadcb08e82015-02-25 10:16:42 -0800143 def CASE101( self, main ):
shahshreyafac62b12015-01-20 16:16:13 -0800144 """
shahshreya4e13a062014-11-11 16:46:18 -0800145 Cleanup sequence:
shahshreyafac62b12015-01-20 16:16:13 -0800146 onos-service <nodeIp> stop
shahshreya4e13a062014-11-11 16:46:18 -0800147 onos-uninstall
148
149 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800150
shahshreyafac62b12015-01-20 16:16:13 -0800151 """
152 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800153
shahshreyafac62b12015-01-20 16:16:13 -0800154 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800155
shahshreyafac62b12015-01-20 16:16:13 -0800156 main.step( "Testing ONOS kill function" )
157 killResult = main.ONOSbench.onosKill( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800158
shahshreyafac62b12015-01-20 16:16:13 -0800159 main.step( "Stopping ONOS service" )
160 stopResult = main.ONOSbench.onosStop( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800161
shahshreyafac62b12015-01-20 16:16:13 -0800162 main.step( "Uninstalling ONOS service" )
163 uninstallResult = main.ONOSbench.onosUninstall()
shahshreya4e13a062014-11-11 16:46:18 -0800164
shahshreyafac62b12015-01-20 16:16:13 -0800165 case11Result = killResult and stopResult and uninstallResult
166 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
shahshreya9294c8d2015-01-21 15:54:16 -0800167 onpass="Cleanup successful",
168 onfail="Cleanup failed" )
shahshreyafac62b12015-01-20 16:16:13 -0800169
170 def CASE3( self, main ):
171 """
shahshreya4e13a062014-11-11 16:46:18 -0800172 Test 'onos' command and its functionality in driver
shahshreyafac62b12015-01-20 16:16:13 -0800173 """
174 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800175
shahshreyafac62b12015-01-20 16:16:13 -0800176 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800177
shahshreyafac62b12015-01-20 16:16:13 -0800178 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800179 cmdstr1 = "system:name"
shahshreyafac62b12015-01-20 16:16:13 -0800180 cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
181 main.log.info( "onos command returned: " + cmdResult1 )
shahshreya4e13a062014-11-11 16:46:18 -0800182
shahshreyafac62b12015-01-20 16:16:13 -0800183 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800184 cmdstr2 = "onos:topology"
shahshreyafac62b12015-01-20 16:16:13 -0800185 cmdResult2 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
186 main.log.info( "onos command returned: " + cmdResult2 )
shahshreya4e13a062014-11-11 16:46:18 -0800187
shahshreyafac62b12015-01-20 16:16:13 -0800188 def CASE20( self ):
189 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800190 Exit from mininet cli
191 reinstall ONOS
shahshreyafac62b12015-01-20 16:16:13 -0800192 """
shahshreya234a1682015-05-27 15:41:56 -0700193 import time
shahshreyafac62b12015-01-20 16:16:13 -0800194 cellName = main.params[ 'ENV' ][ 'cellName' ]
195 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800196
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800197 main.log.report( "This testcase exits the mininet cli and reinstalls" +
198 "ONOS to switch over to Packet Optical topology" )
shahshreyafac62b12015-01-20 16:16:13 -0800199 main.log.report( "_____________________________________________" )
200 main.case( "Disconnecting mininet and restarting ONOS" )
shahshreya234a1682015-05-27 15:41:56 -0700201
shahshreyafac62b12015-01-20 16:16:13 -0800202 main.step( "Disconnecting mininet and restarting ONOS" )
shahshreya234a1682015-05-27 15:41:56 -0700203 step1Result = main.TRUE
shahshreyafac62b12015-01-20 16:16:13 -0800204 mininetDisconnect = main.Mininet1.disconnect()
shahshreya3140b1a2015-04-28 14:22:15 -0700205 print "mininetDisconnect = ", mininetDisconnect
shahshreya234a1682015-05-27 15:41:56 -0700206 step1Result = mininetDisconnect
207 utilities.assert_equals(
208 expect=main.TRUE,
209 actual=step1Result,
210 onpass="Mininet disconnect successfully",
211 onfail="Mininet failed to disconnect")
212 """
213 main.step( "Removing raft logs before a clean installation of ONOS" )
214 step2Result = main.TRUE
215 removeRaftLogsResult = main.ONOSbench.onosRemoveRaftLogs()
216 step2Result = removeRaftLogsResult
217 utilities.assert_equals(
218 expect=main.TRUE,
219 actual=step2Result,
220 onpass="Raft logs removed successfully",
221 onfail="Failed to remove raft logs")
222 """
shahshreyafac62b12015-01-20 16:16:13 -0800223 main.step( "Applying cell variable to environment" )
shahshreya234a1682015-05-27 15:41:56 -0700224 step3Result = main.TRUE
225 setCellResult = main.ONOSbench.setCell( cellName )
226 verifyCellResult = main.ONOSbench.verifyCell()
227 step3Result = setCellResult and verifyCellResult
228 utilities.assert_equals(
229 expect=main.TRUE,
230 actual=step3Result,
231 onpass="Cell applied successfully",
232 onfail="Failed to apply cell")
shahshreyafac62b12015-01-20 16:16:13 -0800233
shahshreya234a1682015-05-27 15:41:56 -0700234 main.step( "Uninstalling ONOS package" )
235 step4Result = main.TRUE
236 ONOSip1 = main.params[ 'CTRL' ][ 'ip1' ]
237 onosUninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOSip1)
238 step4Result = onosUninstallResult
239 utilities.assert_equals(
240 expect=main.TRUE,
241 actual=step4Result,
242 onpass="Successfully uninstalled ONOS",
243 onfail="Failed to uninstall ONOS")
244
245 time.sleep( 5 )
246 main.step( "Installing ONOS package" )
247 step5Result = main.TRUE
248 onosInstallResult = main.ONOSbench.onosInstall( node = ONOSip1 )
249 step5Result = onosInstallResult
250 utilities.assert_equals(
251 expect=main.TRUE,
252 actual=step5Result,
253 onpass="Successfully installed ONOS",
254 onfail="Failed to install ONOS")
shahshreyae6c7cf42014-11-26 16:39:01 -0800255
shahshreyafac62b12015-01-20 16:16:13 -0800256 onos1Isup = main.ONOSbench.isup()
257 if onos1Isup == main.TRUE:
258 main.log.report( "ONOS instance is up and ready" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800259 else:
shahshreyafac62b12015-01-20 16:16:13 -0800260 main.log.report( "ONOS instance may not be up" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800261
shahshreyafac62b12015-01-20 16:16:13 -0800262 main.step( "Starting ONOS service" )
shahshreya234a1682015-05-27 15:41:56 -0700263 step6Result = main.TRUE
shahshreyafac62b12015-01-20 16:16:13 -0800264 startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreya234a1682015-05-27 15:41:56 -0700265 step6Result = startResult
shahshreyafac62b12015-01-20 16:16:13 -0800266 utilities.assert_equals(
267 expect=main.TRUE,
shahshreya234a1682015-05-27 15:41:56 -0700268 actual=step6Result,
269 onpass="Successfully started ONOS",
270 onfail="Failed to start ONOS")
271
272 main.step( "Starting ONOS cli" )
273 step7Result = main.TRUE
274 cliResult = main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
275 step7Result = cliResult
276 utilities.assert_equals(
277 expect=main.TRUE,
278 actual=step7Result,
279 onpass="Successfully started ONOS cli",
280 onfail="Failed to start ONOS cli")
shahshreyafac62b12015-01-20 16:16:13 -0800281
282 def CASE21( self, main ):
283 """
284 On ONOS bench, run this command:
shahshreya1937ec12015-04-03 15:35:48 -0700285 sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1
286 which spawns packet optical topology and copies the links
shahshreyafac62b12015-01-20 16:16:13 -0800287 json file to the onos instance.
288 Note that in case of Packet Optical, the links are not learnt
289 from the topology, instead the links are learnt
shahshreyae6c7cf42014-11-26 16:39:01 -0800290 from the json config file
shahshreyafac62b12015-01-20 16:16:13 -0800291 """
shahshreya234a1682015-05-27 15:41:56 -0700292 import time
shahshreyafac62b12015-01-20 16:16:13 -0800293 main.log.report(
294 "This testcase starts the packet layer topology and REST" )
295 main.log.report( "_____________________________________________" )
296 main.case( "Starting LINC-OE and other components" )
shahshreya234a1682015-05-27 15:41:56 -0700297
298 main.step( "Activate optical app" )
299 step1Result = main.TRUE
300 activateOpticalResult = main.ONOS2.activateApp( "org.onosproject.optical" )
301 step1Result = activateOpticalResult
302 utilities.assert_equals(
303 expect=main.TRUE,
304 actual=step1Result,
305 onpass="Successfully activated optical app",
306 onfail="Failed to activate optical app")
307
shahshreyad524a942015-04-21 09:55:16 -0700308 appCheck = main.ONOS2.appToIDCheck()
309 if appCheck != main.TRUE:
310 main.log.warn( main.ONOS2.apps() )
311 main.log.warn( main.ONOS2.appIDs() )
312
shahshreya234a1682015-05-27 15:41:56 -0700313 main.step( "Starting mininet and LINC-OE" )
314 step2Result = main.TRUE
315 time.sleep( 10 )
shahshreya215c48f2015-04-06 15:55:55 -0700316 opticalMnScript = main.LincOE2.runOpticalMnScript(ctrllerIP = main.params[ 'CTRL' ][ 'ip1' ])
shahshreya234a1682015-05-27 15:41:56 -0700317 step2Result = opticalMnScript
shahshreyafac62b12015-01-20 16:16:13 -0800318 utilities.assert_equals(
319 expect=main.TRUE,
shahshreya234a1682015-05-27 15:41:56 -0700320 actual=step2Result,
321 onpass="Started the topology successfully ",
322 onfail="Failed to start the topology")
shahshreyae6c7cf42014-11-26 16:39:01 -0800323
shahshreyafac62b12015-01-20 16:16:13 -0800324 def CASE22( self, main ):
325 """
shahshreya1937ec12015-04-03 15:35:48 -0700326 Curretly we use, 10 optical switches(ROADM's) and
327 6 packet layer mininet switches each with one host.
328 Therefore, the roadmCount variable = 10,
329 packetLayerSWCount variable = 6, hostCount=6 and
shahshreyaa47ebf42015-05-20 13:29:18 -0700330 links=46.
shahshreya1937ec12015-04-03 15:35:48 -0700331 All this is hardcoded in the testcase. If the topology changes,
shahshreyafac62b12015-01-20 16:16:13 -0800332 these hardcoded values need to be changed
333 """
shahshreya234a1682015-05-27 15:41:56 -0700334 import time
shahshreyafac62b12015-01-20 16:16:13 -0800335 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800336 "This testcase compares the optical+packet topology against what" +
337 " is expected" )
shahshreyafac62b12015-01-20 16:16:13 -0800338 main.case( "Topology comparision" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800339
shahshreya234a1682015-05-27 15:41:56 -0700340 main.step( "Starts new ONOS cli" )
341 step1Result = main.TRUE
342 cliResult = main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ]\
343 [ 'ip1' ] )
344 step1Result = cliResult
345 utilities.assert_equals(
346 expect=main.TRUE,
347 actual=step1Result,
348 onpass="Successfully starts a new cli",
349 onfail="Failed to start new cli" )
350
351 main.step( "Compare topology" )
352 step2Result = main.TRUE
353 devicesResult = main.ONOS3.devices( jsonFormat=False )
354 print "devices_result :\n", devicesResult
shahshreyafac62b12015-01-20 16:16:13 -0800355 devicesLinewise = devicesResult.split( "\n" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800356 roadmCount = 0
357 packetLayerSWCount = 0
shahshreyafac62b12015-01-20 16:16:13 -0800358 for line in devicesLinewise:
359 components = line.split( "," )
360 availability = components[ 1 ].split( "=" )[ 1 ]
361 type = components[ 3 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800362 if availability == 'true' and type == 'ROADM':
363 roadmCount += 1
shahshreyafac62b12015-01-20 16:16:13 -0800364 elif availability == 'true' and type == 'SWITCH':
shahshreyae6c7cf42014-11-26 16:39:01 -0800365 packetLayerSWCount += 1
shahshreya1937ec12015-04-03 15:35:48 -0700366 if roadmCount == 10:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800367 print "Number of Optical Switches = %d and is" % roadmCount +\
368 " correctly detected"
shahshreyafac62b12015-01-20 16:16:13 -0800369 main.log.info(
370 "Number of Optical Switches = " +
371 str( roadmCount ) +
372 " and is correctly detected" )
373 opticalSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800374 else:
shahshreyafac62b12015-01-20 16:16:13 -0800375 print "Number of Optical Switches = %d and is wrong" % roadmCount
376 main.log.info(
377 "Number of Optical Switches = " +
378 str( roadmCount ) +
379 " and is wrong" )
380 opticalSWResult = main.FALSE
shahshreya1937ec12015-04-03 15:35:48 -0700381 if packetLayerSWCount == 6:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800382 print "Number of Packet layer or mininet Switches = %d "\
383 % packetLayerSWCount + "and is correctly detected"
shahshreyafac62b12015-01-20 16:16:13 -0800384 main.log.info(
385 "Number of Packet layer or mininet Switches = " +
386 str( packetLayerSWCount ) +
387 " and is correctly detected" )
388 packetSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800389 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800390 print "Number of Packet layer or mininet Switches = %d and"\
391 % packetLayerSWCount + " is wrong"
shahshreyafac62b12015-01-20 16:16:13 -0800392 main.log.info(
393 "Number of Packet layer or mininet Switches = " +
394 str( packetLayerSWCount ) +
395 " and is wrong" )
396 packetSWResult = main.FALSE
shahshreya234a1682015-05-27 15:41:56 -0700397 # sleeps for sometime so the state of the switches will be active
398 time.sleep( 30 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800399 print "_________________________________"
shahshreyafac62b12015-01-20 16:16:13 -0800400 linksResult = main.ONOS3.links( jsonFormat=False )
401 print "links_result = ", linksResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800402 print "_________________________________"
shahshreya234a1682015-05-27 15:41:56 -0700403 linkActiveCount = linksResult.count("state=ACTIVE")
shahshreya1937ec12015-04-03 15:35:48 -0700404 main.log.info( "linkActiveCount = " + str( linkActiveCount ))
shahshreyaa47ebf42015-05-20 13:29:18 -0700405 if linkActiveCount == 46:
shahshreya1937ec12015-04-03 15:35:48 -0700406 linkActiveResult = main.TRUE
407 main.log.info(
408 "Number of links in ACTIVE state are correct")
409 else:
410 linkActiveResult = main.FALSE
411 main.log.info(
412 "Number of links in ACTIVE state are wrong")
shahshreya234a1682015-05-27 15:41:56 -0700413 step2Result = opticalSWResult and packetSWResult and \
shahshreya1937ec12015-04-03 15:35:48 -0700414 linkActiveResult
shahshreyafac62b12015-01-20 16:16:13 -0800415 utilities.assert_equals(
416 expect=main.TRUE,
shahshreya234a1682015-05-27 15:41:56 -0700417 actual=step2Result,
418 onpass="Successfully loaded packet optical topology",
419 onfail="Failed to load packet optical topology" )
shahshreya0e81ed92014-12-08 16:57:17 -0800420
shahshreyafac62b12015-01-20 16:16:13 -0800421 def CASE23( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800422 import time
shahshreyafac62b12015-01-20 16:16:13 -0800423 """
424 Add bidirectional point intents between 2 packet layer( mininet )
425 devices and
shahshreyae6c7cf42014-11-26 16:39:01 -0800426 ping mininet hosts
shahshreyafac62b12015-01-20 16:16:13 -0800427 """
428 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800429 "This testcase adds bidirectional point intents between 2 " +
430 "packet layer( mininet ) devices and ping mininet hosts" )
shahshreya234a1682015-05-27 15:41:56 -0700431 main.case( "Install point intents between 2 packet layer device and " +
432 "ping the hosts" )
433
shahshreyafac62b12015-01-20 16:16:13 -0800434 main.step( "Adding point intents" )
shahshreya234a1682015-05-27 15:41:56 -0700435 step1Result = main.TRUE
436 main.pIntentsId = []
437 pIntent1 = main.ONOS3.addPointIntent(
shahshreyafac62b12015-01-20 16:16:13 -0800438 "of:0000ffffffff0001/1",
shahshreya1937ec12015-04-03 15:35:48 -0700439 "of:0000ffffffff0005/1" )
shahshreya234a1682015-05-27 15:41:56 -0700440 pIntent2 = main.ONOS3.addPointIntent(
shahshreya1937ec12015-04-03 15:35:48 -0700441 "of:0000ffffffff0005/1",
shahshreyafac62b12015-01-20 16:16:13 -0800442 "of:0000ffffffff0001/1" )
shahshreya234a1682015-05-27 15:41:56 -0700443 main.pIntentsId.append( pIntent1 )
444 main.pIntentsId.append( pIntent2 )
445 time.sleep( 10 )
446 main.log.info( "Checking intents state")
447 checkStateResult = main.ONOS3.checkIntentState(
448 intentsId = main.pIntentsId )
449 time.sleep( 10 )
450 main.log.info( "Checking flows state")
451 checkFlowResult = main.ONOS3.checkFlowsState()
shahshreyae6c7cf42014-11-26 16:39:01 -0800452 # Sleep for 30 seconds to provide time for the intent state to change
shahshreya234a1682015-05-27 15:41:56 -0700453 time.sleep( 10 )
454 main.log.info( "Checking intents state one more time")
455 checkStateResult = main.ONOS3.checkIntentState(
456 intentsId = main.pIntentsId )
457 step1Result = checkStateResult and checkFlowResult
shahshreyafac62b12015-01-20 16:16:13 -0800458 utilities.assert_equals(
459 expect=main.TRUE,
shahshreya234a1682015-05-27 15:41:56 -0700460 actual=step1Result,
461 onpass="Successfully added point intents",
462 onfail="Failed to add point intents")
463
464 main.step( "Ping h1 and h5" )
465 step2Result = main.TRUE
466 main.log.info( "\n\nh1 is Pinging h5" )
467 pingResult = main.LincOE2.pingHostOptical( src="h1", target="h5" )
468 step2Result = pingResult
469 utilities.assert_equals(
470 expect=main.TRUE,
471 actual=step2Result,
472 onpass="Successfully pinged h1 and h5",
473 onfail="Failed to ping between h1 and h5")
shahshreyae6c7cf42014-11-26 16:39:01 -0800474
shahshreyafac62b12015-01-20 16:16:13 -0800475 def CASE24( self, main ):
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800476 import time
477 import json
shahshreyafac62b12015-01-20 16:16:13 -0800478 """
shahshreya1937ec12015-04-03 15:35:48 -0700479 LINC uses its own switch IDs. You can use the following
480 command on the LINC console to find the mapping between
481 DPIDs and LINC IDs.
482 rp(application:get_all_key(linc)).
483
shahshreyafac62b12015-01-20 16:16:13 -0800484 Test Rerouting of Packet Optical by bringing a port down
shahshreya1937ec12015-04-03 15:35:48 -0700485 ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
486 so that link
487 ( between switch1 port20 - switch5 port50 ) is inactive
shahshreyafac62b12015-01-20 16:16:13 -0800488 and do a ping test. If rerouting is successful,
489 ping should pass. also check the flows
490 """
491 main.log.report(
492 "This testcase tests rerouting and pings mininet hosts" )
493 main.case( "Test rerouting and pings mininet hosts" )
shahshreya234a1682015-05-27 15:41:56 -0700494
shahshreya1937ec12015-04-03 15:35:48 -0700495 main.step( "Attach to the Linc-OE session" )
shahshreya234a1682015-05-27 15:41:56 -0700496 step1Result = main.TRUE
497 attachConsole = main.LincOE1.attachLincOESession()
498 step1Result = attachConsole
499 utilities.assert_equals(
500 expect=main.TRUE,
501 actual=step1Result,
502 onpass="Successfully attached Linc-OE session",
503 onfail="Failed to attached Linc-OE session")
shahshreya1937ec12015-04-03 15:35:48 -0700504
shahshreyafac62b12015-01-20 16:16:13 -0800505 main.step( "Bring a port down and verify the link state" )
shahshreya234a1682015-05-27 15:41:56 -0700506 step2Result = main.TRUE
shahshreya1937ec12015-04-03 15:35:48 -0700507 main.LincOE1.portDown( swId="9", ptId="20" )
shahshreyafac62b12015-01-20 16:16:13 -0800508 linksNonjson = main.ONOS3.links( jsonFormat=False )
509 main.log.info( "links = " + linksNonjson )
shahshreya234a1682015-05-27 15:41:56 -0700510 linkInactiveCount = linksNonjson.count( "state=INACTIVE" )
shahshreya1937ec12015-04-03 15:35:48 -0700511 main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
512 if linkInactiveCount == 2:
513 main.log.info(
514 "Number of links in INACTIVE state are correct")
515 else:
516 main.log.info(
517 "Number of links in INACTIVE state are wrong")
shahshreya0e81ed92014-12-08 16:57:17 -0800518 links = main.ONOS3.links()
shahshreyafac62b12015-01-20 16:16:13 -0800519 main.log.info( "links = " + links )
shahshreyafac62b12015-01-20 16:16:13 -0800520 linksResult = json.loads( links )
521 linksStateResult = main.FALSE
522 for item in linksResult:
523 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
shahshreya1937ec12015-04-03 15:35:48 -0700524 'src' ][ 'port' ] == "20":
525 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
526 'dst' ][ 'port' ] == "50":
shahshreyafac62b12015-01-20 16:16:13 -0800527 linksState = item[ 'state' ]
528 if linksState == "INACTIVE":
529 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800530 "Links state is inactive as expected due to one" +
531 " of the ports being down" )
shahshreyafac62b12015-01-20 16:16:13 -0800532 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800533 "Links state is inactive as expected due to one" +
534 " of the ports being down" )
shahshreyafac62b12015-01-20 16:16:13 -0800535 linksStateResult = main.TRUE
shahshreya0e81ed92014-12-08 16:57:17 -0800536 break
537 else:
shahshreyafac62b12015-01-20 16:16:13 -0800538 main.log.info(
539 "Links state is not inactive as expected" )
540 main.log.report(
541 "Links state is not inactive as expected" )
542 linksStateResult = main.FALSE
shahshreyafac62b12015-01-20 16:16:13 -0800543 time.sleep( 10 )
shahshreya234a1682015-05-27 15:41:56 -0700544 checkFlowsState = main.ONOS3.checkFlowsState()
545 step2Result = linksStateResult
546 utilities.assert_equals(
547 expect=main.TRUE,
548 actual=step2Result,
549 onpass="Successfuly brought down a link",
550 onfail="Failed to bring down a link")
shahshreya0e81ed92014-12-08 16:57:17 -0800551
shahshreyafac62b12015-01-20 16:16:13 -0800552 main.step( "Verify Rerouting by a ping test" )
shahshreya234a1682015-05-27 15:41:56 -0700553 step3Result = main.TRUE
shahshreya1937ec12015-04-03 15:35:48 -0700554 main.log.info( "\n\nh1 is Pinging h5" )
shahshreya234a1682015-05-27 15:41:56 -0700555 pingResult = main.LincOE2.pingHostOptical( src="h1", target="h5" )
556 step3Result = pingResult
557 utilities.assert_equals(
558 expect=main.TRUE,
559 actual=step3Result,
560 onpass="Successfully pinged h1 and h5",
561 onfail="Failed to ping between h1 and h5")
562
563 main.step( "Bring the downed port up and verify the link state" )
564 step4Result = main.TRUE
565 main.LincOE1.portUp( swId="9", ptId="20" )
566 linksNonjson = main.ONOS3.links( jsonFormat=False )
567 main.log.info( "links = " + linksNonjson )
568 linkInactiveCount = linksNonjson.count( "state=INACTIVE" )
569 main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
570 if linkInactiveCount == 0:
shahshreyafac62b12015-01-20 16:16:13 -0800571 main.log.info(
shahshreya234a1682015-05-27 15:41:56 -0700572 "Number of links in INACTIVE state are correct")
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800573 else:
shahshreya234a1682015-05-27 15:41:56 -0700574 main.log.info(
575 "Number of links in INACTIVE state are wrong")
576 step4Result = main.FALSE
577 utilities.assert_equals(
578 expect=main.TRUE,
579 actual=step4Result,
580 onpass="Successfully brought the port up",
581 onfail="Failed to bring the port up")
582 """
583 main.step( "Removing host intents" )
584 step5Result = main.TRUE
585 removeResult = main.TRUE
586 # Check remaining intents
587 intentsJson = json.loads( main.ONOS3.intents() )
588 main.ONOS3.removeIntent( intentId=intent1, purge=True )
589 main.ONOS3.removeIntent( intentId=intent2, purge=True )
590 for intents in intentsJson:
591 main.ONOS3.removeIntent( intentId=intents.get( 'id' ),
592 app='org.onosproject.optical',
593 purge=True )
594 print json.loads( main.ONOS3.intents() )
595 if len( json.loads( main.ONOS3.intents() ) ):
596 removeResult = main.FALSE
597 step5Result = removeResult
598 utilities.assert_equals( expect=main.TRUE,
599 actual=step5Result,
600 onpass="Successfully removed host intents",
601 onfail="Failed to remove host intents" )
602 """
603 def CASE10( self ):
604 main.log.report(
605 "This testcase uninstalls the reactive forwarding app" )
606 main.log.report( "__________________________________" )
607 main.case( "Uninstalling reactive forwarding app" )
608 main.step( "Uninstalling reactive forwarding app" )
609 step1Result = main.TRUE
610 # Unistall onos-app-fwd app to disable reactive forwarding
611 main.log.info( "deactivate reactive forwarding app" )
612 appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
613 appCheck = main.ONOS2.appToIDCheck()
614 if appCheck != main.TRUE:
615 main.log.warn( main.ONOS2.apps() )
616 main.log.warn( main.ONOS2.appIDs() )
617 step1Result = appUninstallResult
618 utilities.assert_equals(
619 expect=main.TRUE,
620 actual=step1Result,
621 onpass="Successfully deactivate reactive forwarding app",
622 onfail="Failed to deactivate reactive forwarding app")
623 # After reactive forwarding is disabled, the reactive flows on
624 # switches timeout in 10-15s
625 # So sleep for 15s
626 time.sleep( 15 )
627 flows = main.ONOS2.flows()
628 main.log.info( flows )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800629
shahshreya234a1682015-05-27 15:41:56 -0700630 def CASE25( self ):
631 """
632 Add host intents between 2 packet layer host
633 """
634 import time
635 import json
636 main.log.report( "Adding host intents between 2 optical layer host" )
637 main.case( "Test add host intents between optical layer host" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800638
shahshreya234a1682015-05-27 15:41:56 -0700639 main.step( "Discover host using arping" )
640 step1Result = main.TRUE
641 main.hostMACs = []
642 main.hostId = []
643 #Listing host MAC addresses
644 for i in range( 1 , 7 ):
645 main.hostMACs.append( "00:00:00:00:00:" +
646 str( hex( i )[ 2: ] ).zfill( 2 ).upper() )
647 for macs in main.hostMACs:
648 main.hostId.append( macs + "/-1" )
649 host1 = main.hostId[ 0 ]
650 host2 = main.hostId[ 1 ]
651 # Use arping to discover the hosts
652 main.LincOE2.arping( host = "h1" )
653 main.LincOE2.arping( host = "h2" )
654 time.sleep( 5 )
655 hostsDict = main.ONOS3.hosts()
656 if not len( hostsDict ):
657 step1Result = main.FALSE
658 # Adding host intent
659 utilities.assert_equals(
660 expect=main.TRUE,
661 actual=step1Result,
662 onpass="Hosts discovered",
663 onfail="Failed to discover hosts")
664
665 main.step( "Adding host intents to h1 and h2" )
666 step2Result = main.TRUE
667 intentsId = []
668 intent1 = main.ONOS3.addHostIntent( hostIdOne = host1,
669 hostIdTwo = host2 )
670 intentsId.append( intent1 )
671 time.sleep( 5 )
672 intent2 = main.ONOS3.addHostIntent( hostIdOne = host2,
673 hostIdTwo = host1 )
674 intentsId.append( intent2 )
675 # Checking intents state before pinging
676 main.log.info( "Checking intents state" )
677 time.sleep( 15 )
678 intentResult = main.ONOS3.checkIntentState( intentsId = intentsId )
679 #check intent state again if intents are not in installed state
680 if not intentResult:
681 intentResult = main.ONOS3.checkIntentState( intentsId = intentsId )
682 step2Result = intentResult
683 utilities.assert_equals( expect=main.TRUE,
684 actual=step2Result,
685 onpass="All intents are in INSTALLED state ",
686 onfail="Some of the intents are not in " +
687 "INSTALLED state " )
688
689 # pinging h1 to h2 and then ping h2 to h1
690 main.step( "Pinging h1 and h2" )
691 step3Result = main.TRUE
692 pingResult = main.TRUE
693 pingResult = main.LincOE2.pingHostOptical( src="h1", target="h2" )
694 pingResult = pingResult and main.LincOE2.pingHostOptical( src="h2",
695 target="h1" )
696 step3Result = pingResult
697 utilities.assert_equals( expect=main.TRUE,
698 actual=step3Result,
699 onpass="Pinged successfully between h1 and h2",
700 onfail="Pinged failed between h1 and h2" )
701 # Removed all added host intents
702 main.step( "Removing host intents" )
703 step4Result = main.TRUE
704 removeResult = main.TRUE
705 # Check remaining intents
706 intentsJson = json.loads( main.ONOS3.intents() )
707 main.ONOS3.removeIntent( intentId=intent1, purge=True )
708 main.ONOS3.removeIntent( intentId=intent2, purge=True )
709 for intents in intentsJson:
710 main.ONOS3.removeIntent( intentId=intents.get( 'id' ),
711 app='org.onosproject.optical',
712 purge=True )
713 print json.loads( main.ONOS3.intents() )
714 if len( json.loads( main.ONOS3.intents() ) ):
715 removeResult = main.FALSE
716 step4Result = removeResult
717 utilities.assert_equals( expect=main.TRUE,
718 actual=step4Result,
719 onpass="Successfully removed host intents",
720 onfail="Failed to remove host intents" )
shahshreya4e13a062014-11-11 16:46:18 -0800721
shahshreyafac62b12015-01-20 16:16:13 -0800722 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800723 import re
724 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800725 main.log.report( "This testcase is testing the assignment of" +
726 " all the switches to all the controllers and" +
shahshreyadcb08e82015-02-25 10:16:42 -0800727 " discovering the hosts in reactive mode" )
shahshreyafac62b12015-01-20 16:16:13 -0800728 main.log.report( "__________________________________" )
shahshreyaa47ebf42015-05-20 13:29:18 -0700729
shahshreyafac62b12015-01-20 16:16:13 -0800730 main.case( "Pingall Test" )
731 main.step( "Assigning switches to controllers" )
732 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
733 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
734 for i in range( 1, 29 ):
735 if i == 1:
736 main.Mininet1.assignSwController(
737 sw=str( i ),
738 ip1=ONOS1Ip,
739 port1=ONOS1Port )
740 elif i >= 2 and i < 5:
741 main.Mininet1.assignSwController(
742 sw=str( i ),
743 ip1=ONOS1Ip,
744 port1=ONOS1Port )
745 elif i >= 5 and i < 8:
746 main.Mininet1.assignSwController(
747 sw=str( i ),
748 ip1=ONOS1Ip,
749 port1=ONOS1Port )
750 elif i >= 8 and i < 18:
751 main.Mininet1.assignSwController(
752 sw=str( i ),
753 ip1=ONOS1Ip,
754 port1=ONOS1Port )
755 elif i >= 18 and i < 28:
756 main.Mininet1.assignSwController(
757 sw=str( i ),
758 ip1=ONOS1Ip,
759 port1=ONOS1Port )
shahshreya4e13a062014-11-11 16:46:18 -0800760 else:
shahshreyafac62b12015-01-20 16:16:13 -0800761 main.Mininet1.assignSwController(
762 sw=str( i ),
763 ip1=ONOS1Ip,
764 port1=ONOS1Port )
765 SwitchMastership = main.TRUE
766 for i in range( 1, 29 ):
767 if i == 1:
768 response = main.Mininet1.getSwController( "s" + str( i ) )
769 print( "Response is " + str( response ) )
770 if re.search( "tcp:" + ONOS1Ip, response ):
771 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800772 else:
shahshreyafac62b12015-01-20 16:16:13 -0800773 SwitchMastership = main.FALSE
774 elif i >= 2 and i < 5:
775 response = main.Mininet1.getSwController( "s" + str( i ) )
776 print( "Response is " + str( response ) )
777 if re.search( "tcp:" + ONOS1Ip, response ):
778 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800779 else:
shahshreyafac62b12015-01-20 16:16:13 -0800780 SwitchMastership = main.FALSE
781 elif i >= 5 and i < 8:
782 response = main.Mininet1.getSwController( "s" + str( i ) )
783 print( "Response is " + str( response ) )
784 if re.search( "tcp:" + ONOS1Ip, response ):
785 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800786 else:
shahshreyafac62b12015-01-20 16:16:13 -0800787 SwitchMastership = main.FALSE
788 elif i >= 8 and i < 18:
789 response = main.Mininet1.getSwController( "s" + str( i ) )
790 print( "Response is " + str( response ) )
791 if re.search( "tcp:" + ONOS1Ip, response ):
792 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800793 else:
shahshreyafac62b12015-01-20 16:16:13 -0800794 SwitchMastership = main.FALSE
795 elif i >= 18 and i < 28:
796 response = main.Mininet1.getSwController( "s" + str( i ) )
797 print( "Response is " + str( response ) )
798 if re.search( "tcp:" + ONOS1Ip, response ):
799 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800800 else:
shahshreyafac62b12015-01-20 16:16:13 -0800801 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800802 else:
shahshreyafac62b12015-01-20 16:16:13 -0800803 response = main.Mininet1.getSwController( "s" + str( i ) )
804 print( "Response is" + str( response ) )
805 if re.search( "tcp:" + ONOS1Ip, response ):
806 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800807 else:
shahshreyafac62b12015-01-20 16:16:13 -0800808 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800809
shahshreyafac62b12015-01-20 16:16:13 -0800810 if SwitchMastership == main.TRUE:
811 main.log.report( "Controller assignmnet successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800812 else:
shahshreyafac62b12015-01-20 16:16:13 -0800813 main.log.report( "Controller assignmnet failed" )
814 utilities.assert_equals(
815 expect=main.TRUE,
816 actual=SwitchMastership,
817 onpass="MasterControllers assigned correctly" )
818 """
819 for i in range ( 1,29 ):
820 main.Mininet1.assignSwController( sw=str( i ),count=5,
821 ip1=ONOS1Ip,port1=ONOS1Port,
822 ip2=ONOS2Ip,port2=ONOS2Port,
823 ip3=ONOS3Ip,port3=ONOS3Port,
824 ip4=ONOS4Ip,port4=ONOS4Port,
825 ip5=ONOS5Ip,port5=ONOS5Port )
826 """
827 # REACTIVE FWD test
shahshreyad524a942015-04-21 09:55:16 -0700828 main.log.info( "Activate fwd app" )
829 appInstallResult = main.ONOS2.activateApp( "org.onosproject.fwd" )
830 appCheck = main.ONOS2.appToIDCheck()
831 if appCheck != main.TRUE:
832 main.log.warn( main.ONOS2.apps() )
833 main.log.warn( main.ONOS2.appIDs() )
834 time.sleep( 10 )
shahshreya4e13a062014-11-11 16:46:18 -0800835
shahshreyafac62b12015-01-20 16:16:13 -0800836 main.step( "Get list of hosts from Mininet" )
837 hostList = main.Mininet1.getHosts()
838 main.log.info( hostList )
shahshreya4e13a062014-11-11 16:46:18 -0800839
shahshreyafac62b12015-01-20 16:16:13 -0800840 main.step( "Get host list in ONOS format" )
841 hostOnosList = main.ONOS2.getHostsId( hostList )
842 main.log.info( hostOnosList )
843 # time.sleep( 5 )
844
845 main.step( "Pingall" )
846 pingResult = main.FALSE
shahshreya82ecd282015-02-05 16:48:03 -0800847 time1 = time.time()
848 pingResult = main.Mininet1.pingall()
849 time2 = time.time()
850 print "Time for pingall: %2f seconds" % ( time2 - time1 )
shahshreya4e13a062014-11-11 16:46:18 -0800851
shahshreyafac62b12015-01-20 16:16:13 -0800852 # Start onos cli again because u might have dropped out of
853 # onos prompt to the shell prompt
854 # if there was no activity
855 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
856
857 case4Result = SwitchMastership and pingResult
858 if pingResult == main.TRUE:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800859 main.log.report( "Pingall Test in reactive mode to" +
860 " discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800861 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800862 main.log.report( "Pingall Test in reactive mode to" +
863 " discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800864
shahshreyafac62b12015-01-20 16:16:13 -0800865 utilities.assert_equals(
866 expect=main.TRUE,
867 actual=case4Result,
868 onpass="Controller assignment and Pingall Test successful",
869 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800870
shahshreyadcb08e82015-02-25 10:16:42 -0800871 def CASE11( self ):
872 # NOTE: This testcase require reactive forwarding mode enabled
873 # NOTE: in the beginning and then uninstall it before adding
874 # NOTE: point intents. Again the app is installed so that
875 # NOTE: testcase 10 can be ran successively
876 import time
877 main.log.report(
878 "This testcase moves a host from one switch to another to add" +
879 "point intents between them and then perform ping" )
880 main.log.report( "__________________________________" )
881 main.log.info( "Moving host from one switch to another" )
882 main.case( "Moving host from a device and attach it to another device" )
883 main.step( "Moving host h9 from device s9 and attach it to s8" )
884 main.Mininet1.moveHost(host = 'h9', oldSw = 's9', newSw = 's8')
885
shahshreyad524a942015-04-21 09:55:16 -0700886 main.log.info( "Activate fwd app" )
887 appInstallResult = main.ONOS2.activateApp( "org.onosproject.fwd" )
888 appCheck = main.ONOS2.appToIDCheck()
889 if appCheck != main.TRUE:
890 main.log.warn( main.ONOS2.apps() )
891 main.log.warn( main.ONOS2.appIDs() )
892
shahshreyaa47ebf42015-05-20 13:29:18 -0700893 time.sleep(25) #Time delay to have all the flows ready
shahshreyadcb08e82015-02-25 10:16:42 -0800894 main.step( "Pingall" )
895 pingResult = main.FALSE
896 time1 = time.time()
shahshreyad524a942015-04-21 09:55:16 -0700897 pingResult = main.Mininet1.pingall( timeout=120,
898 shortCircuit=True,
shahshreyaa47ebf42015-05-20 13:29:18 -0700899 acceptableFailed=20 )
shahshreyadcb08e82015-02-25 10:16:42 -0800900 time2 = time.time()
901 print "Time for pingall: %2f seconds" % ( time2 - time1 )
902
903 hosts = main.ONOS2.hosts( jsonFormat = False )
904 main.log.info( hosts )
905
shahshreyad524a942015-04-21 09:55:16 -0700906 main.log.info( "deactivate reactive forwarding app" )
907 appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
908 appCheck = main.ONOS2.appToIDCheck()
909 if appCheck != main.TRUE:
910 main.log.warn( main.ONOS2.apps() )
911 main.log.warn( main.ONOS2.appIDs() )
shahshreyadcb08e82015-02-25 10:16:42 -0800912
913 main.step( "Add point intents between hosts on the same device")
914 ptpIntentResult = main.ONOS2.addPointIntent(
915 "of:0000000000003008/1",
shahshreya234a1682015-05-27 15:41:56 -0700916 "of:0000000000003008/3",
917 ethType='IPV4',
918 ethSrc='00:00:00:00:00:08',
919 ethDst='00:00:00:00:00:09' )
shahshreyadcb08e82015-02-25 10:16:42 -0800920 if ptpIntentResult == main.TRUE:
921 getIntentResult = main.ONOS2.intents()
922 main.log.info( "Point to point intent install successful" )
923 # main.log.info( getIntentResult )
924
925 ptpIntentResult = main.ONOS2.addPointIntent(
926 "of:0000000000003008/3",
shahshreya234a1682015-05-27 15:41:56 -0700927 "of:0000000000003008/1",
928 ethType='IPV4',
929 ethSrc='00:00:00:00:00:09',
930 ethDst='00:00:00:00:00:08' )
shahshreyadcb08e82015-02-25 10:16:42 -0800931 if ptpIntentResult == main.TRUE:
932 getIntentResult = main.ONOS2.intents()
933 main.log.info( "Point to point intent install successful" )
934 # main.log.info( getIntentResult )
935
936 main.case( "Ping hosts on the same devices" )
937 ping = main.Mininet1.pingHost( src = 'h8', target = 'h9' )
938
939 '''
940 main.case( "Installing reactive forwarding app" )
941 # Install onos-app-fwd app to enable reactive forwarding
942 appUninstallResult = main.ONOS2.featureInstall( "onos-app-fwd" )
943 main.log.info( "onos-app-fwd installed" )
944 '''
945
946 if ping == main.FALSE:
947 main.log.report(
948 "Point intents for hosts on same devices haven't" +
949 " been installed correctly. Cleaning up" )
950 if ping == main.TRUE:
951 main.log.report(
952 "Point intents for hosts on same devices" +
953 "installed correctly. Cleaning up" )
954
shahshreyaa47ebf42015-05-20 13:29:18 -0700955 case11Result = ping
shahshreyadcb08e82015-02-25 10:16:42 -0800956 utilities.assert_equals(
shahshreya74cca802015-02-26 12:24:01 -0800957 expect = main.TRUE,
958 actual = case11Result,
959 onpass = "Point intents for hosts on same devices" +
shahshreyadcb08e82015-02-25 10:16:42 -0800960 "Ping Test successful",
shahshreya74cca802015-02-26 12:24:01 -0800961 onfail = "Point intents for hosts on same devices" +
shahshreyadcb08e82015-02-25 10:16:42 -0800962 "Ping Test NOT successful" )
shahshreya74cca802015-02-26 12:24:01 -0800963
shahshreya74cca802015-02-26 12:24:01 -0800964 def CASE12( self ):
965 """
shahshreya1937ec12015-04-03 15:35:48 -0700966 Verify the default flows on each switch in proactive mode
shahshreya74cca802015-02-26 12:24:01 -0800967 """
968 main.log.report( "This testcase is verifying num of default" +
969 " flows on each switch" )
970 main.log.report( "__________________________________" )
971 main.case( "Verify num of default flows on each switch" )
972 main.step( "Obtaining the device id's and flowrule count on them" )
973
974 case12Result = main.TRUE
975 idList = main.ONOS2.getAllDevicesId()
976 for id in idList:
977 count = main.ONOS2.FlowAddedCount( id )
shahshreya531e2b52015-02-26 12:40:46 -0800978 main.log.info("count = " +count)
979 if int(count) != 3:
shahshreya74cca802015-02-26 12:24:01 -0800980 case12Result = main.FALSE
981 break
shahshreya74cca802015-02-26 12:24:01 -0800982 utilities.assert_equals(
983 expect=main.TRUE,
984 actual=case12Result,
985 onpass = "Expected default num of flows exist",
986 onfail = "Expected default num of flows do not exist")
shahshreyadcb08e82015-02-25 10:16:42 -0800987
shahshreyafac62b12015-01-20 16:16:13 -0800988 def CASE6( self ):
shahshreyadcb08e82015-02-25 10:16:42 -0800989 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800990 main.log.report( "This testcase is testing the addition of" +
991 " host intents and then does pingall" )
shahshreyafac62b12015-01-20 16:16:13 -0800992 main.log.report( "__________________________________" )
993 main.case( "Obtaining host id's" )
994 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800995 hosts = main.ONOS2.hosts()
shahshreyafac62b12015-01-20 16:16:13 -0800996 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800997
shahshreyafac62b12015-01-20 16:16:13 -0800998 main.step( "Get all devices id" )
999 devicesIdList = main.ONOS2.getAllDevicesId()
1000 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -08001001
shahshreyafac62b12015-01-20 16:16:13 -08001002 # ONOS displays the hosts in hex format unlike mininet which does
1003 # in decimal format
1004 # So take care while adding intents
1005 """
1006 main.step( "Add host-to-host intents for mininet hosts h8 and h18 or
1007 ONOS hosts h8 and h12" )
1008 hthIntentResult = main.ONOS2.addHostIntent(
1009 "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
1010 hthIntentResult = main.ONOS2.addHostIntent(
1011 "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
1012 hthIntentResult = main.ONOS2.addHostIntent(
1013 "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
1014 hthIntentResult = main.ONOS2.addHostIntent(
1015 "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
1016 hthIntentResult = main.ONOS2.addHostIntent(
1017 "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
1018 hthIntentResult = main.ONOS2.addHostIntent(
1019 "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
1020 hthIntentResult = main.ONOS2.addHostIntent(
1021 "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
1022 hthIntentResult = main.ONOS2.addHostIntent(
1023 "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
1024 hthIntentResult = main.ONOS2.addHostIntent(
1025 "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
1026 hthIntentResult = main.ONOS2.addHostIntent(
1027 "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
1028 print "______________________________________________________"
1029 """
shahshreya234a1682015-05-27 15:41:56 -07001030 intentsId = []
shahshreyafac62b12015-01-20 16:16:13 -08001031 for i in range( 8, 18 ):
1032 main.log.info(
1033 "Adding host intent between h" + str( i ) +
1034 " and h" + str( i + 10 ) )
1035 host1 = "00:00:00:00:00:" + \
1036 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1037 host2 = "00:00:00:00:00:" + \
1038 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
1039 # NOTE: get host can return None
shahshreya1937ec12015-04-03 15:35:48 -07001040 if host1:
1041 host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
1042 if host2:
1043 host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
1044 if host1Id and host2Id:
shahshreya234a1682015-05-27 15:41:56 -07001045 intentsId.append( main.ONOS2.addHostIntent( host1Id, host2Id ) )
shahshreyafac62b12015-01-20 16:16:13 -08001046
shahshreya234a1682015-05-27 15:41:56 -07001047 checkIntentResult = main.ONOS2.checkIntentState( intentsId )
shahshreyafac62b12015-01-20 16:16:13 -08001048 time.sleep( 10 )
1049 hIntents = main.ONOS2.intents( jsonFormat=False )
1050 main.log.info( "intents:" + hIntents )
shahshreyadcb08e82015-02-25 10:16:42 -08001051 flows = main.ONOS2.flows()
1052 main.log.info( "flows:" + flows )
shahshreya4e13a062014-11-11 16:46:18 -08001053
1054 count = 1
1055 i = 8
shahshreyafac62b12015-01-20 16:16:13 -08001056 PingResult = main.TRUE
1057 # while i<10:
1058 while i < 18:
1059 main.log.info(
1060 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1061 ping = main.Mininet1.pingHost(
1062 src="h" + str( i ), target="h" + str( i + 10 ) )
1063 if ping == main.FALSE and count < 5:
1064 count += 1
1065 # i = 8
1066 PingResult = main.FALSE
1067 main.log.report( "Ping between h" +
1068 str( i ) +
1069 " and h" +
1070 str( i +
1071 10 ) +
1072 " failed. Making attempt number " +
1073 str( count ) +
1074 " in 2 seconds" )
1075 time.sleep( 2 )
1076 elif ping == main.FALSE:
1077 main.log.report( "All ping attempts between h" +
1078 str( i ) +
1079 " and h" +
1080 str( i +
1081 10 ) +
1082 "have failed" )
1083 i = 19
1084 PingResult = main.FALSE
1085 elif ping == main.TRUE:
1086 main.log.info( "Ping test between h" +
1087 str( i ) +
1088 " and h" +
1089 str( i +
1090 10 ) +
1091 "passed!" )
1092 i += 1
1093 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001094 else:
shahshreyafac62b12015-01-20 16:16:13 -08001095 main.log.info( "Unknown error" )
1096 PingResult = main.ERROR
1097 if PingResult == main.FALSE:
1098 main.log.report(
shahshreya9294c8d2015-01-21 15:54:16 -08001099 "Ping all test after Host intent addition failed.Cleaning up" )
shahshreyafac62b12015-01-20 16:16:13 -08001100 # main.cleanup()
1101 # main.exit()
1102 if PingResult == main.TRUE:
1103 main.log.report(
1104 "Ping all test after Host intent addition successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001105
shahshreya234a1682015-05-27 15:41:56 -07001106 checkIntentResult = main.ONOS2.checkIntentState( intentsId )
1107
shahshreyafac62b12015-01-20 16:16:13 -08001108 case6Result = PingResult
1109 utilities.assert_equals(
1110 expect=main.TRUE,
1111 actual=case6Result,
1112 onpass="Pingall Test after Host intents addition successful",
1113 onfail="Pingall Test after Host intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001114
shahshreyafac62b12015-01-20 16:16:13 -08001115 def CASE5( self, main ):
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001116 """
1117 Check ONOS topology matches with mininet
1118 """
shahshreya4e13a062014-11-11 16:46:18 -08001119 import json
shahshreyafac62b12015-01-20 16:16:13 -08001120 # assumes that sts is already in you PYTHONPATH
shahshreya9294c8d2015-01-21 15:54:16 -08001121 from sts.topology.teston_topology import TestONTopology
shahshreyafac62b12015-01-20 16:16:13 -08001122 # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001123 main.log.report( "This testcase is testing if all ONOS nodes" +
1124 " are in topology sync with mininet" )
shahshreyafac62b12015-01-20 16:16:13 -08001125 main.log.report( "__________________________________" )
1126 main.case( "Comparing Mininet topology with the topology of ONOS" )
1127 main.step( "Start continuous pings" )
1128 main.Mininet2.pingLong(
1129 src=main.params[ 'PING' ][ 'source1' ],
1130 target=main.params[ 'PING' ][ 'target1' ],
1131 pingTime=500 )
1132 main.Mininet2.pingLong(
1133 src=main.params[ 'PING' ][ 'source2' ],
1134 target=main.params[ 'PING' ][ 'target2' ],
1135 pingTime=500 )
1136 main.Mininet2.pingLong(
1137 src=main.params[ 'PING' ][ 'source3' ],
1138 target=main.params[ 'PING' ][ 'target3' ],
1139 pingTime=500 )
1140 main.Mininet2.pingLong(
1141 src=main.params[ 'PING' ][ 'source4' ],
1142 target=main.params[ 'PING' ][ 'target4' ],
1143 pingTime=500 )
1144 main.Mininet2.pingLong(
1145 src=main.params[ 'PING' ][ 'source5' ],
1146 target=main.params[ 'PING' ][ 'target5' ],
1147 pingTime=500 )
1148 main.Mininet2.pingLong(
1149 src=main.params[ 'PING' ][ 'source6' ],
1150 target=main.params[ 'PING' ][ 'target6' ],
1151 pingTime=500 )
1152 main.Mininet2.pingLong(
1153 src=main.params[ 'PING' ][ 'source7' ],
1154 target=main.params[ 'PING' ][ 'target7' ],
1155 pingTime=500 )
1156 main.Mininet2.pingLong(
1157 src=main.params[ 'PING' ][ 'source8' ],
1158 target=main.params[ 'PING' ][ 'target8' ],
1159 pingTime=500 )
1160 main.Mininet2.pingLong(
1161 src=main.params[ 'PING' ][ 'source9' ],
1162 target=main.params[ 'PING' ][ 'target9' ],
1163 pingTime=500 )
1164 main.Mininet2.pingLong(
1165 src=main.params[ 'PING' ][ 'source10' ],
1166 target=main.params[ 'PING' ][ 'target10' ],
1167 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -08001168
shahshreyafac62b12015-01-20 16:16:13 -08001169 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -08001170 global ctrls
1171 ctrls = []
1172 count = 1
1173 while True:
1174 temp = ()
shahshreyafac62b12015-01-20 16:16:13 -08001175 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
1176 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
1177 temp = temp + ( "ONOS" + str( count ), )
1178 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
1179 temp = temp + \
1180 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
1181 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -08001182 count = count + 1
1183 else:
1184 break
1185 global MNTopo
shahshreyafac62b12015-01-20 16:16:13 -08001186 Topo = TestONTopology(
1187 main.Mininet1,
1188 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -08001189 MNTopo = Topo
1190
shahshreyafac62b12015-01-20 16:16:13 -08001191 TopologyCheck = main.TRUE
1192 main.step( "Compare ONOS Topology to MN Topology" )
1193 devicesJson = main.ONOS2.devices()
1194 linksJson = main.ONOS2.links()
1195 # portsJson = main.ONOS2.ports()
1196
1197 result1 = main.Mininet1.compareSwitches(
1198 MNTopo,
1199 json.loads( devicesJson ) )
1200 result2 = main.Mininet1.compareLinks(
1201 MNTopo,
1202 json.loads( linksJson ) )
1203 # result3 = main.Mininet1.comparePorts(
1204 # MNTopo, json.loads( portsJson ) )
1205
1206 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001207 result = result1 and result2
shahshreyafac62b12015-01-20 16:16:13 -08001208
shahshreya4e13a062014-11-11 16:46:18 -08001209 print "***********************"
1210 if result == main.TRUE:
shahshreyafac62b12015-01-20 16:16:13 -08001211 main.log.report( "ONOS" + " Topology matches MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001212 else:
shahshreyafac62b12015-01-20 16:16:13 -08001213 main.log.report( "ONOS" + " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001214
shahshreyafac62b12015-01-20 16:16:13 -08001215 utilities.assert_equals(
1216 expect=main.TRUE,
1217 actual=result,
1218 onpass="ONOS" +
1219 " Topology matches MN Topology",
1220 onfail="ONOS" +
1221 " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001222
shahshreyafac62b12015-01-20 16:16:13 -08001223 TopologyCheck = TopologyCheck and result
1224 utilities.assert_equals(
1225 expect=main.TRUE,
1226 actual=TopologyCheck,
1227 onpass="Topology checks passed",
1228 onfail="Topology checks failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001229
shahshreyafac62b12015-01-20 16:16:13 -08001230 def CASE7( self, main ):
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001231 """
1232 Link discovery test case. Checks if ONOS can discover a link
1233 down or up properly.
1234 """
1235
shahshreya9294c8d2015-01-21 15:54:16 -08001236 from sts.topology.teston_topology import TestONTopology
shahshreya4e13a062014-11-11 16:46:18 -08001237
shahshreyafac62b12015-01-20 16:16:13 -08001238 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -08001239
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001240 main.log.report( "This testscase is killing a link to ensure that" +
1241 " link discovery is consistent" )
shahshreyafac62b12015-01-20 16:16:13 -08001242 main.log.report( "__________________________________" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001243 main.log.report( "Killing a link to ensure that link discovery" +
1244 " is consistent" )
1245 main.case( "Killing a link to Ensure that Link Discovery" +
1246 "is Working Properly" )
shahshreyafac62b12015-01-20 16:16:13 -08001247 """
1248 main.step( "Start continuous pings" )
shahshreya4e13a062014-11-11 16:46:18 -08001249
shahshreyafac62b12015-01-20 16:16:13 -08001250 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
1251 target=main.params[ 'PING' ][ 'target1' ],
1252 pingTime=500 )
1253 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
1254 target=main.params[ 'PING' ][ 'target2' ],
1255 pingTime=500 )
1256 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
1257 target=main.params[ 'PING' ][ 'target3' ],
1258 pingTime=500 )
1259 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
1260 target=main.params[ 'PING' ][ 'target4' ],
1261 pingTime=500 )
1262 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
1263 target=main.params[ 'PING' ][ 'target5' ],
1264 pingTime=500 )
1265 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
1266 target=main.params[ 'PING' ][ 'target6' ],
1267 pingTime=500 )
1268 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
1269 target=main.params[ 'PING' ][ 'target7' ],
1270 pingTime=500 )
1271 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
1272 target=main.params[ 'PING' ][ 'target8' ],
1273 pingTime=500 )
1274 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
1275 target=main.params[ 'PING' ][ 'target9' ],
1276 pingTime=500 )
1277 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
1278 target=main.params[ 'PING' ][ 'target10' ],
1279 pingTime=500 )
1280 """
1281 main.step( "Determine the current number of switches and links" )
1282 topologyOutput = main.ONOS2.topology()
1283 topologyResult = main.ONOS1.getTopology( topologyOutput )
shahshreyaa47ebf42015-05-20 13:29:18 -07001284 activeSwitches = topologyResult[ 'devices' ]
1285 links = topologyResult[ 'links' ]
shahshreyafac62b12015-01-20 16:16:13 -08001286 print "activeSwitches = ", type( activeSwitches )
1287 print "links = ", type( links )
1288 main.log.info(
1289 "Currently there are %s switches and %s links" %
1290 ( str( activeSwitches ), str( links ) ) )
1291
1292 main.step( "Kill Link between s3 and s28" )
1293 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
1294 time.sleep( linkSleep )
1295 topologyOutput = main.ONOS2.topology()
1296 LinkDown = main.ONOS1.checkStatus(
1297 topologyOutput, activeSwitches, str(
1298 int( links ) - 2 ) )
1299 if LinkDown == main.TRUE:
1300 main.log.report( "Link Down discovered properly" )
1301 utilities.assert_equals(
1302 expect=main.TRUE,
1303 actual=LinkDown,
1304 onpass="Link Down discovered properly",
1305 onfail="Link down was not discovered in " +
1306 str( linkSleep ) +
1307 " seconds" )
1308
1309 # Check ping result here..add code for it
1310
1311 main.step( "Bring link between s3 and s28 back up" )
1312 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
1313 time.sleep( linkSleep )
1314 topologyOutput = main.ONOS2.topology()
1315 LinkUp = main.ONOS1.checkStatus(
1316 topologyOutput,
1317 activeSwitches,
1318 str( links ) )
1319 if LinkUp == main.TRUE:
1320 main.log.report( "Link up discovered properly" )
1321 utilities.assert_equals(
1322 expect=main.TRUE,
1323 actual=LinkUp,
1324 onpass="Link up discovered properly",
1325 onfail="Link up was not discovered in " +
1326 str( linkSleep ) +
1327 " seconds" )
1328
1329 # NOTE Check ping result here..add code for it
1330
1331 main.step( "Compare ONOS Topology to MN Topology" )
1332 Topo = TestONTopology(
1333 main.Mininet1,
1334 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -08001335 MNTopo = Topo
shahshreyafac62b12015-01-20 16:16:13 -08001336 TopologyCheck = main.TRUE
1337
1338 devicesJson = main.ONOS2.devices()
1339 linksJson = main.ONOS2.links()
1340 portsJson = main.ONOS2.ports()
1341
1342 result1 = main.Mininet1.compareSwitches(
1343 MNTopo,
1344 json.loads( devicesJson ) )
1345 result2 = main.Mininet1.compareLinks(
1346 MNTopo,
1347 json.loads( linksJson ) )
1348 # result3 = main.Mininet1.comparePorts(
1349 # MNTopo, json.loads( portsJson ) )
1350
1351 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001352 result = result1 and result2
1353 print "***********************"
shahshreyafac62b12015-01-20 16:16:13 -08001354
shahshreya4e13a062014-11-11 16:46:18 -08001355 if result == main.TRUE:
shahshreyafac62b12015-01-20 16:16:13 -08001356 main.log.report( "ONOS" + " Topology matches MN Topology" )
1357 utilities.assert_equals(
1358 expect=main.TRUE,
1359 actual=result,
1360 onpass="ONOS" +
1361 " Topology matches MN Topology",
1362 onfail="ONOS" +
1363 " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001364
shahshreyafac62b12015-01-20 16:16:13 -08001365 TopologyCheck = TopologyCheck and result
1366 utilities.assert_equals(
1367 expect=main.TRUE,
1368 actual=TopologyCheck,
1369 onpass="Topology checks passed",
1370 onfail="Topology checks failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001371
shahshreyafac62b12015-01-20 16:16:13 -08001372 result = LinkDown and LinkUp and TopologyCheck
1373 utilities.assert_equals( expect=main.TRUE, actual=result,
shahshreya9294c8d2015-01-21 15:54:16 -08001374 onpass="Link failure is discovered correctly",
1375 onfail="Link Discovery failed" )
shahshreyafac62b12015-01-20 16:16:13 -08001376
1377 def CASE8( self ):
1378 """
shahshreya82ecd282015-02-05 16:48:03 -08001379 Intent removal
shahshreyafac62b12015-01-20 16:16:13 -08001380 """
shahshreya82ecd282015-02-05 16:48:03 -08001381 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001382 main.log.report( "This testcase removes any previously added intents" +
shahshreya82ecd282015-02-05 16:48:03 -08001383 " before adding any new set of intents" )
shahshreyafac62b12015-01-20 16:16:13 -08001384 main.log.report( "__________________________________" )
shahshreya82ecd282015-02-05 16:48:03 -08001385 main.log.info( "intent removal" )
1386 main.case( "Removing installed intents" )
shahshreyafac62b12015-01-20 16:16:13 -08001387 main.step( "Obtain the intent id's" )
shahshreya234a1682015-05-27 15:41:56 -07001388 currentIntents = main.ONOS2.intents( jsonFormat=False )
1389 main.log.info( "intent_result = " + currentIntents )
1390 intentLinewise = currentIntents.split( "\n" )
shahshreyafac62b12015-01-20 16:16:13 -08001391
shahshreyadcb08e82015-02-25 10:16:42 -08001392 intentList = [line for line in intentLinewise \
1393 if line.startswith( "id=")]
1394 intentids = [line.split( "," )[ 0 ].split( "=" )[ 1 ] for line in \
1395 intentList]
shahshreya4e13a062014-11-11 16:46:18 -08001396 for id in intentids:
1397 print "id = ", id
shahshreyafac62b12015-01-20 16:16:13 -08001398
1399 main.step(
1400 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -08001401 for id in intentids:
shahshreyaa47ebf42015-05-20 13:29:18 -07001402 main.ONOS2.removeIntent( intentId=id ,purge=True)
shahshreyae6c7cf42014-11-26 16:39:01 -08001403
shahshreya234a1682015-05-27 15:41:56 -07001404 remainingIntents = main.ONOS2.intents( jsonFormat=False )
1405 main.log.info( "intent_result = " + remainingIntents )
1406 if remainingIntents:
1407 main.log.info( "There are still remaining intents " )
1408 intentResult = main.FALSE
1409 else:
1410 intentResult = main.TRUE
1411
1412 intentList = [line for line in remainingIntents.split( "\n" ) \
shahshreyadcb08e82015-02-25 10:16:42 -08001413 if line.startswith( "id=")]
1414 intentState = [line.split( "," )[ 1 ].split( "=" )[ 1 ] for line in \
1415 intentList]
1416 for state in intentState:
1417 print state
1418
shahshreya234a1682015-05-27 15:41:56 -07001419 case8Result = main.TRUE
shahshreyadcb08e82015-02-25 10:16:42 -08001420 for state in intentState:
1421 if state != 'WITHDRAWN':
1422 case8Result = main.FALSE
1423 break
shahshreyafac62b12015-01-20 16:16:13 -08001424
1425 PingResult = main.TRUE
shahshreya234a1682015-05-27 15:41:56 -07001426 """
shahshreyafac62b12015-01-20 16:16:13 -08001427 if case8Result == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001428 i = 8
shahshreyafac62b12015-01-20 16:16:13 -08001429 while i < 18:
1430 main.log.info(
1431 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1432 ping = main.Mininet1.pingHost(
1433 src="h" + str( i ), target="h" + str( i + 10 ) )
1434 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001435 i = 19
shahshreyafac62b12015-01-20 16:16:13 -08001436 PingResult = PingResult and main.TRUE
1437 elif ping == main.FALSE:
1438 i += 1
1439 PingResult = PingResult and main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -08001440 else:
shahshreyafac62b12015-01-20 16:16:13 -08001441 main.log.info( "Unknown error" )
1442 PingResult = main.ERROR
shahshreya234a1682015-05-27 15:41:56 -07001443
shahshreyafac62b12015-01-20 16:16:13 -08001444 # Note: If the ping result failed, that means the intents have been
1445 # withdrawn correctly.
1446 if PingResult == main.TRUE:
shahshreya82ecd282015-02-05 16:48:03 -08001447 main.log.report( "Installed intents have not been withdrawn correctly" )
shahshreyafac62b12015-01-20 16:16:13 -08001448 # main.cleanup()
1449 # main.exit()
1450 if PingResult == main.FALSE:
shahshreya82ecd282015-02-05 16:48:03 -08001451 main.log.report( "Installed intents have been withdrawn correctly" )
shahshreya234a1682015-05-27 15:41:56 -07001452 """
shahshreya4e13a062014-11-11 16:46:18 -08001453
shahshreya234a1682015-05-27 15:41:56 -07001454 if case8Result:
shahshreyafac62b12015-01-20 16:16:13 -08001455 main.log.report( "Intent removal successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001456 else:
shahshreyafac62b12015-01-20 16:16:13 -08001457 main.log.report( "Intent removal failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001458
shahshreya234a1682015-05-27 15:41:56 -07001459 utilities.assert_equals( expect=main.TRUE, actual=case8Result,
shahshreya9294c8d2015-01-21 15:54:16 -08001460 onpass="Intent removal test passed",
1461 onfail="Intent removal test failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001462
shahshreyafac62b12015-01-20 16:16:13 -08001463 def CASE9( self ):
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001464 """
1465 Testing Point intents
1466 """
shahshreyafac62b12015-01-20 16:16:13 -08001467 main.log.report(
kelvin-onlabc2dcd3f2015-04-09 16:40:02 -07001468 "This test case adds point intents and then does pingall" )
shahshreyafac62b12015-01-20 16:16:13 -08001469 main.log.report( "__________________________________" )
1470 main.log.info( "Adding point intents" )
1471 main.case(
shahshreya71162c62015-01-23 15:31:16 -08001472 "Adding bidirectional point for mn hosts" +
1473 "( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22, " +
1474 "h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001475 macsDict = {}
1476 for i in range( 1,29 ):
1477 macsDict[ 'h' + str( i ) ]= main.Mininet1.getMacAddress( host='h'+ str( i ) )
1478 print macsDict
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001479 main.step( "Add point intents for mn hosts h8 and h18 or" +
1480 "ONOS hosts h8 and h12" )
shahshreya3dc3ce62015-01-22 13:31:59 -08001481 # main.step(var1)
shahshreyafac62b12015-01-20 16:16:13 -08001482 ptpIntentResult = main.ONOS2.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -07001483 ingressDevice="of:0000000000003008/1",
1484 egressDevice="of:0000000000006018/1",
1485 ethType='IPV4',
1486 ethSrc=macsDict.get( 'h8' ))
shahshreyafac62b12015-01-20 16:16:13 -08001487 if ptpIntentResult == main.TRUE:
1488 getIntentResult = main.ONOS2.intents()
1489 main.log.info( "Point to point intent install successful" )
1490 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001491
shahshreyafac62b12015-01-20 16:16:13 -08001492 ptpIntentResult = main.ONOS2.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -07001493 ingressDevice="of:0000000000006018/1",
1494 egressDevice="of:0000000000003008/1",
1495 ethType='IPV4',
1496 ethSrc=macsDict.get( 'h18' ))
shahshreyafac62b12015-01-20 16:16:13 -08001497 if ptpIntentResult == main.TRUE:
1498 getIntentResult = main.ONOS2.intents()
1499 main.log.info( "Point to point intent install successful" )
1500 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001501
shahshreya9294c8d2015-01-21 15:54:16 -08001502 var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
1503 main.step(var2)
shahshreyafac62b12015-01-20 16:16:13 -08001504 ptpIntentResult = main.ONOS2.addPointIntent(
1505 "of:0000000000003009/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001506 "of:0000000000006019/1",
1507 ethType='IPV4',
1508 ethSrc=macsDict.get( 'h9' ))
shahshreyafac62b12015-01-20 16:16:13 -08001509 if ptpIntentResult == main.TRUE:
1510 getIntentResult = main.ONOS2.intents()
1511 main.log.info( "Point to point intent install successful" )
1512 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001513
shahshreyafac62b12015-01-20 16:16:13 -08001514 ptpIntentResult = main.ONOS2.addPointIntent(
1515 "of:0000000000006019/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001516 "of:0000000000003009/1",
1517 ethType='IPV4',
1518 ethSrc=macsDict.get( 'h19' ))
shahshreyafac62b12015-01-20 16:16:13 -08001519 if ptpIntentResult == main.TRUE:
1520 getIntentResult = main.ONOS2.intents()
1521 main.log.info( "Point to point intent install successful" )
1522 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001523
shahshreya9294c8d2015-01-21 15:54:16 -08001524 var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
1525 main.step(var3)
shahshreyafac62b12015-01-20 16:16:13 -08001526 ptpIntentResult = main.ONOS2.addPointIntent(
1527 "of:0000000000003010/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001528 "of:0000000000006020/1",
1529 ethType='IPV4',
1530 ethSrc=macsDict.get( 'h10' ))
1531
shahshreyafac62b12015-01-20 16:16:13 -08001532 if ptpIntentResult == main.TRUE:
1533 getIntentResult = main.ONOS2.intents()
1534 main.log.info( "Point to point intent install successful" )
1535 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001536
shahshreyafac62b12015-01-20 16:16:13 -08001537 ptpIntentResult = main.ONOS2.addPointIntent(
1538 "of:0000000000006020/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001539 "of:0000000000003010/1",
1540 ethType='IPV4',
1541 ethSrc=macsDict.get( 'h20' ))
1542
shahshreyafac62b12015-01-20 16:16:13 -08001543 if ptpIntentResult == main.TRUE:
1544 getIntentResult = main.ONOS2.intents()
1545 main.log.info( "Point to point intent install successful" )
1546 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001547
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001548 var4 = "Add point intents for mininet hosts h11 and h21 or" +\
1549 " ONOS hosts hB and h15"
shahshreya9294c8d2015-01-21 15:54:16 -08001550 main.case(var4)
shahshreyafac62b12015-01-20 16:16:13 -08001551 ptpIntentResult = main.ONOS2.addPointIntent(
1552 "of:0000000000003011/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001553 "of:0000000000006021/1",
1554 ethType='IPV4',
1555 ethSrc=macsDict.get( 'h11' ))
1556
shahshreyafac62b12015-01-20 16:16:13 -08001557 if ptpIntentResult == main.TRUE:
1558 getIntentResult = main.ONOS2.intents()
1559 main.log.info( "Point to point intent install successful" )
1560 # main.log.info( getIntentResult )
1561
1562 ptpIntentResult = main.ONOS2.addPointIntent(
1563 "of:0000000000006021/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001564 "of:0000000000003011/1",
1565 ethType='IPV4',
1566 ethSrc=macsDict.get( 'h21' ))
1567
shahshreyafac62b12015-01-20 16:16:13 -08001568 if ptpIntentResult == main.TRUE:
1569 getIntentResult = main.ONOS2.intents()
1570 main.log.info( "Point to point intent install successful" )
1571 # main.log.info( getIntentResult )
1572
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001573 var5 = "Add point intents for mininet hosts h12 and h22 " +\
1574 "ONOS hosts hC and h16"
shahshreya9294c8d2015-01-21 15:54:16 -08001575 main.case(var5)
shahshreyafac62b12015-01-20 16:16:13 -08001576 ptpIntentResult = main.ONOS2.addPointIntent(
1577 "of:0000000000003012/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001578 "of:0000000000006022/1",
1579 ethType='IPV4',
1580 ethSrc=macsDict.get( 'h12' ))
1581
shahshreyafac62b12015-01-20 16:16:13 -08001582 if ptpIntentResult == main.TRUE:
1583 getIntentResult = main.ONOS2.intents()
1584 main.log.info( "Point to point intent install successful" )
1585 # main.log.info( getIntentResult )
1586
1587 ptpIntentResult = main.ONOS2.addPointIntent(
1588 "of:0000000000006022/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001589 "of:0000000000003012/1",
1590 ethType='IPV4',
1591 ethSrc=macsDict.get( 'h22' ))
1592
shahshreyafac62b12015-01-20 16:16:13 -08001593 if ptpIntentResult == main.TRUE:
1594 getIntentResult = main.ONOS2.intents()
1595 main.log.info( "Point to point intent install successful" )
1596 # main.log.info( getIntentResult )
1597
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001598 var6 = "Add point intents for mininet hosts h13 and h23 or" +\
1599 " ONOS hosts hD and h17"
shahshreya9294c8d2015-01-21 15:54:16 -08001600 main.case(var6)
shahshreyafac62b12015-01-20 16:16:13 -08001601 ptpIntentResult = main.ONOS2.addPointIntent(
1602 "of:0000000000003013/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001603 "of:0000000000006023/1",
1604 ethType='IPV4',
1605 ethSrc=macsDict.get( 'h13' ))
1606
shahshreyafac62b12015-01-20 16:16:13 -08001607 if ptpIntentResult == main.TRUE:
1608 getIntentResult = main.ONOS2.intents()
1609 main.log.info( "Point to point intent install successful" )
1610 # main.log.info( getIntentResult )
1611
1612 ptpIntentResult = main.ONOS2.addPointIntent(
1613 "of:0000000000006023/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001614 "of:0000000000003013/1",
1615 ethType='IPV4',
1616 ethSrc=macsDict.get( 'h23' ))
1617
shahshreyafac62b12015-01-20 16:16:13 -08001618 if ptpIntentResult == main.TRUE:
1619 getIntentResult = main.ONOS2.intents()
1620 main.log.info( "Point to point intent install successful" )
1621 # main.log.info( getIntentResult )
1622
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001623 var7 = "Add point intents for mininet hosts h14 and h24 or" +\
1624 " ONOS hosts hE and h18"
shahshreya9294c8d2015-01-21 15:54:16 -08001625 main.case(var7)
shahshreyafac62b12015-01-20 16:16:13 -08001626 ptpIntentResult = main.ONOS2.addPointIntent(
1627 "of:0000000000003014/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001628 "of:0000000000006024/1",
1629 ethType='IPV4',
1630 ethSrc=macsDict.get( 'h14' ))
1631
shahshreyafac62b12015-01-20 16:16:13 -08001632 if ptpIntentResult == main.TRUE:
1633 getIntentResult = main.ONOS2.intents()
1634 main.log.info( "Point to point intent install successful" )
1635 # main.log.info( getIntentResult )
1636
1637 ptpIntentResult = main.ONOS2.addPointIntent(
1638 "of:0000000000006024/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001639 "of:0000000000003014/1",
1640 ethType='IPV4',
1641 ethSrc=macsDict.get( 'h24' ))
1642
shahshreyafac62b12015-01-20 16:16:13 -08001643 if ptpIntentResult == main.TRUE:
1644 getIntentResult = main.ONOS2.intents()
1645 main.log.info( "Point to point intent install successful" )
1646 # main.log.info( getIntentResult )
1647
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001648 var8 = "Add point intents for mininet hosts h15 and h25 or" +\
1649 " ONOS hosts hF and h19"
shahshreya9294c8d2015-01-21 15:54:16 -08001650 main.case(var8)
shahshreyafac62b12015-01-20 16:16:13 -08001651 ptpIntentResult = main.ONOS2.addPointIntent(
1652 "of:0000000000003015/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001653 "of:0000000000006025/1",
1654 ethType='IPV4',
1655 ethSrc=macsDict.get( 'h15' ))
1656
shahshreyafac62b12015-01-20 16:16:13 -08001657 if ptpIntentResult == main.TRUE:
1658 getIntentResult = main.ONOS2.intents()
1659 main.log.info( "Point to point intent install successful" )
1660 # main.log.info( getIntentResult )
1661
1662 ptpIntentResult = main.ONOS2.addPointIntent(
1663 "of:0000000000006025/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001664 "of:0000000000003015/1",
1665 ethType='IPV4',
1666 ethSrc=macsDict.get( 'h25' ))
1667
shahshreyafac62b12015-01-20 16:16:13 -08001668 if ptpIntentResult == main.TRUE:
1669 getIntentResult = main.ONOS2.intents()
1670 main.log.info( "Point to point intent install successful" )
1671 # main.log.info( getIntentResult )
1672
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001673 var9 = "Add intents for mininet hosts h16 and h26 or" +\
1674 " ONOS hosts h10 and h1A"
shahshreya9294c8d2015-01-21 15:54:16 -08001675 main.case(var9)
shahshreyafac62b12015-01-20 16:16:13 -08001676 ptpIntentResult = main.ONOS2.addPointIntent(
1677 "of:0000000000003016/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001678 "of:0000000000006026/1",
1679 ethType='IPV4',
1680 ethSrc=macsDict.get( 'h16' ))
1681
shahshreyafac62b12015-01-20 16:16:13 -08001682 if ptpIntentResult == main.TRUE:
1683 getIntentResult = main.ONOS2.intents()
1684 main.log.info( "Point to point intent install successful" )
1685 # main.log.info( getIntentResult )
1686
1687 ptpIntentResult = main.ONOS2.addPointIntent(
1688 "of:0000000000006026/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001689 "of:0000000000003016/1",
1690 ethType='IPV4',
1691 ethSrc=macsDict.get( 'h26' ))
1692
shahshreyafac62b12015-01-20 16:16:13 -08001693 if ptpIntentResult == main.TRUE:
1694 getIntentResult = main.ONOS2.intents()
1695 main.log.info( "Point to point intent install successful" )
1696 # main.log.info( getIntentResult )
1697
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001698 var10 = "Add point intents for mininet hosts h17 and h27 or" +\
1699 " ONOS hosts h11 and h1B"
shahshreya9294c8d2015-01-21 15:54:16 -08001700 main.case(var10)
shahshreyafac62b12015-01-20 16:16:13 -08001701 ptpIntentResult = main.ONOS2.addPointIntent(
1702 "of:0000000000003017/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001703 "of:0000000000006027/1",
1704 ethType='IPV4',
1705 ethSrc=macsDict.get( 'h17' ))
1706
shahshreyafac62b12015-01-20 16:16:13 -08001707 if ptpIntentResult == main.TRUE:
1708 getIntentResult = main.ONOS2.intents()
1709 main.log.info( "Point to point intent install successful" )
shahshreyadcb08e82015-02-25 10:16:42 -08001710 #main.log.info( getIntentResult )
shahshreyafac62b12015-01-20 16:16:13 -08001711
1712 ptpIntentResult = main.ONOS2.addPointIntent(
1713 "of:0000000000006027/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001714 "of:0000000000003017/1",
1715 ethType='IPV4',
1716 ethSrc=macsDict.get( 'h27' ))
1717
shahshreyafac62b12015-01-20 16:16:13 -08001718 if ptpIntentResult == main.TRUE:
1719 getIntentResult = main.ONOS2.intents()
1720 main.log.info( "Point to point intent install successful" )
shahshreyadcb08e82015-02-25 10:16:42 -08001721 #main.log.info( getIntentResult )
shahshreyafac62b12015-01-20 16:16:13 -08001722
1723 print(
1724 "___________________________________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001725
1726 flowHandle = main.ONOS2.flows()
shahshreya82ecd282015-02-05 16:48:03 -08001727 #main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001728
1729 count = 1
1730 i = 8
shahshreyafac62b12015-01-20 16:16:13 -08001731 PingResult = main.TRUE
1732 while i < 18:
1733 main.log.info(
1734 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1735 ping = main.Mininet1.pingHost(
1736 src="h" + str( i ), target="h" + str( i + 10 ) )
1737 if ping == main.FALSE and count < 5:
1738 count += 1
1739 # i = 8
1740 PingResult = main.FALSE
1741 main.log.report( "Ping between h" +
1742 str( i ) +
1743 " and h" +
1744 str( i +
1745 10 ) +
1746 " failed. Making attempt number " +
1747 str( count ) +
1748 " in 2 seconds" )
1749 time.sleep( 2 )
1750 elif ping == main.FALSE:
1751 main.log.report( "All ping attempts between h" +
1752 str( i ) +
1753 " and h" +
1754 str( i +
1755 10 ) +
1756 "have failed" )
1757 i = 19
1758 PingResult = main.FALSE
1759 elif ping == main.TRUE:
1760 main.log.info( "Ping test between h" +
1761 str( i ) +
1762 " and h" +
1763 str( i +
1764 10 ) +
1765 "passed!" )
1766 i += 1
1767 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001768 else:
shahshreyafac62b12015-01-20 16:16:13 -08001769 main.log.info( "Unknown error" )
1770 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001771
shahshreyafac62b12015-01-20 16:16:13 -08001772 if PingResult == main.FALSE:
1773 main.log.report(
1774 "Point intents have not ben installed correctly. Cleaning up" )
1775 # main.cleanup()
1776 # main.exit()
1777 if PingResult == main.TRUE:
1778 main.log.report( "Point Intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001779
shahshreyafac62b12015-01-20 16:16:13 -08001780 case9Result = PingResult
1781 utilities.assert_equals(
1782 expect=main.TRUE,
1783 actual=case9Result,
1784 onpass="Point intents addition and Pingall Test successful",
1785 onfail="Point intents addition and Pingall Test NOT successful" )