blob: 6bf405b9c2ef82392069e5d78615a17439181d5f [file] [log] [blame]
shahshreya4e13a062014-11-11 16:46:18 -08001
kelvin-onlabeaa2eb32015-01-16 15:58:18 -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
6import sys
7import os
8import re
9import time
10import json
11
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080012time.sleep( 1 )
13
shahshreya4e13a062014-11-11 16:46:18 -080014class MultiProd:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080015
16 def __init__( self ):
shahshreya4e13a062014-11-11 16:46:18 -080017 self.default = ''
18
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080019 def CASE1( self, main ):
20 """
shahshreya4e13a062014-11-11 16:46:18 -080021 Startup sequence:
shahshreyae6c7cf42014-11-26 16:39:01 -080022 cell <name>
23 onos-verify-cell
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080024 onos-remove-raft-logs
shahshreya4e13a062014-11-11 16:46:18 -080025 git pull
26 mvn clean install
27 onos-package
shahshreya4e13a062014-11-11 16:46:18 -080028 onos-install -f
29 onos-wait-for-start
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080030 """
shahshreyaf3076352015-01-23 13:52:01 -080031 cellName = main.params[ 'ENV' ][ 'cellName' ]
32 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
33 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
34 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
35 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
36 ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
37 ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
shahshreya842d8b92015-06-10 14:13:33 -070038 gitPull = main.params[ 'GIT' ][ 'pull' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080039
40 main.case( "Setting up test environment" )
41 main.log.report(
42 "This testcase is testing setting up test environment" )
43 main.log.report( "__________________________________" )
44
45 main.step( "Applying cell variable to environment" )
shahshreyaf3076352015-01-23 13:52:01 -080046 cellResult1 = main.ONOSbench.setCell( cellName )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080047 # cellResult2 = main.ONOScli1.setCell( cellName )
48 # cellResult3 = main.ONOScli2.setCell( cellName )
49 # cellResult4 = main.ONOScli3.setCell( cellName )
shahshreyaf3076352015-01-23 13:52:01 -080050 verifyResult = main.ONOSbench.verifyCell()
51 cellResult = cellResult1
shahshreyae6c7cf42014-11-26 16:39:01 -080052
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080053 main.step( "Removing raft logs before a clen installation of ONOS" )
shahshreyaf3076352015-01-23 13:52:01 -080054 removeLogResult = main.ONOSbench.onosRemoveRaftLogs()
shahshreyae6c7cf42014-11-26 16:39:01 -080055
shahshreya842d8b92015-06-10 14:13:33 -070056 main.step( "Git checkout and get version" )
shahshreyaa47ebf42015-05-20 13:29:18 -070057 main.ONOSbench.gitCheckout( "master" )
shahshreya842d8b92015-06-10 14:13:33 -070058 if gitPull == 'True':
59 gitPullResult = main.ONOSbench.gitPull()
60 if gitPullResult == 1:
61 main.step( "Using mvn clean & install" )
62 main.ONOSbench.cleanInstall()
63 main.step( "Creating ONOS package" )
64 packageResult = main.ONOSbench.onosPackage()
65 elif gitPullResult == 0:
66 main.log.report(
67 "Git Pull Failed, look into logs for detailed reason" )
68 main.cleanup()
69 main.exit()
70 main.log.info( "git_pull_result = " + str( gitPullResult ))
71 else:
72 main.log.info( "Skipping git pull" )
73 main.ONOSbench.getVersion( report=True )
shahshreya234a1682015-05-27 15:41:56 -070074 packageResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -080075
kelvin-onlabcf33bda2015-01-23 16:54:17 -080076 # main.step( "Creating a cell" )
shahshreyaf3076352015-01-23 13:52:01 -080077 # cellCreateResult = main.ONOSbench.createCellFile( **************
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080078 # )
shahshreya4e13a062014-11-11 16:46:18 -080079
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080080 main.step( "Installing ONOS package" )
shahshreyaf3076352015-01-23 13:52:01 -080081 onos1InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080082 options="-f",
shahshreyaf3076352015-01-23 13:52:01 -080083 node=ONOS1Ip )
84 onos2InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080085 options="-f",
shahshreyaf3076352015-01-23 13:52:01 -080086 node=ONOS2Ip )
87 onos3InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080088 options="-f",
shahshreyaf3076352015-01-23 13:52:01 -080089 node=ONOS3Ip )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080090 onosInstallResult = onos1InstallResult and onos2InstallResult and\
91 onos3InstallResult
shahshreyaf3076352015-01-23 13:52:01 -080092 if onosInstallResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080093 main.log.report( "Installing ONOS package successful" )
shahshreya4e13a062014-11-11 16:46:18 -080094 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080095 main.log.report( "Installing ONOS package failed" )
96
shahshreyaf3076352015-01-23 13:52:01 -080097 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
98 onos2Isup = main.ONOSbench.isup( ONOS2Ip )
99 onos3Isup = main.ONOSbench.isup( ONOS3Ip )
100 onosIsup = onos1Isup and onos2Isup and onos3Isup
101 if onosIsup == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800102 main.log.report( "ONOS instances are up and ready" )
shahshreya4e13a062014-11-11 16:46:18 -0800103 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800104 main.log.report( "ONOS instances may not be up" )
shahshreya4e13a062014-11-11 16:46:18 -0800105
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800106 main.step( "Starting ONOS service" )
shahshreyaf3076352015-01-23 13:52:01 -0800107 startResult = main.TRUE
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800108 # startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreyaf3076352015-01-23 13:52:01 -0800109 startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip )
110 startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip )
111 startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800112 print startcli1
113 print startcli2
114 print startcli3
shahshreya4e13a062014-11-11 16:46:18 -0800115
shahshreya42efbd82015-02-05 17:06:08 -0800116 # Starting the mininet using the old way
117 main.step( "Starting Mininet ..." )
118 netIsUp = main.Mininet1.startNet()
119 if netIsUp:
120 main.log.info("Mininet CLI is up")
121
shahshreyaf3076352015-01-23 13:52:01 -0800122 case1Result = ( packageResult and
123 cellResult and verifyResult and onosInstallResult and
124 onosIsup and startResult )
125 utilities.assertEquals( expect=main.TRUE, actual=case1Result,
126 onpass="Test startup successful",
127 onfail="Test startup NOT successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800128
129 def CASE11( self, main ):
130 """
shahshreya4e13a062014-11-11 16:46:18 -0800131 Cleanup sequence:
shahshreyaf3076352015-01-23 13:52:01 -0800132 onos-service <nodeIp> stop
shahshreya4e13a062014-11-11 16:46:18 -0800133 onos-uninstall
134
135 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800136
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800137 """
shahshreyaf3076352015-01-23 13:52:01 -0800138 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
139 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
140 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
shahshreya4e13a062014-11-11 16:46:18 -0800141
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800142 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800143
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800144 main.step( "Testing ONOS kill function" )
shahshreyaf3076352015-01-23 13:52:01 -0800145 killResult1 = main.ONOSbench.onosKill( ONOS1Ip )
146 killResult2 = main.ONOSbench.onosKill( ONOS2Ip )
147 killResult3 = main.ONOSbench.onosKill( ONOS3Ip )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800148
149 main.step( "Stopping ONOS service" )
shahshreyaf3076352015-01-23 13:52:01 -0800150 stopResult1 = main.ONOSbench.onosStop( ONOS1Ip )
151 stopResult2 = main.ONOSbench.onosStop( ONOS2Ip )
152 stopResult3 = main.ONOSbench.onosStop( ONOS3Ip )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800153
154 main.step( "Uninstalling ONOS service" )
shahshreyaf3076352015-01-23 13:52:01 -0800155 uninstallResult = main.ONOSbench.onosUninstall()
shahshreya4e13a062014-11-11 16:46:18 -0800156
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800157 def CASE3( self, main ):
158 """
shahshreya4e13a062014-11-11 16:46:18 -0800159 Test 'onos' command and its functionality in driver
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800160 """
shahshreyaf3076352015-01-23 13:52:01 -0800161 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
162 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
163 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
shahshreya4e13a062014-11-11 16:46:18 -0800164
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800165 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800166
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800167 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800168 cmdstr1 = "system:name"
shahshreyaf3076352015-01-23 13:52:01 -0800169 cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
170 main.log.info( "onos command returned: " + cmdResult1 )
171 cmdResult2 = main.ONOSbench.onosCli( ONOS2Ip, cmdstr1 )
172 main.log.info( "onos command returned: " + cmdResult2 )
173 cmdResult3 = main.ONOSbench.onosCli( ONOS3Ip, cmdstr1 )
174 main.log.info( "onos command returned: " + cmdResult3 )
shahshreya4e13a062014-11-11 16:46:18 -0800175
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800176 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800177 cmdstr2 = "onos:topology"
shahshreyaf3076352015-01-23 13:52:01 -0800178 cmdResult4 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
179 main.log.info( "onos command returned: " + cmdResult4 )
180 cmdResult5 = main.ONOSbench.onosCli( ONOS2Ip, cmdstr2 )
181 main.log.info( "onos command returned: " + cmdResult5 )
182 cmdResult6 = main.ONOSbench.onosCli( ONOS6Ip, cmdstr2 )
183 main.log.info( "onos command returned: " + cmdResult6 )
shahshreya4e13a062014-11-11 16:46:18 -0800184
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800185 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800186 import re
187 import time
shahshreyaf3076352015-01-23 13:52:01 -0800188 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
189 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
190 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
191 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
192 ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
193 ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800194
195 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800196 "This testcase is testing the assignment of all the switches" +
197 " to all controllers and discovering the hosts in reactive mode" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800198 main.log.report( "__________________________________" )
199 main.case( "Pingall Test(No intents are added)" )
200 main.step( "Assigning switches to controllers" )
201 for i in range( 1, 29 ): # 1 to ( num of switches +1 )
shahshreyaf3076352015-01-23 13:52:01 -0800202 main.Mininet1.assignSwController(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800203 sw=str( i ),
204 count=3,
shahshreyaf3076352015-01-23 13:52:01 -0800205 ip1=ONOS1Ip,
206 port1=ONOS1Port,
207 ip2=ONOS2Ip,
208 port2=ONOS2Port,
209 ip3=ONOS3Ip,
210 port3=ONOS3Port )
shahshreya4e13a062014-11-11 16:46:18 -0800211
shahshreyaf3076352015-01-23 13:52:01 -0800212 switchMastership = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800213 for i in range( 1, 29 ):
shahshreyaf3076352015-01-23 13:52:01 -0800214 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800215 print( "Response is " + str( response ) )
shahshreyaf3076352015-01-23 13:52:01 -0800216 if re.search( "tcp:" + ONOS1Ip, response ):
217 switchMastership = switchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800218 else:
shahshreyaf3076352015-01-23 13:52:01 -0800219 switchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800220
shahshreyaf3076352015-01-23 13:52:01 -0800221 if switchMastership == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800222 main.log.report( "Controller assignment successfull" )
shahshreya4e13a062014-11-11 16:46:18 -0800223 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800224 main.log.report( "Controller assignment failed" )
shahshreyad524a942015-04-21 09:55:16 -0700225 appInstallResult = main.TRUE
226 main.log.info( "Activating reactive forwarding app" )
227 appInstallResult = main.ONOScli1.activateApp( "org.onosproject.fwd" )
228 appCheck = main.ONOScli1.appToIDCheck()
229 if appCheck != main.TRUE:
230 main.log.warn( main.ONOScli1.apps() )
231 main.log.warn( main.ONOScli1.appIDs() )
232 time.sleep( 30 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800233 # REACTIVE FWD test
234 main.step( "Pingall" )
shahshreyaf3076352015-01-23 13:52:01 -0800235 pingResult = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800236 time1 = time.time()
shahshreyaf3076352015-01-23 13:52:01 -0800237 pingResult = main.Mininet1.pingall()
shahshreya4e13a062014-11-11 16:46:18 -0800238 time2 = time.time()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800239 print "Time for pingall: %2f seconds" % ( time2 - time1 )
240
shahshreyaf3076352015-01-23 13:52:01 -0800241 case4Result = switchMastership and pingResult
242 if pingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800243 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800244 "Pingall Test in reactive mode to" +
245 " discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800246 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800247 main.log.report(
248 "Pingall Test in reactive mode to discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800249
shahshreyaf3076352015-01-23 13:52:01 -0800250 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800251 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800252 actual=case4Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800253 onpass="Controller assignment and Pingall Test successful",
254 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800255
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800256 def CASE5( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800257 import json
258 from subprocess import Popen, PIPE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800259 # assumes that sts is already in you PYTHONPATH
260 from sts.topology.teston_topology import TestONTopology
shahshreyaf3076352015-01-23 13:52:01 -0800261 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
262 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
263 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800264
265 main.log.report(
shahshreyad2ef8bf2015-04-03 15:34:55 -0700266 "This testcase is testing if all ONOS nodes are in topology" +
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800267 " sync with mininet and its peer ONOS nodes" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800268 main.log.report( "__________________________________" )
269 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800270 "Testing Mininet topology with the" +
271 " topology of multi instances ONOS" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800272 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800273 devices1 = main.ONOScli1.devices()
274 devices2 = main.ONOScli2.devices()
275 devices3 = main.ONOScli3.devices()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800276 # print "devices1 = ", devices1
277 # print "devices2 = ", devices2
278 # print "devices3 = ", devices3
shahshreya4e13a062014-11-11 16:46:18 -0800279 hosts1 = main.ONOScli1.hosts()
280 hosts2 = main.ONOScli2.hosts()
281 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800282 # print "hosts1 = ", hosts1
283 # print "hosts2 = ", hosts2
284 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800285 ports1 = main.ONOScli1.ports()
286 ports2 = main.ONOScli2.ports()
287 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800288 # print "ports1 = ", ports1
289 # print "ports2 = ", ports2
290 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800291 links1 = main.ONOScli1.links()
292 links2 = main.ONOScli2.links()
293 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800294 # print "links1 = ", links1
295 # print "links2 = ", links2
296 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800297
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800298 print "**************"
299
300 main.step( "Start continuous pings" )
301 main.Mininet2.pingLong(
302 src=main.params[ 'PING' ][ 'source1' ],
303 target=main.params[ 'PING' ][ 'target1' ],
304 pingTime=500 )
305 main.Mininet2.pingLong(
306 src=main.params[ 'PING' ][ 'source2' ],
307 target=main.params[ 'PING' ][ 'target2' ],
308 pingTime=500 )
309 main.Mininet2.pingLong(
310 src=main.params[ 'PING' ][ 'source3' ],
311 target=main.params[ 'PING' ][ 'target3' ],
312 pingTime=500 )
313 main.Mininet2.pingLong(
314 src=main.params[ 'PING' ][ 'source4' ],
315 target=main.params[ 'PING' ][ 'target4' ],
316 pingTime=500 )
317 main.Mininet2.pingLong(
318 src=main.params[ 'PING' ][ 'source5' ],
319 target=main.params[ 'PING' ][ 'target5' ],
320 pingTime=500 )
321 main.Mininet2.pingLong(
322 src=main.params[ 'PING' ][ 'source6' ],
323 target=main.params[ 'PING' ][ 'target6' ],
324 pingTime=500 )
325 main.Mininet2.pingLong(
326 src=main.params[ 'PING' ][ 'source7' ],
327 target=main.params[ 'PING' ][ 'target7' ],
328 pingTime=500 )
329 main.Mininet2.pingLong(
330 src=main.params[ 'PING' ][ 'source8' ],
331 target=main.params[ 'PING' ][ 'target8' ],
332 pingTime=500 )
333 main.Mininet2.pingLong(
334 src=main.params[ 'PING' ][ 'source9' ],
335 target=main.params[ 'PING' ][ 'target9' ],
336 pingTime=500 )
337 main.Mininet2.pingLong(
338 src=main.params[ 'PING' ][ 'source10' ],
339 target=main.params[ 'PING' ][ 'target10' ],
340 pingTime=500 )
341
342 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800343 global ctrls
344 ctrls = []
345 count = 1
346 while True:
347 temp = ()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800348 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
349 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
350 temp = temp + ( "ONOS" + str( count ), )
351 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
352 temp = temp + \
353 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
354 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800355 count = count + 1
356 else:
357 break
358 global MNTopo
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800359 Topo = TestONTopology(
360 main.Mininet1,
361 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800362 MNTopo = Topo
363
shahshreyaf3076352015-01-23 13:52:01 -0800364 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800365 main.step( "Compare ONOS Topology to MN Topology" )
366
shahshreyaf3076352015-01-23 13:52:01 -0800367 switchesResults1 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800368 MNTopo,
369 json.loads( devices1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800370 print "switches_Result1 = ", switchesResults1
371 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
372 onpass="ONOS1 Switches view is correct",
373 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800374
shahshreyaf3076352015-01-23 13:52:01 -0800375 switchesResults2 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800376 MNTopo,
377 json.loads( devices2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800378 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
379 onpass="ONOS2 Switches view is correct",
380 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800381
shahshreyaf3076352015-01-23 13:52:01 -0800382 switchesResults3 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800383 MNTopo,
384 json.loads( devices3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800385 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
386 onpass="ONOS3 Switches view is correct",
387 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800388
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800389 portsResults1 = main.Mininet1.comparePorts( MNTopo,
390 json.loads( ports1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800391 utilities.assertEquals( expect=main.TRUE, actual=portsResults1,
shahshreya4e13a062014-11-11 16:46:18 -0800392 onpass="ONOS1 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800393 onfail="ONOS1 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800394
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800395 portsResults2 = main.Mininet1.comparePorts( MNTopo,
396 json.loads( ports2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800397 utilities.assertEquals( expect=main.TRUE, actual=portsResults2,
shahshreya4e13a062014-11-11 16:46:18 -0800398 onpass="ONOS2 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800399 onfail="ONOS2 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800400
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800401 portsResults3 = main.Mininet1.comparePorts( MNTopo,
402 json.loads( ports3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800403 utilities.assertEquals( expect=main.TRUE, actual=portsResults3,
shahshreya4e13a062014-11-11 16:46:18 -0800404 onpass="ONOS3 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800405 onfail="ONOS3 Ports view is incorrect" )
shahshreyabf739d82015-06-10 11:22:31 -0700406
shahshreyaf3076352015-01-23 13:52:01 -0800407 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800408 MNTopo,
409 json.loads( links1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800410 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
411 onpass="ONOS1 Links view is correct",
412 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800413
shahshreyaf3076352015-01-23 13:52:01 -0800414 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800415 MNTopo,
416 json.loads( links2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800417 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
418 onpass="ONOS2 Links view is correct",
419 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800420
shahshreyaf3076352015-01-23 13:52:01 -0800421 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800422 MNTopo,
423 json.loads( links3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800424 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
425 onpass="ONOS2 Links view is correct",
426 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800427
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800428 # topoResult = switchesResults1 and switchesResults2
429 # and switchesResults3\
shahshreyaf3076352015-01-23 13:52:01 -0800430 # and portsResults1 and portsResults2 and portsResults3\
431 # and linksResults1 and linksResults2 and linksResults3
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800432
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800433 topoResult = switchesResults1 and switchesResults2 and\
434 switchesResults3 and linksResults1 and linksResults2 and\
435 linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800436
shahshreyaf3076352015-01-23 13:52:01 -0800437 if topoResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800438 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800439 "Topology Check Test with mininet" +
440 "and ONOS instances successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800441 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800442 main.log.report(
443 "Topology Check Test with mininet and ONOS instances failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800444
shahshreyaf3076352015-01-23 13:52:01 -0800445 utilities.assertEquals( expect=main.TRUE, actual=topoResult,
446 onpass="Topology Check Test successful",
447 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800448
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800449 def CASE10( self ):
shahshreya1f119da2015-04-21 17:16:46 -0700450 import time
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800451 main.log.report(
452 "This testcase uninstalls the reactive forwarding app" )
453 main.log.report( "__________________________________" )
454 main.case( "Uninstalling reactive forwarding app" )
455 # Unistall onos-app-fwd app to disable reactive forwarding
shahshreyad524a942015-04-21 09:55:16 -0700456 appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.fwd" )
457 appCheck = main.ONOScli1.appToIDCheck()
458 if appCheck != main.TRUE:
459 main.log.warn( main.ONOScli1.apps() )
460 main.log.warn( main.ONOScli1.appIDs() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800461 main.log.info( "onos-app-fwd uninstalled" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800462
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800463 # After reactive forwarding is disabled,
464 # the reactive flows on switches timeout in 10-15s
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800465 # So sleep for 15s
466 time.sleep( 15 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800467
shahshreyae6c7cf42014-11-26 16:39:01 -0800468 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800469 main.log.info( hosts )
shahshreyad524a942015-04-21 09:55:16 -0700470 case10Result = appInstallResult
shahshreyaf3076352015-01-23 13:52:01 -0800471 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800472 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800473 actual=case10Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800474 onpass="Reactive forwarding app uninstallation successful",
475 onfail="Reactive forwarding app uninstallation failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800476
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800477 def CASE6( self ):
478 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800479 "This testcase is testing the addition of" +
480 " host intents and then doing pingall" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800481 main.log.report( "__________________________________" )
482 main.case( "Obtaining hostsfor adding host intents" )
483 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800484 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800485 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800486
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800487 main.step( "Get all devices id" )
shahshreyaf3076352015-01-23 13:52:01 -0800488 devicesIdList = main.ONOScli1.getAllDevicesId()
489 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -0800490
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800491 # ONOS displays the hosts in hex format
492 # unlike mininet which does in decimal format
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800493 # So take care while adding intents
shahshreya4e13a062014-11-11 16:46:18 -0800494
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800495 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800496 main.step( "Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,
497 h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
498 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:08/-1",
499 "00:00:00:00:00:12/-1" )
500 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:09/-1",
501 "00:00:00:00:00:13/-1" )
502 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0A/-1",
503 "00:00:00:00:00:14/-1" )
504 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0B/-1",
505 "00:00:00:00:00:15/-1" )
506 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0C/-1",
507 "00:00:00:00:00:16/-1" )
508 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0D/-1",
509 "00:00:00:00:00:17/-1" )
510 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0E/-1",
511 "00:00:00:00:00:18/-1" )
512 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0F/-1",
513 "00:00:00:00:00:19/-1" )
514 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:10/-1",
515 "00:00:00:00:00:1A/-1" )
516 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:11/-1",
517 "00:00:00:00:00:1B/-1" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800518 """
shahshreya234a1682015-05-27 15:41:56 -0700519 intentsId = []
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800520 for i in range( 8, 18 ):
521 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800522 "Adding host intent between h" + str( i ) +
523 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800524 host1 = "00:00:00:00:00:" + \
525 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
526 host2 = "00:00:00:00:00:" + \
527 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
528 # NOTE: get host can return None
529 # TODO: handle this
shahshreyaf3076352015-01-23 13:52:01 -0800530 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
531 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
532 tmpResult = main.ONOScli1.addHostIntent( host1Id, host2Id )
shahshreya234a1682015-05-27 15:41:56 -0700533 intentsId.append( tmpResult )
534
535 checkIntent1 = main.ONOScli1.checkIntentState( intentsId )
536 checkIntent2 = main.ONOScli2.checkIntentState( intentsId )
537 checkIntent3 = main.ONOScli3.checkIntentState( intentsId )
shahshreya4e13a062014-11-11 16:46:18 -0800538
539 flowHandle = main.ONOScli1.flows()
shahshreya234a1682015-05-27 15:41:56 -0700540
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800541 main.log.info( "flows:" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -0800542
543 count = 1
544 i = 8
shahshreyaf3076352015-01-23 13:52:01 -0800545 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800546 while i < 18:
547 main.log.info(
548 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
549 ping = main.Mininet1.pingHost(
550 src="h" + str( i ), target="h" + str( i + 10 ) )
551 if ping == main.FALSE and count < 5:
552 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800553 # i = 8
shahshreyaf3076352015-01-23 13:52:01 -0800554 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800555 main.log.report( "Ping between h" +
556 str( i ) +
557 " and h" +
558 str( i +
559 10 ) +
560 " failed. Making attempt number " +
561 str( count ) +
562 " in 2 seconds" )
563 time.sleep( 2 )
564 elif ping == main.FALSE:
565 main.log.report( "All ping attempts between h" +
566 str( i ) +
567 " and h" +
568 str( i +
569 10 ) +
570 "have failed" )
571 i = 19
shahshreyaf3076352015-01-23 13:52:01 -0800572 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800573 elif ping == main.TRUE:
574 main.log.info( "Ping test between h" +
575 str( i ) +
576 " and h" +
577 str( i +
578 10 ) +
579 "passed!" )
580 i += 1
shahshreyaf3076352015-01-23 13:52:01 -0800581 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800582 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800583 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -0800584 PingResult = main.ERROR
585 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800586 main.log.report(
587 "Host intents have not ben installed correctly. Cleaning up" )
588 # main.cleanup()
589 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -0800590 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800591 main.log.report( "Host intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -0800592
shahshreya234a1682015-05-27 15:41:56 -0700593 checkIntent1 = main.ONOScli1.checkIntentState( intentsId )
594 checkIntent2 = main.ONOScli2.checkIntentState( intentsId )
595 checkIntent3 = main.ONOScli3.checkIntentState( intentsId )
596
shahshreyaf3076352015-01-23 13:52:01 -0800597 case6Result = PingResult
598 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800599 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800600 actual=case6Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800601 onpass="Host intent addition and Pingall Test successful",
602 onfail="Host intent addition and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800603
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800604 def CASE7( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800605
shahshreyaf3076352015-01-23 13:52:01 -0800606 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800607
shahshreyaf3076352015-01-23 13:52:01 -0800608 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800609
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800610 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800611 "This testscase is killing a link to" +
612 " ensure that link discovery is consistent" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800613 main.log.report( "__________________________________" )
614 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800615 "Killing a link to Ensure that Link" +
616 " Discovery is Working Properly" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800617 main.step( "Start continuous pings" )
shahshreya4e13a062014-11-11 16:46:18 -0800618
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800619 main.Mininet2.pingLong(
620 src=main.params[ 'PING' ][ 'source1' ],
621 target=main.params[ 'PING' ][ 'target1' ],
622 pingTime=500 )
623 main.Mininet2.pingLong(
624 src=main.params[ 'PING' ][ 'source2' ],
625 target=main.params[ 'PING' ][ 'target2' ],
626 pingTime=500 )
627 main.Mininet2.pingLong(
628 src=main.params[ 'PING' ][ 'source3' ],
629 target=main.params[ 'PING' ][ 'target3' ],
630 pingTime=500 )
631 main.Mininet2.pingLong(
632 src=main.params[ 'PING' ][ 'source4' ],
633 target=main.params[ 'PING' ][ 'target4' ],
634 pingTime=500 )
635 main.Mininet2.pingLong(
636 src=main.params[ 'PING' ][ 'source5' ],
637 target=main.params[ 'PING' ][ 'target5' ],
638 pingTime=500 )
639 main.Mininet2.pingLong(
640 src=main.params[ 'PING' ][ 'source6' ],
641 target=main.params[ 'PING' ][ 'target6' ],
642 pingTime=500 )
643 main.Mininet2.pingLong(
644 src=main.params[ 'PING' ][ 'source7' ],
645 target=main.params[ 'PING' ][ 'target7' ],
646 pingTime=500 )
647 main.Mininet2.pingLong(
648 src=main.params[ 'PING' ][ 'source8' ],
649 target=main.params[ 'PING' ][ 'target8' ],
650 pingTime=500 )
651 main.Mininet2.pingLong(
652 src=main.params[ 'PING' ][ 'source9' ],
653 target=main.params[ 'PING' ][ 'target9' ],
654 pingTime=500 )
655 main.Mininet2.pingLong(
656 src=main.params[ 'PING' ][ 'source10' ],
657 target=main.params[ 'PING' ][ 'target10' ],
658 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -0800659
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800660 main.step( "Determine the current number of switches and links" )
shahshreyaf3076352015-01-23 13:52:01 -0800661 topologyOutput = main.ONOScli1.topology()
662 topologyResult = main.ONOSbench.getTopology( topologyOutput )
shahshreyaa47ebf42015-05-20 13:29:18 -0700663 activeSwitches = topologyResult[ 'devices' ]
664 links = topologyResult[ 'links' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800665 main.log.info(
666 "Currently there are %s switches and %s links" %
667 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -0800668
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800669 main.step( "Kill Link between s3 and s28" )
670 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
shahshreyaf3076352015-01-23 13:52:01 -0800671 time.sleep( linkSleep )
672 topologyOutput = main.ONOScli2.topology()
673 LinkDown = main.ONOSbench.checkStatus(
674 topologyOutput, activeSwitches, str(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800675 int( links ) - 2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800676 if LinkDown == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800677 main.log.report( "Link Down discovered properly" )
shahshreyaf3076352015-01-23 13:52:01 -0800678 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800679 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800680 actual=LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800681 onpass="Link Down discovered properly",
682 onfail="Link down was not discovered in " +
shahshreyaf3076352015-01-23 13:52:01 -0800683 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800684 " seconds" )
shahshreya4e13a062014-11-11 16:46:18 -0800685
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800686 main.step( "Bring link between s3 and s28 back up" )
shahshreyaf3076352015-01-23 13:52:01 -0800687 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
688 time.sleep( linkSleep )
689 topologyOutput = main.ONOScli2.topology()
690 LinkUp = main.ONOSbench.checkStatus(
691 topologyOutput,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800692 activeSwitches,
693 str( links ) )
shahshreyaf3076352015-01-23 13:52:01 -0800694 if LinkUp == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800695 main.log.report( "Link up discovered properly" )
shahshreyaf3076352015-01-23 13:52:01 -0800696 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800697 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800698 actual=LinkUp,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800699 onpass="Link up discovered properly",
700 onfail="Link up was not discovered in " +
shahshreyaf3076352015-01-23 13:52:01 -0800701 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800702 " seconds" )
703
704 main.step( "Compare ONOS Topology to MN Topology" )
705 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800706 "Testing Mininet topology with the" +
707 " topology of multi instances ONOS" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800708 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800709 devices1 = main.ONOScli1.devices()
710 devices2 = main.ONOScli2.devices()
711 devices3 = main.ONOScli3.devices()
712 print "devices1 = ", devices1
713 print "devices2 = ", devices2
714 print "devices3 = ", devices3
715 hosts1 = main.ONOScli1.hosts()
716 hosts2 = main.ONOScli2.hosts()
717 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800718 # print "hosts1 = ", hosts1
719 # print "hosts2 = ", hosts2
720 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800721 ports1 = main.ONOScli1.ports()
722 ports2 = main.ONOScli2.ports()
723 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800724 # print "ports1 = ", ports1
725 # print "ports2 = ", ports2
726 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800727 links1 = main.ONOScli1.links()
728 links2 = main.ONOScli2.links()
729 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800730 # print "links1 = ", links1
731 # print "links2 = ", links2
732 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800733
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800734 print "**************"
735
736 main.step( "Start continuous pings" )
737 main.Mininet2.pingLong(
738 src=main.params[ 'PING' ][ 'source1' ],
739 target=main.params[ 'PING' ][ 'target1' ],
740 pingTime=500 )
741 main.Mininet2.pingLong(
742 src=main.params[ 'PING' ][ 'source2' ],
743 target=main.params[ 'PING' ][ 'target2' ],
744 pingTime=500 )
745 main.Mininet2.pingLong(
746 src=main.params[ 'PING' ][ 'source3' ],
747 target=main.params[ 'PING' ][ 'target3' ],
748 pingTime=500 )
749 main.Mininet2.pingLong(
750 src=main.params[ 'PING' ][ 'source4' ],
751 target=main.params[ 'PING' ][ 'target4' ],
752 pingTime=500 )
753 main.Mininet2.pingLong(
754 src=main.params[ 'PING' ][ 'source5' ],
755 target=main.params[ 'PING' ][ 'target5' ],
756 pingTime=500 )
757 main.Mininet2.pingLong(
758 src=main.params[ 'PING' ][ 'source6' ],
759 target=main.params[ 'PING' ][ 'target6' ],
760 pingTime=500 )
761 main.Mininet2.pingLong(
762 src=main.params[ 'PING' ][ 'source7' ],
763 target=main.params[ 'PING' ][ 'target7' ],
764 pingTime=500 )
765 main.Mininet2.pingLong(
766 src=main.params[ 'PING' ][ 'source8' ],
767 target=main.params[ 'PING' ][ 'target8' ],
768 pingTime=500 )
769 main.Mininet2.pingLong(
770 src=main.params[ 'PING' ][ 'source9' ],
771 target=main.params[ 'PING' ][ 'target9' ],
772 pingTime=500 )
773 main.Mininet2.pingLong(
774 src=main.params[ 'PING' ][ 'source10' ],
775 target=main.params[ 'PING' ][ 'target10' ],
776 pingTime=500 )
777
778 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800779 global ctrls
780 ctrls = []
781 count = 1
782 while True:
783 temp = ()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800784 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
785 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
786 temp = temp + ( "ONOS" + str( count ), )
787 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
788 temp = temp + \
789 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
790 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800791 count = count + 1
792 else:
793 break
794 global MNTopo
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800795 Topo = TestONTopology(
796 main.Mininet1,
797 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800798 MNTopo = Topo
799
shahshreyaf3076352015-01-23 13:52:01 -0800800 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800801 main.step( "Compare ONOS Topology to MN Topology" )
802
shahshreyaf3076352015-01-23 13:52:01 -0800803 switchesResults1 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800804 MNTopo,
805 json.loads( devices1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800806 print "switches_Result1 = ", switchesResults1
807 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
808 onpass="ONOS1 Switches view is correct",
809 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800810
shahshreyaf3076352015-01-23 13:52:01 -0800811 switchesResults2 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800812 MNTopo,
813 json.loads( devices2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800814 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
815 onpass="ONOS2 Switches view is correct",
816 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800817
shahshreyaf3076352015-01-23 13:52:01 -0800818 switchesResults3 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800819 MNTopo,
820 json.loads( devices3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800821 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
822 onpass="ONOS3 Switches view is correct",
823 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800824
825 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800826 portsResults1 = main.Mininet1.comparePorts( MNTopo,
827 json.loads( ports1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800828 utilities.assertEquals( expect=main.TRUE, actual=portsResults1,
shahshreya4e13a062014-11-11 16:46:18 -0800829 onpass="ONOS1 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800830 onfail="ONOS1 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800831
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800832 portsResults2 = main.Mininet1.comparePorts( MNTopo,
833 json.loads( ports2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800834 utilities.assertEquals( expect=main.TRUE, actual=portsResults2,
shahshreya4e13a062014-11-11 16:46:18 -0800835 onpass="ONOS2 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800836 onfail="ONOS2 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800837
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800838 portsResults3 = main.Mininet1.comparePorts( MNTopo,
839 json.loads( ports3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800840 utilities.assertEquals( expect=main.TRUE, actual=portsResults3,
shahshreya4e13a062014-11-11 16:46:18 -0800841 onpass="ONOS3 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800842 onfail="ONOS3 Ports view is incorrect" )
843 """
shahshreyaf3076352015-01-23 13:52:01 -0800844 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800845 MNTopo,
846 json.loads( links1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800847 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
848 onpass="ONOS1 Links view is correct",
849 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800850
shahshreyaf3076352015-01-23 13:52:01 -0800851 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800852 MNTopo,
853 json.loads( links2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800854 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
855 onpass="ONOS2 Links view is correct",
856 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800857
shahshreyaf3076352015-01-23 13:52:01 -0800858 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800859 MNTopo,
860 json.loads( links3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800861 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
862 onpass="ONOS2 Links view is correct",
863 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800864
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800865 # topoResult = switchesResults1 and switchesResults2
866 # and switchesResults3\
shahshreyaf3076352015-01-23 13:52:01 -0800867 # and portsResults1 and portsResults2 and portsResults3\
868 # and linksResults1 and linksResults2 and linksResults3
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800869
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800870 topoResult = switchesResults1 and switchesResults2\
871 and switchesResults3 and linksResults1 and\
872 linksResults2 and linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800873
shahshreyaf3076352015-01-23 13:52:01 -0800874 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800875 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800876 actual=topoResult and LinkUp and LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800877 onpass="Topology Check Test successful",
878 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800879
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800880 def CASE8( self ):
881 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800882 Intent removal
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800883 """
884 main.log.report(
shahshreyab512cd02015-01-27 17:01:47 -0800885 "This testcase removes any previously added intents" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800886 main.log.report( "__________________________________" )
887 main.log.info( "Removing any previously installed intents" )
888 main.case( "Removing intents" )
889 main.step( "Obtain the intent id's" )
shahshreyaf3076352015-01-23 13:52:01 -0800890 intentResult = main.ONOScli1.intents( jsonFormat=False )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800891
shahshreyaf3076352015-01-23 13:52:01 -0800892 intentLinewise = intentResult.split( "\n" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800893 intentList = []
shahshreyaf3076352015-01-23 13:52:01 -0800894 for line in intentLinewise:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800895 if line.startswith( "id=" ):
896 intentList.append( line )
shahshreyae6c7cf42014-11-26 16:39:01 -0800897
898 intentids = []
899 for line in intentList:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800900 intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
shahshreya4e13a062014-11-11 16:46:18 -0800901 for id in intentids:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800902 main.log.info( "id = " + id )
shahshreyae6c7cf42014-11-26 16:39:01 -0800903
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800904 main.step(
905 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -0800906 for id in intentids:
shahshreyaa47ebf42015-05-20 13:29:18 -0700907 main.ONOScli1.removeIntent( intentId=id ,purge=True )
shahshreyae6c7cf42014-11-26 16:39:01 -0800908
shahshreya234a1682015-05-27 15:41:56 -0700909 remainingIntent = main.ONOScli1.intents( jsonFormat=False )
910 main.log.info( "Remaining intents " + remainingIntent )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800911
shahshreya234a1682015-05-27 15:41:56 -0700912 case8Result = main.TRUE
913 intentResult = main.TRUE
914 if remainingIntent:
915 main.log.error( "There are still remaining intent" )
916 intentResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800917 i = 8
shahshreya234a1682015-05-27 15:41:56 -0700918
shahshreyaf3076352015-01-23 13:52:01 -0800919 PingResult = main.TRUE
shahshreya234a1682015-05-27 15:41:56 -0700920 """
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800921 while i < 18:
922 main.log.info(
923 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
924 ping = main.Mininet1.pingHost(
925 src="h" + str( i ), target="h" + str( i + 10 ) )
926 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -0800927 i = 19
shahshreyaf3076352015-01-23 13:52:01 -0800928 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800929 elif ping == main.FALSE:
930 i += 1
shahshreyaf3076352015-01-23 13:52:01 -0800931 PingResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800932 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800933 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -0800934 PingResult = main.ERROR
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800935 # Note: If the ping result failed, that means the intents have been
936 # withdrawn correctly.
shahshreyaf3076352015-01-23 13:52:01 -0800937 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800938 main.log.report( "Host intents have not been withdrawn correctly" )
939 # main.cleanup()
940 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -0800941 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800942 main.log.report( "Host intents have been withdrawn correctly" )
shahshreya234a1682015-05-27 15:41:56 -0700943 """
944 case8Result = intentResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800945
shahshreya234a1682015-05-27 15:41:56 -0700946 if case8Result == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800947 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800948 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800949 main.log.report( "Intent removal failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800950
shahshreya234a1682015-05-27 15:41:56 -0700951 utilities.assertEquals( expect=main.TRUE, actual=case8Result,
952 onpass="Intent removal test successful",
953 onfail="Intent removal test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800954
955 def CASE9( self ):
956 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800957 This test case adds point intents. Make sure you run test case 8
958 which is host intent removal before executing this test case.
959 Else the host intent's flows will persist on switches and the pings
960 would work even if there is some issue with the point intent's flows
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800961 """
962 main.log.report(
963 "This testcase adds point intents and then does pingall" )
964 main.log.report( "__________________________________" )
965 main.log.info( "Adding point intents" )
966 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800967 "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20," +
968 "h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800969 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800970 "Add point-to-point intents for mininet hosts" +
971 " h8 and h18 or ONOS hosts h8 and h12" )
shahshreyaa47ebf42015-05-20 13:29:18 -0700972 macsDict = {}
973 for i in range( 1,29 ):
974 macsDict[ 'h' + str( i ) ]= main.Mininet1.getMacAddress( host='h'+ str( i ) )
975 print macsDict
976 # main.step(var1)
shahshreyaf3076352015-01-23 13:52:01 -0800977 ptpIntentResult = main.ONOScli1.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -0700978 ingressDevice="of:0000000000003008/1",
979 egressDevice="of:0000000000006018/1",
980 ethType='IPV4',
981 ethSrc=macsDict.get( 'h8' ))
shahshreyaf3076352015-01-23 13:52:01 -0800982 if ptpIntentResult == main.TRUE:
983 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800984 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800985 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800986
shahshreyaf3076352015-01-23 13:52:01 -0800987 ptpIntentResult = main.ONOScli1.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -0700988 ingressDevice="of:0000000000006018/1",
989 egressDevice="of:0000000000003008/1",
990 ethType='IPV4',
991 ethSrc=macsDict.get( 'h18' ))
shahshreyaf3076352015-01-23 13:52:01 -0800992 if ptpIntentResult == main.TRUE:
993 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800994 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800995 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800996
shahshreyaa47ebf42015-05-20 13:29:18 -0700997 var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
998 main.step(var2)
shahshreyaf3076352015-01-23 13:52:01 -0800999 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001000 "of:0000000000003009/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001001 "of:0000000000006019/1",
1002 ethType='IPV4',
1003 ethSrc=macsDict.get( 'h9' ))
shahshreyaf3076352015-01-23 13:52:01 -08001004 if ptpIntentResult == main.TRUE:
1005 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001006 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001007 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001008
shahshreyaf3076352015-01-23 13:52:01 -08001009 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001010 "of:0000000000006019/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001011 "of:0000000000003009/1",
1012 ethType='IPV4',
1013 ethSrc=macsDict.get( 'h19' ))
shahshreyaf3076352015-01-23 13:52:01 -08001014 if ptpIntentResult == main.TRUE:
1015 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001016 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001017 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001018
shahshreyaa47ebf42015-05-20 13:29:18 -07001019 var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
1020 main.step(var3)
shahshreyaf3076352015-01-23 13:52:01 -08001021 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001022 "of:0000000000003010/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001023 "of:0000000000006020/1",
1024 ethType='IPV4',
1025 ethSrc=macsDict.get( 'h10' ))
1026
shahshreyaf3076352015-01-23 13:52:01 -08001027 if ptpIntentResult == main.TRUE:
1028 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001029 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001030 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001031
shahshreyaf3076352015-01-23 13:52:01 -08001032 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001033 "of:0000000000006020/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001034 "of:0000000000003010/1",
1035 ethType='IPV4',
1036 ethSrc=macsDict.get( 'h20' ))
1037
shahshreyaf3076352015-01-23 13:52:01 -08001038 if ptpIntentResult == main.TRUE:
1039 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001040 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001041 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001042
shahshreyaa47ebf42015-05-20 13:29:18 -07001043 var4 = "Add point intents for mininet hosts h11 and h21 or" +\
1044 " ONOS hosts hB and h15"
1045 main.case(var4)
shahshreyaf3076352015-01-23 13:52:01 -08001046 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001047 "of:0000000000003011/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001048 "of:0000000000006021/1",
1049 ethType='IPV4',
1050 ethSrc=macsDict.get( 'h11' ))
1051
shahshreyaf3076352015-01-23 13:52:01 -08001052 if ptpIntentResult == main.TRUE:
1053 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001054 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001055 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001056
shahshreyaf3076352015-01-23 13:52:01 -08001057 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001058 "of:0000000000006021/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001059 "of:0000000000003011/1",
1060 ethType='IPV4',
1061 ethSrc=macsDict.get( 'h21' ))
1062
shahshreyaf3076352015-01-23 13:52:01 -08001063 if ptpIntentResult == main.TRUE:
1064 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001065 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001066 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001067
shahshreyaa47ebf42015-05-20 13:29:18 -07001068 var5 = "Add point intents for mininet hosts h12 and h22 " +\
1069 "ONOS hosts hC and h16"
1070 main.case(var5)
shahshreyaf3076352015-01-23 13:52:01 -08001071 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001072 "of:0000000000003012/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001073 "of:0000000000006022/1",
1074 ethType='IPV4',
1075 ethSrc=macsDict.get( 'h12' ))
1076
shahshreyaf3076352015-01-23 13:52:01 -08001077 if ptpIntentResult == main.TRUE:
1078 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001079 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001080 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001081
shahshreyaf3076352015-01-23 13:52:01 -08001082 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001083 "of:0000000000006022/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001084 "of:0000000000003012/1",
1085 ethType='IPV4',
1086 ethSrc=macsDict.get( 'h22' ))
1087
shahshreyaf3076352015-01-23 13:52:01 -08001088 if ptpIntentResult == main.TRUE:
1089 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001090 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001091 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001092
shahshreyaa47ebf42015-05-20 13:29:18 -07001093 var6 = "Add point intents for mininet hosts h13 and h23 or" +\
1094 " ONOS hosts hD and h17"
1095 main.case(var6)
shahshreyaf3076352015-01-23 13:52:01 -08001096 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001097 "of:0000000000003013/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001098 "of:0000000000006023/1",
1099 ethType='IPV4',
1100 ethSrc=macsDict.get( 'h13' ))
1101
shahshreyaf3076352015-01-23 13:52:01 -08001102 if ptpIntentResult == main.TRUE:
1103 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001104 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001105 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001106
shahshreyaf3076352015-01-23 13:52:01 -08001107 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001108 "of:0000000000006023/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001109 "of:0000000000003013/1",
1110 ethType='IPV4',
1111 ethSrc=macsDict.get( 'h23' ))
1112
shahshreyaf3076352015-01-23 13:52:01 -08001113 if ptpIntentResult == main.TRUE:
1114 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001115 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001116 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001117
shahshreyaa47ebf42015-05-20 13:29:18 -07001118 var7 = "Add point intents for mininet hosts h14 and h24 or" +\
1119 " ONOS hosts hE and h18"
1120 main.case(var7)
shahshreyaf3076352015-01-23 13:52:01 -08001121 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001122 "of:0000000000003014/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001123 "of:0000000000006024/1",
1124 ethType='IPV4',
1125 ethSrc=macsDict.get( 'h14' ))
1126
shahshreyaf3076352015-01-23 13:52:01 -08001127 if ptpIntentResult == main.TRUE:
1128 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001129 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001130 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001131
shahshreyaf3076352015-01-23 13:52:01 -08001132 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001133 "of:0000000000006024/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001134 "of:0000000000003014/1",
1135 ethType='IPV4',
1136 ethSrc=macsDict.get( 'h24' ))
1137
shahshreyaf3076352015-01-23 13:52:01 -08001138 if ptpIntentResult == main.TRUE:
1139 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001140 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001141 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001142
shahshreyaa47ebf42015-05-20 13:29:18 -07001143 var8 = "Add point intents for mininet hosts h15 and h25 or" +\
1144 " ONOS hosts hF and h19"
1145 main.case(var8)
shahshreyaf3076352015-01-23 13:52:01 -08001146 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001147 "of:0000000000003015/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001148 "of:0000000000006025/1",
1149 ethType='IPV4',
1150 ethSrc=macsDict.get( 'h15' ))
1151
shahshreyaf3076352015-01-23 13:52:01 -08001152 if ptpIntentResult == main.TRUE:
1153 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001154 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001155 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001156
shahshreyaf3076352015-01-23 13:52:01 -08001157 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001158 "of:0000000000006025/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001159 "of:0000000000003015/1",
1160 ethType='IPV4',
1161 ethSrc=macsDict.get( 'h25' ))
1162
shahshreyaf3076352015-01-23 13:52:01 -08001163 if ptpIntentResult == main.TRUE:
1164 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001165 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001166 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001167
shahshreyaa47ebf42015-05-20 13:29:18 -07001168 var9 = "Add intents for mininet hosts h16 and h26 or" +\
1169 " ONOS hosts h10 and h1A"
1170 main.case(var9)
shahshreyaf3076352015-01-23 13:52:01 -08001171 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001172 "of:0000000000003016/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001173 "of:0000000000006026/1",
1174 ethType='IPV4',
1175 ethSrc=macsDict.get( 'h16' ))
1176
shahshreyaf3076352015-01-23 13:52:01 -08001177 if ptpIntentResult == main.TRUE:
1178 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001179 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001180 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001181
shahshreyaf3076352015-01-23 13:52:01 -08001182 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001183 "of:0000000000006026/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001184 "of:0000000000003016/1",
1185 ethType='IPV4',
1186 ethSrc=macsDict.get( 'h26' ))
1187
shahshreyaf3076352015-01-23 13:52:01 -08001188 if ptpIntentResult == main.TRUE:
1189 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001190 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001191 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001192
shahshreyaa47ebf42015-05-20 13:29:18 -07001193 var10 = "Add point intents for mininet hosts h17 and h27 or" +\
1194 " ONOS hosts h11 and h1B"
1195 main.case(var10)
shahshreyaf3076352015-01-23 13:52:01 -08001196 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001197 "of:0000000000003017/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001198 "of:0000000000006027/1",
1199 ethType='IPV4',
1200 ethSrc=macsDict.get( 'h17' ))
1201
shahshreyaf3076352015-01-23 13:52:01 -08001202 if ptpIntentResult == main.TRUE:
1203 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001204 main.log.info( "Point to point intent install successful" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001205 #main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001206
shahshreyaf3076352015-01-23 13:52:01 -08001207 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001208 "of:0000000000006027/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001209 "of:0000000000003017/1",
1210 ethType='IPV4',
1211 ethSrc=macsDict.get( 'h27' ))
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001212
1213 print(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001214 "_______________________________________________________" +
1215 "________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001216
1217 flowHandle = main.ONOScli1.flows()
shahshreyabf739d82015-06-10 11:22:31 -07001218 print "flowHandle = ", flowHandle
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001219 main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001220
1221 count = 1
1222 i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001223 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001224 while i < 18:
1225 main.log.info(
1226 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1227 ping = main.Mininet1.pingHost(
1228 src="h" + str( i ), target="h" + str( i + 10 ) )
1229 if ping == main.FALSE and count < 5:
1230 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001231 # i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001232 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001233 main.log.report( "Ping between h" +
1234 str( i ) +
1235 " and h" +
1236 str( i +
1237 10 ) +
1238 " failed. Making attempt number " +
1239 str( count ) +
1240 " in 2 seconds" )
1241 time.sleep( 2 )
1242 elif ping == main.FALSE:
1243 main.log.report( "All ping attempts between h" +
1244 str( i ) +
1245 " and h" +
1246 str( i +
1247 10 ) +
1248 "have failed" )
1249 i = 19
shahshreyaf3076352015-01-23 13:52:01 -08001250 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001251 elif ping == main.TRUE:
1252 main.log.info( "Ping test between h" +
1253 str( i ) +
1254 " and h" +
1255 str( i +
1256 10 ) +
1257 "passed!" )
1258 i += 1
shahshreyaf3076352015-01-23 13:52:01 -08001259 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001260 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001261 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -08001262 PingResult = main.ERROR
1263 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001264 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001265 "Ping all test after Point intents" +
1266 " addition failed. Cleaning up" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001267 # main.cleanup()
1268 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -08001269 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001270 main.log.report(
1271 "Ping all test after Point intents addition successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001272
shahshreyaf3076352015-01-23 13:52:01 -08001273 case8Result = PingResult
1274 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001275 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001276 actual=case8Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001277 onpass="Ping all test after Point intents addition successful",
1278 onfail="Ping all test after Point intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001279
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001280 def CASE31( self ):
1281 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001282 This test case adds point intent related to
1283 SDN-IP matching on ICMP ( ethertype=IPV4, ipProto=1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001284 """
shahshreyae6c7cf42014-11-26 16:39:01 -08001285 import json
1286
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001287 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001288 "This test case adds point intent " +
1289 "related to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001290 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001291 "Adding bidirectional point intent related" +
1292 " to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001293 main.step( "Adding bidirectional point intent" )
1294 # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1295 # --ethType=IPV4 --ipProto=1 of:0000000000003008/1
1296 # of:0000000000006018/1
1297
shahshreyaf3076352015-01-23 13:52:01 -08001298 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001299 for i in range( 8, 11 ):
1300 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001301 "Adding point intent between h" + str( i ) +
1302 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001303 host1 = "00:00:00:00:00:" + \
1304 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1305 host2 = "00:00:00:00:00:" + \
1306 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
shahshreyaf3076352015-01-23 13:52:01 -08001307 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1308 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1309 for host in hostsJson:
1310 if host[ 'id' ] == host1Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001311 ip1 = host[ 'ipAddresses' ][ 0 ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001312 ip1 = str( ip1 + "/32" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001313 device1 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001314 device1 = str( device1 + "/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001315 elif host[ 'id' ] == host2Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001316 ip2 = str( host[ 'ipAddresses' ][ 0 ] ) + "/32"
1317 device2 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001318 device2 = str( device2 + "/1" )
1319
shahshreyaf3076352015-01-23 13:52:01 -08001320 pIntentResult1 = main.ONOScli1.addPointIntent(
1321 ingressDevice=device1,
1322 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001323 ipSrc=ip1,
1324 ipDst=ip2,
1325 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
shahshreyaa47ebf42015-05-20 13:29:18 -07001326 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ], )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001327
shahshreyaf3076352015-01-23 13:52:01 -08001328 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1329 main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001330
shahshreyaf3076352015-01-23 13:52:01 -08001331 pIntentResult2 = main.ONOScli1.addPointIntent(
1332 ingressDevice=device2,
1333 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001334 ipSrc=ip2,
1335 ipDst=ip1,
1336 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1337 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1338
shahshreyaf3076352015-01-23 13:52:01 -08001339 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1340 main.log.info( getIntentResult )
shahshreyaa47ebf42015-05-20 13:29:18 -07001341 if ( pIntentResult1 and pIntentResult2 ) :
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001342 # getIntentResult = main.ONOScli1.intents()
shahshreyaf3076352015-01-23 13:52:01 -08001343 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001344 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001345 "Point intent related to SDN-IP matching" +
1346 " on ICMP install successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001347
1348 time.sleep( 15 )
shahshreyaf3076352015-01-23 13:52:01 -08001349 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1350 main.log.info( "intents = " + getIntentResult )
1351 getFlowsResult = main.ONOScli1.flows()
1352 main.log.info( "flows = " + getFlowsResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001353
shahshreyae6c7cf42014-11-26 16:39:01 -08001354 count = 1
1355 i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001356 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001357 while i < 11:
1358 main.log.info(
1359 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1360 ping = main.Mininet1.pingHost(
1361 src="h" + str( i ), target="h" + str( i + 10 ) )
1362 if ping == main.FALSE and count < 3:
1363 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001364 # i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001365 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001366 main.log.report( "Ping between h" +
1367 str( i ) +
1368 " and h" +
1369 str( i +
1370 10 ) +
1371 " failed. Making attempt number " +
1372 str( count ) +
1373 " in 2 seconds" )
1374 time.sleep( 2 )
1375 elif ping == main.FALSE:
1376 main.log.report( "All ping attempts between h" +
1377 str( i ) +
1378 " and h" +
1379 str( i +
1380 10 ) +
1381 "have failed" )
1382 i = 19
shahshreyaf3076352015-01-23 13:52:01 -08001383 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001384 elif ping == main.TRUE:
1385 main.log.info( "Ping test between h" +
1386 str( i ) +
1387 " and h" +
1388 str( i +
1389 10 ) +
1390 "passed!" )
1391 i += 1
shahshreyaf3076352015-01-23 13:52:01 -08001392 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -08001393 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001394 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -08001395 PingResult = main.ERROR
1396 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001397 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001398 "Ping test after Point intents related to" +
1399 " SDN-IP matching on ICMP failed." )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001400 # main.cleanup()
1401 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -08001402 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001403 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001404 "Ping all test after Point intents related to" +
1405 " SDN-IP matching on ICMP successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001406
shahshreyaa47ebf42015-05-20 13:29:18 -07001407 case31Result = PingResult
shahshreyaf3076352015-01-23 13:52:01 -08001408 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001409 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001410 actual=case31Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001411 onpass="Point intent related to SDN-IP " +
1412 "matching on ICMP and ping test successful",
1413 onfail="Point intent related to SDN-IP" +
1414 " matching on ICMP and ping test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001415
1416 def CASE32( self ):
1417 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001418 This test case adds point intent related to SDN-IP matching on TCP
1419 ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 )
1420 Note: Although BGP port is 179, we are using 5001 because iperf
1421 is used for verifying and iperf's default port is 5001
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001422 """
shahshreyae6c7cf42014-11-26 16:39:01 -08001423 import json
1424
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001425 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001426 "This test case adds point intent" +
1427 " related to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001428 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001429 "Adding bidirectional point intent related" +
1430 " to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001431 main.step( "Adding bidirectional point intent" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001432 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001433 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1434 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1
1435 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001436
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001437 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1438 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1
1439 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001440
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001441 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1442 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1
1443 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001444
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001445 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1446 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1
1447 of:0000000000003008/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001448
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001449 """
shahshreyaf3076352015-01-23 13:52:01 -08001450 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001451 for i in range( 8, 9 ):
1452 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001453 "Adding point intent between h" + str( i ) +
1454 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001455 host1 = "00:00:00:00:00:" + \
1456 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1457 host2 = "00:00:00:00:00:" + \
1458 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
shahshreyaf3076352015-01-23 13:52:01 -08001459 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1460 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1461 for host in hostsJson:
1462 if host[ 'id' ] == host1Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001463 ip1 = host[ 'ipAddresses' ][ 0 ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001464 ip1 = str( ip1 + "/32" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001465 device1 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001466 device1 = str( device1 + "/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001467 elif host[ 'id' ] == host2Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001468 ip2 = str( host[ 'ipAddresses' ][ 0 ] ) + "/32"
1469 device2 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001470 device2 = str( device2 + "/1" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001471
shahshreyaf3076352015-01-23 13:52:01 -08001472 pIntentResult1 = main.ONOScli1.addPointIntent(
1473 ingressDevice=device1,
1474 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001475 ipSrc=ip1,
1476 ipDst=ip2,
1477 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1478 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1479 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
shahshreyaf3076352015-01-23 13:52:01 -08001480 pIntentResult2 = main.ONOScli1.addPointIntent(
1481 ingressDevice=device2,
1482 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001483 ipSrc=ip2,
1484 ipDst=ip1,
1485 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1486 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1487 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
1488
shahshreyaf3076352015-01-23 13:52:01 -08001489 pIntentResult3 = main.ONOScli1.addPointIntent(
1490 ingressDevice=device1,
1491 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001492 ipSrc=ip1,
1493 ipDst=ip2,
1494 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1495 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1496 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
shahshreyaf3076352015-01-23 13:52:01 -08001497 pIntentResult4 = main.ONOScli1.addPointIntent(
1498 ingressDevice=device2,
1499 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001500 ipSrc=ip2,
1501 ipDst=ip1,
1502 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1503 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1504 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
shahshreyae6c7cf42014-11-26 16:39:01 -08001505
shahshreya234a1682015-05-27 15:41:56 -07001506 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1507 main.log.info( getIntentResult )
1508 pIntentResult = main.TRUE
1509 if getIntentResult:
shahshreyab512cd02015-01-27 17:01:47 -08001510 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001511 "Point intent related to SDN-IP matching" +
1512 " on TCP install successful" )
shahshreyab512cd02015-01-27 17:01:47 -08001513 else:
1514 main.log.report(
1515 "Point intent related to SDN-IP matching" +
1516 " on TCP install failed" )
shahshreya234a1682015-05-27 15:41:56 -07001517 pIntentResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -08001518
shahshreyaf3076352015-01-23 13:52:01 -08001519 iperfResult = main.Mininet1.iperf( 'h8', 'h18' )
1520 if iperfResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001521 main.log.report( "iperf test successful" )
1522 else:
1523 main.log.report( "iperf test failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001524
shahshreyaf3076352015-01-23 13:52:01 -08001525 case32Result = pIntentResult and iperfResult
1526 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001527 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001528 actual=case32Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001529 onpass="Ping all test after Point intents addition related " +
1530 "to SDN-IP on TCP match successful",
1531 onfail="Ping all test after Point intents addition related " +
1532 "to SDN-IP on TCP match failed" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001533
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001534 def CASE33( self ):
1535 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001536 This test case adds multipoint to singlepoint intent related to
1537 SDN-IP matching on destination ip and the action is to rewrite
1538 the mac address
1539 Here the mac address to be rewritten is the mac address of the
1540 egress device
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001541 """
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001542 import json
1543 import time
1544
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001545 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001546 "This test case adds multipoint to singlepoint intent related to" +
1547 " SDN-IP matching on destination ip and " +
1548 "rewrite mac address action" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001549 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001550 "Adding multipoint to singlepoint intent related to SDN-IP" +
1551 " matching on destination ip" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001552 main.step( "Adding bidirectional multipoint to singlepoint intent" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001553 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001554 add-multi-to-single-intent --ipDst=10.0.3.0/24
1555 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1
1556 of:0000000000006018/1
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001557
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001558 add-multi-to-single-intent --ipDst=10.0.1.0/24
1559 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1
1560 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001561 """
1562 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001563 "Installing multipoint to single point " +
1564 "intent with rewrite mac address" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001565 main.step( "Uninstalling proxy arp app" )
shahshreyad524a942015-04-21 09:55:16 -07001566 # deactivating proxyarp app
1567 appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.proxyarp" )
1568 appCheck = main.ONOScli1.appToIDCheck()
1569 if appCheck != main.TRUE:
1570 main.log.warn( main.ONOScli1.apps() )
1571 main.log.warn( main.ONOScli1.appIDs() )
1572 time.sleep( 30 )
1573 main.log.info( "onos-app-proxyarp deactivated" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001574
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001575 main.step( "Changing ipaddress of hosts h8,h9 and h18" )
1576 main.Mininet1.changeIP(
1577 host='h8',
1578 intf='h8-eth0',
1579 newIP='10.0.1.1',
1580 newNetmask='255.255.255.0' )
1581 main.Mininet1.changeIP(
1582 host='h9',
1583 intf='h9-eth0',
1584 newIP='10.0.2.1',
1585 newNetmask='255.255.255.0' )
1586 main.Mininet1.changeIP(
1587 host='h10',
1588 intf='h10-eth0',
1589 newIP='10.0.3.1',
1590 newNetmask='255.255.255.0' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001591
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001592 main.step( "Changing default gateway of hosts h8,h9 and h18" )
1593 main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' )
1594 main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' )
1595 main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001596
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001597 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001598 "Assigning random mac address to the default gateways " +
1599 "since proxyarp app is uninstalled" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001600 main.Mininet1.addStaticMACAddress(
1601 host='h8',
1602 GW='10.0.1.254',
1603 macaddr='00:00:00:00:11:11' )
1604 main.Mininet1.addStaticMACAddress(
1605 host='h9',
1606 GW='10.0.2.254',
1607 macaddr='00:00:00:00:22:22' )
1608 main.Mininet1.addStaticMACAddress(
1609 host='h10',
1610 GW='10.0.3.254',
1611 macaddr='00:00:00:00:33:33' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001612
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001613 main.step( "Verify static gateway and MAC address assignment" )
1614 main.Mininet1.verifyStaticGWandMAC( host='h8' )
1615 main.Mininet1.verifyStaticGWandMAC( host='h9' )
1616 main.Mininet1.verifyStaticGWandMAC( host='h10' )
1617
shahshreyab471a3e2015-03-19 17:07:13 -07001618 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ]
1619 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ]
1620 ingressDeviceList = []
1621 ingressDeviceList.append( ingressDevice1 )
1622 ingressDeviceList.append( ingressDevice2 )
1623
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001624 main.step( "Adding multipoint to singlepoint intent" )
shahshreyaf3076352015-01-23 13:52:01 -08001625 pIntentResult1 = main.ONOScli1.addMultipointToSinglepointIntent(
shahshreyab471a3e2015-03-19 17:07:13 -07001626 ingressDeviceList,
shahshreyaf3076352015-01-23 13:52:01 -08001627 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001628 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
1629 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
1630
shahshreyab471a3e2015-03-19 17:07:13 -07001631 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ]
1632 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ]
1633 ingressDeviceList = [ingressDevice1, ingressDevice2]
1634
shahshreyaf3076352015-01-23 13:52:01 -08001635 pIntentResult2 = main.ONOScli1.addMultipointToSinglepointIntent(
shahshreyab471a3e2015-03-19 17:07:13 -07001636 ingressDeviceList,
shahshreyaf3076352015-01-23 13:52:01 -08001637 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001638 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
1639 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
1640
shahshreyab471a3e2015-03-19 17:07:13 -07001641 pIntentResult = pIntentResult1 and pIntentResult2
1642 if pIntentResult == main.FALSE:
1643 main.log.info(
1644 "Multi point to single point intent " +
1645 "installation failed" )
1646 else:
1647 pIntentResult = main.TRUE
1648 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1649 main.log.info( "intents = " + getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001650
shahshreyab471a3e2015-03-19 17:07:13 -07001651 time.sleep( 10 )
1652 getFlowsResult = main.ONOScli1.flows( jsonFormat=False )
1653 main.log.info( "flows = " + getFlowsResult )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001654
shahshreyab471a3e2015-03-19 17:07:13 -07001655 count = 1
1656 i = 8
1657 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001658
shahshreyab471a3e2015-03-19 17:07:13 -07001659 main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
1660 ping = main.Mininet1.pingHost(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001661 src="h" + str( i ), target="h" + str( i + 2 ) )
shahshreyab471a3e2015-03-19 17:07:13 -07001662 if ping == main.FALSE and count < 3:
1663 count += 1
1664 PingResult = main.FALSE
1665 main.log.report( "Ping between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001666 str( i ) +
1667 " and h" +
1668 str( i +
1669 2 ) +
1670 " failed. Making attempt number " +
1671 str( count ) +
1672 " in 2 seconds" )
shahshreyab471a3e2015-03-19 17:07:13 -07001673 time.sleep( 2 )
1674 elif ping == main.FALSE:
1675 main.log.report( "All ping attempts between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001676 str( i ) +
1677 " and h" +
1678 str( i +
1679 10 ) +
1680 "have failed" )
shahshreyab471a3e2015-03-19 17:07:13 -07001681 PingResult = main.FALSE
1682 elif ping == main.TRUE:
1683 main.log.info( "Ping test between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001684 str( i ) +
1685 " and h" +
1686 str( i +
1687 2 ) +
shahshreyaa47ebf42015-05-20 13:29:18 -07001688 " passed!" )
shahshreyab471a3e2015-03-19 17:07:13 -07001689 PingResult = main.TRUE
1690 else:
1691 main.log.info( "Unknown error" )
1692 PingResult = main.ERROR
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001693
shahshreyab471a3e2015-03-19 17:07:13 -07001694 if PingResult == main.FALSE:
1695 main.log.report( "Ping test failed." )
1696 # main.cleanup()
1697 # main.exit()
1698 if PingResult == main.TRUE:
1699 main.log.report( "Ping all successful" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001700
shahshreyaf3076352015-01-23 13:52:01 -08001701 if pIntentResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001702 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001703 "Multi point intent with rewrite mac " +
shahshreyab471a3e2015-03-19 17:07:13 -07001704 "address installation and ping successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001705
shahshreyaf3076352015-01-23 13:52:01 -08001706 case33Result = pIntentResult and PingResult
1707 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001708 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001709 actual=case33Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001710 onpass="Ping all test after multipoint to single point" +
1711 " intent addition with rewrite mac address successful",
1712 onfail="Ping all test after multipoint to single point intent" +
1713 " addition with rewrite mac address failed" )
shahshreya1f119da2015-04-21 17:16:46 -07001714
1715 def CASE20( self ):
1716 """
1717 Exit from mininet cli
1718 reinstall ONOS
1719 """
shahshreyaa47ebf42015-05-20 13:29:18 -07001720 import time
shahshreya1f119da2015-04-21 17:16:46 -07001721 cellName = main.params[ 'ENV' ][ 'cellName' ]
1722 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
1723 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
1724 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
1725 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
1726 ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
1727 ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
1728
1729 main.log.report( "This testcase exits the mininet cli and reinstalls" +
1730 "ONOS to switch over to Packet Optical topology" )
1731 main.log.report( "_____________________________________________" )
1732 main.case( "Disconnecting mininet and restarting ONOS" )
1733 main.step( "Disconnecting mininet and restarting ONOS" )
1734 mininetDisconnect = main.Mininet1.disconnect()
1735 print "mininetDisconnect = ", mininetDisconnect
1736
1737 main.step( "Removing raft logs before a clen installation of ONOS" )
1738 main.ONOSbench.onosRemoveRaftLogs()
1739
1740 main.step( "Applying cell variable to environment" )
1741 cellResult = main.ONOSbench.setCell( cellName )
1742 verifyResult = main.ONOSbench.verifyCell()
1743
shahshreyaa47ebf42015-05-20 13:29:18 -07001744 time.sleep( 5 )
1745 main.step( "Uninstalling ONOS package" )
1746 onos1UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS1Ip)
1747 onos2UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS2Ip)
1748 onos3UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS3Ip)
1749 onosUninstallResult = onos1UninstallResult and onos2UninstallResult \
1750 and onos3UninstallResult
1751 time.sleep( 15 )
shahshreya1f119da2015-04-21 17:16:46 -07001752 main.step( "Installing ONOS package" )
1753 onos1InstallResult = main.ONOSbench.onosInstall(
1754 options="-f",
1755 node=ONOS1Ip )
1756 onos2InstallResult = main.ONOSbench.onosInstall(
1757 options="-f",
1758 node=ONOS2Ip )
1759 onos3InstallResult = main.ONOSbench.onosInstall(
1760 options="-f",
1761 node=ONOS3Ip )
1762 onosInstallResult = onos1InstallResult and onos2InstallResult and\
1763 onos3InstallResult
1764 if onosInstallResult == main.TRUE:
1765 main.log.report( "Installing ONOS package successful" )
1766 else:
1767 main.log.report( "Installing ONOS package failed" )
1768
shahshreyaa47ebf42015-05-20 13:29:18 -07001769 time.sleep( 10 )
shahshreya1f119da2015-04-21 17:16:46 -07001770 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
1771 onos2Isup = main.ONOSbench.isup( ONOS2Ip )
1772 onos3Isup = main.ONOSbench.isup( ONOS3Ip )
1773 onosIsup = onos1Isup and onos2Isup and onos3Isup
1774 if onosIsup == main.TRUE:
1775 main.log.report( "ONOS instances are up and ready" )
1776 else:
1777 main.log.report( "ONOS instances may not be up" )
1778
1779 main.step( "Starting ONOS service" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001780 time.sleep( 10 )
shahshreya1f119da2015-04-21 17:16:46 -07001781 startResult = main.TRUE
1782 # startResult = main.ONOSbench.onosStart( ONOS1Ip )
1783 startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip )
1784 startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip )
1785 startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip )
1786 startResult = startcli1 and startcli2 and startcli3
1787 if startResult == main.TRUE:
1788 main.log.report( "ONOS cli starts properly" )
1789 case20Result = mininetDisconnect and cellResult and verifyResult \
1790 and onosInstallResult and onosIsup and startResult
1791
1792 utilities.assert_equals(
1793 expect=main.TRUE,
1794 actual=case20Result,
1795 onpass= "Exiting functionality mininet topology and reinstalling" +
1796 " ONOS successful",
1797 onfail= "Exiting functionality mininet topology and reinstalling" +
1798 " ONOS failed" )
1799
1800 def CASE21( self, main ):
1801 """
1802 On ONOS bench, run this command:
1803 sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1 <Ctrls>
1804 which spawns packet optical topology and copies the links
1805 json file to the onos instance.
1806 Note that in case of Packet Optical, the links are not learnt
1807 from the topology, instead the links are learnt
1808 from the json config file
1809 """
1810 main.log.report(
1811 "This testcase starts the packet layer topology and REST" )
1812 main.log.report( "_____________________________________________" )
1813 main.case( "Starting LINC-OE and other components" )
1814 main.step( "Starting LINC-OE and other components" )
1815 main.log.info( "Activate optical app" )
1816 appInstallResult = main.ONOScli1.activateApp( "org.onosproject.optical" )
1817 appCheck = main.ONOScli1.appToIDCheck()
1818 appCheck = appCheck and main.ONOScli2.appToIDCheck()
1819 appCheck = appCheck and main.ONOScli3.appToIDCheck()
1820 if appCheck != main.TRUE:
1821 main.log.warn( "Checking ONOS application unsuccesful" )
1822
1823 ctrllerIP = []
1824 ctrllerIP.append( main.params[ 'CTRL' ][ 'ip1' ] )
1825 #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip2' ] )
1826 #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip3' ] )
1827 opticalMnScript = main.LincOE2.runOpticalMnScript( ctrllerIP = ctrllerIP )
1828 case21Result = opticalMnScript and appInstallResult
1829 utilities.assert_equals(
1830 expect=main.TRUE,
1831 actual=case21Result,
1832 onpass="Packet optical topology spawned successsfully",
1833 onfail="Packet optical topology spawning failed" )
1834
1835 def CASE22( self, main ):
1836 """
1837 Curretly we use, 10 optical switches(ROADM's) and
1838 6 packet layer mininet switches each with one host.
1839 Therefore, the roadmCount variable = 10,
1840 packetLayerSWCount variable = 6, hostCount=6 and
shahshreyaa47ebf42015-05-20 13:29:18 -07001841 links=46.
shahshreya1f119da2015-04-21 17:16:46 -07001842 All this is hardcoded in the testcase. If the topology changes,
1843 these hardcoded values need to be changed
1844 """
shahshreyaa47ebf42015-05-20 13:29:18 -07001845 import time
shahshreya1f119da2015-04-21 17:16:46 -07001846 main.log.report(
1847 "This testcase compares the optical+packet topology against what" +
1848 " is expected" )
1849 main.case( "Topology comparision" )
1850 main.step( "Topology comparision" )
1851 devicesResult = main.ONOScli3.devices( jsonFormat=False )
shahshreyaa47ebf42015-05-20 13:29:18 -07001852 time.sleep( 15 )
shahshreya1f119da2015-04-21 17:16:46 -07001853 print "devices_result = ", devicesResult
1854 devicesLinewise = devicesResult.split( "\n" )
shahshreya1f119da2015-04-21 17:16:46 -07001855 roadmCount = 0
1856 packetLayerSWCount = 0
1857 for line in devicesLinewise:
1858 components = line.split( "," )
1859 availability = components[ 1 ].split( "=" )[ 1 ]
1860 type = components[ 3 ].split( "=" )[ 1 ]
1861 if availability == 'true' and type == 'ROADM':
1862 roadmCount += 1
1863 elif availability == 'true' and type == 'SWITCH':
1864 packetLayerSWCount += 1
1865 if roadmCount == 10:
1866 print "Number of Optical Switches = %d and is" % roadmCount +\
1867 " correctly detected"
1868 main.log.info(
1869 "Number of Optical Switches = " +
1870 str( roadmCount ) +
1871 " and is correctly detected" )
1872 opticalSWResult = main.TRUE
1873 else:
1874 print "Number of Optical Switches = %d and is wrong" % roadmCount
1875 main.log.info(
1876 "Number of Optical Switches = " +
1877 str( roadmCount ) +
1878 " and is wrong" )
1879 opticalSWResult = main.FALSE
1880
1881 if packetLayerSWCount == 6:
1882 print "Number of Packet layer or mininet Switches = %d "\
1883 % packetLayerSWCount + "and is correctly detected"
1884 main.log.info(
1885 "Number of Packet layer or mininet Switches = " +
1886 str( packetLayerSWCount ) +
1887 " and is correctly detected" )
1888 packetSWResult = main.TRUE
1889 else:
1890 print "Number of Packet layer or mininet Switches = %d and"\
1891 % packetLayerSWCount + " is wrong"
1892 main.log.info(
1893 "Number of Packet layer or mininet Switches = " +
1894 str( packetLayerSWCount ) +
1895 " and is wrong" )
1896 packetSWResult = main.FALSE
1897 print "_________________________________"
1898
1899 linksResult = main.ONOScli3.links( jsonFormat=False )
1900 print "links_result = ", linksResult
1901 print "_________________________________"
1902 linkActiveCount = linksResult.count("state=ACTIVE")
1903 main.log.info( "linkActiveCount = " + str( linkActiveCount ))
shahshreyaa47ebf42015-05-20 13:29:18 -07001904 if linkActiveCount == 46:
shahshreya1f119da2015-04-21 17:16:46 -07001905 linkActiveResult = main.TRUE
1906 main.log.info(
1907 "Number of links in ACTIVE state are correct")
1908 else:
1909 linkActiveResult = main.FALSE
1910 main.log.info(
1911 "Number of links in ACTIVE state are wrong")
1912
1913 case22Result = opticalSWResult and packetSWResult and \
1914 linkActiveResult
1915 utilities.assert_equals(
1916 expect=main.TRUE,
1917 actual=case22Result,
1918 onpass="Packet optical topology discovery successful",
1919 onfail="Packet optical topology discovery failed" )
1920
1921 def CASE23( self, main ):
1922 import time
1923 """
1924 Add bidirectional point intents between 2 packet layer( mininet )
1925 devices and
1926 ping mininet hosts
1927 """
1928 main.log.report(
1929 "This testcase adds bidirectional point intents between 2 " +
1930 "packet layer( mininet ) devices and ping mininet hosts" )
1931 main.case( "Topology comparision" )
1932 main.step( "Adding point intents" )
1933 ptpIntentResult = main.ONOScli1.addPointIntent(
1934 "of:0000ffffffff0001/1",
1935 "of:0000ffffffff0005/1" )
1936 if ptpIntentResult == main.TRUE:
1937 main.ONOScli1.intents( jsonFormat=False )
1938 main.log.info( "Point to point intent install successful" )
1939
1940 ptpIntentResult = main.ONOScli1.addPointIntent(
1941 "of:0000ffffffff0005/1",
1942 "of:0000ffffffff0001/1" )
1943 if ptpIntentResult == main.TRUE:
1944 main.ONOScli1.intents( jsonFormat=False )
1945 main.log.info( "Point to point intent install successful" )
1946
1947 time.sleep( 30 )
shahshreyabf739d82015-06-10 11:22:31 -07001948 #flowHandle = main.ONOScli1.flows()
1949 #main.log.info( "flows :" + flowHandle )
shahshreya1f119da2015-04-21 17:16:46 -07001950
1951 # Sleep for 30 seconds to provide time for the intent state to change
1952 time.sleep( 60 )
1953 intentHandle = main.ONOScli1.intents( jsonFormat=False )
1954 main.log.info( "intents :" + intentHandle )
1955
1956 PingResult = main.TRUE
1957 count = 1
1958 main.log.info( "\n\nh1 is Pinging h5" )
1959 ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
1960 # ping = main.LincOE2.pinghost()
1961 if ping == main.FALSE and count < 5:
1962 count += 1
1963 PingResult = main.FALSE
1964 main.log.info(
1965 "Ping between h1 and h5 failed. Making attempt number " +
1966 str( count ) +
1967 " in 2 seconds" )
1968 time.sleep( 2 )
1969 elif ping == main.FALSE:
1970 main.log.info( "All ping attempts between h1 and h5 have failed" )
1971 PingResult = main.FALSE
1972 elif ping == main.TRUE:
1973 main.log.info( "Ping test between h1 and h5 passed!" )
1974 PingResult = main.TRUE
1975 else:
1976 main.log.info( "Unknown error" )
1977 PingResult = main.ERROR
1978
1979 if PingResult == main.FALSE:
1980 main.log.report(
1981 "Point intents for packet optical have not ben installed" +
1982 " correctly. Cleaning up" )
1983 if PingResult == main.TRUE:
1984 main.log.report(
1985 "Point Intents for packet optical have been " +
1986 "installed correctly" )
1987
1988 case23Result = PingResult
1989 utilities.assert_equals(
1990 expect=main.TRUE,
1991 actual=case23Result,
1992 onpass= "Point intents addition for packet optical and" +
1993 "Pingall Test successful",
1994 onfail= "Point intents addition for packet optical and" +
1995 "Pingall Test NOT successful" )
1996
1997 def CASE24( self, main ):
1998 import time
1999 import json
2000 """
2001 LINC uses its own switch IDs. You can use the following
2002 command on the LINC console to find the mapping between
2003 DPIDs and LINC IDs.
2004 rp(application:get_all_key(linc)).
2005
2006 Test Rerouting of Packet Optical by bringing a port down
2007 ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
2008 so that link
2009 ( between switch1 port20 - switch5 port50 ) is inactive
2010 and do a ping test. If rerouting is successful,
2011 ping should pass. also check the flows
2012 """
2013 main.log.report(
2014 "This testcase tests rerouting and pings mininet hosts" )
2015 main.case( "Test rerouting and pings mininet hosts" )
2016 main.step( "Attach to the Linc-OE session" )
2017 attachConsole = main.LincOE1.attachLincOESession()
2018 print "attachConsole = ", attachConsole
2019
2020 main.step( "Bring a port down and verify the link state" )
2021 main.LincOE1.portDown( swId="9", ptId="20" )
2022 linksNonjson = main.ONOScli3.links( jsonFormat=False )
2023 main.log.info( "links = " + linksNonjson )
2024
2025 linkInactiveCount = linksNonjson.count("state=INACTIVE")
2026 main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
2027 if linkInactiveCount == 2:
2028 main.log.info(
2029 "Number of links in INACTIVE state are correct")
2030 else:
2031 main.log.info(
2032 "Number of links in INACTIVE state are wrong")
2033
2034 links = main.ONOScli3.links()
2035 main.log.info( "links = " + links )
2036
2037 linksResult = json.loads( links )
2038 linksStateResult = main.FALSE
2039 for item in linksResult:
2040 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
2041 'src' ][ 'port' ] == "20":
2042 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
2043 'dst' ][ 'port' ] == "50":
2044 linksState = item[ 'state' ]
2045 if linksState == "INACTIVE":
2046 main.log.info(
2047 "Links state is inactive as expected due to one" +
2048 " of the ports being down" )
2049 main.log.report(
2050 "Links state is inactive as expected due to one" +
2051 " of the ports being down" )
2052 linksStateResult = main.TRUE
2053 break
2054 else:
2055 main.log.info(
2056 "Links state is not inactive as expected" )
2057 main.log.report(
2058 "Links state is not inactive as expected" )
2059 linksStateResult = main.FALSE
2060
2061 print "links_state_result = ", linksStateResult
2062 time.sleep( 10 )
shahshreyabf739d82015-06-10 11:22:31 -07002063 #flowHandle = main.ONOScli3.flows()
2064 #main.log.info( "flows :" + flowHandle )
shahshreya1f119da2015-04-21 17:16:46 -07002065
2066 main.step( "Verify Rerouting by a ping test" )
2067 PingResult = main.TRUE
2068 count = 1
2069 main.log.info( "\n\nh1 is Pinging h5" )
2070 ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
2071 # ping = main.LincOE2.pinghost()
2072 if ping == main.FALSE and count < 5:
2073 count += 1
2074 PingResult = main.FALSE
2075 main.log.info(
2076 "Ping between h1 and h5 failed. Making attempt number " +
2077 str( count ) +
2078 " in 2 seconds" )
2079 time.sleep( 2 )
2080 elif ping == main.FALSE:
2081 main.log.info( "All ping attempts between h1 and h5 have failed" )
2082 PingResult = main.FALSE
2083 elif ping == main.TRUE:
2084 main.log.info( "Ping test between h1 and h5 passed!" )
2085 PingResult = main.TRUE
2086 else:
2087 main.log.info( "Unknown error" )
2088 PingResult = main.ERROR
2089
2090 if PingResult == main.TRUE:
2091 main.log.report( "Ping test successful " )
2092 if PingResult == main.FALSE:
2093 main.log.report( "Ping test failed" )
2094
2095 case24Result = PingResult and linksStateResult
2096 utilities.assert_equals( expect=main.TRUE, actual=case24Result,
2097 onpass="Packet optical rerouting successful",
2098 onfail="Packet optical rerouting failed" )