blob: 45d66dc7935fd97c3870ae6473448934c4496bfc [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
shahshreya82ecd282015-02-05 16:48:03 -080044 main.step( "Git checkout and get version" )
shahshreyaa47ebf42015-05-20 13:29:18 -070045 main.ONOSbench.gitCheckout( "master" )
shahshreya9294c8d2015-01-21 15:54:16 -080046 gitPullResult = main.ONOSbench.gitPull()
shahshreya82ecd282015-02-05 16:48:03 -080047 main.log.info( "git_pull_result = " + str( gitPullResult ))
shahshreya9294c8d2015-01-21 15:54:16 -080048 main.ONOSbench.getVersion( report=True )
kelvin-onlab8a832582015-01-16 17:06:11 -080049
shahshreyaa47ebf42015-05-20 13:29:18 -070050 if gitPullResult == 100:
kelvin-onlab8a832582015-01-16 17:06:11 -080051 main.step( "Using mvn clean & install" )
shahshreya9294c8d2015-01-21 15:54:16 -080052 main.ONOSbench.cleanInstall()
53 elif gitPullResult == 0:
kelvin-onlab8a832582015-01-16 17:06:11 -080054 main.log.report(
55 "Git Pull Failed, look into logs for detailed reason" )
shahshreyaa22f8f82014-12-08 16:59:21 -080056 main.cleanup()
kelvin-onlab8a832582015-01-16 17:06:11 -080057 main.exit()
58
59 main.step( "Creating ONOS package" )
shahshreya9294c8d2015-01-21 15:54:16 -080060 packageResult = main.ONOSbench.onosPackage()
shahshreya4e13a062014-11-11 16:46:18 -080061
kelvin-onlab8a832582015-01-16 17:06:11 -080062 main.step( "Installing ONOS package" )
shahshreya9294c8d2015-01-21 15:54:16 -080063 onosInstallResult = main.ONOSbench.onosInstall()
64 if onosInstallResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -080065 main.log.report( "Installing ONOS package successful" )
shahshreya4e13a062014-11-11 16:46:18 -080066 else:
kelvin-onlab8a832582015-01-16 17:06:11 -080067 main.log.report( "Installing ONOS package failed" )
shahshreya4e13a062014-11-11 16:46:18 -080068
shahshreya9294c8d2015-01-21 15:54:16 -080069 onos1Isup = main.ONOSbench.isup()
70 if onos1Isup == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -080071 main.log.report( "ONOS instance is up and ready" )
shahshreya4e13a062014-11-11 16:46:18 -080072 else:
kelvin-onlab8a832582015-01-16 17:06:11 -080073 main.log.report( "ONOS instance may not be up" )
shahshreya4e13a062014-11-11 16:46:18 -080074
kelvin-onlab8a832582015-01-16 17:06:11 -080075 main.step( "Starting ONOS service" )
shahshreya9294c8d2015-01-21 15:54:16 -080076 startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -080077
shahshreya9294c8d2015-01-21 15:54:16 -080078 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
shahshreya82ecd282015-02-05 16:48:03 -080079 main.step( "Starting Mininet CLI..." )
80
81 # Starting the mininet using the old way
82 main.step( "Starting Mininet ..." )
83 netIsUp = main.Mininet1.startNet()
84 if netIsUp:
85 main.log.info("Mininet CLI is up")
86
shahshreya9294c8d2015-01-21 15:54:16 -080087 case1Result = ( packageResult and
88 cellResult and verifyResult
89 and onosInstallResult and
90 onos1Isup and startResult )
91 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
kelvin-onlab8a832582015-01-16 17:06:11 -080092 onpass="Test startup successful",
93 onfail="Test startup NOT successful" )
94
95 def CASE2( self, main ):
96 """
shahshreyaa22f8f82014-12-08 16:59:21 -080097 Switch Down
kelvin-onlab8a832582015-01-16 17:06:11 -080098 """
99 # NOTE: You should probably run a topology check after this
100 import time
shahshreyaa22f8f82014-12-08 16:59:21 -0800101
kelvin-onlab8a832582015-01-16 17:06:11 -0800102 main.case( "Switch down discovery" )
103 main.log.report( "This testcase is testing a switch down discovery" )
104 main.log.report( "__________________________________" )
105
shahshreya9294c8d2015-01-21 15:54:16 -0800106 switchSleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
shahshreyaa22f8f82014-12-08 16:59:21 -0800107
108 description = "Killing a switch to ensure it is discovered correctly"
kelvin-onlab8a832582015-01-16 17:06:11 -0800109 main.log.report( description )
110 main.case( description )
shahshreyaa22f8f82014-12-08 16:59:21 -0800111
kelvin-onlab8a832582015-01-16 17:06:11 -0800112 # TODO: Make this switch parameterizable
113 main.step( "Kill s28 " )
114 main.log.report( "Deleting s28" )
115 # FIXME: use new dynamic topo functions
shahshreya9294c8d2015-01-21 15:54:16 -0800116 main.Mininet1.delSwitch( "s28" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800117 main.log.info(
118 "Waiting " +
shahshreya9294c8d2015-01-21 15:54:16 -0800119 str( switchSleep ) +
kelvin-onlab8a832582015-01-16 17:06:11 -0800120 " seconds for switch down to be discovered" )
shahshreya9294c8d2015-01-21 15:54:16 -0800121 time.sleep( switchSleep )
kelvin-onlab8a832582015-01-16 17:06:11 -0800122 # Peek at the deleted switch
shahshreya9294c8d2015-01-21 15:54:16 -0800123 device = main.ONOS2.getDevice( dpid="0028" )
shahshreyaa22f8f82014-12-08 16:59:21 -0800124 print "device = ", device
kelvin-onlab8a832582015-01-16 17:06:11 -0800125 if device[ u'available' ] == 'False':
shahshreya9294c8d2015-01-21 15:54:16 -0800126 case2Result = main.FALSE
shahshreyaa22f8f82014-12-08 16:59:21 -0800127 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800128 case2Result = main.TRUE
129 utilities.assert_equals( expect=main.TRUE, actual=case2Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800130 onpass="Switch down discovery successful",
131 onfail="Switch down discovery failed" )
shahshreyaa22f8f82014-12-08 16:59:21 -0800132
shahshreyab189da22015-02-25 10:18:26 -0800133 def CASE101( self, main ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800134 """
shahshreya4e13a062014-11-11 16:46:18 -0800135 Cleanup sequence:
shahshreya9294c8d2015-01-21 15:54:16 -0800136 onos-service <nodeIp> stop
shahshreya4e13a062014-11-11 16:46:18 -0800137 onos-uninstall
138
139 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800140
kelvin-onlab8a832582015-01-16 17:06:11 -0800141 """
shahshreya9294c8d2015-01-21 15:54:16 -0800142 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800143
kelvin-onlab8a832582015-01-16 17:06:11 -0800144 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800145
kelvin-onlab8a832582015-01-16 17:06:11 -0800146 main.step( "Testing ONOS kill function" )
shahshreya9294c8d2015-01-21 15:54:16 -0800147 killResult = main.ONOSbench.onosKill( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800148
kelvin-onlab8a832582015-01-16 17:06:11 -0800149 main.step( "Stopping ONOS service" )
shahshreya9294c8d2015-01-21 15:54:16 -0800150 stopResult = main.ONOSbench.onosStop( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800151
kelvin-onlab8a832582015-01-16 17:06:11 -0800152 main.step( "Uninstalling ONOS service" )
shahshreya9294c8d2015-01-21 15:54:16 -0800153 uninstallResult = main.ONOSbench.onosUninstall()
154
155 case11Result = killResult and stopResult and uninstallResult
156 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
157 onpass="Cleanup successful",
158 onfail="Cleanup failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800159
kelvin-onlab8a832582015-01-16 17:06:11 -0800160 def CASE3( self, main ):
161 """
shahshreya4e13a062014-11-11 16:46:18 -0800162 Test 'onos' command and its functionality in driver
kelvin-onlab8a832582015-01-16 17:06:11 -0800163 """
shahshreya9294c8d2015-01-21 15:54:16 -0800164 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800165
kelvin-onlab8a832582015-01-16 17:06:11 -0800166 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800167
kelvin-onlab8a832582015-01-16 17:06:11 -0800168 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800169 cmdstr1 = "system:name"
shahshreya9294c8d2015-01-21 15:54:16 -0800170 cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
171 main.log.info( "onos command returned: " + cmdResult1 )
shahshreya4e13a062014-11-11 16:46:18 -0800172
kelvin-onlab8a832582015-01-16 17:06:11 -0800173 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800174 cmdstr2 = "onos:topology"
shahshreya9294c8d2015-01-21 15:54:16 -0800175 cmdResult2 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
176 main.log.info( "onos command returned: " + cmdResult2 )
shahshreya4e13a062014-11-11 16:46:18 -0800177
kelvin-onlab8a832582015-01-16 17:06:11 -0800178 def CASE20( self ):
179 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800180 Exit from mininet cli
181 reinstall ONOS
kelvin-onlab8a832582015-01-16 17:06:11 -0800182 """
shahshreya9294c8d2015-01-21 15:54:16 -0800183 cellName = main.params[ 'ENV' ][ 'cellName' ]
184 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
kelvin-onlab8a832582015-01-16 17:06:11 -0800185
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800186 main.log.report( "This testcase exits the mininet cli and reinstalls" +
187 "ONOS to switch over to Packet Optical topology" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800188 main.log.report( "_____________________________________________" )
189 main.case( "Disconnecting mininet and restarting ONOS" )
190 main.step( "Disconnecting mininet and restarting ONOS" )
shahshreya9294c8d2015-01-21 15:54:16 -0800191 mininetDisconnect = main.Mininet1.disconnect()
shahshreyaa47ebf42015-05-20 13:29:18 -0700192 print "mininetDisconnect = ", mininetDisconnect
shahshreyae6c7cf42014-11-26 16:39:01 -0800193
kelvin-onlab8a832582015-01-16 17:06:11 -0800194 main.step( "Removing raft logs before a clen installation of ONOS" )
shahshreya9294c8d2015-01-21 15:54:16 -0800195 main.ONOSbench.onosRemoveRaftLogs()
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800196
kelvin-onlab8a832582015-01-16 17:06:11 -0800197 main.step( "Applying cell variable to environment" )
shahshreya9294c8d2015-01-21 15:54:16 -0800198 cellResult = main.ONOSbench.setCell( cellName )
199 verifyResult = main.ONOSbench.verifyCell()
shahshreyae6c7cf42014-11-26 16:39:01 -0800200
shahshreya9294c8d2015-01-21 15:54:16 -0800201 onosInstallResult = main.ONOSbench.onosInstall()
202 if onosInstallResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800203 main.log.report( "Installing ONOS package successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800204 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800205 main.log.report( "Installing ONOS package failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800206
shahshreya9294c8d2015-01-21 15:54:16 -0800207 onos1Isup = main.ONOSbench.isup()
208 if onos1Isup == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800209 main.log.report( "ONOS instance is up and ready" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800210 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800211 main.log.report( "ONOS instance may not be up" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800212
kelvin-onlab8a832582015-01-16 17:06:11 -0800213 main.step( "Starting ONOS service" )
shahshreya9294c8d2015-01-21 15:54:16 -0800214 startResult = main.ONOSbench.onosStart( ONOS1Ip )
kelvin-onlab8a832582015-01-16 17:06:11 -0800215
shahshreya9294c8d2015-01-21 15:54:16 -0800216 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
217 case20Result = mininetDisconnect and cellResult and verifyResult \
218 and onosInstallResult and onos1Isup and \
219 startResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800220 utilities.assert_equals(
221 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800222 actual=case20Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800223 onpass= "Exiting functionality mininet topology and reinstalling" +
224 " ONOS successful",
225 onfail= "Exiting functionality mininet topology and reinstalling" +
226 " ONOS failed" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800227
228 def CASE21( self, main ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800229 """
shahshreya9294c8d2015-01-21 15:54:16 -0800230 On ONOS bench, run this command:
shahshreya7630b1c2015-04-03 15:37:14 -0700231 sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1
232 which spawns packet optical topology and copies the links
shahshreya9294c8d2015-01-21 15:54:16 -0800233 json file to the onos instance.
234 Note that in case of Packet Optical, the links are not learnt
235 from the topology, instead the links are learnt
shahshreyae6c7cf42014-11-26 16:39:01 -0800236 from the json config file
kelvin-onlab8a832582015-01-16 17:06:11 -0800237 """
238 main.log.report(
239 "This testcase starts the packet layer topology and REST" )
240 main.log.report( "_____________________________________________" )
241 main.case( "Starting LINC-OE and other components" )
242 main.step( "Starting LINC-OE and other components" )
shahshreyad524a942015-04-21 09:55:16 -0700243 main.log.info( "Activate optical app" )
244 appInstallResult = main.ONOS2.activateApp( "org.onosproject.optical" )
245 appCheck = main.ONOS2.appToIDCheck()
246 if appCheck != main.TRUE:
247 main.log.warn( main.ONOS2.apps() )
248 main.log.warn( main.ONOS2.appIDs() )
249
shahshreya215c48f2015-04-06 15:55:55 -0700250 opticalMnScript = main.LincOE2.runOpticalMnScript(ctrllerIP = main.params[ 'CTRL' ][ 'ip1' ])
kelvin-onlab8a832582015-01-16 17:06:11 -0800251
shahshreya7630b1c2015-04-03 15:37:14 -0700252 case21Result = opticalMnScript and appInstallResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800253 utilities.assert_equals(
254 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800255 actual=case21Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800256 onpass="Packet optical topology spawned successsfully",
257 onfail="Packet optical topology spawning failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800258
kelvin-onlab8a832582015-01-16 17:06:11 -0800259 def CASE22( self, main ):
260 """
shahshreya7630b1c2015-04-03 15:37:14 -0700261 Curretly we use, 10 optical switches(ROADM's) and
262 6 packet layer mininet switches each with one host.
263 Therefore, the roadmCount variable = 10,
264 packetLayerSWCount variable = 6, hostCount=6 and
265 links=42.
266 All this is hardcoded in the testcase. If the topology changes,
shahshreya9294c8d2015-01-21 15:54:16 -0800267 these hardcoded values need to be changed
kelvin-onlab8a832582015-01-16 17:06:11 -0800268 """
269 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800270 "This testcase compares the optical+packet topology against what" +
271 " is expected" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800272 main.case( "Topology comparision" )
273 main.step( "Topology comparision" )
shahshreya9294c8d2015-01-21 15:54:16 -0800274 main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
275 devicesResult = main.ONOS3.devices( jsonFormat=False )
shahshreyae6c7cf42014-11-26 16:39:01 -0800276
shahshreya9294c8d2015-01-21 15:54:16 -0800277 print "devices_result = ", devicesResult
278 devicesLinewise = devicesResult.split( "\n" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800279 roadmCount = 0
280 packetLayerSWCount = 0
shahshreya9294c8d2015-01-21 15:54:16 -0800281 for line in devicesLinewise:
kelvin-onlab8a832582015-01-16 17:06:11 -0800282 components = line.split( "," )
283 availability = components[ 1 ].split( "=" )[ 1 ]
284 type = components[ 3 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800285 if availability == 'true' and type == 'ROADM':
286 roadmCount += 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800287 elif availability == 'true' and type == 'SWITCH':
shahshreyae6c7cf42014-11-26 16:39:01 -0800288 packetLayerSWCount += 1
shahshreya7630b1c2015-04-03 15:37:14 -0700289 if roadmCount == 10:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800290 print "Number of Optical Switches = %d and is" % roadmCount +\
291 " correctly detected"
kelvin-onlab8a832582015-01-16 17:06:11 -0800292 main.log.info(
293 "Number of Optical Switches = " +
294 str( roadmCount ) +
295 " and is correctly detected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800296 opticalSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800297 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800298 print "Number of Optical Switches = %d and is wrong" % roadmCount
kelvin-onlab8a832582015-01-16 17:06:11 -0800299 main.log.info(
300 "Number of Optical Switches = " +
301 str( roadmCount ) +
302 " and is wrong" )
shahshreya9294c8d2015-01-21 15:54:16 -0800303 opticalSWResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800304
shahshreya7630b1c2015-04-03 15:37:14 -0700305 if packetLayerSWCount == 6:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800306 print "Number of Packet layer or mininet Switches = %d "\
307 % packetLayerSWCount + "and is correctly detected"
kelvin-onlab8a832582015-01-16 17:06:11 -0800308 main.log.info(
309 "Number of Packet layer or mininet Switches = " +
310 str( packetLayerSWCount ) +
311 " and is correctly detected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800312 packetSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800313 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800314 print "Number of Packet layer or mininet Switches = %d and"\
315 % packetLayerSWCount + " is wrong"
kelvin-onlab8a832582015-01-16 17:06:11 -0800316 main.log.info(
317 "Number of Packet layer or mininet Switches = " +
318 str( packetLayerSWCount ) +
319 " and is wrong" )
shahshreya9294c8d2015-01-21 15:54:16 -0800320 packetSWResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800321 print "_________________________________"
kelvin-onlab8a832582015-01-16 17:06:11 -0800322
shahshreya9294c8d2015-01-21 15:54:16 -0800323 linksResult = main.ONOS3.links( jsonFormat=False )
324 print "links_result = ", linksResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800325 print "_________________________________"
shahshreya7630b1c2015-04-03 15:37:14 -0700326 linkActiveCount = linksResult.count("state=ACTIVE")
327 main.log.info( "linkActiveCount = " + str( linkActiveCount ))
328 if linkActiveCount == 42:
329 linkActiveResult = main.TRUE
330 main.log.info(
331 "Number of links in ACTIVE state are correct")
332 else:
333 linkActiveResult = main.FALSE
334 main.log.info(
335 "Number of links in ACTIVE state are wrong")
kelvin-onlab8a832582015-01-16 17:06:11 -0800336
shahshreya9294c8d2015-01-21 15:54:16 -0800337 # NOTE:Since only point intents are added, there is no
338 # requirement to discover the hosts
kelvin-onlab8a832582015-01-16 17:06:11 -0800339 # Therfore, the below portion of the code is commented.
340 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800341 #Discover hosts using pingall
shahshreya9294c8d2015-01-21 15:54:16 -0800342 pingallResult = main.LincOE2.pingall()
kelvin-onlab8a832582015-01-16 17:06:11 -0800343
shahshreya9294c8d2015-01-21 15:54:16 -0800344 hostsResult = main.ONOS3.hosts( jsonFormat=False )
345 main.log.info( "hosts_result = "+hostsResult )
kelvin-onlab8a832582015-01-16 17:06:11 -0800346 main.log.info( "_________________________________" )
shahshreya9294c8d2015-01-21 15:54:16 -0800347 hostsLinewise = hostsResult.split( "\n" )
348 hostsLinewise = hostsLinewise[ 1:-1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800349 hostCount = 0
shahshreya9294c8d2015-01-21 15:54:16 -0800350 for line in hostsLinewise:
kelvin-onlab8a832582015-01-16 17:06:11 -0800351 hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800352 hostCount +=1
353 if hostCount ==2:
354 print "Number of hosts = %d and is correctly detected" %hostCount
shahshreya9294c8d2015-01-21 15:54:16 -0800355 main.log.info( "Number of hosts = " + str( hostCount ) +" and \
356 is correctly detected" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800357 hostDiscovery = main.TRUE
358 else:
359 print "Number of hosts = %d and is wrong" %hostCount
shahshreya9294c8d2015-01-21 15:54:16 -0800360 main.log.info( "Number of hosts = " + str( hostCount ) +" and \
361 is wrong" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800362 hostDiscovery = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800363 """
shahshreya7630b1c2015-04-03 15:37:14 -0700364 case22Result = opticalSWResult and packetSWResult and \
365 linkActiveResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800366 utilities.assert_equals(
367 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800368 actual=case22Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800369 onpass="Packet optical topology discovery successful",
370 onfail="Packet optical topology discovery failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800371
kelvin-onlab8a832582015-01-16 17:06:11 -0800372 def CASE23( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800373 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800374 """
shahshreya9294c8d2015-01-21 15:54:16 -0800375 Add bidirectional point intents between 2 packet layer( mininet )
376 devices and
shahshreyae6c7cf42014-11-26 16:39:01 -0800377 ping mininet hosts
kelvin-onlab8a832582015-01-16 17:06:11 -0800378 """
379 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800380 "This testcase adds bidirectional point intents between 2 " +
381 "packet layer( mininet ) devices and ping mininet hosts" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800382 main.case( "Topology comparision" )
383 main.step( "Adding point intents" )
shahshreya9294c8d2015-01-21 15:54:16 -0800384 ptpIntentResult = main.ONOS3.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -0800385 "of:0000ffffffff0001/1",
shahshreya7630b1c2015-04-03 15:37:14 -0700386 "of:0000ffffffff0005/1" )
shahshreya9294c8d2015-01-21 15:54:16 -0800387 if ptpIntentResult == main.TRUE:
388 main.ONOS3.intents( jsonFormat=False )
kelvin-onlab8a832582015-01-16 17:06:11 -0800389 main.log.info( "Point to point intent install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800390
shahshreya9294c8d2015-01-21 15:54:16 -0800391 ptpIntentResult = main.ONOS3.addPointIntent(
shahshreya7630b1c2015-04-03 15:37:14 -0700392 "of:0000ffffffff0005/1",
kelvin-onlab8a832582015-01-16 17:06:11 -0800393 "of:0000ffffffff0001/1" )
shahshreya9294c8d2015-01-21 15:54:16 -0800394 if ptpIntentResult == main.TRUE:
395 main.ONOS3.intents( jsonFormat=False )
kelvin-onlab8a832582015-01-16 17:06:11 -0800396 main.log.info( "Point to point intent install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800397
shahshreya7630b1c2015-04-03 15:37:14 -0700398 time.sleep( 30 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800399 flowHandle = main.ONOS3.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -0800400 main.log.info( "flows :" + flowHandle )
shahshreyae6c7cf42014-11-26 16:39:01 -0800401
402 # Sleep for 30 seconds to provide time for the intent state to change
shahshreya7630b1c2015-04-03 15:37:14 -0700403 time.sleep( 60 )
shahshreya9294c8d2015-01-21 15:54:16 -0800404 intentHandle = main.ONOS3.intents( jsonFormat=False )
kelvin-onlab8a832582015-01-16 17:06:11 -0800405 main.log.info( "intents :" + intentHandle )
406
shahshreya9294c8d2015-01-21 15:54:16 -0800407 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800408 count = 1
shahshreya7630b1c2015-04-03 15:37:14 -0700409 main.log.info( "\n\nh1 is Pinging h5" )
410 ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
shahshreya9294c8d2015-01-21 15:54:16 -0800411 # ping = main.LincOE2.pinghost()
kelvin-onlab8a832582015-01-16 17:06:11 -0800412 if ping == main.FALSE and count < 5:
413 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -0800414 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800415 main.log.info(
shahshreya7630b1c2015-04-03 15:37:14 -0700416 "Ping between h1 and h5 failed. Making attempt number " +
kelvin-onlab8a832582015-01-16 17:06:11 -0800417 str( count ) +
418 " in 2 seconds" )
419 time.sleep( 2 )
420 elif ping == main.FALSE:
shahshreya7630b1c2015-04-03 15:37:14 -0700421 main.log.info( "All ping attempts between h1 and h5 have failed" )
shahshreya9294c8d2015-01-21 15:54:16 -0800422 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800423 elif ping == main.TRUE:
shahshreya7630b1c2015-04-03 15:37:14 -0700424 main.log.info( "Ping test between h1 and h5 passed!" )
shahshreya9294c8d2015-01-21 15:54:16 -0800425 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800426 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800427 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -0800428 PingResult = main.ERROR
kelvin-onlab8a832582015-01-16 17:06:11 -0800429
shahshreya9294c8d2015-01-21 15:54:16 -0800430 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800431 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800432 "Point intents for packet optical have not ben installed" +
433 " correctly. Cleaning up" )
shahshreya9294c8d2015-01-21 15:54:16 -0800434 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800435 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800436 "Point Intents for packet optical have been " +
437 "installed correctly" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800438
shahshreya9294c8d2015-01-21 15:54:16 -0800439 case23Result = PingResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800440 utilities.assert_equals(
441 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800442 actual=case23Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800443 onpass= "Point intents addition for packet optical and" +
444 "Pingall Test successful",
445 onfail= "Point intents addition for packet optical and" +
446 "Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800447
kelvin-onlab8a832582015-01-16 17:06:11 -0800448 def CASE24( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800449 import time
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800450 import json
kelvin-onlab8a832582015-01-16 17:06:11 -0800451 """
shahshreya7630b1c2015-04-03 15:37:14 -0700452 LINC uses its own switch IDs. You can use the following
453 command on the LINC console to find the mapping between
454 DPIDs and LINC IDs.
455 rp(application:get_all_key(linc)).
456
shahshreya9294c8d2015-01-21 15:54:16 -0800457 Test Rerouting of Packet Optical by bringing a port down
shahshreya7630b1c2015-04-03 15:37:14 -0700458 ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
459 so that link
460 ( between switch1 port20 - switch5 port50 ) is inactive
shahshreya9294c8d2015-01-21 15:54:16 -0800461 and do a ping test. If rerouting is successful,
462 ping should pass. also check the flows
kelvin-onlab8a832582015-01-16 17:06:11 -0800463 """
464 main.log.report(
465 "This testcase tests rerouting and pings mininet hosts" )
466 main.case( "Test rerouting and pings mininet hosts" )
shahshreya7630b1c2015-04-03 15:37:14 -0700467 main.step( "Attach to the Linc-OE session" )
468 attachConsole = main.LincOE1.attachLincOESession()
469 print "attachConsole = ", attachConsole
470
kelvin-onlab8a832582015-01-16 17:06:11 -0800471 main.step( "Bring a port down and verify the link state" )
shahshreya7630b1c2015-04-03 15:37:14 -0700472 main.LincOE1.portDown( swId="9", ptId="20" )
shahshreya9294c8d2015-01-21 15:54:16 -0800473 linksNonjson = main.ONOS3.links( jsonFormat=False )
474 main.log.info( "links = " + linksNonjson )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800475
shahshreya7630b1c2015-04-03 15:37:14 -0700476 linkInactiveCount = linksNonjson.count("state=INACTIVE")
477 main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
478 if linkInactiveCount == 2:
479 main.log.info(
480 "Number of links in INACTIVE state are correct")
481 else:
482 main.log.info(
483 "Number of links in INACTIVE state are wrong")
484
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800485 links = main.ONOS3.links()
kelvin-onlab8a832582015-01-16 17:06:11 -0800486 main.log.info( "links = " + links )
487
shahshreya9294c8d2015-01-21 15:54:16 -0800488 linksResult = json.loads( links )
489 linksStateResult = main.FALSE
490 for item in linksResult:
kelvin-onlab8a832582015-01-16 17:06:11 -0800491 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
shahshreya7630b1c2015-04-03 15:37:14 -0700492 'src' ][ 'port' ] == "20":
493 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
494 'dst' ][ 'port' ] == "50":
shahshreya9294c8d2015-01-21 15:54:16 -0800495 linksState = item[ 'state' ]
496 if linksState == "INACTIVE":
kelvin-onlab8a832582015-01-16 17:06:11 -0800497 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800498 "Links state is inactive as expected due to one" +
499 " of the ports being down" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800500 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800501 "Links state is inactive as expected due to one" +
502 " of the ports being down" )
shahshreya9294c8d2015-01-21 15:54:16 -0800503 linksStateResult = main.TRUE
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800504 break
505 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800506 main.log.info(
507 "Links state is not inactive as expected" )
508 main.log.report(
509 "Links state is not inactive as expected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800510 linksStateResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800511
shahshreya9294c8d2015-01-21 15:54:16 -0800512 print "links_state_result = ", linksStateResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800513 time.sleep( 10 )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800514 flowHandle = main.ONOS3.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -0800515 main.log.info( "flows :" + flowHandle )
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800516
kelvin-onlab8a832582015-01-16 17:06:11 -0800517 main.step( "Verify Rerouting by a ping test" )
shahshreya9294c8d2015-01-21 15:54:16 -0800518 PingResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800519 count = 1
shahshreya7630b1c2015-04-03 15:37:14 -0700520 main.log.info( "\n\nh1 is Pinging h5" )
521 ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
shahshreya9294c8d2015-01-21 15:54:16 -0800522 # ping = main.LincOE2.pinghost()
kelvin-onlab8a832582015-01-16 17:06:11 -0800523 if ping == main.FALSE and count < 5:
524 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -0800525 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800526 main.log.info(
shahshreya7630b1c2015-04-03 15:37:14 -0700527 "Ping between h1 and h5 failed. Making attempt number " +
kelvin-onlab8a832582015-01-16 17:06:11 -0800528 str( count ) +
529 " in 2 seconds" )
530 time.sleep( 2 )
531 elif ping == main.FALSE:
shahshreya7630b1c2015-04-03 15:37:14 -0700532 main.log.info( "All ping attempts between h1 and h5 have failed" )
shahshreya9294c8d2015-01-21 15:54:16 -0800533 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800534 elif ping == main.TRUE:
shahshreya7630b1c2015-04-03 15:37:14 -0700535 main.log.info( "Ping test between h1 and h5 passed!" )
shahshreya9294c8d2015-01-21 15:54:16 -0800536 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800537 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800538 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -0800539 PingResult = main.ERROR
shahshreyae6c7cf42014-11-26 16:39:01 -0800540
shahshreya9294c8d2015-01-21 15:54:16 -0800541 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800542 main.log.report( "Ping test successful " )
shahshreya9294c8d2015-01-21 15:54:16 -0800543 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800544 main.log.report( "Ping test failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800545
shahshreya9294c8d2015-01-21 15:54:16 -0800546 case24Result = PingResult and linksStateResult
547 utilities.assert_equals( expect=main.TRUE, actual=case24Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800548 onpass="Packet optical rerouting successful",
549 onfail="Packet optical rerouting failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800550
kelvin-onlab8a832582015-01-16 17:06:11 -0800551 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800552 import re
553 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800554 main.log.report( "This testcase is testing the assignment of" +
555 " all the switches to all the controllers and" +
shahshreyab189da22015-02-25 10:18:26 -0800556 " discovering the hosts in reactive mode" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800557 main.log.report( "__________________________________" )
shahshreyaa47ebf42015-05-20 13:29:18 -0700558
kelvin-onlab8a832582015-01-16 17:06:11 -0800559 main.case( "Pingall Test" )
560 main.step( "Assigning switches to controllers" )
shahshreya9294c8d2015-01-21 15:54:16 -0800561 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
562 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
kelvin-onlab8a832582015-01-16 17:06:11 -0800563 for i in range( 1, 29 ):
564 if i == 1:
shahshreya9294c8d2015-01-21 15:54:16 -0800565 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800566 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800567 ip1=ONOS1Ip,
568 port1=ONOS1Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800569 elif i >= 2 and i < 5:
shahshreya9294c8d2015-01-21 15:54:16 -0800570 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800571 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800572 ip1=ONOS1Ip,
573 port1=ONOS1Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800574 elif i >= 5 and i < 8:
shahshreya9294c8d2015-01-21 15:54:16 -0800575 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800576 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800577 ip1=ONOS1Ip,
578 port1=ONOS1Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800579 elif i >= 8 and i < 18:
shahshreya9294c8d2015-01-21 15:54:16 -0800580 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800581 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800582 ip1=ONOS1Ip,
583 port1=ONOS1Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800584 elif i >= 18 and i < 28:
shahshreya9294c8d2015-01-21 15:54:16 -0800585 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800586 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800587 ip1=ONOS1Ip,
588 port1=ONOS1Port )
shahshreya4e13a062014-11-11 16:46:18 -0800589 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800590 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800591 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800592 ip1=ONOS1Ip,
593 port1=ONOS1Port )
594 SwitchMastership = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800595 for i in range( 1, 29 ):
596 if i == 1:
shahshreya9294c8d2015-01-21 15:54:16 -0800597 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800598 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800599 if re.search( "tcp:" + ONOS1Ip, response ):
600 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800601 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800602 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800603 elif i >= 2 and i < 5:
shahshreya9294c8d2015-01-21 15:54:16 -0800604 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800605 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800606 if re.search( "tcp:" + ONOS1Ip, response ):
607 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800608 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800609 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800610 elif i >= 5 and i < 8:
shahshreya9294c8d2015-01-21 15:54:16 -0800611 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800612 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800613 if re.search( "tcp:" + ONOS1Ip, response ):
614 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800615 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800616 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800617 elif i >= 8 and i < 18:
shahshreya9294c8d2015-01-21 15:54:16 -0800618 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800619 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800620 if re.search( "tcp:" + ONOS1Ip, response ):
621 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800622 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800623 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800624 elif i >= 18 and i < 28:
shahshreya9294c8d2015-01-21 15:54:16 -0800625 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800626 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800627 if re.search( "tcp:" + ONOS1Ip, response ):
628 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800629 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800630 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800631 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800632 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800633 print( "Response is" + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800634 if re.search( "tcp:" + ONOS1Ip, response ):
635 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800636 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800637 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800638
shahshreya9294c8d2015-01-21 15:54:16 -0800639 if SwitchMastership == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800640 main.log.report( "Controller assignmnet successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800641 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800642 main.log.report( "Controller assignmnet failed" )
643 utilities.assert_equals(
644 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800645 actual=SwitchMastership,
kelvin-onlab8a832582015-01-16 17:06:11 -0800646 onpass="MasterControllers assigned correctly" )
647 """
648 for i in range ( 1,29 ):
shahshreya9294c8d2015-01-21 15:54:16 -0800649 main.Mininet1.assignSwController( sw=str( i ),count=5,
650 ip1=ONOS1Ip,port1=ONOS1Port,
651 ip2=ONOS2Ip,port2=ONOS2Port,
652 ip3=ONOS3Ip,port3=ONOS3Port,
653 ip4=ONOS4Ip,port4=ONOS4Port,
654 ip5=ONOS5Ip,port5=ONOS5Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800655 """
656 # REACTIVE FWD test
shahshreyad524a942015-04-21 09:55:16 -0700657 main.log.info( "Activate fwd app" )
658 appInstallResult = main.ONOS2.activateApp( "org.onosproject.fwd" )
659 appCheck = main.ONOS2.appToIDCheck()
660 if appCheck != main.TRUE:
661 main.log.warn( main.ONOS2.apps() )
662 main.log.warn( main.ONOS2.appIDs() )
663 time.sleep( 10 )
shahshreya4e13a062014-11-11 16:46:18 -0800664
kelvin-onlab8a832582015-01-16 17:06:11 -0800665 main.step( "Get list of hosts from Mininet" )
shahshreya9294c8d2015-01-21 15:54:16 -0800666 hostList = main.Mininet1.getHosts()
667 main.log.info( hostList )
shahshreya4e13a062014-11-11 16:46:18 -0800668
kelvin-onlab8a832582015-01-16 17:06:11 -0800669 main.step( "Get host list in ONOS format" )
shahshreya9294c8d2015-01-21 15:54:16 -0800670 hostOnosList = main.ONOS2.getHostsId( hostList )
671 main.log.info( hostOnosList )
kelvin-onlab8a832582015-01-16 17:06:11 -0800672 # time.sleep( 5 )
673
674 main.step( "Pingall" )
shahshreya9294c8d2015-01-21 15:54:16 -0800675 pingResult = main.FALSE
shahshreya82ecd282015-02-05 16:48:03 -0800676 time1 = time.time()
677 pingResult = main.Mininet1.pingall()
678 time2 = time.time()
679 print "Time for pingall: %2f seconds" % ( time2 - time1 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800680
shahshreya9294c8d2015-01-21 15:54:16 -0800681 # Start onos cli again because u might have dropped out of
682 # onos prompt to the shell prompt
kelvin-onlab8a832582015-01-16 17:06:11 -0800683 # if there was no activity
shahshreya9294c8d2015-01-21 15:54:16 -0800684 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800685
shahshreya9294c8d2015-01-21 15:54:16 -0800686 case4Result = SwitchMastership and pingResult
687 if pingResult == main.TRUE:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800688 main.log.report( "Pingall Test in reactive mode to" +
689 " discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800690 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800691 main.log.report( "Pingall Test in reactive mode to" +
692 " discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800693
kelvin-onlab8a832582015-01-16 17:06:11 -0800694 utilities.assert_equals(
695 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800696 actual=case4Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800697 onpass="Controller assignment and Pingall Test successful",
698 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800699
kelvin-onlab8a832582015-01-16 17:06:11 -0800700 def CASE10( self ):
701 main.log.report(
702 "This testcase uninstalls the reactive forwarding app" )
703 main.log.report( "__________________________________" )
704 main.case( "Uninstalling reactive forwarding app" )
705 # Unistall onos-app-fwd app to disable reactive forwarding
shahshreyad524a942015-04-21 09:55:16 -0700706 main.log.info( "deactivate reactive forwarding app" )
707 appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
708 appCheck = main.ONOS2.appToIDCheck()
709 if appCheck != main.TRUE:
710 main.log.warn( main.ONOS2.apps() )
711 main.log.warn( main.ONOS2.appIDs() )
shahshreyae6c7cf42014-11-26 16:39:01 -0800712
shahshreya9294c8d2015-01-21 15:54:16 -0800713 # After reactive forwarding is disabled, the reactive flows on
714 # switches timeout in 10-15s
kelvin-onlab8a832582015-01-16 17:06:11 -0800715 # So sleep for 15s
716 time.sleep( 15 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800717
718 flows = main.ONOS2.flows()
kelvin-onlab8a832582015-01-16 17:06:11 -0800719 main.log.info( flows )
shahshreyae6c7cf42014-11-26 16:39:01 -0800720
shahshreya9294c8d2015-01-21 15:54:16 -0800721 case10Result = appUninstallResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800722 utilities.assert_equals(
723 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800724 actual=case10Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800725 onpass="Reactive forwarding app uninstallation successful",
726 onfail="Reactive forwarding app uninstallation failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800727
shahshreyab189da22015-02-25 10:18:26 -0800728
729 def CASE11( self ):
730 # NOTE: This testcase require reactive forwarding mode enabled
731 # NOTE: in the beginning and then uninstall it before adding
732 # NOTE: point intents. Again the app is installed so that
733 # NOTE: testcase 10 can be ran successively
734 import time
735 main.log.report(
736 "This testcase moves a host from one switch to another to add" +
737 "point intents between them and then perform ping" )
738 main.log.report( "__________________________________" )
739 main.log.info( "Moving host from one switch to another" )
740 main.case( "Moving host from a device and attach it to another device" )
741 main.step( "Moving host h9 from device s9 and attach it to s8" )
742 main.Mininet1.moveHost(host = 'h9', oldSw = 's9', newSw = 's8')
743
shahshreyad524a942015-04-21 09:55:16 -0700744 main.log.info( "Activate fwd app" )
745 appInstallResult = main.ONOS2.activateApp( "org.onosproject.fwd" )
746 appCheck = main.ONOS2.appToIDCheck()
747 if appCheck != main.TRUE:
748 main.log.warn( main.ONOS2.apps() )
749 main.log.warn( main.ONOS2.appIDs() )
750
shahshreyaa47ebf42015-05-20 13:29:18 -0700751 time.sleep(25) #Time delay to have all the flows ready
shahshreyab189da22015-02-25 10:18:26 -0800752 main.step( "Pingall" )
753 pingResult = main.FALSE
754 time1 = time.time()
shahshreyad524a942015-04-21 09:55:16 -0700755 pingResult = main.Mininet1.pingall( timeout=120,
756 shortCircuit=True,
shahshreyaa47ebf42015-05-20 13:29:18 -0700757 acceptableFailed=20 )
shahshreyab189da22015-02-25 10:18:26 -0800758 time2 = time.time()
759 print "Time for pingall: %2f seconds" % ( time2 - time1 )
760
761 hosts = main.ONOS2.hosts( jsonFormat = False )
762 main.log.info( hosts )
763
shahshreyad524a942015-04-21 09:55:16 -0700764 main.log.info( "deactivate reactive forwarding app" )
765 appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
766 appCheck = main.ONOS2.appToIDCheck()
767 if appCheck != main.TRUE:
768 main.log.warn( main.ONOS2.apps() )
769 main.log.warn( main.ONOS2.appIDs() )
shahshreyab189da22015-02-25 10:18:26 -0800770
771 main.step( "Add point intents between hosts on the same device")
772 ptpIntentResult = main.ONOS2.addPointIntent(
773 "of:0000000000003008/1",
774 "of:0000000000003008/3" )
775 if ptpIntentResult == main.TRUE:
776 getIntentResult = main.ONOS2.intents()
777 main.log.info( "Point to point intent install successful" )
778 # main.log.info( getIntentResult )
779
780 ptpIntentResult = main.ONOS2.addPointIntent(
781 "of:0000000000003008/3",
782 "of:0000000000003008/1" )
783 if ptpIntentResult == main.TRUE:
784 getIntentResult = main.ONOS2.intents()
785 main.log.info( "Point to point intent install successful" )
786 # main.log.info( getIntentResult )
787
788 main.case( "Ping hosts on the same devices" )
789 ping = main.Mininet1.pingHost( src = 'h8', target = 'h9' )
790
791 '''
792 main.case( "Installing reactive forwarding app" )
793 # Install onos-app-fwd app to enable reactive forwarding
794 appUninstallResult = main.ONOS2.featureInstall( "onos-app-fwd" )
795 main.log.info( "onos-app-fwd installed" )
796 '''
797
798 if ping == main.FALSE:
799 main.log.report(
800 "Point intents for hosts on same devices haven't" +
801 " been installed correctly. Cleaning up" )
802 if ping == main.TRUE:
803 main.log.report(
804 "Point intents for hosts on same devices" +
805 "installed correctly. Cleaning up" )
806
shahshreyaa47ebf42015-05-20 13:29:18 -0700807 case11Result = ping
shahshreyab189da22015-02-25 10:18:26 -0800808 utilities.assert_equals(
shahshreya74cca802015-02-26 12:24:01 -0800809 expect = main.TRUE,
810 actual = case11Result,
811 onpass = "Point intents for hosts on same devices" +
shahshreyab189da22015-02-25 10:18:26 -0800812 "Ping Test successful",
shahshreya74cca802015-02-26 12:24:01 -0800813 onfail = "Point intents for hosts on same devices" +
shahshreyab189da22015-02-25 10:18:26 -0800814 "Ping Test NOT successful" )
shahshreya74cca802015-02-26 12:24:01 -0800815
816
817 def CASE12( self ):
818 """
shahshreyaed683ed2015-03-16 15:04:40 -0700819 Verify the default flows on each switch in proactive mode
shahshreya74cca802015-02-26 12:24:01 -0800820 """
shahshreyaed683ed2015-03-16 15:04:40 -0700821 main.log.report( "This testcase is verifying num of default" +
822 " flows on each switch" )
823 main.log.report( "__________________________________" )
824 main.case( "Verify num of default flows on each switch" )
825 main.step( "Obtaining the device id's and flowrule count on them" )
826
shahshreya74cca802015-02-26 12:24:01 -0800827 case12Result = main.TRUE
828 idList = main.ONOS2.getAllDevicesId()
829 for id in idList:
shahshreyaed683ed2015-03-16 15:04:40 -0700830 count = main.ONOS2.FlowAddedCount( id )
831 main.log.info("count = " +count)
832 if int(count) != 3:
shahshreya74cca802015-02-26 12:24:01 -0800833 case12Result = main.FALSE
shahshreyaed683ed2015-03-16 15:04:40 -0700834 break
shahshreya74cca802015-02-26 12:24:01 -0800835 utilities.assert_equals(
836 expect=main.TRUE,
837 actual=case12Result,
838 onpass = "Expected default num of flows exist",
839 onfail = "Expected default num of flows do not exist")
shahshreyab189da22015-02-25 10:18:26 -0800840
kelvin-onlab8a832582015-01-16 17:06:11 -0800841 def CASE6( self ):
shahshreyab189da22015-02-25 10:18:26 -0800842 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800843 main.log.report( "This testcase is testing the addition of" +
844 " host intents and then does pingall" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800845 main.log.report( "__________________________________" )
846 main.case( "Obtaining host id's" )
847 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800848 hosts = main.ONOS2.hosts()
shahshreya9294c8d2015-01-21 15:54:16 -0800849 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800850
kelvin-onlab8a832582015-01-16 17:06:11 -0800851 main.step( "Get all devices id" )
shahshreya9294c8d2015-01-21 15:54:16 -0800852 devicesIdList = main.ONOS2.getAllDevicesId()
853 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -0800854
shahshreya9294c8d2015-01-21 15:54:16 -0800855 # ONOS displays the hosts in hex format unlike mininet which does
856 # in decimal format
kelvin-onlab8a832582015-01-16 17:06:11 -0800857 # So take care while adding intents
858 """
shahshreya9294c8d2015-01-21 15:54:16 -0800859 main.step( "Add host-to-host intents for mininet hosts h8 and h18 or
860 ONOS hosts h8 and h12" )
861 hthIntentResult = main.ONOS2.addHostIntent(
862 "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
863 hthIntentResult = main.ONOS2.addHostIntent(
864 "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
865 hthIntentResult = main.ONOS2.addHostIntent(
866 "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
867 hthIntentResult = main.ONOS2.addHostIntent(
868 "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
869 hthIntentResult = main.ONOS2.addHostIntent(
870 "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
871 hthIntentResult = main.ONOS2.addHostIntent(
872 "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
873 hthIntentResult = main.ONOS2.addHostIntent(
874 "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
875 hthIntentResult = main.ONOS2.addHostIntent(
876 "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
877 hthIntentResult = main.ONOS2.addHostIntent(
878 "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
879 hthIntentResult = main.ONOS2.addHostIntent(
880 "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
881 print "______________________________________________________"
kelvin-onlab8a832582015-01-16 17:06:11 -0800882 """
883 for i in range( 8, 18 ):
884 main.log.info(
shahshreya9294c8d2015-01-21 15:54:16 -0800885 "Adding host intent between h" + str( i ) +
886 " and h" + str( i + 10 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800887 host1 = "00:00:00:00:00:" + \
888 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
889 host2 = "00:00:00:00:00:" + \
890 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
891 # NOTE: get host can return None
shahshreya7630b1c2015-04-03 15:37:14 -0700892 if host1:
893 host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
894 if host2:
895 host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
896 if host1Id and host2Id:
897 main.ONOS2.addHostIntent( host1Id, host2Id )
kelvin-onlab8a832582015-01-16 17:06:11 -0800898
899 time.sleep( 10 )
shahshreya9294c8d2015-01-21 15:54:16 -0800900 hIntents = main.ONOS2.intents( jsonFormat=False )
901 main.log.info( "intents:" + hIntents )
shahshreyab189da22015-02-25 10:18:26 -0800902 flows = main.ONOS2.flows()
903 main.log.info( "flows:" + flows )
shahshreya4e13a062014-11-11 16:46:18 -0800904
905 count = 1
906 i = 8
shahshreya9294c8d2015-01-21 15:54:16 -0800907 PingResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800908 # while i<10:
909 while i < 18:
910 main.log.info(
911 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
912 ping = main.Mininet1.pingHost(
913 src="h" + str( i ), target="h" + str( i + 10 ) )
914 if ping == main.FALSE and count < 5:
915 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -0800916 # i = 8
917 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800918 main.log.report( "Ping between h" +
919 str( i ) +
920 " and h" +
921 str( i +
922 10 ) +
923 " failed. Making attempt number " +
924 str( count ) +
925 " in 2 seconds" )
926 time.sleep( 2 )
927 elif ping == main.FALSE:
928 main.log.report( "All ping attempts between h" +
929 str( i ) +
930 " and h" +
931 str( i +
932 10 ) +
933 "have failed" )
934 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -0800935 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800936 elif ping == main.TRUE:
937 main.log.info( "Ping test between h" +
938 str( i ) +
939 " and h" +
940 str( i +
941 10 ) +
942 "passed!" )
943 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -0800944 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800945 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800946 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -0800947 PingResult = main.ERROR
948 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800949 main.log.report(
shahshreya9294c8d2015-01-21 15:54:16 -0800950 "Ping all test after Host intent addition failed.Cleaning up" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800951 # main.cleanup()
952 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -0800953 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800954 main.log.report(
955 "Ping all test after Host intent addition successful" )
956
shahshreya9294c8d2015-01-21 15:54:16 -0800957 case6Result = PingResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800958 utilities.assert_equals(
959 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800960 actual=case6Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800961 onpass="Pingall Test after Host intents addition successful",
962 onfail="Pingall Test after Host intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800963
kelvin-onlab8a832582015-01-16 17:06:11 -0800964 def CASE5( self, main ):
shahshreyad524a942015-04-21 09:55:16 -0700965 """
966 Check ONOS topology matches with mininet
967 """
shahshreya4e13a062014-11-11 16:46:18 -0800968 import json
kelvin-onlab8a832582015-01-16 17:06:11 -0800969 # assumes that sts is already in you PYTHONPATH
970 from sts.topology.teston_topology import TestONTopology
shahshreya9294c8d2015-01-21 15:54:16 -0800971 # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800972 main.log.report( "This testcase is testing if all ONOS nodes" +
973 " are in topology sync with mininet" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800974 main.log.report( "__________________________________" )
975 main.case( "Comparing Mininet topology with the topology of ONOS" )
976 main.step( "Start continuous pings" )
977 main.Mininet2.pingLong(
978 src=main.params[ 'PING' ][ 'source1' ],
979 target=main.params[ 'PING' ][ 'target1' ],
980 pingTime=500 )
981 main.Mininet2.pingLong(
982 src=main.params[ 'PING' ][ 'source2' ],
983 target=main.params[ 'PING' ][ 'target2' ],
984 pingTime=500 )
985 main.Mininet2.pingLong(
986 src=main.params[ 'PING' ][ 'source3' ],
987 target=main.params[ 'PING' ][ 'target3' ],
988 pingTime=500 )
989 main.Mininet2.pingLong(
990 src=main.params[ 'PING' ][ 'source4' ],
991 target=main.params[ 'PING' ][ 'target4' ],
992 pingTime=500 )
993 main.Mininet2.pingLong(
994 src=main.params[ 'PING' ][ 'source5' ],
995 target=main.params[ 'PING' ][ 'target5' ],
996 pingTime=500 )
997 main.Mininet2.pingLong(
998 src=main.params[ 'PING' ][ 'source6' ],
999 target=main.params[ 'PING' ][ 'target6' ],
1000 pingTime=500 )
1001 main.Mininet2.pingLong(
1002 src=main.params[ 'PING' ][ 'source7' ],
1003 target=main.params[ 'PING' ][ 'target7' ],
1004 pingTime=500 )
1005 main.Mininet2.pingLong(
1006 src=main.params[ 'PING' ][ 'source8' ],
1007 target=main.params[ 'PING' ][ 'target8' ],
1008 pingTime=500 )
1009 main.Mininet2.pingLong(
1010 src=main.params[ 'PING' ][ 'source9' ],
1011 target=main.params[ 'PING' ][ 'target9' ],
1012 pingTime=500 )
1013 main.Mininet2.pingLong(
1014 src=main.params[ 'PING' ][ 'source10' ],
1015 target=main.params[ 'PING' ][ 'target10' ],
1016 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -08001017
kelvin-onlab8a832582015-01-16 17:06:11 -08001018 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -08001019 global ctrls
1020 ctrls = []
1021 count = 1
1022 while True:
1023 temp = ()
kelvin-onlab8a832582015-01-16 17:06:11 -08001024 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
1025 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
1026 temp = temp + ( "ONOS" + str( count ), )
1027 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
1028 temp = temp + \
1029 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
1030 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -08001031 count = count + 1
1032 else:
1033 break
1034 global MNTopo
kelvin-onlab8a832582015-01-16 17:06:11 -08001035 Topo = TestONTopology(
1036 main.Mininet1,
1037 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -08001038 MNTopo = Topo
1039
shahshreya9294c8d2015-01-21 15:54:16 -08001040 TopologyCheck = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001041 main.step( "Compare ONOS Topology to MN Topology" )
shahshreya9294c8d2015-01-21 15:54:16 -08001042 devicesJson = main.ONOS2.devices()
1043 linksJson = main.ONOS2.links()
1044 # portsJson = main.ONOS2.ports()
kelvin-onlab8a832582015-01-16 17:06:11 -08001045
shahshreya9294c8d2015-01-21 15:54:16 -08001046 result1 = main.Mininet1.compareSwitches(
kelvin-onlab8a832582015-01-16 17:06:11 -08001047 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001048 json.loads( devicesJson ) )
1049 result2 = main.Mininet1.compareLinks(
kelvin-onlab8a832582015-01-16 17:06:11 -08001050 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001051 json.loads( linksJson ) )
1052 # result3 = main.Mininet1.comparePorts(
1053 # MNTopo, json.loads( portsJson ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001054
shahshreya9294c8d2015-01-21 15:54:16 -08001055 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001056 result = result1 and result2
kelvin-onlab8a832582015-01-16 17:06:11 -08001057
shahshreya4e13a062014-11-11 16:46:18 -08001058 print "***********************"
1059 if result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001060 main.log.report( "ONOS" + " Topology matches MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001061 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001062 main.log.report( "ONOS" + " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001063
kelvin-onlab8a832582015-01-16 17:06:11 -08001064 utilities.assert_equals(
1065 expect=main.TRUE,
1066 actual=result,
1067 onpass="ONOS" +
1068 " Topology matches MN Topology",
1069 onfail="ONOS" +
1070 " Topology does not match MN Topology" )
1071
shahshreya9294c8d2015-01-21 15:54:16 -08001072 TopologyCheck = TopologyCheck and result
kelvin-onlab8a832582015-01-16 17:06:11 -08001073 utilities.assert_equals(
1074 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001075 actual=TopologyCheck,
kelvin-onlab8a832582015-01-16 17:06:11 -08001076 onpass="Topology checks passed",
1077 onfail="Topology checks failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001078
kelvin-onlab8a832582015-01-16 17:06:11 -08001079 def CASE7( self, main ):
shahshreyad524a942015-04-21 09:55:16 -07001080 """
1081 Link discovery test case. Checks if ONOS can discover a link
1082 down or up properly.
1083 """
1084
shahshreya9294c8d2015-01-21 15:54:16 -08001085 from sts.topology.teston_topology import TestONTopology
shahshreya4e13a062014-11-11 16:46:18 -08001086
shahshreya9294c8d2015-01-21 15:54:16 -08001087 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -08001088
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001089 main.log.report( "This testscase is killing a link to ensure that" +
1090 " link discovery is consistent" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001091 main.log.report( "__________________________________" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001092 main.log.report( "Killing a link to ensure that link discovery" +
1093 " is consistent" )
1094 main.case( "Killing a link to Ensure that Link Discovery" +
1095 "is Working Properly" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001096 """
1097 main.step( "Start continuous pings" )
1098
1099 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001100 target=main.params[ 'PING' ][ 'target1' ],
1101 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001102 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001103 target=main.params[ 'PING' ][ 'target2' ],
1104 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001105 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001106 target=main.params[ 'PING' ][ 'target3' ],
1107 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001108 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001109 target=main.params[ 'PING' ][ 'target4' ],
1110 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001111 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001112 target=main.params[ 'PING' ][ 'target5' ],
1113 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001114 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001115 target=main.params[ 'PING' ][ 'target6' ],
1116 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001117 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001118 target=main.params[ 'PING' ][ 'target7' ],
1119 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001120 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001121 target=main.params[ 'PING' ][ 'target8' ],
1122 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001123 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001124 target=main.params[ 'PING' ][ 'target9' ],
1125 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001126 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001127 target=main.params[ 'PING' ][ 'target10' ],
1128 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001129 """
1130 main.step( "Determine the current number of switches and links" )
shahshreya9294c8d2015-01-21 15:54:16 -08001131 topologyOutput = main.ONOS2.topology()
1132 topologyResult = main.ONOS1.getTopology( topologyOutput )
shahshreyaa47ebf42015-05-20 13:29:18 -07001133 activeSwitches = topologyResult[ 'devices' ]
1134 links = topologyResult[ 'links' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001135 print "activeSwitches = ", type( activeSwitches )
1136 print "links = ", type( links )
1137 main.log.info(
1138 "Currently there are %s switches and %s links" %
1139 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -08001140
kelvin-onlab8a832582015-01-16 17:06:11 -08001141 main.step( "Kill Link between s3 and s28" )
1142 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
shahshreya9294c8d2015-01-21 15:54:16 -08001143 time.sleep( linkSleep )
1144 topologyOutput = main.ONOS2.topology()
1145 LinkDown = main.ONOS1.checkStatus(
1146 topologyOutput, activeSwitches, str(
kelvin-onlab8a832582015-01-16 17:06:11 -08001147 int( links ) - 2 ) )
shahshreya9294c8d2015-01-21 15:54:16 -08001148 if LinkDown == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001149 main.log.report( "Link Down discovered properly" )
1150 utilities.assert_equals(
1151 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001152 actual=LinkDown,
kelvin-onlab8a832582015-01-16 17:06:11 -08001153 onpass="Link Down discovered properly",
1154 onfail="Link down was not discovered in " +
shahshreya9294c8d2015-01-21 15:54:16 -08001155 str( linkSleep ) +
kelvin-onlab8a832582015-01-16 17:06:11 -08001156 " seconds" )
1157
1158 # Check ping result here..add code for it
1159
1160 main.step( "Bring link between s3 and s28 back up" )
shahshreya9294c8d2015-01-21 15:54:16 -08001161 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
1162 time.sleep( linkSleep )
1163 topologyOutput = main.ONOS2.topology()
1164 LinkUp = main.ONOS1.checkStatus(
1165 topologyOutput,
kelvin-onlab8a832582015-01-16 17:06:11 -08001166 activeSwitches,
1167 str( links ) )
shahshreya9294c8d2015-01-21 15:54:16 -08001168 if LinkUp == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001169 main.log.report( "Link up discovered properly" )
1170 utilities.assert_equals(
1171 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001172 actual=LinkUp,
kelvin-onlab8a832582015-01-16 17:06:11 -08001173 onpass="Link up discovered properly",
1174 onfail="Link up was not discovered in " +
shahshreya9294c8d2015-01-21 15:54:16 -08001175 str( linkSleep ) +
kelvin-onlab8a832582015-01-16 17:06:11 -08001176 " seconds" )
1177
1178 # NOTE Check ping result here..add code for it
1179
1180 main.step( "Compare ONOS Topology to MN Topology" )
1181 Topo = TestONTopology(
1182 main.Mininet1,
1183 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -08001184 MNTopo = Topo
shahshreya9294c8d2015-01-21 15:54:16 -08001185 TopologyCheck = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001186
shahshreya9294c8d2015-01-21 15:54:16 -08001187 devicesJson = main.ONOS2.devices()
1188 linksJson = main.ONOS2.links()
1189 portsJson = main.ONOS2.ports()
kelvin-onlab8a832582015-01-16 17:06:11 -08001190
shahshreya9294c8d2015-01-21 15:54:16 -08001191 result1 = main.Mininet1.compareSwitches(
kelvin-onlab8a832582015-01-16 17:06:11 -08001192 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001193 json.loads( devicesJson ) )
1194 result2 = main.Mininet1.compareLinks(
kelvin-onlab8a832582015-01-16 17:06:11 -08001195 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001196 json.loads( linksJson ) )
1197 # result3 = main.Mininet1.comparePorts(
1198 # MNTopo, json.loads( portsJson ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001199
shahshreya9294c8d2015-01-21 15:54:16 -08001200 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001201 result = result1 and result2
1202 print "***********************"
kelvin-onlab8a832582015-01-16 17:06:11 -08001203
shahshreya4e13a062014-11-11 16:46:18 -08001204 if result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001205 main.log.report( "ONOS" + " Topology matches MN Topology" )
1206 utilities.assert_equals(
1207 expect=main.TRUE,
1208 actual=result,
1209 onpass="ONOS" +
1210 " Topology matches MN Topology",
1211 onfail="ONOS" +
1212 " Topology does not match MN Topology" )
1213
shahshreya9294c8d2015-01-21 15:54:16 -08001214 TopologyCheck = TopologyCheck and result
kelvin-onlab8a832582015-01-16 17:06:11 -08001215 utilities.assert_equals(
1216 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001217 actual=TopologyCheck,
kelvin-onlab8a832582015-01-16 17:06:11 -08001218 onpass="Topology checks passed",
1219 onfail="Topology checks failed" )
1220
shahshreya9294c8d2015-01-21 15:54:16 -08001221 result = LinkDown and LinkUp and TopologyCheck
kelvin-onlab8a832582015-01-16 17:06:11 -08001222 utilities.assert_equals( expect=main.TRUE, actual=result,
1223 onpass="Link failure is discovered correctly",
1224 onfail="Link Discovery failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001225
kelvin-onlab8a832582015-01-16 17:06:11 -08001226 def CASE8( self ):
1227 """
shahshreya82ecd282015-02-05 16:48:03 -08001228 Intent removal
kelvin-onlab8a832582015-01-16 17:06:11 -08001229 """
shahshreya82ecd282015-02-05 16:48:03 -08001230 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001231 main.log.report( "This testcase removes any previously added intents" +
shahshreya82ecd282015-02-05 16:48:03 -08001232 " before adding any new set of intents" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001233 main.log.report( "__________________________________" )
shahshreya82ecd282015-02-05 16:48:03 -08001234 main.log.info( "intent removal" )
1235 main.case( "Removing installed intents" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001236 main.step( "Obtain the intent id's" )
shahshreya9294c8d2015-01-21 15:54:16 -08001237 intentResult = main.ONOS2.intents( jsonFormat=False )
1238 main.log.info( "intent_result = " + intentResult )
shahshreya9294c8d2015-01-21 15:54:16 -08001239 intentLinewise = intentResult.split( "\n" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001240
shahshreyab189da22015-02-25 10:18:26 -08001241 intentList = [line for line in intentLinewise \
1242 if line.startswith( "id=")]
1243 intentids = [line.split( "," )[ 0 ].split( "=" )[ 1 ] for line in \
1244 intentList]
shahshreya4e13a062014-11-11 16:46:18 -08001245 for id in intentids:
1246 print "id = ", id
kelvin-onlab8a832582015-01-16 17:06:11 -08001247
1248 main.step(
1249 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -08001250 for id in intentids:
shahshreyaa47ebf42015-05-20 13:29:18 -07001251 main.ONOS2.removeIntent( intentId=id ,purge=True)
kelvin-onlab8a832582015-01-16 17:06:11 -08001252
shahshreya9294c8d2015-01-21 15:54:16 -08001253 intentResult = main.ONOS2.intents( jsonFormat=False )
1254 main.log.info( "intent_result = " + intentResult )
shahshreyab189da22015-02-25 10:18:26 -08001255
1256 intentList = [line for line in intentResult.split( "\n" ) \
1257 if line.startswith( "id=")]
1258 intentState = [line.split( "," )[ 1 ].split( "=" )[ 1 ] for line in \
1259 intentList]
1260 for state in intentState:
1261 print state
1262
1263 case8Result = main.TRUE
1264 for state in intentState:
1265 if state != 'WITHDRAWN':
1266 case8Result = main.FALSE
1267 break
1268
shahshreya9294c8d2015-01-21 15:54:16 -08001269 if case8Result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001270 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001271 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001272 main.log.report( "Intent removal failed" )
1273
shahshreya9294c8d2015-01-21 15:54:16 -08001274 PingResult = main.TRUE
1275 if case8Result == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001276 i = 8
kelvin-onlab8a832582015-01-16 17:06:11 -08001277 while i < 18:
1278 main.log.info(
1279 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1280 ping = main.Mininet1.pingHost(
1281 src="h" + str( i ), target="h" + str( i + 10 ) )
1282 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001283 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -08001284 PingResult = PingResult and main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001285 elif ping == main.FALSE:
1286 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001287 PingResult = PingResult and main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -08001288 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001289 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -08001290 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001291
kelvin-onlab8a832582015-01-16 17:06:11 -08001292 # Note: If the ping result failed, that means the intents have been
1293 # withdrawn correctly.
shahshreya9294c8d2015-01-21 15:54:16 -08001294 if PingResult == main.TRUE:
shahshreya82ecd282015-02-05 16:48:03 -08001295 main.log.report( "Installed intents have not been withdrawn correctly" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001296 # main.cleanup()
1297 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -08001298 if PingResult == main.FALSE:
shahshreya82ecd282015-02-05 16:48:03 -08001299 main.log.report( "Installed intents have been withdrawn correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001300
shahshreya9294c8d2015-01-21 15:54:16 -08001301 case8Result = case8Result and PingResult
shahshreyae6c7cf42014-11-26 16:39:01 -08001302
shahshreya9294c8d2015-01-21 15:54:16 -08001303 if case8Result == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001304 main.log.report( "Intent removal successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001305 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001306 main.log.report( "Intent removal failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001307
shahshreya9294c8d2015-01-21 15:54:16 -08001308 utilities.assert_equals( expect=main.FALSE, actual=case8Result,
1309 onpass="Intent removal test passed",
1310 onfail="Intent removal test failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001311
kelvin-onlab8a832582015-01-16 17:06:11 -08001312 def CASE9( self ):
shahshreyad524a942015-04-21 09:55:16 -07001313 """
1314 Testing Point intents
1315 """
kelvin-onlab8a832582015-01-16 17:06:11 -08001316 main.log.report(
shahshreyad524a942015-04-21 09:55:16 -07001317 "This test case adds point intents and then does pingall" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001318 main.log.report( "__________________________________" )
1319 main.log.info( "Adding point intents" )
1320 main.case(
shahshreya82ecd282015-02-05 16:48:03 -08001321 "Adding bidirectional point for mn hosts" +
1322 "( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22, " +
1323 "h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001324 macsDict = {}
1325 for i in range( 1,29 ):
1326 macsDict[ 'h' + str( i ) ]= main.Mininet1.getMacAddress( host='h'+ str( i ) )
1327 print macsDict
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001328 main.step( "Add point intents for mn hosts h8 and h18 or" +
1329 "ONOS hosts h8 and h12" )
1330 # main.step(var1)
shahshreya9294c8d2015-01-21 15:54:16 -08001331 ptpIntentResult = main.ONOS2.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -07001332 ingressDevice="of:0000000000003008/1",
1333 egressDevice="of:0000000000006018/1",
1334 ethType='IPV4',
1335 ethSrc=macsDict.get( 'h8' ))
shahshreya9294c8d2015-01-21 15:54:16 -08001336 if ptpIntentResult == main.TRUE:
1337 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001338 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001339 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001340
shahshreya9294c8d2015-01-21 15:54:16 -08001341 ptpIntentResult = main.ONOS2.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -07001342 ingressDevice="of:0000000000006018/1",
1343 egressDevice="of:0000000000003008/1",
1344 ethType='IPV4',
1345 ethSrc=macsDict.get( 'h18' ))
shahshreya9294c8d2015-01-21 15:54:16 -08001346 if ptpIntentResult == main.TRUE:
1347 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001348 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001349 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001350
shahshreya9294c8d2015-01-21 15:54:16 -08001351 var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
1352 main.step(var2)
1353 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001354 "of:0000000000003009/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001355 "of:0000000000006019/1",
1356 ethType='IPV4',
1357 ethSrc=macsDict.get( 'h9' ))
shahshreya9294c8d2015-01-21 15:54:16 -08001358 if ptpIntentResult == main.TRUE:
1359 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001360 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001361 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001362
shahshreya9294c8d2015-01-21 15:54:16 -08001363 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001364 "of:0000000000006019/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001365 "of:0000000000003009/1",
1366 ethType='IPV4',
1367 ethSrc=macsDict.get( 'h19' ))
shahshreya9294c8d2015-01-21 15:54:16 -08001368 if ptpIntentResult == main.TRUE:
1369 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001370 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001371 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001372
shahshreya9294c8d2015-01-21 15:54:16 -08001373 var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
1374 main.step(var3)
1375 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001376 "of:0000000000003010/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001377 "of:0000000000006020/1",
1378 ethType='IPV4',
1379 ethSrc=macsDict.get( 'h10' ))
1380
shahshreya9294c8d2015-01-21 15:54:16 -08001381 if ptpIntentResult == main.TRUE:
1382 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001383 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001384 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001385
shahshreya9294c8d2015-01-21 15:54:16 -08001386 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001387 "of:0000000000006020/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001388 "of:0000000000003010/1",
1389 ethType='IPV4',
1390 ethSrc=macsDict.get( 'h20' ))
1391
shahshreya9294c8d2015-01-21 15:54:16 -08001392 if ptpIntentResult == main.TRUE:
1393 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001394 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001395 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001396
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001397 var4 = "Add point intents for mininet hosts h11 and h21 or" +\
1398 " ONOS hosts hB and h15"
shahshreya9294c8d2015-01-21 15:54:16 -08001399 main.case(var4)
1400 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001401 "of:0000000000003011/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001402 "of:0000000000006021/1",
1403 ethType='IPV4',
1404 ethSrc=macsDict.get( 'h11' ))
1405
shahshreya9294c8d2015-01-21 15:54:16 -08001406 if ptpIntentResult == main.TRUE:
1407 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001408 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001409 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001410
shahshreya9294c8d2015-01-21 15:54:16 -08001411 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001412 "of:0000000000006021/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001413 "of:0000000000003011/1",
1414 ethType='IPV4',
1415 ethSrc=macsDict.get( 'h21' ))
1416
shahshreya9294c8d2015-01-21 15:54:16 -08001417 if ptpIntentResult == main.TRUE:
1418 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001419 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001420 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001421
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001422 var5 = "Add point intents for mininet hosts h12 and h22 " +\
1423 "ONOS hosts hC and h16"
shahshreya9294c8d2015-01-21 15:54:16 -08001424 main.case(var5)
1425 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001426 "of:0000000000003012/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001427 "of:0000000000006022/1",
1428 ethType='IPV4',
1429 ethSrc=macsDict.get( 'h12' ))
1430
shahshreya9294c8d2015-01-21 15:54:16 -08001431 if ptpIntentResult == main.TRUE:
1432 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001433 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001434 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001435
shahshreya9294c8d2015-01-21 15:54:16 -08001436 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001437 "of:0000000000006022/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001438 "of:0000000000003012/1",
1439 ethType='IPV4',
1440 ethSrc=macsDict.get( 'h22' ))
1441
shahshreya9294c8d2015-01-21 15:54:16 -08001442 if ptpIntentResult == main.TRUE:
1443 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001444 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001445 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001446
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001447 var6 = "Add point intents for mininet hosts h13 and h23 or" +\
1448 " ONOS hosts hD and h17"
shahshreya9294c8d2015-01-21 15:54:16 -08001449 main.case(var6)
1450 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001451 "of:0000000000003013/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001452 "of:0000000000006023/1",
1453 ethType='IPV4',
1454 ethSrc=macsDict.get( 'h13' ))
1455
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
shahshreya9294c8d2015-01-21 15:54:16 -08001461 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001462 "of:0000000000006023/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001463 "of:0000000000003013/1",
1464 ethType='IPV4',
1465 ethSrc=macsDict.get( 'h23' ))
1466
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" )
shahshreya9294c8d2015-01-21 15:54:16 -08001470 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001471
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001472 var7 = "Add point intents for mininet hosts h14 and h24 or" +\
1473 " ONOS hosts hE and h18"
shahshreya9294c8d2015-01-21 15:54:16 -08001474 main.case(var7)
1475 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001476 "of:0000000000003014/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001477 "of:0000000000006024/1",
1478 ethType='IPV4',
1479 ethSrc=macsDict.get( 'h14' ))
1480
shahshreya9294c8d2015-01-21 15:54:16 -08001481 if ptpIntentResult == main.TRUE:
1482 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001483 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001484 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001485
shahshreya9294c8d2015-01-21 15:54:16 -08001486 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001487 "of:0000000000006024/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001488 "of:0000000000003014/1",
1489 ethType='IPV4',
1490 ethSrc=macsDict.get( 'h24' ))
1491
shahshreya9294c8d2015-01-21 15:54:16 -08001492 if ptpIntentResult == main.TRUE:
1493 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001494 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001495 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001496
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001497 var8 = "Add point intents for mininet hosts h15 and h25 or" +\
1498 " ONOS hosts hF and h19"
shahshreya9294c8d2015-01-21 15:54:16 -08001499 main.case(var8)
1500 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001501 "of:0000000000003015/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001502 "of:0000000000006025/1",
1503 ethType='IPV4',
1504 ethSrc=macsDict.get( 'h15' ))
1505
shahshreya9294c8d2015-01-21 15:54:16 -08001506 if ptpIntentResult == main.TRUE:
1507 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001508 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001509 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001510
shahshreya9294c8d2015-01-21 15:54:16 -08001511 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001512 "of:0000000000006025/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001513 "of:0000000000003015/1",
1514 ethType='IPV4',
1515 ethSrc=macsDict.get( 'h25' ))
1516
shahshreya9294c8d2015-01-21 15:54:16 -08001517 if ptpIntentResult == main.TRUE:
1518 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001519 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001520 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001521
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001522 var9 = "Add intents for mininet hosts h16 and h26 or" +\
1523 " ONOS hosts h10 and h1A"
shahshreya9294c8d2015-01-21 15:54:16 -08001524 main.case(var9)
1525 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001526 "of:0000000000003016/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001527 "of:0000000000006026/1",
1528 ethType='IPV4',
1529 ethSrc=macsDict.get( 'h16' ))
1530
shahshreya9294c8d2015-01-21 15:54:16 -08001531 if ptpIntentResult == main.TRUE:
1532 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001533 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001534 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001535
shahshreya9294c8d2015-01-21 15:54:16 -08001536 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001537 "of:0000000000006026/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001538 "of:0000000000003016/1",
1539 ethType='IPV4',
1540 ethSrc=macsDict.get( 'h26' ))
1541
shahshreya9294c8d2015-01-21 15:54:16 -08001542 if ptpIntentResult == main.TRUE:
1543 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001544 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001545 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001546
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001547 var10 = "Add point intents for mininet hosts h17 and h27 or" +\
1548 " ONOS hosts h11 and h1B"
shahshreya9294c8d2015-01-21 15:54:16 -08001549 main.case(var10)
1550 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001551 "of:0000000000003017/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001552 "of:0000000000006027/1",
1553 ethType='IPV4',
1554 ethSrc=macsDict.get( 'h17' ))
1555
shahshreya9294c8d2015-01-21 15:54:16 -08001556 if ptpIntentResult == main.TRUE:
1557 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001558 main.log.info( "Point to point intent install successful" )
shahshreyab189da22015-02-25 10:18:26 -08001559 #main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001560
shahshreya9294c8d2015-01-21 15:54:16 -08001561 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001562 "of:0000000000006027/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001563 "of:0000000000003017/1",
1564 ethType='IPV4',
1565 ethSrc=macsDict.get( 'h27' ))
1566
shahshreya9294c8d2015-01-21 15:54:16 -08001567 if ptpIntentResult == main.TRUE:
1568 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001569 main.log.info( "Point to point intent install successful" )
shahshreyab189da22015-02-25 10:18:26 -08001570 #main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001571
1572 print(
shahshreya9294c8d2015-01-21 15:54:16 -08001573 "___________________________________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001574
1575 flowHandle = main.ONOS2.flows()
shahshreya82ecd282015-02-05 16:48:03 -08001576 #main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001577
1578 count = 1
1579 i = 8
shahshreya9294c8d2015-01-21 15:54:16 -08001580 PingResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001581 while i < 18:
1582 main.log.info(
1583 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1584 ping = main.Mininet1.pingHost(
1585 src="h" + str( i ), target="h" + str( i + 10 ) )
1586 if ping == main.FALSE and count < 5:
1587 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001588 # i = 8
1589 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001590 main.log.report( "Ping between h" +
1591 str( i ) +
1592 " and h" +
1593 str( i +
1594 10 ) +
1595 " failed. Making attempt number " +
1596 str( count ) +
1597 " in 2 seconds" )
1598 time.sleep( 2 )
1599 elif ping == main.FALSE:
1600 main.log.report( "All ping attempts between h" +
1601 str( i ) +
1602 " and h" +
1603 str( i +
1604 10 ) +
1605 "have failed" )
1606 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -08001607 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001608 elif ping == main.TRUE:
1609 main.log.info( "Ping test between h" +
1610 str( i ) +
1611 " and h" +
1612 str( i +
1613 10 ) +
1614 "passed!" )
1615 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001616 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001617 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001618 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -08001619 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001620
shahshreya9294c8d2015-01-21 15:54:16 -08001621 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001622 main.log.report(
1623 "Point intents have not ben installed correctly. Cleaning up" )
1624 # main.cleanup()
1625 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -08001626 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001627 main.log.report( "Point Intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001628
shahshreya9294c8d2015-01-21 15:54:16 -08001629 case9Result = PingResult
kelvin-onlab8a832582015-01-16 17:06:11 -08001630 utilities.assert_equals(
1631 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001632 actual=case9Result,
kelvin-onlab8a832582015-01-16 17:06:11 -08001633 onpass="Point intents addition and Pingall Test successful",
1634 onfail="Point intents addition and Pingall Test NOT successful" )