blob: 5551759012a599dda9f6f2b8b329c1bb2b0fa246 [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" )
shahshreyad524a942015-04-21 09:55:16 -0700246 main.log.info( "Activate optical app" )
247 appInstallResult = main.ONOS2.activateApp( "org.onosproject.optical" )
248 appCheck = main.ONOS2.appToIDCheck()
249 if appCheck != main.TRUE:
250 main.log.warn( main.ONOS2.apps() )
251 main.log.warn( main.ONOS2.appIDs() )
252
shahshreya215c48f2015-04-06 15:55:55 -0700253 opticalMnScript = main.LincOE2.runOpticalMnScript(ctrllerIP = main.params[ 'CTRL' ][ 'ip1' ])
kelvin-onlab8a832582015-01-16 17:06:11 -0800254
shahshreya7630b1c2015-04-03 15:37:14 -0700255 case21Result = opticalMnScript and appInstallResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800256 utilities.assert_equals(
257 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800258 actual=case21Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800259 onpass="Packet optical topology spawned successsfully",
260 onfail="Packet optical topology spawning failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800261
kelvin-onlab8a832582015-01-16 17:06:11 -0800262 def CASE22( self, main ):
263 """
shahshreya7630b1c2015-04-03 15:37:14 -0700264 Curretly we use, 10 optical switches(ROADM's) and
265 6 packet layer mininet switches each with one host.
266 Therefore, the roadmCount variable = 10,
267 packetLayerSWCount variable = 6, hostCount=6 and
268 links=42.
269 All this is hardcoded in the testcase. If the topology changes,
shahshreya9294c8d2015-01-21 15:54:16 -0800270 these hardcoded values need to be changed
kelvin-onlab8a832582015-01-16 17:06:11 -0800271 """
272 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800273 "This testcase compares the optical+packet topology against what" +
274 " is expected" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800275 main.case( "Topology comparision" )
276 main.step( "Topology comparision" )
shahshreya9294c8d2015-01-21 15:54:16 -0800277 main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
278 devicesResult = main.ONOS3.devices( jsonFormat=False )
shahshreyae6c7cf42014-11-26 16:39:01 -0800279
shahshreya9294c8d2015-01-21 15:54:16 -0800280 print "devices_result = ", devicesResult
281 devicesLinewise = devicesResult.split( "\n" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800282 roadmCount = 0
283 packetLayerSWCount = 0
shahshreya9294c8d2015-01-21 15:54:16 -0800284 for line in devicesLinewise:
kelvin-onlab8a832582015-01-16 17:06:11 -0800285 components = line.split( "," )
286 availability = components[ 1 ].split( "=" )[ 1 ]
287 type = components[ 3 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800288 if availability == 'true' and type == 'ROADM':
289 roadmCount += 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800290 elif availability == 'true' and type == 'SWITCH':
shahshreyae6c7cf42014-11-26 16:39:01 -0800291 packetLayerSWCount += 1
shahshreya7630b1c2015-04-03 15:37:14 -0700292 if roadmCount == 10:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800293 print "Number of Optical Switches = %d and is" % roadmCount +\
294 " correctly detected"
kelvin-onlab8a832582015-01-16 17:06:11 -0800295 main.log.info(
296 "Number of Optical Switches = " +
297 str( roadmCount ) +
298 " and is correctly detected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800299 opticalSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800300 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800301 print "Number of Optical Switches = %d and is wrong" % roadmCount
kelvin-onlab8a832582015-01-16 17:06:11 -0800302 main.log.info(
303 "Number of Optical Switches = " +
304 str( roadmCount ) +
305 " and is wrong" )
shahshreya9294c8d2015-01-21 15:54:16 -0800306 opticalSWResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800307
shahshreya7630b1c2015-04-03 15:37:14 -0700308 if packetLayerSWCount == 6:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800309 print "Number of Packet layer or mininet Switches = %d "\
310 % packetLayerSWCount + "and is correctly detected"
kelvin-onlab8a832582015-01-16 17:06:11 -0800311 main.log.info(
312 "Number of Packet layer or mininet Switches = " +
313 str( packetLayerSWCount ) +
314 " and is correctly detected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800315 packetSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800316 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800317 print "Number of Packet layer or mininet Switches = %d and"\
318 % packetLayerSWCount + " is wrong"
kelvin-onlab8a832582015-01-16 17:06:11 -0800319 main.log.info(
320 "Number of Packet layer or mininet Switches = " +
321 str( packetLayerSWCount ) +
322 " and is wrong" )
shahshreya9294c8d2015-01-21 15:54:16 -0800323 packetSWResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800324 print "_________________________________"
kelvin-onlab8a832582015-01-16 17:06:11 -0800325
shahshreya9294c8d2015-01-21 15:54:16 -0800326 linksResult = main.ONOS3.links( jsonFormat=False )
327 print "links_result = ", linksResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800328 print "_________________________________"
shahshreya7630b1c2015-04-03 15:37:14 -0700329 linkActiveCount = linksResult.count("state=ACTIVE")
330 main.log.info( "linkActiveCount = " + str( linkActiveCount ))
331 if linkActiveCount == 42:
332 linkActiveResult = main.TRUE
333 main.log.info(
334 "Number of links in ACTIVE state are correct")
335 else:
336 linkActiveResult = main.FALSE
337 main.log.info(
338 "Number of links in ACTIVE state are wrong")
kelvin-onlab8a832582015-01-16 17:06:11 -0800339
shahshreya9294c8d2015-01-21 15:54:16 -0800340 # NOTE:Since only point intents are added, there is no
341 # requirement to discover the hosts
kelvin-onlab8a832582015-01-16 17:06:11 -0800342 # Therfore, the below portion of the code is commented.
343 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800344 #Discover hosts using pingall
shahshreya9294c8d2015-01-21 15:54:16 -0800345 pingallResult = main.LincOE2.pingall()
kelvin-onlab8a832582015-01-16 17:06:11 -0800346
shahshreya9294c8d2015-01-21 15:54:16 -0800347 hostsResult = main.ONOS3.hosts( jsonFormat=False )
348 main.log.info( "hosts_result = "+hostsResult )
kelvin-onlab8a832582015-01-16 17:06:11 -0800349 main.log.info( "_________________________________" )
shahshreya9294c8d2015-01-21 15:54:16 -0800350 hostsLinewise = hostsResult.split( "\n" )
351 hostsLinewise = hostsLinewise[ 1:-1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800352 hostCount = 0
shahshreya9294c8d2015-01-21 15:54:16 -0800353 for line in hostsLinewise:
kelvin-onlab8a832582015-01-16 17:06:11 -0800354 hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800355 hostCount +=1
356 if hostCount ==2:
357 print "Number of hosts = %d and is correctly detected" %hostCount
shahshreya9294c8d2015-01-21 15:54:16 -0800358 main.log.info( "Number of hosts = " + str( hostCount ) +" and \
359 is correctly detected" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800360 hostDiscovery = main.TRUE
361 else:
362 print "Number of hosts = %d and is wrong" %hostCount
shahshreya9294c8d2015-01-21 15:54:16 -0800363 main.log.info( "Number of hosts = " + str( hostCount ) +" and \
364 is wrong" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800365 hostDiscovery = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800366 """
shahshreya7630b1c2015-04-03 15:37:14 -0700367 case22Result = opticalSWResult and packetSWResult and \
368 linkActiveResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800369 utilities.assert_equals(
370 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800371 actual=case22Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800372 onpass="Packet optical topology discovery successful",
373 onfail="Packet optical topology discovery failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800374
kelvin-onlab8a832582015-01-16 17:06:11 -0800375 def CASE23( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800376 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800377 """
shahshreya9294c8d2015-01-21 15:54:16 -0800378 Add bidirectional point intents between 2 packet layer( mininet )
379 devices and
shahshreyae6c7cf42014-11-26 16:39:01 -0800380 ping mininet hosts
kelvin-onlab8a832582015-01-16 17:06:11 -0800381 """
382 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800383 "This testcase adds bidirectional point intents between 2 " +
384 "packet layer( mininet ) devices and ping mininet hosts" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800385 main.case( "Topology comparision" )
386 main.step( "Adding point intents" )
shahshreya9294c8d2015-01-21 15:54:16 -0800387 ptpIntentResult = main.ONOS3.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -0800388 "of:0000ffffffff0001/1",
shahshreya7630b1c2015-04-03 15:37:14 -0700389 "of:0000ffffffff0005/1" )
shahshreya9294c8d2015-01-21 15:54:16 -0800390 if ptpIntentResult == main.TRUE:
391 main.ONOS3.intents( jsonFormat=False )
kelvin-onlab8a832582015-01-16 17:06:11 -0800392 main.log.info( "Point to point intent install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800393
shahshreya9294c8d2015-01-21 15:54:16 -0800394 ptpIntentResult = main.ONOS3.addPointIntent(
shahshreya7630b1c2015-04-03 15:37:14 -0700395 "of:0000ffffffff0005/1",
kelvin-onlab8a832582015-01-16 17:06:11 -0800396 "of:0000ffffffff0001/1" )
shahshreya9294c8d2015-01-21 15:54:16 -0800397 if ptpIntentResult == main.TRUE:
398 main.ONOS3.intents( jsonFormat=False )
kelvin-onlab8a832582015-01-16 17:06:11 -0800399 main.log.info( "Point to point intent install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800400
shahshreya7630b1c2015-04-03 15:37:14 -0700401 time.sleep( 30 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800402 flowHandle = main.ONOS3.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -0800403 main.log.info( "flows :" + flowHandle )
shahshreyae6c7cf42014-11-26 16:39:01 -0800404
405 # Sleep for 30 seconds to provide time for the intent state to change
shahshreya7630b1c2015-04-03 15:37:14 -0700406 time.sleep( 60 )
shahshreya9294c8d2015-01-21 15:54:16 -0800407 intentHandle = main.ONOS3.intents( jsonFormat=False )
kelvin-onlab8a832582015-01-16 17:06:11 -0800408 main.log.info( "intents :" + intentHandle )
409
shahshreya9294c8d2015-01-21 15:54:16 -0800410 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800411 count = 1
shahshreya7630b1c2015-04-03 15:37:14 -0700412 main.log.info( "\n\nh1 is Pinging h5" )
413 ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
shahshreya9294c8d2015-01-21 15:54:16 -0800414 # ping = main.LincOE2.pinghost()
kelvin-onlab8a832582015-01-16 17:06:11 -0800415 if ping == main.FALSE and count < 5:
416 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -0800417 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800418 main.log.info(
shahshreya7630b1c2015-04-03 15:37:14 -0700419 "Ping between h1 and h5 failed. Making attempt number " +
kelvin-onlab8a832582015-01-16 17:06:11 -0800420 str( count ) +
421 " in 2 seconds" )
422 time.sleep( 2 )
423 elif ping == main.FALSE:
shahshreya7630b1c2015-04-03 15:37:14 -0700424 main.log.info( "All ping attempts between h1 and h5 have failed" )
shahshreya9294c8d2015-01-21 15:54:16 -0800425 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800426 elif ping == main.TRUE:
shahshreya7630b1c2015-04-03 15:37:14 -0700427 main.log.info( "Ping test between h1 and h5 passed!" )
shahshreya9294c8d2015-01-21 15:54:16 -0800428 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800429 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800430 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -0800431 PingResult = main.ERROR
kelvin-onlab8a832582015-01-16 17:06:11 -0800432
shahshreya9294c8d2015-01-21 15:54:16 -0800433 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800434 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800435 "Point intents for packet optical have not ben installed" +
436 " correctly. Cleaning up" )
shahshreya9294c8d2015-01-21 15:54:16 -0800437 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800438 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800439 "Point Intents for packet optical have been " +
440 "installed correctly" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800441
shahshreya9294c8d2015-01-21 15:54:16 -0800442 case23Result = PingResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800443 utilities.assert_equals(
444 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800445 actual=case23Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800446 onpass= "Point intents addition for packet optical and" +
447 "Pingall Test successful",
448 onfail= "Point intents addition for packet optical and" +
449 "Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800450
kelvin-onlab8a832582015-01-16 17:06:11 -0800451 def CASE24( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800452 import time
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800453 import json
kelvin-onlab8a832582015-01-16 17:06:11 -0800454 """
shahshreya7630b1c2015-04-03 15:37:14 -0700455 LINC uses its own switch IDs. You can use the following
456 command on the LINC console to find the mapping between
457 DPIDs and LINC IDs.
458 rp(application:get_all_key(linc)).
459
shahshreya9294c8d2015-01-21 15:54:16 -0800460 Test Rerouting of Packet Optical by bringing a port down
shahshreya7630b1c2015-04-03 15:37:14 -0700461 ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
462 so that link
463 ( between switch1 port20 - switch5 port50 ) is inactive
shahshreya9294c8d2015-01-21 15:54:16 -0800464 and do a ping test. If rerouting is successful,
465 ping should pass. also check the flows
kelvin-onlab8a832582015-01-16 17:06:11 -0800466 """
467 main.log.report(
468 "This testcase tests rerouting and pings mininet hosts" )
469 main.case( "Test rerouting and pings mininet hosts" )
shahshreya7630b1c2015-04-03 15:37:14 -0700470 main.step( "Attach to the Linc-OE session" )
471 attachConsole = main.LincOE1.attachLincOESession()
472 print "attachConsole = ", attachConsole
473
kelvin-onlab8a832582015-01-16 17:06:11 -0800474 main.step( "Bring a port down and verify the link state" )
shahshreya7630b1c2015-04-03 15:37:14 -0700475 main.LincOE1.portDown( swId="9", ptId="20" )
shahshreya9294c8d2015-01-21 15:54:16 -0800476 linksNonjson = main.ONOS3.links( jsonFormat=False )
477 main.log.info( "links = " + linksNonjson )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800478
shahshreya7630b1c2015-04-03 15:37:14 -0700479 linkInactiveCount = linksNonjson.count("state=INACTIVE")
480 main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
481 if linkInactiveCount == 2:
482 main.log.info(
483 "Number of links in INACTIVE state are correct")
484 else:
485 main.log.info(
486 "Number of links in INACTIVE state are wrong")
487
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800488 links = main.ONOS3.links()
kelvin-onlab8a832582015-01-16 17:06:11 -0800489 main.log.info( "links = " + links )
490
shahshreya9294c8d2015-01-21 15:54:16 -0800491 linksResult = json.loads( links )
492 linksStateResult = main.FALSE
493 for item in linksResult:
kelvin-onlab8a832582015-01-16 17:06:11 -0800494 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
shahshreya7630b1c2015-04-03 15:37:14 -0700495 'src' ][ 'port' ] == "20":
496 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
497 'dst' ][ 'port' ] == "50":
shahshreya9294c8d2015-01-21 15:54:16 -0800498 linksState = item[ 'state' ]
499 if linksState == "INACTIVE":
kelvin-onlab8a832582015-01-16 17:06:11 -0800500 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800501 "Links state is inactive as expected due to one" +
502 " of the ports being down" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800503 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800504 "Links state is inactive as expected due to one" +
505 " of the ports being down" )
shahshreya9294c8d2015-01-21 15:54:16 -0800506 linksStateResult = main.TRUE
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800507 break
508 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800509 main.log.info(
510 "Links state is not inactive as expected" )
511 main.log.report(
512 "Links state is not inactive as expected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800513 linksStateResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800514
shahshreya9294c8d2015-01-21 15:54:16 -0800515 print "links_state_result = ", linksStateResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800516 time.sleep( 10 )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800517 flowHandle = main.ONOS3.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -0800518 main.log.info( "flows :" + flowHandle )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800519
kelvin-onlab8a832582015-01-16 17:06:11 -0800520 main.step( "Verify Rerouting by a ping test" )
shahshreya9294c8d2015-01-21 15:54:16 -0800521 PingResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800522 count = 1
shahshreya7630b1c2015-04-03 15:37:14 -0700523 main.log.info( "\n\nh1 is Pinging h5" )
524 ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
shahshreya9294c8d2015-01-21 15:54:16 -0800525 # ping = main.LincOE2.pinghost()
kelvin-onlab8a832582015-01-16 17:06:11 -0800526 if ping == main.FALSE and count < 5:
527 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -0800528 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800529 main.log.info(
shahshreya7630b1c2015-04-03 15:37:14 -0700530 "Ping between h1 and h5 failed. Making attempt number " +
kelvin-onlab8a832582015-01-16 17:06:11 -0800531 str( count ) +
532 " in 2 seconds" )
533 time.sleep( 2 )
534 elif ping == main.FALSE:
shahshreya7630b1c2015-04-03 15:37:14 -0700535 main.log.info( "All ping attempts between h1 and h5 have failed" )
shahshreya9294c8d2015-01-21 15:54:16 -0800536 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800537 elif ping == main.TRUE:
shahshreya7630b1c2015-04-03 15:37:14 -0700538 main.log.info( "Ping test between h1 and h5 passed!" )
shahshreya9294c8d2015-01-21 15:54:16 -0800539 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800540 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800541 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -0800542 PingResult = main.ERROR
shahshreyae6c7cf42014-11-26 16:39:01 -0800543
shahshreya9294c8d2015-01-21 15:54:16 -0800544 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800545 main.log.report( "Ping test successful " )
shahshreya9294c8d2015-01-21 15:54:16 -0800546 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800547 main.log.report( "Ping test failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800548
shahshreya9294c8d2015-01-21 15:54:16 -0800549 case24Result = PingResult and linksStateResult
550 utilities.assert_equals( expect=main.TRUE, actual=case24Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800551 onpass="Packet optical rerouting successful",
552 onfail="Packet optical rerouting failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800553
kelvin-onlab8a832582015-01-16 17:06:11 -0800554 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800555 import re
556 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800557 main.log.report( "This testcase is testing the assignment of" +
558 " all the switches to all the controllers and" +
shahshreyab189da22015-02-25 10:18:26 -0800559 " discovering the hosts in reactive mode" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800560 main.log.report( "__________________________________" )
561 main.case( "Pingall Test" )
562 main.step( "Assigning switches to controllers" )
shahshreya9294c8d2015-01-21 15:54:16 -0800563 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
564 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
kelvin-onlab8a832582015-01-16 17:06:11 -0800565 for i in range( 1, 29 ):
566 if i == 1:
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 >= 2 and i < 5:
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 >= 5 and i < 8:
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 >= 8 and i < 18:
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 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800586 elif i >= 18 and i < 28:
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 )
shahshreya4e13a062014-11-11 16:46:18 -0800591 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800592 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800593 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800594 ip1=ONOS1Ip,
595 port1=ONOS1Port )
596 SwitchMastership = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800597 for i in range( 1, 29 ):
598 if i == 1:
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
kelvin-onlab8a832582015-01-16 17:06:11 -0800605 elif i >= 2 and i < 5:
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
kelvin-onlab8a832582015-01-16 17:06:11 -0800612 elif i >= 5 and i < 8:
shahshreya9294c8d2015-01-21 15:54:16 -0800613 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800614 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800615 if re.search( "tcp:" + ONOS1Ip, response ):
616 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800617 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800618 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800619 elif i >= 8 and i < 18:
shahshreya9294c8d2015-01-21 15:54:16 -0800620 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800621 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800622 if re.search( "tcp:" + ONOS1Ip, response ):
623 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800624 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800625 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800626 elif i >= 18 and i < 28:
shahshreya9294c8d2015-01-21 15:54:16 -0800627 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800628 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800629 if re.search( "tcp:" + ONOS1Ip, response ):
630 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800631 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800632 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800633 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800634 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800635 print( "Response is" + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800636 if re.search( "tcp:" + ONOS1Ip, response ):
637 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800638 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800639 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800640
shahshreya9294c8d2015-01-21 15:54:16 -0800641 if SwitchMastership == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800642 main.log.report( "Controller assignmnet successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800643 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800644 main.log.report( "Controller assignmnet failed" )
645 utilities.assert_equals(
646 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800647 actual=SwitchMastership,
kelvin-onlab8a832582015-01-16 17:06:11 -0800648 onpass="MasterControllers assigned correctly" )
649 """
650 for i in range ( 1,29 ):
shahshreya9294c8d2015-01-21 15:54:16 -0800651 main.Mininet1.assignSwController( sw=str( i ),count=5,
652 ip1=ONOS1Ip,port1=ONOS1Port,
653 ip2=ONOS2Ip,port2=ONOS2Port,
654 ip3=ONOS3Ip,port3=ONOS3Port,
655 ip4=ONOS4Ip,port4=ONOS4Port,
656 ip5=ONOS5Ip,port5=ONOS5Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800657 """
658 # REACTIVE FWD test
shahshreyad524a942015-04-21 09:55:16 -0700659 main.log.info( "Activate fwd app" )
660 appInstallResult = main.ONOS2.activateApp( "org.onosproject.fwd" )
661 appCheck = main.ONOS2.appToIDCheck()
662 if appCheck != main.TRUE:
663 main.log.warn( main.ONOS2.apps() )
664 main.log.warn( main.ONOS2.appIDs() )
665 time.sleep( 10 )
shahshreya4e13a062014-11-11 16:46:18 -0800666
kelvin-onlab8a832582015-01-16 17:06:11 -0800667 main.step( "Get list of hosts from Mininet" )
shahshreya9294c8d2015-01-21 15:54:16 -0800668 hostList = main.Mininet1.getHosts()
669 main.log.info( hostList )
shahshreya4e13a062014-11-11 16:46:18 -0800670
kelvin-onlab8a832582015-01-16 17:06:11 -0800671 main.step( "Get host list in ONOS format" )
shahshreya9294c8d2015-01-21 15:54:16 -0800672 hostOnosList = main.ONOS2.getHostsId( hostList )
673 main.log.info( hostOnosList )
kelvin-onlab8a832582015-01-16 17:06:11 -0800674 # time.sleep( 5 )
675
676 main.step( "Pingall" )
shahshreya9294c8d2015-01-21 15:54:16 -0800677 pingResult = main.FALSE
shahshreya82ecd282015-02-05 16:48:03 -0800678 time1 = time.time()
679 pingResult = main.Mininet1.pingall()
680 time2 = time.time()
681 print "Time for pingall: %2f seconds" % ( time2 - time1 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800682
shahshreya9294c8d2015-01-21 15:54:16 -0800683 # Start onos cli again because u might have dropped out of
684 # onos prompt to the shell prompt
kelvin-onlab8a832582015-01-16 17:06:11 -0800685 # if there was no activity
shahshreya9294c8d2015-01-21 15:54:16 -0800686 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800687
shahshreya9294c8d2015-01-21 15:54:16 -0800688 case4Result = SwitchMastership and pingResult
689 if pingResult == main.TRUE:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800690 main.log.report( "Pingall Test in reactive mode to" +
691 " discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800692 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800693 main.log.report( "Pingall Test in reactive mode to" +
694 " discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800695
kelvin-onlab8a832582015-01-16 17:06:11 -0800696 utilities.assert_equals(
697 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800698 actual=case4Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800699 onpass="Controller assignment and Pingall Test successful",
700 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800701
kelvin-onlab8a832582015-01-16 17:06:11 -0800702 def CASE10( self ):
703 main.log.report(
704 "This testcase uninstalls the reactive forwarding app" )
705 main.log.report( "__________________________________" )
706 main.case( "Uninstalling reactive forwarding app" )
707 # Unistall onos-app-fwd app to disable reactive forwarding
shahshreyad524a942015-04-21 09:55:16 -0700708 main.log.info( "deactivate reactive forwarding app" )
709 appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
710 appCheck = main.ONOS2.appToIDCheck()
711 if appCheck != main.TRUE:
712 main.log.warn( main.ONOS2.apps() )
713 main.log.warn( main.ONOS2.appIDs() )
shahshreyae6c7cf42014-11-26 16:39:01 -0800714
shahshreya9294c8d2015-01-21 15:54:16 -0800715 # After reactive forwarding is disabled, the reactive flows on
716 # switches timeout in 10-15s
kelvin-onlab8a832582015-01-16 17:06:11 -0800717 # So sleep for 15s
718 time.sleep( 15 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800719
720 flows = main.ONOS2.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -0800721 main.log.info( flows )
shahshreyae6c7cf42014-11-26 16:39:01 -0800722
shahshreya9294c8d2015-01-21 15:54:16 -0800723 case10Result = appUninstallResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800724 utilities.assert_equals(
725 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800726 actual=case10Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800727 onpass="Reactive forwarding app uninstallation successful",
728 onfail="Reactive forwarding app uninstallation failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800729
shahshreyab189da22015-02-25 10:18:26 -0800730
731 def CASE11( self ):
732 # NOTE: This testcase require reactive forwarding mode enabled
733 # NOTE: in the beginning and then uninstall it before adding
734 # NOTE: point intents. Again the app is installed so that
735 # NOTE: testcase 10 can be ran successively
736 import time
737 main.log.report(
738 "This testcase moves a host from one switch to another to add" +
739 "point intents between them and then perform ping" )
740 main.log.report( "__________________________________" )
741 main.log.info( "Moving host from one switch to another" )
742 main.case( "Moving host from a device and attach it to another device" )
743 main.step( "Moving host h9 from device s9 and attach it to s8" )
744 main.Mininet1.moveHost(host = 'h9', oldSw = 's9', newSw = 's8')
745
shahshreyad524a942015-04-21 09:55:16 -0700746 main.log.info( "Activate fwd app" )
747 appInstallResult = main.ONOS2.activateApp( "org.onosproject.fwd" )
748 appCheck = main.ONOS2.appToIDCheck()
749 if appCheck != main.TRUE:
750 main.log.warn( main.ONOS2.apps() )
751 main.log.warn( main.ONOS2.appIDs() )
752
753 time.sleep( 45 ) #Time delay to have all the flows ready
shahshreyab189da22015-02-25 10:18:26 -0800754 main.step( "Pingall" )
755 pingResult = main.FALSE
756 time1 = time.time()
shahshreyad524a942015-04-21 09:55:16 -0700757 pingResult = main.Mininet1.pingall( timeout=120,
758 shortCircuit=True,
759 acceptableFailed=10)
shahshreyab189da22015-02-25 10:18:26 -0800760 time2 = time.time()
761 print "Time for pingall: %2f seconds" % ( time2 - time1 )
762
763 hosts = main.ONOS2.hosts( jsonFormat = False )
764 main.log.info( hosts )
765
shahshreyad524a942015-04-21 09:55:16 -0700766 main.log.info( "deactivate reactive forwarding app" )
767 appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
768 appCheck = main.ONOS2.appToIDCheck()
769 if appCheck != main.TRUE:
770 main.log.warn( main.ONOS2.apps() )
771 main.log.warn( main.ONOS2.appIDs() )
shahshreyab189da22015-02-25 10:18:26 -0800772
773 main.step( "Add point intents between hosts on the same device")
774 ptpIntentResult = main.ONOS2.addPointIntent(
775 "of:0000000000003008/1",
776 "of:0000000000003008/3" )
777 if ptpIntentResult == main.TRUE:
778 getIntentResult = main.ONOS2.intents()
779 main.log.info( "Point to point intent install successful" )
780 # main.log.info( getIntentResult )
781
782 ptpIntentResult = main.ONOS2.addPointIntent(
783 "of:0000000000003008/3",
784 "of:0000000000003008/1" )
785 if ptpIntentResult == main.TRUE:
786 getIntentResult = main.ONOS2.intents()
787 main.log.info( "Point to point intent install successful" )
788 # main.log.info( getIntentResult )
789
790 main.case( "Ping hosts on the same devices" )
791 ping = main.Mininet1.pingHost( src = 'h8', target = 'h9' )
792
793 '''
794 main.case( "Installing reactive forwarding app" )
795 # Install onos-app-fwd app to enable reactive forwarding
796 appUninstallResult = main.ONOS2.featureInstall( "onos-app-fwd" )
797 main.log.info( "onos-app-fwd installed" )
798 '''
799
800 if ping == main.FALSE:
801 main.log.report(
802 "Point intents for hosts on same devices haven't" +
803 " been installed correctly. Cleaning up" )
804 if ping == main.TRUE:
805 main.log.report(
806 "Point intents for hosts on same devices" +
807 "installed correctly. Cleaning up" )
808
809 case11Result = ping and pingResult
810 utilities.assert_equals(
shahshreya74cca802015-02-26 12:24:01 -0800811 expect = main.TRUE,
812 actual = case11Result,
813 onpass = "Point intents for hosts on same devices" +
shahshreyab189da22015-02-25 10:18:26 -0800814 "Ping Test successful",
shahshreya74cca802015-02-26 12:24:01 -0800815 onfail = "Point intents for hosts on same devices" +
shahshreyab189da22015-02-25 10:18:26 -0800816 "Ping Test NOT successful" )
shahshreya74cca802015-02-26 12:24:01 -0800817
818
819 def CASE12( self ):
820 """
shahshreyaed683ed2015-03-16 15:04:40 -0700821 Verify the default flows on each switch in proactive mode
shahshreya74cca802015-02-26 12:24:01 -0800822 """
shahshreyaed683ed2015-03-16 15:04:40 -0700823 main.log.report( "This testcase is verifying num of default" +
824 " flows on each switch" )
825 main.log.report( "__________________________________" )
826 main.case( "Verify num of default flows on each switch" )
827 main.step( "Obtaining the device id's and flowrule count on them" )
828
shahshreya74cca802015-02-26 12:24:01 -0800829 case12Result = main.TRUE
830 idList = main.ONOS2.getAllDevicesId()
831 for id in idList:
shahshreyaed683ed2015-03-16 15:04:40 -0700832 count = main.ONOS2.FlowAddedCount( id )
833 main.log.info("count = " +count)
834 if int(count) != 3:
shahshreya74cca802015-02-26 12:24:01 -0800835 case12Result = main.FALSE
shahshreyaed683ed2015-03-16 15:04:40 -0700836 break
shahshreya74cca802015-02-26 12:24:01 -0800837 utilities.assert_equals(
838 expect=main.TRUE,
839 actual=case12Result,
840 onpass = "Expected default num of flows exist",
841 onfail = "Expected default num of flows do not exist")
shahshreyab189da22015-02-25 10:18:26 -0800842
kelvin-onlab8a832582015-01-16 17:06:11 -0800843 def CASE6( self ):
shahshreyab189da22015-02-25 10:18:26 -0800844 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800845 main.log.report( "This testcase is testing the addition of" +
846 " host intents and then does pingall" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800847 main.log.report( "__________________________________" )
848 main.case( "Obtaining host id's" )
849 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800850 hosts = main.ONOS2.hosts()
shahshreya9294c8d2015-01-21 15:54:16 -0800851 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800852
kelvin-onlab8a832582015-01-16 17:06:11 -0800853 main.step( "Get all devices id" )
shahshreya9294c8d2015-01-21 15:54:16 -0800854 devicesIdList = main.ONOS2.getAllDevicesId()
855 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -0800856
shahshreya9294c8d2015-01-21 15:54:16 -0800857 # ONOS displays the hosts in hex format unlike mininet which does
858 # in decimal format
kelvin-onlab8a832582015-01-16 17:06:11 -0800859 # So take care while adding intents
860 """
shahshreya9294c8d2015-01-21 15:54:16 -0800861 main.step( "Add host-to-host intents for mininet hosts h8 and h18 or
862 ONOS hosts h8 and h12" )
863 hthIntentResult = main.ONOS2.addHostIntent(
864 "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
865 hthIntentResult = main.ONOS2.addHostIntent(
866 "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
867 hthIntentResult = main.ONOS2.addHostIntent(
868 "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
869 hthIntentResult = main.ONOS2.addHostIntent(
870 "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
871 hthIntentResult = main.ONOS2.addHostIntent(
872 "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
873 hthIntentResult = main.ONOS2.addHostIntent(
874 "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
875 hthIntentResult = main.ONOS2.addHostIntent(
876 "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
877 hthIntentResult = main.ONOS2.addHostIntent(
878 "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
879 hthIntentResult = main.ONOS2.addHostIntent(
880 "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
881 hthIntentResult = main.ONOS2.addHostIntent(
882 "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
883 print "______________________________________________________"
kelvin-onlab8a832582015-01-16 17:06:11 -0800884 """
885 for i in range( 8, 18 ):
886 main.log.info(
shahshreya9294c8d2015-01-21 15:54:16 -0800887 "Adding host intent between h" + str( i ) +
888 " and h" + str( i + 10 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800889 host1 = "00:00:00:00:00:" + \
890 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
891 host2 = "00:00:00:00:00:" + \
892 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
893 # NOTE: get host can return None
shahshreya7630b1c2015-04-03 15:37:14 -0700894 if host1:
895 host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
896 if host2:
897 host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
898 if host1Id and host2Id:
899 main.ONOS2.addHostIntent( host1Id, host2Id )
kelvin-onlab8a832582015-01-16 17:06:11 -0800900
901 time.sleep( 10 )
shahshreya9294c8d2015-01-21 15:54:16 -0800902 hIntents = main.ONOS2.intents( jsonFormat=False )
903 main.log.info( "intents:" + hIntents )
shahshreyab189da22015-02-25 10:18:26 -0800904 flows = main.ONOS2.flows()
905 main.log.info( "flows:" + flows )
shahshreya4e13a062014-11-11 16:46:18 -0800906
907 count = 1
908 i = 8
shahshreya9294c8d2015-01-21 15:54:16 -0800909 PingResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800910 # while i<10:
911 while i < 18:
912 main.log.info(
913 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
914 ping = main.Mininet1.pingHost(
915 src="h" + str( i ), target="h" + str( i + 10 ) )
916 if ping == main.FALSE and count < 5:
917 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -0800918 # i = 8
919 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800920 main.log.report( "Ping between h" +
921 str( i ) +
922 " and h" +
923 str( i +
924 10 ) +
925 " failed. Making attempt number " +
926 str( count ) +
927 " in 2 seconds" )
928 time.sleep( 2 )
929 elif ping == main.FALSE:
930 main.log.report( "All ping attempts between h" +
931 str( i ) +
932 " and h" +
933 str( i +
934 10 ) +
935 "have failed" )
936 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -0800937 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800938 elif ping == main.TRUE:
939 main.log.info( "Ping test between h" +
940 str( i ) +
941 " and h" +
942 str( i +
943 10 ) +
944 "passed!" )
945 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -0800946 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800947 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800948 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -0800949 PingResult = main.ERROR
950 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800951 main.log.report(
shahshreya9294c8d2015-01-21 15:54:16 -0800952 "Ping all test after Host intent addition failed.Cleaning up" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800953 # main.cleanup()
954 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -0800955 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800956 main.log.report(
957 "Ping all test after Host intent addition successful" )
958
shahshreya9294c8d2015-01-21 15:54:16 -0800959 case6Result = PingResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800960 utilities.assert_equals(
961 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800962 actual=case6Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800963 onpass="Pingall Test after Host intents addition successful",
964 onfail="Pingall Test after Host intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800965
kelvin-onlab8a832582015-01-16 17:06:11 -0800966 def CASE5( self, main ):
shahshreyad524a942015-04-21 09:55:16 -0700967 """
968 Check ONOS topology matches with mininet
969 """
shahshreya4e13a062014-11-11 16:46:18 -0800970 import json
kelvin-onlab8a832582015-01-16 17:06:11 -0800971 # assumes that sts is already in you PYTHONPATH
972 from sts.topology.teston_topology import TestONTopology
shahshreya9294c8d2015-01-21 15:54:16 -0800973 # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800974 main.log.report( "This testcase is testing if all ONOS nodes" +
975 " are in topology sync with mininet" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800976 main.log.report( "__________________________________" )
977 main.case( "Comparing Mininet topology with the topology of ONOS" )
978 main.step( "Start continuous pings" )
979 main.Mininet2.pingLong(
980 src=main.params[ 'PING' ][ 'source1' ],
981 target=main.params[ 'PING' ][ 'target1' ],
982 pingTime=500 )
983 main.Mininet2.pingLong(
984 src=main.params[ 'PING' ][ 'source2' ],
985 target=main.params[ 'PING' ][ 'target2' ],
986 pingTime=500 )
987 main.Mininet2.pingLong(
988 src=main.params[ 'PING' ][ 'source3' ],
989 target=main.params[ 'PING' ][ 'target3' ],
990 pingTime=500 )
991 main.Mininet2.pingLong(
992 src=main.params[ 'PING' ][ 'source4' ],
993 target=main.params[ 'PING' ][ 'target4' ],
994 pingTime=500 )
995 main.Mininet2.pingLong(
996 src=main.params[ 'PING' ][ 'source5' ],
997 target=main.params[ 'PING' ][ 'target5' ],
998 pingTime=500 )
999 main.Mininet2.pingLong(
1000 src=main.params[ 'PING' ][ 'source6' ],
1001 target=main.params[ 'PING' ][ 'target6' ],
1002 pingTime=500 )
1003 main.Mininet2.pingLong(
1004 src=main.params[ 'PING' ][ 'source7' ],
1005 target=main.params[ 'PING' ][ 'target7' ],
1006 pingTime=500 )
1007 main.Mininet2.pingLong(
1008 src=main.params[ 'PING' ][ 'source8' ],
1009 target=main.params[ 'PING' ][ 'target8' ],
1010 pingTime=500 )
1011 main.Mininet2.pingLong(
1012 src=main.params[ 'PING' ][ 'source9' ],
1013 target=main.params[ 'PING' ][ 'target9' ],
1014 pingTime=500 )
1015 main.Mininet2.pingLong(
1016 src=main.params[ 'PING' ][ 'source10' ],
1017 target=main.params[ 'PING' ][ 'target10' ],
1018 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -08001019
kelvin-onlab8a832582015-01-16 17:06:11 -08001020 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -08001021 global ctrls
1022 ctrls = []
1023 count = 1
1024 while True:
1025 temp = ()
kelvin-onlab8a832582015-01-16 17:06:11 -08001026 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
1027 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
1028 temp = temp + ( "ONOS" + str( count ), )
1029 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
1030 temp = temp + \
1031 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
1032 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -08001033 count = count + 1
1034 else:
1035 break
1036 global MNTopo
kelvin-onlab8a832582015-01-16 17:06:11 -08001037 Topo = TestONTopology(
1038 main.Mininet1,
1039 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -08001040 MNTopo = Topo
1041
shahshreya9294c8d2015-01-21 15:54:16 -08001042 TopologyCheck = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001043 main.step( "Compare ONOS Topology to MN Topology" )
shahshreya9294c8d2015-01-21 15:54:16 -08001044 devicesJson = main.ONOS2.devices()
1045 linksJson = main.ONOS2.links()
1046 # portsJson = main.ONOS2.ports()
kelvin-onlab8a832582015-01-16 17:06:11 -08001047
shahshreya9294c8d2015-01-21 15:54:16 -08001048 result1 = main.Mininet1.compareSwitches(
kelvin-onlab8a832582015-01-16 17:06:11 -08001049 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001050 json.loads( devicesJson ) )
1051 result2 = main.Mininet1.compareLinks(
kelvin-onlab8a832582015-01-16 17:06:11 -08001052 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001053 json.loads( linksJson ) )
1054 # result3 = main.Mininet1.comparePorts(
1055 # MNTopo, json.loads( portsJson ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001056
shahshreya9294c8d2015-01-21 15:54:16 -08001057 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001058 result = result1 and result2
kelvin-onlab8a832582015-01-16 17:06:11 -08001059
shahshreya4e13a062014-11-11 16:46:18 -08001060 print "***********************"
1061 if result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001062 main.log.report( "ONOS" + " Topology matches MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001063 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001064 main.log.report( "ONOS" + " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001065
kelvin-onlab8a832582015-01-16 17:06:11 -08001066 utilities.assert_equals(
1067 expect=main.TRUE,
1068 actual=result,
1069 onpass="ONOS" +
1070 " Topology matches MN Topology",
1071 onfail="ONOS" +
1072 " Topology does not match MN Topology" )
1073
shahshreya9294c8d2015-01-21 15:54:16 -08001074 TopologyCheck = TopologyCheck and result
kelvin-onlab8a832582015-01-16 17:06:11 -08001075 utilities.assert_equals(
1076 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001077 actual=TopologyCheck,
kelvin-onlab8a832582015-01-16 17:06:11 -08001078 onpass="Topology checks passed",
1079 onfail="Topology checks failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001080
kelvin-onlab8a832582015-01-16 17:06:11 -08001081 def CASE7( self, main ):
shahshreyad524a942015-04-21 09:55:16 -07001082 """
1083 Link discovery test case. Checks if ONOS can discover a link
1084 down or up properly.
1085 """
1086
shahshreya9294c8d2015-01-21 15:54:16 -08001087 from sts.topology.teston_topology import TestONTopology
shahshreya4e13a062014-11-11 16:46:18 -08001088
shahshreya9294c8d2015-01-21 15:54:16 -08001089 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -08001090
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001091 main.log.report( "This testscase is killing a link to ensure that" +
1092 " link discovery is consistent" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001093 main.log.report( "__________________________________" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001094 main.log.report( "Killing a link to ensure that link discovery" +
1095 " is consistent" )
1096 main.case( "Killing a link to Ensure that Link Discovery" +
1097 "is Working Properly" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001098 """
1099 main.step( "Start continuous pings" )
1100
1101 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001102 target=main.params[ 'PING' ][ 'target1' ],
1103 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001104 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001105 target=main.params[ 'PING' ][ 'target2' ],
1106 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001107 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001108 target=main.params[ 'PING' ][ 'target3' ],
1109 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001110 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001111 target=main.params[ 'PING' ][ 'target4' ],
1112 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001113 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001114 target=main.params[ 'PING' ][ 'target5' ],
1115 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001116 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001117 target=main.params[ 'PING' ][ 'target6' ],
1118 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001119 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001120 target=main.params[ 'PING' ][ 'target7' ],
1121 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001122 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001123 target=main.params[ 'PING' ][ 'target8' ],
1124 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001125 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001126 target=main.params[ 'PING' ][ 'target9' ],
1127 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001128 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001129 target=main.params[ 'PING' ][ 'target10' ],
1130 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001131 """
1132 main.step( "Determine the current number of switches and links" )
shahshreya9294c8d2015-01-21 15:54:16 -08001133 topologyOutput = main.ONOS2.topology()
1134 topologyResult = main.ONOS1.getTopology( topologyOutput )
shahshreyaed683ed2015-03-16 15:04:40 -07001135 activeSwitches = topologyResult[ 'deviceCount' ]
1136 links = topologyResult[ 'linkCount' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001137 print "activeSwitches = ", type( activeSwitches )
1138 print "links = ", type( links )
1139 main.log.info(
1140 "Currently there are %s switches and %s links" %
1141 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -08001142
kelvin-onlab8a832582015-01-16 17:06:11 -08001143 main.step( "Kill Link between s3 and s28" )
1144 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
shahshreya9294c8d2015-01-21 15:54:16 -08001145 time.sleep( linkSleep )
1146 topologyOutput = main.ONOS2.topology()
1147 LinkDown = main.ONOS1.checkStatus(
1148 topologyOutput, activeSwitches, str(
kelvin-onlab8a832582015-01-16 17:06:11 -08001149 int( links ) - 2 ) )
shahshreya9294c8d2015-01-21 15:54:16 -08001150 if LinkDown == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001151 main.log.report( "Link Down discovered properly" )
1152 utilities.assert_equals(
1153 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001154 actual=LinkDown,
kelvin-onlab8a832582015-01-16 17:06:11 -08001155 onpass="Link Down discovered properly",
1156 onfail="Link down was not discovered in " +
shahshreya9294c8d2015-01-21 15:54:16 -08001157 str( linkSleep ) +
kelvin-onlab8a832582015-01-16 17:06:11 -08001158 " seconds" )
1159
1160 # Check ping result here..add code for it
1161
1162 main.step( "Bring link between s3 and s28 back up" )
shahshreya9294c8d2015-01-21 15:54:16 -08001163 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
1164 time.sleep( linkSleep )
1165 topologyOutput = main.ONOS2.topology()
1166 LinkUp = main.ONOS1.checkStatus(
1167 topologyOutput,
kelvin-onlab8a832582015-01-16 17:06:11 -08001168 activeSwitches,
1169 str( links ) )
shahshreya9294c8d2015-01-21 15:54:16 -08001170 if LinkUp == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001171 main.log.report( "Link up discovered properly" )
1172 utilities.assert_equals(
1173 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001174 actual=LinkUp,
kelvin-onlab8a832582015-01-16 17:06:11 -08001175 onpass="Link up discovered properly",
1176 onfail="Link up was not discovered in " +
shahshreya9294c8d2015-01-21 15:54:16 -08001177 str( linkSleep ) +
kelvin-onlab8a832582015-01-16 17:06:11 -08001178 " seconds" )
1179
1180 # NOTE Check ping result here..add code for it
1181
1182 main.step( "Compare ONOS Topology to MN Topology" )
1183 Topo = TestONTopology(
1184 main.Mininet1,
1185 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -08001186 MNTopo = Topo
shahshreya9294c8d2015-01-21 15:54:16 -08001187 TopologyCheck = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001188
shahshreya9294c8d2015-01-21 15:54:16 -08001189 devicesJson = main.ONOS2.devices()
1190 linksJson = main.ONOS2.links()
1191 portsJson = main.ONOS2.ports()
kelvin-onlab8a832582015-01-16 17:06:11 -08001192
shahshreya9294c8d2015-01-21 15:54:16 -08001193 result1 = main.Mininet1.compareSwitches(
kelvin-onlab8a832582015-01-16 17:06:11 -08001194 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001195 json.loads( devicesJson ) )
1196 result2 = main.Mininet1.compareLinks(
kelvin-onlab8a832582015-01-16 17:06:11 -08001197 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001198 json.loads( linksJson ) )
1199 # result3 = main.Mininet1.comparePorts(
1200 # MNTopo, json.loads( portsJson ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001201
shahshreya9294c8d2015-01-21 15:54:16 -08001202 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001203 result = result1 and result2
1204 print "***********************"
kelvin-onlab8a832582015-01-16 17:06:11 -08001205
shahshreya4e13a062014-11-11 16:46:18 -08001206 if result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001207 main.log.report( "ONOS" + " Topology matches MN Topology" )
1208 utilities.assert_equals(
1209 expect=main.TRUE,
1210 actual=result,
1211 onpass="ONOS" +
1212 " Topology matches MN Topology",
1213 onfail="ONOS" +
1214 " Topology does not match MN Topology" )
1215
shahshreya9294c8d2015-01-21 15:54:16 -08001216 TopologyCheck = TopologyCheck and result
kelvin-onlab8a832582015-01-16 17:06:11 -08001217 utilities.assert_equals(
1218 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001219 actual=TopologyCheck,
kelvin-onlab8a832582015-01-16 17:06:11 -08001220 onpass="Topology checks passed",
1221 onfail="Topology checks failed" )
1222
shahshreya9294c8d2015-01-21 15:54:16 -08001223 result = LinkDown and LinkUp and TopologyCheck
kelvin-onlab8a832582015-01-16 17:06:11 -08001224 utilities.assert_equals( expect=main.TRUE, actual=result,
1225 onpass="Link failure is discovered correctly",
1226 onfail="Link Discovery failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001227
kelvin-onlab8a832582015-01-16 17:06:11 -08001228 def CASE8( self ):
1229 """
shahshreya82ecd282015-02-05 16:48:03 -08001230 Intent removal
kelvin-onlab8a832582015-01-16 17:06:11 -08001231 """
shahshreya82ecd282015-02-05 16:48:03 -08001232 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001233 main.log.report( "This testcase removes any previously added intents" +
shahshreya82ecd282015-02-05 16:48:03 -08001234 " before adding any new set of intents" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001235 main.log.report( "__________________________________" )
shahshreya82ecd282015-02-05 16:48:03 -08001236 main.log.info( "intent removal" )
1237 main.case( "Removing installed intents" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001238 main.step( "Obtain the intent id's" )
shahshreya9294c8d2015-01-21 15:54:16 -08001239 intentResult = main.ONOS2.intents( jsonFormat=False )
1240 main.log.info( "intent_result = " + intentResult )
shahshreya9294c8d2015-01-21 15:54:16 -08001241 intentLinewise = intentResult.split( "\n" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001242
shahshreyab189da22015-02-25 10:18:26 -08001243 intentList = [line for line in intentLinewise \
1244 if line.startswith( "id=")]
1245 intentids = [line.split( "," )[ 0 ].split( "=" )[ 1 ] for line in \
1246 intentList]
shahshreya4e13a062014-11-11 16:46:18 -08001247 for id in intentids:
1248 print "id = ", id
kelvin-onlab8a832582015-01-16 17:06:11 -08001249
1250 main.step(
1251 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -08001252 for id in intentids:
shahshreya9294c8d2015-01-21 15:54:16 -08001253 main.ONOS2.removeIntent( intentId=id )
kelvin-onlab8a832582015-01-16 17:06:11 -08001254
shahshreya9294c8d2015-01-21 15:54:16 -08001255 intentResult = main.ONOS2.intents( jsonFormat=False )
1256 main.log.info( "intent_result = " + intentResult )
shahshreyab189da22015-02-25 10:18:26 -08001257
1258 intentList = [line for line in intentResult.split( "\n" ) \
1259 if line.startswith( "id=")]
1260 intentState = [line.split( "," )[ 1 ].split( "=" )[ 1 ] for line in \
1261 intentList]
1262 for state in intentState:
1263 print state
1264
1265 case8Result = main.TRUE
1266 for state in intentState:
1267 if state != 'WITHDRAWN':
1268 case8Result = main.FALSE
1269 break
1270
shahshreya9294c8d2015-01-21 15:54:16 -08001271 if case8Result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001272 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001273 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001274 main.log.report( "Intent removal failed" )
1275
shahshreya9294c8d2015-01-21 15:54:16 -08001276 PingResult = main.TRUE
1277 if case8Result == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001278 i = 8
kelvin-onlab8a832582015-01-16 17:06:11 -08001279 while i < 18:
1280 main.log.info(
1281 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1282 ping = main.Mininet1.pingHost(
1283 src="h" + str( i ), target="h" + str( i + 10 ) )
1284 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001285 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -08001286 PingResult = PingResult and main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001287 elif ping == main.FALSE:
1288 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001289 PingResult = PingResult and main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -08001290 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001291 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -08001292 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001293
kelvin-onlab8a832582015-01-16 17:06:11 -08001294 # Note: If the ping result failed, that means the intents have been
1295 # withdrawn correctly.
shahshreya9294c8d2015-01-21 15:54:16 -08001296 if PingResult == main.TRUE:
shahshreya82ecd282015-02-05 16:48:03 -08001297 main.log.report( "Installed intents have not been withdrawn correctly" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001298 # main.cleanup()
1299 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -08001300 if PingResult == main.FALSE:
shahshreya82ecd282015-02-05 16:48:03 -08001301 main.log.report( "Installed intents have been withdrawn correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001302
shahshreya9294c8d2015-01-21 15:54:16 -08001303 case8Result = case8Result and PingResult
shahshreyae6c7cf42014-11-26 16:39:01 -08001304
shahshreya9294c8d2015-01-21 15:54:16 -08001305 if case8Result == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001306 main.log.report( "Intent removal successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001307 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001308 main.log.report( "Intent removal failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001309
shahshreya9294c8d2015-01-21 15:54:16 -08001310 utilities.assert_equals( expect=main.FALSE, actual=case8Result,
1311 onpass="Intent removal test passed",
1312 onfail="Intent removal test failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001313
kelvin-onlab8a832582015-01-16 17:06:11 -08001314 def CASE9( self ):
shahshreyad524a942015-04-21 09:55:16 -07001315 """
1316 Testing Point intents
1317 """
kelvin-onlab8a832582015-01-16 17:06:11 -08001318 main.log.report(
shahshreyad524a942015-04-21 09:55:16 -07001319 "This test case adds point intents and then does pingall" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001320 main.log.report( "__________________________________" )
1321 main.log.info( "Adding point intents" )
1322 main.case(
shahshreya82ecd282015-02-05 16:48:03 -08001323 "Adding bidirectional point for mn hosts" +
1324 "( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22, " +
1325 "h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001326
1327 main.step( "Add point intents for mn hosts h8 and h18 or" +
1328 "ONOS hosts h8 and h12" )
1329 # main.step(var1)
shahshreya9294c8d2015-01-21 15:54:16 -08001330 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001331 "of:0000000000003008/1",
1332 "of:0000000000006018/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001333 if ptpIntentResult == main.TRUE:
1334 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001335 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001336 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001337
shahshreya9294c8d2015-01-21 15:54:16 -08001338 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001339 "of:0000000000006018/1",
1340 "of:0000000000003008/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001341 if ptpIntentResult == main.TRUE:
1342 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001343 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001344 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001345
shahshreya9294c8d2015-01-21 15:54:16 -08001346 var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
1347 main.step(var2)
1348 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001349 "of:0000000000003009/1",
1350 "of:0000000000006019/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001351 if ptpIntentResult == main.TRUE:
1352 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001353 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001354 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001355
shahshreya9294c8d2015-01-21 15:54:16 -08001356 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001357 "of:0000000000006019/1",
1358 "of:0000000000003009/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001359 if ptpIntentResult == main.TRUE:
1360 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001361 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001362 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001363
shahshreya9294c8d2015-01-21 15:54:16 -08001364 var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
1365 main.step(var3)
1366 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001367 "of:0000000000003010/1",
1368 "of:0000000000006020/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001369 if ptpIntentResult == main.TRUE:
1370 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001371 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001372 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001373
shahshreya9294c8d2015-01-21 15:54:16 -08001374 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001375 "of:0000000000006020/1",
1376 "of:0000000000003010/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001377 if ptpIntentResult == main.TRUE:
1378 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001379 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001380 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001381
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001382 var4 = "Add point intents for mininet hosts h11 and h21 or" +\
1383 " ONOS hosts hB and h15"
shahshreya9294c8d2015-01-21 15:54:16 -08001384 main.case(var4)
1385 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001386 "of:0000000000003011/1",
1387 "of:0000000000006021/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001388 if ptpIntentResult == main.TRUE:
1389 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001390 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001391 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001392
shahshreya9294c8d2015-01-21 15:54:16 -08001393 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001394 "of:0000000000006021/1",
1395 "of:0000000000003011/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001396 if ptpIntentResult == main.TRUE:
1397 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001398 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001399 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001400
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001401 var5 = "Add point intents for mininet hosts h12 and h22 " +\
1402 "ONOS hosts hC and h16"
shahshreya9294c8d2015-01-21 15:54:16 -08001403 main.case(var5)
1404 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001405 "of:0000000000003012/1",
1406 "of:0000000000006022/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001407 if ptpIntentResult == main.TRUE:
1408 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001409 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001410 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001411
shahshreya9294c8d2015-01-21 15:54:16 -08001412 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001413 "of:0000000000006022/1",
1414 "of:0000000000003012/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001415 if ptpIntentResult == main.TRUE:
1416 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001417 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001418 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001419
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001420 var6 = "Add point intents for mininet hosts h13 and h23 or" +\
1421 " ONOS hosts hD and h17"
shahshreya9294c8d2015-01-21 15:54:16 -08001422 main.case(var6)
1423 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001424 "of:0000000000003013/1",
1425 "of:0000000000006023/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001426 if ptpIntentResult == main.TRUE:
1427 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001428 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001429 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001430
shahshreya9294c8d2015-01-21 15:54:16 -08001431 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001432 "of:0000000000006023/1",
1433 "of:0000000000003013/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001434 if ptpIntentResult == main.TRUE:
1435 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001436 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001437 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001438
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001439 var7 = "Add point intents for mininet hosts h14 and h24 or" +\
1440 " ONOS hosts hE and h18"
shahshreya9294c8d2015-01-21 15:54:16 -08001441 main.case(var7)
1442 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001443 "of:0000000000003014/1",
1444 "of:0000000000006024/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001445 if ptpIntentResult == main.TRUE:
1446 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001447 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001448 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001449
shahshreya9294c8d2015-01-21 15:54:16 -08001450 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001451 "of:0000000000006024/1",
1452 "of:0000000000003014/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001453 if ptpIntentResult == main.TRUE:
1454 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001455 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001456 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001457
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001458 var8 = "Add point intents for mininet hosts h15 and h25 or" +\
1459 " ONOS hosts hF and h19"
shahshreya9294c8d2015-01-21 15:54:16 -08001460 main.case(var8)
1461 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001462 "of:0000000000003015/1",
1463 "of:0000000000006025/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001464 if ptpIntentResult == main.TRUE:
1465 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001466 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001467 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001468
shahshreya9294c8d2015-01-21 15:54:16 -08001469 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001470 "of:0000000000006025/1",
1471 "of:0000000000003015/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001472 if ptpIntentResult == main.TRUE:
1473 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001474 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001475 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001476
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001477 var9 = "Add intents for mininet hosts h16 and h26 or" +\
1478 " ONOS hosts h10 and h1A"
shahshreya9294c8d2015-01-21 15:54:16 -08001479 main.case(var9)
1480 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001481 "of:0000000000003016/1",
1482 "of:0000000000006026/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001483 if ptpIntentResult == main.TRUE:
1484 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001485 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001486 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001487
shahshreya9294c8d2015-01-21 15:54:16 -08001488 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001489 "of:0000000000006026/1",
1490 "of:0000000000003016/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001491 if ptpIntentResult == main.TRUE:
1492 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001493 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001494 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001495
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001496 var10 = "Add point intents for mininet hosts h17 and h27 or" +\
1497 " ONOS hosts h11 and h1B"
shahshreya9294c8d2015-01-21 15:54:16 -08001498 main.case(var10)
1499 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001500 "of:0000000000003017/1",
1501 "of:0000000000006027/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001502 if ptpIntentResult == main.TRUE:
1503 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001504 main.log.info( "Point to point intent install successful" )
shahshreyab189da22015-02-25 10:18:26 -08001505 #main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001506
shahshreya9294c8d2015-01-21 15:54:16 -08001507 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001508 "of:0000000000006027/1",
1509 "of:0000000000003017/1" )
shahshreya9294c8d2015-01-21 15:54:16 -08001510 if ptpIntentResult == main.TRUE:
1511 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001512 main.log.info( "Point to point intent install successful" )
shahshreyab189da22015-02-25 10:18:26 -08001513 #main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001514
1515 print(
shahshreya9294c8d2015-01-21 15:54:16 -08001516 "___________________________________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001517
1518 flowHandle = main.ONOS2.flows()
shahshreya82ecd282015-02-05 16:48:03 -08001519 #main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001520
1521 count = 1
1522 i = 8
shahshreya9294c8d2015-01-21 15:54:16 -08001523 PingResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001524 while i < 18:
1525 main.log.info(
1526 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1527 ping = main.Mininet1.pingHost(
1528 src="h" + str( i ), target="h" + str( i + 10 ) )
1529 if ping == main.FALSE and count < 5:
1530 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001531 # i = 8
1532 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001533 main.log.report( "Ping between h" +
1534 str( i ) +
1535 " and h" +
1536 str( i +
1537 10 ) +
1538 " failed. Making attempt number " +
1539 str( count ) +
1540 " in 2 seconds" )
1541 time.sleep( 2 )
1542 elif ping == main.FALSE:
1543 main.log.report( "All ping attempts between h" +
1544 str( i ) +
1545 " and h" +
1546 str( i +
1547 10 ) +
1548 "have failed" )
1549 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -08001550 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001551 elif ping == main.TRUE:
1552 main.log.info( "Ping test between h" +
1553 str( i ) +
1554 " and h" +
1555 str( i +
1556 10 ) +
1557 "passed!" )
1558 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001559 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001560 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001561 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -08001562 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001563
shahshreya9294c8d2015-01-21 15:54:16 -08001564 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001565 main.log.report(
1566 "Point intents have not ben installed correctly. Cleaning up" )
1567 # main.cleanup()
1568 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -08001569 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001570 main.log.report( "Point Intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001571
shahshreya9294c8d2015-01-21 15:54:16 -08001572 case9Result = PingResult
kelvin-onlab8a832582015-01-16 17:06:11 -08001573 utilities.assert_equals(
1574 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001575 actual=case9Result,
kelvin-onlab8a832582015-01-16 17:06:11 -08001576 onpass="Point intents addition and Pingall Test successful",
1577 onfail="Point intents addition and Pingall Test NOT successful" )