blob: 44e78b7e2f51eb8771a99a2622e6e6aeb365b92c [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 ):
shahshreya82ecd282015-02-05 16:48:03 -080020 import time
kelvin-onlab8a832582015-01-16 17:06:11 -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
kelvin-onlab8a832582015-01-16 17:06:11 -080031 """
shahshreya9294c8d2015-01-21 15:54:16 -080032 cellName = main.params[ 'ENV' ][ 'cellName' ]
33 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreyae6c7cf42014-11-26 16:39:01 -080034
kelvin-onlab8a832582015-01-16 17:06:11 -080035 main.case( "Setting up test environment" )
36 main.log.report(
37 "This testcase is testing setting up test environment" )
38 main.log.report( "__________________________________" )
39
40 main.step( "Applying cell variable to environment" )
shahshreya9294c8d2015-01-21 15:54:16 -080041 cellResult = main.ONOSbench.setCell( cellName )
42 verifyResult = main.ONOSbench.verifyCell()
kelvin-onlab8a832582015-01-16 17:06:11 -080043
44 main.step( "Removing raft logs before a clen installation of ONOS" )
shahshreya9294c8d2015-01-21 15:54:16 -080045 main.ONOSbench.onosRemoveRaftLogs()
shahshreyae6c7cf42014-11-26 16:39:01 -080046
shahshreya82ecd282015-02-05 16:48:03 -080047 main.step( "Git checkout and get version" )
shahshreyab512cd02015-01-27 17:01:47 -080048 #main.ONOSbench.gitCheckout( "master" )
shahshreya9294c8d2015-01-21 15:54:16 -080049 gitPullResult = main.ONOSbench.gitPull()
shahshreya82ecd282015-02-05 16:48:03 -080050 main.log.info( "git_pull_result = " + str( gitPullResult ))
shahshreya9294c8d2015-01-21 15:54:16 -080051 main.ONOSbench.getVersion( report=True )
kelvin-onlab8a832582015-01-16 17:06:11 -080052
shahshreya9294c8d2015-01-21 15:54:16 -080053 if gitPullResult == 1:
kelvin-onlab8a832582015-01-16 17:06:11 -080054 main.step( "Using mvn clean & install" )
shahshreya9294c8d2015-01-21 15:54:16 -080055 main.ONOSbench.cleanInstall()
56 elif gitPullResult == 0:
kelvin-onlab8a832582015-01-16 17:06:11 -080057 main.log.report(
58 "Git Pull Failed, look into logs for detailed reason" )
shahshreyaa22f8f82014-12-08 16:59:21 -080059 main.cleanup()
kelvin-onlab8a832582015-01-16 17:06:11 -080060 main.exit()
61
62 main.step( "Creating ONOS package" )
shahshreya9294c8d2015-01-21 15:54:16 -080063 packageResult = main.ONOSbench.onosPackage()
shahshreya4e13a062014-11-11 16:46:18 -080064
kelvin-onlab8a832582015-01-16 17:06:11 -080065 main.step( "Installing ONOS package" )
shahshreya9294c8d2015-01-21 15:54:16 -080066 onosInstallResult = main.ONOSbench.onosInstall()
67 if onosInstallResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -080068 main.log.report( "Installing ONOS package successful" )
shahshreya4e13a062014-11-11 16:46:18 -080069 else:
kelvin-onlab8a832582015-01-16 17:06:11 -080070 main.log.report( "Installing ONOS package failed" )
shahshreya4e13a062014-11-11 16:46:18 -080071
shahshreya9294c8d2015-01-21 15:54:16 -080072 onos1Isup = main.ONOSbench.isup()
73 if onos1Isup == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -080074 main.log.report( "ONOS instance is up and ready" )
shahshreya4e13a062014-11-11 16:46:18 -080075 else:
kelvin-onlab8a832582015-01-16 17:06:11 -080076 main.log.report( "ONOS instance may not be up" )
shahshreya4e13a062014-11-11 16:46:18 -080077
kelvin-onlab8a832582015-01-16 17:06:11 -080078 main.step( "Starting ONOS service" )
shahshreya9294c8d2015-01-21 15:54:16 -080079 startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -080080
shahshreya9294c8d2015-01-21 15:54:16 -080081 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
shahshreya82ecd282015-02-05 16:48:03 -080082 main.step( "Starting Mininet CLI..." )
83
84 # Starting the mininet using the old way
85 main.step( "Starting Mininet ..." )
86 netIsUp = main.Mininet1.startNet()
87 if netIsUp:
88 main.log.info("Mininet CLI is up")
89
shahshreya9294c8d2015-01-21 15:54:16 -080090 case1Result = ( packageResult and
91 cellResult and verifyResult
92 and onosInstallResult and
93 onos1Isup and startResult )
94 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
kelvin-onlab8a832582015-01-16 17:06:11 -080095 onpass="Test startup successful",
96 onfail="Test startup NOT successful" )
97
98 def CASE2( self, main ):
99 """
shahshreyaa22f8f82014-12-08 16:59:21 -0800100 Switch Down
kelvin-onlab8a832582015-01-16 17:06:11 -0800101 """
102 # NOTE: You should probably run a topology check after this
103 import time
shahshreyaa22f8f82014-12-08 16:59:21 -0800104
kelvin-onlab8a832582015-01-16 17:06:11 -0800105 main.case( "Switch down discovery" )
106 main.log.report( "This testcase is testing a switch down discovery" )
107 main.log.report( "__________________________________" )
108
shahshreya9294c8d2015-01-21 15:54:16 -0800109 switchSleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
shahshreyaa22f8f82014-12-08 16:59:21 -0800110
111 description = "Killing a switch to ensure it is discovered correctly"
kelvin-onlab8a832582015-01-16 17:06:11 -0800112 main.log.report( description )
113 main.case( description )
shahshreyaa22f8f82014-12-08 16:59:21 -0800114
kelvin-onlab8a832582015-01-16 17:06:11 -0800115 # TODO: Make this switch parameterizable
116 main.step( "Kill s28 " )
117 main.log.report( "Deleting s28" )
118 # FIXME: use new dynamic topo functions
shahshreya9294c8d2015-01-21 15:54:16 -0800119 main.Mininet1.delSwitch( "s28" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800120 main.log.info(
121 "Waiting " +
shahshreya9294c8d2015-01-21 15:54:16 -0800122 str( switchSleep ) +
kelvin-onlab8a832582015-01-16 17:06:11 -0800123 " seconds for switch down to be discovered" )
shahshreya9294c8d2015-01-21 15:54:16 -0800124 time.sleep( switchSleep )
kelvin-onlab8a832582015-01-16 17:06:11 -0800125 # Peek at the deleted switch
shahshreya9294c8d2015-01-21 15:54:16 -0800126 device = main.ONOS2.getDevice( dpid="0028" )
shahshreyaa22f8f82014-12-08 16:59:21 -0800127 print "device = ", device
kelvin-onlab8a832582015-01-16 17:06:11 -0800128 if device[ u'available' ] == 'False':
shahshreya9294c8d2015-01-21 15:54:16 -0800129 case2Result = main.FALSE
shahshreyaa22f8f82014-12-08 16:59:21 -0800130 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800131 case2Result = main.TRUE
132 utilities.assert_equals( expect=main.TRUE, actual=case2Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800133 onpass="Switch down discovery successful",
134 onfail="Switch down discovery failed" )
shahshreyaa22f8f82014-12-08 16:59:21 -0800135
shahshreyab189da22015-02-25 10:18:26 -0800136 def CASE101( self, main ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800137 """
shahshreya4e13a062014-11-11 16:46:18 -0800138 Cleanup sequence:
shahshreya9294c8d2015-01-21 15:54:16 -0800139 onos-service <nodeIp> stop
shahshreya4e13a062014-11-11 16:46:18 -0800140 onos-uninstall
141
142 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800143
kelvin-onlab8a832582015-01-16 17:06:11 -0800144 """
shahshreya9294c8d2015-01-21 15:54:16 -0800145 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800146
kelvin-onlab8a832582015-01-16 17:06:11 -0800147 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800148
kelvin-onlab8a832582015-01-16 17:06:11 -0800149 main.step( "Testing ONOS kill function" )
shahshreya9294c8d2015-01-21 15:54:16 -0800150 killResult = main.ONOSbench.onosKill( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800151
kelvin-onlab8a832582015-01-16 17:06:11 -0800152 main.step( "Stopping ONOS service" )
shahshreya9294c8d2015-01-21 15:54:16 -0800153 stopResult = main.ONOSbench.onosStop( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800154
kelvin-onlab8a832582015-01-16 17:06:11 -0800155 main.step( "Uninstalling ONOS service" )
shahshreya9294c8d2015-01-21 15:54:16 -0800156 uninstallResult = main.ONOSbench.onosUninstall()
157
158 case11Result = killResult and stopResult and uninstallResult
159 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
160 onpass="Cleanup successful",
161 onfail="Cleanup failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800162
kelvin-onlab8a832582015-01-16 17:06:11 -0800163 def CASE3( self, main ):
164 """
shahshreya4e13a062014-11-11 16:46:18 -0800165 Test 'onos' command and its functionality in driver
kelvin-onlab8a832582015-01-16 17:06:11 -0800166 """
shahshreya9294c8d2015-01-21 15:54:16 -0800167 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800168
kelvin-onlab8a832582015-01-16 17:06:11 -0800169 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800170
kelvin-onlab8a832582015-01-16 17:06:11 -0800171 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800172 cmdstr1 = "system:name"
shahshreya9294c8d2015-01-21 15:54:16 -0800173 cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
174 main.log.info( "onos command returned: " + cmdResult1 )
shahshreya4e13a062014-11-11 16:46:18 -0800175
kelvin-onlab8a832582015-01-16 17:06:11 -0800176 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800177 cmdstr2 = "onos:topology"
shahshreya9294c8d2015-01-21 15:54:16 -0800178 cmdResult2 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
179 main.log.info( "onos command returned: " + cmdResult2 )
shahshreya4e13a062014-11-11 16:46:18 -0800180
kelvin-onlab8a832582015-01-16 17:06:11 -0800181 def CASE20( self ):
182 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800183 Exit from mininet cli
184 reinstall ONOS
kelvin-onlab8a832582015-01-16 17:06:11 -0800185 """
shahshreya9294c8d2015-01-21 15:54:16 -0800186 cellName = main.params[ 'ENV' ][ 'cellName' ]
187 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
kelvin-onlab8a832582015-01-16 17:06:11 -0800188
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800189 main.log.report( "This testcase exits the mininet cli and reinstalls" +
190 "ONOS to switch over to Packet Optical topology" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800191 main.log.report( "_____________________________________________" )
192 main.case( "Disconnecting mininet and restarting ONOS" )
193 main.step( "Disconnecting mininet and restarting ONOS" )
shahshreya9294c8d2015-01-21 15:54:16 -0800194 mininetDisconnect = main.Mininet1.disconnect()
shahshreya82ecd282015-02-05 16:48:03 -0800195 print "mininetDisconnect = ", mininetDisconnect
shahshreyae6c7cf42014-11-26 16:39:01 -0800196
kelvin-onlab8a832582015-01-16 17:06:11 -0800197 main.step( "Removing raft logs before a clen installation of ONOS" )
shahshreya9294c8d2015-01-21 15:54:16 -0800198 main.ONOSbench.onosRemoveRaftLogs()
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800199
kelvin-onlab8a832582015-01-16 17:06:11 -0800200 main.step( "Applying cell variable to environment" )
shahshreya9294c8d2015-01-21 15:54:16 -0800201 cellResult = main.ONOSbench.setCell( cellName )
202 verifyResult = main.ONOSbench.verifyCell()
shahshreyae6c7cf42014-11-26 16:39:01 -0800203
shahshreya9294c8d2015-01-21 15:54:16 -0800204 onosInstallResult = main.ONOSbench.onosInstall()
205 if onosInstallResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800206 main.log.report( "Installing ONOS package successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800207 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800208 main.log.report( "Installing ONOS package failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800209
shahshreya9294c8d2015-01-21 15:54:16 -0800210 onos1Isup = main.ONOSbench.isup()
211 if onos1Isup == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800212 main.log.report( "ONOS instance is up and ready" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800213 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800214 main.log.report( "ONOS instance may not be up" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800215
kelvin-onlab8a832582015-01-16 17:06:11 -0800216 main.step( "Starting ONOS service" )
shahshreya9294c8d2015-01-21 15:54:16 -0800217 startResult = main.ONOSbench.onosStart( ONOS1Ip )
kelvin-onlab8a832582015-01-16 17:06:11 -0800218
shahshreya9294c8d2015-01-21 15:54:16 -0800219 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
220 case20Result = mininetDisconnect and cellResult and verifyResult \
221 and onosInstallResult and onos1Isup and \
222 startResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800223 utilities.assert_equals(
224 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800225 actual=case20Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800226 onpass= "Exiting functionality mininet topology and reinstalling" +
227 " ONOS successful",
228 onfail= "Exiting functionality mininet topology and reinstalling" +
229 " ONOS failed" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800230
231 def CASE21( self, main ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800232 """
shahshreya9294c8d2015-01-21 15:54:16 -0800233 On ONOS bench, run this command:
234 ./~/ONOS/tools/test/bin/onos-topo-cfg
235 which starts the rest and copies the links
236 json file to the onos instance.
237 Note that in case of Packet Optical, the links are not learnt
238 from the topology, instead the links are learnt
shahshreyae6c7cf42014-11-26 16:39:01 -0800239 from the json config file
kelvin-onlab8a832582015-01-16 17:06:11 -0800240 """
241 main.log.report(
242 "This testcase starts the packet layer topology and REST" )
243 main.log.report( "_____________________________________________" )
244 main.case( "Starting LINC-OE and other components" )
245 main.step( "Starting LINC-OE and other components" )
shahshreya9294c8d2015-01-21 15:54:16 -0800246 startConsoleResult = main.LincOE1.startConsole()
247 opticalMnScript = main.LincOE2.runOpticalMnScript()
248 onosTopoCfgResult = main.ONOSbench.runOnosTopoCfg(
249 instanceName=main.params[ 'CTRL' ][ 'ip1' ],
250 jsonFile=main.params[ 'OPTICAL' ][ 'jsonfile' ] )
kelvin-onlab8a832582015-01-16 17:06:11 -0800251
shahshreya9294c8d2015-01-21 15:54:16 -0800252 print "start_console_result =", startConsoleResult
253 print "optical_mn_script = ", opticalMnScript
254 print "onos_topo_cfg_result =", onosTopoCfgResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800255
shahshreya9294c8d2015-01-21 15:54:16 -0800256 case21Result = startConsoleResult and opticalMnScript and \
257 onosTopoCfgResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800258 utilities.assert_equals(
259 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800260 actual=case21Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800261 onpass="Packet optical topology spawned successsfully",
262 onfail="Packet optical topology spawning failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800263
kelvin-onlab8a832582015-01-16 17:06:11 -0800264 def CASE22( self, main ):
265 """
shahshreya9294c8d2015-01-21 15:54:16 -0800266 Curretly we use, 4 linear switch optical topology and
267 2 packet layer mininet switches each with one host.
268 Therefore, the roadmCount variable = 4,
269 packetLayerSWCount variable = 2 and hostCount = 2
270 and this is hardcoded in the testcase. If the topology changes,
271 these hardcoded values need to be changed
kelvin-onlab8a832582015-01-16 17:06:11 -0800272 """
273 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800274 "This testcase compares the optical+packet topology against what" +
275 " is expected" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800276 main.case( "Topology comparision" )
277 main.step( "Topology comparision" )
shahshreya9294c8d2015-01-21 15:54:16 -0800278 main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
279 devicesResult = main.ONOS3.devices( jsonFormat=False )
shahshreyae6c7cf42014-11-26 16:39:01 -0800280
shahshreya9294c8d2015-01-21 15:54:16 -0800281 print "devices_result = ", devicesResult
282 devicesLinewise = devicesResult.split( "\n" )
shahshreya82ecd282015-02-05 16:48:03 -0800283 devicesLinewise = devicesLinewise[ 1: ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800284 roadmCount = 0
285 packetLayerSWCount = 0
shahshreya9294c8d2015-01-21 15:54:16 -0800286 for line in devicesLinewise:
kelvin-onlab8a832582015-01-16 17:06:11 -0800287 components = line.split( "," )
288 availability = components[ 1 ].split( "=" )[ 1 ]
289 type = components[ 3 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800290 if availability == 'true' and type == 'ROADM':
291 roadmCount += 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800292 elif availability == 'true' and type == 'SWITCH':
shahshreyae6c7cf42014-11-26 16:39:01 -0800293 packetLayerSWCount += 1
294 if roadmCount == 4:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800295 print "Number of Optical Switches = %d and is" % roadmCount +\
296 " correctly detected"
kelvin-onlab8a832582015-01-16 17:06:11 -0800297 main.log.info(
298 "Number of Optical Switches = " +
299 str( roadmCount ) +
300 " and is correctly detected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800301 opticalSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800302 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800303 print "Number of Optical Switches = %d and is wrong" % roadmCount
kelvin-onlab8a832582015-01-16 17:06:11 -0800304 main.log.info(
305 "Number of Optical Switches = " +
306 str( roadmCount ) +
307 " and is wrong" )
shahshreya9294c8d2015-01-21 15:54:16 -0800308 opticalSWResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800309
310 if packetLayerSWCount == 2:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800311 print "Number of Packet layer or mininet Switches = %d "\
312 % packetLayerSWCount + "and is correctly detected"
kelvin-onlab8a832582015-01-16 17:06:11 -0800313 main.log.info(
314 "Number of Packet layer or mininet Switches = " +
315 str( packetLayerSWCount ) +
316 " and is correctly detected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800317 packetSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800318 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800319 print "Number of Packet layer or mininet Switches = %d and"\
320 % packetLayerSWCount + " is wrong"
kelvin-onlab8a832582015-01-16 17:06:11 -0800321 main.log.info(
322 "Number of Packet layer or mininet Switches = " +
323 str( packetLayerSWCount ) +
324 " and is wrong" )
shahshreya9294c8d2015-01-21 15:54:16 -0800325 packetSWResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800326 print "_________________________________"
kelvin-onlab8a832582015-01-16 17:06:11 -0800327
shahshreya9294c8d2015-01-21 15:54:16 -0800328 linksResult = main.ONOS3.links( jsonFormat=False )
329 print "links_result = ", linksResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800330 print "_________________________________"
kelvin-onlab8a832582015-01-16 17:06:11 -0800331
shahshreya9294c8d2015-01-21 15:54:16 -0800332 # NOTE:Since only point intents are added, there is no
333 # requirement to discover the hosts
kelvin-onlab8a832582015-01-16 17:06:11 -0800334 # Therfore, the below portion of the code is commented.
335 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800336 #Discover hosts using pingall
shahshreya9294c8d2015-01-21 15:54:16 -0800337 pingallResult = main.LincOE2.pingall()
kelvin-onlab8a832582015-01-16 17:06:11 -0800338
shahshreya9294c8d2015-01-21 15:54:16 -0800339 hostsResult = main.ONOS3.hosts( jsonFormat=False )
340 main.log.info( "hosts_result = "+hostsResult )
kelvin-onlab8a832582015-01-16 17:06:11 -0800341 main.log.info( "_________________________________" )
shahshreya9294c8d2015-01-21 15:54:16 -0800342 hostsLinewise = hostsResult.split( "\n" )
343 hostsLinewise = hostsLinewise[ 1:-1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800344 hostCount = 0
shahshreya9294c8d2015-01-21 15:54:16 -0800345 for line in hostsLinewise:
kelvin-onlab8a832582015-01-16 17:06:11 -0800346 hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800347 hostCount +=1
348 if hostCount ==2:
349 print "Number of hosts = %d and is correctly detected" %hostCount
shahshreya9294c8d2015-01-21 15:54:16 -0800350 main.log.info( "Number of hosts = " + str( hostCount ) +" and \
351 is correctly detected" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800352 hostDiscovery = main.TRUE
353 else:
354 print "Number of hosts = %d and is wrong" %hostCount
shahshreya9294c8d2015-01-21 15:54:16 -0800355 main.log.info( "Number of hosts = " + str( hostCount ) +" and \
356 is wrong" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800357 hostDiscovery = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800358 """
shahshreya9294c8d2015-01-21 15:54:16 -0800359 case22Result = opticalSWResult and packetSWResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800360 utilities.assert_equals(
361 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800362 actual=case22Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800363 onpass="Packet optical topology discovery successful",
364 onfail="Packet optical topology discovery failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800365
kelvin-onlab8a832582015-01-16 17:06:11 -0800366 def CASE23( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800367 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800368 """
shahshreya9294c8d2015-01-21 15:54:16 -0800369 Add bidirectional point intents between 2 packet layer( mininet )
370 devices and
shahshreyae6c7cf42014-11-26 16:39:01 -0800371 ping mininet hosts
kelvin-onlab8a832582015-01-16 17:06:11 -0800372 """
373 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800374 "This testcase adds bidirectional point intents between 2 " +
375 "packet layer( mininet ) devices and ping mininet hosts" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800376 main.case( "Topology comparision" )
377 main.step( "Adding point intents" )
shahshreya9294c8d2015-01-21 15:54:16 -0800378 ptpIntentResult = main.ONOS3.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -0800379 "of:0000ffffffff0001/1",
380 "of:0000ffffffff0002/1" )
shahshreya9294c8d2015-01-21 15:54:16 -0800381 if ptpIntentResult == main.TRUE:
382 main.ONOS3.intents( jsonFormat=False )
kelvin-onlab8a832582015-01-16 17:06:11 -0800383 main.log.info( "Point to point intent install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800384
shahshreya9294c8d2015-01-21 15:54:16 -0800385 ptpIntentResult = main.ONOS3.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -0800386 "of:0000ffffffff0002/1",
387 "of:0000ffffffff0001/1" )
shahshreya9294c8d2015-01-21 15:54:16 -0800388 if ptpIntentResult == main.TRUE:
389 main.ONOS3.intents( jsonFormat=False )
kelvin-onlab8a832582015-01-16 17:06:11 -0800390 main.log.info( "Point to point intent install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800391
kelvin-onlab8a832582015-01-16 17:06:11 -0800392 time.sleep( 10 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800393 flowHandle = main.ONOS3.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -0800394 main.log.info( "flows :" + flowHandle )
shahshreyae6c7cf42014-11-26 16:39:01 -0800395
396 # Sleep for 30 seconds to provide time for the intent state to change
kelvin-onlab8a832582015-01-16 17:06:11 -0800397 time.sleep( 30 )
shahshreya9294c8d2015-01-21 15:54:16 -0800398 intentHandle = main.ONOS3.intents( jsonFormat=False )
kelvin-onlab8a832582015-01-16 17:06:11 -0800399 main.log.info( "intents :" + intentHandle )
400
shahshreya9294c8d2015-01-21 15:54:16 -0800401 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800402 count = 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800403 main.log.info( "\n\nh1 is Pinging h2" )
404 ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
shahshreya9294c8d2015-01-21 15:54:16 -0800405 # ping = main.LincOE2.pinghost()
kelvin-onlab8a832582015-01-16 17:06:11 -0800406 if ping == main.FALSE and count < 5:
407 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -0800408 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800409 main.log.info(
410 "Ping between h1 and h2 failed. Making attempt number " +
411 str( count ) +
412 " in 2 seconds" )
413 time.sleep( 2 )
414 elif ping == main.FALSE:
415 main.log.info( "All ping attempts between h1 and h2 have failed" )
shahshreya9294c8d2015-01-21 15:54:16 -0800416 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800417 elif ping == main.TRUE:
418 main.log.info( "Ping test between h1 and h2 passed!" )
shahshreya9294c8d2015-01-21 15:54:16 -0800419 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800420 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800421 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -0800422 PingResult = main.ERROR
kelvin-onlab8a832582015-01-16 17:06:11 -0800423
shahshreya9294c8d2015-01-21 15:54:16 -0800424 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800425 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800426 "Point intents for packet optical have not ben installed" +
427 " correctly. Cleaning up" )
shahshreya9294c8d2015-01-21 15:54:16 -0800428 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800429 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800430 "Point Intents for packet optical have been " +
431 "installed correctly" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800432
shahshreya9294c8d2015-01-21 15:54:16 -0800433 case23Result = PingResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800434 utilities.assert_equals(
435 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800436 actual=case23Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800437 onpass= "Point intents addition for packet optical and" +
438 "Pingall Test successful",
439 onfail= "Point intents addition for packet optical and" +
440 "Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800441
kelvin-onlab8a832582015-01-16 17:06:11 -0800442 def CASE24( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800443 import time
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800444 import json
kelvin-onlab8a832582015-01-16 17:06:11 -0800445 """
shahshreya9294c8d2015-01-21 15:54:16 -0800446 Test Rerouting of Packet Optical by bringing a port down
447 ( port 22 ) of a switch( switchID=1 ), so that link
448 ( between switch1 port22 - switch4-port30 ) is inactive
449 and do a ping test. If rerouting is successful,
450 ping should pass. also check the flows
kelvin-onlab8a832582015-01-16 17:06:11 -0800451 """
452 main.log.report(
453 "This testcase tests rerouting and pings mininet hosts" )
454 main.case( "Test rerouting and pings mininet hosts" )
455 main.step( "Bring a port down and verify the link state" )
shahshreya9294c8d2015-01-21 15:54:16 -0800456 main.LincOE1.portDown( swId="1", ptId="22" )
457 linksNonjson = main.ONOS3.links( jsonFormat=False )
458 main.log.info( "links = " + linksNonjson )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800459
460 links = main.ONOS3.links()
kelvin-onlab8a832582015-01-16 17:06:11 -0800461 main.log.info( "links = " + links )
462
shahshreya9294c8d2015-01-21 15:54:16 -0800463 linksResult = json.loads( links )
464 linksStateResult = main.FALSE
465 for item in linksResult:
kelvin-onlab8a832582015-01-16 17:06:11 -0800466 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
467 'src' ][ 'port' ] == "22":
468 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff04" and item[
469 'dst' ][ 'port' ] == "30":
shahshreya9294c8d2015-01-21 15:54:16 -0800470 linksState = item[ 'state' ]
471 if linksState == "INACTIVE":
kelvin-onlab8a832582015-01-16 17:06:11 -0800472 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800473 "Links state is inactive as expected due to one" +
474 " of the ports being down" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800475 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800476 "Links state is inactive as expected due to one" +
477 " of the ports being down" )
shahshreya9294c8d2015-01-21 15:54:16 -0800478 linksStateResult = main.TRUE
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800479 break
480 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800481 main.log.info(
482 "Links state is not inactive as expected" )
483 main.log.report(
484 "Links state is not inactive as expected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800485 linksStateResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800486
shahshreya9294c8d2015-01-21 15:54:16 -0800487 print "links_state_result = ", linksStateResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800488 time.sleep( 10 )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800489 flowHandle = main.ONOS3.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -0800490 main.log.info( "flows :" + flowHandle )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800491
kelvin-onlab8a832582015-01-16 17:06:11 -0800492 main.step( "Verify Rerouting by a ping test" )
shahshreya9294c8d2015-01-21 15:54:16 -0800493 PingResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800494 count = 1
495 main.log.info( "\n\nh1 is Pinging h2" )
496 ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
shahshreya9294c8d2015-01-21 15:54:16 -0800497 # ping = main.LincOE2.pinghost()
kelvin-onlab8a832582015-01-16 17:06:11 -0800498 if ping == main.FALSE and count < 5:
499 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -0800500 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800501 main.log.info(
502 "Ping between h1 and h2 failed. Making attempt number " +
503 str( count ) +
504 " in 2 seconds" )
505 time.sleep( 2 )
506 elif ping == main.FALSE:
507 main.log.info( "All ping attempts between h1 and h2 have failed" )
shahshreya9294c8d2015-01-21 15:54:16 -0800508 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800509 elif ping == main.TRUE:
510 main.log.info( "Ping test between h1 and h2 passed!" )
shahshreya9294c8d2015-01-21 15:54:16 -0800511 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800512 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800513 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -0800514 PingResult = main.ERROR
shahshreyae6c7cf42014-11-26 16:39:01 -0800515
shahshreya9294c8d2015-01-21 15:54:16 -0800516 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800517 main.log.report( "Ping test successful " )
shahshreya9294c8d2015-01-21 15:54:16 -0800518 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800519 main.log.report( "Ping test failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800520
shahshreya9294c8d2015-01-21 15:54:16 -0800521 case24Result = PingResult and linksStateResult
522 utilities.assert_equals( expect=main.TRUE, actual=case24Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800523 onpass="Packet optical rerouting successful",
524 onfail="Packet optical rerouting failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800525
kelvin-onlab8a832582015-01-16 17:06:11 -0800526 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800527 import re
528 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800529 main.log.report( "This testcase is testing the assignment of" +
530 " all the switches to all the controllers and" +
shahshreyab189da22015-02-25 10:18:26 -0800531 " discovering the hosts in reactive mode" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800532 main.log.report( "__________________________________" )
533 main.case( "Pingall Test" )
534 main.step( "Assigning switches to controllers" )
shahshreya9294c8d2015-01-21 15:54:16 -0800535 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
536 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
kelvin-onlab8a832582015-01-16 17:06:11 -0800537 for i in range( 1, 29 ):
538 if i == 1:
shahshreya9294c8d2015-01-21 15:54:16 -0800539 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800540 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800541 ip1=ONOS1Ip,
542 port1=ONOS1Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800543 elif i >= 2 and i < 5:
shahshreya9294c8d2015-01-21 15:54:16 -0800544 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800545 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800546 ip1=ONOS1Ip,
547 port1=ONOS1Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800548 elif i >= 5 and i < 8:
shahshreya9294c8d2015-01-21 15:54:16 -0800549 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800550 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800551 ip1=ONOS1Ip,
552 port1=ONOS1Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800553 elif i >= 8 and i < 18:
shahshreya9294c8d2015-01-21 15:54:16 -0800554 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800555 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800556 ip1=ONOS1Ip,
557 port1=ONOS1Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800558 elif i >= 18 and i < 28:
shahshreya9294c8d2015-01-21 15:54:16 -0800559 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800560 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800561 ip1=ONOS1Ip,
562 port1=ONOS1Port )
shahshreya4e13a062014-11-11 16:46:18 -0800563 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800564 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800565 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800566 ip1=ONOS1Ip,
567 port1=ONOS1Port )
568 SwitchMastership = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800569 for i in range( 1, 29 ):
570 if i == 1:
shahshreya9294c8d2015-01-21 15:54:16 -0800571 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800572 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800573 if re.search( "tcp:" + ONOS1Ip, response ):
574 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800575 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800576 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800577 elif i >= 2 and i < 5:
shahshreya9294c8d2015-01-21 15:54:16 -0800578 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800579 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800580 if re.search( "tcp:" + ONOS1Ip, response ):
581 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800582 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800583 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800584 elif i >= 5 and i < 8:
shahshreya9294c8d2015-01-21 15:54:16 -0800585 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800586 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800587 if re.search( "tcp:" + ONOS1Ip, response ):
588 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800589 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800590 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800591 elif i >= 8 and i < 18:
shahshreya9294c8d2015-01-21 15:54:16 -0800592 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800593 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800594 if re.search( "tcp:" + ONOS1Ip, response ):
595 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800596 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800597 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800598 elif i >= 18 and i < 28:
shahshreya9294c8d2015-01-21 15:54:16 -0800599 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800600 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800601 if re.search( "tcp:" + ONOS1Ip, response ):
602 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800603 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800604 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800605 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800606 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800607 print( "Response is" + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800608 if re.search( "tcp:" + ONOS1Ip, response ):
609 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800610 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800611 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800612
shahshreya9294c8d2015-01-21 15:54:16 -0800613 if SwitchMastership == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800614 main.log.report( "Controller assignmnet successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800615 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800616 main.log.report( "Controller assignmnet failed" )
617 utilities.assert_equals(
618 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800619 actual=SwitchMastership,
kelvin-onlab8a832582015-01-16 17:06:11 -0800620 onpass="MasterControllers assigned correctly" )
621 """
622 for i in range ( 1,29 ):
shahshreya9294c8d2015-01-21 15:54:16 -0800623 main.Mininet1.assignSwController( sw=str( i ),count=5,
624 ip1=ONOS1Ip,port1=ONOS1Port,
625 ip2=ONOS2Ip,port2=ONOS2Port,
626 ip3=ONOS3Ip,port3=ONOS3Port,
627 ip4=ONOS4Ip,port4=ONOS4Port,
628 ip5=ONOS5Ip,port5=ONOS5Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800629 """
630 # REACTIVE FWD test
shahshreya4e13a062014-11-11 16:46:18 -0800631
kelvin-onlab8a832582015-01-16 17:06:11 -0800632 main.step( "Get list of hosts from Mininet" )
shahshreya9294c8d2015-01-21 15:54:16 -0800633 hostList = main.Mininet1.getHosts()
634 main.log.info( hostList )
shahshreya4e13a062014-11-11 16:46:18 -0800635
kelvin-onlab8a832582015-01-16 17:06:11 -0800636 main.step( "Get host list in ONOS format" )
shahshreya9294c8d2015-01-21 15:54:16 -0800637 hostOnosList = main.ONOS2.getHostsId( hostList )
638 main.log.info( hostOnosList )
kelvin-onlab8a832582015-01-16 17:06:11 -0800639 # time.sleep( 5 )
640
641 main.step( "Pingall" )
shahshreya9294c8d2015-01-21 15:54:16 -0800642 pingResult = main.FALSE
shahshreya82ecd282015-02-05 16:48:03 -0800643 time1 = time.time()
644 pingResult = main.Mininet1.pingall()
645 time2 = time.time()
646 print "Time for pingall: %2f seconds" % ( time2 - time1 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800647
shahshreya9294c8d2015-01-21 15:54:16 -0800648 # Start onos cli again because u might have dropped out of
649 # onos prompt to the shell prompt
kelvin-onlab8a832582015-01-16 17:06:11 -0800650 # if there was no activity
shahshreya9294c8d2015-01-21 15:54:16 -0800651 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800652
shahshreya9294c8d2015-01-21 15:54:16 -0800653 case4Result = SwitchMastership and pingResult
654 if pingResult == main.TRUE:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800655 main.log.report( "Pingall Test in reactive mode to" +
656 " discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800657 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800658 main.log.report( "Pingall Test in reactive mode to" +
659 " discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800660
kelvin-onlab8a832582015-01-16 17:06:11 -0800661 utilities.assert_equals(
662 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800663 actual=case4Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800664 onpass="Controller assignment and Pingall Test successful",
665 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800666
kelvin-onlab8a832582015-01-16 17:06:11 -0800667 def CASE10( self ):
668 main.log.report(
669 "This testcase uninstalls the reactive forwarding app" )
670 main.log.report( "__________________________________" )
671 main.case( "Uninstalling reactive forwarding app" )
672 # Unistall onos-app-fwd app to disable reactive forwarding
shahshreya9294c8d2015-01-21 15:54:16 -0800673 appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800674 main.log.info( "onos-app-fwd uninstalled" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800675
shahshreya9294c8d2015-01-21 15:54:16 -0800676 # After reactive forwarding is disabled, the reactive flows on
677 # switches timeout in 10-15s
kelvin-onlab8a832582015-01-16 17:06:11 -0800678 # So sleep for 15s
679 time.sleep( 15 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800680
681 flows = main.ONOS2.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -0800682 main.log.info( flows )
shahshreyae6c7cf42014-11-26 16:39:01 -0800683
shahshreya9294c8d2015-01-21 15:54:16 -0800684 case10Result = appUninstallResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800685 utilities.assert_equals(
686 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800687 actual=case10Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800688 onpass="Reactive forwarding app uninstallation successful",
689 onfail="Reactive forwarding app uninstallation failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800690
shahshreyab189da22015-02-25 10:18:26 -0800691
692 def CASE11( self ):
693 # NOTE: This testcase require reactive forwarding mode enabled
694 # NOTE: in the beginning and then uninstall it before adding
695 # NOTE: point intents. Again the app is installed so that
696 # NOTE: testcase 10 can be ran successively
697 import time
698 main.log.report(
699 "This testcase moves a host from one switch to another to add" +
700 "point intents between them and then perform ping" )
701 main.log.report( "__________________________________" )
702 main.log.info( "Moving host from one switch to another" )
703 main.case( "Moving host from a device and attach it to another device" )
704 main.step( "Moving host h9 from device s9 and attach it to s8" )
705 main.Mininet1.moveHost(host = 'h9', oldSw = 's9', newSw = 's8')
706
707 time.sleep(15) #Time delay to have all the flows ready
708 main.step( "Pingall" )
709 pingResult = main.FALSE
710 time1 = time.time()
711 pingResult = main.Mininet1.pingall()
712 time2 = time.time()
713 print "Time for pingall: %2f seconds" % ( time2 - time1 )
714
715 hosts = main.ONOS2.hosts( jsonFormat = False )
716 main.log.info( hosts )
717
718 main.case( "Uninstalling reactive forwarding app" )
719 # Unistall onos-app-fwd app to disable reactive forwarding
720 appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
721 main.log.info( "onos-app-fwd uninstalled" )
722
723 main.step( "Add point intents between hosts on the same device")
724 ptpIntentResult = main.ONOS2.addPointIntent(
725 "of:0000000000003008/1",
726 "of:0000000000003008/3" )
727 if ptpIntentResult == main.TRUE:
728 getIntentResult = main.ONOS2.intents()
729 main.log.info( "Point to point intent install successful" )
730 # main.log.info( getIntentResult )
731
732 ptpIntentResult = main.ONOS2.addPointIntent(
733 "of:0000000000003008/3",
734 "of:0000000000003008/1" )
735 if ptpIntentResult == main.TRUE:
736 getIntentResult = main.ONOS2.intents()
737 main.log.info( "Point to point intent install successful" )
738 # main.log.info( getIntentResult )
739
740 main.case( "Ping hosts on the same devices" )
741 ping = main.Mininet1.pingHost( src = 'h8', target = 'h9' )
742
743 '''
744 main.case( "Installing reactive forwarding app" )
745 # Install onos-app-fwd app to enable reactive forwarding
746 appUninstallResult = main.ONOS2.featureInstall( "onos-app-fwd" )
747 main.log.info( "onos-app-fwd installed" )
748 '''
749
750 if ping == main.FALSE:
751 main.log.report(
752 "Point intents for hosts on same devices haven't" +
753 " been installed correctly. Cleaning up" )
754 if ping == main.TRUE:
755 main.log.report(
756 "Point intents for hosts on same devices" +
757 "installed correctly. Cleaning up" )
758
759 case11Result = ping and pingResult
760 utilities.assert_equals(
shahshreya74cca802015-02-26 12:24:01 -0800761 expect = main.TRUE,
762 actual = case11Result,
763 onpass = "Point intents for hosts on same devices" +
shahshreyab189da22015-02-25 10:18:26 -0800764 "Ping Test successful",
shahshreya74cca802015-02-26 12:24:01 -0800765 onfail = "Point intents for hosts on same devices" +
shahshreyab189da22015-02-25 10:18:26 -0800766 "Ping Test NOT successful" )
shahshreya74cca802015-02-26 12:24:01 -0800767
768
769 def CASE12( self ):
770 """
shahshreyaed683ed2015-03-16 15:04:40 -0700771 Verify the default flows on each switch in proactive mode
shahshreya74cca802015-02-26 12:24:01 -0800772 """
shahshreyaed683ed2015-03-16 15:04:40 -0700773 main.log.report( "This testcase is verifying num of default" +
774 " flows on each switch" )
775 main.log.report( "__________________________________" )
776 main.case( "Verify num of default flows on each switch" )
777 main.step( "Obtaining the device id's and flowrule count on them" )
778
shahshreya74cca802015-02-26 12:24:01 -0800779 case12Result = main.TRUE
780 idList = main.ONOS2.getAllDevicesId()
781 for id in idList:
shahshreyaed683ed2015-03-16 15:04:40 -0700782 count = main.ONOS2.FlowAddedCount( id )
783 main.log.info("count = " +count)
784 if int(count) != 3:
shahshreya74cca802015-02-26 12:24:01 -0800785 case12Result = main.FALSE
shahshreyaed683ed2015-03-16 15:04:40 -0700786 break
shahshreya74cca802015-02-26 12:24:01 -0800787 utilities.assert_equals(
788 expect=main.TRUE,
789 actual=case12Result,
790 onpass = "Expected default num of flows exist",
791 onfail = "Expected default num of flows do not exist")
792
793
shahshreyab189da22015-02-25 10:18:26 -0800794
795
kelvin-onlab8a832582015-01-16 17:06:11 -0800796 def CASE6( self ):
shahshreyab189da22015-02-25 10:18:26 -0800797 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800798 main.log.report( "This testcase is testing the addition of" +
799 " host intents and then does pingall" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800800 main.log.report( "__________________________________" )
801 main.case( "Obtaining host id's" )
802 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800803 hosts = main.ONOS2.hosts()
shahshreya9294c8d2015-01-21 15:54:16 -0800804 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800805
kelvin-onlab8a832582015-01-16 17:06:11 -0800806 main.step( "Get all devices id" )
shahshreya9294c8d2015-01-21 15:54:16 -0800807 devicesIdList = main.ONOS2.getAllDevicesId()
808 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -0800809
shahshreya9294c8d2015-01-21 15:54:16 -0800810 # ONOS displays the hosts in hex format unlike mininet which does
811 # in decimal format
kelvin-onlab8a832582015-01-16 17:06:11 -0800812 # So take care while adding intents
813 """
shahshreya9294c8d2015-01-21 15:54:16 -0800814 main.step( "Add host-to-host intents for mininet hosts h8 and h18 or
815 ONOS hosts h8 and h12" )
816 hthIntentResult = main.ONOS2.addHostIntent(
817 "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
818 hthIntentResult = main.ONOS2.addHostIntent(
819 "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
820 hthIntentResult = main.ONOS2.addHostIntent(
821 "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
822 hthIntentResult = main.ONOS2.addHostIntent(
823 "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
824 hthIntentResult = main.ONOS2.addHostIntent(
825 "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
826 hthIntentResult = main.ONOS2.addHostIntent(
827 "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
828 hthIntentResult = main.ONOS2.addHostIntent(
829 "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
830 hthIntentResult = main.ONOS2.addHostIntent(
831 "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
832 hthIntentResult = main.ONOS2.addHostIntent(
833 "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
834 hthIntentResult = main.ONOS2.addHostIntent(
835 "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
836 print "______________________________________________________"
kelvin-onlab8a832582015-01-16 17:06:11 -0800837 """
838 for i in range( 8, 18 ):
839 main.log.info(
shahshreya9294c8d2015-01-21 15:54:16 -0800840 "Adding host intent between h" + str( i ) +
841 " and h" + str( i + 10 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800842 host1 = "00:00:00:00:00:" + \
843 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
844 host2 = "00:00:00:00:00:" + \
845 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
846 # NOTE: get host can return None
847 # TODO: handle this
shahshreya9294c8d2015-01-21 15:54:16 -0800848 host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
shahshreyab189da22015-02-25 10:18:26 -0800849
shahshreya9294c8d2015-01-21 15:54:16 -0800850 host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
851 main.ONOS2.addHostIntent( host1Id, host2Id )
kelvin-onlab8a832582015-01-16 17:06:11 -0800852
853 time.sleep( 10 )
shahshreya9294c8d2015-01-21 15:54:16 -0800854 hIntents = main.ONOS2.intents( jsonFormat=False )
855 main.log.info( "intents:" + hIntents )
shahshreyab189da22015-02-25 10:18:26 -0800856 flows = main.ONOS2.flows()
857 main.log.info( "flows:" + flows )
shahshreya4e13a062014-11-11 16:46:18 -0800858
859 count = 1
860 i = 8
shahshreya9294c8d2015-01-21 15:54:16 -0800861 PingResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800862 # while i<10:
863 while i < 18:
864 main.log.info(
865 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
866 ping = main.Mininet1.pingHost(
867 src="h" + str( i ), target="h" + str( i + 10 ) )
868 if ping == main.FALSE and count < 5:
869 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -0800870 # i = 8
871 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800872 main.log.report( "Ping between h" +
873 str( i ) +
874 " and h" +
875 str( i +
876 10 ) +
877 " failed. Making attempt number " +
878 str( count ) +
879 " in 2 seconds" )
880 time.sleep( 2 )
881 elif ping == main.FALSE:
882 main.log.report( "All ping attempts between h" +
883 str( i ) +
884 " and h" +
885 str( i +
886 10 ) +
887 "have failed" )
888 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -0800889 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800890 elif ping == main.TRUE:
891 main.log.info( "Ping test between h" +
892 str( i ) +
893 " and h" +
894 str( i +
895 10 ) +
896 "passed!" )
897 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -0800898 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800899 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800900 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -0800901 PingResult = main.ERROR
902 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800903 main.log.report(
shahshreya9294c8d2015-01-21 15:54:16 -0800904 "Ping all test after Host intent addition failed.Cleaning up" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800905 # main.cleanup()
906 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -0800907 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800908 main.log.report(
909 "Ping all test after Host intent addition successful" )
910
shahshreya9294c8d2015-01-21 15:54:16 -0800911 case6Result = PingResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800912 utilities.assert_equals(
913 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800914 actual=case6Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800915 onpass="Pingall Test after Host intents addition successful",
916 onfail="Pingall Test after Host intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800917
kelvin-onlab8a832582015-01-16 17:06:11 -0800918 def CASE5( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800919 import json
kelvin-onlab8a832582015-01-16 17:06:11 -0800920 # assumes that sts is already in you PYTHONPATH
921 from sts.topology.teston_topology import TestONTopology
shahshreya9294c8d2015-01-21 15:54:16 -0800922 # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800923 main.log.report( "This testcase is testing if all ONOS nodes" +
924 " are in topology sync with mininet" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800925 main.log.report( "__________________________________" )
926 main.case( "Comparing Mininet topology with the topology of ONOS" )
927 main.step( "Start continuous pings" )
928 main.Mininet2.pingLong(
929 src=main.params[ 'PING' ][ 'source1' ],
930 target=main.params[ 'PING' ][ 'target1' ],
931 pingTime=500 )
932 main.Mininet2.pingLong(
933 src=main.params[ 'PING' ][ 'source2' ],
934 target=main.params[ 'PING' ][ 'target2' ],
935 pingTime=500 )
936 main.Mininet2.pingLong(
937 src=main.params[ 'PING' ][ 'source3' ],
938 target=main.params[ 'PING' ][ 'target3' ],
939 pingTime=500 )
940 main.Mininet2.pingLong(
941 src=main.params[ 'PING' ][ 'source4' ],
942 target=main.params[ 'PING' ][ 'target4' ],
943 pingTime=500 )
944 main.Mininet2.pingLong(
945 src=main.params[ 'PING' ][ 'source5' ],
946 target=main.params[ 'PING' ][ 'target5' ],
947 pingTime=500 )
948 main.Mininet2.pingLong(
949 src=main.params[ 'PING' ][ 'source6' ],
950 target=main.params[ 'PING' ][ 'target6' ],
951 pingTime=500 )
952 main.Mininet2.pingLong(
953 src=main.params[ 'PING' ][ 'source7' ],
954 target=main.params[ 'PING' ][ 'target7' ],
955 pingTime=500 )
956 main.Mininet2.pingLong(
957 src=main.params[ 'PING' ][ 'source8' ],
958 target=main.params[ 'PING' ][ 'target8' ],
959 pingTime=500 )
960 main.Mininet2.pingLong(
961 src=main.params[ 'PING' ][ 'source9' ],
962 target=main.params[ 'PING' ][ 'target9' ],
963 pingTime=500 )
964 main.Mininet2.pingLong(
965 src=main.params[ 'PING' ][ 'source10' ],
966 target=main.params[ 'PING' ][ 'target10' ],
967 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -0800968
kelvin-onlab8a832582015-01-16 17:06:11 -0800969 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800970 global ctrls
971 ctrls = []
972 count = 1
973 while True:
974 temp = ()
kelvin-onlab8a832582015-01-16 17:06:11 -0800975 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
976 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
977 temp = temp + ( "ONOS" + str( count ), )
978 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
979 temp = temp + \
980 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
981 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800982 count = count + 1
983 else:
984 break
985 global MNTopo
kelvin-onlab8a832582015-01-16 17:06:11 -0800986 Topo = TestONTopology(
987 main.Mininet1,
988 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800989 MNTopo = Topo
990
shahshreya9294c8d2015-01-21 15:54:16 -0800991 TopologyCheck = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800992 main.step( "Compare ONOS Topology to MN Topology" )
shahshreya9294c8d2015-01-21 15:54:16 -0800993 devicesJson = main.ONOS2.devices()
994 linksJson = main.ONOS2.links()
995 # portsJson = main.ONOS2.ports()
kelvin-onlab8a832582015-01-16 17:06:11 -0800996
shahshreya9294c8d2015-01-21 15:54:16 -0800997 result1 = main.Mininet1.compareSwitches(
kelvin-onlab8a832582015-01-16 17:06:11 -0800998 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -0800999 json.loads( devicesJson ) )
1000 result2 = main.Mininet1.compareLinks(
kelvin-onlab8a832582015-01-16 17:06:11 -08001001 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001002 json.loads( linksJson ) )
1003 # result3 = main.Mininet1.comparePorts(
1004 # MNTopo, json.loads( portsJson ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001005
shahshreya9294c8d2015-01-21 15:54:16 -08001006 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001007 result = result1 and result2
kelvin-onlab8a832582015-01-16 17:06:11 -08001008
shahshreya4e13a062014-11-11 16:46:18 -08001009 print "***********************"
1010 if result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001011 main.log.report( "ONOS" + " Topology matches MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001012 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001013 main.log.report( "ONOS" + " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001014
kelvin-onlab8a832582015-01-16 17:06:11 -08001015 utilities.assert_equals(
1016 expect=main.TRUE,
1017 actual=result,
1018 onpass="ONOS" +
1019 " Topology matches MN Topology",
1020 onfail="ONOS" +
1021 " Topology does not match MN Topology" )
1022
shahshreya9294c8d2015-01-21 15:54:16 -08001023 TopologyCheck = TopologyCheck and result
kelvin-onlab8a832582015-01-16 17:06:11 -08001024 utilities.assert_equals(
1025 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001026 actual=TopologyCheck,
kelvin-onlab8a832582015-01-16 17:06:11 -08001027 onpass="Topology checks passed",
1028 onfail="Topology checks failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001029
kelvin-onlab8a832582015-01-16 17:06:11 -08001030 def CASE7( self, main ):
shahshreya9294c8d2015-01-21 15:54:16 -08001031 from sts.topology.teston_topology import TestONTopology
shahshreya4e13a062014-11-11 16:46:18 -08001032
shahshreya9294c8d2015-01-21 15:54:16 -08001033 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -08001034
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001035 main.log.report( "This testscase is killing a link to ensure that" +
1036 " link discovery is consistent" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001037 main.log.report( "__________________________________" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001038 main.log.report( "Killing a link to ensure that link discovery" +
1039 " is consistent" )
1040 main.case( "Killing a link to Ensure that Link Discovery" +
1041 "is Working Properly" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001042 """
1043 main.step( "Start continuous pings" )
1044
1045 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001046 target=main.params[ 'PING' ][ 'target1' ],
1047 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001048 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001049 target=main.params[ 'PING' ][ 'target2' ],
1050 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001051 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001052 target=main.params[ 'PING' ][ 'target3' ],
1053 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001054 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001055 target=main.params[ 'PING' ][ 'target4' ],
1056 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001057 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001058 target=main.params[ 'PING' ][ 'target5' ],
1059 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001060 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001061 target=main.params[ 'PING' ][ 'target6' ],
1062 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001063 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001064 target=main.params[ 'PING' ][ 'target7' ],
1065 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001066 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001067 target=main.params[ 'PING' ][ 'target8' ],
1068 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001069 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001070 target=main.params[ 'PING' ][ 'target9' ],
1071 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001072 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001073 target=main.params[ 'PING' ][ 'target10' ],
1074 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001075 """
1076 main.step( "Determine the current number of switches and links" )
shahshreya9294c8d2015-01-21 15:54:16 -08001077 topologyOutput = main.ONOS2.topology()
1078 topologyResult = main.ONOS1.getTopology( topologyOutput )
shahshreyaed683ed2015-03-16 15:04:40 -07001079 activeSwitches = topologyResult[ 'deviceCount' ]
1080 links = topologyResult[ 'linkCount' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001081 print "activeSwitches = ", type( activeSwitches )
1082 print "links = ", type( links )
1083 main.log.info(
1084 "Currently there are %s switches and %s links" %
1085 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -08001086
kelvin-onlab8a832582015-01-16 17:06:11 -08001087 main.step( "Kill Link between s3 and s28" )
1088 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
shahshreya9294c8d2015-01-21 15:54:16 -08001089 time.sleep( linkSleep )
1090 topologyOutput = main.ONOS2.topology()
1091 LinkDown = main.ONOS1.checkStatus(
1092 topologyOutput, activeSwitches, str(
kelvin-onlab8a832582015-01-16 17:06:11 -08001093 int( links ) - 2 ) )
shahshreya9294c8d2015-01-21 15:54:16 -08001094 if LinkDown == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001095 main.log.report( "Link Down discovered properly" )
1096 utilities.assert_equals(
1097 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001098 actual=LinkDown,
kelvin-onlab8a832582015-01-16 17:06:11 -08001099 onpass="Link Down discovered properly",
1100 onfail="Link down was not discovered in " +
shahshreya9294c8d2015-01-21 15:54:16 -08001101 str( linkSleep ) +
kelvin-onlab8a832582015-01-16 17:06:11 -08001102 " seconds" )
1103
1104 # Check ping result here..add code for it
1105
1106 main.step( "Bring link between s3 and s28 back up" )
shahshreya9294c8d2015-01-21 15:54:16 -08001107 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
1108 time.sleep( linkSleep )
1109 topologyOutput = main.ONOS2.topology()
1110 LinkUp = main.ONOS1.checkStatus(
1111 topologyOutput,
kelvin-onlab8a832582015-01-16 17:06:11 -08001112 activeSwitches,
1113 str( links ) )
shahshreya9294c8d2015-01-21 15:54:16 -08001114 if LinkUp == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001115 main.log.report( "Link up discovered properly" )
1116 utilities.assert_equals(
1117 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001118 actual=LinkUp,
kelvin-onlab8a832582015-01-16 17:06:11 -08001119 onpass="Link up discovered properly",
1120 onfail="Link up was not discovered in " +
shahshreya9294c8d2015-01-21 15:54:16 -08001121 str( linkSleep ) +
kelvin-onlab8a832582015-01-16 17:06:11 -08001122 " seconds" )
1123
1124 # NOTE Check ping result here..add code for it
1125
1126 main.step( "Compare ONOS Topology to MN Topology" )
1127 Topo = TestONTopology(
1128 main.Mininet1,
1129 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -08001130 MNTopo = Topo
shahshreya9294c8d2015-01-21 15:54:16 -08001131 TopologyCheck = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001132
shahshreya9294c8d2015-01-21 15:54:16 -08001133 devicesJson = main.ONOS2.devices()
1134 linksJson = main.ONOS2.links()
1135 portsJson = main.ONOS2.ports()
kelvin-onlab8a832582015-01-16 17:06:11 -08001136
shahshreya9294c8d2015-01-21 15:54:16 -08001137 result1 = main.Mininet1.compareSwitches(
kelvin-onlab8a832582015-01-16 17:06:11 -08001138 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001139 json.loads( devicesJson ) )
1140 result2 = main.Mininet1.compareLinks(
kelvin-onlab8a832582015-01-16 17:06:11 -08001141 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001142 json.loads( linksJson ) )
1143 # result3 = main.Mininet1.comparePorts(
1144 # MNTopo, json.loads( portsJson ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001145
shahshreya9294c8d2015-01-21 15:54:16 -08001146 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001147 result = result1 and result2
1148 print "***********************"
kelvin-onlab8a832582015-01-16 17:06:11 -08001149
shahshreya4e13a062014-11-11 16:46:18 -08001150 if result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001151 main.log.report( "ONOS" + " Topology matches MN Topology" )
1152 utilities.assert_equals(
1153 expect=main.TRUE,
1154 actual=result,
1155 onpass="ONOS" +
1156 " Topology matches MN Topology",
1157 onfail="ONOS" +
1158 " Topology does not match MN Topology" )
1159
shahshreya9294c8d2015-01-21 15:54:16 -08001160 TopologyCheck = TopologyCheck and result
kelvin-onlab8a832582015-01-16 17:06:11 -08001161 utilities.assert_equals(
1162 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001163 actual=TopologyCheck,
kelvin-onlab8a832582015-01-16 17:06:11 -08001164 onpass="Topology checks passed",
1165 onfail="Topology checks failed" )
1166
shahshreya9294c8d2015-01-21 15:54:16 -08001167 result = LinkDown and LinkUp and TopologyCheck
kelvin-onlab8a832582015-01-16 17:06:11 -08001168 utilities.assert_equals( expect=main.TRUE, actual=result,
1169 onpass="Link failure is discovered correctly",
1170 onfail="Link Discovery failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001171
kelvin-onlab8a832582015-01-16 17:06:11 -08001172 def CASE8( self ):
1173 """
shahshreya82ecd282015-02-05 16:48:03 -08001174 Intent removal
kelvin-onlab8a832582015-01-16 17:06:11 -08001175 """
shahshreya82ecd282015-02-05 16:48:03 -08001176 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001177 main.log.report( "This testcase removes any previously added intents" +
shahshreya82ecd282015-02-05 16:48:03 -08001178 " before adding any new set of intents" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001179 main.log.report( "__________________________________" )
shahshreya82ecd282015-02-05 16:48:03 -08001180 main.log.info( "intent removal" )
1181 main.case( "Removing installed intents" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001182 main.step( "Obtain the intent id's" )
shahshreya9294c8d2015-01-21 15:54:16 -08001183 intentResult = main.ONOS2.intents( jsonFormat=False )
1184 main.log.info( "intent_result = " + intentResult )
shahshreya9294c8d2015-01-21 15:54:16 -08001185 intentLinewise = intentResult.split( "\n" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001186
shahshreyab189da22015-02-25 10:18:26 -08001187 intentList = [line for line in intentLinewise \
1188 if line.startswith( "id=")]
1189 intentids = [line.split( "," )[ 0 ].split( "=" )[ 1 ] for line in \
1190 intentList]
shahshreya4e13a062014-11-11 16:46:18 -08001191 for id in intentids:
1192 print "id = ", id
kelvin-onlab8a832582015-01-16 17:06:11 -08001193
1194 main.step(
1195 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -08001196 for id in intentids:
shahshreya9294c8d2015-01-21 15:54:16 -08001197 main.ONOS2.removeIntent( intentId=id )
kelvin-onlab8a832582015-01-16 17:06:11 -08001198
shahshreya9294c8d2015-01-21 15:54:16 -08001199 intentResult = main.ONOS2.intents( jsonFormat=False )
1200 main.log.info( "intent_result = " + intentResult )
shahshreyab189da22015-02-25 10:18:26 -08001201
1202 intentList = [line for line in intentResult.split( "\n" ) \
1203 if line.startswith( "id=")]
1204 intentState = [line.split( "," )[ 1 ].split( "=" )[ 1 ] for line in \
1205 intentList]
1206 for state in intentState:
1207 print state
1208
1209 case8Result = main.TRUE
1210 for state in intentState:
1211 if state != 'WITHDRAWN':
1212 case8Result = main.FALSE
1213 break
1214
shahshreya9294c8d2015-01-21 15:54:16 -08001215 if case8Result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001216 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001217 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001218 main.log.report( "Intent removal failed" )
1219
shahshreya9294c8d2015-01-21 15:54:16 -08001220 PingResult = main.TRUE
1221 if case8Result == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001222 i = 8
kelvin-onlab8a832582015-01-16 17:06:11 -08001223 while i < 18:
1224 main.log.info(
1225 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1226 ping = main.Mininet1.pingHost(
1227 src="h" + str( i ), target="h" + str( i + 10 ) )
1228 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001229 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -08001230 PingResult = PingResult and main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001231 elif ping == main.FALSE:
1232 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001233 PingResult = PingResult and main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -08001234 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001235 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -08001236 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001237
kelvin-onlab8a832582015-01-16 17:06:11 -08001238 # Note: If the ping result failed, that means the intents have been
1239 # withdrawn correctly.
shahshreya9294c8d2015-01-21 15:54:16 -08001240 if PingResult == main.TRUE:
shahshreya82ecd282015-02-05 16:48:03 -08001241 main.log.report( "Installed intents have not been withdrawn correctly" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001242 # main.cleanup()
1243 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -08001244 if PingResult == main.FALSE:
shahshreya82ecd282015-02-05 16:48:03 -08001245 main.log.report( "Installed intents have been withdrawn correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001246
shahshreya9294c8d2015-01-21 15:54:16 -08001247 case8Result = case8Result and PingResult
shahshreyae6c7cf42014-11-26 16:39:01 -08001248
shahshreya9294c8d2015-01-21 15:54:16 -08001249 if case8Result == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001250 main.log.report( "Intent removal successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001251 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001252 main.log.report( "Intent removal failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001253
shahshreya9294c8d2015-01-21 15:54:16 -08001254 utilities.assert_equals( expect=main.FALSE, actual=case8Result,
1255 onpass="Intent removal test passed",
1256 onfail="Intent removal test failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001257
kelvin-onlab8a832582015-01-16 17:06:11 -08001258 def CASE9( self ):
1259 main.log.report(
1260 "This testcase adds point intents and then does pingall" )
1261 main.log.report( "__________________________________" )
1262 main.log.info( "Adding point intents" )
1263 main.case(
shahshreya82ecd282015-02-05 16:48:03 -08001264 "Adding bidirectional point for mn hosts" +
1265 "( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22, " +
1266 "h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001267
1268 main.step( "Add point intents for mn hosts h8 and h18 or" +
1269 "ONOS hosts h8 and h12" )
1270 # main.step(var1)
shahshreya9294c8d2015-01-21 15:54:16 -08001271 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001272 "of:0000000000003008/1",
1273 "of:0000000000006018/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001274 if ptpIntentResult == main.TRUE:
1275 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001276 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001277 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001278
shahshreya9294c8d2015-01-21 15:54:16 -08001279 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001280 "of:0000000000006018/1",
1281 "of:0000000000003008/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001282 if ptpIntentResult == main.TRUE:
1283 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001284 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001285 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001286
shahshreya9294c8d2015-01-21 15:54:16 -08001287 var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
1288 main.step(var2)
1289 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001290 "of:0000000000003009/1",
1291 "of:0000000000006019/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001292 if ptpIntentResult == main.TRUE:
1293 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001294 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001295 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001296
shahshreya9294c8d2015-01-21 15:54:16 -08001297 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001298 "of:0000000000006019/1",
1299 "of:0000000000003009/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001300 if ptpIntentResult == main.TRUE:
1301 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001302 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001303 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001304
shahshreya9294c8d2015-01-21 15:54:16 -08001305 var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
1306 main.step(var3)
1307 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001308 "of:0000000000003010/1",
1309 "of:0000000000006020/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001310 if ptpIntentResult == main.TRUE:
1311 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001312 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001313 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001314
shahshreya9294c8d2015-01-21 15:54:16 -08001315 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001316 "of:0000000000006020/1",
1317 "of:0000000000003010/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 )
shahshreya4e13a062014-11-11 16:46:18 -08001322
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001323 var4 = "Add point intents for mininet hosts h11 and h21 or" +\
1324 " ONOS hosts hB and h15"
shahshreya9294c8d2015-01-21 15:54:16 -08001325 main.case(var4)
1326 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001327 "of:0000000000003011/1",
1328 "of:0000000000006021/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001329 if ptpIntentResult == main.TRUE:
1330 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001331 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001332 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001333
shahshreya9294c8d2015-01-21 15:54:16 -08001334 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001335 "of:0000000000006021/1",
1336 "of:0000000000003011/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001337 if ptpIntentResult == main.TRUE:
1338 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001339 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001340 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001341
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001342 var5 = "Add point intents for mininet hosts h12 and h22 " +\
1343 "ONOS hosts hC and h16"
shahshreya9294c8d2015-01-21 15:54:16 -08001344 main.case(var5)
1345 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001346 "of:0000000000003012/1",
1347 "of:0000000000006022/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001348 if ptpIntentResult == main.TRUE:
1349 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001350 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001351 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001352
shahshreya9294c8d2015-01-21 15:54:16 -08001353 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001354 "of:0000000000006022/1",
1355 "of:0000000000003012/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001356 if ptpIntentResult == main.TRUE:
1357 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001358 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001359 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001360
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001361 var6 = "Add point intents for mininet hosts h13 and h23 or" +\
1362 " ONOS hosts hD and h17"
shahshreya9294c8d2015-01-21 15:54:16 -08001363 main.case(var6)
1364 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001365 "of:0000000000003013/1",
1366 "of:0000000000006023/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001367 if ptpIntentResult == main.TRUE:
1368 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001369 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001370 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001371
shahshreya9294c8d2015-01-21 15:54:16 -08001372 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001373 "of:0000000000006023/1",
1374 "of:0000000000003013/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001375 if ptpIntentResult == main.TRUE:
1376 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001377 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001378 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001379
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001380 var7 = "Add point intents for mininet hosts h14 and h24 or" +\
1381 " ONOS hosts hE and h18"
shahshreya9294c8d2015-01-21 15:54:16 -08001382 main.case(var7)
1383 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001384 "of:0000000000003014/1",
1385 "of:0000000000006024/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001386 if ptpIntentResult == main.TRUE:
1387 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001388 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001389 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001390
shahshreya9294c8d2015-01-21 15:54:16 -08001391 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001392 "of:0000000000006024/1",
1393 "of:0000000000003014/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001394 if ptpIntentResult == main.TRUE:
1395 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001396 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001397 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001398
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001399 var8 = "Add point intents for mininet hosts h15 and h25 or" +\
1400 " ONOS hosts hF and h19"
shahshreya9294c8d2015-01-21 15:54:16 -08001401 main.case(var8)
1402 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001403 "of:0000000000003015/1",
1404 "of:0000000000006025/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001405 if ptpIntentResult == main.TRUE:
1406 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001407 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001408 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001409
shahshreya9294c8d2015-01-21 15:54:16 -08001410 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001411 "of:0000000000006025/1",
1412 "of:0000000000003015/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001413 if ptpIntentResult == main.TRUE:
1414 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001415 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001416 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001417
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001418 var9 = "Add intents for mininet hosts h16 and h26 or" +\
1419 " ONOS hosts h10 and h1A"
shahshreya9294c8d2015-01-21 15:54:16 -08001420 main.case(var9)
1421 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001422 "of:0000000000003016/1",
1423 "of:0000000000006026/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001424 if ptpIntentResult == main.TRUE:
1425 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001426 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001427 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001428
shahshreya9294c8d2015-01-21 15:54:16 -08001429 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001430 "of:0000000000006026/1",
1431 "of:0000000000003016/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001432 if ptpIntentResult == main.TRUE:
1433 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001434 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001435 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001436
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001437 var10 = "Add point intents for mininet hosts h17 and h27 or" +\
1438 " ONOS hosts h11 and h1B"
shahshreya9294c8d2015-01-21 15:54:16 -08001439 main.case(var10)
1440 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001441 "of:0000000000003017/1",
1442 "of:0000000000006027/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001443 if ptpIntentResult == main.TRUE:
1444 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001445 main.log.info( "Point to point intent install successful" )
shahshreyab189da22015-02-25 10:18:26 -08001446 #main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001447
shahshreya9294c8d2015-01-21 15:54:16 -08001448 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001449 "of:0000000000006027/1",
1450 "of:0000000000003017/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001451 if ptpIntentResult == main.TRUE:
1452 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001453 main.log.info( "Point to point intent install successful" )
shahshreyab189da22015-02-25 10:18:26 -08001454 #main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001455
1456 print(
shahshreya9294c8d2015-01-21 15:54:16 -08001457 "___________________________________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001458
1459 flowHandle = main.ONOS2.flows()
shahshreya82ecd282015-02-05 16:48:03 -08001460 #main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001461
1462 count = 1
1463 i = 8
shahshreya9294c8d2015-01-21 15:54:16 -08001464 PingResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001465 while i < 18:
1466 main.log.info(
1467 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1468 ping = main.Mininet1.pingHost(
1469 src="h" + str( i ), target="h" + str( i + 10 ) )
1470 if ping == main.FALSE and count < 5:
1471 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001472 # i = 8
1473 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001474 main.log.report( "Ping between h" +
1475 str( i ) +
1476 " and h" +
1477 str( i +
1478 10 ) +
1479 " failed. Making attempt number " +
1480 str( count ) +
1481 " in 2 seconds" )
1482 time.sleep( 2 )
1483 elif ping == main.FALSE:
1484 main.log.report( "All ping attempts between h" +
1485 str( i ) +
1486 " and h" +
1487 str( i +
1488 10 ) +
1489 "have failed" )
1490 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -08001491 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001492 elif ping == main.TRUE:
1493 main.log.info( "Ping test between h" +
1494 str( i ) +
1495 " and h" +
1496 str( i +
1497 10 ) +
1498 "passed!" )
1499 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001500 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001501 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001502 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -08001503 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001504
shahshreya9294c8d2015-01-21 15:54:16 -08001505 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001506 main.log.report(
1507 "Point intents have not ben installed correctly. Cleaning up" )
1508 # main.cleanup()
1509 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -08001510 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001511 main.log.report( "Point Intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001512
shahshreya9294c8d2015-01-21 15:54:16 -08001513 case9Result = PingResult
kelvin-onlab8a832582015-01-16 17:06:11 -08001514 utilities.assert_equals(
1515 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001516 actual=case9Result,
kelvin-onlab8a832582015-01-16 17:06:11 -08001517 onpass="Point intents addition and Pingall Test successful",
1518 onfail="Point intents addition and Pingall Test NOT successful" )