blob: b1246c23b0eb6c6ed2781e2dea6576560c2c8ec2 [file] [log] [blame]
shahshreya4e13a062014-11-11 16:46:18 -08001
kelvin-onlab8a832582015-01-16 17:06:11 -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
shahshreya9294c8d2015-01-21 15:54:16 -08006# import sys
7# import os
8# import re
shahshreya4e13a062014-11-11 16:46:18 -08009import json
10
kelvin-onlab8a832582015-01-16 17:06:11 -080011time.sleep( 1 )
12
13
shahshreya4e13a062014-11-11 16:46:18 -080014class ProdFunc13:
kelvin-onlab8a832582015-01-16 17:06:11 -080015
16 def __init__( self ):
shahshreya4e13a062014-11-11 16:46:18 -080017 self.default = ''
18
kelvin-onlab8a832582015-01-16 17:06:11 -080019 def CASE1( self, main ):
20 """
shahshreya4e13a062014-11-11 16:46:18 -080021 Startup sequence:
shahshreyae6c7cf42014-11-26 16:39:01 -080022 cell <name>
23 onos-verify-cell
24 onos-remove-raft-log
shahshreya4e13a062014-11-11 16:46:18 -080025 git pull
26 mvn clean install
27 onos-package
shahshreya4e13a062014-11-11 16:46:18 -080028 onos-install -f
29 onos-wait-for-start
kelvin-onlab8a832582015-01-16 17:06:11 -080030 """
shahshreya9294c8d2015-01-21 15:54:16 -080031 cellName = main.params[ 'ENV' ][ 'cellName' ]
32 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreyae6c7cf42014-11-26 16:39:01 -080033
kelvin-onlab8a832582015-01-16 17:06:11 -080034 main.case( "Setting up test environment" )
35 main.log.report(
36 "This testcase is testing setting up test environment" )
37 main.log.report( "__________________________________" )
38
39 main.step( "Applying cell variable to environment" )
shahshreya9294c8d2015-01-21 15:54:16 -080040 cellResult = main.ONOSbench.setCell( cellName )
41 verifyResult = main.ONOSbench.verifyCell()
kelvin-onlab8a832582015-01-16 17:06:11 -080042
43 main.step( "Removing raft logs before a clen installation of ONOS" )
shahshreya9294c8d2015-01-21 15:54:16 -080044 main.ONOSbench.onosRemoveRaftLogs()
shahshreyae6c7cf42014-11-26 16:39:01 -080045
shahshreyab512cd02015-01-27 17:01:47 -080046 main.step( "Git checkout, pull and get version" )
47 #main.ONOSbench.gitCheckout( "master" )
shahshreya9294c8d2015-01-21 15:54:16 -080048 gitPullResult = main.ONOSbench.gitPull()
49 main.log.info( "git_pull_result = " + gitPullResult )
50 main.ONOSbench.getVersion( report=True )
kelvin-onlab8a832582015-01-16 17:06:11 -080051
shahshreya9294c8d2015-01-21 15:54:16 -080052 if gitPullResult == 1:
kelvin-onlab8a832582015-01-16 17:06:11 -080053 main.step( "Using mvn clean & install" )
shahshreya9294c8d2015-01-21 15:54:16 -080054 main.ONOSbench.cleanInstall()
55 elif gitPullResult == 0:
kelvin-onlab8a832582015-01-16 17:06:11 -080056 main.log.report(
57 "Git Pull Failed, look into logs for detailed reason" )
shahshreyaa22f8f82014-12-08 16:59:21 -080058 main.cleanup()
kelvin-onlab8a832582015-01-16 17:06:11 -080059 main.exit()
60
61 main.step( "Creating ONOS package" )
shahshreya9294c8d2015-01-21 15:54:16 -080062 packageResult = main.ONOSbench.onosPackage()
shahshreya4e13a062014-11-11 16:46:18 -080063
kelvin-onlab8a832582015-01-16 17:06:11 -080064 main.step( "Installing ONOS package" )
shahshreya9294c8d2015-01-21 15:54:16 -080065 onosInstallResult = main.ONOSbench.onosInstall()
66 if onosInstallResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -080067 main.log.report( "Installing ONOS package successful" )
shahshreya4e13a062014-11-11 16:46:18 -080068 else:
kelvin-onlab8a832582015-01-16 17:06:11 -080069 main.log.report( "Installing ONOS package failed" )
shahshreya4e13a062014-11-11 16:46:18 -080070
shahshreya9294c8d2015-01-21 15:54:16 -080071 onos1Isup = main.ONOSbench.isup()
72 if onos1Isup == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -080073 main.log.report( "ONOS instance is up and ready" )
shahshreya4e13a062014-11-11 16:46:18 -080074 else:
kelvin-onlab8a832582015-01-16 17:06:11 -080075 main.log.report( "ONOS instance may not be up" )
shahshreya4e13a062014-11-11 16:46:18 -080076
kelvin-onlab8a832582015-01-16 17:06:11 -080077 main.step( "Starting ONOS service" )
shahshreya9294c8d2015-01-21 15:54:16 -080078 startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -080079
shahshreya9294c8d2015-01-21 15:54:16 -080080 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
kelvin-onlab8a832582015-01-16 17:06:11 -080081
shahshreya9294c8d2015-01-21 15:54:16 -080082 case1Result = ( packageResult and
83 cellResult and verifyResult
84 and onosInstallResult and
85 onos1Isup and startResult )
86 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
kelvin-onlab8a832582015-01-16 17:06:11 -080087 onpass="Test startup successful",
88 onfail="Test startup NOT successful" )
89
90 def CASE2( self, main ):
91 """
shahshreyaa22f8f82014-12-08 16:59:21 -080092 Switch Down
kelvin-onlab8a832582015-01-16 17:06:11 -080093 """
94 # NOTE: You should probably run a topology check after this
95 import time
shahshreyaa22f8f82014-12-08 16:59:21 -080096
kelvin-onlab8a832582015-01-16 17:06:11 -080097 main.case( "Switch down discovery" )
98 main.log.report( "This testcase is testing a switch down discovery" )
99 main.log.report( "__________________________________" )
100
shahshreya9294c8d2015-01-21 15:54:16 -0800101 switchSleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
shahshreyaa22f8f82014-12-08 16:59:21 -0800102
103 description = "Killing a switch to ensure it is discovered correctly"
kelvin-onlab8a832582015-01-16 17:06:11 -0800104 main.log.report( description )
105 main.case( description )
shahshreyaa22f8f82014-12-08 16:59:21 -0800106
kelvin-onlab8a832582015-01-16 17:06:11 -0800107 # TODO: Make this switch parameterizable
108 main.step( "Kill s28 " )
109 main.log.report( "Deleting s28" )
110 # FIXME: use new dynamic topo functions
shahshreya9294c8d2015-01-21 15:54:16 -0800111 main.Mininet1.delSwitch( "s28" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800112 main.log.info(
113 "Waiting " +
shahshreya9294c8d2015-01-21 15:54:16 -0800114 str( switchSleep ) +
kelvin-onlab8a832582015-01-16 17:06:11 -0800115 " seconds for switch down to be discovered" )
shahshreya9294c8d2015-01-21 15:54:16 -0800116 time.sleep( switchSleep )
kelvin-onlab8a832582015-01-16 17:06:11 -0800117 # Peek at the deleted switch
shahshreya9294c8d2015-01-21 15:54:16 -0800118 device = main.ONOS2.getDevice( dpid="0028" )
shahshreyaa22f8f82014-12-08 16:59:21 -0800119 print "device = ", device
kelvin-onlab8a832582015-01-16 17:06:11 -0800120 if device[ u'available' ] == 'False':
shahshreya9294c8d2015-01-21 15:54:16 -0800121 case2Result = main.FALSE
shahshreyaa22f8f82014-12-08 16:59:21 -0800122 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800123 case2Result = main.TRUE
124 utilities.assert_equals( expect=main.TRUE, actual=case2Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800125 onpass="Switch down discovery successful",
126 onfail="Switch down discovery failed" )
shahshreyaa22f8f82014-12-08 16:59:21 -0800127
kelvin-onlab8a832582015-01-16 17:06:11 -0800128 def CASE11( self, main ):
129 """
shahshreya4e13a062014-11-11 16:46:18 -0800130 Cleanup sequence:
shahshreya9294c8d2015-01-21 15:54:16 -0800131 onos-service <nodeIp> stop
shahshreya4e13a062014-11-11 16:46:18 -0800132 onos-uninstall
133
134 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800135
kelvin-onlab8a832582015-01-16 17:06:11 -0800136 """
shahshreya9294c8d2015-01-21 15:54:16 -0800137 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800138
kelvin-onlab8a832582015-01-16 17:06:11 -0800139 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800140
kelvin-onlab8a832582015-01-16 17:06:11 -0800141 main.step( "Testing ONOS kill function" )
shahshreya9294c8d2015-01-21 15:54:16 -0800142 killResult = main.ONOSbench.onosKill( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800143
kelvin-onlab8a832582015-01-16 17:06:11 -0800144 main.step( "Stopping ONOS service" )
shahshreya9294c8d2015-01-21 15:54:16 -0800145 stopResult = main.ONOSbench.onosStop( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800146
kelvin-onlab8a832582015-01-16 17:06:11 -0800147 main.step( "Uninstalling ONOS service" )
shahshreya9294c8d2015-01-21 15:54:16 -0800148 uninstallResult = main.ONOSbench.onosUninstall()
149
150 case11Result = killResult and stopResult and uninstallResult
151 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
152 onpass="Cleanup successful",
153 onfail="Cleanup failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800154
kelvin-onlab8a832582015-01-16 17:06:11 -0800155 def CASE3( self, main ):
156 """
shahshreya4e13a062014-11-11 16:46:18 -0800157 Test 'onos' command and its functionality in driver
kelvin-onlab8a832582015-01-16 17:06:11 -0800158 """
shahshreya9294c8d2015-01-21 15:54:16 -0800159 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800160
kelvin-onlab8a832582015-01-16 17:06:11 -0800161 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800162
kelvin-onlab8a832582015-01-16 17:06:11 -0800163 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800164 cmdstr1 = "system:name"
shahshreya9294c8d2015-01-21 15:54:16 -0800165 cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
166 main.log.info( "onos command returned: " + cmdResult1 )
shahshreya4e13a062014-11-11 16:46:18 -0800167
kelvin-onlab8a832582015-01-16 17:06:11 -0800168 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800169 cmdstr2 = "onos:topology"
shahshreya9294c8d2015-01-21 15:54:16 -0800170 cmdResult2 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
171 main.log.info( "onos command returned: " + cmdResult2 )
shahshreya4e13a062014-11-11 16:46:18 -0800172
kelvin-onlab8a832582015-01-16 17:06:11 -0800173 def CASE20( self ):
174 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800175 Exit from mininet cli
176 reinstall ONOS
kelvin-onlab8a832582015-01-16 17:06:11 -0800177 """
shahshreya9294c8d2015-01-21 15:54:16 -0800178 cellName = main.params[ 'ENV' ][ 'cellName' ]
179 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
kelvin-onlab8a832582015-01-16 17:06:11 -0800180
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800181 main.log.report( "This testcase exits the mininet cli and reinstalls" +
182 "ONOS to switch over to Packet Optical topology" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800183 main.log.report( "_____________________________________________" )
184 main.case( "Disconnecting mininet and restarting ONOS" )
185 main.step( "Disconnecting mininet and restarting ONOS" )
shahshreya9294c8d2015-01-21 15:54:16 -0800186 mininetDisconnect = main.Mininet1.disconnect()
shahshreyae6c7cf42014-11-26 16:39:01 -0800187
kelvin-onlab8a832582015-01-16 17:06:11 -0800188 main.step( "Removing raft logs before a clen installation of ONOS" )
shahshreya9294c8d2015-01-21 15:54:16 -0800189 main.ONOSbench.onosRemoveRaftLogs()
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800190
kelvin-onlab8a832582015-01-16 17:06:11 -0800191 main.step( "Applying cell variable to environment" )
shahshreya9294c8d2015-01-21 15:54:16 -0800192 cellResult = main.ONOSbench.setCell( cellName )
193 verifyResult = main.ONOSbench.verifyCell()
shahshreyae6c7cf42014-11-26 16:39:01 -0800194
shahshreya9294c8d2015-01-21 15:54:16 -0800195 onosInstallResult = main.ONOSbench.onosInstall()
196 if onosInstallResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800197 main.log.report( "Installing ONOS package successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800198 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800199 main.log.report( "Installing ONOS package failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800200
shahshreya9294c8d2015-01-21 15:54:16 -0800201 onos1Isup = main.ONOSbench.isup()
202 if onos1Isup == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800203 main.log.report( "ONOS instance is up and ready" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800204 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800205 main.log.report( "ONOS instance may not be up" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800206
kelvin-onlab8a832582015-01-16 17:06:11 -0800207 main.step( "Starting ONOS service" )
shahshreya9294c8d2015-01-21 15:54:16 -0800208 startResult = main.ONOSbench.onosStart( ONOS1Ip )
kelvin-onlab8a832582015-01-16 17:06:11 -0800209
shahshreya9294c8d2015-01-21 15:54:16 -0800210 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
211 case20Result = mininetDisconnect and cellResult and verifyResult \
212 and onosInstallResult and onos1Isup and \
213 startResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800214 utilities.assert_equals(
215 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800216 actual=case20Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800217 onpass= "Exiting functionality mininet topology and reinstalling" +
218 " ONOS successful",
219 onfail= "Exiting functionality mininet topology and reinstalling" +
220 " ONOS failed" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800221
222 def CASE21( self, main ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800223 """
shahshreya9294c8d2015-01-21 15:54:16 -0800224 On ONOS bench, run this command:
225 ./~/ONOS/tools/test/bin/onos-topo-cfg
226 which starts the rest and copies the links
227 json file to the onos instance.
228 Note that in case of Packet Optical, the links are not learnt
229 from the topology, instead the links are learnt
shahshreyae6c7cf42014-11-26 16:39:01 -0800230 from the json config file
kelvin-onlab8a832582015-01-16 17:06:11 -0800231 """
232 main.log.report(
233 "This testcase starts the packet layer topology and REST" )
234 main.log.report( "_____________________________________________" )
235 main.case( "Starting LINC-OE and other components" )
236 main.step( "Starting LINC-OE and other components" )
shahshreya9294c8d2015-01-21 15:54:16 -0800237 startConsoleResult = main.LincOE1.startConsole()
238 opticalMnScript = main.LincOE2.runOpticalMnScript()
239 onosTopoCfgResult = main.ONOSbench.runOnosTopoCfg(
240 instanceName=main.params[ 'CTRL' ][ 'ip1' ],
241 jsonFile=main.params[ 'OPTICAL' ][ 'jsonfile' ] )
kelvin-onlab8a832582015-01-16 17:06:11 -0800242
shahshreya9294c8d2015-01-21 15:54:16 -0800243 print "start_console_result =", startConsoleResult
244 print "optical_mn_script = ", opticalMnScript
245 print "onos_topo_cfg_result =", onosTopoCfgResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800246
shahshreya9294c8d2015-01-21 15:54:16 -0800247 case21Result = startConsoleResult and opticalMnScript and \
248 onosTopoCfgResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800249 utilities.assert_equals(
250 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800251 actual=case21Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800252 onpass="Packet optical topology spawned successsfully",
253 onfail="Packet optical topology spawning failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800254
kelvin-onlab8a832582015-01-16 17:06:11 -0800255 def CASE22( self, main ):
256 """
shahshreya9294c8d2015-01-21 15:54:16 -0800257 Curretly we use, 4 linear switch optical topology and
258 2 packet layer mininet switches each with one host.
259 Therefore, the roadmCount variable = 4,
260 packetLayerSWCount variable = 2 and hostCount = 2
261 and this is hardcoded in the testcase. If the topology changes,
262 these hardcoded values need to be changed
kelvin-onlab8a832582015-01-16 17:06:11 -0800263 """
264 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800265 "This testcase compares the optical+packet topology against what" +
266 " is expected" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800267 main.case( "Topology comparision" )
268 main.step( "Topology comparision" )
shahshreya9294c8d2015-01-21 15:54:16 -0800269 main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
270 devicesResult = main.ONOS3.devices( jsonFormat=False )
shahshreyae6c7cf42014-11-26 16:39:01 -0800271
shahshreya9294c8d2015-01-21 15:54:16 -0800272 print "devices_result = ", devicesResult
273 devicesLinewise = devicesResult.split( "\n" )
274 devicesLinewise = devicesLinewise[ 1:-1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800275 roadmCount = 0
276 packetLayerSWCount = 0
shahshreya9294c8d2015-01-21 15:54:16 -0800277 for line in devicesLinewise:
kelvin-onlab8a832582015-01-16 17:06:11 -0800278 components = line.split( "," )
279 availability = components[ 1 ].split( "=" )[ 1 ]
280 type = components[ 3 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800281 if availability == 'true' and type == 'ROADM':
282 roadmCount += 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800283 elif availability == 'true' and type == 'SWITCH':
shahshreyae6c7cf42014-11-26 16:39:01 -0800284 packetLayerSWCount += 1
285 if roadmCount == 4:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800286 print "Number of Optical Switches = %d and is" % roadmCount +\
287 " correctly detected"
kelvin-onlab8a832582015-01-16 17:06:11 -0800288 main.log.info(
289 "Number of Optical Switches = " +
290 str( roadmCount ) +
291 " and is correctly detected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800292 opticalSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800293 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800294 print "Number of Optical Switches = %d and is wrong" % roadmCount
kelvin-onlab8a832582015-01-16 17:06:11 -0800295 main.log.info(
296 "Number of Optical Switches = " +
297 str( roadmCount ) +
298 " and is wrong" )
shahshreya9294c8d2015-01-21 15:54:16 -0800299 opticalSWResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800300
301 if packetLayerSWCount == 2:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800302 print "Number of Packet layer or mininet Switches = %d "\
303 % packetLayerSWCount + "and is correctly detected"
kelvin-onlab8a832582015-01-16 17:06:11 -0800304 main.log.info(
305 "Number of Packet layer or mininet Switches = " +
306 str( packetLayerSWCount ) +
307 " and is correctly detected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800308 packetSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800309 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800310 print "Number of Packet layer or mininet Switches = %d and"\
311 % packetLayerSWCount + " is wrong"
kelvin-onlab8a832582015-01-16 17:06:11 -0800312 main.log.info(
313 "Number of Packet layer or mininet Switches = " +
314 str( packetLayerSWCount ) +
315 " and is wrong" )
shahshreya9294c8d2015-01-21 15:54:16 -0800316 packetSWResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800317 print "_________________________________"
kelvin-onlab8a832582015-01-16 17:06:11 -0800318
shahshreya9294c8d2015-01-21 15:54:16 -0800319 linksResult = main.ONOS3.links( jsonFormat=False )
320 print "links_result = ", linksResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800321 print "_________________________________"
kelvin-onlab8a832582015-01-16 17:06:11 -0800322
shahshreya9294c8d2015-01-21 15:54:16 -0800323 # NOTE:Since only point intents are added, there is no
324 # requirement to discover the hosts
kelvin-onlab8a832582015-01-16 17:06:11 -0800325 # Therfore, the below portion of the code is commented.
326 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800327 #Discover hosts using pingall
shahshreya9294c8d2015-01-21 15:54:16 -0800328 pingallResult = main.LincOE2.pingall()
kelvin-onlab8a832582015-01-16 17:06:11 -0800329
shahshreya9294c8d2015-01-21 15:54:16 -0800330 hostsResult = main.ONOS3.hosts( jsonFormat=False )
331 main.log.info( "hosts_result = "+hostsResult )
kelvin-onlab8a832582015-01-16 17:06:11 -0800332 main.log.info( "_________________________________" )
shahshreya9294c8d2015-01-21 15:54:16 -0800333 hostsLinewise = hostsResult.split( "\n" )
334 hostsLinewise = hostsLinewise[ 1:-1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800335 hostCount = 0
shahshreya9294c8d2015-01-21 15:54:16 -0800336 for line in hostsLinewise:
kelvin-onlab8a832582015-01-16 17:06:11 -0800337 hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800338 hostCount +=1
339 if hostCount ==2:
340 print "Number of hosts = %d and is correctly detected" %hostCount
shahshreya9294c8d2015-01-21 15:54:16 -0800341 main.log.info( "Number of hosts = " + str( hostCount ) +" and \
342 is correctly detected" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800343 hostDiscovery = main.TRUE
344 else:
345 print "Number of hosts = %d and is wrong" %hostCount
shahshreya9294c8d2015-01-21 15:54:16 -0800346 main.log.info( "Number of hosts = " + str( hostCount ) +" and \
347 is wrong" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800348 hostDiscovery = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800349 """
shahshreya9294c8d2015-01-21 15:54:16 -0800350 case22Result = opticalSWResult and packetSWResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800351 utilities.assert_equals(
352 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800353 actual=case22Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800354 onpass="Packet optical topology discovery successful",
355 onfail="Packet optical topology discovery failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800356
kelvin-onlab8a832582015-01-16 17:06:11 -0800357 def CASE23( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800358 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800359 """
shahshreya9294c8d2015-01-21 15:54:16 -0800360 Add bidirectional point intents between 2 packet layer( mininet )
361 devices and
shahshreyae6c7cf42014-11-26 16:39:01 -0800362 ping mininet hosts
kelvin-onlab8a832582015-01-16 17:06:11 -0800363 """
364 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800365 "This testcase adds bidirectional point intents between 2 " +
366 "packet layer( mininet ) devices and ping mininet hosts" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800367 main.case( "Topology comparision" )
368 main.step( "Adding point intents" )
shahshreya9294c8d2015-01-21 15:54:16 -0800369 ptpIntentResult = main.ONOS3.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -0800370 "of:0000ffffffff0001/1",
371 "of:0000ffffffff0002/1" )
shahshreya9294c8d2015-01-21 15:54:16 -0800372 if ptpIntentResult == main.TRUE:
373 main.ONOS3.intents( jsonFormat=False )
kelvin-onlab8a832582015-01-16 17:06:11 -0800374 main.log.info( "Point to point intent install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800375
shahshreya9294c8d2015-01-21 15:54:16 -0800376 ptpIntentResult = main.ONOS3.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -0800377 "of:0000ffffffff0002/1",
378 "of:0000ffffffff0001/1" )
shahshreya9294c8d2015-01-21 15:54:16 -0800379 if ptpIntentResult == main.TRUE:
380 main.ONOS3.intents( jsonFormat=False )
kelvin-onlab8a832582015-01-16 17:06:11 -0800381 main.log.info( "Point to point intent install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800382
kelvin-onlab8a832582015-01-16 17:06:11 -0800383 time.sleep( 10 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800384 flowHandle = main.ONOS3.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -0800385 main.log.info( "flows :" + flowHandle )
shahshreyae6c7cf42014-11-26 16:39:01 -0800386
387 # Sleep for 30 seconds to provide time for the intent state to change
kelvin-onlab8a832582015-01-16 17:06:11 -0800388 time.sleep( 30 )
shahshreya9294c8d2015-01-21 15:54:16 -0800389 intentHandle = main.ONOS3.intents( jsonFormat=False )
kelvin-onlab8a832582015-01-16 17:06:11 -0800390 main.log.info( "intents :" + intentHandle )
391
shahshreya9294c8d2015-01-21 15:54:16 -0800392 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800393 count = 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800394 main.log.info( "\n\nh1 is Pinging h2" )
395 ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
shahshreya9294c8d2015-01-21 15:54:16 -0800396 # ping = main.LincOE2.pinghost()
kelvin-onlab8a832582015-01-16 17:06:11 -0800397 if ping == main.FALSE and count < 5:
398 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -0800399 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800400 main.log.info(
401 "Ping between h1 and h2 failed. Making attempt number " +
402 str( count ) +
403 " in 2 seconds" )
404 time.sleep( 2 )
405 elif ping == main.FALSE:
406 main.log.info( "All ping attempts between h1 and h2 have failed" )
shahshreya9294c8d2015-01-21 15:54:16 -0800407 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800408 elif ping == main.TRUE:
409 main.log.info( "Ping test between h1 and h2 passed!" )
shahshreya9294c8d2015-01-21 15:54:16 -0800410 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800411 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800412 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -0800413 PingResult = main.ERROR
kelvin-onlab8a832582015-01-16 17:06:11 -0800414
shahshreya9294c8d2015-01-21 15:54:16 -0800415 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800416 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800417 "Point intents for packet optical have not ben installed" +
418 " correctly. Cleaning up" )
shahshreya9294c8d2015-01-21 15:54:16 -0800419 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800420 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800421 "Point Intents for packet optical have been " +
422 "installed correctly" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800423
shahshreya9294c8d2015-01-21 15:54:16 -0800424 case23Result = PingResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800425 utilities.assert_equals(
426 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800427 actual=case23Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800428 onpass= "Point intents addition for packet optical and" +
429 "Pingall Test successful",
430 onfail= "Point intents addition for packet optical and" +
431 "Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800432
kelvin-onlab8a832582015-01-16 17:06:11 -0800433 def CASE24( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800434 import time
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800435 import json
kelvin-onlab8a832582015-01-16 17:06:11 -0800436 """
shahshreya9294c8d2015-01-21 15:54:16 -0800437 Test Rerouting of Packet Optical by bringing a port down
438 ( port 22 ) of a switch( switchID=1 ), so that link
439 ( between switch1 port22 - switch4-port30 ) is inactive
440 and do a ping test. If rerouting is successful,
441 ping should pass. also check the flows
kelvin-onlab8a832582015-01-16 17:06:11 -0800442 """
443 main.log.report(
444 "This testcase tests rerouting and pings mininet hosts" )
445 main.case( "Test rerouting and pings mininet hosts" )
446 main.step( "Bring a port down and verify the link state" )
shahshreya9294c8d2015-01-21 15:54:16 -0800447 main.LincOE1.portDown( swId="1", ptId="22" )
448 linksNonjson = main.ONOS3.links( jsonFormat=False )
449 main.log.info( "links = " + linksNonjson )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800450
451 links = main.ONOS3.links()
kelvin-onlab8a832582015-01-16 17:06:11 -0800452 main.log.info( "links = " + links )
453
shahshreya9294c8d2015-01-21 15:54:16 -0800454 linksResult = json.loads( links )
455 linksStateResult = main.FALSE
456 for item in linksResult:
kelvin-onlab8a832582015-01-16 17:06:11 -0800457 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
458 'src' ][ 'port' ] == "22":
459 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff04" and item[
460 'dst' ][ 'port' ] == "30":
shahshreya9294c8d2015-01-21 15:54:16 -0800461 linksState = item[ 'state' ]
462 if linksState == "INACTIVE":
kelvin-onlab8a832582015-01-16 17:06:11 -0800463 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800464 "Links state is inactive as expected due to one" +
465 " of the ports being down" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800466 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800467 "Links state is inactive as expected due to one" +
468 " of the ports being down" )
shahshreya9294c8d2015-01-21 15:54:16 -0800469 linksStateResult = main.TRUE
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800470 break
471 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800472 main.log.info(
473 "Links state is not inactive as expected" )
474 main.log.report(
475 "Links state is not inactive as expected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800476 linksStateResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800477
shahshreya9294c8d2015-01-21 15:54:16 -0800478 print "links_state_result = ", linksStateResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800479 time.sleep( 10 )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800480 flowHandle = main.ONOS3.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -0800481 main.log.info( "flows :" + flowHandle )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800482
kelvin-onlab8a832582015-01-16 17:06:11 -0800483 main.step( "Verify Rerouting by a ping test" )
shahshreya9294c8d2015-01-21 15:54:16 -0800484 PingResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800485 count = 1
486 main.log.info( "\n\nh1 is Pinging h2" )
487 ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
shahshreya9294c8d2015-01-21 15:54:16 -0800488 # ping = main.LincOE2.pinghost()
kelvin-onlab8a832582015-01-16 17:06:11 -0800489 if ping == main.FALSE and count < 5:
490 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -0800491 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800492 main.log.info(
493 "Ping between h1 and h2 failed. Making attempt number " +
494 str( count ) +
495 " in 2 seconds" )
496 time.sleep( 2 )
497 elif ping == main.FALSE:
498 main.log.info( "All ping attempts between h1 and h2 have failed" )
shahshreya9294c8d2015-01-21 15:54:16 -0800499 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800500 elif ping == main.TRUE:
501 main.log.info( "Ping test between h1 and h2 passed!" )
shahshreya9294c8d2015-01-21 15:54:16 -0800502 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800503 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800504 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -0800505 PingResult = main.ERROR
shahshreyae6c7cf42014-11-26 16:39:01 -0800506
shahshreya9294c8d2015-01-21 15:54:16 -0800507 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800508 main.log.report( "Ping test successful " )
shahshreya9294c8d2015-01-21 15:54:16 -0800509 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800510 main.log.report( "Ping test failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800511
shahshreya9294c8d2015-01-21 15:54:16 -0800512 case24Result = PingResult and linksStateResult
513 utilities.assert_equals( expect=main.TRUE, actual=case24Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800514 onpass="Packet optical rerouting successful",
515 onfail="Packet optical rerouting failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800516
kelvin-onlab8a832582015-01-16 17:06:11 -0800517 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800518 import re
519 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800520 main.log.report( "This testcase is testing the assignment of" +
521 " all the switches to all the controllers and" +
522 " discovering the hists in reactive mode" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800523 main.log.report( "__________________________________" )
524 main.case( "Pingall Test" )
525 main.step( "Assigning switches to controllers" )
shahshreya9294c8d2015-01-21 15:54:16 -0800526 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
527 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
kelvin-onlab8a832582015-01-16 17:06:11 -0800528 for i in range( 1, 29 ):
529 if i == 1:
shahshreya9294c8d2015-01-21 15:54:16 -0800530 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800531 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800532 ip1=ONOS1Ip,
533 port1=ONOS1Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800534 elif i >= 2 and i < 5:
shahshreya9294c8d2015-01-21 15:54:16 -0800535 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800536 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800537 ip1=ONOS1Ip,
538 port1=ONOS1Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800539 elif i >= 5 and i < 8:
shahshreya9294c8d2015-01-21 15:54:16 -0800540 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800541 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800542 ip1=ONOS1Ip,
543 port1=ONOS1Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800544 elif i >= 8 and i < 18:
shahshreya9294c8d2015-01-21 15:54:16 -0800545 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800546 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800547 ip1=ONOS1Ip,
548 port1=ONOS1Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800549 elif i >= 18 and i < 28:
shahshreya9294c8d2015-01-21 15:54:16 -0800550 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800551 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800552 ip1=ONOS1Ip,
553 port1=ONOS1Port )
shahshreya4e13a062014-11-11 16:46:18 -0800554 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800555 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800556 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800557 ip1=ONOS1Ip,
558 port1=ONOS1Port )
559 SwitchMastership = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800560 for i in range( 1, 29 ):
561 if i == 1:
shahshreya9294c8d2015-01-21 15:54:16 -0800562 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800563 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800564 if re.search( "tcp:" + ONOS1Ip, response ):
565 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800566 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800567 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800568 elif i >= 2 and i < 5:
shahshreya9294c8d2015-01-21 15:54:16 -0800569 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800570 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800571 if re.search( "tcp:" + ONOS1Ip, response ):
572 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800573 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800574 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800575 elif i >= 5 and i < 8:
shahshreya9294c8d2015-01-21 15:54:16 -0800576 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800577 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800578 if re.search( "tcp:" + ONOS1Ip, response ):
579 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800580 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800581 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800582 elif i >= 8 and i < 18:
shahshreya9294c8d2015-01-21 15:54:16 -0800583 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800584 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800585 if re.search( "tcp:" + ONOS1Ip, response ):
586 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800587 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800588 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800589 elif i >= 18 and i < 28:
shahshreya9294c8d2015-01-21 15:54:16 -0800590 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800591 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800592 if re.search( "tcp:" + ONOS1Ip, response ):
593 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800594 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800595 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800596 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800597 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800598 print( "Response is" + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800599 if re.search( "tcp:" + ONOS1Ip, response ):
600 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800601 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800602 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800603
shahshreya9294c8d2015-01-21 15:54:16 -0800604 if SwitchMastership == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800605 main.log.report( "Controller assignmnet successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800606 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800607 main.log.report( "Controller assignmnet failed" )
608 utilities.assert_equals(
609 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800610 actual=SwitchMastership,
kelvin-onlab8a832582015-01-16 17:06:11 -0800611 onpass="MasterControllers assigned correctly" )
612 """
613 for i in range ( 1,29 ):
shahshreya9294c8d2015-01-21 15:54:16 -0800614 main.Mininet1.assignSwController( sw=str( i ),count=5,
615 ip1=ONOS1Ip,port1=ONOS1Port,
616 ip2=ONOS2Ip,port2=ONOS2Port,
617 ip3=ONOS3Ip,port3=ONOS3Port,
618 ip4=ONOS4Ip,port4=ONOS4Port,
619 ip5=ONOS5Ip,port5=ONOS5Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800620 """
621 # REACTIVE FWD test
shahshreya4e13a062014-11-11 16:46:18 -0800622
kelvin-onlab8a832582015-01-16 17:06:11 -0800623 main.step( "Get list of hosts from Mininet" )
shahshreya9294c8d2015-01-21 15:54:16 -0800624 hostList = main.Mininet1.getHosts()
625 main.log.info( hostList )
shahshreya4e13a062014-11-11 16:46:18 -0800626
kelvin-onlab8a832582015-01-16 17:06:11 -0800627 main.step( "Get host list in ONOS format" )
shahshreya9294c8d2015-01-21 15:54:16 -0800628 hostOnosList = main.ONOS2.getHostsId( hostList )
629 main.log.info( hostOnosList )
kelvin-onlab8a832582015-01-16 17:06:11 -0800630 # time.sleep( 5 )
631
632 main.step( "Pingall" )
shahshreya9294c8d2015-01-21 15:54:16 -0800633 pingResult = main.FALSE
634 while pingResult == main.FALSE:
shahshreya4e13a062014-11-11 16:46:18 -0800635 time1 = time.time()
shahshreya9294c8d2015-01-21 15:54:16 -0800636 pingResult = main.Mininet1.pingall()
shahshreya4e13a062014-11-11 16:46:18 -0800637 time2 = time.time()
kelvin-onlab8a832582015-01-16 17:06:11 -0800638 print "Time for pingall: %2f seconds" % ( time2 - time1 )
639
shahshreya9294c8d2015-01-21 15:54:16 -0800640 # Start onos cli again because u might have dropped out of
641 # onos prompt to the shell prompt
kelvin-onlab8a832582015-01-16 17:06:11 -0800642 # if there was no activity
shahshreya9294c8d2015-01-21 15:54:16 -0800643 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800644
shahshreya9294c8d2015-01-21 15:54:16 -0800645 case4Result = SwitchMastership and pingResult
646 if pingResult == main.TRUE:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800647 main.log.report( "Pingall Test in reactive mode to" +
648 " discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800649 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800650 main.log.report( "Pingall Test in reactive mode to" +
651 " discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800652
kelvin-onlab8a832582015-01-16 17:06:11 -0800653 utilities.assert_equals(
654 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800655 actual=case4Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800656 onpass="Controller assignment and Pingall Test successful",
657 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800658
kelvin-onlab8a832582015-01-16 17:06:11 -0800659 def CASE10( self ):
660 main.log.report(
661 "This testcase uninstalls the reactive forwarding app" )
662 main.log.report( "__________________________________" )
663 main.case( "Uninstalling reactive forwarding app" )
664 # Unistall onos-app-fwd app to disable reactive forwarding
shahshreya9294c8d2015-01-21 15:54:16 -0800665 appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800666 main.log.info( "onos-app-fwd uninstalled" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800667
shahshreya9294c8d2015-01-21 15:54:16 -0800668 # After reactive forwarding is disabled, the reactive flows on
669 # switches timeout in 10-15s
kelvin-onlab8a832582015-01-16 17:06:11 -0800670 # So sleep for 15s
671 time.sleep( 15 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800672
673 flows = main.ONOS2.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -0800674 main.log.info( flows )
shahshreyae6c7cf42014-11-26 16:39:01 -0800675
shahshreya9294c8d2015-01-21 15:54:16 -0800676 case10Result = appUninstallResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800677 utilities.assert_equals(
678 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800679 actual=case10Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800680 onpass="Reactive forwarding app uninstallation successful",
681 onfail="Reactive forwarding app uninstallation failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800682
kelvin-onlab8a832582015-01-16 17:06:11 -0800683 def CASE6( self ):
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800684 main.log.report( "This testcase is testing the addition of" +
685 " host intents and then does pingall" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800686 main.log.report( "__________________________________" )
687 main.case( "Obtaining host id's" )
688 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800689 hosts = main.ONOS2.hosts()
shahshreya9294c8d2015-01-21 15:54:16 -0800690 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800691
kelvin-onlab8a832582015-01-16 17:06:11 -0800692 main.step( "Get all devices id" )
shahshreya9294c8d2015-01-21 15:54:16 -0800693 devicesIdList = main.ONOS2.getAllDevicesId()
694 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -0800695
shahshreya9294c8d2015-01-21 15:54:16 -0800696 # ONOS displays the hosts in hex format unlike mininet which does
697 # in decimal format
kelvin-onlab8a832582015-01-16 17:06:11 -0800698 # So take care while adding intents
699 """
shahshreya9294c8d2015-01-21 15:54:16 -0800700 main.step( "Add host-to-host intents for mininet hosts h8 and h18 or
701 ONOS hosts h8 and h12" )
702 hthIntentResult = main.ONOS2.addHostIntent(
703 "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
704 hthIntentResult = main.ONOS2.addHostIntent(
705 "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
706 hthIntentResult = main.ONOS2.addHostIntent(
707 "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
708 hthIntentResult = main.ONOS2.addHostIntent(
709 "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
710 hthIntentResult = main.ONOS2.addHostIntent(
711 "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
712 hthIntentResult = main.ONOS2.addHostIntent(
713 "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
714 hthIntentResult = main.ONOS2.addHostIntent(
715 "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
716 hthIntentResult = main.ONOS2.addHostIntent(
717 "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
718 hthIntentResult = main.ONOS2.addHostIntent(
719 "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
720 hthIntentResult = main.ONOS2.addHostIntent(
721 "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
722 print "______________________________________________________"
kelvin-onlab8a832582015-01-16 17:06:11 -0800723 """
724 for i in range( 8, 18 ):
725 main.log.info(
shahshreya9294c8d2015-01-21 15:54:16 -0800726 "Adding host intent between h" + str( i ) +
727 " and h" + str( i + 10 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800728 host1 = "00:00:00:00:00:" + \
729 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
730 host2 = "00:00:00:00:00:" + \
731 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
732 # NOTE: get host can return None
733 # TODO: handle this
shahshreya9294c8d2015-01-21 15:54:16 -0800734 host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
735 host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
736 main.ONOS2.addHostIntent( host1Id, host2Id )
kelvin-onlab8a832582015-01-16 17:06:11 -0800737
738 time.sleep( 10 )
shahshreya9294c8d2015-01-21 15:54:16 -0800739 hIntents = main.ONOS2.intents( jsonFormat=False )
740 main.log.info( "intents:" + hIntents )
741 main.ONOS2.flows()
shahshreya4e13a062014-11-11 16:46:18 -0800742
743 count = 1
744 i = 8
shahshreya9294c8d2015-01-21 15:54:16 -0800745 PingResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800746 # while i<10:
747 while i < 18:
748 main.log.info(
749 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
750 ping = main.Mininet1.pingHost(
751 src="h" + str( i ), target="h" + str( i + 10 ) )
752 if ping == main.FALSE and count < 5:
753 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -0800754 # i = 8
755 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800756 main.log.report( "Ping between h" +
757 str( i ) +
758 " and h" +
759 str( i +
760 10 ) +
761 " failed. Making attempt number " +
762 str( count ) +
763 " in 2 seconds" )
764 time.sleep( 2 )
765 elif ping == main.FALSE:
766 main.log.report( "All ping attempts between h" +
767 str( i ) +
768 " and h" +
769 str( i +
770 10 ) +
771 "have failed" )
772 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -0800773 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800774 elif ping == main.TRUE:
775 main.log.info( "Ping test between h" +
776 str( i ) +
777 " and h" +
778 str( i +
779 10 ) +
780 "passed!" )
781 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -0800782 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800783 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800784 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -0800785 PingResult = main.ERROR
786 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800787 main.log.report(
shahshreya9294c8d2015-01-21 15:54:16 -0800788 "Ping all test after Host intent addition failed.Cleaning up" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800789 # main.cleanup()
790 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -0800791 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800792 main.log.report(
793 "Ping all test after Host intent addition successful" )
794
shahshreya9294c8d2015-01-21 15:54:16 -0800795 case6Result = PingResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800796 utilities.assert_equals(
797 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800798 actual=case6Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800799 onpass="Pingall Test after Host intents addition successful",
800 onfail="Pingall Test after Host intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800801
kelvin-onlab8a832582015-01-16 17:06:11 -0800802 def CASE5( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800803 import json
kelvin-onlab8a832582015-01-16 17:06:11 -0800804 # assumes that sts is already in you PYTHONPATH
805 from sts.topology.teston_topology import TestONTopology
shahshreya9294c8d2015-01-21 15:54:16 -0800806 # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800807 main.log.report( "This testcase is testing if all ONOS nodes" +
808 " are in topology sync with mininet" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800809 main.log.report( "__________________________________" )
810 main.case( "Comparing Mininet topology with the topology of ONOS" )
811 main.step( "Start continuous pings" )
812 main.Mininet2.pingLong(
813 src=main.params[ 'PING' ][ 'source1' ],
814 target=main.params[ 'PING' ][ 'target1' ],
815 pingTime=500 )
816 main.Mininet2.pingLong(
817 src=main.params[ 'PING' ][ 'source2' ],
818 target=main.params[ 'PING' ][ 'target2' ],
819 pingTime=500 )
820 main.Mininet2.pingLong(
821 src=main.params[ 'PING' ][ 'source3' ],
822 target=main.params[ 'PING' ][ 'target3' ],
823 pingTime=500 )
824 main.Mininet2.pingLong(
825 src=main.params[ 'PING' ][ 'source4' ],
826 target=main.params[ 'PING' ][ 'target4' ],
827 pingTime=500 )
828 main.Mininet2.pingLong(
829 src=main.params[ 'PING' ][ 'source5' ],
830 target=main.params[ 'PING' ][ 'target5' ],
831 pingTime=500 )
832 main.Mininet2.pingLong(
833 src=main.params[ 'PING' ][ 'source6' ],
834 target=main.params[ 'PING' ][ 'target6' ],
835 pingTime=500 )
836 main.Mininet2.pingLong(
837 src=main.params[ 'PING' ][ 'source7' ],
838 target=main.params[ 'PING' ][ 'target7' ],
839 pingTime=500 )
840 main.Mininet2.pingLong(
841 src=main.params[ 'PING' ][ 'source8' ],
842 target=main.params[ 'PING' ][ 'target8' ],
843 pingTime=500 )
844 main.Mininet2.pingLong(
845 src=main.params[ 'PING' ][ 'source9' ],
846 target=main.params[ 'PING' ][ 'target9' ],
847 pingTime=500 )
848 main.Mininet2.pingLong(
849 src=main.params[ 'PING' ][ 'source10' ],
850 target=main.params[ 'PING' ][ 'target10' ],
851 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -0800852
kelvin-onlab8a832582015-01-16 17:06:11 -0800853 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800854 global ctrls
855 ctrls = []
856 count = 1
857 while True:
858 temp = ()
kelvin-onlab8a832582015-01-16 17:06:11 -0800859 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
860 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
861 temp = temp + ( "ONOS" + str( count ), )
862 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
863 temp = temp + \
864 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
865 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800866 count = count + 1
867 else:
868 break
869 global MNTopo
kelvin-onlab8a832582015-01-16 17:06:11 -0800870 Topo = TestONTopology(
871 main.Mininet1,
872 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800873 MNTopo = Topo
874
shahshreya9294c8d2015-01-21 15:54:16 -0800875 TopologyCheck = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800876 main.step( "Compare ONOS Topology to MN Topology" )
shahshreya9294c8d2015-01-21 15:54:16 -0800877 devicesJson = main.ONOS2.devices()
878 linksJson = main.ONOS2.links()
879 # portsJson = main.ONOS2.ports()
kelvin-onlab8a832582015-01-16 17:06:11 -0800880
shahshreya9294c8d2015-01-21 15:54:16 -0800881 result1 = main.Mininet1.compareSwitches(
kelvin-onlab8a832582015-01-16 17:06:11 -0800882 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -0800883 json.loads( devicesJson ) )
884 result2 = main.Mininet1.compareLinks(
kelvin-onlab8a832582015-01-16 17:06:11 -0800885 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -0800886 json.loads( linksJson ) )
887 # result3 = main.Mininet1.comparePorts(
888 # MNTopo, json.loads( portsJson ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800889
shahshreya9294c8d2015-01-21 15:54:16 -0800890 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -0800891 result = result1 and result2
kelvin-onlab8a832582015-01-16 17:06:11 -0800892
shahshreya4e13a062014-11-11 16:46:18 -0800893 print "***********************"
894 if result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800895 main.log.report( "ONOS" + " Topology matches MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -0800896 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800897 main.log.report( "ONOS" + " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -0800898
kelvin-onlab8a832582015-01-16 17:06:11 -0800899 utilities.assert_equals(
900 expect=main.TRUE,
901 actual=result,
902 onpass="ONOS" +
903 " Topology matches MN Topology",
904 onfail="ONOS" +
905 " Topology does not match MN Topology" )
906
shahshreya9294c8d2015-01-21 15:54:16 -0800907 TopologyCheck = TopologyCheck and result
kelvin-onlab8a832582015-01-16 17:06:11 -0800908 utilities.assert_equals(
909 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800910 actual=TopologyCheck,
kelvin-onlab8a832582015-01-16 17:06:11 -0800911 onpass="Topology checks passed",
912 onfail="Topology checks failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800913
kelvin-onlab8a832582015-01-16 17:06:11 -0800914 def CASE7( self, main ):
shahshreya9294c8d2015-01-21 15:54:16 -0800915 from sts.topology.teston_topology import TestONTopology
shahshreya4e13a062014-11-11 16:46:18 -0800916
shahshreya9294c8d2015-01-21 15:54:16 -0800917 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800918
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800919 main.log.report( "This testscase is killing a link to ensure that" +
920 " link discovery is consistent" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800921 main.log.report( "__________________________________" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800922 main.log.report( "Killing a link to ensure that link discovery" +
923 " is consistent" )
924 main.case( "Killing a link to Ensure that Link Discovery" +
925 "is Working Properly" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800926 """
927 main.step( "Start continuous pings" )
928
929 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
shahshreya9294c8d2015-01-21 15:54:16 -0800930 target=main.params[ 'PING' ][ 'target1' ],
931 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800932 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
shahshreya9294c8d2015-01-21 15:54:16 -0800933 target=main.params[ 'PING' ][ 'target2' ],
934 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800935 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
shahshreya9294c8d2015-01-21 15:54:16 -0800936 target=main.params[ 'PING' ][ 'target3' ],
937 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800938 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
shahshreya9294c8d2015-01-21 15:54:16 -0800939 target=main.params[ 'PING' ][ 'target4' ],
940 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800941 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
shahshreya9294c8d2015-01-21 15:54:16 -0800942 target=main.params[ 'PING' ][ 'target5' ],
943 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800944 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
shahshreya9294c8d2015-01-21 15:54:16 -0800945 target=main.params[ 'PING' ][ 'target6' ],
946 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800947 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
shahshreya9294c8d2015-01-21 15:54:16 -0800948 target=main.params[ 'PING' ][ 'target7' ],
949 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800950 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
shahshreya9294c8d2015-01-21 15:54:16 -0800951 target=main.params[ 'PING' ][ 'target8' ],
952 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800953 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
shahshreya9294c8d2015-01-21 15:54:16 -0800954 target=main.params[ 'PING' ][ 'target9' ],
955 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800956 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
shahshreya9294c8d2015-01-21 15:54:16 -0800957 target=main.params[ 'PING' ][ 'target10' ],
958 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800959 """
960 main.step( "Determine the current number of switches and links" )
shahshreya9294c8d2015-01-21 15:54:16 -0800961 topologyOutput = main.ONOS2.topology()
962 topologyResult = main.ONOS1.getTopology( topologyOutput )
963 activeSwitches = topologyResult[ 'devices' ]
964 links = topologyResult[ 'links' ]
kelvin-onlab8a832582015-01-16 17:06:11 -0800965 print "activeSwitches = ", type( activeSwitches )
966 print "links = ", type( links )
967 main.log.info(
968 "Currently there are %s switches and %s links" %
969 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -0800970
kelvin-onlab8a832582015-01-16 17:06:11 -0800971 main.step( "Kill Link between s3 and s28" )
972 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
shahshreya9294c8d2015-01-21 15:54:16 -0800973 time.sleep( linkSleep )
974 topologyOutput = main.ONOS2.topology()
975 LinkDown = main.ONOS1.checkStatus(
976 topologyOutput, activeSwitches, str(
kelvin-onlab8a832582015-01-16 17:06:11 -0800977 int( links ) - 2 ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800978 if LinkDown == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800979 main.log.report( "Link Down discovered properly" )
980 utilities.assert_equals(
981 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800982 actual=LinkDown,
kelvin-onlab8a832582015-01-16 17:06:11 -0800983 onpass="Link Down discovered properly",
984 onfail="Link down was not discovered in " +
shahshreya9294c8d2015-01-21 15:54:16 -0800985 str( linkSleep ) +
kelvin-onlab8a832582015-01-16 17:06:11 -0800986 " seconds" )
987
988 # Check ping result here..add code for it
989
990 main.step( "Bring link between s3 and s28 back up" )
shahshreya9294c8d2015-01-21 15:54:16 -0800991 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
992 time.sleep( linkSleep )
993 topologyOutput = main.ONOS2.topology()
994 LinkUp = main.ONOS1.checkStatus(
995 topologyOutput,
kelvin-onlab8a832582015-01-16 17:06:11 -0800996 activeSwitches,
997 str( links ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800998 if LinkUp == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800999 main.log.report( "Link up discovered properly" )
1000 utilities.assert_equals(
1001 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001002 actual=LinkUp,
kelvin-onlab8a832582015-01-16 17:06:11 -08001003 onpass="Link up discovered properly",
1004 onfail="Link up was not discovered in " +
shahshreya9294c8d2015-01-21 15:54:16 -08001005 str( linkSleep ) +
kelvin-onlab8a832582015-01-16 17:06:11 -08001006 " seconds" )
1007
1008 # NOTE Check ping result here..add code for it
1009
1010 main.step( "Compare ONOS Topology to MN Topology" )
1011 Topo = TestONTopology(
1012 main.Mininet1,
1013 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -08001014 MNTopo = Topo
shahshreya9294c8d2015-01-21 15:54:16 -08001015 TopologyCheck = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001016
shahshreya9294c8d2015-01-21 15:54:16 -08001017 devicesJson = main.ONOS2.devices()
1018 linksJson = main.ONOS2.links()
1019 portsJson = main.ONOS2.ports()
kelvin-onlab8a832582015-01-16 17:06:11 -08001020
shahshreya9294c8d2015-01-21 15:54:16 -08001021 result1 = main.Mininet1.compareSwitches(
kelvin-onlab8a832582015-01-16 17:06:11 -08001022 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001023 json.loads( devicesJson ) )
1024 result2 = main.Mininet1.compareLinks(
kelvin-onlab8a832582015-01-16 17:06:11 -08001025 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001026 json.loads( linksJson ) )
1027 # result3 = main.Mininet1.comparePorts(
1028 # MNTopo, json.loads( portsJson ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001029
shahshreya9294c8d2015-01-21 15:54:16 -08001030 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001031 result = result1 and result2
1032 print "***********************"
kelvin-onlab8a832582015-01-16 17:06:11 -08001033
shahshreya4e13a062014-11-11 16:46:18 -08001034 if result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001035 main.log.report( "ONOS" + " Topology matches MN Topology" )
1036 utilities.assert_equals(
1037 expect=main.TRUE,
1038 actual=result,
1039 onpass="ONOS" +
1040 " Topology matches MN Topology",
1041 onfail="ONOS" +
1042 " Topology does not match MN Topology" )
1043
shahshreya9294c8d2015-01-21 15:54:16 -08001044 TopologyCheck = TopologyCheck and result
kelvin-onlab8a832582015-01-16 17:06:11 -08001045 utilities.assert_equals(
1046 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001047 actual=TopologyCheck,
kelvin-onlab8a832582015-01-16 17:06:11 -08001048 onpass="Topology checks passed",
1049 onfail="Topology checks failed" )
1050
shahshreya9294c8d2015-01-21 15:54:16 -08001051 result = LinkDown and LinkUp and TopologyCheck
kelvin-onlab8a832582015-01-16 17:06:11 -08001052 utilities.assert_equals( expect=main.TRUE, actual=result,
1053 onpass="Link failure is discovered correctly",
1054 onfail="Link Discovery failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001055
kelvin-onlab8a832582015-01-16 17:06:11 -08001056 def CASE8( self ):
1057 """
shahshreya4e13a062014-11-11 16:46:18 -08001058 Host intents removal
kelvin-onlab8a832582015-01-16 17:06:11 -08001059 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001060 main.log.report( "This testcase removes any previously added intents" +
1061 " before adding the same intents or point intents" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001062 main.log.report( "__________________________________" )
1063 main.log.info( "Host intents removal" )
1064 main.case( "Removing host intents" )
1065 main.step( "Obtain the intent id's" )
shahshreya9294c8d2015-01-21 15:54:16 -08001066 intentResult = main.ONOS2.intents( jsonFormat=False )
1067 main.log.info( "intent_result = " + intentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001068
shahshreya9294c8d2015-01-21 15:54:16 -08001069 intentLinewise = intentResult.split( "\n" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001070 intentList = []
shahshreya9294c8d2015-01-21 15:54:16 -08001071 for line in intentLinewise:
kelvin-onlab8a832582015-01-16 17:06:11 -08001072 if line.startswith( "id=" ):
1073 intentList.append( line )
1074
shahshreyae6c7cf42014-11-26 16:39:01 -08001075 intentids = []
1076 for line in intentList:
kelvin-onlab8a832582015-01-16 17:06:11 -08001077 intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
shahshreya4e13a062014-11-11 16:46:18 -08001078 for id in intentids:
1079 print "id = ", id
kelvin-onlab8a832582015-01-16 17:06:11 -08001080
1081 main.step(
1082 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -08001083 for id in intentids:
shahshreya9294c8d2015-01-21 15:54:16 -08001084 main.ONOS2.removeIntent( intentId=id )
kelvin-onlab8a832582015-01-16 17:06:11 -08001085
shahshreya9294c8d2015-01-21 15:54:16 -08001086 intentResult = main.ONOS2.intents( jsonFormat=False )
1087 main.log.info( "intent_result = " + intentResult )
shahshreyae6c7cf42014-11-26 16:39:01 -08001088
shahshreya9294c8d2015-01-21 15:54:16 -08001089 case8Result = main.TRUE
1090 if case8Result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001091 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001092 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001093 main.log.report( "Intent removal failed" )
1094
shahshreya9294c8d2015-01-21 15:54:16 -08001095 PingResult = main.TRUE
1096 if case8Result == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001097 i = 8
kelvin-onlab8a832582015-01-16 17:06:11 -08001098 while i < 18:
1099 main.log.info(
1100 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1101 ping = main.Mininet1.pingHost(
1102 src="h" + str( i ), target="h" + str( i + 10 ) )
1103 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001104 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -08001105 PingResult = PingResult and main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001106 elif ping == main.FALSE:
1107 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001108 PingResult = PingResult and main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -08001109 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001110 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -08001111 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001112
kelvin-onlab8a832582015-01-16 17:06:11 -08001113 # Note: If the ping result failed, that means the intents have been
1114 # withdrawn correctly.
shahshreya9294c8d2015-01-21 15:54:16 -08001115 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001116 main.log.report( "Host intents have not been withdrawn correctly" )
1117 # main.cleanup()
1118 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -08001119 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001120 main.log.report( "Host intents have been withdrawn correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001121
shahshreya9294c8d2015-01-21 15:54:16 -08001122 case8Result = case8Result and PingResult
shahshreyae6c7cf42014-11-26 16:39:01 -08001123
shahshreya9294c8d2015-01-21 15:54:16 -08001124 if case8Result == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001125 main.log.report( "Intent removal successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001126 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001127 main.log.report( "Intent removal failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001128
shahshreya9294c8d2015-01-21 15:54:16 -08001129 utilities.assert_equals( expect=main.FALSE, actual=case8Result,
1130 onpass="Intent removal test passed",
1131 onfail="Intent removal test failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001132
kelvin-onlab8a832582015-01-16 17:06:11 -08001133 def CASE9( self ):
1134 main.log.report(
1135 "This testcase adds point intents and then does pingall" )
1136 main.log.report( "__________________________________" )
1137 main.log.info( "Adding point intents" )
1138 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001139 '''Adding bidirectional point for mn hosts
1140 ( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22,
1141 h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )''' )
1142
1143 main.step( "Add point intents for mn hosts h8 and h18 or" +
1144 "ONOS hosts h8 and h12" )
1145 # main.step(var1)
shahshreya9294c8d2015-01-21 15:54:16 -08001146 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001147 "of:0000000000003008/1",
1148 "of:0000000000006018/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001149 if ptpIntentResult == main.TRUE:
1150 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001151 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001152 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001153
shahshreya9294c8d2015-01-21 15:54:16 -08001154 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001155 "of:0000000000006018/1",
1156 "of:0000000000003008/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001157 if ptpIntentResult == main.TRUE:
1158 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001159 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001160 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001161
shahshreya9294c8d2015-01-21 15:54:16 -08001162 var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
1163 main.step(var2)
1164 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001165 "of:0000000000003009/1",
1166 "of:0000000000006019/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001167 if ptpIntentResult == main.TRUE:
1168 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001169 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001170 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001171
shahshreya9294c8d2015-01-21 15:54:16 -08001172 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001173 "of:0000000000006019/1",
1174 "of:0000000000003009/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001175 if ptpIntentResult == main.TRUE:
1176 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001177 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001178 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001179
shahshreya9294c8d2015-01-21 15:54:16 -08001180 var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
1181 main.step(var3)
1182 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001183 "of:0000000000003010/1",
1184 "of:0000000000006020/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001185 if ptpIntentResult == main.TRUE:
1186 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001187 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001188 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001189
shahshreya9294c8d2015-01-21 15:54:16 -08001190 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001191 "of:0000000000006020/1",
1192 "of:0000000000003010/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001193 if ptpIntentResult == main.TRUE:
1194 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001195 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001196 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001197
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001198 var4 = "Add point intents for mininet hosts h11 and h21 or" +\
1199 " ONOS hosts hB and h15"
shahshreya9294c8d2015-01-21 15:54:16 -08001200 main.case(var4)
1201 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001202 "of:0000000000003011/1",
1203 "of:0000000000006021/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001204 if ptpIntentResult == main.TRUE:
1205 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001206 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001207 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001208
shahshreya9294c8d2015-01-21 15:54:16 -08001209 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001210 "of:0000000000006021/1",
1211 "of:0000000000003011/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001212 if ptpIntentResult == main.TRUE:
1213 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001214 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001215 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001216
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001217 var5 = "Add point intents for mininet hosts h12 and h22 " +\
1218 "ONOS hosts hC and h16"
shahshreya9294c8d2015-01-21 15:54:16 -08001219 main.case(var5)
1220 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001221 "of:0000000000003012/1",
1222 "of:0000000000006022/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001223 if ptpIntentResult == main.TRUE:
1224 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001225 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001226 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001227
shahshreya9294c8d2015-01-21 15:54:16 -08001228 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001229 "of:0000000000006022/1",
1230 "of:0000000000003012/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001231 if ptpIntentResult == main.TRUE:
1232 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001233 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001234 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001235
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001236 var6 = "Add point intents for mininet hosts h13 and h23 or" +\
1237 " ONOS hosts hD and h17"
shahshreya9294c8d2015-01-21 15:54:16 -08001238 main.case(var6)
1239 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001240 "of:0000000000003013/1",
1241 "of:0000000000006023/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001242 if ptpIntentResult == main.TRUE:
1243 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001244 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001245 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001246
shahshreya9294c8d2015-01-21 15:54:16 -08001247 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001248 "of:0000000000006023/1",
1249 "of:0000000000003013/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001250 if ptpIntentResult == main.TRUE:
1251 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001252 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001253 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001254
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001255 var7 = "Add point intents for mininet hosts h14 and h24 or" +\
1256 " ONOS hosts hE and h18"
shahshreya9294c8d2015-01-21 15:54:16 -08001257 main.case(var7)
1258 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001259 "of:0000000000003014/1",
1260 "of:0000000000006024/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001261 if ptpIntentResult == main.TRUE:
1262 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001263 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001264 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001265
shahshreya9294c8d2015-01-21 15:54:16 -08001266 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001267 "of:0000000000006024/1",
1268 "of:0000000000003014/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001269 if ptpIntentResult == main.TRUE:
1270 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001271 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001272 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001273
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001274 var8 = "Add point intents for mininet hosts h15 and h25 or" +\
1275 " ONOS hosts hF and h19"
shahshreya9294c8d2015-01-21 15:54:16 -08001276 main.case(var8)
1277 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001278 "of:0000000000003015/1",
1279 "of:0000000000006025/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001280 if ptpIntentResult == main.TRUE:
1281 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001282 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001283 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001284
shahshreya9294c8d2015-01-21 15:54:16 -08001285 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001286 "of:0000000000006025/1",
1287 "of:0000000000003015/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001288 if ptpIntentResult == main.TRUE:
1289 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001290 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001291 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001292
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001293 var9 = "Add intents for mininet hosts h16 and h26 or" +\
1294 " ONOS hosts h10 and h1A"
shahshreya9294c8d2015-01-21 15:54:16 -08001295 main.case(var9)
1296 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001297 "of:0000000000003016/1",
1298 "of:0000000000006026/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001299 if ptpIntentResult == main.TRUE:
1300 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001301 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001302 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001303
shahshreya9294c8d2015-01-21 15:54:16 -08001304 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001305 "of:0000000000006026/1",
1306 "of:0000000000003016/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001307 if ptpIntentResult == main.TRUE:
1308 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001309 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001310 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001311
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001312 var10 = "Add point intents for mininet hosts h17 and h27 or" +\
1313 " ONOS hosts h11 and h1B"
shahshreya9294c8d2015-01-21 15:54:16 -08001314 main.case(var10)
1315 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001316 "of:0000000000003017/1",
1317 "of:0000000000006027/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001318 if ptpIntentResult == main.TRUE:
1319 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001320 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001321 main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001322
shahshreya9294c8d2015-01-21 15:54:16 -08001323 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001324 "of:0000000000006027/1",
1325 "of:0000000000003017/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001326 if ptpIntentResult == main.TRUE:
1327 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001328 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001329 main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001330
1331 print(
shahshreya9294c8d2015-01-21 15:54:16 -08001332 "___________________________________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001333
1334 flowHandle = main.ONOS2.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -08001335 # print "flowHandle = ", flowHandle
1336 main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001337
1338 count = 1
1339 i = 8
shahshreya9294c8d2015-01-21 15:54:16 -08001340 PingResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001341 while i < 18:
1342 main.log.info(
1343 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1344 ping = main.Mininet1.pingHost(
1345 src="h" + str( i ), target="h" + str( i + 10 ) )
1346 if ping == main.FALSE and count < 5:
1347 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001348 # i = 8
1349 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001350 main.log.report( "Ping between h" +
1351 str( i ) +
1352 " and h" +
1353 str( i +
1354 10 ) +
1355 " failed. Making attempt number " +
1356 str( count ) +
1357 " in 2 seconds" )
1358 time.sleep( 2 )
1359 elif ping == main.FALSE:
1360 main.log.report( "All ping attempts between h" +
1361 str( i ) +
1362 " and h" +
1363 str( i +
1364 10 ) +
1365 "have failed" )
1366 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -08001367 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001368 elif ping == main.TRUE:
1369 main.log.info( "Ping test between h" +
1370 str( i ) +
1371 " and h" +
1372 str( i +
1373 10 ) +
1374 "passed!" )
1375 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001376 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001377 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001378 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -08001379 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001380
shahshreya9294c8d2015-01-21 15:54:16 -08001381 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001382 main.log.report(
1383 "Point intents have not ben installed correctly. Cleaning up" )
1384 # main.cleanup()
1385 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -08001386 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001387 main.log.report( "Point Intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001388
shahshreya9294c8d2015-01-21 15:54:16 -08001389 case9Result = PingResult
kelvin-onlab8a832582015-01-16 17:06:11 -08001390 utilities.assert_equals(
1391 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001392 actual=case9Result,
kelvin-onlab8a832582015-01-16 17:06:11 -08001393 onpass="Point intents addition and Pingall Test successful",
1394 onfail="Point intents addition and Pingall Test NOT successful" )