blob: 79a0b3a1e39be1da199b7b819b3b8200cbdb5077 [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
shahshreya234a1682015-05-27 15:41:56 -070050 packageResult = main.TRUE
shahshreyaa47ebf42015-05-20 13:29:18 -070051 if gitPullResult == 100:
kelvin-onlab8a832582015-01-16 17:06:11 -080052 main.step( "Using mvn clean & install" )
shahshreya9294c8d2015-01-21 15:54:16 -080053 main.ONOSbench.cleanInstall()
shahshreya234a1682015-05-27 15:41:56 -070054 main.step( "Creating ONOS package" )
55 packageResult = main.ONOSbench.onosPackage()
shahshreya9294c8d2015-01-21 15:54:16 -080056 elif gitPullResult == 0:
kelvin-onlab8a832582015-01-16 17:06:11 -080057 main.log.report(
58 "Git Pull Failed, look into logs for detailed reason" )
shahshreyaa22f8f82014-12-08 16:59:21 -080059 main.cleanup()
kelvin-onlab8a832582015-01-16 17:06:11 -080060 main.exit()
61
shahshreya234a1682015-05-27 15:41:56 -070062
63 main.step( "Uninstalling ONOS package" )
64 onosInstallResult = main.ONOSbench.onosUninstall( ONOS1Ip )
65 if onosInstallResult == main.TRUE:
66 main.log.report( "Uninstalling ONOS package successful" )
67 else:
68 main.log.report( "Uninstalling ONOS package failed" )
shahshreya4e13a062014-11-11 16:46:18 -080069
kelvin-onlab8a832582015-01-16 17:06:11 -080070 main.step( "Installing ONOS package" )
shahshreya234a1682015-05-27 15:41:56 -070071 onosInstallResult = main.ONOSbench.onosInstall( ONOS1Ip )
72 print onosInstallResult
shahshreya9294c8d2015-01-21 15:54:16 -080073 if onosInstallResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -080074 main.log.report( "Installing ONOS package successful" )
shahshreya4e13a062014-11-11 16:46:18 -080075 else:
kelvin-onlab8a832582015-01-16 17:06:11 -080076 main.log.report( "Installing ONOS package failed" )
shahshreya4e13a062014-11-11 16:46:18 -080077
shahshreya9294c8d2015-01-21 15:54:16 -080078 onos1Isup = main.ONOSbench.isup()
79 if onos1Isup == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -080080 main.log.report( "ONOS instance is up and ready" )
shahshreya4e13a062014-11-11 16:46:18 -080081 else:
kelvin-onlab8a832582015-01-16 17:06:11 -080082 main.log.report( "ONOS instance may not be up" )
shahshreya4e13a062014-11-11 16:46:18 -080083
shahshreya234a1682015-05-27 15:41:56 -070084 startResult = main.TRUE
85 #main.step( "Starting ONOS service" )
86 #startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -080087
shahshreya234a1682015-05-27 15:41:56 -070088 main.ONOS2.startOnosCli( ONOS1Ip )
shahshreya82ecd282015-02-05 16:48:03 -080089 main.step( "Starting Mininet CLI..." )
90
91 # Starting the mininet using the old way
92 main.step( "Starting Mininet ..." )
93 netIsUp = main.Mininet1.startNet()
94 if netIsUp:
95 main.log.info("Mininet CLI is up")
96
shahshreya9294c8d2015-01-21 15:54:16 -080097 case1Result = ( packageResult and
98 cellResult and verifyResult
99 and onosInstallResult and
100 onos1Isup and startResult )
101 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800102 onpass="Test startup successful",
103 onfail="Test startup NOT successful" )
104
105 def CASE2( self, main ):
106 """
shahshreyaa22f8f82014-12-08 16:59:21 -0800107 Switch Down
kelvin-onlab8a832582015-01-16 17:06:11 -0800108 """
109 # NOTE: You should probably run a topology check after this
110 import time
shahshreyaa22f8f82014-12-08 16:59:21 -0800111
kelvin-onlab8a832582015-01-16 17:06:11 -0800112 main.case( "Switch down discovery" )
113 main.log.report( "This testcase is testing a switch down discovery" )
114 main.log.report( "__________________________________" )
115
shahshreya9294c8d2015-01-21 15:54:16 -0800116 switchSleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
shahshreyaa22f8f82014-12-08 16:59:21 -0800117
118 description = "Killing a switch to ensure it is discovered correctly"
kelvin-onlab8a832582015-01-16 17:06:11 -0800119 main.log.report( description )
120 main.case( description )
shahshreyaa22f8f82014-12-08 16:59:21 -0800121
kelvin-onlab8a832582015-01-16 17:06:11 -0800122 # TODO: Make this switch parameterizable
123 main.step( "Kill s28 " )
124 main.log.report( "Deleting s28" )
125 # FIXME: use new dynamic topo functions
shahshreya9294c8d2015-01-21 15:54:16 -0800126 main.Mininet1.delSwitch( "s28" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800127 main.log.info(
128 "Waiting " +
shahshreya9294c8d2015-01-21 15:54:16 -0800129 str( switchSleep ) +
kelvin-onlab8a832582015-01-16 17:06:11 -0800130 " seconds for switch down to be discovered" )
shahshreya9294c8d2015-01-21 15:54:16 -0800131 time.sleep( switchSleep )
kelvin-onlab8a832582015-01-16 17:06:11 -0800132 # Peek at the deleted switch
shahshreya9294c8d2015-01-21 15:54:16 -0800133 device = main.ONOS2.getDevice( dpid="0028" )
shahshreyaa22f8f82014-12-08 16:59:21 -0800134 print "device = ", device
kelvin-onlab8a832582015-01-16 17:06:11 -0800135 if device[ u'available' ] == 'False':
shahshreya9294c8d2015-01-21 15:54:16 -0800136 case2Result = main.FALSE
shahshreyaa22f8f82014-12-08 16:59:21 -0800137 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800138 case2Result = main.TRUE
139 utilities.assert_equals( expect=main.TRUE, actual=case2Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800140 onpass="Switch down discovery successful",
141 onfail="Switch down discovery failed" )
shahshreyaa22f8f82014-12-08 16:59:21 -0800142
shahshreyab189da22015-02-25 10:18:26 -0800143 def CASE101( self, main ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800144 """
shahshreya4e13a062014-11-11 16:46:18 -0800145 Cleanup sequence:
shahshreya9294c8d2015-01-21 15:54:16 -0800146 onos-service <nodeIp> stop
shahshreya4e13a062014-11-11 16:46:18 -0800147 onos-uninstall
148
149 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800150
kelvin-onlab8a832582015-01-16 17:06:11 -0800151 """
shahshreya9294c8d2015-01-21 15:54:16 -0800152 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800153
kelvin-onlab8a832582015-01-16 17:06:11 -0800154 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800155
kelvin-onlab8a832582015-01-16 17:06:11 -0800156 main.step( "Testing ONOS kill function" )
shahshreya9294c8d2015-01-21 15:54:16 -0800157 killResult = main.ONOSbench.onosKill( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800158
kelvin-onlab8a832582015-01-16 17:06:11 -0800159 main.step( "Stopping ONOS service" )
shahshreya9294c8d2015-01-21 15:54:16 -0800160 stopResult = main.ONOSbench.onosStop( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800161
kelvin-onlab8a832582015-01-16 17:06:11 -0800162 main.step( "Uninstalling ONOS service" )
shahshreya9294c8d2015-01-21 15:54:16 -0800163 uninstallResult = main.ONOSbench.onosUninstall()
164
165 case11Result = killResult and stopResult and uninstallResult
166 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
167 onpass="Cleanup successful",
168 onfail="Cleanup failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800169
kelvin-onlab8a832582015-01-16 17:06:11 -0800170 def CASE3( self, main ):
171 """
shahshreya4e13a062014-11-11 16:46:18 -0800172 Test 'onos' command and its functionality in driver
kelvin-onlab8a832582015-01-16 17:06:11 -0800173 """
shahshreya9294c8d2015-01-21 15:54:16 -0800174 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800175
kelvin-onlab8a832582015-01-16 17:06:11 -0800176 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800177
kelvin-onlab8a832582015-01-16 17:06:11 -0800178 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800179 cmdstr1 = "system:name"
shahshreya9294c8d2015-01-21 15:54:16 -0800180 cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
181 main.log.info( "onos command returned: " + cmdResult1 )
shahshreya4e13a062014-11-11 16:46:18 -0800182
kelvin-onlab8a832582015-01-16 17:06:11 -0800183 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800184 cmdstr2 = "onos:topology"
shahshreya9294c8d2015-01-21 15:54:16 -0800185 cmdResult2 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
186 main.log.info( "onos command returned: " + cmdResult2 )
shahshreya4e13a062014-11-11 16:46:18 -0800187
kelvin-onlab8a832582015-01-16 17:06:11 -0800188 def CASE20( self ):
189 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800190 Exit from mininet cli
191 reinstall ONOS
kelvin-onlab8a832582015-01-16 17:06:11 -0800192 """
shahshreya234a1682015-05-27 15:41:56 -0700193 import time
shahshreya9294c8d2015-01-21 15:54:16 -0800194 cellName = main.params[ 'ENV' ][ 'cellName' ]
195 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
kelvin-onlab8a832582015-01-16 17:06:11 -0800196
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800197 main.log.report( "This testcase exits the mininet cli and reinstalls" +
198 "ONOS to switch over to Packet Optical topology" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800199 main.log.report( "_____________________________________________" )
200 main.case( "Disconnecting mininet and restarting ONOS" )
shahshreya234a1682015-05-27 15:41:56 -0700201
kelvin-onlab8a832582015-01-16 17:06:11 -0800202 main.step( "Disconnecting mininet and restarting ONOS" )
shahshreya234a1682015-05-27 15:41:56 -0700203 step1Result = main.TRUE
shahshreya9294c8d2015-01-21 15:54:16 -0800204 mininetDisconnect = main.Mininet1.disconnect()
shahshreyaa47ebf42015-05-20 13:29:18 -0700205 print "mininetDisconnect = ", mininetDisconnect
shahshreya234a1682015-05-27 15:41:56 -0700206 step1Result = mininetDisconnect
207 utilities.assert_equals(
208 expect=main.TRUE,
209 actual=step1Result,
210 onpass="Mininet disconnect successfully",
211 onfail="Mininet failed to disconnect")
212 """
213 main.step( "Removing raft logs before a clean installation of ONOS" )
214 step2Result = main.TRUE
215 removeRaftLogsResult = main.ONOSbench.onosRemoveRaftLogs()
216 step2Result = removeRaftLogsResult
217 utilities.assert_equals(
218 expect=main.TRUE,
219 actual=step2Result,
220 onpass="Raft logs removed successfully",
221 onfail="Failed to remove raft logs")
222 """
kelvin-onlab8a832582015-01-16 17:06:11 -0800223 main.step( "Applying cell variable to environment" )
shahshreya234a1682015-05-27 15:41:56 -0700224 step3Result = main.TRUE
225 setCellResult = main.ONOSbench.setCell( cellName )
226 verifyCellResult = main.ONOSbench.verifyCell()
227 step3Result = setCellResult and verifyCellResult
228 utilities.assert_equals(
229 expect=main.TRUE,
230 actual=step3Result,
231 onpass="Cell applied successfully",
232 onfail="Failed to apply cell")
shahshreyae6c7cf42014-11-26 16:39:01 -0800233
shahshreya234a1682015-05-27 15:41:56 -0700234 main.step( "Uninstalling ONOS package" )
235 step4Result = main.TRUE
236 ONOSip1 = main.params[ 'CTRL' ][ 'ip1' ]
237 onosUninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOSip1)
238 step4Result = onosUninstallResult
239 utilities.assert_equals(
240 expect=main.TRUE,
241 actual=step4Result,
242 onpass="Successfully uninstalled ONOS",
243 onfail="Failed to uninstall ONOS")
244
245 time.sleep( 5 )
246 main.step( "Installing ONOS package" )
247 step5Result = main.TRUE
248 onosInstallResult = main.ONOSbench.onosInstall( node = ONOSip1 )
249 step5Result = onosInstallResult
250 utilities.assert_equals(
251 expect=main.TRUE,
252 actual=step5Result,
253 onpass="Successfully installed ONOS",
254 onfail="Failed to install ONOS")
shahshreyae6c7cf42014-11-26 16:39:01 -0800255
shahshreya9294c8d2015-01-21 15:54:16 -0800256 onos1Isup = main.ONOSbench.isup()
257 if onos1Isup == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800258 main.log.report( "ONOS instance is up and ready" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800259 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800260 main.log.report( "ONOS instance may not be up" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800261
kelvin-onlab8a832582015-01-16 17:06:11 -0800262 main.step( "Starting ONOS service" )
shahshreya234a1682015-05-27 15:41:56 -0700263 step6Result = main.TRUE
shahshreya9294c8d2015-01-21 15:54:16 -0800264 startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreya234a1682015-05-27 15:41:56 -0700265 step6Result = startResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800266 utilities.assert_equals(
267 expect=main.TRUE,
shahshreya234a1682015-05-27 15:41:56 -0700268 actual=step6Result,
269 onpass="Successfully started ONOS",
270 onfail="Failed to start ONOS")
271
272 main.step( "Starting ONOS cli" )
273 step7Result = main.TRUE
274 cliResult = main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
275 step7Result = cliResult
276 utilities.assert_equals(
277 expect=main.TRUE,
278 actual=step7Result,
279 onpass="Successfully started ONOS cli",
280 onfail="Failed to start ONOS cli")
kelvin-onlab8a832582015-01-16 17:06:11 -0800281
282 def CASE21( self, main ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800283 """
shahshreya9294c8d2015-01-21 15:54:16 -0800284 On ONOS bench, run this command:
shahshreya7630b1c2015-04-03 15:37:14 -0700285 sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1
286 which spawns packet optical topology and copies the links
shahshreya9294c8d2015-01-21 15:54:16 -0800287 json file to the onos instance.
288 Note that in case of Packet Optical, the links are not learnt
289 from the topology, instead the links are learnt
shahshreyae6c7cf42014-11-26 16:39:01 -0800290 from the json config file
kelvin-onlab8a832582015-01-16 17:06:11 -0800291 """
shahshreya234a1682015-05-27 15:41:56 -0700292 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800293 main.log.report(
294 "This testcase starts the packet layer topology and REST" )
295 main.log.report( "_____________________________________________" )
296 main.case( "Starting LINC-OE and other components" )
shahshreya234a1682015-05-27 15:41:56 -0700297
298 main.step( "Activate optical app" )
299 step1Result = main.TRUE
300 activateOpticalResult = main.ONOS2.activateApp( "org.onosproject.optical" )
301 step1Result = activateOpticalResult
302 utilities.assert_equals(
303 expect=main.TRUE,
304 actual=step1Result,
305 onpass="Successfully activated optical app",
306 onfail="Failed to activate optical app")
307
shahshreyad524a942015-04-21 09:55:16 -0700308 appCheck = main.ONOS2.appToIDCheck()
309 if appCheck != main.TRUE:
310 main.log.warn( main.ONOS2.apps() )
311 main.log.warn( main.ONOS2.appIDs() )
312
shahshreya234a1682015-05-27 15:41:56 -0700313 main.step( "Starting mininet and LINC-OE" )
314 step2Result = main.TRUE
315 time.sleep( 10 )
shahshreya215c48f2015-04-06 15:55:55 -0700316 opticalMnScript = main.LincOE2.runOpticalMnScript(ctrllerIP = main.params[ 'CTRL' ][ 'ip1' ])
shahshreya234a1682015-05-27 15:41:56 -0700317 step2Result = opticalMnScript
kelvin-onlab8a832582015-01-16 17:06:11 -0800318 utilities.assert_equals(
319 expect=main.TRUE,
shahshreya234a1682015-05-27 15:41:56 -0700320 actual=step2Result,
321 onpass="Started the topology successfully ",
322 onfail="Failed to start the topology")
shahshreyae6c7cf42014-11-26 16:39:01 -0800323
kelvin-onlab8a832582015-01-16 17:06:11 -0800324 def CASE22( self, main ):
325 """
shahshreya7630b1c2015-04-03 15:37:14 -0700326 Curretly we use, 10 optical switches(ROADM's) and
327 6 packet layer mininet switches each with one host.
328 Therefore, the roadmCount variable = 10,
329 packetLayerSWCount variable = 6, hostCount=6 and
shahshreya234a1682015-05-27 15:41:56 -0700330 links=46.
shahshreya7630b1c2015-04-03 15:37:14 -0700331 All this is hardcoded in the testcase. If the topology changes,
shahshreya9294c8d2015-01-21 15:54:16 -0800332 these hardcoded values need to be changed
kelvin-onlab8a832582015-01-16 17:06:11 -0800333 """
shahshreya234a1682015-05-27 15:41:56 -0700334 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800335 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800336 "This testcase compares the optical+packet topology against what" +
337 " is expected" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800338 main.case( "Topology comparision" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800339
shahshreya234a1682015-05-27 15:41:56 -0700340 main.step( "Starts new ONOS cli" )
341 step1Result = main.TRUE
342 cliResult = main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ]\
343 [ 'ip1' ] )
344 step1Result = cliResult
345 utilities.assert_equals(
346 expect=main.TRUE,
347 actual=step1Result,
348 onpass="Successfully starts a new cli",
349 onfail="Failed to start new cli" )
350
351 main.step( "Compare topology" )
352 step2Result = main.TRUE
353 devicesResult = main.ONOS3.devices( jsonFormat=False )
354 print "devices_result :\n", devicesResult
shahshreya9294c8d2015-01-21 15:54:16 -0800355 devicesLinewise = devicesResult.split( "\n" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800356 roadmCount = 0
357 packetLayerSWCount = 0
shahshreya9294c8d2015-01-21 15:54:16 -0800358 for line in devicesLinewise:
kelvin-onlab8a832582015-01-16 17:06:11 -0800359 components = line.split( "," )
360 availability = components[ 1 ].split( "=" )[ 1 ]
361 type = components[ 3 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800362 if availability == 'true' and type == 'ROADM':
363 roadmCount += 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800364 elif availability == 'true' and type == 'SWITCH':
shahshreyae6c7cf42014-11-26 16:39:01 -0800365 packetLayerSWCount += 1
shahshreya7630b1c2015-04-03 15:37:14 -0700366 if roadmCount == 10:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800367 print "Number of Optical Switches = %d and is" % roadmCount +\
368 " correctly detected"
kelvin-onlab8a832582015-01-16 17:06:11 -0800369 main.log.info(
370 "Number of Optical Switches = " +
371 str( roadmCount ) +
372 " and is correctly detected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800373 opticalSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800374 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800375 print "Number of Optical Switches = %d and is wrong" % roadmCount
kelvin-onlab8a832582015-01-16 17:06:11 -0800376 main.log.info(
377 "Number of Optical Switches = " +
378 str( roadmCount ) +
379 " and is wrong" )
shahshreya9294c8d2015-01-21 15:54:16 -0800380 opticalSWResult = main.FALSE
shahshreya7630b1c2015-04-03 15:37:14 -0700381 if packetLayerSWCount == 6:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800382 print "Number of Packet layer or mininet Switches = %d "\
383 % packetLayerSWCount + "and is correctly detected"
kelvin-onlab8a832582015-01-16 17:06:11 -0800384 main.log.info(
385 "Number of Packet layer or mininet Switches = " +
386 str( packetLayerSWCount ) +
387 " and is correctly detected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800388 packetSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800389 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800390 print "Number of Packet layer or mininet Switches = %d and"\
391 % packetLayerSWCount + " is wrong"
kelvin-onlab8a832582015-01-16 17:06:11 -0800392 main.log.info(
393 "Number of Packet layer or mininet Switches = " +
394 str( packetLayerSWCount ) +
395 " and is wrong" )
shahshreya9294c8d2015-01-21 15:54:16 -0800396 packetSWResult = main.FALSE
shahshreya234a1682015-05-27 15:41:56 -0700397 # sleeps for sometime so the state of the switches will be active
398 time.sleep( 30 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800399 print "_________________________________"
shahshreya9294c8d2015-01-21 15:54:16 -0800400 linksResult = main.ONOS3.links( jsonFormat=False )
401 print "links_result = ", linksResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800402 print "_________________________________"
shahshreya234a1682015-05-27 15:41:56 -0700403 linkActiveCount = linksResult.count("state=ACTIVE")
shahshreya7630b1c2015-04-03 15:37:14 -0700404 main.log.info( "linkActiveCount = " + str( linkActiveCount ))
shahshreya234a1682015-05-27 15:41:56 -0700405 if linkActiveCount == 46:
shahshreya7630b1c2015-04-03 15:37:14 -0700406 linkActiveResult = main.TRUE
407 main.log.info(
408 "Number of links in ACTIVE state are correct")
409 else:
410 linkActiveResult = main.FALSE
411 main.log.info(
412 "Number of links in ACTIVE state are wrong")
shahshreya234a1682015-05-27 15:41:56 -0700413 step2Result = opticalSWResult and packetSWResult and \
shahshreya7630b1c2015-04-03 15:37:14 -0700414 linkActiveResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800415 utilities.assert_equals(
416 expect=main.TRUE,
shahshreya234a1682015-05-27 15:41:56 -0700417 actual=step2Result,
418 onpass="Successfully loaded packet optical topology",
419 onfail="Failed to load packet optical topology" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800420
kelvin-onlab8a832582015-01-16 17:06:11 -0800421 def CASE23( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800422 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800423 """
shahshreya9294c8d2015-01-21 15:54:16 -0800424 Add bidirectional point intents between 2 packet layer( mininet )
425 devices and
shahshreyae6c7cf42014-11-26 16:39:01 -0800426 ping mininet hosts
kelvin-onlab8a832582015-01-16 17:06:11 -0800427 """
428 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800429 "This testcase adds bidirectional point intents between 2 " +
430 "packet layer( mininet ) devices and ping mininet hosts" )
shahshreya234a1682015-05-27 15:41:56 -0700431 main.case( "Install point intents between 2 packet layer device and " +
432 "ping the hosts" )
433
kelvin-onlab8a832582015-01-16 17:06:11 -0800434 main.step( "Adding point intents" )
shahshreya234a1682015-05-27 15:41:56 -0700435 step1Result = main.TRUE
436 main.pIntentsId = []
437 pIntent1 = main.ONOS3.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -0800438 "of:0000ffffffff0001/1",
shahshreya7630b1c2015-04-03 15:37:14 -0700439 "of:0000ffffffff0005/1" )
shahshreya234a1682015-05-27 15:41:56 -0700440 pIntent2 = main.ONOS3.addPointIntent(
shahshreya7630b1c2015-04-03 15:37:14 -0700441 "of:0000ffffffff0005/1",
kelvin-onlab8a832582015-01-16 17:06:11 -0800442 "of:0000ffffffff0001/1" )
shahshreya234a1682015-05-27 15:41:56 -0700443 main.pIntentsId.append( pIntent1 )
444 main.pIntentsId.append( pIntent2 )
445 time.sleep( 10 )
446 main.log.info( "Checking intents state")
447 checkStateResult = main.ONOS3.checkIntentState(
448 intentsId = main.pIntentsId )
449 time.sleep( 10 )
450 main.log.info( "Checking flows state")
451 checkFlowResult = main.ONOS3.checkFlowsState()
shahshreyae6c7cf42014-11-26 16:39:01 -0800452 # Sleep for 30 seconds to provide time for the intent state to change
shahshreya234a1682015-05-27 15:41:56 -0700453 time.sleep( 10 )
454 main.log.info( "Checking intents state one more time")
455 checkStateResult = main.ONOS3.checkIntentState(
456 intentsId = main.pIntentsId )
457 step1Result = checkStateResult and checkFlowResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800458 utilities.assert_equals(
459 expect=main.TRUE,
shahshreya234a1682015-05-27 15:41:56 -0700460 actual=step1Result,
461 onpass="Successfully added point intents",
462 onfail="Failed to add point intents")
463
464 main.step( "Ping h1 and h5" )
465 step2Result = main.TRUE
466 main.log.info( "\n\nh1 is Pinging h5" )
467 pingResult = main.LincOE2.pingHostOptical( src="h1", target="h5" )
468 step2Result = pingResult
469 utilities.assert_equals(
470 expect=main.TRUE,
471 actual=step2Result,
472 onpass="Successfully pinged h1 and h5",
473 onfail="Failed to ping between h1 and h5")
shahshreyae6c7cf42014-11-26 16:39:01 -0800474
kelvin-onlab8a832582015-01-16 17:06:11 -0800475 def CASE24( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800476 import time
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800477 import json
kelvin-onlab8a832582015-01-16 17:06:11 -0800478 """
shahshreya7630b1c2015-04-03 15:37:14 -0700479 LINC uses its own switch IDs. You can use the following
480 command on the LINC console to find the mapping between
481 DPIDs and LINC IDs.
482 rp(application:get_all_key(linc)).
483
shahshreya9294c8d2015-01-21 15:54:16 -0800484 Test Rerouting of Packet Optical by bringing a port down
shahshreya7630b1c2015-04-03 15:37:14 -0700485 ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
486 so that link
487 ( between switch1 port20 - switch5 port50 ) is inactive
shahshreya9294c8d2015-01-21 15:54:16 -0800488 and do a ping test. If rerouting is successful,
489 ping should pass. also check the flows
kelvin-onlab8a832582015-01-16 17:06:11 -0800490 """
491 main.log.report(
492 "This testcase tests rerouting and pings mininet hosts" )
493 main.case( "Test rerouting and pings mininet hosts" )
shahshreya234a1682015-05-27 15:41:56 -0700494
shahshreya7630b1c2015-04-03 15:37:14 -0700495 main.step( "Attach to the Linc-OE session" )
shahshreya234a1682015-05-27 15:41:56 -0700496 step1Result = main.TRUE
497 attachConsole = main.LincOE1.attachLincOESession()
498 step1Result = attachConsole
499 utilities.assert_equals(
500 expect=main.TRUE,
501 actual=step1Result,
502 onpass="Successfully attached Linc-OE session",
503 onfail="Failed to attached Linc-OE session")
shahshreya7630b1c2015-04-03 15:37:14 -0700504
kelvin-onlab8a832582015-01-16 17:06:11 -0800505 main.step( "Bring a port down and verify the link state" )
shahshreya234a1682015-05-27 15:41:56 -0700506 step2Result = main.TRUE
shahshreya7630b1c2015-04-03 15:37:14 -0700507 main.LincOE1.portDown( swId="9", ptId="20" )
shahshreya9294c8d2015-01-21 15:54:16 -0800508 linksNonjson = main.ONOS3.links( jsonFormat=False )
509 main.log.info( "links = " + linksNonjson )
shahshreya234a1682015-05-27 15:41:56 -0700510 linkInactiveCount = linksNonjson.count( "state=INACTIVE" )
shahshreya7630b1c2015-04-03 15:37:14 -0700511 main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
512 if linkInactiveCount == 2:
513 main.log.info(
514 "Number of links in INACTIVE state are correct")
515 else:
516 main.log.info(
517 "Number of links in INACTIVE state are wrong")
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800518 links = main.ONOS3.links()
kelvin-onlab8a832582015-01-16 17:06:11 -0800519 main.log.info( "links = " + links )
shahshreya9294c8d2015-01-21 15:54:16 -0800520 linksResult = json.loads( links )
521 linksStateResult = main.FALSE
522 for item in linksResult:
kelvin-onlab8a832582015-01-16 17:06:11 -0800523 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
shahshreya7630b1c2015-04-03 15:37:14 -0700524 'src' ][ 'port' ] == "20":
525 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
526 'dst' ][ 'port' ] == "50":
shahshreya9294c8d2015-01-21 15:54:16 -0800527 linksState = item[ 'state' ]
528 if linksState == "INACTIVE":
kelvin-onlab8a832582015-01-16 17:06:11 -0800529 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800530 "Links state is inactive as expected due to one" +
531 " of the ports being down" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800532 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800533 "Links state is inactive as expected due to one" +
534 " of the ports being down" )
shahshreya9294c8d2015-01-21 15:54:16 -0800535 linksStateResult = main.TRUE
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800536 break
537 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800538 main.log.info(
539 "Links state is not inactive as expected" )
540 main.log.report(
541 "Links state is not inactive as expected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800542 linksStateResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800543 time.sleep( 10 )
shahshreya234a1682015-05-27 15:41:56 -0700544 checkFlowsState = main.ONOS3.checkFlowsState()
545 step2Result = linksStateResult
546 utilities.assert_equals(
547 expect=main.TRUE,
548 actual=step2Result,
549 onpass="Successfuly brought down a link",
550 onfail="Failed to bring down a link")
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800551
kelvin-onlab8a832582015-01-16 17:06:11 -0800552 main.step( "Verify Rerouting by a ping test" )
shahshreya234a1682015-05-27 15:41:56 -0700553 step3Result = main.TRUE
shahshreya7630b1c2015-04-03 15:37:14 -0700554 main.log.info( "\n\nh1 is Pinging h5" )
shahshreya234a1682015-05-27 15:41:56 -0700555 pingResult = main.LincOE2.pingHostOptical( src="h1", target="h5" )
556 step3Result = pingResult
557 utilities.assert_equals(
558 expect=main.TRUE,
559 actual=step3Result,
560 onpass="Successfully pinged h1 and h5",
561 onfail="Failed to ping between h1 and h5")
562
563 main.step( "Bring the downed port up and verify the link state" )
564 step4Result = main.TRUE
565 main.LincOE1.portUp( swId="9", ptId="20" )
566 linksNonjson = main.ONOS3.links( jsonFormat=False )
567 main.log.info( "links = " + linksNonjson )
568 linkInactiveCount = linksNonjson.count( "state=INACTIVE" )
569 main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
570 if linkInactiveCount == 0:
kelvin-onlab8a832582015-01-16 17:06:11 -0800571 main.log.info(
shahshreya234a1682015-05-27 15:41:56 -0700572 "Number of links in INACTIVE state are correct")
shahshreyae6c7cf42014-11-26 16:39:01 -0800573 else:
shahshreya234a1682015-05-27 15:41:56 -0700574 main.log.info(
575 "Number of links in INACTIVE state are wrong")
576 step4Result = main.FALSE
577 utilities.assert_equals(
578 expect=main.TRUE,
579 actual=step4Result,
580 onpass="Successfully brought the port up",
581 onfail="Failed to bring the port up")
582 """
583 main.step( "Removing host intents" )
584 step5Result = main.TRUE
585 removeResult = main.TRUE
586 # Check remaining intents
587 intentsJson = json.loads( main.ONOS3.intents() )
588 main.ONOS3.removeIntent( intentId=intent1, purge=True )
589 main.ONOS3.removeIntent( intentId=intent2, purge=True )
590 for intents in intentsJson:
591 main.ONOS3.removeIntent( intentId=intents.get( 'id' ),
592 app='org.onosproject.optical',
593 purge=True )
594 print json.loads( main.ONOS3.intents() )
595 if len( json.loads( main.ONOS3.intents() ) ):
596 removeResult = main.FALSE
597 step5Result = removeResult
598 utilities.assert_equals( expect=main.TRUE,
599 actual=step5Result,
600 onpass="Successfully removed host intents",
601 onfail="Failed to remove host intents" )
602 """
603 def CASE10( self ):
604 main.log.report(
605 "This testcase uninstalls the reactive forwarding app" )
606 main.log.report( "__________________________________" )
607 main.case( "Uninstalling reactive forwarding app" )
608 main.step( "Uninstalling reactive forwarding app" )
609 step1Result = main.TRUE
610 # Unistall onos-app-fwd app to disable reactive forwarding
611 main.log.info( "deactivate reactive forwarding app" )
612 appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
613 appCheck = main.ONOS2.appToIDCheck()
614 if appCheck != main.TRUE:
615 main.log.warn( main.ONOS2.apps() )
616 main.log.warn( main.ONOS2.appIDs() )
617 step1Result = appUninstallResult
618 utilities.assert_equals(
619 expect=main.TRUE,
620 actual=step1Result,
621 onpass="Successfully deactivate reactive forwarding app",
622 onfail="Failed to deactivate reactive forwarding app")
623 # After reactive forwarding is disabled, the reactive flows on
624 # switches timeout in 10-15s
625 # So sleep for 15s
626 time.sleep( 15 )
627 flows = main.ONOS2.flows()
628 main.log.info( flows )
shahshreyae6c7cf42014-11-26 16:39:01 -0800629
shahshreya234a1682015-05-27 15:41:56 -0700630 def CASE25( self ):
631 """
632 Add host intents between 2 packet layer host
633 """
634 import time
635 import json
636 main.log.report( "Adding host intents between 2 optical layer host" )
637 main.case( "Test add host intents between optical layer host" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800638
shahshreya234a1682015-05-27 15:41:56 -0700639 main.step( "Discover host using arping" )
640 step1Result = main.TRUE
641 main.hostMACs = []
642 main.hostId = []
643 #Listing host MAC addresses
644 for i in range( 1 , 7 ):
645 main.hostMACs.append( "00:00:00:00:00:" +
646 str( hex( i )[ 2: ] ).zfill( 2 ).upper() )
647 for macs in main.hostMACs:
648 main.hostId.append( macs + "/-1" )
649 host1 = main.hostId[ 0 ]
650 host2 = main.hostId[ 1 ]
651 # Use arping to discover the hosts
652 main.LincOE2.arping( host = "h1" )
653 main.LincOE2.arping( host = "h2" )
654 time.sleep( 5 )
655 hostsDict = main.ONOS3.hosts()
656 if not len( hostsDict ):
657 step1Result = main.FALSE
658 # Adding host intent
659 utilities.assert_equals(
660 expect=main.TRUE,
661 actual=step1Result,
662 onpass="Hosts discovered",
663 onfail="Failed to discover hosts")
664
665 main.step( "Adding host intents to h1 and h2" )
666 step2Result = main.TRUE
667 intentsId = []
668 intent1 = main.ONOS3.addHostIntent( hostIdOne = host1,
669 hostIdTwo = host2 )
670 intentsId.append( intent1 )
671 time.sleep( 5 )
672 intent2 = main.ONOS3.addHostIntent( hostIdOne = host2,
673 hostIdTwo = host1 )
674 intentsId.append( intent2 )
675 # Checking intents state before pinging
676 main.log.info( "Checking intents state" )
677 time.sleep( 15 )
678 intentResult = main.ONOS3.checkIntentState( intentsId = intentsId )
679 #check intent state again if intents are not in installed state
680 if not intentResult:
681 intentResult = main.ONOS3.checkIntentState( intentsId = intentsId )
682 step2Result = intentResult
683 utilities.assert_equals( expect=main.TRUE,
684 actual=step2Result,
685 onpass="All intents are in INSTALLED state ",
686 onfail="Some of the intents are not in " +
687 "INSTALLED state " )
688
689 # pinging h1 to h2 and then ping h2 to h1
690 main.step( "Pinging h1 and h2" )
691 step3Result = main.TRUE
692 pingResult = main.TRUE
693 pingResult = main.LincOE2.pingHostOptical( src="h1", target="h2" )
694 pingResult = pingResult and main.LincOE2.pingHostOptical( src="h2",
695 target="h1" )
696 step3Result = pingResult
697 utilities.assert_equals( expect=main.TRUE,
698 actual=step3Result,
699 onpass="Pinged successfully between h1 and h2",
700 onfail="Pinged failed between h1 and h2" )
701 # Removed all added host intents
702 main.step( "Removing host intents" )
703 step4Result = main.TRUE
704 removeResult = main.TRUE
705 # Check remaining intents
706 intentsJson = json.loads( main.ONOS3.intents() )
707 main.ONOS3.removeIntent( intentId=intent1, purge=True )
708 main.ONOS3.removeIntent( intentId=intent2, purge=True )
709 for intents in intentsJson:
710 main.ONOS3.removeIntent( intentId=intents.get( 'id' ),
711 app='org.onosproject.optical',
712 purge=True )
713 print json.loads( main.ONOS3.intents() )
714 if len( json.loads( main.ONOS3.intents() ) ):
715 removeResult = main.FALSE
716 step4Result = removeResult
717 utilities.assert_equals( expect=main.TRUE,
718 actual=step4Result,
719 onpass="Successfully removed host intents",
720 onfail="Failed to remove host intents" )
shahshreya4e13a062014-11-11 16:46:18 -0800721
kelvin-onlab8a832582015-01-16 17:06:11 -0800722 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800723 import re
724 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800725 main.log.report( "This testcase is testing the assignment of" +
726 " all the switches to all the controllers and" +
shahshreyab189da22015-02-25 10:18:26 -0800727 " discovering the hosts in reactive mode" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800728 main.log.report( "__________________________________" )
shahshreyaa47ebf42015-05-20 13:29:18 -0700729
kelvin-onlab8a832582015-01-16 17:06:11 -0800730 main.case( "Pingall Test" )
731 main.step( "Assigning switches to controllers" )
shahshreya9294c8d2015-01-21 15:54:16 -0800732 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
733 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
kelvin-onlab8a832582015-01-16 17:06:11 -0800734 for i in range( 1, 29 ):
735 if i == 1:
shahshreya9294c8d2015-01-21 15:54:16 -0800736 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800737 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800738 ip1=ONOS1Ip,
739 port1=ONOS1Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800740 elif i >= 2 and i < 5:
shahshreya9294c8d2015-01-21 15:54:16 -0800741 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800742 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800743 ip1=ONOS1Ip,
744 port1=ONOS1Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800745 elif i >= 5 and i < 8:
shahshreya9294c8d2015-01-21 15:54:16 -0800746 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800747 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800748 ip1=ONOS1Ip,
749 port1=ONOS1Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800750 elif i >= 8 and i < 18:
shahshreya9294c8d2015-01-21 15:54:16 -0800751 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800752 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800753 ip1=ONOS1Ip,
754 port1=ONOS1Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800755 elif i >= 18 and i < 28:
shahshreya9294c8d2015-01-21 15:54:16 -0800756 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800757 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800758 ip1=ONOS1Ip,
759 port1=ONOS1Port )
shahshreya4e13a062014-11-11 16:46:18 -0800760 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800761 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800762 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800763 ip1=ONOS1Ip,
764 port1=ONOS1Port )
765 SwitchMastership = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800766 for i in range( 1, 29 ):
767 if i == 1:
shahshreya9294c8d2015-01-21 15:54:16 -0800768 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800769 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800770 if re.search( "tcp:" + ONOS1Ip, response ):
771 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800772 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800773 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800774 elif i >= 2 and i < 5:
shahshreya9294c8d2015-01-21 15:54:16 -0800775 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800776 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800777 if re.search( "tcp:" + ONOS1Ip, response ):
778 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800779 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800780 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800781 elif i >= 5 and i < 8:
shahshreya9294c8d2015-01-21 15:54:16 -0800782 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800783 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800784 if re.search( "tcp:" + ONOS1Ip, response ):
785 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800786 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800787 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800788 elif i >= 8 and i < 18:
shahshreya9294c8d2015-01-21 15:54:16 -0800789 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800790 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800791 if re.search( "tcp:" + ONOS1Ip, response ):
792 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800793 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800794 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800795 elif i >= 18 and i < 28:
shahshreya9294c8d2015-01-21 15:54:16 -0800796 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800797 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800798 if re.search( "tcp:" + ONOS1Ip, response ):
799 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800800 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800801 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800802 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800803 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800804 print( "Response is" + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800805 if re.search( "tcp:" + ONOS1Ip, response ):
806 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800807 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800808 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800809
shahshreya9294c8d2015-01-21 15:54:16 -0800810 if SwitchMastership == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800811 main.log.report( "Controller assignmnet successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800812 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800813 main.log.report( "Controller assignmnet failed" )
814 utilities.assert_equals(
815 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800816 actual=SwitchMastership,
kelvin-onlab8a832582015-01-16 17:06:11 -0800817 onpass="MasterControllers assigned correctly" )
818 """
819 for i in range ( 1,29 ):
shahshreya9294c8d2015-01-21 15:54:16 -0800820 main.Mininet1.assignSwController( sw=str( i ),count=5,
821 ip1=ONOS1Ip,port1=ONOS1Port,
822 ip2=ONOS2Ip,port2=ONOS2Port,
823 ip3=ONOS3Ip,port3=ONOS3Port,
824 ip4=ONOS4Ip,port4=ONOS4Port,
825 ip5=ONOS5Ip,port5=ONOS5Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800826 """
827 # REACTIVE FWD test
shahshreyad524a942015-04-21 09:55:16 -0700828 main.log.info( "Activate fwd app" )
829 appInstallResult = main.ONOS2.activateApp( "org.onosproject.fwd" )
830 appCheck = main.ONOS2.appToIDCheck()
831 if appCheck != main.TRUE:
832 main.log.warn( main.ONOS2.apps() )
833 main.log.warn( main.ONOS2.appIDs() )
834 time.sleep( 10 )
shahshreya4e13a062014-11-11 16:46:18 -0800835
kelvin-onlab8a832582015-01-16 17:06:11 -0800836 main.step( "Get list of hosts from Mininet" )
shahshreya9294c8d2015-01-21 15:54:16 -0800837 hostList = main.Mininet1.getHosts()
838 main.log.info( hostList )
shahshreya4e13a062014-11-11 16:46:18 -0800839
kelvin-onlab8a832582015-01-16 17:06:11 -0800840 main.step( "Get host list in ONOS format" )
shahshreya9294c8d2015-01-21 15:54:16 -0800841 hostOnosList = main.ONOS2.getHostsId( hostList )
842 main.log.info( hostOnosList )
kelvin-onlab8a832582015-01-16 17:06:11 -0800843 # time.sleep( 5 )
844
845 main.step( "Pingall" )
shahshreya9294c8d2015-01-21 15:54:16 -0800846 pingResult = main.FALSE
shahshreya82ecd282015-02-05 16:48:03 -0800847 time1 = time.time()
848 pingResult = main.Mininet1.pingall()
849 time2 = time.time()
850 print "Time for pingall: %2f seconds" % ( time2 - time1 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800851
shahshreya9294c8d2015-01-21 15:54:16 -0800852 # Start onos cli again because u might have dropped out of
853 # onos prompt to the shell prompt
kelvin-onlab8a832582015-01-16 17:06:11 -0800854 # if there was no activity
shahshreya9294c8d2015-01-21 15:54:16 -0800855 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800856
shahshreya9294c8d2015-01-21 15:54:16 -0800857 case4Result = SwitchMastership and pingResult
858 if pingResult == main.TRUE:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800859 main.log.report( "Pingall Test in reactive mode to" +
860 " discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800861 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800862 main.log.report( "Pingall Test in reactive mode to" +
863 " discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800864
kelvin-onlab8a832582015-01-16 17:06:11 -0800865 utilities.assert_equals(
866 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800867 actual=case4Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800868 onpass="Controller assignment and Pingall Test successful",
869 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800870
shahshreyab189da22015-02-25 10:18:26 -0800871 def CASE11( self ):
872 # NOTE: This testcase require reactive forwarding mode enabled
873 # NOTE: in the beginning and then uninstall it before adding
874 # NOTE: point intents. Again the app is installed so that
875 # NOTE: testcase 10 can be ran successively
876 import time
877 main.log.report(
878 "This testcase moves a host from one switch to another to add" +
879 "point intents between them and then perform ping" )
880 main.log.report( "__________________________________" )
881 main.log.info( "Moving host from one switch to another" )
882 main.case( "Moving host from a device and attach it to another device" )
883 main.step( "Moving host h9 from device s9 and attach it to s8" )
884 main.Mininet1.moveHost(host = 'h9', oldSw = 's9', newSw = 's8')
885
shahshreyad524a942015-04-21 09:55:16 -0700886 main.log.info( "Activate fwd app" )
887 appInstallResult = main.ONOS2.activateApp( "org.onosproject.fwd" )
888 appCheck = main.ONOS2.appToIDCheck()
889 if appCheck != main.TRUE:
890 main.log.warn( main.ONOS2.apps() )
891 main.log.warn( main.ONOS2.appIDs() )
892
shahshreyaa47ebf42015-05-20 13:29:18 -0700893 time.sleep(25) #Time delay to have all the flows ready
shahshreyab189da22015-02-25 10:18:26 -0800894 main.step( "Pingall" )
895 pingResult = main.FALSE
896 time1 = time.time()
shahshreyad524a942015-04-21 09:55:16 -0700897 pingResult = main.Mininet1.pingall( timeout=120,
898 shortCircuit=True,
shahshreyaa47ebf42015-05-20 13:29:18 -0700899 acceptableFailed=20 )
shahshreyab189da22015-02-25 10:18:26 -0800900 time2 = time.time()
901 print "Time for pingall: %2f seconds" % ( time2 - time1 )
902
903 hosts = main.ONOS2.hosts( jsonFormat = False )
904 main.log.info( hosts )
905
shahshreyad524a942015-04-21 09:55:16 -0700906 main.log.info( "deactivate reactive forwarding app" )
907 appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
908 appCheck = main.ONOS2.appToIDCheck()
909 if appCheck != main.TRUE:
910 main.log.warn( main.ONOS2.apps() )
911 main.log.warn( main.ONOS2.appIDs() )
shahshreyab189da22015-02-25 10:18:26 -0800912
913 main.step( "Add point intents between hosts on the same device")
914 ptpIntentResult = main.ONOS2.addPointIntent(
915 "of:0000000000003008/1",
shahshreya234a1682015-05-27 15:41:56 -0700916 "of:0000000000003008/3",
917 ethType='IPV4',
918 ethSrc='00:00:00:00:00:08',
919 ethDst='00:00:00:00:00:09' )
shahshreyab189da22015-02-25 10:18:26 -0800920 if ptpIntentResult == main.TRUE:
921 getIntentResult = main.ONOS2.intents()
922 main.log.info( "Point to point intent install successful" )
923 # main.log.info( getIntentResult )
924
925 ptpIntentResult = main.ONOS2.addPointIntent(
926 "of:0000000000003008/3",
shahshreya234a1682015-05-27 15:41:56 -0700927 "of:0000000000003008/1",
928 ethType='IPV4',
929 ethSrc='00:00:00:00:00:09',
930 ethDst='00:00:00:00:00:08' )
shahshreyab189da22015-02-25 10:18:26 -0800931 if ptpIntentResult == main.TRUE:
932 getIntentResult = main.ONOS2.intents()
933 main.log.info( "Point to point intent install successful" )
934 # main.log.info( getIntentResult )
935
936 main.case( "Ping hosts on the same devices" )
937 ping = main.Mininet1.pingHost( src = 'h8', target = 'h9' )
938
939 '''
940 main.case( "Installing reactive forwarding app" )
941 # Install onos-app-fwd app to enable reactive forwarding
942 appUninstallResult = main.ONOS2.featureInstall( "onos-app-fwd" )
943 main.log.info( "onos-app-fwd installed" )
944 '''
945
946 if ping == main.FALSE:
947 main.log.report(
948 "Point intents for hosts on same devices haven't" +
949 " been installed correctly. Cleaning up" )
950 if ping == main.TRUE:
951 main.log.report(
952 "Point intents for hosts on same devices" +
953 "installed correctly. Cleaning up" )
954
shahshreyaa47ebf42015-05-20 13:29:18 -0700955 case11Result = ping
shahshreyab189da22015-02-25 10:18:26 -0800956 utilities.assert_equals(
shahshreya74cca802015-02-26 12:24:01 -0800957 expect = main.TRUE,
958 actual = case11Result,
959 onpass = "Point intents for hosts on same devices" +
shahshreyab189da22015-02-25 10:18:26 -0800960 "Ping Test successful",
shahshreya74cca802015-02-26 12:24:01 -0800961 onfail = "Point intents for hosts on same devices" +
shahshreyab189da22015-02-25 10:18:26 -0800962 "Ping Test NOT successful" )
shahshreya74cca802015-02-26 12:24:01 -0800963
shahshreya74cca802015-02-26 12:24:01 -0800964 def CASE12( self ):
965 """
shahshreyaed683ed2015-03-16 15:04:40 -0700966 Verify the default flows on each switch in proactive mode
shahshreya74cca802015-02-26 12:24:01 -0800967 """
shahshreyaed683ed2015-03-16 15:04:40 -0700968 main.log.report( "This testcase is verifying num of default" +
969 " flows on each switch" )
970 main.log.report( "__________________________________" )
971 main.case( "Verify num of default flows on each switch" )
972 main.step( "Obtaining the device id's and flowrule count on them" )
973
shahshreya74cca802015-02-26 12:24:01 -0800974 case12Result = main.TRUE
975 idList = main.ONOS2.getAllDevicesId()
976 for id in idList:
shahshreyaed683ed2015-03-16 15:04:40 -0700977 count = main.ONOS2.FlowAddedCount( id )
978 main.log.info("count = " +count)
979 if int(count) != 3:
shahshreya74cca802015-02-26 12:24:01 -0800980 case12Result = main.FALSE
shahshreyaed683ed2015-03-16 15:04:40 -0700981 break
shahshreya74cca802015-02-26 12:24:01 -0800982 utilities.assert_equals(
983 expect=main.TRUE,
984 actual=case12Result,
985 onpass = "Expected default num of flows exist",
986 onfail = "Expected default num of flows do not exist")
shahshreyab189da22015-02-25 10:18:26 -0800987
kelvin-onlab8a832582015-01-16 17:06:11 -0800988 def CASE6( self ):
shahshreyab189da22015-02-25 10:18:26 -0800989 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800990 main.log.report( "This testcase is testing the addition of" +
991 " host intents and then does pingall" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800992 main.log.report( "__________________________________" )
993 main.case( "Obtaining host id's" )
994 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800995 hosts = main.ONOS2.hosts()
shahshreya9294c8d2015-01-21 15:54:16 -0800996 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800997
kelvin-onlab8a832582015-01-16 17:06:11 -0800998 main.step( "Get all devices id" )
shahshreya9294c8d2015-01-21 15:54:16 -0800999 devicesIdList = main.ONOS2.getAllDevicesId()
1000 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -08001001
shahshreya9294c8d2015-01-21 15:54:16 -08001002 # ONOS displays the hosts in hex format unlike mininet which does
1003 # in decimal format
kelvin-onlab8a832582015-01-16 17:06:11 -08001004 # So take care while adding intents
1005 """
shahshreya9294c8d2015-01-21 15:54:16 -08001006 main.step( "Add host-to-host intents for mininet hosts h8 and h18 or
1007 ONOS hosts h8 and h12" )
1008 hthIntentResult = main.ONOS2.addHostIntent(
1009 "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
1010 hthIntentResult = main.ONOS2.addHostIntent(
1011 "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
1012 hthIntentResult = main.ONOS2.addHostIntent(
1013 "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
1014 hthIntentResult = main.ONOS2.addHostIntent(
1015 "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
1016 hthIntentResult = main.ONOS2.addHostIntent(
1017 "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
1018 hthIntentResult = main.ONOS2.addHostIntent(
1019 "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
1020 hthIntentResult = main.ONOS2.addHostIntent(
1021 "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
1022 hthIntentResult = main.ONOS2.addHostIntent(
1023 "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
1024 hthIntentResult = main.ONOS2.addHostIntent(
1025 "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
1026 hthIntentResult = main.ONOS2.addHostIntent(
1027 "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
1028 print "______________________________________________________"
kelvin-onlab8a832582015-01-16 17:06:11 -08001029 """
shahshreya234a1682015-05-27 15:41:56 -07001030 intentsId = []
kelvin-onlab8a832582015-01-16 17:06:11 -08001031 for i in range( 8, 18 ):
1032 main.log.info(
shahshreya9294c8d2015-01-21 15:54:16 -08001033 "Adding host intent between h" + str( i ) +
1034 " and h" + str( i + 10 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001035 host1 = "00:00:00:00:00:" + \
1036 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1037 host2 = "00:00:00:00:00:" + \
1038 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
1039 # NOTE: get host can return None
shahshreya7630b1c2015-04-03 15:37:14 -07001040 if host1:
1041 host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
1042 if host2:
1043 host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
1044 if host1Id and host2Id:
shahshreya234a1682015-05-27 15:41:56 -07001045 intentsId.append( main.ONOS2.addHostIntent( host1Id, host2Id ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001046
shahshreya234a1682015-05-27 15:41:56 -07001047 checkIntentResult = main.ONOS2.checkIntentState( intentsId )
kelvin-onlab8a832582015-01-16 17:06:11 -08001048 time.sleep( 10 )
shahshreya9294c8d2015-01-21 15:54:16 -08001049 hIntents = main.ONOS2.intents( jsonFormat=False )
1050 main.log.info( "intents:" + hIntents )
shahshreyab189da22015-02-25 10:18:26 -08001051 flows = main.ONOS2.flows()
1052 main.log.info( "flows:" + flows )
shahshreya4e13a062014-11-11 16:46:18 -08001053
1054 count = 1
1055 i = 8
shahshreya9294c8d2015-01-21 15:54:16 -08001056 PingResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001057 # while i<10:
1058 while i < 18:
1059 main.log.info(
1060 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1061 ping = main.Mininet1.pingHost(
1062 src="h" + str( i ), target="h" + str( i + 10 ) )
1063 if ping == main.FALSE and count < 5:
1064 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001065 # i = 8
1066 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001067 main.log.report( "Ping between h" +
1068 str( i ) +
1069 " and h" +
1070 str( i +
1071 10 ) +
1072 " failed. Making attempt number " +
1073 str( count ) +
1074 " in 2 seconds" )
1075 time.sleep( 2 )
1076 elif ping == main.FALSE:
1077 main.log.report( "All ping attempts between h" +
1078 str( i ) +
1079 " and h" +
1080 str( i +
1081 10 ) +
1082 "have failed" )
1083 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -08001084 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001085 elif ping == main.TRUE:
1086 main.log.info( "Ping test between h" +
1087 str( i ) +
1088 " and h" +
1089 str( i +
1090 10 ) +
1091 "passed!" )
1092 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001093 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001094 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001095 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -08001096 PingResult = main.ERROR
1097 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001098 main.log.report(
shahshreya9294c8d2015-01-21 15:54:16 -08001099 "Ping all test after Host intent addition failed.Cleaning up" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001100 # main.cleanup()
1101 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -08001102 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001103 main.log.report(
1104 "Ping all test after Host intent addition successful" )
1105
shahshreya234a1682015-05-27 15:41:56 -07001106 checkIntentResult = main.ONOS2.checkIntentState( intentsId )
1107
shahshreya9294c8d2015-01-21 15:54:16 -08001108 case6Result = PingResult
kelvin-onlab8a832582015-01-16 17:06:11 -08001109 utilities.assert_equals(
1110 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001111 actual=case6Result,
kelvin-onlab8a832582015-01-16 17:06:11 -08001112 onpass="Pingall Test after Host intents addition successful",
1113 onfail="Pingall Test after Host intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001114
kelvin-onlab8a832582015-01-16 17:06:11 -08001115 def CASE5( self, main ):
shahshreyad524a942015-04-21 09:55:16 -07001116 """
1117 Check ONOS topology matches with mininet
1118 """
shahshreya4e13a062014-11-11 16:46:18 -08001119 import json
kelvin-onlab8a832582015-01-16 17:06:11 -08001120 # assumes that sts is already in you PYTHONPATH
1121 from sts.topology.teston_topology import TestONTopology
shahshreya9294c8d2015-01-21 15:54:16 -08001122 # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001123 main.log.report( "This testcase is testing if all ONOS nodes" +
1124 " are in topology sync with mininet" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001125 main.log.report( "__________________________________" )
1126 main.case( "Comparing Mininet topology with the topology of ONOS" )
1127 main.step( "Start continuous pings" )
1128 main.Mininet2.pingLong(
1129 src=main.params[ 'PING' ][ 'source1' ],
1130 target=main.params[ 'PING' ][ 'target1' ],
1131 pingTime=500 )
1132 main.Mininet2.pingLong(
1133 src=main.params[ 'PING' ][ 'source2' ],
1134 target=main.params[ 'PING' ][ 'target2' ],
1135 pingTime=500 )
1136 main.Mininet2.pingLong(
1137 src=main.params[ 'PING' ][ 'source3' ],
1138 target=main.params[ 'PING' ][ 'target3' ],
1139 pingTime=500 )
1140 main.Mininet2.pingLong(
1141 src=main.params[ 'PING' ][ 'source4' ],
1142 target=main.params[ 'PING' ][ 'target4' ],
1143 pingTime=500 )
1144 main.Mininet2.pingLong(
1145 src=main.params[ 'PING' ][ 'source5' ],
1146 target=main.params[ 'PING' ][ 'target5' ],
1147 pingTime=500 )
1148 main.Mininet2.pingLong(
1149 src=main.params[ 'PING' ][ 'source6' ],
1150 target=main.params[ 'PING' ][ 'target6' ],
1151 pingTime=500 )
1152 main.Mininet2.pingLong(
1153 src=main.params[ 'PING' ][ 'source7' ],
1154 target=main.params[ 'PING' ][ 'target7' ],
1155 pingTime=500 )
1156 main.Mininet2.pingLong(
1157 src=main.params[ 'PING' ][ 'source8' ],
1158 target=main.params[ 'PING' ][ 'target8' ],
1159 pingTime=500 )
1160 main.Mininet2.pingLong(
1161 src=main.params[ 'PING' ][ 'source9' ],
1162 target=main.params[ 'PING' ][ 'target9' ],
1163 pingTime=500 )
1164 main.Mininet2.pingLong(
1165 src=main.params[ 'PING' ][ 'source10' ],
1166 target=main.params[ 'PING' ][ 'target10' ],
1167 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -08001168
kelvin-onlab8a832582015-01-16 17:06:11 -08001169 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -08001170 global ctrls
1171 ctrls = []
1172 count = 1
1173 while True:
1174 temp = ()
kelvin-onlab8a832582015-01-16 17:06:11 -08001175 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
1176 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
1177 temp = temp + ( "ONOS" + str( count ), )
1178 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
1179 temp = temp + \
1180 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
1181 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -08001182 count = count + 1
1183 else:
1184 break
1185 global MNTopo
kelvin-onlab8a832582015-01-16 17:06:11 -08001186 Topo = TestONTopology(
1187 main.Mininet1,
1188 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -08001189 MNTopo = Topo
1190
shahshreya9294c8d2015-01-21 15:54:16 -08001191 TopologyCheck = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001192 main.step( "Compare ONOS Topology to MN Topology" )
shahshreya9294c8d2015-01-21 15:54:16 -08001193 devicesJson = main.ONOS2.devices()
1194 linksJson = main.ONOS2.links()
1195 # portsJson = main.ONOS2.ports()
kelvin-onlab8a832582015-01-16 17:06:11 -08001196
shahshreya9294c8d2015-01-21 15:54:16 -08001197 result1 = main.Mininet1.compareSwitches(
kelvin-onlab8a832582015-01-16 17:06:11 -08001198 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001199 json.loads( devicesJson ) )
1200 result2 = main.Mininet1.compareLinks(
kelvin-onlab8a832582015-01-16 17:06:11 -08001201 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001202 json.loads( linksJson ) )
1203 # result3 = main.Mininet1.comparePorts(
1204 # MNTopo, json.loads( portsJson ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001205
shahshreya9294c8d2015-01-21 15:54:16 -08001206 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001207 result = result1 and result2
kelvin-onlab8a832582015-01-16 17:06:11 -08001208
shahshreya4e13a062014-11-11 16:46:18 -08001209 print "***********************"
1210 if result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001211 main.log.report( "ONOS" + " Topology matches MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001212 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001213 main.log.report( "ONOS" + " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001214
kelvin-onlab8a832582015-01-16 17:06:11 -08001215 utilities.assert_equals(
1216 expect=main.TRUE,
1217 actual=result,
1218 onpass="ONOS" +
1219 " Topology matches MN Topology",
1220 onfail="ONOS" +
1221 " Topology does not match MN Topology" )
1222
shahshreya9294c8d2015-01-21 15:54:16 -08001223 TopologyCheck = TopologyCheck and result
kelvin-onlab8a832582015-01-16 17:06:11 -08001224 utilities.assert_equals(
1225 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001226 actual=TopologyCheck,
kelvin-onlab8a832582015-01-16 17:06:11 -08001227 onpass="Topology checks passed",
1228 onfail="Topology checks failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001229
kelvin-onlab8a832582015-01-16 17:06:11 -08001230 def CASE7( self, main ):
shahshreyad524a942015-04-21 09:55:16 -07001231 """
1232 Link discovery test case. Checks if ONOS can discover a link
1233 down or up properly.
1234 """
1235
shahshreya9294c8d2015-01-21 15:54:16 -08001236 from sts.topology.teston_topology import TestONTopology
shahshreya4e13a062014-11-11 16:46:18 -08001237
shahshreya9294c8d2015-01-21 15:54:16 -08001238 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -08001239
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001240 main.log.report( "This testscase is killing a link to ensure that" +
1241 " link discovery is consistent" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001242 main.log.report( "__________________________________" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001243 main.log.report( "Killing a link to ensure that link discovery" +
1244 " is consistent" )
1245 main.case( "Killing a link to Ensure that Link Discovery" +
1246 "is Working Properly" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001247 """
1248 main.step( "Start continuous pings" )
1249
1250 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001251 target=main.params[ 'PING' ][ 'target1' ],
1252 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001253 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001254 target=main.params[ 'PING' ][ 'target2' ],
1255 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001256 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001257 target=main.params[ 'PING' ][ 'target3' ],
1258 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001259 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001260 target=main.params[ 'PING' ][ 'target4' ],
1261 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001262 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001263 target=main.params[ 'PING' ][ 'target5' ],
1264 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001265 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001266 target=main.params[ 'PING' ][ 'target6' ],
1267 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001268 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001269 target=main.params[ 'PING' ][ 'target7' ],
1270 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001271 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001272 target=main.params[ 'PING' ][ 'target8' ],
1273 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001274 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001275 target=main.params[ 'PING' ][ 'target9' ],
1276 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001277 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001278 target=main.params[ 'PING' ][ 'target10' ],
1279 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001280 """
1281 main.step( "Determine the current number of switches and links" )
shahshreya9294c8d2015-01-21 15:54:16 -08001282 topologyOutput = main.ONOS2.topology()
1283 topologyResult = main.ONOS1.getTopology( topologyOutput )
shahshreyaa47ebf42015-05-20 13:29:18 -07001284 activeSwitches = topologyResult[ 'devices' ]
1285 links = topologyResult[ 'links' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001286 print "activeSwitches = ", type( activeSwitches )
1287 print "links = ", type( links )
1288 main.log.info(
1289 "Currently there are %s switches and %s links" %
1290 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -08001291
kelvin-onlab8a832582015-01-16 17:06:11 -08001292 main.step( "Kill Link between s3 and s28" )
1293 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
shahshreya9294c8d2015-01-21 15:54:16 -08001294 time.sleep( linkSleep )
1295 topologyOutput = main.ONOS2.topology()
1296 LinkDown = main.ONOS1.checkStatus(
1297 topologyOutput, activeSwitches, str(
kelvin-onlab8a832582015-01-16 17:06:11 -08001298 int( links ) - 2 ) )
shahshreya9294c8d2015-01-21 15:54:16 -08001299 if LinkDown == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001300 main.log.report( "Link Down discovered properly" )
1301 utilities.assert_equals(
1302 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001303 actual=LinkDown,
kelvin-onlab8a832582015-01-16 17:06:11 -08001304 onpass="Link Down discovered properly",
1305 onfail="Link down was not discovered in " +
shahshreya9294c8d2015-01-21 15:54:16 -08001306 str( linkSleep ) +
kelvin-onlab8a832582015-01-16 17:06:11 -08001307 " seconds" )
1308
1309 # Check ping result here..add code for it
1310
1311 main.step( "Bring link between s3 and s28 back up" )
shahshreya9294c8d2015-01-21 15:54:16 -08001312 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
1313 time.sleep( linkSleep )
1314 topologyOutput = main.ONOS2.topology()
1315 LinkUp = main.ONOS1.checkStatus(
1316 topologyOutput,
kelvin-onlab8a832582015-01-16 17:06:11 -08001317 activeSwitches,
1318 str( links ) )
shahshreya9294c8d2015-01-21 15:54:16 -08001319 if LinkUp == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001320 main.log.report( "Link up discovered properly" )
1321 utilities.assert_equals(
1322 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001323 actual=LinkUp,
kelvin-onlab8a832582015-01-16 17:06:11 -08001324 onpass="Link up discovered properly",
1325 onfail="Link up was not discovered in " +
shahshreya9294c8d2015-01-21 15:54:16 -08001326 str( linkSleep ) +
kelvin-onlab8a832582015-01-16 17:06:11 -08001327 " seconds" )
1328
1329 # NOTE Check ping result here..add code for it
1330
1331 main.step( "Compare ONOS Topology to MN Topology" )
1332 Topo = TestONTopology(
1333 main.Mininet1,
1334 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -08001335 MNTopo = Topo
shahshreya9294c8d2015-01-21 15:54:16 -08001336 TopologyCheck = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001337
shahshreya9294c8d2015-01-21 15:54:16 -08001338 devicesJson = main.ONOS2.devices()
1339 linksJson = main.ONOS2.links()
1340 portsJson = main.ONOS2.ports()
kelvin-onlab8a832582015-01-16 17:06:11 -08001341
shahshreya9294c8d2015-01-21 15:54:16 -08001342 result1 = main.Mininet1.compareSwitches(
kelvin-onlab8a832582015-01-16 17:06:11 -08001343 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001344 json.loads( devicesJson ) )
1345 result2 = main.Mininet1.compareLinks(
kelvin-onlab8a832582015-01-16 17:06:11 -08001346 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001347 json.loads( linksJson ) )
1348 # result3 = main.Mininet1.comparePorts(
1349 # MNTopo, json.loads( portsJson ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001350
shahshreya9294c8d2015-01-21 15:54:16 -08001351 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001352 result = result1 and result2
1353 print "***********************"
kelvin-onlab8a832582015-01-16 17:06:11 -08001354
shahshreya4e13a062014-11-11 16:46:18 -08001355 if result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001356 main.log.report( "ONOS" + " Topology matches MN Topology" )
1357 utilities.assert_equals(
1358 expect=main.TRUE,
1359 actual=result,
1360 onpass="ONOS" +
1361 " Topology matches MN Topology",
1362 onfail="ONOS" +
1363 " Topology does not match MN Topology" )
1364
shahshreya9294c8d2015-01-21 15:54:16 -08001365 TopologyCheck = TopologyCheck and result
kelvin-onlab8a832582015-01-16 17:06:11 -08001366 utilities.assert_equals(
1367 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001368 actual=TopologyCheck,
kelvin-onlab8a832582015-01-16 17:06:11 -08001369 onpass="Topology checks passed",
1370 onfail="Topology checks failed" )
1371
shahshreya9294c8d2015-01-21 15:54:16 -08001372 result = LinkDown and LinkUp and TopologyCheck
kelvin-onlab8a832582015-01-16 17:06:11 -08001373 utilities.assert_equals( expect=main.TRUE, actual=result,
1374 onpass="Link failure is discovered correctly",
1375 onfail="Link Discovery failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001376
kelvin-onlab8a832582015-01-16 17:06:11 -08001377 def CASE8( self ):
1378 """
shahshreya82ecd282015-02-05 16:48:03 -08001379 Intent removal
kelvin-onlab8a832582015-01-16 17:06:11 -08001380 """
shahshreya82ecd282015-02-05 16:48:03 -08001381 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001382 main.log.report( "This testcase removes any previously added intents" +
shahshreya82ecd282015-02-05 16:48:03 -08001383 " before adding any new set of intents" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001384 main.log.report( "__________________________________" )
shahshreya82ecd282015-02-05 16:48:03 -08001385 main.log.info( "intent removal" )
1386 main.case( "Removing installed intents" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001387 main.step( "Obtain the intent id's" )
shahshreya234a1682015-05-27 15:41:56 -07001388 currentIntents = main.ONOS2.intents( jsonFormat=False )
1389 main.log.info( "intent_result = " + currentIntents )
1390 intentLinewise = currentIntents.split( "\n" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001391
shahshreyab189da22015-02-25 10:18:26 -08001392 intentList = [line for line in intentLinewise \
1393 if line.startswith( "id=")]
1394 intentids = [line.split( "," )[ 0 ].split( "=" )[ 1 ] for line in \
1395 intentList]
shahshreya4e13a062014-11-11 16:46:18 -08001396 for id in intentids:
1397 print "id = ", id
kelvin-onlab8a832582015-01-16 17:06:11 -08001398
1399 main.step(
1400 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -08001401 for id in intentids:
shahshreyaa47ebf42015-05-20 13:29:18 -07001402 main.ONOS2.removeIntent( intentId=id ,purge=True)
kelvin-onlab8a832582015-01-16 17:06:11 -08001403
shahshreya234a1682015-05-27 15:41:56 -07001404 remainingIntents = main.ONOS2.intents( jsonFormat=False )
1405 main.log.info( "intent_result = " + remainingIntents )
1406 if remainingIntents:
1407 main.log.info( "There are still remaining intents " )
1408 intentResult = main.FALSE
1409 else:
1410 intentResult = main.TRUE
1411
1412 intentList = [line for line in remainingIntents.split( "\n" ) \
shahshreyab189da22015-02-25 10:18:26 -08001413 if line.startswith( "id=")]
1414 intentState = [line.split( "," )[ 1 ].split( "=" )[ 1 ] for line in \
1415 intentList]
1416 for state in intentState:
1417 print state
1418
shahshreya234a1682015-05-27 15:41:56 -07001419 case8Result = main.TRUE
shahshreyab189da22015-02-25 10:18:26 -08001420 for state in intentState:
1421 if state != 'WITHDRAWN':
1422 case8Result = main.FALSE
1423 break
kelvin-onlab8a832582015-01-16 17:06:11 -08001424
shahshreya9294c8d2015-01-21 15:54:16 -08001425 PingResult = main.TRUE
shahshreya234a1682015-05-27 15:41:56 -07001426 """
shahshreya9294c8d2015-01-21 15:54:16 -08001427 if case8Result == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001428 i = 8
kelvin-onlab8a832582015-01-16 17:06:11 -08001429 while i < 18:
1430 main.log.info(
1431 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1432 ping = main.Mininet1.pingHost(
1433 src="h" + str( i ), target="h" + str( i + 10 ) )
1434 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001435 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -08001436 PingResult = PingResult and main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001437 elif ping == main.FALSE:
1438 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001439 PingResult = PingResult and main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -08001440 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001441 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -08001442 PingResult = main.ERROR
shahshreya234a1682015-05-27 15:41:56 -07001443
kelvin-onlab8a832582015-01-16 17:06:11 -08001444 # Note: If the ping result failed, that means the intents have been
1445 # withdrawn correctly.
shahshreya9294c8d2015-01-21 15:54:16 -08001446 if PingResult == main.TRUE:
shahshreya82ecd282015-02-05 16:48:03 -08001447 main.log.report( "Installed intents have not been withdrawn correctly" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001448 # main.cleanup()
1449 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -08001450 if PingResult == main.FALSE:
shahshreya82ecd282015-02-05 16:48:03 -08001451 main.log.report( "Installed intents have been withdrawn correctly" )
shahshreya234a1682015-05-27 15:41:56 -07001452 """
shahshreya4e13a062014-11-11 16:46:18 -08001453
shahshreya234a1682015-05-27 15:41:56 -07001454 if case8Result:
kelvin-onlab8a832582015-01-16 17:06:11 -08001455 main.log.report( "Intent removal successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001456 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001457 main.log.report( "Intent removal failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001458
shahshreya234a1682015-05-27 15:41:56 -07001459 utilities.assert_equals( expect=main.TRUE, actual=case8Result,
shahshreya9294c8d2015-01-21 15:54:16 -08001460 onpass="Intent removal test passed",
1461 onfail="Intent removal test failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001462
kelvin-onlab8a832582015-01-16 17:06:11 -08001463 def CASE9( self ):
shahshreyad524a942015-04-21 09:55:16 -07001464 """
1465 Testing Point intents
1466 """
kelvin-onlab8a832582015-01-16 17:06:11 -08001467 main.log.report(
shahshreyad524a942015-04-21 09:55:16 -07001468 "This test case adds point intents and then does pingall" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001469 main.log.report( "__________________________________" )
1470 main.log.info( "Adding point intents" )
1471 main.case(
shahshreya82ecd282015-02-05 16:48:03 -08001472 "Adding bidirectional point for mn hosts" +
1473 "( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22, " +
1474 "h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001475 macsDict = {}
1476 for i in range( 1,29 ):
1477 macsDict[ 'h' + str( i ) ]= main.Mininet1.getMacAddress( host='h'+ str( i ) )
1478 print macsDict
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001479 main.step( "Add point intents for mn hosts h8 and h18 or" +
1480 "ONOS hosts h8 and h12" )
1481 # main.step(var1)
shahshreya9294c8d2015-01-21 15:54:16 -08001482 ptpIntentResult = main.ONOS2.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -07001483 ingressDevice="of:0000000000003008/1",
1484 egressDevice="of:0000000000006018/1",
1485 ethType='IPV4',
1486 ethSrc=macsDict.get( 'h8' ))
shahshreya9294c8d2015-01-21 15:54:16 -08001487 if ptpIntentResult == main.TRUE:
1488 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001489 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001490 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001491
shahshreya9294c8d2015-01-21 15:54:16 -08001492 ptpIntentResult = main.ONOS2.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -07001493 ingressDevice="of:0000000000006018/1",
1494 egressDevice="of:0000000000003008/1",
1495 ethType='IPV4',
1496 ethSrc=macsDict.get( 'h18' ))
shahshreya9294c8d2015-01-21 15:54:16 -08001497 if ptpIntentResult == main.TRUE:
1498 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001499 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001500 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001501
shahshreya9294c8d2015-01-21 15:54:16 -08001502 var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
1503 main.step(var2)
1504 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001505 "of:0000000000003009/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001506 "of:0000000000006019/1",
1507 ethType='IPV4',
1508 ethSrc=macsDict.get( 'h9' ))
shahshreya9294c8d2015-01-21 15:54:16 -08001509 if ptpIntentResult == main.TRUE:
1510 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001511 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001512 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001513
shahshreya9294c8d2015-01-21 15:54:16 -08001514 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001515 "of:0000000000006019/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001516 "of:0000000000003009/1",
1517 ethType='IPV4',
1518 ethSrc=macsDict.get( 'h19' ))
shahshreya9294c8d2015-01-21 15:54:16 -08001519 if ptpIntentResult == main.TRUE:
1520 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001521 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001522 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001523
shahshreya9294c8d2015-01-21 15:54:16 -08001524 var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
1525 main.step(var3)
1526 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001527 "of:0000000000003010/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001528 "of:0000000000006020/1",
1529 ethType='IPV4',
1530 ethSrc=macsDict.get( 'h10' ))
1531
shahshreya9294c8d2015-01-21 15:54:16 -08001532 if ptpIntentResult == main.TRUE:
1533 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001534 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001535 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001536
shahshreya9294c8d2015-01-21 15:54:16 -08001537 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001538 "of:0000000000006020/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001539 "of:0000000000003010/1",
1540 ethType='IPV4',
1541 ethSrc=macsDict.get( 'h20' ))
1542
shahshreya9294c8d2015-01-21 15:54:16 -08001543 if ptpIntentResult == main.TRUE:
1544 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001545 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001546 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001547
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001548 var4 = "Add point intents for mininet hosts h11 and h21 or" +\
1549 " ONOS hosts hB and h15"
shahshreya9294c8d2015-01-21 15:54:16 -08001550 main.case(var4)
1551 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001552 "of:0000000000003011/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001553 "of:0000000000006021/1",
1554 ethType='IPV4',
1555 ethSrc=macsDict.get( 'h11' ))
1556
shahshreya9294c8d2015-01-21 15:54:16 -08001557 if ptpIntentResult == main.TRUE:
1558 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001559 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001560 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001561
shahshreya9294c8d2015-01-21 15:54:16 -08001562 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001563 "of:0000000000006021/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001564 "of:0000000000003011/1",
1565 ethType='IPV4',
1566 ethSrc=macsDict.get( 'h21' ))
1567
shahshreya9294c8d2015-01-21 15:54:16 -08001568 if ptpIntentResult == main.TRUE:
1569 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001570 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001571 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001572
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001573 var5 = "Add point intents for mininet hosts h12 and h22 " +\
1574 "ONOS hosts hC and h16"
shahshreya9294c8d2015-01-21 15:54:16 -08001575 main.case(var5)
1576 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001577 "of:0000000000003012/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001578 "of:0000000000006022/1",
1579 ethType='IPV4',
1580 ethSrc=macsDict.get( 'h12' ))
1581
shahshreya9294c8d2015-01-21 15:54:16 -08001582 if ptpIntentResult == main.TRUE:
1583 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001584 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001585 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001586
shahshreya9294c8d2015-01-21 15:54:16 -08001587 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001588 "of:0000000000006022/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001589 "of:0000000000003012/1",
1590 ethType='IPV4',
1591 ethSrc=macsDict.get( 'h22' ))
1592
shahshreya9294c8d2015-01-21 15:54:16 -08001593 if ptpIntentResult == main.TRUE:
1594 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001595 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001596 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001597
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001598 var6 = "Add point intents for mininet hosts h13 and h23 or" +\
1599 " ONOS hosts hD and h17"
shahshreya9294c8d2015-01-21 15:54:16 -08001600 main.case(var6)
1601 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001602 "of:0000000000003013/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001603 "of:0000000000006023/1",
1604 ethType='IPV4',
1605 ethSrc=macsDict.get( 'h13' ))
1606
shahshreya9294c8d2015-01-21 15:54:16 -08001607 if ptpIntentResult == main.TRUE:
1608 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001609 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001610 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001611
shahshreya9294c8d2015-01-21 15:54:16 -08001612 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001613 "of:0000000000006023/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001614 "of:0000000000003013/1",
1615 ethType='IPV4',
1616 ethSrc=macsDict.get( 'h23' ))
1617
shahshreya9294c8d2015-01-21 15:54:16 -08001618 if ptpIntentResult == main.TRUE:
1619 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001620 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001621 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001622
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001623 var7 = "Add point intents for mininet hosts h14 and h24 or" +\
1624 " ONOS hosts hE and h18"
shahshreya9294c8d2015-01-21 15:54:16 -08001625 main.case(var7)
1626 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001627 "of:0000000000003014/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001628 "of:0000000000006024/1",
1629 ethType='IPV4',
1630 ethSrc=macsDict.get( 'h14' ))
1631
shahshreya9294c8d2015-01-21 15:54:16 -08001632 if ptpIntentResult == main.TRUE:
1633 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001634 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001635 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001636
shahshreya9294c8d2015-01-21 15:54:16 -08001637 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001638 "of:0000000000006024/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001639 "of:0000000000003014/1",
1640 ethType='IPV4',
1641 ethSrc=macsDict.get( 'h24' ))
1642
shahshreya9294c8d2015-01-21 15:54:16 -08001643 if ptpIntentResult == main.TRUE:
1644 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001645 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001646 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001647
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001648 var8 = "Add point intents for mininet hosts h15 and h25 or" +\
1649 " ONOS hosts hF and h19"
shahshreya9294c8d2015-01-21 15:54:16 -08001650 main.case(var8)
1651 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001652 "of:0000000000003015/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001653 "of:0000000000006025/1",
1654 ethType='IPV4',
1655 ethSrc=macsDict.get( 'h15' ))
1656
shahshreya9294c8d2015-01-21 15:54:16 -08001657 if ptpIntentResult == main.TRUE:
1658 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001659 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001660 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001661
shahshreya9294c8d2015-01-21 15:54:16 -08001662 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001663 "of:0000000000006025/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001664 "of:0000000000003015/1",
1665 ethType='IPV4',
1666 ethSrc=macsDict.get( 'h25' ))
1667
shahshreya9294c8d2015-01-21 15:54:16 -08001668 if ptpIntentResult == main.TRUE:
1669 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001670 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001671 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001672
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001673 var9 = "Add intents for mininet hosts h16 and h26 or" +\
1674 " ONOS hosts h10 and h1A"
shahshreya9294c8d2015-01-21 15:54:16 -08001675 main.case(var9)
1676 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001677 "of:0000000000003016/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001678 "of:0000000000006026/1",
1679 ethType='IPV4',
1680 ethSrc=macsDict.get( 'h16' ))
1681
shahshreya9294c8d2015-01-21 15:54:16 -08001682 if ptpIntentResult == main.TRUE:
1683 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001684 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001685 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001686
shahshreya9294c8d2015-01-21 15:54:16 -08001687 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001688 "of:0000000000006026/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001689 "of:0000000000003016/1",
1690 ethType='IPV4',
1691 ethSrc=macsDict.get( 'h26' ))
1692
shahshreya9294c8d2015-01-21 15:54:16 -08001693 if ptpIntentResult == main.TRUE:
1694 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001695 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001696 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001697
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001698 var10 = "Add point intents for mininet hosts h17 and h27 or" +\
1699 " ONOS hosts h11 and h1B"
shahshreya9294c8d2015-01-21 15:54:16 -08001700 main.case(var10)
1701 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001702 "of:0000000000003017/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001703 "of:0000000000006027/1",
1704 ethType='IPV4',
1705 ethSrc=macsDict.get( 'h17' ))
1706
shahshreya9294c8d2015-01-21 15:54:16 -08001707 if ptpIntentResult == main.TRUE:
1708 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001709 main.log.info( "Point to point intent install successful" )
shahshreyab189da22015-02-25 10:18:26 -08001710 #main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001711
shahshreya9294c8d2015-01-21 15:54:16 -08001712 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001713 "of:0000000000006027/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001714 "of:0000000000003017/1",
1715 ethType='IPV4',
1716 ethSrc=macsDict.get( 'h27' ))
1717
shahshreya9294c8d2015-01-21 15:54:16 -08001718 if ptpIntentResult == main.TRUE:
1719 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001720 main.log.info( "Point to point intent install successful" )
shahshreyab189da22015-02-25 10:18:26 -08001721 #main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001722
1723 print(
shahshreya9294c8d2015-01-21 15:54:16 -08001724 "___________________________________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001725
1726 flowHandle = main.ONOS2.flows()
shahshreya82ecd282015-02-05 16:48:03 -08001727 #main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001728
1729 count = 1
1730 i = 8
shahshreya9294c8d2015-01-21 15:54:16 -08001731 PingResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001732 while i < 18:
1733 main.log.info(
1734 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1735 ping = main.Mininet1.pingHost(
1736 src="h" + str( i ), target="h" + str( i + 10 ) )
1737 if ping == main.FALSE and count < 5:
1738 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001739 # i = 8
1740 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001741 main.log.report( "Ping between h" +
1742 str( i ) +
1743 " and h" +
1744 str( i +
1745 10 ) +
1746 " failed. Making attempt number " +
1747 str( count ) +
1748 " in 2 seconds" )
1749 time.sleep( 2 )
1750 elif ping == main.FALSE:
1751 main.log.report( "All ping attempts between h" +
1752 str( i ) +
1753 " and h" +
1754 str( i +
1755 10 ) +
1756 "have failed" )
1757 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -08001758 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001759 elif ping == main.TRUE:
1760 main.log.info( "Ping test between h" +
1761 str( i ) +
1762 " and h" +
1763 str( i +
1764 10 ) +
1765 "passed!" )
1766 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001767 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001768 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001769 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -08001770 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001771
shahshreya9294c8d2015-01-21 15:54:16 -08001772 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001773 main.log.report(
1774 "Point intents have not ben installed correctly. Cleaning up" )
1775 # main.cleanup()
1776 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -08001777 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001778 main.log.report( "Point Intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001779
shahshreya9294c8d2015-01-21 15:54:16 -08001780 case9Result = PingResult
kelvin-onlab8a832582015-01-16 17:06:11 -08001781 utilities.assert_equals(
1782 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001783 actual=case9Result,
kelvin-onlab8a832582015-01-16 17:06:11 -08001784 onpass="Point intents addition and Pingall Test successful",
1785 onfail="Point intents addition and Pingall Test NOT successful" )