blob: ade6d07bb6b4975e0bef192b2c574d31a7410b7e [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' ]
shahshreya842d8b92015-06-10 14:13:33 -070034 gitPull = main.params[ 'GIT' ][ 'pull' ]
shahshreyae6c7cf42014-11-26 16:39:01 -080035
kelvin-onlab8a832582015-01-16 17:06:11 -080036 main.case( "Setting up test environment" )
37 main.log.report(
38 "This testcase is testing setting up test environment" )
39 main.log.report( "__________________________________" )
40
41 main.step( "Applying cell variable to environment" )
shahshreya9294c8d2015-01-21 15:54:16 -080042 cellResult = main.ONOSbench.setCell( cellName )
43 verifyResult = main.ONOSbench.verifyCell()
kelvin-onlab8a832582015-01-16 17:06:11 -080044
shahshreya82ecd282015-02-05 16:48:03 -080045 main.step( "Git checkout and get version" )
shahshreyaa47ebf42015-05-20 13:29:18 -070046 main.ONOSbench.gitCheckout( "master" )
shahshreya842d8b92015-06-10 14:13:33 -070047 if gitPull == 'True':
48 gitPullResult = main.ONOSbench.gitPull()
49 if gitPullResult == 1:
50 main.step( "Using mvn clean & install" )
51 main.ONOSbench.cleanInstall()
52 main.step( "Creating ONOS package" )
53 packageResult = main.ONOSbench.onosPackage()
54 elif gitPullResult == 0:
55 main.log.report(
56 "Git Pull Failed, look into logs for detailed reason" )
57 main.cleanup()
58 main.exit()
59 main.log.info( "git_pull_result = " + str( gitPullResult ))
60 else:
61 main.log.info( "Skipping git pull" )
shahshreya9294c8d2015-01-21 15:54:16 -080062 main.ONOSbench.getVersion( report=True )
shahshreya234a1682015-05-27 15:41:56 -070063 packageResult = main.TRUE
shahshreya234a1682015-05-27 15:41:56 -070064
65 main.step( "Uninstalling ONOS package" )
66 onosInstallResult = main.ONOSbench.onosUninstall( ONOS1Ip )
67 if onosInstallResult == main.TRUE:
68 main.log.report( "Uninstalling ONOS package successful" )
69 else:
70 main.log.report( "Uninstalling ONOS package failed" )
shahshreya4e13a062014-11-11 16:46:18 -080071
shahshreya842d8b92015-06-10 14:13:33 -070072 time.sleep( 20 )
kelvin-onlab8a832582015-01-16 17:06:11 -080073 main.step( "Installing ONOS package" )
shahshreya234a1682015-05-27 15:41:56 -070074 onosInstallResult = main.ONOSbench.onosInstall( ONOS1Ip )
75 print onosInstallResult
shahshreya9294c8d2015-01-21 15:54:16 -080076 if onosInstallResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -080077 main.log.report( "Installing ONOS package successful" )
shahshreya4e13a062014-11-11 16:46:18 -080078 else:
kelvin-onlab8a832582015-01-16 17:06:11 -080079 main.log.report( "Installing ONOS package failed" )
shahshreya4e13a062014-11-11 16:46:18 -080080
shahshreya842d8b92015-06-10 14:13:33 -070081 time.sleep( 20 )
shahshreya9294c8d2015-01-21 15:54:16 -080082 onos1Isup = main.ONOSbench.isup()
83 if onos1Isup == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -080084 main.log.report( "ONOS instance is up and ready" )
shahshreya4e13a062014-11-11 16:46:18 -080085 else:
kelvin-onlab8a832582015-01-16 17:06:11 -080086 main.log.report( "ONOS instance may not be up" )
shahshreya4e13a062014-11-11 16:46:18 -080087
shahshreya234a1682015-05-27 15:41:56 -070088 startResult = main.TRUE
89 #main.step( "Starting ONOS service" )
90 #startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -080091
shahshreya234a1682015-05-27 15:41:56 -070092 main.ONOS2.startOnosCli( ONOS1Ip )
shahshreya82ecd282015-02-05 16:48:03 -080093 main.step( "Starting Mininet CLI..." )
94
95 # Starting the mininet using the old way
96 main.step( "Starting Mininet ..." )
97 netIsUp = main.Mininet1.startNet()
98 if netIsUp:
99 main.log.info("Mininet CLI is up")
100
shahshreya9294c8d2015-01-21 15:54:16 -0800101 case1Result = ( packageResult and
102 cellResult and verifyResult
103 and onosInstallResult and
104 onos1Isup and startResult )
105 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800106 onpass="Test startup successful",
107 onfail="Test startup NOT successful" )
108
109 def CASE2( self, main ):
110 """
shahshreyaa22f8f82014-12-08 16:59:21 -0800111 Switch Down
kelvin-onlab8a832582015-01-16 17:06:11 -0800112 """
113 # NOTE: You should probably run a topology check after this
114 import time
shahshreyaa22f8f82014-12-08 16:59:21 -0800115
kelvin-onlab8a832582015-01-16 17:06:11 -0800116 main.case( "Switch down discovery" )
117 main.log.report( "This testcase is testing a switch down discovery" )
118 main.log.report( "__________________________________" )
119
shahshreya9294c8d2015-01-21 15:54:16 -0800120 switchSleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
shahshreyaa22f8f82014-12-08 16:59:21 -0800121
122 description = "Killing a switch to ensure it is discovered correctly"
kelvin-onlab8a832582015-01-16 17:06:11 -0800123 main.log.report( description )
124 main.case( description )
shahshreyaa22f8f82014-12-08 16:59:21 -0800125
kelvin-onlab8a832582015-01-16 17:06:11 -0800126 # TODO: Make this switch parameterizable
127 main.step( "Kill s28 " )
128 main.log.report( "Deleting s28" )
129 # FIXME: use new dynamic topo functions
shahshreya9294c8d2015-01-21 15:54:16 -0800130 main.Mininet1.delSwitch( "s28" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800131 main.log.info(
132 "Waiting " +
shahshreya9294c8d2015-01-21 15:54:16 -0800133 str( switchSleep ) +
kelvin-onlab8a832582015-01-16 17:06:11 -0800134 " seconds for switch down to be discovered" )
shahshreya9294c8d2015-01-21 15:54:16 -0800135 time.sleep( switchSleep )
kelvin-onlab8a832582015-01-16 17:06:11 -0800136 # Peek at the deleted switch
shahshreya9294c8d2015-01-21 15:54:16 -0800137 device = main.ONOS2.getDevice( dpid="0028" )
shahshreyaa22f8f82014-12-08 16:59:21 -0800138 print "device = ", device
kelvin-onlab8a832582015-01-16 17:06:11 -0800139 if device[ u'available' ] == 'False':
shahshreya9294c8d2015-01-21 15:54:16 -0800140 case2Result = main.FALSE
shahshreyaa22f8f82014-12-08 16:59:21 -0800141 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800142 case2Result = main.TRUE
143 utilities.assert_equals( expect=main.TRUE, actual=case2Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800144 onpass="Switch down discovery successful",
145 onfail="Switch down discovery failed" )
shahshreyaa22f8f82014-12-08 16:59:21 -0800146
shahshreyab189da22015-02-25 10:18:26 -0800147 def CASE101( self, main ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800148 """
shahshreya4e13a062014-11-11 16:46:18 -0800149 Cleanup sequence:
shahshreya9294c8d2015-01-21 15:54:16 -0800150 onos-service <nodeIp> stop
shahshreya4e13a062014-11-11 16:46:18 -0800151 onos-uninstall
152
153 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800154
kelvin-onlab8a832582015-01-16 17:06:11 -0800155 """
shahshreya9294c8d2015-01-21 15:54:16 -0800156 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800157
kelvin-onlab8a832582015-01-16 17:06:11 -0800158 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800159
kelvin-onlab8a832582015-01-16 17:06:11 -0800160 main.step( "Testing ONOS kill function" )
shahshreya9294c8d2015-01-21 15:54:16 -0800161 killResult = main.ONOSbench.onosKill( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800162
kelvin-onlab8a832582015-01-16 17:06:11 -0800163 main.step( "Stopping ONOS service" )
shahshreya9294c8d2015-01-21 15:54:16 -0800164 stopResult = main.ONOSbench.onosStop( ONOS1Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800165
kelvin-onlab8a832582015-01-16 17:06:11 -0800166 main.step( "Uninstalling ONOS service" )
shahshreya9294c8d2015-01-21 15:54:16 -0800167 uninstallResult = main.ONOSbench.onosUninstall()
168
169 case11Result = killResult and stopResult and uninstallResult
170 utilities.assert_equals( expect=main.TRUE, actual=case11Result,
171 onpass="Cleanup successful",
172 onfail="Cleanup failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800173
kelvin-onlab8a832582015-01-16 17:06:11 -0800174 def CASE3( self, main ):
175 """
shahshreya4e13a062014-11-11 16:46:18 -0800176 Test 'onos' command and its functionality in driver
kelvin-onlab8a832582015-01-16 17:06:11 -0800177 """
shahshreya9294c8d2015-01-21 15:54:16 -0800178 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800179
kelvin-onlab8a832582015-01-16 17:06:11 -0800180 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800181
kelvin-onlab8a832582015-01-16 17:06:11 -0800182 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800183 cmdstr1 = "system:name"
shahshreya9294c8d2015-01-21 15:54:16 -0800184 cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
185 main.log.info( "onos command returned: " + cmdResult1 )
shahshreya4e13a062014-11-11 16:46:18 -0800186
kelvin-onlab8a832582015-01-16 17:06:11 -0800187 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800188 cmdstr2 = "onos:topology"
shahshreya9294c8d2015-01-21 15:54:16 -0800189 cmdResult2 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
190 main.log.info( "onos command returned: " + cmdResult2 )
shahshreya4e13a062014-11-11 16:46:18 -0800191
kelvin-onlab8a832582015-01-16 17:06:11 -0800192 def CASE20( self ):
193 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800194 Exit from mininet cli
195 reinstall ONOS
kelvin-onlab8a832582015-01-16 17:06:11 -0800196 """
shahshreya234a1682015-05-27 15:41:56 -0700197 import time
shahshreya9294c8d2015-01-21 15:54:16 -0800198 cellName = main.params[ 'ENV' ][ 'cellName' ]
199 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
kelvin-onlab8a832582015-01-16 17:06:11 -0800200
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800201 main.log.report( "This testcase exits the mininet cli and reinstalls" +
202 "ONOS to switch over to Packet Optical topology" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800203 main.log.report( "_____________________________________________" )
204 main.case( "Disconnecting mininet and restarting ONOS" )
shahshreya234a1682015-05-27 15:41:56 -0700205
kelvin-onlab8a832582015-01-16 17:06:11 -0800206 main.step( "Disconnecting mininet and restarting ONOS" )
shahshreya234a1682015-05-27 15:41:56 -0700207 step1Result = main.TRUE
shahshreya9294c8d2015-01-21 15:54:16 -0800208 mininetDisconnect = main.Mininet1.disconnect()
shahshreyaa47ebf42015-05-20 13:29:18 -0700209 print "mininetDisconnect = ", mininetDisconnect
shahshreya234a1682015-05-27 15:41:56 -0700210 step1Result = mininetDisconnect
211 utilities.assert_equals(
212 expect=main.TRUE,
213 actual=step1Result,
214 onpass="Mininet disconnect successfully",
215 onfail="Mininet failed to disconnect")
216 """
217 main.step( "Removing raft logs before a clean installation of ONOS" )
218 step2Result = main.TRUE
219 removeRaftLogsResult = main.ONOSbench.onosRemoveRaftLogs()
220 step2Result = removeRaftLogsResult
221 utilities.assert_equals(
222 expect=main.TRUE,
223 actual=step2Result,
224 onpass="Raft logs removed successfully",
225 onfail="Failed to remove raft logs")
226 """
kelvin-onlab8a832582015-01-16 17:06:11 -0800227 main.step( "Applying cell variable to environment" )
shahshreya234a1682015-05-27 15:41:56 -0700228 step3Result = main.TRUE
229 setCellResult = main.ONOSbench.setCell( cellName )
230 verifyCellResult = main.ONOSbench.verifyCell()
231 step3Result = setCellResult and verifyCellResult
232 utilities.assert_equals(
233 expect=main.TRUE,
234 actual=step3Result,
235 onpass="Cell applied successfully",
236 onfail="Failed to apply cell")
shahshreyae6c7cf42014-11-26 16:39:01 -0800237
shahshreya234a1682015-05-27 15:41:56 -0700238 main.step( "Uninstalling ONOS package" )
239 step4Result = main.TRUE
240 ONOSip1 = main.params[ 'CTRL' ][ 'ip1' ]
241 onosUninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOSip1)
242 step4Result = onosUninstallResult
243 utilities.assert_equals(
244 expect=main.TRUE,
245 actual=step4Result,
246 onpass="Successfully uninstalled ONOS",
247 onfail="Failed to uninstall ONOS")
248
249 time.sleep( 5 )
250 main.step( "Installing ONOS package" )
251 step5Result = main.TRUE
252 onosInstallResult = main.ONOSbench.onosInstall( node = ONOSip1 )
253 step5Result = onosInstallResult
254 utilities.assert_equals(
255 expect=main.TRUE,
256 actual=step5Result,
257 onpass="Successfully installed ONOS",
258 onfail="Failed to install ONOS")
shahshreyae6c7cf42014-11-26 16:39:01 -0800259
shahshreya9294c8d2015-01-21 15:54:16 -0800260 onos1Isup = main.ONOSbench.isup()
261 if onos1Isup == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800262 main.log.report( "ONOS instance is up and ready" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800263 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800264 main.log.report( "ONOS instance may not be up" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800265
kelvin-onlab8a832582015-01-16 17:06:11 -0800266 main.step( "Starting ONOS service" )
shahshreya234a1682015-05-27 15:41:56 -0700267 step6Result = main.TRUE
shahshreya9294c8d2015-01-21 15:54:16 -0800268 startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreya234a1682015-05-27 15:41:56 -0700269 step6Result = startResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800270 utilities.assert_equals(
271 expect=main.TRUE,
shahshreya234a1682015-05-27 15:41:56 -0700272 actual=step6Result,
273 onpass="Successfully started ONOS",
274 onfail="Failed to start ONOS")
275
276 main.step( "Starting ONOS cli" )
277 step7Result = main.TRUE
278 cliResult = main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
279 step7Result = cliResult
280 utilities.assert_equals(
281 expect=main.TRUE,
282 actual=step7Result,
283 onpass="Successfully started ONOS cli",
284 onfail="Failed to start ONOS cli")
kelvin-onlab8a832582015-01-16 17:06:11 -0800285
286 def CASE21( self, main ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800287 """
shahshreya9294c8d2015-01-21 15:54:16 -0800288 On ONOS bench, run this command:
shahshreya7630b1c2015-04-03 15:37:14 -0700289 sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1
290 which spawns packet optical topology and copies the links
shahshreya9294c8d2015-01-21 15:54:16 -0800291 json file to the onos instance.
292 Note that in case of Packet Optical, the links are not learnt
293 from the topology, instead the links are learnt
shahshreyae6c7cf42014-11-26 16:39:01 -0800294 from the json config file
kelvin-onlab8a832582015-01-16 17:06:11 -0800295 """
shahshreya234a1682015-05-27 15:41:56 -0700296 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800297 main.log.report(
298 "This testcase starts the packet layer topology and REST" )
299 main.log.report( "_____________________________________________" )
300 main.case( "Starting LINC-OE and other components" )
shahshreya234a1682015-05-27 15:41:56 -0700301
302 main.step( "Activate optical app" )
303 step1Result = main.TRUE
304 activateOpticalResult = main.ONOS2.activateApp( "org.onosproject.optical" )
305 step1Result = activateOpticalResult
306 utilities.assert_equals(
307 expect=main.TRUE,
308 actual=step1Result,
309 onpass="Successfully activated optical app",
310 onfail="Failed to activate optical app")
311
shahshreyad524a942015-04-21 09:55:16 -0700312 appCheck = main.ONOS2.appToIDCheck()
313 if appCheck != main.TRUE:
314 main.log.warn( main.ONOS2.apps() )
315 main.log.warn( main.ONOS2.appIDs() )
316
shahshreya234a1682015-05-27 15:41:56 -0700317 main.step( "Starting mininet and LINC-OE" )
318 step2Result = main.TRUE
319 time.sleep( 10 )
shahshreya215c48f2015-04-06 15:55:55 -0700320 opticalMnScript = main.LincOE2.runOpticalMnScript(ctrllerIP = main.params[ 'CTRL' ][ 'ip1' ])
shahshreya234a1682015-05-27 15:41:56 -0700321 step2Result = opticalMnScript
kelvin-onlab8a832582015-01-16 17:06:11 -0800322 utilities.assert_equals(
323 expect=main.TRUE,
shahshreya234a1682015-05-27 15:41:56 -0700324 actual=step2Result,
325 onpass="Started the topology successfully ",
326 onfail="Failed to start the topology")
shahshreyae6c7cf42014-11-26 16:39:01 -0800327
kelvin-onlab8a832582015-01-16 17:06:11 -0800328 def CASE22( self, main ):
329 """
shahshreya7630b1c2015-04-03 15:37:14 -0700330 Curretly we use, 10 optical switches(ROADM's) and
331 6 packet layer mininet switches each with one host.
332 Therefore, the roadmCount variable = 10,
333 packetLayerSWCount variable = 6, hostCount=6 and
shahshreya234a1682015-05-27 15:41:56 -0700334 links=46.
shahshreya7630b1c2015-04-03 15:37:14 -0700335 All this is hardcoded in the testcase. If the topology changes,
shahshreya9294c8d2015-01-21 15:54:16 -0800336 these hardcoded values need to be changed
kelvin-onlab8a832582015-01-16 17:06:11 -0800337 """
shahshreya234a1682015-05-27 15:41:56 -0700338 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800339 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800340 "This testcase compares the optical+packet topology against what" +
341 " is expected" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800342 main.case( "Topology comparision" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800343
shahshreya234a1682015-05-27 15:41:56 -0700344 main.step( "Starts new ONOS cli" )
345 step1Result = main.TRUE
346 cliResult = main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ]\
347 [ 'ip1' ] )
348 step1Result = cliResult
349 utilities.assert_equals(
350 expect=main.TRUE,
351 actual=step1Result,
352 onpass="Successfully starts a new cli",
353 onfail="Failed to start new cli" )
354
355 main.step( "Compare topology" )
356 step2Result = main.TRUE
357 devicesResult = main.ONOS3.devices( jsonFormat=False )
358 print "devices_result :\n", devicesResult
shahshreya9294c8d2015-01-21 15:54:16 -0800359 devicesLinewise = devicesResult.split( "\n" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800360 roadmCount = 0
361 packetLayerSWCount = 0
shahshreya9294c8d2015-01-21 15:54:16 -0800362 for line in devicesLinewise:
kelvin-onlab8a832582015-01-16 17:06:11 -0800363 components = line.split( "," )
364 availability = components[ 1 ].split( "=" )[ 1 ]
365 type = components[ 3 ].split( "=" )[ 1 ]
shahshreyae6c7cf42014-11-26 16:39:01 -0800366 if availability == 'true' and type == 'ROADM':
367 roadmCount += 1
kelvin-onlab8a832582015-01-16 17:06:11 -0800368 elif availability == 'true' and type == 'SWITCH':
shahshreyae6c7cf42014-11-26 16:39:01 -0800369 packetLayerSWCount += 1
shahshreya7630b1c2015-04-03 15:37:14 -0700370 if roadmCount == 10:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800371 print "Number of Optical Switches = %d and is" % roadmCount +\
372 " correctly detected"
kelvin-onlab8a832582015-01-16 17:06:11 -0800373 main.log.info(
374 "Number of Optical Switches = " +
375 str( roadmCount ) +
376 " and is correctly detected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800377 opticalSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800378 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800379 print "Number of Optical Switches = %d and is wrong" % roadmCount
kelvin-onlab8a832582015-01-16 17:06:11 -0800380 main.log.info(
381 "Number of Optical Switches = " +
382 str( roadmCount ) +
383 " and is wrong" )
shahshreya9294c8d2015-01-21 15:54:16 -0800384 opticalSWResult = main.FALSE
shahshreya7630b1c2015-04-03 15:37:14 -0700385 if packetLayerSWCount == 6:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800386 print "Number of Packet layer or mininet Switches = %d "\
387 % packetLayerSWCount + "and is correctly detected"
kelvin-onlab8a832582015-01-16 17:06:11 -0800388 main.log.info(
389 "Number of Packet layer or mininet Switches = " +
390 str( packetLayerSWCount ) +
391 " and is correctly detected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800392 packetSWResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -0800393 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800394 print "Number of Packet layer or mininet Switches = %d and"\
395 % packetLayerSWCount + " is wrong"
kelvin-onlab8a832582015-01-16 17:06:11 -0800396 main.log.info(
397 "Number of Packet layer or mininet Switches = " +
398 str( packetLayerSWCount ) +
399 " and is wrong" )
shahshreya9294c8d2015-01-21 15:54:16 -0800400 packetSWResult = main.FALSE
shahshreya234a1682015-05-27 15:41:56 -0700401 # sleeps for sometime so the state of the switches will be active
402 time.sleep( 30 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800403 print "_________________________________"
shahshreya9294c8d2015-01-21 15:54:16 -0800404 linksResult = main.ONOS3.links( jsonFormat=False )
405 print "links_result = ", linksResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800406 print "_________________________________"
shahshreya234a1682015-05-27 15:41:56 -0700407 linkActiveCount = linksResult.count("state=ACTIVE")
shahshreya7630b1c2015-04-03 15:37:14 -0700408 main.log.info( "linkActiveCount = " + str( linkActiveCount ))
shahshreya234a1682015-05-27 15:41:56 -0700409 if linkActiveCount == 46:
shahshreya7630b1c2015-04-03 15:37:14 -0700410 linkActiveResult = main.TRUE
411 main.log.info(
412 "Number of links in ACTIVE state are correct")
413 else:
414 linkActiveResult = main.FALSE
415 main.log.info(
416 "Number of links in ACTIVE state are wrong")
shahshreya234a1682015-05-27 15:41:56 -0700417 step2Result = opticalSWResult and packetSWResult and \
shahshreya7630b1c2015-04-03 15:37:14 -0700418 linkActiveResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800419 utilities.assert_equals(
420 expect=main.TRUE,
shahshreya234a1682015-05-27 15:41:56 -0700421 actual=step2Result,
422 onpass="Successfully loaded packet optical topology",
423 onfail="Failed to load packet optical topology" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800424
kelvin-onlab8a832582015-01-16 17:06:11 -0800425 def CASE23( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800426 import time
kelvin-onlab8a832582015-01-16 17:06:11 -0800427 """
shahshreya9294c8d2015-01-21 15:54:16 -0800428 Add bidirectional point intents between 2 packet layer( mininet )
429 devices and
shahshreyae6c7cf42014-11-26 16:39:01 -0800430 ping mininet hosts
kelvin-onlab8a832582015-01-16 17:06:11 -0800431 """
432 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800433 "This testcase adds bidirectional point intents between 2 " +
434 "packet layer( mininet ) devices and ping mininet hosts" )
shahshreya234a1682015-05-27 15:41:56 -0700435 main.case( "Install point intents between 2 packet layer device and " +
436 "ping the hosts" )
437
kelvin-onlab8a832582015-01-16 17:06:11 -0800438 main.step( "Adding point intents" )
shahshreyabf739d82015-06-10 11:22:31 -0700439 checkFlowResult = main.TRUE
shahshreya234a1682015-05-27 15:41:56 -0700440 step1Result = main.TRUE
441 main.pIntentsId = []
442 pIntent1 = main.ONOS3.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -0800443 "of:0000ffffffff0001/1",
shahshreya7630b1c2015-04-03 15:37:14 -0700444 "of:0000ffffffff0005/1" )
shahshreya234a1682015-05-27 15:41:56 -0700445 pIntent2 = main.ONOS3.addPointIntent(
shahshreya7630b1c2015-04-03 15:37:14 -0700446 "of:0000ffffffff0005/1",
kelvin-onlab8a832582015-01-16 17:06:11 -0800447 "of:0000ffffffff0001/1" )
shahshreya234a1682015-05-27 15:41:56 -0700448 main.pIntentsId.append( pIntent1 )
449 main.pIntentsId.append( pIntent2 )
450 time.sleep( 10 )
451 main.log.info( "Checking intents state")
452 checkStateResult = main.ONOS3.checkIntentState(
453 intentsId = main.pIntentsId )
454 time.sleep( 10 )
455 main.log.info( "Checking flows state")
456 checkFlowResult = main.ONOS3.checkFlowsState()
shahshreyae6c7cf42014-11-26 16:39:01 -0800457 # Sleep for 30 seconds to provide time for the intent state to change
shahshreya234a1682015-05-27 15:41:56 -0700458 time.sleep( 10 )
459 main.log.info( "Checking intents state one more time")
460 checkStateResult = main.ONOS3.checkIntentState(
461 intentsId = main.pIntentsId )
462 step1Result = checkStateResult and checkFlowResult
kelvin-onlab8a832582015-01-16 17:06:11 -0800463 utilities.assert_equals(
464 expect=main.TRUE,
shahshreya234a1682015-05-27 15:41:56 -0700465 actual=step1Result,
466 onpass="Successfully added point intents",
467 onfail="Failed to add point intents")
468
469 main.step( "Ping h1 and h5" )
470 step2Result = main.TRUE
471 main.log.info( "\n\nh1 is Pinging h5" )
472 pingResult = main.LincOE2.pingHostOptical( src="h1", target="h5" )
473 step2Result = pingResult
474 utilities.assert_equals(
475 expect=main.TRUE,
476 actual=step2Result,
477 onpass="Successfully pinged h1 and h5",
478 onfail="Failed to ping between h1 and h5")
shahshreyae6c7cf42014-11-26 16:39:01 -0800479
kelvin-onlab8a832582015-01-16 17:06:11 -0800480 def CASE24( self, main ):
shahshreyae6c7cf42014-11-26 16:39:01 -0800481 import time
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800482 import json
kelvin-onlab8a832582015-01-16 17:06:11 -0800483 """
shahshreya7630b1c2015-04-03 15:37:14 -0700484 LINC uses its own switch IDs. You can use the following
485 command on the LINC console to find the mapping between
486 DPIDs and LINC IDs.
487 rp(application:get_all_key(linc)).
488
shahshreya9294c8d2015-01-21 15:54:16 -0800489 Test Rerouting of Packet Optical by bringing a port down
shahshreya7630b1c2015-04-03 15:37:14 -0700490 ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
491 so that link
492 ( between switch1 port20 - switch5 port50 ) is inactive
shahshreya9294c8d2015-01-21 15:54:16 -0800493 and do a ping test. If rerouting is successful,
494 ping should pass. also check the flows
kelvin-onlab8a832582015-01-16 17:06:11 -0800495 """
496 main.log.report(
497 "This testcase tests rerouting and pings mininet hosts" )
498 main.case( "Test rerouting and pings mininet hosts" )
shahshreya234a1682015-05-27 15:41:56 -0700499
shahshreya7630b1c2015-04-03 15:37:14 -0700500 main.step( "Attach to the Linc-OE session" )
shahshreya234a1682015-05-27 15:41:56 -0700501 step1Result = main.TRUE
502 attachConsole = main.LincOE1.attachLincOESession()
503 step1Result = attachConsole
504 utilities.assert_equals(
505 expect=main.TRUE,
506 actual=step1Result,
507 onpass="Successfully attached Linc-OE session",
508 onfail="Failed to attached Linc-OE session")
shahshreya7630b1c2015-04-03 15:37:14 -0700509
kelvin-onlab8a832582015-01-16 17:06:11 -0800510 main.step( "Bring a port down and verify the link state" )
shahshreya234a1682015-05-27 15:41:56 -0700511 step2Result = main.TRUE
shahshreya7630b1c2015-04-03 15:37:14 -0700512 main.LincOE1.portDown( swId="9", ptId="20" )
shahshreya9294c8d2015-01-21 15:54:16 -0800513 linksNonjson = main.ONOS3.links( jsonFormat=False )
514 main.log.info( "links = " + linksNonjson )
shahshreya234a1682015-05-27 15:41:56 -0700515 linkInactiveCount = linksNonjson.count( "state=INACTIVE" )
shahshreya7630b1c2015-04-03 15:37:14 -0700516 main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
517 if linkInactiveCount == 2:
518 main.log.info(
519 "Number of links in INACTIVE state are correct")
520 else:
521 main.log.info(
522 "Number of links in INACTIVE state are wrong")
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800523 links = main.ONOS3.links()
kelvin-onlab8a832582015-01-16 17:06:11 -0800524 main.log.info( "links = " + links )
shahshreya9294c8d2015-01-21 15:54:16 -0800525 linksResult = json.loads( links )
526 linksStateResult = main.FALSE
527 for item in linksResult:
kelvin-onlab8a832582015-01-16 17:06:11 -0800528 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
shahshreya7630b1c2015-04-03 15:37:14 -0700529 'src' ][ 'port' ] == "20":
530 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
531 'dst' ][ 'port' ] == "50":
shahshreya9294c8d2015-01-21 15:54:16 -0800532 linksState = item[ 'state' ]
533 if linksState == "INACTIVE":
kelvin-onlab8a832582015-01-16 17:06:11 -0800534 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800535 "Links state is inactive as expected due to one" +
536 " of the ports being down" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800537 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800538 "Links state is inactive as expected due to one" +
539 " of the ports being down" )
shahshreya9294c8d2015-01-21 15:54:16 -0800540 linksStateResult = main.TRUE
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800541 break
542 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800543 main.log.info(
544 "Links state is not inactive as expected" )
545 main.log.report(
546 "Links state is not inactive as expected" )
shahshreya9294c8d2015-01-21 15:54:16 -0800547 linksStateResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800548 time.sleep( 10 )
shahshreya234a1682015-05-27 15:41:56 -0700549 checkFlowsState = main.ONOS3.checkFlowsState()
550 step2Result = linksStateResult
551 utilities.assert_equals(
552 expect=main.TRUE,
553 actual=step2Result,
554 onpass="Successfuly brought down a link",
555 onfail="Failed to bring down a link")
shahshreyaf1b1b9f2014-12-04 16:59:20 -0800556
kelvin-onlab8a832582015-01-16 17:06:11 -0800557 main.step( "Verify Rerouting by a ping test" )
shahshreya234a1682015-05-27 15:41:56 -0700558 step3Result = main.TRUE
shahshreya7630b1c2015-04-03 15:37:14 -0700559 main.log.info( "\n\nh1 is Pinging h5" )
shahshreya234a1682015-05-27 15:41:56 -0700560 pingResult = main.LincOE2.pingHostOptical( src="h1", target="h5" )
561 step3Result = pingResult
562 utilities.assert_equals(
563 expect=main.TRUE,
564 actual=step3Result,
565 onpass="Successfully pinged h1 and h5",
566 onfail="Failed to ping between h1 and h5")
567
568 main.step( "Bring the downed port up and verify the link state" )
569 step4Result = main.TRUE
570 main.LincOE1.portUp( swId="9", ptId="20" )
571 linksNonjson = main.ONOS3.links( jsonFormat=False )
572 main.log.info( "links = " + linksNonjson )
573 linkInactiveCount = linksNonjson.count( "state=INACTIVE" )
574 main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
575 if linkInactiveCount == 0:
kelvin-onlab8a832582015-01-16 17:06:11 -0800576 main.log.info(
shahshreya234a1682015-05-27 15:41:56 -0700577 "Number of links in INACTIVE state are correct")
shahshreyae6c7cf42014-11-26 16:39:01 -0800578 else:
shahshreya234a1682015-05-27 15:41:56 -0700579 main.log.info(
580 "Number of links in INACTIVE state are wrong")
581 step4Result = main.FALSE
582 utilities.assert_equals(
583 expect=main.TRUE,
584 actual=step4Result,
585 onpass="Successfully brought the port up",
586 onfail="Failed to bring the port up")
587 """
588 main.step( "Removing host intents" )
589 step5Result = main.TRUE
590 removeResult = main.TRUE
591 # Check remaining intents
592 intentsJson = json.loads( main.ONOS3.intents() )
593 main.ONOS3.removeIntent( intentId=intent1, purge=True )
594 main.ONOS3.removeIntent( intentId=intent2, purge=True )
595 for intents in intentsJson:
596 main.ONOS3.removeIntent( intentId=intents.get( 'id' ),
597 app='org.onosproject.optical',
598 purge=True )
599 print json.loads( main.ONOS3.intents() )
600 if len( json.loads( main.ONOS3.intents() ) ):
601 removeResult = main.FALSE
602 step5Result = removeResult
603 utilities.assert_equals( expect=main.TRUE,
604 actual=step5Result,
605 onpass="Successfully removed host intents",
606 onfail="Failed to remove host intents" )
607 """
608 def CASE10( self ):
609 main.log.report(
610 "This testcase uninstalls the reactive forwarding app" )
611 main.log.report( "__________________________________" )
612 main.case( "Uninstalling reactive forwarding app" )
613 main.step( "Uninstalling reactive forwarding app" )
614 step1Result = main.TRUE
615 # Unistall onos-app-fwd app to disable reactive forwarding
616 main.log.info( "deactivate reactive forwarding app" )
617 appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
618 appCheck = main.ONOS2.appToIDCheck()
619 if appCheck != main.TRUE:
620 main.log.warn( main.ONOS2.apps() )
621 main.log.warn( main.ONOS2.appIDs() )
622 step1Result = appUninstallResult
623 utilities.assert_equals(
624 expect=main.TRUE,
625 actual=step1Result,
626 onpass="Successfully deactivate reactive forwarding app",
627 onfail="Failed to deactivate reactive forwarding app")
628 # After reactive forwarding is disabled, the reactive flows on
629 # switches timeout in 10-15s
630 # So sleep for 15s
631 time.sleep( 15 )
632 flows = main.ONOS2.flows()
633 main.log.info( flows )
shahshreyae6c7cf42014-11-26 16:39:01 -0800634
shahshreya234a1682015-05-27 15:41:56 -0700635 def CASE25( self ):
636 """
637 Add host intents between 2 packet layer host
638 """
639 import time
640 import json
641 main.log.report( "Adding host intents between 2 optical layer host" )
642 main.case( "Test add host intents between optical layer host" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800643
shahshreya234a1682015-05-27 15:41:56 -0700644 main.step( "Discover host using arping" )
645 step1Result = main.TRUE
646 main.hostMACs = []
647 main.hostId = []
648 #Listing host MAC addresses
649 for i in range( 1 , 7 ):
650 main.hostMACs.append( "00:00:00:00:00:" +
651 str( hex( i )[ 2: ] ).zfill( 2 ).upper() )
652 for macs in main.hostMACs:
653 main.hostId.append( macs + "/-1" )
654 host1 = main.hostId[ 0 ]
655 host2 = main.hostId[ 1 ]
656 # Use arping to discover the hosts
657 main.LincOE2.arping( host = "h1" )
658 main.LincOE2.arping( host = "h2" )
659 time.sleep( 5 )
660 hostsDict = main.ONOS3.hosts()
661 if not len( hostsDict ):
662 step1Result = main.FALSE
663 # Adding host intent
664 utilities.assert_equals(
665 expect=main.TRUE,
666 actual=step1Result,
667 onpass="Hosts discovered",
668 onfail="Failed to discover hosts")
669
670 main.step( "Adding host intents to h1 and h2" )
671 step2Result = main.TRUE
672 intentsId = []
673 intent1 = main.ONOS3.addHostIntent( hostIdOne = host1,
674 hostIdTwo = host2 )
675 intentsId.append( intent1 )
676 time.sleep( 5 )
677 intent2 = main.ONOS3.addHostIntent( hostIdOne = host2,
678 hostIdTwo = host1 )
679 intentsId.append( intent2 )
680 # Checking intents state before pinging
681 main.log.info( "Checking intents state" )
682 time.sleep( 15 )
683 intentResult = main.ONOS3.checkIntentState( intentsId = intentsId )
684 #check intent state again if intents are not in installed state
685 if not intentResult:
686 intentResult = main.ONOS3.checkIntentState( intentsId = intentsId )
687 step2Result = intentResult
688 utilities.assert_equals( expect=main.TRUE,
689 actual=step2Result,
690 onpass="All intents are in INSTALLED state ",
691 onfail="Some of the intents are not in " +
692 "INSTALLED state " )
693
694 # pinging h1 to h2 and then ping h2 to h1
695 main.step( "Pinging h1 and h2" )
696 step3Result = main.TRUE
697 pingResult = main.TRUE
698 pingResult = main.LincOE2.pingHostOptical( src="h1", target="h2" )
699 pingResult = pingResult and main.LincOE2.pingHostOptical( src="h2",
700 target="h1" )
701 step3Result = pingResult
702 utilities.assert_equals( expect=main.TRUE,
703 actual=step3Result,
704 onpass="Pinged successfully between h1 and h2",
705 onfail="Pinged failed between h1 and h2" )
706 # Removed all added host intents
707 main.step( "Removing host intents" )
708 step4Result = main.TRUE
709 removeResult = main.TRUE
710 # Check remaining intents
711 intentsJson = json.loads( main.ONOS3.intents() )
712 main.ONOS3.removeIntent( intentId=intent1, purge=True )
713 main.ONOS3.removeIntent( intentId=intent2, purge=True )
714 for intents in intentsJson:
715 main.ONOS3.removeIntent( intentId=intents.get( 'id' ),
716 app='org.onosproject.optical',
717 purge=True )
718 print json.loads( main.ONOS3.intents() )
719 if len( json.loads( main.ONOS3.intents() ) ):
720 removeResult = main.FALSE
721 step4Result = removeResult
722 utilities.assert_equals( expect=main.TRUE,
723 actual=step4Result,
724 onpass="Successfully removed host intents",
725 onfail="Failed to remove host intents" )
shahshreya4e13a062014-11-11 16:46:18 -0800726
kelvin-onlab8a832582015-01-16 17:06:11 -0800727 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800728 import re
729 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800730 main.log.report( "This testcase is testing the assignment of" +
731 " all the switches to all the controllers and" +
shahshreyab189da22015-02-25 10:18:26 -0800732 " discovering the hosts in reactive mode" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800733 main.log.report( "__________________________________" )
shahshreyaa47ebf42015-05-20 13:29:18 -0700734
kelvin-onlab8a832582015-01-16 17:06:11 -0800735 main.case( "Pingall Test" )
736 main.step( "Assigning switches to controllers" )
shahshreya9294c8d2015-01-21 15:54:16 -0800737 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
738 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
kelvin-onlab8a832582015-01-16 17:06:11 -0800739 for i in range( 1, 29 ):
740 if i == 1:
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 >= 2 and i < 5:
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 >= 5 and i < 8:
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 >= 8 and i < 18:
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 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800760 elif i >= 18 and i < 28:
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 )
shahshreya4e13a062014-11-11 16:46:18 -0800765 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800766 main.Mininet1.assignSwController(
kelvin-onlab8a832582015-01-16 17:06:11 -0800767 sw=str( i ),
shahshreya9294c8d2015-01-21 15:54:16 -0800768 ip1=ONOS1Ip,
769 port1=ONOS1Port )
770 SwitchMastership = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -0800771 for i in range( 1, 29 ):
772 if i == 1:
shahshreya9294c8d2015-01-21 15:54:16 -0800773 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800774 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800775 if re.search( "tcp:" + ONOS1Ip, response ):
776 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800777 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800778 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800779 elif i >= 2 and i < 5:
shahshreya9294c8d2015-01-21 15:54:16 -0800780 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800781 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800782 if re.search( "tcp:" + ONOS1Ip, response ):
783 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800784 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800785 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800786 elif i >= 5 and i < 8:
shahshreya9294c8d2015-01-21 15:54:16 -0800787 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800788 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800789 if re.search( "tcp:" + ONOS1Ip, response ):
790 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800791 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800792 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800793 elif i >= 8 and i < 18:
shahshreya9294c8d2015-01-21 15:54:16 -0800794 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800795 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800796 if re.search( "tcp:" + ONOS1Ip, response ):
797 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800798 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800799 SwitchMastership = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -0800800 elif i >= 18 and i < 28:
shahshreya9294c8d2015-01-21 15:54:16 -0800801 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800802 print( "Response is " + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800803 if re.search( "tcp:" + ONOS1Ip, response ):
804 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800805 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800806 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800807 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800808 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlab8a832582015-01-16 17:06:11 -0800809 print( "Response is" + str( response ) )
shahshreya9294c8d2015-01-21 15:54:16 -0800810 if re.search( "tcp:" + ONOS1Ip, response ):
811 SwitchMastership = SwitchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800812 else:
shahshreya9294c8d2015-01-21 15:54:16 -0800813 SwitchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800814
shahshreya9294c8d2015-01-21 15:54:16 -0800815 if SwitchMastership == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -0800816 main.log.report( "Controller assignmnet successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800817 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800818 main.log.report( "Controller assignmnet failed" )
819 utilities.assert_equals(
820 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800821 actual=SwitchMastership,
kelvin-onlab8a832582015-01-16 17:06:11 -0800822 onpass="MasterControllers assigned correctly" )
823 """
824 for i in range ( 1,29 ):
shahshreya9294c8d2015-01-21 15:54:16 -0800825 main.Mininet1.assignSwController( sw=str( i ),count=5,
826 ip1=ONOS1Ip,port1=ONOS1Port,
827 ip2=ONOS2Ip,port2=ONOS2Port,
828 ip3=ONOS3Ip,port3=ONOS3Port,
829 ip4=ONOS4Ip,port4=ONOS4Port,
830 ip5=ONOS5Ip,port5=ONOS5Port )
kelvin-onlab8a832582015-01-16 17:06:11 -0800831 """
832 # REACTIVE FWD test
shahshreyad524a942015-04-21 09:55:16 -0700833 main.log.info( "Activate fwd app" )
834 appInstallResult = main.ONOS2.activateApp( "org.onosproject.fwd" )
835 appCheck = main.ONOS2.appToIDCheck()
836 if appCheck != main.TRUE:
837 main.log.warn( main.ONOS2.apps() )
838 main.log.warn( main.ONOS2.appIDs() )
839 time.sleep( 10 )
shahshreya4e13a062014-11-11 16:46:18 -0800840
kelvin-onlab8a832582015-01-16 17:06:11 -0800841 main.step( "Get list of hosts from Mininet" )
shahshreya9294c8d2015-01-21 15:54:16 -0800842 hostList = main.Mininet1.getHosts()
843 main.log.info( hostList )
shahshreya4e13a062014-11-11 16:46:18 -0800844
kelvin-onlab8a832582015-01-16 17:06:11 -0800845 main.step( "Get host list in ONOS format" )
shahshreya9294c8d2015-01-21 15:54:16 -0800846 hostOnosList = main.ONOS2.getHostsId( hostList )
847 main.log.info( hostOnosList )
kelvin-onlab8a832582015-01-16 17:06:11 -0800848 # time.sleep( 5 )
849
850 main.step( "Pingall" )
shahshreya9294c8d2015-01-21 15:54:16 -0800851 pingResult = main.FALSE
shahshreya82ecd282015-02-05 16:48:03 -0800852 time1 = time.time()
853 pingResult = main.Mininet1.pingall()
854 time2 = time.time()
855 print "Time for pingall: %2f seconds" % ( time2 - time1 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800856
shahshreya9294c8d2015-01-21 15:54:16 -0800857 # Start onos cli again because u might have dropped out of
858 # onos prompt to the shell prompt
kelvin-onlab8a832582015-01-16 17:06:11 -0800859 # if there was no activity
shahshreya9294c8d2015-01-21 15:54:16 -0800860 main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800861
shahshreya9294c8d2015-01-21 15:54:16 -0800862 case4Result = SwitchMastership and pingResult
863 if pingResult == main.TRUE:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800864 main.log.report( "Pingall Test in reactive mode to" +
865 " discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800866 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800867 main.log.report( "Pingall Test in reactive mode to" +
868 " discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800869
kelvin-onlab8a832582015-01-16 17:06:11 -0800870 utilities.assert_equals(
871 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -0800872 actual=case4Result,
kelvin-onlab8a832582015-01-16 17:06:11 -0800873 onpass="Controller assignment and Pingall Test successful",
874 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800875
shahshreyab189da22015-02-25 10:18:26 -0800876 def CASE11( self ):
877 # NOTE: This testcase require reactive forwarding mode enabled
878 # NOTE: in the beginning and then uninstall it before adding
879 # NOTE: point intents. Again the app is installed so that
880 # NOTE: testcase 10 can be ran successively
881 import time
882 main.log.report(
883 "This testcase moves a host from one switch to another to add" +
884 "point intents between them and then perform ping" )
885 main.log.report( "__________________________________" )
886 main.log.info( "Moving host from one switch to another" )
887 main.case( "Moving host from a device and attach it to another device" )
888 main.step( "Moving host h9 from device s9 and attach it to s8" )
889 main.Mininet1.moveHost(host = 'h9', oldSw = 's9', newSw = 's8')
890
shahshreyad524a942015-04-21 09:55:16 -0700891 main.log.info( "Activate fwd app" )
892 appInstallResult = main.ONOS2.activateApp( "org.onosproject.fwd" )
893 appCheck = main.ONOS2.appToIDCheck()
894 if appCheck != main.TRUE:
895 main.log.warn( main.ONOS2.apps() )
896 main.log.warn( main.ONOS2.appIDs() )
897
shahshreyaa47ebf42015-05-20 13:29:18 -0700898 time.sleep(25) #Time delay to have all the flows ready
shahshreyab189da22015-02-25 10:18:26 -0800899 main.step( "Pingall" )
900 pingResult = main.FALSE
901 time1 = time.time()
shahshreyad524a942015-04-21 09:55:16 -0700902 pingResult = main.Mininet1.pingall( timeout=120,
903 shortCircuit=True,
shahshreyaa47ebf42015-05-20 13:29:18 -0700904 acceptableFailed=20 )
shahshreyab189da22015-02-25 10:18:26 -0800905 time2 = time.time()
906 print "Time for pingall: %2f seconds" % ( time2 - time1 )
907
908 hosts = main.ONOS2.hosts( jsonFormat = False )
909 main.log.info( hosts )
910
shahshreyad524a942015-04-21 09:55:16 -0700911 main.log.info( "deactivate reactive forwarding app" )
912 appUninstallResult = main.ONOS2.deactivateApp( "org.onosproject.fwd" )
913 appCheck = main.ONOS2.appToIDCheck()
914 if appCheck != main.TRUE:
915 main.log.warn( main.ONOS2.apps() )
916 main.log.warn( main.ONOS2.appIDs() )
shahshreyab189da22015-02-25 10:18:26 -0800917
918 main.step( "Add point intents between hosts on the same device")
919 ptpIntentResult = main.ONOS2.addPointIntent(
920 "of:0000000000003008/1",
shahshreya234a1682015-05-27 15:41:56 -0700921 "of:0000000000003008/3",
922 ethType='IPV4',
923 ethSrc='00:00:00:00:00:08',
924 ethDst='00:00:00:00:00:09' )
shahshreyab189da22015-02-25 10:18:26 -0800925 if ptpIntentResult == main.TRUE:
926 getIntentResult = main.ONOS2.intents()
927 main.log.info( "Point to point intent install successful" )
928 # main.log.info( getIntentResult )
929
930 ptpIntentResult = main.ONOS2.addPointIntent(
931 "of:0000000000003008/3",
shahshreya234a1682015-05-27 15:41:56 -0700932 "of:0000000000003008/1",
933 ethType='IPV4',
934 ethSrc='00:00:00:00:00:09',
935 ethDst='00:00:00:00:00:08' )
shahshreyab189da22015-02-25 10:18:26 -0800936 if ptpIntentResult == main.TRUE:
937 getIntentResult = main.ONOS2.intents()
938 main.log.info( "Point to point intent install successful" )
939 # main.log.info( getIntentResult )
940
941 main.case( "Ping hosts on the same devices" )
942 ping = main.Mininet1.pingHost( src = 'h8', target = 'h9' )
943
944 '''
945 main.case( "Installing reactive forwarding app" )
946 # Install onos-app-fwd app to enable reactive forwarding
947 appUninstallResult = main.ONOS2.featureInstall( "onos-app-fwd" )
948 main.log.info( "onos-app-fwd installed" )
949 '''
950
951 if ping == main.FALSE:
952 main.log.report(
953 "Point intents for hosts on same devices haven't" +
954 " been installed correctly. Cleaning up" )
955 if ping == main.TRUE:
956 main.log.report(
957 "Point intents for hosts on same devices" +
958 "installed correctly. Cleaning up" )
959
shahshreyaa47ebf42015-05-20 13:29:18 -0700960 case11Result = ping
shahshreyab189da22015-02-25 10:18:26 -0800961 utilities.assert_equals(
shahshreya74cca802015-02-26 12:24:01 -0800962 expect = main.TRUE,
963 actual = case11Result,
964 onpass = "Point intents for hosts on same devices" +
shahshreyab189da22015-02-25 10:18:26 -0800965 "Ping Test successful",
shahshreya74cca802015-02-26 12:24:01 -0800966 onfail = "Point intents for hosts on same devices" +
shahshreyab189da22015-02-25 10:18:26 -0800967 "Ping Test NOT successful" )
shahshreya74cca802015-02-26 12:24:01 -0800968
shahshreya74cca802015-02-26 12:24:01 -0800969 def CASE12( self ):
970 """
shahshreyaed683ed2015-03-16 15:04:40 -0700971 Verify the default flows on each switch in proactive mode
shahshreya74cca802015-02-26 12:24:01 -0800972 """
shahshreyaed683ed2015-03-16 15:04:40 -0700973 main.log.report( "This testcase is verifying num of default" +
974 " flows on each switch" )
975 main.log.report( "__________________________________" )
976 main.case( "Verify num of default flows on each switch" )
977 main.step( "Obtaining the device id's and flowrule count on them" )
978
shahshreya74cca802015-02-26 12:24:01 -0800979 case12Result = main.TRUE
980 idList = main.ONOS2.getAllDevicesId()
981 for id in idList:
shahshreyaed683ed2015-03-16 15:04:40 -0700982 count = main.ONOS2.FlowAddedCount( id )
983 main.log.info("count = " +count)
984 if int(count) != 3:
shahshreya74cca802015-02-26 12:24:01 -0800985 case12Result = main.FALSE
shahshreyaed683ed2015-03-16 15:04:40 -0700986 break
shahshreya74cca802015-02-26 12:24:01 -0800987 utilities.assert_equals(
988 expect=main.TRUE,
989 actual=case12Result,
990 onpass = "Expected default num of flows exist",
991 onfail = "Expected default num of flows do not exist")
shahshreyab189da22015-02-25 10:18:26 -0800992
kelvin-onlab8a832582015-01-16 17:06:11 -0800993 def CASE6( self ):
shahshreyab189da22015-02-25 10:18:26 -0800994 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800995 main.log.report( "This testcase is testing the addition of" +
996 " host intents and then does pingall" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800997 main.log.report( "__________________________________" )
998 main.case( "Obtaining host id's" )
999 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001000 hosts = main.ONOS2.hosts()
shahshreya9294c8d2015-01-21 15:54:16 -08001001 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -08001002
kelvin-onlab8a832582015-01-16 17:06:11 -08001003 main.step( "Get all devices id" )
shahshreya9294c8d2015-01-21 15:54:16 -08001004 devicesIdList = main.ONOS2.getAllDevicesId()
1005 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -08001006
shahshreya9294c8d2015-01-21 15:54:16 -08001007 # ONOS displays the hosts in hex format unlike mininet which does
1008 # in decimal format
kelvin-onlab8a832582015-01-16 17:06:11 -08001009 # So take care while adding intents
1010 """
shahshreya9294c8d2015-01-21 15:54:16 -08001011 main.step( "Add host-to-host intents for mininet hosts h8 and h18 or
1012 ONOS hosts h8 and h12" )
1013 hthIntentResult = main.ONOS2.addHostIntent(
1014 "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
1015 hthIntentResult = main.ONOS2.addHostIntent(
1016 "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
1017 hthIntentResult = main.ONOS2.addHostIntent(
1018 "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
1019 hthIntentResult = main.ONOS2.addHostIntent(
1020 "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
1021 hthIntentResult = main.ONOS2.addHostIntent(
1022 "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
1023 hthIntentResult = main.ONOS2.addHostIntent(
1024 "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
1025 hthIntentResult = main.ONOS2.addHostIntent(
1026 "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
1027 hthIntentResult = main.ONOS2.addHostIntent(
1028 "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
1029 hthIntentResult = main.ONOS2.addHostIntent(
1030 "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
1031 hthIntentResult = main.ONOS2.addHostIntent(
1032 "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
1033 print "______________________________________________________"
kelvin-onlab8a832582015-01-16 17:06:11 -08001034 """
shahshreya234a1682015-05-27 15:41:56 -07001035 intentsId = []
kelvin-onlab8a832582015-01-16 17:06:11 -08001036 for i in range( 8, 18 ):
1037 main.log.info(
shahshreya9294c8d2015-01-21 15:54:16 -08001038 "Adding host intent between h" + str( i ) +
1039 " and h" + str( i + 10 ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001040 host1 = "00:00:00:00:00:" + \
1041 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1042 host2 = "00:00:00:00:00:" + \
1043 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
1044 # NOTE: get host can return None
shahshreya7630b1c2015-04-03 15:37:14 -07001045 if host1:
1046 host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
1047 if host2:
1048 host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
1049 if host1Id and host2Id:
shahshreya234a1682015-05-27 15:41:56 -07001050 intentsId.append( main.ONOS2.addHostIntent( host1Id, host2Id ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001051
shahshreya234a1682015-05-27 15:41:56 -07001052 checkIntentResult = main.ONOS2.checkIntentState( intentsId )
kelvin-onlab8a832582015-01-16 17:06:11 -08001053 time.sleep( 10 )
shahshreya9294c8d2015-01-21 15:54:16 -08001054 hIntents = main.ONOS2.intents( jsonFormat=False )
1055 main.log.info( "intents:" + hIntents )
shahshreyab189da22015-02-25 10:18:26 -08001056 flows = main.ONOS2.flows()
1057 main.log.info( "flows:" + flows )
shahshreya4e13a062014-11-11 16:46:18 -08001058
1059 count = 1
1060 i = 8
shahshreya9294c8d2015-01-21 15:54:16 -08001061 PingResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001062 # while i<10:
1063 while i < 18:
1064 main.log.info(
1065 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1066 ping = main.Mininet1.pingHost(
1067 src="h" + str( i ), target="h" + str( i + 10 ) )
1068 if ping == main.FALSE and count < 5:
1069 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001070 # i = 8
1071 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001072 main.log.report( "Ping between h" +
1073 str( i ) +
1074 " and h" +
1075 str( i +
1076 10 ) +
1077 " failed. Making attempt number " +
1078 str( count ) +
1079 " in 2 seconds" )
1080 time.sleep( 2 )
1081 elif ping == main.FALSE:
1082 main.log.report( "All ping attempts between h" +
1083 str( i ) +
1084 " and h" +
1085 str( i +
1086 10 ) +
1087 "have failed" )
1088 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -08001089 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001090 elif ping == main.TRUE:
1091 main.log.info( "Ping test between h" +
1092 str( i ) +
1093 " and h" +
1094 str( i +
1095 10 ) +
1096 "passed!" )
1097 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001098 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001099 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001100 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -08001101 PingResult = main.ERROR
1102 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001103 main.log.report(
shahshreya9294c8d2015-01-21 15:54:16 -08001104 "Ping all test after Host intent addition failed.Cleaning up" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001105 # main.cleanup()
1106 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -08001107 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001108 main.log.report(
1109 "Ping all test after Host intent addition successful" )
1110
shahshreya234a1682015-05-27 15:41:56 -07001111 checkIntentResult = main.ONOS2.checkIntentState( intentsId )
1112
shahshreya9294c8d2015-01-21 15:54:16 -08001113 case6Result = PingResult
kelvin-onlab8a832582015-01-16 17:06:11 -08001114 utilities.assert_equals(
1115 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001116 actual=case6Result,
kelvin-onlab8a832582015-01-16 17:06:11 -08001117 onpass="Pingall Test after Host intents addition successful",
1118 onfail="Pingall Test after Host intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001119
kelvin-onlab8a832582015-01-16 17:06:11 -08001120 def CASE5( self, main ):
shahshreyad524a942015-04-21 09:55:16 -07001121 """
1122 Check ONOS topology matches with mininet
1123 """
shahshreya4e13a062014-11-11 16:46:18 -08001124 import json
kelvin-onlab8a832582015-01-16 17:06:11 -08001125 # assumes that sts is already in you PYTHONPATH
1126 from sts.topology.teston_topology import TestONTopology
shahshreya9294c8d2015-01-21 15:54:16 -08001127 # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001128 main.log.report( "This testcase is testing if all ONOS nodes" +
1129 " are in topology sync with mininet" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001130 main.log.report( "__________________________________" )
1131 main.case( "Comparing Mininet topology with the topology of ONOS" )
1132 main.step( "Start continuous pings" )
1133 main.Mininet2.pingLong(
1134 src=main.params[ 'PING' ][ 'source1' ],
1135 target=main.params[ 'PING' ][ 'target1' ],
1136 pingTime=500 )
1137 main.Mininet2.pingLong(
1138 src=main.params[ 'PING' ][ 'source2' ],
1139 target=main.params[ 'PING' ][ 'target2' ],
1140 pingTime=500 )
1141 main.Mininet2.pingLong(
1142 src=main.params[ 'PING' ][ 'source3' ],
1143 target=main.params[ 'PING' ][ 'target3' ],
1144 pingTime=500 )
1145 main.Mininet2.pingLong(
1146 src=main.params[ 'PING' ][ 'source4' ],
1147 target=main.params[ 'PING' ][ 'target4' ],
1148 pingTime=500 )
1149 main.Mininet2.pingLong(
1150 src=main.params[ 'PING' ][ 'source5' ],
1151 target=main.params[ 'PING' ][ 'target5' ],
1152 pingTime=500 )
1153 main.Mininet2.pingLong(
1154 src=main.params[ 'PING' ][ 'source6' ],
1155 target=main.params[ 'PING' ][ 'target6' ],
1156 pingTime=500 )
1157 main.Mininet2.pingLong(
1158 src=main.params[ 'PING' ][ 'source7' ],
1159 target=main.params[ 'PING' ][ 'target7' ],
1160 pingTime=500 )
1161 main.Mininet2.pingLong(
1162 src=main.params[ 'PING' ][ 'source8' ],
1163 target=main.params[ 'PING' ][ 'target8' ],
1164 pingTime=500 )
1165 main.Mininet2.pingLong(
1166 src=main.params[ 'PING' ][ 'source9' ],
1167 target=main.params[ 'PING' ][ 'target9' ],
1168 pingTime=500 )
1169 main.Mininet2.pingLong(
1170 src=main.params[ 'PING' ][ 'source10' ],
1171 target=main.params[ 'PING' ][ 'target10' ],
1172 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -08001173
kelvin-onlab8a832582015-01-16 17:06:11 -08001174 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -08001175 global ctrls
1176 ctrls = []
1177 count = 1
1178 while True:
1179 temp = ()
kelvin-onlab8a832582015-01-16 17:06:11 -08001180 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
1181 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
1182 temp = temp + ( "ONOS" + str( count ), )
1183 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
1184 temp = temp + \
1185 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
1186 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -08001187 count = count + 1
1188 else:
1189 break
1190 global MNTopo
kelvin-onlab8a832582015-01-16 17:06:11 -08001191 Topo = TestONTopology(
1192 main.Mininet1,
1193 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -08001194 MNTopo = Topo
1195
shahshreya9294c8d2015-01-21 15:54:16 -08001196 TopologyCheck = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001197 main.step( "Compare ONOS Topology to MN Topology" )
shahshreya9294c8d2015-01-21 15:54:16 -08001198 devicesJson = main.ONOS2.devices()
1199 linksJson = main.ONOS2.links()
shahshreyabf739d82015-06-10 11:22:31 -07001200 portsJson = main.ONOS2.ports()
kelvin-onlab8a832582015-01-16 17:06:11 -08001201
shahshreya9294c8d2015-01-21 15:54:16 -08001202 result1 = main.Mininet1.compareSwitches(
kelvin-onlab8a832582015-01-16 17:06:11 -08001203 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001204 json.loads( devicesJson ) )
1205 result2 = main.Mininet1.compareLinks(
kelvin-onlab8a832582015-01-16 17:06:11 -08001206 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001207 json.loads( linksJson ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001208
shahshreya842d8b92015-06-10 14:13:33 -07001209 result3 = main.Mininet1.comparePorts( MNTopo, json.loads( portsJson ) )
shahshreya9294c8d2015-01-21 15:54:16 -08001210 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001211 result = result1 and result2
kelvin-onlab8a832582015-01-16 17:06:11 -08001212
shahshreya4e13a062014-11-11 16:46:18 -08001213 print "***********************"
1214 if result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001215 main.log.report( "ONOS" + " Topology matches MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001216 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001217 main.log.report( "ONOS" + " Topology does not match MN Topology" )
shahshreya4e13a062014-11-11 16:46:18 -08001218
kelvin-onlab8a832582015-01-16 17:06:11 -08001219 utilities.assert_equals(
1220 expect=main.TRUE,
1221 actual=result,
1222 onpass="ONOS" +
1223 " Topology matches MN Topology",
1224 onfail="ONOS" +
1225 " Topology does not match MN Topology" )
1226
shahshreya9294c8d2015-01-21 15:54:16 -08001227 TopologyCheck = TopologyCheck and result
kelvin-onlab8a832582015-01-16 17:06:11 -08001228 utilities.assert_equals(
1229 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001230 actual=TopologyCheck,
kelvin-onlab8a832582015-01-16 17:06:11 -08001231 onpass="Topology checks passed",
1232 onfail="Topology checks failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001233
kelvin-onlab8a832582015-01-16 17:06:11 -08001234 def CASE7( self, main ):
shahshreyad524a942015-04-21 09:55:16 -07001235 """
1236 Link discovery test case. Checks if ONOS can discover a link
1237 down or up properly.
1238 """
1239
shahshreya9294c8d2015-01-21 15:54:16 -08001240 from sts.topology.teston_topology import TestONTopology
shahshreya4e13a062014-11-11 16:46:18 -08001241
shahshreya9294c8d2015-01-21 15:54:16 -08001242 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -08001243
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001244 main.log.report( "This testscase is killing a link to ensure that" +
1245 " link discovery is consistent" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001246 main.log.report( "__________________________________" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001247 main.log.report( "Killing a link to ensure that link discovery" +
1248 " is consistent" )
1249 main.case( "Killing a link to Ensure that Link Discovery" +
1250 "is Working Properly" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001251 """
1252 main.step( "Start continuous pings" )
1253
1254 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001255 target=main.params[ 'PING' ][ 'target1' ],
1256 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001257 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001258 target=main.params[ 'PING' ][ 'target2' ],
1259 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001260 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001261 target=main.params[ 'PING' ][ 'target3' ],
1262 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001263 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001264 target=main.params[ 'PING' ][ 'target4' ],
1265 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001266 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001267 target=main.params[ 'PING' ][ 'target5' ],
1268 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001269 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001270 target=main.params[ 'PING' ][ 'target6' ],
1271 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001272 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001273 target=main.params[ 'PING' ][ 'target7' ],
1274 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001275 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001276 target=main.params[ 'PING' ][ 'target8' ],
1277 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001278 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001279 target=main.params[ 'PING' ][ 'target9' ],
1280 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001281 main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
shahshreya9294c8d2015-01-21 15:54:16 -08001282 target=main.params[ 'PING' ][ 'target10' ],
1283 pingTime=500 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001284 """
1285 main.step( "Determine the current number of switches and links" )
shahshreya9294c8d2015-01-21 15:54:16 -08001286 topologyOutput = main.ONOS2.topology()
1287 topologyResult = main.ONOS1.getTopology( topologyOutput )
shahshreyaa47ebf42015-05-20 13:29:18 -07001288 activeSwitches = topologyResult[ 'devices' ]
1289 links = topologyResult[ 'links' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001290 print "activeSwitches = ", type( activeSwitches )
1291 print "links = ", type( links )
1292 main.log.info(
1293 "Currently there are %s switches and %s links" %
1294 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -08001295
kelvin-onlab8a832582015-01-16 17:06:11 -08001296 main.step( "Kill Link between s3 and s28" )
1297 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
shahshreya9294c8d2015-01-21 15:54:16 -08001298 time.sleep( linkSleep )
1299 topologyOutput = main.ONOS2.topology()
1300 LinkDown = main.ONOS1.checkStatus(
1301 topologyOutput, activeSwitches, str(
kelvin-onlab8a832582015-01-16 17:06:11 -08001302 int( links ) - 2 ) )
shahshreya9294c8d2015-01-21 15:54:16 -08001303 if LinkDown == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001304 main.log.report( "Link Down discovered properly" )
1305 utilities.assert_equals(
1306 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001307 actual=LinkDown,
kelvin-onlab8a832582015-01-16 17:06:11 -08001308 onpass="Link Down discovered properly",
1309 onfail="Link down was not discovered in " +
shahshreya9294c8d2015-01-21 15:54:16 -08001310 str( linkSleep ) +
kelvin-onlab8a832582015-01-16 17:06:11 -08001311 " seconds" )
1312
1313 # Check ping result here..add code for it
1314
1315 main.step( "Bring link between s3 and s28 back up" )
shahshreya9294c8d2015-01-21 15:54:16 -08001316 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
1317 time.sleep( linkSleep )
1318 topologyOutput = main.ONOS2.topology()
1319 LinkUp = main.ONOS1.checkStatus(
1320 topologyOutput,
kelvin-onlab8a832582015-01-16 17:06:11 -08001321 activeSwitches,
1322 str( links ) )
shahshreya9294c8d2015-01-21 15:54:16 -08001323 if LinkUp == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001324 main.log.report( "Link up discovered properly" )
1325 utilities.assert_equals(
1326 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001327 actual=LinkUp,
kelvin-onlab8a832582015-01-16 17:06:11 -08001328 onpass="Link up discovered properly",
1329 onfail="Link up was not discovered in " +
shahshreya9294c8d2015-01-21 15:54:16 -08001330 str( linkSleep ) +
kelvin-onlab8a832582015-01-16 17:06:11 -08001331 " seconds" )
1332
1333 # NOTE Check ping result here..add code for it
1334
1335 main.step( "Compare ONOS Topology to MN Topology" )
1336 Topo = TestONTopology(
1337 main.Mininet1,
1338 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -08001339 MNTopo = Topo
shahshreya9294c8d2015-01-21 15:54:16 -08001340 TopologyCheck = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001341
shahshreya9294c8d2015-01-21 15:54:16 -08001342 devicesJson = main.ONOS2.devices()
1343 linksJson = main.ONOS2.links()
1344 portsJson = main.ONOS2.ports()
kelvin-onlab8a832582015-01-16 17:06:11 -08001345
shahshreya9294c8d2015-01-21 15:54:16 -08001346 result1 = main.Mininet1.compareSwitches(
kelvin-onlab8a832582015-01-16 17:06:11 -08001347 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001348 json.loads( devicesJson ) )
1349 result2 = main.Mininet1.compareLinks(
kelvin-onlab8a832582015-01-16 17:06:11 -08001350 MNTopo,
shahshreya9294c8d2015-01-21 15:54:16 -08001351 json.loads( linksJson ) )
shahshreyabf739d82015-06-10 11:22:31 -07001352 result3 = main.Mininet1.comparePorts( MNTopo, json.loads( portsJson ) )
kelvin-onlab8a832582015-01-16 17:06:11 -08001353
shahshreya9294c8d2015-01-21 15:54:16 -08001354 # result = result1 and result2 and result3
shahshreya4e13a062014-11-11 16:46:18 -08001355 result = result1 and result2
1356 print "***********************"
kelvin-onlab8a832582015-01-16 17:06:11 -08001357
shahshreya4e13a062014-11-11 16:46:18 -08001358 if result == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001359 main.log.report( "ONOS" + " Topology matches MN Topology" )
1360 utilities.assert_equals(
1361 expect=main.TRUE,
1362 actual=result,
1363 onpass="ONOS" +
1364 " Topology matches MN Topology",
1365 onfail="ONOS" +
1366 " Topology does not match MN Topology" )
1367
shahshreya9294c8d2015-01-21 15:54:16 -08001368 TopologyCheck = TopologyCheck and result
kelvin-onlab8a832582015-01-16 17:06:11 -08001369 utilities.assert_equals(
1370 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001371 actual=TopologyCheck,
kelvin-onlab8a832582015-01-16 17:06:11 -08001372 onpass="Topology checks passed",
1373 onfail="Topology checks failed" )
1374
shahshreya9294c8d2015-01-21 15:54:16 -08001375 result = LinkDown and LinkUp and TopologyCheck
kelvin-onlab8a832582015-01-16 17:06:11 -08001376 utilities.assert_equals( expect=main.TRUE, actual=result,
1377 onpass="Link failure is discovered correctly",
1378 onfail="Link Discovery failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001379
kelvin-onlab8a832582015-01-16 17:06:11 -08001380 def CASE8( self ):
1381 """
shahshreya82ecd282015-02-05 16:48:03 -08001382 Intent removal
kelvin-onlab8a832582015-01-16 17:06:11 -08001383 """
shahshreya82ecd282015-02-05 16:48:03 -08001384 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001385 main.log.report( "This testcase removes any previously added intents" +
shahshreya82ecd282015-02-05 16:48:03 -08001386 " before adding any new set of intents" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001387 main.log.report( "__________________________________" )
shahshreya82ecd282015-02-05 16:48:03 -08001388 main.log.info( "intent removal" )
1389 main.case( "Removing installed intents" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001390 main.step( "Obtain the intent id's" )
shahshreya234a1682015-05-27 15:41:56 -07001391 currentIntents = main.ONOS2.intents( jsonFormat=False )
1392 main.log.info( "intent_result = " + currentIntents )
1393 intentLinewise = currentIntents.split( "\n" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001394
shahshreyab189da22015-02-25 10:18:26 -08001395 intentList = [line for line in intentLinewise \
1396 if line.startswith( "id=")]
1397 intentids = [line.split( "," )[ 0 ].split( "=" )[ 1 ] for line in \
1398 intentList]
shahshreya4e13a062014-11-11 16:46:18 -08001399 for id in intentids:
1400 print "id = ", id
kelvin-onlab8a832582015-01-16 17:06:11 -08001401
1402 main.step(
1403 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -08001404 for id in intentids:
shahshreyaa47ebf42015-05-20 13:29:18 -07001405 main.ONOS2.removeIntent( intentId=id ,purge=True)
kelvin-onlab8a832582015-01-16 17:06:11 -08001406
shahshreya234a1682015-05-27 15:41:56 -07001407 remainingIntents = main.ONOS2.intents( jsonFormat=False )
1408 main.log.info( "intent_result = " + remainingIntents )
1409 if remainingIntents:
1410 main.log.info( "There are still remaining intents " )
1411 intentResult = main.FALSE
1412 else:
1413 intentResult = main.TRUE
1414
1415 intentList = [line for line in remainingIntents.split( "\n" ) \
shahshreyab189da22015-02-25 10:18:26 -08001416 if line.startswith( "id=")]
1417 intentState = [line.split( "," )[ 1 ].split( "=" )[ 1 ] for line in \
1418 intentList]
1419 for state in intentState:
1420 print state
1421
shahshreya234a1682015-05-27 15:41:56 -07001422 case8Result = main.TRUE
shahshreyab189da22015-02-25 10:18:26 -08001423 for state in intentState:
1424 if state != 'WITHDRAWN':
1425 case8Result = main.FALSE
1426 break
kelvin-onlab8a832582015-01-16 17:06:11 -08001427
shahshreya9294c8d2015-01-21 15:54:16 -08001428 PingResult = main.TRUE
shahshreya234a1682015-05-27 15:41:56 -07001429 """
shahshreya9294c8d2015-01-21 15:54:16 -08001430 if case8Result == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001431 i = 8
kelvin-onlab8a832582015-01-16 17:06:11 -08001432 while i < 18:
1433 main.log.info(
1434 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1435 ping = main.Mininet1.pingHost(
1436 src="h" + str( i ), target="h" + str( i + 10 ) )
1437 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -08001438 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -08001439 PingResult = PingResult and main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001440 elif ping == main.FALSE:
1441 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001442 PingResult = PingResult and main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -08001443 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001444 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -08001445 PingResult = main.ERROR
shahshreya234a1682015-05-27 15:41:56 -07001446
kelvin-onlab8a832582015-01-16 17:06:11 -08001447 # Note: If the ping result failed, that means the intents have been
1448 # withdrawn correctly.
shahshreya9294c8d2015-01-21 15:54:16 -08001449 if PingResult == main.TRUE:
shahshreya82ecd282015-02-05 16:48:03 -08001450 main.log.report( "Installed intents have not been withdrawn correctly" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001451 # main.cleanup()
1452 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -08001453 if PingResult == main.FALSE:
shahshreya82ecd282015-02-05 16:48:03 -08001454 main.log.report( "Installed intents have been withdrawn correctly" )
shahshreya234a1682015-05-27 15:41:56 -07001455 """
shahshreya4e13a062014-11-11 16:46:18 -08001456
shahshreya234a1682015-05-27 15:41:56 -07001457 if case8Result:
kelvin-onlab8a832582015-01-16 17:06:11 -08001458 main.log.report( "Intent removal successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001459 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001460 main.log.report( "Intent removal failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001461
shahshreya234a1682015-05-27 15:41:56 -07001462 utilities.assert_equals( expect=main.TRUE, actual=case8Result,
shahshreya9294c8d2015-01-21 15:54:16 -08001463 onpass="Intent removal test passed",
1464 onfail="Intent removal test failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001465
kelvin-onlab8a832582015-01-16 17:06:11 -08001466 def CASE9( self ):
shahshreyad524a942015-04-21 09:55:16 -07001467 """
1468 Testing Point intents
1469 """
kelvin-onlab8a832582015-01-16 17:06:11 -08001470 main.log.report(
shahshreyad524a942015-04-21 09:55:16 -07001471 "This test case adds point intents and then does pingall" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001472 main.log.report( "__________________________________" )
1473 main.log.info( "Adding point intents" )
1474 main.case(
shahshreya82ecd282015-02-05 16:48:03 -08001475 "Adding bidirectional point for mn hosts" +
1476 "( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22, " +
1477 "h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001478 macsDict = {}
1479 for i in range( 1,29 ):
1480 macsDict[ 'h' + str( i ) ]= main.Mininet1.getMacAddress( host='h'+ str( i ) )
1481 print macsDict
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001482 main.step( "Add point intents for mn hosts h8 and h18 or" +
1483 "ONOS hosts h8 and h12" )
1484 # main.step(var1)
shahshreya9294c8d2015-01-21 15:54:16 -08001485 ptpIntentResult = main.ONOS2.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -07001486 ingressDevice="of:0000000000003008/1",
1487 egressDevice="of:0000000000006018/1",
1488 ethType='IPV4',
1489 ethSrc=macsDict.get( 'h8' ))
shahshreya9294c8d2015-01-21 15:54:16 -08001490 if ptpIntentResult == main.TRUE:
1491 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001492 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001493 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001494
shahshreya9294c8d2015-01-21 15:54:16 -08001495 ptpIntentResult = main.ONOS2.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -07001496 ingressDevice="of:0000000000006018/1",
1497 egressDevice="of:0000000000003008/1",
1498 ethType='IPV4',
1499 ethSrc=macsDict.get( 'h18' ))
shahshreya9294c8d2015-01-21 15:54:16 -08001500 if ptpIntentResult == main.TRUE:
1501 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001502 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001503 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001504
shahshreya9294c8d2015-01-21 15:54:16 -08001505 var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
1506 main.step(var2)
1507 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001508 "of:0000000000003009/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001509 "of:0000000000006019/1",
1510 ethType='IPV4',
1511 ethSrc=macsDict.get( 'h9' ))
shahshreya9294c8d2015-01-21 15:54:16 -08001512 if ptpIntentResult == main.TRUE:
1513 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001514 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001515 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001516
shahshreya9294c8d2015-01-21 15:54:16 -08001517 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001518 "of:0000000000006019/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001519 "of:0000000000003009/1",
1520 ethType='IPV4',
1521 ethSrc=macsDict.get( 'h19' ))
shahshreya9294c8d2015-01-21 15:54:16 -08001522 if ptpIntentResult == main.TRUE:
1523 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001524 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001525 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001526
shahshreya9294c8d2015-01-21 15:54:16 -08001527 var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
1528 main.step(var3)
1529 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001530 "of:0000000000003010/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001531 "of:0000000000006020/1",
1532 ethType='IPV4',
1533 ethSrc=macsDict.get( 'h10' ))
1534
shahshreya9294c8d2015-01-21 15:54:16 -08001535 if ptpIntentResult == main.TRUE:
1536 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001537 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001538 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001539
shahshreya9294c8d2015-01-21 15:54:16 -08001540 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001541 "of:0000000000006020/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001542 "of:0000000000003010/1",
1543 ethType='IPV4',
1544 ethSrc=macsDict.get( 'h20' ))
1545
shahshreya9294c8d2015-01-21 15:54:16 -08001546 if ptpIntentResult == main.TRUE:
1547 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001548 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001549 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001550
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001551 var4 = "Add point intents for mininet hosts h11 and h21 or" +\
1552 " ONOS hosts hB and h15"
shahshreya9294c8d2015-01-21 15:54:16 -08001553 main.case(var4)
1554 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001555 "of:0000000000003011/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001556 "of:0000000000006021/1",
1557 ethType='IPV4',
1558 ethSrc=macsDict.get( 'h11' ))
1559
shahshreya9294c8d2015-01-21 15:54:16 -08001560 if ptpIntentResult == main.TRUE:
1561 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001562 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001563 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001564
shahshreya9294c8d2015-01-21 15:54:16 -08001565 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001566 "of:0000000000006021/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001567 "of:0000000000003011/1",
1568 ethType='IPV4',
1569 ethSrc=macsDict.get( 'h21' ))
1570
shahshreya9294c8d2015-01-21 15:54:16 -08001571 if ptpIntentResult == main.TRUE:
1572 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001573 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001574 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001575
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001576 var5 = "Add point intents for mininet hosts h12 and h22 " +\
1577 "ONOS hosts hC and h16"
shahshreya9294c8d2015-01-21 15:54:16 -08001578 main.case(var5)
1579 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001580 "of:0000000000003012/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001581 "of:0000000000006022/1",
1582 ethType='IPV4',
1583 ethSrc=macsDict.get( 'h12' ))
1584
shahshreya9294c8d2015-01-21 15:54:16 -08001585 if ptpIntentResult == main.TRUE:
1586 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001587 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001588 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001589
shahshreya9294c8d2015-01-21 15:54:16 -08001590 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001591 "of:0000000000006022/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001592 "of:0000000000003012/1",
1593 ethType='IPV4',
1594 ethSrc=macsDict.get( 'h22' ))
1595
shahshreya9294c8d2015-01-21 15:54:16 -08001596 if ptpIntentResult == main.TRUE:
1597 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001598 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001599 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001600
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001601 var6 = "Add point intents for mininet hosts h13 and h23 or" +\
1602 " ONOS hosts hD and h17"
shahshreya9294c8d2015-01-21 15:54:16 -08001603 main.case(var6)
1604 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001605 "of:0000000000003013/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001606 "of:0000000000006023/1",
1607 ethType='IPV4',
1608 ethSrc=macsDict.get( 'h13' ))
1609
shahshreya9294c8d2015-01-21 15:54:16 -08001610 if ptpIntentResult == main.TRUE:
1611 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001612 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001613 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001614
shahshreya9294c8d2015-01-21 15:54:16 -08001615 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001616 "of:0000000000006023/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001617 "of:0000000000003013/1",
1618 ethType='IPV4',
1619 ethSrc=macsDict.get( 'h23' ))
1620
shahshreya9294c8d2015-01-21 15:54:16 -08001621 if ptpIntentResult == main.TRUE:
1622 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001623 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001624 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001625
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001626 var7 = "Add point intents for mininet hosts h14 and h24 or" +\
1627 " ONOS hosts hE and h18"
shahshreya9294c8d2015-01-21 15:54:16 -08001628 main.case(var7)
1629 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001630 "of:0000000000003014/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001631 "of:0000000000006024/1",
1632 ethType='IPV4',
1633 ethSrc=macsDict.get( 'h14' ))
1634
shahshreya9294c8d2015-01-21 15:54:16 -08001635 if ptpIntentResult == main.TRUE:
1636 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001637 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001638 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001639
shahshreya9294c8d2015-01-21 15:54:16 -08001640 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001641 "of:0000000000006024/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001642 "of:0000000000003014/1",
1643 ethType='IPV4',
1644 ethSrc=macsDict.get( 'h24' ))
1645
shahshreya9294c8d2015-01-21 15:54:16 -08001646 if ptpIntentResult == main.TRUE:
1647 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001648 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001649 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001650
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001651 var8 = "Add point intents for mininet hosts h15 and h25 or" +\
1652 " ONOS hosts hF and h19"
shahshreya9294c8d2015-01-21 15:54:16 -08001653 main.case(var8)
1654 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001655 "of:0000000000003015/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001656 "of:0000000000006025/1",
1657 ethType='IPV4',
1658 ethSrc=macsDict.get( 'h15' ))
1659
shahshreya9294c8d2015-01-21 15:54:16 -08001660 if ptpIntentResult == main.TRUE:
1661 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001662 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001663 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001664
shahshreya9294c8d2015-01-21 15:54:16 -08001665 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001666 "of:0000000000006025/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001667 "of:0000000000003015/1",
1668 ethType='IPV4',
1669 ethSrc=macsDict.get( 'h25' ))
1670
shahshreya9294c8d2015-01-21 15:54:16 -08001671 if ptpIntentResult == main.TRUE:
1672 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001673 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001674 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001675
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001676 var9 = "Add intents for mininet hosts h16 and h26 or" +\
1677 " ONOS hosts h10 and h1A"
shahshreya9294c8d2015-01-21 15:54:16 -08001678 main.case(var9)
1679 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001680 "of:0000000000003016/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001681 "of:0000000000006026/1",
1682 ethType='IPV4',
1683 ethSrc=macsDict.get( 'h16' ))
1684
shahshreya9294c8d2015-01-21 15:54:16 -08001685 if ptpIntentResult == main.TRUE:
1686 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001687 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001688 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001689
shahshreya9294c8d2015-01-21 15:54:16 -08001690 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001691 "of:0000000000006026/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001692 "of:0000000000003016/1",
1693 ethType='IPV4',
1694 ethSrc=macsDict.get( 'h26' ))
1695
shahshreya9294c8d2015-01-21 15:54:16 -08001696 if ptpIntentResult == main.TRUE:
1697 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001698 main.log.info( "Point to point intent install successful" )
shahshreya9294c8d2015-01-21 15:54:16 -08001699 # main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001700
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001701 var10 = "Add point intents for mininet hosts h17 and h27 or" +\
1702 " ONOS hosts h11 and h1B"
shahshreya9294c8d2015-01-21 15:54:16 -08001703 main.case(var10)
1704 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001705 "of:0000000000003017/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001706 "of:0000000000006027/1",
1707 ethType='IPV4',
1708 ethSrc=macsDict.get( 'h17' ))
1709
shahshreya9294c8d2015-01-21 15:54:16 -08001710 if ptpIntentResult == main.TRUE:
1711 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001712 main.log.info( "Point to point intent install successful" )
shahshreyab189da22015-02-25 10:18:26 -08001713 #main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001714
shahshreya9294c8d2015-01-21 15:54:16 -08001715 ptpIntentResult = main.ONOS2.addPointIntent(
kelvin-onlab8a832582015-01-16 17:06:11 -08001716 "of:0000000000006027/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001717 "of:0000000000003017/1",
1718 ethType='IPV4',
1719 ethSrc=macsDict.get( 'h27' ))
1720
shahshreya9294c8d2015-01-21 15:54:16 -08001721 if ptpIntentResult == main.TRUE:
1722 getIntentResult = main.ONOS2.intents()
kelvin-onlab8a832582015-01-16 17:06:11 -08001723 main.log.info( "Point to point intent install successful" )
shahshreyab189da22015-02-25 10:18:26 -08001724 #main.log.info( getIntentResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001725
1726 print(
shahshreya9294c8d2015-01-21 15:54:16 -08001727 "___________________________________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001728
1729 flowHandle = main.ONOS2.flows()
shahshreya82ecd282015-02-05 16:48:03 -08001730 #main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001731
1732 count = 1
1733 i = 8
shahshreya9294c8d2015-01-21 15:54:16 -08001734 PingResult = main.TRUE
kelvin-onlab8a832582015-01-16 17:06:11 -08001735 while i < 18:
1736 main.log.info(
1737 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1738 ping = main.Mininet1.pingHost(
1739 src="h" + str( i ), target="h" + str( i + 10 ) )
1740 if ping == main.FALSE and count < 5:
1741 count += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001742 # i = 8
1743 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001744 main.log.report( "Ping between h" +
1745 str( i ) +
1746 " and h" +
1747 str( i +
1748 10 ) +
1749 " failed. Making attempt number " +
1750 str( count ) +
1751 " in 2 seconds" )
1752 time.sleep( 2 )
1753 elif ping == main.FALSE:
1754 main.log.report( "All ping attempts between h" +
1755 str( i ) +
1756 " and h" +
1757 str( i +
1758 10 ) +
1759 "have failed" )
1760 i = 19
shahshreya9294c8d2015-01-21 15:54:16 -08001761 PingResult = main.FALSE
kelvin-onlab8a832582015-01-16 17:06:11 -08001762 elif ping == main.TRUE:
1763 main.log.info( "Ping test between h" +
1764 str( i ) +
1765 " and h" +
1766 str( i +
1767 10 ) +
1768 "passed!" )
1769 i += 1
shahshreya9294c8d2015-01-21 15:54:16 -08001770 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001771 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001772 main.log.info( "Unknown error" )
shahshreya9294c8d2015-01-21 15:54:16 -08001773 PingResult = main.ERROR
shahshreya4e13a062014-11-11 16:46:18 -08001774
shahshreya9294c8d2015-01-21 15:54:16 -08001775 if PingResult == main.FALSE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001776 main.log.report(
1777 "Point intents have not ben installed correctly. Cleaning up" )
1778 # main.cleanup()
1779 # main.exit()
shahshreya9294c8d2015-01-21 15:54:16 -08001780 if PingResult == main.TRUE:
kelvin-onlab8a832582015-01-16 17:06:11 -08001781 main.log.report( "Point Intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -08001782
shahshreya9294c8d2015-01-21 15:54:16 -08001783 case9Result = PingResult
kelvin-onlab8a832582015-01-16 17:06:11 -08001784 utilities.assert_equals(
1785 expect=main.TRUE,
shahshreya9294c8d2015-01-21 15:54:16 -08001786 actual=case9Result,
kelvin-onlab8a832582015-01-16 17:06:11 -08001787 onpass="Point intents addition and Pingall Test successful",
1788 onfail="Point intents addition and Pingall Test NOT successful" )