blob: ada4168764d7237d5779896a06abf20de09549f9 [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:
shahshreya7630b1c2015-04-03 15:37:14 -0700234 sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1
235 which spawns packet optical topology and copies the links
shahshreya9294c8d2015-01-21 15:54:16 -0800236 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" )
shahshreya7630b1c2015-04-03 15:37:14 -0700246 appInstallResult = main.ONOS2.featureInstall( "onos-app-optical" )
shahshreya9294c8d2015-01-21 15:54:16 -0800247 opticalMnScript = main.LincOE2.runOpticalMnScript()
kelvin-onlab8a832582015-01-16 17:06:11 -0800248
shahshreya7630b1c2015-04-03 15:37:14 -0700249 case21Result = opticalMnScript and appInstallResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800250 utilities.assert_equals(
251 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800252 actual=case21Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800253 onpass="Packet optical topology spawned successsfully",
254 onfail="Packet optical topology spawning failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800255
kelvin-onlab8a832582015-01-16 17:06:11 -0800256 def CASE22( self, main ):
257 """
shahshreya7630b1c2015-04-03 15:37:14 -0700258 Curretly we use, 10 optical switches(ROADM's) and
259 6 packet layer mininet switches each with one host.
260 Therefore, the roadmCount variable = 10,
261 packetLayerSWCount variable = 6, hostCount=6 and
262 links=42.
263 All this is hardcoded in the testcase. If the topology changes,
shahshreya9294c8d2015-01-21 15:54:16 -0800264 these hardcoded values need to be changed
kelvin-onlab8a832582015-01-16 17:06:11 -0800265 """
266 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800267 "This testcase compares the optical+packet topology against what" +
268 " is expected" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800269 main.case( "Topology comparision" )
270 main.step( "Topology comparision" )
shahshreya9294c8d2015-01-21 15:54:16 -0800271 main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
272 devicesResult = main.ONOS3.devices( jsonFormat=False )
shahshreyae6c7cf42014-11-26 16:39:01 -0800273
shahshreya9294c8d2015-01-21 15:54:16 -0800274 print "devices_result = ", devicesResult
275 devicesLinewise = devicesResult.split( "\n" )
shahshreya82ecd282015-02-05 16:48:03 -0800276 devicesLinewise = devicesLinewise[ 1: ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800277 roadmCount = 0
278 packetLayerSWCount = 0
shahshreya9294c8d2015-01-21 15:54:16 -0800279 for line in devicesLinewise:
kelvin-onlab8a832582015-01-16 17:06:11 -0800280 components = line.split( "," )
281 availability = components[ 1 ].split( "=" )[ 1 ]
282 type = components[ 3 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800283 if availability == 'true' and type == 'ROADM':
284 roadmCount += 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800285 elif availability == 'true' and type == 'SWITCH':
shahshreyae6c7cf42014-11-26 16:39:01 -0800286 packetLayerSWCount += 1
shahshreya7630b1c2015-04-03 15:37:14 -0700287 if roadmCount == 10:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800288 print "Number of Optical Switches = %d and is" % roadmCount +\
289 " correctly detected"
kelvin-onlab8a832582015-01-16 17:06:11 -0800290 main.log.info(
291 "Number of Optical Switches = " +
292 str( roadmCount ) +
293 " and is correctly detected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800294 opticalSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800295 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800296 print "Number of Optical Switches = %d and is wrong" % roadmCount
kelvin-onlab8a832582015-01-16 17:06:11 -0800297 main.log.info(
298 "Number of Optical Switches = " +
299 str( roadmCount ) +
300 " and is wrong" )
shahshreya9294c8d2015-01-21 15:54:16 -0800301 opticalSWResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800302
shahshreya7630b1c2015-04-03 15:37:14 -0700303 if packetLayerSWCount == 6:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800304 print "Number of Packet layer or mininet Switches = %d "\
305 % packetLayerSWCount + "and is correctly detected"
kelvin-onlab8a832582015-01-16 17:06:11 -0800306 main.log.info(
307 "Number of Packet layer or mininet Switches = " +
308 str( packetLayerSWCount ) +
309 " and is correctly detected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800310 packetSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800311 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800312 print "Number of Packet layer or mininet Switches = %d and"\
313 % packetLayerSWCount + " is wrong"
kelvin-onlab8a832582015-01-16 17:06:11 -0800314 main.log.info(
315 "Number of Packet layer or mininet Switches = " +
316 str( packetLayerSWCount ) +
317 " and is wrong" )
shahshreya9294c8d2015-01-21 15:54:16 -0800318 packetSWResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800319 print "_________________________________"
kelvin-onlab8a832582015-01-16 17:06:11 -0800320
shahshreya9294c8d2015-01-21 15:54:16 -0800321 linksResult = main.ONOS3.links( jsonFormat=False )
322 print "links_result = ", linksResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800323 print "_________________________________"
shahshreya7630b1c2015-04-03 15:37:14 -0700324 linkActiveCount = linksResult.count("state=ACTIVE")
325 main.log.info( "linkActiveCount = " + str( linkActiveCount ))
326 if linkActiveCount == 42:
327 linkActiveResult = main.TRUE
328 main.log.info(
329 "Number of links in ACTIVE state are correct")
330 else:
331 linkActiveResult = main.FALSE
332 main.log.info(
333 "Number of links in ACTIVE state are wrong")
kelvin-onlab8a832582015-01-16 17:06:11 -0800334
shahshreya9294c8d2015-01-21 15:54:16 -0800335 # NOTE:Since only point intents are added, there is no
336 # requirement to discover the hosts
kelvin-onlab8a832582015-01-16 17:06:11 -0800337 # Therfore, the below portion of the code is commented.
338 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800339 #Discover hosts using pingall
shahshreya9294c8d2015-01-21 15:54:16 -0800340 pingallResult = main.LincOE2.pingall()
kelvin-onlab8a832582015-01-16 17:06:11 -0800341
shahshreya9294c8d2015-01-21 15:54:16 -0800342 hostsResult = main.ONOS3.hosts( jsonFormat=False )
343 main.log.info( "hosts_result = "+hostsResult )
kelvin-onlab8a832582015-01-16 17:06:11 -0800344 main.log.info( "_________________________________" )
shahshreya9294c8d2015-01-21 15:54:16 -0800345 hostsLinewise = hostsResult.split( "\n" )
346 hostsLinewise = hostsLinewise[ 1:-1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800347 hostCount = 0
shahshreya9294c8d2015-01-21 15:54:16 -0800348 for line in hostsLinewise:
kelvin-onlab8a832582015-01-16 17:06:11 -0800349 hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800350 hostCount +=1
351 if hostCount ==2:
352 print "Number of hosts = %d and is correctly detected" %hostCount
shahshreya9294c8d2015-01-21 15:54:16 -0800353 main.log.info( "Number of hosts = " + str( hostCount ) +" and \
354 is correctly detected" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800355 hostDiscovery = main.TRUE
356 else:
357 print "Number of hosts = %d and is wrong" %hostCount
shahshreya9294c8d2015-01-21 15:54:16 -0800358 main.log.info( "Number of hosts = " + str( hostCount ) +" and \
359 is wrong" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800360 hostDiscovery = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800361 """
shahshreya7630b1c2015-04-03 15:37:14 -0700362 case22Result = opticalSWResult and packetSWResult and \
363 linkActiveResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800364 utilities.assert_equals(
365 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800366 actual=case22Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800367 onpass="Packet optical topology discovery successful",
368 onfail="Packet optical topology discovery failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800369
kelvin-onlab8a832582015-01-16 17:06:11 -0800370 def CASE23( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800371 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800372 """
shahshreya9294c8d2015-01-21 15:54:16 -0800373 Add bidirectional point intents between 2 packet layer( mininet )
374 devices and
shahshreyae6c7cf42014-11-26 16:39:01 -0800375 ping mininet hosts
kelvin-onlab8a832582015-01-16 17:06:11 -0800376 """
377 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800378 "This testcase adds bidirectional point intents between 2 " +
379 "packet layer( mininet ) devices and ping mininet hosts" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800380 main.case( "Topology comparision" )
381 main.step( "Adding point intents" )
shahshreya9294c8d2015-01-21 15:54:16 -0800382 ptpIntentResult = main.ONOS3.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -0800383 "of:0000ffffffff0001/1",
shahshreya7630b1c2015-04-03 15:37:14 -0700384 "of:0000ffffffff0005/1" )
shahshreya9294c8d2015-01-21 15:54:16 -0800385 if ptpIntentResult == main.TRUE:
386 main.ONOS3.intents( jsonFormat=False )
kelvin-onlab8a832582015-01-16 17:06:11 -0800387 main.log.info( "Point to point intent install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800388
shahshreya9294c8d2015-01-21 15:54:16 -0800389 ptpIntentResult = main.ONOS3.addPointIntent(
shahshreya7630b1c2015-04-03 15:37:14 -0700390 "of:0000ffffffff0005/1",
kelvin-onlab8a832582015-01-16 17:06:11 -0800391 "of:0000ffffffff0001/1" )
shahshreya9294c8d2015-01-21 15:54:16 -0800392 if ptpIntentResult == main.TRUE:
393 main.ONOS3.intents( jsonFormat=False )
kelvin-onlab8a832582015-01-16 17:06:11 -0800394 main.log.info( "Point to point intent install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800395
shahshreya7630b1c2015-04-03 15:37:14 -0700396 time.sleep( 30 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800397 flowHandle = main.ONOS3.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -0800398 main.log.info( "flows :" + flowHandle )
shahshreyae6c7cf42014-11-26 16:39:01 -0800399
400 # Sleep for 30 seconds to provide time for the intent state to change
shahshreya7630b1c2015-04-03 15:37:14 -0700401 time.sleep( 60 )
shahshreya9294c8d2015-01-21 15:54:16 -0800402 intentHandle = main.ONOS3.intents( jsonFormat=False )
kelvin-onlab8a832582015-01-16 17:06:11 -0800403 main.log.info( "intents :" + intentHandle )
404
shahshreya9294c8d2015-01-21 15:54:16 -0800405 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800406 count = 1
shahshreya7630b1c2015-04-03 15:37:14 -0700407 main.log.info( "\n\nh1 is Pinging h5" )
408 ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
shahshreya9294c8d2015-01-21 15:54:16 -0800409 # ping = main.LincOE2.pinghost()
kelvin-onlab8a832582015-01-16 17:06:11 -0800410 if ping == main.FALSE and count < 5:
411 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -0800412 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800413 main.log.info(
shahshreya7630b1c2015-04-03 15:37:14 -0700414 "Ping between h1 and h5 failed. Making attempt number " +
kelvin-onlab8a832582015-01-16 17:06:11 -0800415 str( count ) +
416 " in 2 seconds" )
417 time.sleep( 2 )
418 elif ping == main.FALSE:
shahshreya7630b1c2015-04-03 15:37:14 -0700419 main.log.info( "All ping attempts between h1 and h5 have failed" )
shahshreya9294c8d2015-01-21 15:54:16 -0800420 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800421 elif ping == main.TRUE:
shahshreya7630b1c2015-04-03 15:37:14 -0700422 main.log.info( "Ping test between h1 and h5 passed!" )
shahshreya9294c8d2015-01-21 15:54:16 -0800423 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800424 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800425 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -0800426 PingResult = main.ERROR
kelvin-onlab8a832582015-01-16 17:06:11 -0800427
shahshreya9294c8d2015-01-21 15:54:16 -0800428 if PingResult == main.FALSE:
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 not ben installed" +
431 " correctly. Cleaning up" )
shahshreya9294c8d2015-01-21 15:54:16 -0800432 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800433 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800434 "Point Intents for packet optical have been " +
435 "installed correctly" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800436
shahshreya9294c8d2015-01-21 15:54:16 -0800437 case23Result = PingResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800438 utilities.assert_equals(
439 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800440 actual=case23Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800441 onpass= "Point intents addition for packet optical and" +
442 "Pingall Test successful",
443 onfail= "Point intents addition for packet optical and" +
444 "Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800445
kelvin-onlab8a832582015-01-16 17:06:11 -0800446 def CASE24( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800447 import time
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800448 import json
kelvin-onlab8a832582015-01-16 17:06:11 -0800449 """
shahshreya7630b1c2015-04-03 15:37:14 -0700450 LINC uses its own switch IDs. You can use the following
451 command on the LINC console to find the mapping between
452 DPIDs and LINC IDs.
453 rp(application:get_all_key(linc)).
454
shahshreya9294c8d2015-01-21 15:54:16 -0800455 Test Rerouting of Packet Optical by bringing a port down
shahshreya7630b1c2015-04-03 15:37:14 -0700456 ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
457 so that link
458 ( between switch1 port20 - switch5 port50 ) is inactive
shahshreya9294c8d2015-01-21 15:54:16 -0800459 and do a ping test. If rerouting is successful,
460 ping should pass. also check the flows
kelvin-onlab8a832582015-01-16 17:06:11 -0800461 """
462 main.log.report(
463 "This testcase tests rerouting and pings mininet hosts" )
464 main.case( "Test rerouting and pings mininet hosts" )
shahshreya7630b1c2015-04-03 15:37:14 -0700465 main.step( "Attach to the Linc-OE session" )
466 attachConsole = main.LincOE1.attachLincOESession()
467 print "attachConsole = ", attachConsole
468
kelvin-onlab8a832582015-01-16 17:06:11 -0800469 main.step( "Bring a port down and verify the link state" )
shahshreya7630b1c2015-04-03 15:37:14 -0700470 main.LincOE1.portDown( swId="9", ptId="20" )
shahshreya9294c8d2015-01-21 15:54:16 -0800471 linksNonjson = main.ONOS3.links( jsonFormat=False )
472 main.log.info( "links = " + linksNonjson )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800473
shahshreya7630b1c2015-04-03 15:37:14 -0700474 linkInactiveCount = linksNonjson.count("state=INACTIVE")
475 main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
476 if linkInactiveCount == 2:
477 main.log.info(
478 "Number of links in INACTIVE state are correct")
479 else:
480 main.log.info(
481 "Number of links in INACTIVE state are wrong")
482
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800483 links = main.ONOS3.links()
kelvin-onlab8a832582015-01-16 17:06:11 -0800484 main.log.info( "links = " + links )
485
shahshreya9294c8d2015-01-21 15:54:16 -0800486 linksResult = json.loads( links )
487 linksStateResult = main.FALSE
488 for item in linksResult:
kelvin-onlab8a832582015-01-16 17:06:11 -0800489 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
shahshreya7630b1c2015-04-03 15:37:14 -0700490 'src' ][ 'port' ] == "20":
491 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
492 'dst' ][ 'port' ] == "50":
shahshreya9294c8d2015-01-21 15:54:16 -0800493 linksState = item[ 'state' ]
494 if linksState == "INACTIVE":
kelvin-onlab8a832582015-01-16 17:06:11 -0800495 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800496 "Links state is inactive as expected due to one" +
497 " of the ports being down" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800498 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800499 "Links state is inactive as expected due to one" +
500 " of the ports being down" )
shahshreya9294c8d2015-01-21 15:54:16 -0800501 linksStateResult = main.TRUE
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800502 break
503 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800504 main.log.info(
505 "Links state is not inactive as expected" )
506 main.log.report(
507 "Links state is not inactive as expected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800508 linksStateResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800509
shahshreya9294c8d2015-01-21 15:54:16 -0800510 print "links_state_result = ", linksStateResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800511 time.sleep( 10 )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800512 flowHandle = main.ONOS3.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -0800513 main.log.info( "flows :" + flowHandle )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800514
kelvin-onlab8a832582015-01-16 17:06:11 -0800515 main.step( "Verify Rerouting by a ping test" )
shahshreya9294c8d2015-01-21 15:54:16 -0800516 PingResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800517 count = 1
shahshreya7630b1c2015-04-03 15:37:14 -0700518 main.log.info( "\n\nh1 is Pinging h5" )
519 ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
shahshreya9294c8d2015-01-21 15:54:16 -0800520 # ping = main.LincOE2.pinghost()
kelvin-onlab8a832582015-01-16 17:06:11 -0800521 if ping == main.FALSE and count < 5:
522 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -0800523 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800524 main.log.info(
shahshreya7630b1c2015-04-03 15:37:14 -0700525 "Ping between h1 and h5 failed. Making attempt number " +
kelvin-onlab8a832582015-01-16 17:06:11 -0800526 str( count ) +
527 " in 2 seconds" )
528 time.sleep( 2 )
529 elif ping == main.FALSE:
shahshreya7630b1c2015-04-03 15:37:14 -0700530 main.log.info( "All ping attempts between h1 and h5 have failed" )
shahshreya9294c8d2015-01-21 15:54:16 -0800531 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800532 elif ping == main.TRUE:
shahshreya7630b1c2015-04-03 15:37:14 -0700533 main.log.info( "Ping test between h1 and h5 passed!" )
shahshreya9294c8d2015-01-21 15:54:16 -0800534 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800535 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800536 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -0800537 PingResult = main.ERROR
shahshreyae6c7cf42014-11-26 16:39:01 -0800538
shahshreya9294c8d2015-01-21 15:54:16 -0800539 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800540 main.log.report( "Ping test successful " )
shahshreya9294c8d2015-01-21 15:54:16 -0800541 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800542 main.log.report( "Ping test failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800543
shahshreya9294c8d2015-01-21 15:54:16 -0800544 case24Result = PingResult and linksStateResult
545 utilities.assert_equals( expect=main.TRUE, actual=case24Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800546 onpass="Packet optical rerouting successful",
547 onfail="Packet optical rerouting failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800548
kelvin-onlab8a832582015-01-16 17:06:11 -0800549 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800550 import re
551 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800552 main.log.report( "This testcase is testing the assignment of" +
553 " all the switches to all the controllers and" +
shahshreyab189da22015-02-25 10:18:26 -0800554 " discovering the hosts in reactive mode" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800555 main.log.report( "__________________________________" )
556 main.case( "Pingall Test" )
557 main.step( "Assigning switches to controllers" )
shahshreya9294c8d2015-01-21 15:54:16 -0800558 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
559 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
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 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800563 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800564 ip1=ONOS1Ip,
565 port1=ONOS1Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800566 elif i >= 2 and i < 5:
shahshreya9294c8d2015-01-21 15:54:16 -0800567 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800568 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800569 ip1=ONOS1Ip,
570 port1=ONOS1Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800571 elif i >= 5 and i < 8:
shahshreya9294c8d2015-01-21 15:54:16 -0800572 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800573 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800574 ip1=ONOS1Ip,
575 port1=ONOS1Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800576 elif i >= 8 and i < 18:
shahshreya9294c8d2015-01-21 15:54:16 -0800577 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800578 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800579 ip1=ONOS1Ip,
580 port1=ONOS1Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800581 elif i >= 18 and i < 28:
shahshreya9294c8d2015-01-21 15:54:16 -0800582 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800583 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800584 ip1=ONOS1Ip,
585 port1=ONOS1Port )
shahshreya4e13a062014-11-11 16:46:18 -0800586 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800587 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800588 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800589 ip1=ONOS1Ip,
590 port1=ONOS1Port )
591 SwitchMastership = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800592 for i in range( 1, 29 ):
593 if i == 1:
shahshreya9294c8d2015-01-21 15:54:16 -0800594 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800595 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800596 if re.search( "tcp:" + ONOS1Ip, response ):
597 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800598 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800599 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800600 elif i >= 2 and i < 5:
shahshreya9294c8d2015-01-21 15:54:16 -0800601 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800602 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800603 if re.search( "tcp:" + ONOS1Ip, response ):
604 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800605 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800606 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800607 elif i >= 5 and i < 8:
shahshreya9294c8d2015-01-21 15:54:16 -0800608 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800609 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800610 if re.search( "tcp:" + ONOS1Ip, response ):
611 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800612 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800613 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800614 elif i >= 8 and i < 18:
shahshreya9294c8d2015-01-21 15:54:16 -0800615 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800616 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800617 if re.search( "tcp:" + ONOS1Ip, response ):
618 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800619 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800620 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800621 elif i >= 18 and i < 28:
shahshreya9294c8d2015-01-21 15:54:16 -0800622 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800623 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800624 if re.search( "tcp:" + ONOS1Ip, response ):
625 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800626 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800627 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800628 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800629 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800630 print( "Response is" + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800631 if re.search( "tcp:" + ONOS1Ip, response ):
632 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800633 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800634 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800635
shahshreya9294c8d2015-01-21 15:54:16 -0800636 if SwitchMastership == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800637 main.log.report( "Controller assignmnet successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800638 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800639 main.log.report( "Controller assignmnet failed" )
640 utilities.assert_equals(
641 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800642 actual=SwitchMastership,
kelvin-onlab8a832582015-01-16 17:06:11 -0800643 onpass="MasterControllers assigned correctly" )
644 """
645 for i in range ( 1,29 ):
shahshreya9294c8d2015-01-21 15:54:16 -0800646 main.Mininet1.assignSwController( sw=str( i ),count=5,
647 ip1=ONOS1Ip,port1=ONOS1Port,
648 ip2=ONOS2Ip,port2=ONOS2Port,
649 ip3=ONOS3Ip,port3=ONOS3Port,
650 ip4=ONOS4Ip,port4=ONOS4Port,
651 ip5=ONOS5Ip,port5=ONOS5Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800652 """
653 # REACTIVE FWD test
shahshreya4e13a062014-11-11 16:46:18 -0800654
kelvin-onlab8a832582015-01-16 17:06:11 -0800655 main.step( "Get list of hosts from Mininet" )
shahshreya9294c8d2015-01-21 15:54:16 -0800656 hostList = main.Mininet1.getHosts()
657 main.log.info( hostList )
shahshreya4e13a062014-11-11 16:46:18 -0800658
kelvin-onlab8a832582015-01-16 17:06:11 -0800659 main.step( "Get host list in ONOS format" )
shahshreya9294c8d2015-01-21 15:54:16 -0800660 hostOnosList = main.ONOS2.getHostsId( hostList )
661 main.log.info( hostOnosList )
kelvin-onlab8a832582015-01-16 17:06:11 -0800662 # time.sleep( 5 )
663
664 main.step( "Pingall" )
shahshreya9294c8d2015-01-21 15:54:16 -0800665 pingResult = main.FALSE
shahshreya82ecd282015-02-05 16:48:03 -0800666 time1 = time.time()
667 pingResult = main.Mininet1.pingall()
668 time2 = time.time()
669 print "Time for pingall: %2f seconds" % ( time2 - time1 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800670
shahshreya9294c8d2015-01-21 15:54:16 -0800671 # Start onos cli again because u might have dropped out of
672 # onos prompt to the shell prompt
kelvin-onlab8a832582015-01-16 17:06:11 -0800673 # if there was no activity
shahshreya9294c8d2015-01-21 15:54:16 -0800674 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800675
shahshreya9294c8d2015-01-21 15:54:16 -0800676 case4Result = SwitchMastership and pingResult
677 if pingResult == main.TRUE:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800678 main.log.report( "Pingall Test in reactive mode to" +
679 " discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800680 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800681 main.log.report( "Pingall Test in reactive mode to" +
682 " discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800683
kelvin-onlab8a832582015-01-16 17:06:11 -0800684 utilities.assert_equals(
685 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800686 actual=case4Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800687 onpass="Controller assignment and Pingall Test successful",
688 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800689
kelvin-onlab8a832582015-01-16 17:06:11 -0800690 def CASE10( self ):
691 main.log.report(
692 "This testcase uninstalls the reactive forwarding app" )
693 main.log.report( "__________________________________" )
694 main.case( "Uninstalling reactive forwarding app" )
695 # Unistall onos-app-fwd app to disable reactive forwarding
shahshreya9294c8d2015-01-21 15:54:16 -0800696 appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800697 main.log.info( "onos-app-fwd uninstalled" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800698
shahshreya9294c8d2015-01-21 15:54:16 -0800699 # After reactive forwarding is disabled, the reactive flows on
700 # switches timeout in 10-15s
kelvin-onlab8a832582015-01-16 17:06:11 -0800701 # So sleep for 15s
702 time.sleep( 15 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800703
704 flows = main.ONOS2.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -0800705 main.log.info( flows )
shahshreyae6c7cf42014-11-26 16:39:01 -0800706
shahshreya9294c8d2015-01-21 15:54:16 -0800707 case10Result = appUninstallResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800708 utilities.assert_equals(
709 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800710 actual=case10Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800711 onpass="Reactive forwarding app uninstallation successful",
712 onfail="Reactive forwarding app uninstallation failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800713
shahshreyab189da22015-02-25 10:18:26 -0800714
715 def CASE11( self ):
716 # NOTE: This testcase require reactive forwarding mode enabled
717 # NOTE: in the beginning and then uninstall it before adding
718 # NOTE: point intents. Again the app is installed so that
719 # NOTE: testcase 10 can be ran successively
720 import time
721 main.log.report(
722 "This testcase moves a host from one switch to another to add" +
723 "point intents between them and then perform ping" )
724 main.log.report( "__________________________________" )
725 main.log.info( "Moving host from one switch to another" )
726 main.case( "Moving host from a device and attach it to another device" )
727 main.step( "Moving host h9 from device s9 and attach it to s8" )
728 main.Mininet1.moveHost(host = 'h9', oldSw = 's9', newSw = 's8')
729
730 time.sleep(15) #Time delay to have all the flows ready
731 main.step( "Pingall" )
732 pingResult = main.FALSE
733 time1 = time.time()
734 pingResult = main.Mininet1.pingall()
735 time2 = time.time()
736 print "Time for pingall: %2f seconds" % ( time2 - time1 )
737
738 hosts = main.ONOS2.hosts( jsonFormat = False )
739 main.log.info( hosts )
740
741 main.case( "Uninstalling reactive forwarding app" )
742 # Unistall onos-app-fwd app to disable reactive forwarding
743 appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
744 main.log.info( "onos-app-fwd uninstalled" )
745
746 main.step( "Add point intents between hosts on the same device")
747 ptpIntentResult = main.ONOS2.addPointIntent(
748 "of:0000000000003008/1",
749 "of:0000000000003008/3" )
750 if ptpIntentResult == main.TRUE:
751 getIntentResult = main.ONOS2.intents()
752 main.log.info( "Point to point intent install successful" )
753 # main.log.info( getIntentResult )
754
755 ptpIntentResult = main.ONOS2.addPointIntent(
756 "of:0000000000003008/3",
757 "of:0000000000003008/1" )
758 if ptpIntentResult == main.TRUE:
759 getIntentResult = main.ONOS2.intents()
760 main.log.info( "Point to point intent install successful" )
761 # main.log.info( getIntentResult )
762
763 main.case( "Ping hosts on the same devices" )
764 ping = main.Mininet1.pingHost( src = 'h8', target = 'h9' )
765
766 '''
767 main.case( "Installing reactive forwarding app" )
768 # Install onos-app-fwd app to enable reactive forwarding
769 appUninstallResult = main.ONOS2.featureInstall( "onos-app-fwd" )
770 main.log.info( "onos-app-fwd installed" )
771 '''
772
773 if ping == main.FALSE:
774 main.log.report(
775 "Point intents for hosts on same devices haven't" +
776 " been installed correctly. Cleaning up" )
777 if ping == main.TRUE:
778 main.log.report(
779 "Point intents for hosts on same devices" +
780 "installed correctly. Cleaning up" )
781
782 case11Result = ping and pingResult
783 utilities.assert_equals(
shahshreya74cca802015-02-26 12:24:01 -0800784 expect = main.TRUE,
785 actual = case11Result,
786 onpass = "Point intents for hosts on same devices" +
shahshreyab189da22015-02-25 10:18:26 -0800787 "Ping Test successful",
shahshreya74cca802015-02-26 12:24:01 -0800788 onfail = "Point intents for hosts on same devices" +
shahshreyab189da22015-02-25 10:18:26 -0800789 "Ping Test NOT successful" )
shahshreya74cca802015-02-26 12:24:01 -0800790
791
792 def CASE12( self ):
793 """
shahshreyaed683ed2015-03-16 15:04:40 -0700794 Verify the default flows on each switch in proactive mode
shahshreya74cca802015-02-26 12:24:01 -0800795 """
shahshreyaed683ed2015-03-16 15:04:40 -0700796 main.log.report( "This testcase is verifying num of default" +
797 " flows on each switch" )
798 main.log.report( "__________________________________" )
799 main.case( "Verify num of default flows on each switch" )
800 main.step( "Obtaining the device id's and flowrule count on them" )
801
shahshreya74cca802015-02-26 12:24:01 -0800802 case12Result = main.TRUE
803 idList = main.ONOS2.getAllDevicesId()
804 for id in idList:
shahshreyaed683ed2015-03-16 15:04:40 -0700805 count = main.ONOS2.FlowAddedCount( id )
806 main.log.info("count = " +count)
807 if int(count) != 3:
shahshreya74cca802015-02-26 12:24:01 -0800808 case12Result = main.FALSE
shahshreyaed683ed2015-03-16 15:04:40 -0700809 break
shahshreya74cca802015-02-26 12:24:01 -0800810 utilities.assert_equals(
811 expect=main.TRUE,
812 actual=case12Result,
813 onpass = "Expected default num of flows exist",
814 onfail = "Expected default num of flows do not exist")
815
816
shahshreyab189da22015-02-25 10:18:26 -0800817
818
kelvin-onlab8a832582015-01-16 17:06:11 -0800819 def CASE6( self ):
shahshreyab189da22015-02-25 10:18:26 -0800820 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800821 main.log.report( "This testcase is testing the addition of" +
822 " host intents and then does pingall" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800823 main.log.report( "__________________________________" )
824 main.case( "Obtaining host id's" )
825 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800826 hosts = main.ONOS2.hosts()
shahshreya9294c8d2015-01-21 15:54:16 -0800827 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800828
kelvin-onlab8a832582015-01-16 17:06:11 -0800829 main.step( "Get all devices id" )
shahshreya9294c8d2015-01-21 15:54:16 -0800830 devicesIdList = main.ONOS2.getAllDevicesId()
831 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -0800832
shahshreya9294c8d2015-01-21 15:54:16 -0800833 # ONOS displays the hosts in hex format unlike mininet which does
834 # in decimal format
kelvin-onlab8a832582015-01-16 17:06:11 -0800835 # So take care while adding intents
836 """
shahshreya9294c8d2015-01-21 15:54:16 -0800837 main.step( "Add host-to-host intents for mininet hosts h8 and h18 or
838 ONOS hosts h8 and h12" )
839 hthIntentResult = main.ONOS2.addHostIntent(
840 "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
841 hthIntentResult = main.ONOS2.addHostIntent(
842 "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
843 hthIntentResult = main.ONOS2.addHostIntent(
844 "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
845 hthIntentResult = main.ONOS2.addHostIntent(
846 "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
847 hthIntentResult = main.ONOS2.addHostIntent(
848 "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
849 hthIntentResult = main.ONOS2.addHostIntent(
850 "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
851 hthIntentResult = main.ONOS2.addHostIntent(
852 "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
853 hthIntentResult = main.ONOS2.addHostIntent(
854 "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
855 hthIntentResult = main.ONOS2.addHostIntent(
856 "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
857 hthIntentResult = main.ONOS2.addHostIntent(
858 "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
859 print "______________________________________________________"
kelvin-onlab8a832582015-01-16 17:06:11 -0800860 """
861 for i in range( 8, 18 ):
862 main.log.info(
shahshreya9294c8d2015-01-21 15:54:16 -0800863 "Adding host intent between h" + str( i ) +
864 " and h" + str( i + 10 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800865 host1 = "00:00:00:00:00:" + \
866 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
867 host2 = "00:00:00:00:00:" + \
868 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
869 # NOTE: get host can return None
shahshreya7630b1c2015-04-03 15:37:14 -0700870 if host1:
871 host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
872 if host2:
873 host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
874 if host1Id and host2Id:
875 main.ONOS2.addHostIntent( host1Id, host2Id )
kelvin-onlab8a832582015-01-16 17:06:11 -0800876
877 time.sleep( 10 )
shahshreya9294c8d2015-01-21 15:54:16 -0800878 hIntents = main.ONOS2.intents( jsonFormat=False )
879 main.log.info( "intents:" + hIntents )
shahshreyab189da22015-02-25 10:18:26 -0800880 flows = main.ONOS2.flows()
881 main.log.info( "flows:" + flows )
shahshreya4e13a062014-11-11 16:46:18 -0800882
883 count = 1
884 i = 8
shahshreya9294c8d2015-01-21 15:54:16 -0800885 PingResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800886 # while i<10:
887 while i < 18:
888 main.log.info(
889 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
890 ping = main.Mininet1.pingHost(
891 src="h" + str( i ), target="h" + str( i + 10 ) )
892 if ping == main.FALSE and count < 5:
893 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -0800894 # i = 8
895 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800896 main.log.report( "Ping between h" +
897 str( i ) +
898 " and h" +
899 str( i +
900 10 ) +
901 " failed. Making attempt number " +
902 str( count ) +
903 " in 2 seconds" )
904 time.sleep( 2 )
905 elif ping == main.FALSE:
906 main.log.report( "All ping attempts between h" +
907 str( i ) +
908 " and h" +
909 str( i +
910 10 ) +
911 "have failed" )
912 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -0800913 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800914 elif ping == main.TRUE:
915 main.log.info( "Ping test between h" +
916 str( i ) +
917 " and h" +
918 str( i +
919 10 ) +
920 "passed!" )
921 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -0800922 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800923 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800924 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -0800925 PingResult = main.ERROR
926 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800927 main.log.report(
shahshreya9294c8d2015-01-21 15:54:16 -0800928 "Ping all test after Host intent addition failed.Cleaning up" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800929 # main.cleanup()
930 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -0800931 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800932 main.log.report(
933 "Ping all test after Host intent addition successful" )
934
shahshreya9294c8d2015-01-21 15:54:16 -0800935 case6Result = PingResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800936 utilities.assert_equals(
937 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800938 actual=case6Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800939 onpass="Pingall Test after Host intents addition successful",
940 onfail="Pingall Test after Host intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800941
kelvin-onlab8a832582015-01-16 17:06:11 -0800942 def CASE5( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800943 import json
kelvin-onlab8a832582015-01-16 17:06:11 -0800944 # assumes that sts is already in you PYTHONPATH
945 from sts.topology.teston_topology import TestONTopology
shahshreya9294c8d2015-01-21 15:54:16 -0800946 # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800947 main.log.report( "This testcase is testing if all ONOS nodes" +
948 " are in topology sync with mininet" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800949 main.log.report( "__________________________________" )
950 main.case( "Comparing Mininet topology with the topology of ONOS" )
951 main.step( "Start continuous pings" )
952 main.Mininet2.pingLong(
953 src=main.params[ 'PING' ][ 'source1' ],
954 target=main.params[ 'PING' ][ 'target1' ],
955 pingTime=500 )
956 main.Mininet2.pingLong(
957 src=main.params[ 'PING' ][ 'source2' ],
958 target=main.params[ 'PING' ][ 'target2' ],
959 pingTime=500 )
960 main.Mininet2.pingLong(
961 src=main.params[ 'PING' ][ 'source3' ],
962 target=main.params[ 'PING' ][ 'target3' ],
963 pingTime=500 )
964 main.Mininet2.pingLong(
965 src=main.params[ 'PING' ][ 'source4' ],
966 target=main.params[ 'PING' ][ 'target4' ],
967 pingTime=500 )
968 main.Mininet2.pingLong(
969 src=main.params[ 'PING' ][ 'source5' ],
970 target=main.params[ 'PING' ][ 'target5' ],
971 pingTime=500 )
972 main.Mininet2.pingLong(
973 src=main.params[ 'PING' ][ 'source6' ],
974 target=main.params[ 'PING' ][ 'target6' ],
975 pingTime=500 )
976 main.Mininet2.pingLong(
977 src=main.params[ 'PING' ][ 'source7' ],
978 target=main.params[ 'PING' ][ 'target7' ],
979 pingTime=500 )
980 main.Mininet2.pingLong(
981 src=main.params[ 'PING' ][ 'source8' ],
982 target=main.params[ 'PING' ][ 'target8' ],
983 pingTime=500 )
984 main.Mininet2.pingLong(
985 src=main.params[ 'PING' ][ 'source9' ],
986 target=main.params[ 'PING' ][ 'target9' ],
987 pingTime=500 )
988 main.Mininet2.pingLong(
989 src=main.params[ 'PING' ][ 'source10' ],
990 target=main.params[ 'PING' ][ 'target10' ],
991 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -0800992
kelvin-onlab8a832582015-01-16 17:06:11 -0800993 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800994 global ctrls
995 ctrls = []
996 count = 1
997 while True:
998 temp = ()
kelvin-onlab8a832582015-01-16 17:06:11 -0800999 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
1000 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
1001 temp = temp + ( "ONOS" + str( count ), )
1002 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
1003 temp = temp + \
1004 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
1005 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -08001006 count = count + 1
1007 else:
1008 break
1009 global MNTopo
kelvin-onlab8a832582015-01-16 17:06:11 -08001010 Topo = TestONTopology(
1011 main.Mininet1,
1012 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -08001013 MNTopo = Topo
1014
shahshreya9294c8d2015-01-21 15:54:16 -08001015 TopologyCheck = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001016 main.step( "Compare ONOS Topology to MN Topology" )
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
kelvin-onlab8a832582015-01-16 17:06:11 -08001032
shahshreya4e13a062014-11-11 16:46:18 -08001033 print "***********************"
1034 if result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001035 main.log.report( "ONOS" + " Topology matches MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001036 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001037 main.log.report( "ONOS" + " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001038
kelvin-onlab8a832582015-01-16 17:06:11 -08001039 utilities.assert_equals(
1040 expect=main.TRUE,
1041 actual=result,
1042 onpass="ONOS" +
1043 " Topology matches MN Topology",
1044 onfail="ONOS" +
1045 " Topology does not match MN Topology" )
1046
shahshreya9294c8d2015-01-21 15:54:16 -08001047 TopologyCheck = TopologyCheck and result
kelvin-onlab8a832582015-01-16 17:06:11 -08001048 utilities.assert_equals(
1049 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001050 actual=TopologyCheck,
kelvin-onlab8a832582015-01-16 17:06:11 -08001051 onpass="Topology checks passed",
1052 onfail="Topology checks failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001053
kelvin-onlab8a832582015-01-16 17:06:11 -08001054 def CASE7( self, main ):
shahshreya9294c8d2015-01-21 15:54:16 -08001055 from sts.topology.teston_topology import TestONTopology
shahshreya4e13a062014-11-11 16:46:18 -08001056
shahshreya9294c8d2015-01-21 15:54:16 -08001057 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -08001058
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001059 main.log.report( "This testscase is killing a link to ensure that" +
1060 " link discovery is consistent" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001061 main.log.report( "__________________________________" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001062 main.log.report( "Killing a link to ensure that link discovery" +
1063 " is consistent" )
1064 main.case( "Killing a link to Ensure that Link Discovery" +
1065 "is Working Properly" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001066 """
1067 main.step( "Start continuous pings" )
1068
1069 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001070 target=main.params[ 'PING' ][ 'target1' ],
1071 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001072 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001073 target=main.params[ 'PING' ][ 'target2' ],
1074 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001075 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001076 target=main.params[ 'PING' ][ 'target3' ],
1077 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001078 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001079 target=main.params[ 'PING' ][ 'target4' ],
1080 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001081 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001082 target=main.params[ 'PING' ][ 'target5' ],
1083 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001084 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001085 target=main.params[ 'PING' ][ 'target6' ],
1086 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001087 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001088 target=main.params[ 'PING' ][ 'target7' ],
1089 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001090 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001091 target=main.params[ 'PING' ][ 'target8' ],
1092 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001093 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001094 target=main.params[ 'PING' ][ 'target9' ],
1095 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001096 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001097 target=main.params[ 'PING' ][ 'target10' ],
1098 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001099 """
1100 main.step( "Determine the current number of switches and links" )
shahshreya9294c8d2015-01-21 15:54:16 -08001101 topologyOutput = main.ONOS2.topology()
1102 topologyResult = main.ONOS1.getTopology( topologyOutput )
shahshreyaed683ed2015-03-16 15:04:40 -07001103 activeSwitches = topologyResult[ 'deviceCount' ]
1104 links = topologyResult[ 'linkCount' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001105 print "activeSwitches = ", type( activeSwitches )
1106 print "links = ", type( links )
1107 main.log.info(
1108 "Currently there are %s switches and %s links" %
1109 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -08001110
kelvin-onlab8a832582015-01-16 17:06:11 -08001111 main.step( "Kill Link between s3 and s28" )
1112 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
shahshreya9294c8d2015-01-21 15:54:16 -08001113 time.sleep( linkSleep )
1114 topologyOutput = main.ONOS2.topology()
1115 LinkDown = main.ONOS1.checkStatus(
1116 topologyOutput, activeSwitches, str(
kelvin-onlab8a832582015-01-16 17:06:11 -08001117 int( links ) - 2 ) )
shahshreya9294c8d2015-01-21 15:54:16 -08001118 if LinkDown == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001119 main.log.report( "Link Down discovered properly" )
1120 utilities.assert_equals(
1121 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001122 actual=LinkDown,
kelvin-onlab8a832582015-01-16 17:06:11 -08001123 onpass="Link Down discovered properly",
1124 onfail="Link down was not discovered in " +
shahshreya9294c8d2015-01-21 15:54:16 -08001125 str( linkSleep ) +
kelvin-onlab8a832582015-01-16 17:06:11 -08001126 " seconds" )
1127
1128 # Check ping result here..add code for it
1129
1130 main.step( "Bring link between s3 and s28 back up" )
shahshreya9294c8d2015-01-21 15:54:16 -08001131 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
1132 time.sleep( linkSleep )
1133 topologyOutput = main.ONOS2.topology()
1134 LinkUp = main.ONOS1.checkStatus(
1135 topologyOutput,
kelvin-onlab8a832582015-01-16 17:06:11 -08001136 activeSwitches,
1137 str( links ) )
shahshreya9294c8d2015-01-21 15:54:16 -08001138 if LinkUp == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001139 main.log.report( "Link up discovered properly" )
1140 utilities.assert_equals(
1141 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001142 actual=LinkUp,
kelvin-onlab8a832582015-01-16 17:06:11 -08001143 onpass="Link up discovered properly",
1144 onfail="Link up was not discovered in " +
shahshreya9294c8d2015-01-21 15:54:16 -08001145 str( linkSleep ) +
kelvin-onlab8a832582015-01-16 17:06:11 -08001146 " seconds" )
1147
1148 # NOTE Check ping result here..add code for it
1149
1150 main.step( "Compare ONOS Topology to MN Topology" )
1151 Topo = TestONTopology(
1152 main.Mininet1,
1153 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -08001154 MNTopo = Topo
shahshreya9294c8d2015-01-21 15:54:16 -08001155 TopologyCheck = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001156
shahshreya9294c8d2015-01-21 15:54:16 -08001157 devicesJson = main.ONOS2.devices()
1158 linksJson = main.ONOS2.links()
1159 portsJson = main.ONOS2.ports()
kelvin-onlab8a832582015-01-16 17:06:11 -08001160
shahshreya9294c8d2015-01-21 15:54:16 -08001161 result1 = main.Mininet1.compareSwitches(
kelvin-onlab8a832582015-01-16 17:06:11 -08001162 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001163 json.loads( devicesJson ) )
1164 result2 = main.Mininet1.compareLinks(
kelvin-onlab8a832582015-01-16 17:06:11 -08001165 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001166 json.loads( linksJson ) )
1167 # result3 = main.Mininet1.comparePorts(
1168 # MNTopo, json.loads( portsJson ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001169
shahshreya9294c8d2015-01-21 15:54:16 -08001170 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001171 result = result1 and result2
1172 print "***********************"
kelvin-onlab8a832582015-01-16 17:06:11 -08001173
shahshreya4e13a062014-11-11 16:46:18 -08001174 if result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001175 main.log.report( "ONOS" + " Topology matches MN Topology" )
1176 utilities.assert_equals(
1177 expect=main.TRUE,
1178 actual=result,
1179 onpass="ONOS" +
1180 " Topology matches MN Topology",
1181 onfail="ONOS" +
1182 " Topology does not match MN Topology" )
1183
shahshreya9294c8d2015-01-21 15:54:16 -08001184 TopologyCheck = TopologyCheck and result
kelvin-onlab8a832582015-01-16 17:06:11 -08001185 utilities.assert_equals(
1186 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001187 actual=TopologyCheck,
kelvin-onlab8a832582015-01-16 17:06:11 -08001188 onpass="Topology checks passed",
1189 onfail="Topology checks failed" )
1190
shahshreya9294c8d2015-01-21 15:54:16 -08001191 result = LinkDown and LinkUp and TopologyCheck
kelvin-onlab8a832582015-01-16 17:06:11 -08001192 utilities.assert_equals( expect=main.TRUE, actual=result,
1193 onpass="Link failure is discovered correctly",
1194 onfail="Link Discovery failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001195
kelvin-onlab8a832582015-01-16 17:06:11 -08001196 def CASE8( self ):
1197 """
shahshreya82ecd282015-02-05 16:48:03 -08001198 Intent removal
kelvin-onlab8a832582015-01-16 17:06:11 -08001199 """
shahshreya82ecd282015-02-05 16:48:03 -08001200 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001201 main.log.report( "This testcase removes any previously added intents" +
shahshreya82ecd282015-02-05 16:48:03 -08001202 " before adding any new set of intents" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001203 main.log.report( "__________________________________" )
shahshreya82ecd282015-02-05 16:48:03 -08001204 main.log.info( "intent removal" )
1205 main.case( "Removing installed intents" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001206 main.step( "Obtain the intent id's" )
shahshreya9294c8d2015-01-21 15:54:16 -08001207 intentResult = main.ONOS2.intents( jsonFormat=False )
1208 main.log.info( "intent_result = " + intentResult )
shahshreya9294c8d2015-01-21 15:54:16 -08001209 intentLinewise = intentResult.split( "\n" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001210
shahshreyab189da22015-02-25 10:18:26 -08001211 intentList = [line for line in intentLinewise \
1212 if line.startswith( "id=")]
1213 intentids = [line.split( "," )[ 0 ].split( "=" )[ 1 ] for line in \
1214 intentList]
shahshreya4e13a062014-11-11 16:46:18 -08001215 for id in intentids:
1216 print "id = ", id
kelvin-onlab8a832582015-01-16 17:06:11 -08001217
1218 main.step(
1219 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -08001220 for id in intentids:
shahshreya9294c8d2015-01-21 15:54:16 -08001221 main.ONOS2.removeIntent( intentId=id )
kelvin-onlab8a832582015-01-16 17:06:11 -08001222
shahshreya9294c8d2015-01-21 15:54:16 -08001223 intentResult = main.ONOS2.intents( jsonFormat=False )
1224 main.log.info( "intent_result = " + intentResult )
shahshreyab189da22015-02-25 10:18:26 -08001225
1226 intentList = [line for line in intentResult.split( "\n" ) \
1227 if line.startswith( "id=")]
1228 intentState = [line.split( "," )[ 1 ].split( "=" )[ 1 ] for line in \
1229 intentList]
1230 for state in intentState:
1231 print state
1232
1233 case8Result = main.TRUE
1234 for state in intentState:
1235 if state != 'WITHDRAWN':
1236 case8Result = main.FALSE
1237 break
1238
shahshreya9294c8d2015-01-21 15:54:16 -08001239 if case8Result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001240 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001241 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001242 main.log.report( "Intent removal failed" )
1243
shahshreya9294c8d2015-01-21 15:54:16 -08001244 PingResult = main.TRUE
1245 if case8Result == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001246 i = 8
kelvin-onlab8a832582015-01-16 17:06:11 -08001247 while i < 18:
1248 main.log.info(
1249 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1250 ping = main.Mininet1.pingHost(
1251 src="h" + str( i ), target="h" + str( i + 10 ) )
1252 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001253 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -08001254 PingResult = PingResult and main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001255 elif ping == main.FALSE:
1256 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001257 PingResult = PingResult and main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -08001258 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001259 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -08001260 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001261
kelvin-onlab8a832582015-01-16 17:06:11 -08001262 # Note: If the ping result failed, that means the intents have been
1263 # withdrawn correctly.
shahshreya9294c8d2015-01-21 15:54:16 -08001264 if PingResult == main.TRUE:
shahshreya82ecd282015-02-05 16:48:03 -08001265 main.log.report( "Installed intents have not been withdrawn correctly" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001266 # main.cleanup()
1267 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -08001268 if PingResult == main.FALSE:
shahshreya82ecd282015-02-05 16:48:03 -08001269 main.log.report( "Installed intents have been withdrawn correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001270
shahshreya9294c8d2015-01-21 15:54:16 -08001271 case8Result = case8Result and PingResult
shahshreyae6c7cf42014-11-26 16:39:01 -08001272
shahshreya9294c8d2015-01-21 15:54:16 -08001273 if case8Result == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001274 main.log.report( "Intent removal successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001275 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001276 main.log.report( "Intent removal failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001277
shahshreya9294c8d2015-01-21 15:54:16 -08001278 utilities.assert_equals( expect=main.FALSE, actual=case8Result,
1279 onpass="Intent removal test passed",
1280 onfail="Intent removal test failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001281
kelvin-onlab8a832582015-01-16 17:06:11 -08001282 def CASE9( self ):
1283 main.log.report(
1284 "This testcase adds point intents and then does pingall" )
1285 main.log.report( "__________________________________" )
1286 main.log.info( "Adding point intents" )
1287 main.case(
shahshreya82ecd282015-02-05 16:48:03 -08001288 "Adding bidirectional point for mn hosts" +
1289 "( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22, " +
1290 "h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001291
1292 main.step( "Add point intents for mn hosts h8 and h18 or" +
1293 "ONOS hosts h8 and h12" )
1294 # main.step(var1)
shahshreya9294c8d2015-01-21 15:54:16 -08001295 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001296 "of:0000000000003008/1",
1297 "of:0000000000006018/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001298 if ptpIntentResult == main.TRUE:
1299 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001300 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001301 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001302
shahshreya9294c8d2015-01-21 15:54:16 -08001303 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001304 "of:0000000000006018/1",
1305 "of:0000000000003008/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001306 if ptpIntentResult == main.TRUE:
1307 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001308 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001309 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001310
shahshreya9294c8d2015-01-21 15:54:16 -08001311 var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
1312 main.step(var2)
1313 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001314 "of:0000000000003009/1",
1315 "of:0000000000006019/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001316 if ptpIntentResult == main.TRUE:
1317 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001318 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001319 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001320
shahshreya9294c8d2015-01-21 15:54:16 -08001321 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001322 "of:0000000000006019/1",
1323 "of:0000000000003009/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001324 if ptpIntentResult == main.TRUE:
1325 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001326 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001327 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001328
shahshreya9294c8d2015-01-21 15:54:16 -08001329 var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
1330 main.step(var3)
1331 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001332 "of:0000000000003010/1",
1333 "of:0000000000006020/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001334 if ptpIntentResult == main.TRUE:
1335 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001336 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001337 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001338
shahshreya9294c8d2015-01-21 15:54:16 -08001339 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001340 "of:0000000000006020/1",
1341 "of:0000000000003010/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001342 if ptpIntentResult == main.TRUE:
1343 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001344 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001345 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001346
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001347 var4 = "Add point intents for mininet hosts h11 and h21 or" +\
1348 " ONOS hosts hB and h15"
shahshreya9294c8d2015-01-21 15:54:16 -08001349 main.case(var4)
1350 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001351 "of:0000000000003011/1",
1352 "of:0000000000006021/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001353 if ptpIntentResult == main.TRUE:
1354 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001355 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001356 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001357
shahshreya9294c8d2015-01-21 15:54:16 -08001358 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001359 "of:0000000000006021/1",
1360 "of:0000000000003011/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001361 if ptpIntentResult == main.TRUE:
1362 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001363 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001364 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001365
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001366 var5 = "Add point intents for mininet hosts h12 and h22 " +\
1367 "ONOS hosts hC and h16"
shahshreya9294c8d2015-01-21 15:54:16 -08001368 main.case(var5)
1369 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001370 "of:0000000000003012/1",
1371 "of:0000000000006022/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001372 if ptpIntentResult == main.TRUE:
1373 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001374 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001375 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001376
shahshreya9294c8d2015-01-21 15:54:16 -08001377 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001378 "of:0000000000006022/1",
1379 "of:0000000000003012/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001380 if ptpIntentResult == main.TRUE:
1381 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001382 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001383 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001384
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001385 var6 = "Add point intents for mininet hosts h13 and h23 or" +\
1386 " ONOS hosts hD and h17"
shahshreya9294c8d2015-01-21 15:54:16 -08001387 main.case(var6)
1388 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001389 "of:0000000000003013/1",
1390 "of:0000000000006023/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001391 if ptpIntentResult == main.TRUE:
1392 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001393 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001394 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001395
shahshreya9294c8d2015-01-21 15:54:16 -08001396 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001397 "of:0000000000006023/1",
1398 "of:0000000000003013/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001399 if ptpIntentResult == main.TRUE:
1400 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001401 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001402 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001403
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001404 var7 = "Add point intents for mininet hosts h14 and h24 or" +\
1405 " ONOS hosts hE and h18"
shahshreya9294c8d2015-01-21 15:54:16 -08001406 main.case(var7)
1407 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001408 "of:0000000000003014/1",
1409 "of:0000000000006024/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001410 if ptpIntentResult == main.TRUE:
1411 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001412 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001413 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001414
shahshreya9294c8d2015-01-21 15:54:16 -08001415 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001416 "of:0000000000006024/1",
1417 "of:0000000000003014/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001418 if ptpIntentResult == main.TRUE:
1419 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001420 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001421 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001422
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001423 var8 = "Add point intents for mininet hosts h15 and h25 or" +\
1424 " ONOS hosts hF and h19"
shahshreya9294c8d2015-01-21 15:54:16 -08001425 main.case(var8)
1426 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001427 "of:0000000000003015/1",
1428 "of:0000000000006025/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001429 if ptpIntentResult == main.TRUE:
1430 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001431 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001432 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001433
shahshreya9294c8d2015-01-21 15:54:16 -08001434 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001435 "of:0000000000006025/1",
1436 "of:0000000000003015/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001437 if ptpIntentResult == main.TRUE:
1438 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001439 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001440 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001441
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001442 var9 = "Add intents for mininet hosts h16 and h26 or" +\
1443 " ONOS hosts h10 and h1A"
shahshreya9294c8d2015-01-21 15:54:16 -08001444 main.case(var9)
1445 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001446 "of:0000000000003016/1",
1447 "of:0000000000006026/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001448 if ptpIntentResult == main.TRUE:
1449 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001450 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001451 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001452
shahshreya9294c8d2015-01-21 15:54:16 -08001453 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001454 "of:0000000000006026/1",
1455 "of:0000000000003016/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001456 if ptpIntentResult == main.TRUE:
1457 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001458 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001459 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001460
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001461 var10 = "Add point intents for mininet hosts h17 and h27 or" +\
1462 " ONOS hosts h11 and h1B"
shahshreya9294c8d2015-01-21 15:54:16 -08001463 main.case(var10)
1464 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001465 "of:0000000000003017/1",
1466 "of:0000000000006027/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001467 if ptpIntentResult == main.TRUE:
1468 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001469 main.log.info( "Point to point intent install successful" )
shahshreyab189da22015-02-25 10:18:26 -08001470 #main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001471
shahshreya9294c8d2015-01-21 15:54:16 -08001472 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001473 "of:0000000000006027/1",
1474 "of:0000000000003017/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001475 if ptpIntentResult == main.TRUE:
1476 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001477 main.log.info( "Point to point intent install successful" )
shahshreyab189da22015-02-25 10:18:26 -08001478 #main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001479
1480 print(
shahshreya9294c8d2015-01-21 15:54:16 -08001481 "___________________________________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001482
1483 flowHandle = main.ONOS2.flows()
shahshreya82ecd282015-02-05 16:48:03 -08001484 #main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001485
1486 count = 1
1487 i = 8
shahshreya9294c8d2015-01-21 15:54:16 -08001488 PingResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001489 while i < 18:
1490 main.log.info(
1491 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1492 ping = main.Mininet1.pingHost(
1493 src="h" + str( i ), target="h" + str( i + 10 ) )
1494 if ping == main.FALSE and count < 5:
1495 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001496 # i = 8
1497 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001498 main.log.report( "Ping between h" +
1499 str( i ) +
1500 " and h" +
1501 str( i +
1502 10 ) +
1503 " failed. Making attempt number " +
1504 str( count ) +
1505 " in 2 seconds" )
1506 time.sleep( 2 )
1507 elif ping == main.FALSE:
1508 main.log.report( "All ping attempts between h" +
1509 str( i ) +
1510 " and h" +
1511 str( i +
1512 10 ) +
1513 "have failed" )
1514 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -08001515 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001516 elif ping == main.TRUE:
1517 main.log.info( "Ping test between h" +
1518 str( i ) +
1519 " and h" +
1520 str( i +
1521 10 ) +
1522 "passed!" )
1523 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001524 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001525 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001526 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -08001527 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001528
shahshreya9294c8d2015-01-21 15:54:16 -08001529 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001530 main.log.report(
1531 "Point intents have not ben installed correctly. Cleaning up" )
1532 # main.cleanup()
1533 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -08001534 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001535 main.log.report( "Point Intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001536
shahshreya9294c8d2015-01-21 15:54:16 -08001537 case9Result = PingResult
kelvin-onlab8a832582015-01-16 17:06:11 -08001538 utilities.assert_equals(
1539 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001540 actual=case9Result,
kelvin-onlab8a832582015-01-16 17:06:11 -08001541 onpass="Point intents addition and Pingall Test successful",
1542 onfail="Point intents addition and Pingall Test NOT successful" )