blob: a458dec2f0bcc422ce325866ddcc00b624d4eb0d [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
shahshreya74cca802015-02-26 12:24:01 -080014class MultiProd13:
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 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080046 cellResult1 = main.ONOSbench.setCell( cellName )
47 # cellResult2 = main.ONOScli1.setCell( cellName )
48 # cellResult3 = main.ONOScli2.setCell( cellName )
49 # cellResult4 = main.ONOScli3.setCell( cellName )
50 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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -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" )
77 # 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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080081 onos1InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080082 options="-f",
kelvin-onlabcf33bda2015-01-23 16:54:17 -080083 node=ONOS1Ip )
84 onos2InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080085 options="-f",
kelvin-onlabcf33bda2015-01-23 16:54:17 -080086 node=ONOS2Ip )
87 onos3InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080088 options="-f",
kelvin-onlabcf33bda2015-01-23 16:54:17 -080089 node=ONOS3Ip )
90 onosInstallResult = onos1InstallResult and onos2InstallResult and\
91 onos3InstallResult
92 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
kelvin-onlabcf33bda2015-01-23 16:54:17 -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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800107 startResult = main.TRUE
108 # startResult = main.ONOSbench.onosStart( ONOS1Ip )
109 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
shahshreya1db2e292015-02-05 16:35:32 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -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:
kelvin-onlabcf33bda2015-01-23 16:54:17 -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 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -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 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -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"
kelvin-onlabcf33bda2015-01-23 16:54:17 -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"
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -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 )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800202 main.Mininet1.assignSwController(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800203 sw=str( i ),
204 count=3,
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800212 switchMastership = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800213 for i in range( 1, 29 ):
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800214 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800215 print( "Response is " + str( response ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800216 if re.search( "tcp:" + ONOS1Ip, response ):
217 switchMastership = switchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800218 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800219 switchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800220
kelvin-onlabcf33bda2015-01-23 16:54:17 -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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800235 pingResult = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800236 time1 = time.time()
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800250 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800251 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800258 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
259 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
260 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800261
262 main.log.report(
shahshreyad524a942015-04-21 09:55:16 -0700263 "This testcase is testing if all ONOS nodes are in topology" +
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800264 " sync with mininet and its peer ONOS nodes" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800265 main.log.report( "__________________________________" )
266 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800267 "Testing Mininet topology with the" +
268 " topology of multi instances ONOS" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800269 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800270 devices1 = main.ONOScli1.devices()
271 devices2 = main.ONOScli2.devices()
272 devices3 = main.ONOScli3.devices()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800273 # print "devices1 = ", devices1
274 # print "devices2 = ", devices2
275 # print "devices3 = ", devices3
shahshreya4e13a062014-11-11 16:46:18 -0800276 hosts1 = main.ONOScli1.hosts()
277 hosts2 = main.ONOScli2.hosts()
278 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800279 # print "hosts1 = ", hosts1
280 # print "hosts2 = ", hosts2
281 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800282 ports1 = main.ONOScli1.ports()
283 ports2 = main.ONOScli2.ports()
284 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800285 # print "ports1 = ", ports1
286 # print "ports2 = ", ports2
287 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800288 links1 = main.ONOScli1.links()
289 links2 = main.ONOScli2.links()
290 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800291 # print "links1 = ", links1
292 # print "links2 = ", links2
293 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800294
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800295 print "**************"
296
297 main.step( "Start continuous pings" )
298 main.Mininet2.pingLong(
299 src=main.params[ 'PING' ][ 'source1' ],
300 target=main.params[ 'PING' ][ 'target1' ],
301 pingTime=500 )
302 main.Mininet2.pingLong(
303 src=main.params[ 'PING' ][ 'source2' ],
304 target=main.params[ 'PING' ][ 'target2' ],
305 pingTime=500 )
306 main.Mininet2.pingLong(
307 src=main.params[ 'PING' ][ 'source3' ],
308 target=main.params[ 'PING' ][ 'target3' ],
309 pingTime=500 )
310 main.Mininet2.pingLong(
311 src=main.params[ 'PING' ][ 'source4' ],
312 target=main.params[ 'PING' ][ 'target4' ],
313 pingTime=500 )
314 main.Mininet2.pingLong(
315 src=main.params[ 'PING' ][ 'source5' ],
316 target=main.params[ 'PING' ][ 'target5' ],
317 pingTime=500 )
318 main.Mininet2.pingLong(
319 src=main.params[ 'PING' ][ 'source6' ],
320 target=main.params[ 'PING' ][ 'target6' ],
321 pingTime=500 )
322 main.Mininet2.pingLong(
323 src=main.params[ 'PING' ][ 'source7' ],
324 target=main.params[ 'PING' ][ 'target7' ],
325 pingTime=500 )
326 main.Mininet2.pingLong(
327 src=main.params[ 'PING' ][ 'source8' ],
328 target=main.params[ 'PING' ][ 'target8' ],
329 pingTime=500 )
330 main.Mininet2.pingLong(
331 src=main.params[ 'PING' ][ 'source9' ],
332 target=main.params[ 'PING' ][ 'target9' ],
333 pingTime=500 )
334 main.Mininet2.pingLong(
335 src=main.params[ 'PING' ][ 'source10' ],
336 target=main.params[ 'PING' ][ 'target10' ],
337 pingTime=500 )
338
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800339 main.step( "Compare ONOS Topology to MN Topology" )
Jon Hall5b0120a2015-06-12 17:35:53 -0700340 mnSwitches = main.Mininet1.getSwitches()
341 mnLinks = main.Mininet1.getLinks()
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800342 switchesResults1 = main.Mininet1.compareSwitches(
Jon Hall5b0120a2015-06-12 17:35:53 -0700343 mnSwitches, json.loads( devices1 ), json.loads( ports1 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800344 print "switches_Result1 = ", switchesResults1
345 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
346 onpass="ONOS1 Switches view is correct",
347 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800348
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800349 switchesResults2 = main.Mininet1.compareSwitches(
Jon Hall5b0120a2015-06-12 17:35:53 -0700350 mnSwitches, json.loads( devices2 ), json.loads( ports2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800351 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
352 onpass="ONOS2 Switches view is correct",
353 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800354
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800355 switchesResults3 = main.Mininet1.compareSwitches(
Jon Hall5b0120a2015-06-12 17:35:53 -0700356 mnSwitches, json.loads( devices3 ), json.loads( ports3 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800357 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
358 onpass="ONOS3 Switches view is correct",
359 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800360
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800361 linksResults1 = main.Mininet1.compareLinks(
Jon Hall5b0120a2015-06-12 17:35:53 -0700362 mnSwitches, mnLinks, json.loads( links1 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800363 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
364 onpass="ONOS1 Links view is correct",
365 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800366
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800367 linksResults2 = main.Mininet1.compareLinks(
Jon Hall5b0120a2015-06-12 17:35:53 -0700368 mnSwitches, mnLinks, json.loads( links2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800369 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
370 onpass="ONOS2 Links view is correct",
371 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800372
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800373 linksResults3 = main.Mininet1.compareLinks(
Jon Hall5b0120a2015-06-12 17:35:53 -0700374 mnSwitches, mnLinks, json.loads( links3 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800375 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
376 onpass="ONOS2 Links view is correct",
377 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800378
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800379 topoResult = switchesResults1 and switchesResults2 and\
380 switchesResults3 and linksResults1 and linksResults2 and\
381 linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800382
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800383 if topoResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800384 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800385 "Topology Check Test with mininet" +
386 "and ONOS instances successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800387 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800388 main.log.report(
389 "Topology Check Test with mininet and ONOS instances failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800390
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800391 utilities.assertEquals( expect=main.TRUE, actual=topoResult,
392 onpass="Topology Check Test successful",
393 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800394
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800395 def CASE10( self ):
shahshreya1f119da2015-04-21 17:16:46 -0700396 import time
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800397 main.log.report(
398 "This testcase uninstalls the reactive forwarding app" )
399 main.log.report( "__________________________________" )
400 main.case( "Uninstalling reactive forwarding app" )
401 # Unistall onos-app-fwd app to disable reactive forwarding
shahshreyad524a942015-04-21 09:55:16 -0700402 appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.fwd" )
403 appCheck = main.ONOScli1.appToIDCheck()
404 if appCheck != main.TRUE:
405 main.log.warn( main.ONOScli1.apps() )
406 main.log.warn( main.ONOScli1.appIDs() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800407 main.log.info( "onos-app-fwd uninstalled" )
shahshreyaa9d79f22014-11-18 15:41:29 -0800408
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800409 # After reactive forwarding is disabled,
410 # the reactive flows on switches timeout in 10-15s
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800411 # So sleep for 15s
412 time.sleep( 15 )
shahshreyaa9d79f22014-11-18 15:41:29 -0800413
shahshreyae6c7cf42014-11-26 16:39:01 -0800414 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800415 main.log.info( hosts )
shahshreyad524a942015-04-21 09:55:16 -0700416 case10Result = appInstallResult
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800417 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800418 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800419 actual=case10Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800420 onpass="Reactive forwarding app uninstallation successful",
421 onfail="Reactive forwarding app uninstallation failed" )
shahshreyaa9d79f22014-11-18 15:41:29 -0800422
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800423 def CASE6( self ):
424 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800425 "This testcase is testing the addition of" +
426 " host intents and then doing pingall" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800427 main.log.report( "__________________________________" )
428 main.case( "Obtaining hostsfor adding host intents" )
429 main.step( "Get hosts" )
shahshreyaeac353b2014-11-18 17:19:20 -0800430 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800431 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800432
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800433 main.step( "Get all devices id" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800434 devicesIdList = main.ONOScli1.getAllDevicesId()
435 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -0800436
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800437 # ONOS displays the hosts in hex format
438 # unlike mininet which does in decimal format
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800439 # So take care while adding intents
shahshreya4e13a062014-11-11 16:46:18 -0800440
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800441 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800442 main.step( "Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,
443 h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
444 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:08/-1",
445 "00:00:00:00:00:12/-1" )
446 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:09/-1",
447 "00:00:00:00:00:13/-1" )
448 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0A/-1",
449 "00:00:00:00:00:14/-1" )
450 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0B/-1",
451 "00:00:00:00:00:15/-1" )
452 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0C/-1",
453 "00:00:00:00:00:16/-1" )
454 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0D/-1",
455 "00:00:00:00:00:17/-1" )
456 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0E/-1",
457 "00:00:00:00:00:18/-1" )
458 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0F/-1",
459 "00:00:00:00:00:19/-1" )
460 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:10/-1",
461 "00:00:00:00:00:1A/-1" )
462 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:11/-1",
463 "00:00:00:00:00:1B/-1" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800464 """
shahshreya234a1682015-05-27 15:41:56 -0700465 intentsId = []
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800466 for i in range( 8, 18 ):
467 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800468 "Adding host intent between h" + str( i ) +
469 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800470 host1 = "00:00:00:00:00:" + \
471 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
472 host2 = "00:00:00:00:00:" + \
473 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
474 # NOTE: get host can return None
475 # TODO: handle this
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800476 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
477 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
478 tmpResult = main.ONOScli1.addHostIntent( host1Id, host2Id )
shahshreya234a1682015-05-27 15:41:56 -0700479 intentsId.append( tmpResult )
480
481 checkIntent1 = main.ONOScli1.checkIntentState( intentsId )
482 checkIntent2 = main.ONOScli2.checkIntentState( intentsId )
483 checkIntent3 = main.ONOScli3.checkIntentState( intentsId )
shahshreya4e13a062014-11-11 16:46:18 -0800484
485 flowHandle = main.ONOScli1.flows()
shahshreya234a1682015-05-27 15:41:56 -0700486
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800487 main.log.info( "flows:" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -0800488
489 count = 1
490 i = 8
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800491 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800492 while i < 18:
493 main.log.info(
494 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
495 ping = main.Mininet1.pingHost(
496 src="h" + str( i ), target="h" + str( i + 10 ) )
497 if ping == main.FALSE and count < 5:
498 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800499 # i = 8
500 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800501 main.log.report( "Ping between h" +
502 str( i ) +
503 " and h" +
504 str( i +
505 10 ) +
506 " failed. Making attempt number " +
507 str( count ) +
508 " in 2 seconds" )
509 time.sleep( 2 )
510 elif ping == main.FALSE:
511 main.log.report( "All ping attempts between h" +
512 str( i ) +
513 " and h" +
514 str( i +
515 10 ) +
516 "have failed" )
517 i = 19
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800518 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800519 elif ping == main.TRUE:
520 main.log.info( "Ping test between h" +
521 str( i ) +
522 " and h" +
523 str( i +
524 10 ) +
525 "passed!" )
526 i += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800527 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800528 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800529 main.log.info( "Unknown error" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800530 PingResult = main.ERROR
531 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800532 main.log.report(
533 "Host intents have not ben installed correctly. Cleaning up" )
534 # main.cleanup()
535 # main.exit()
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800536 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800537 main.log.report( "Host intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -0800538
shahshreya234a1682015-05-27 15:41:56 -0700539 checkIntent1 = main.ONOScli1.checkIntentState( intentsId )
540 checkIntent2 = main.ONOScli2.checkIntentState( intentsId )
541 checkIntent3 = main.ONOScli3.checkIntentState( intentsId )
542
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800543 case6Result = PingResult
544 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800545 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800546 actual=case6Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800547 onpass="Host intent addition and Pingall Test successful",
548 onfail="Host intent addition and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800549
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800550 def CASE7( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800551
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800552 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800553
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800554 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800555
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800556 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800557 "This testscase is killing a link to" +
558 " ensure that link discovery is consistent" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800559 main.log.report( "__________________________________" )
560 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800561 "Killing a link to Ensure that Link" +
562 " Discovery is Working Properly" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800563 main.step( "Start continuous pings" )
shahshreya4e13a062014-11-11 16:46:18 -0800564
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800565 main.Mininet2.pingLong(
566 src=main.params[ 'PING' ][ 'source1' ],
567 target=main.params[ 'PING' ][ 'target1' ],
568 pingTime=500 )
569 main.Mininet2.pingLong(
570 src=main.params[ 'PING' ][ 'source2' ],
571 target=main.params[ 'PING' ][ 'target2' ],
572 pingTime=500 )
573 main.Mininet2.pingLong(
574 src=main.params[ 'PING' ][ 'source3' ],
575 target=main.params[ 'PING' ][ 'target3' ],
576 pingTime=500 )
577 main.Mininet2.pingLong(
578 src=main.params[ 'PING' ][ 'source4' ],
579 target=main.params[ 'PING' ][ 'target4' ],
580 pingTime=500 )
581 main.Mininet2.pingLong(
582 src=main.params[ 'PING' ][ 'source5' ],
583 target=main.params[ 'PING' ][ 'target5' ],
584 pingTime=500 )
585 main.Mininet2.pingLong(
586 src=main.params[ 'PING' ][ 'source6' ],
587 target=main.params[ 'PING' ][ 'target6' ],
588 pingTime=500 )
589 main.Mininet2.pingLong(
590 src=main.params[ 'PING' ][ 'source7' ],
591 target=main.params[ 'PING' ][ 'target7' ],
592 pingTime=500 )
593 main.Mininet2.pingLong(
594 src=main.params[ 'PING' ][ 'source8' ],
595 target=main.params[ 'PING' ][ 'target8' ],
596 pingTime=500 )
597 main.Mininet2.pingLong(
598 src=main.params[ 'PING' ][ 'source9' ],
599 target=main.params[ 'PING' ][ 'target9' ],
600 pingTime=500 )
601 main.Mininet2.pingLong(
602 src=main.params[ 'PING' ][ 'source10' ],
603 target=main.params[ 'PING' ][ 'target10' ],
604 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -0800605
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800606 main.step( "Determine the current number of switches and links" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800607 topologyOutput = main.ONOScli1.topology()
608 topologyResult = main.ONOSbench.getTopology( topologyOutput )
shahshreyaa47ebf42015-05-20 13:29:18 -0700609 activeSwitches = topologyResult[ 'devices' ]
610 links = topologyResult[ 'links' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800611 main.log.info(
612 "Currently there are %s switches and %s links" %
613 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -0800614
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800615 main.step( "Kill Link between s3 and s28" )
616 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800617 time.sleep( linkSleep )
618 topologyOutput = main.ONOScli2.topology()
619 LinkDown = main.ONOSbench.checkStatus(
620 topologyOutput, activeSwitches, str(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800621 int( links ) - 2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800622 if LinkDown == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800623 main.log.report( "Link Down discovered properly" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800624 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800625 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800626 actual=LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800627 onpass="Link Down discovered properly",
628 onfail="Link down was not discovered in " +
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800629 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800630 " seconds" )
shahshreya4e13a062014-11-11 16:46:18 -0800631
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800632 main.step( "Bring link between s3 and s28 back up" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800633 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
634 time.sleep( linkSleep )
635 topologyOutput = main.ONOScli2.topology()
636 LinkUp = main.ONOSbench.checkStatus(
637 topologyOutput,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800638 activeSwitches,
639 str( links ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800640 if LinkUp == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800641 main.log.report( "Link up discovered properly" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800642 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800643 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800644 actual=LinkUp,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800645 onpass="Link up discovered properly",
646 onfail="Link up was not discovered in " +
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800647 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800648 " seconds" )
649
650 main.step( "Compare ONOS Topology to MN Topology" )
651 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800652 "Testing Mininet topology with the" +
653 " topology of multi instances ONOS" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800654 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800655 devices1 = main.ONOScli1.devices()
656 devices2 = main.ONOScli2.devices()
657 devices3 = main.ONOScli3.devices()
658 print "devices1 = ", devices1
659 print "devices2 = ", devices2
660 print "devices3 = ", devices3
661 hosts1 = main.ONOScli1.hosts()
662 hosts2 = main.ONOScli2.hosts()
663 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800664 # print "hosts1 = ", hosts1
665 # print "hosts2 = ", hosts2
666 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800667 ports1 = main.ONOScli1.ports()
668 ports2 = main.ONOScli2.ports()
669 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800670 # print "ports1 = ", ports1
671 # print "ports2 = ", ports2
672 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800673 links1 = main.ONOScli1.links()
674 links2 = main.ONOScli2.links()
675 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800676 # print "links1 = ", links1
677 # print "links2 = ", links2
678 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800679
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800680 print "**************"
681
682 main.step( "Start continuous pings" )
683 main.Mininet2.pingLong(
684 src=main.params[ 'PING' ][ 'source1' ],
685 target=main.params[ 'PING' ][ 'target1' ],
686 pingTime=500 )
687 main.Mininet2.pingLong(
688 src=main.params[ 'PING' ][ 'source2' ],
689 target=main.params[ 'PING' ][ 'target2' ],
690 pingTime=500 )
691 main.Mininet2.pingLong(
692 src=main.params[ 'PING' ][ 'source3' ],
693 target=main.params[ 'PING' ][ 'target3' ],
694 pingTime=500 )
695 main.Mininet2.pingLong(
696 src=main.params[ 'PING' ][ 'source4' ],
697 target=main.params[ 'PING' ][ 'target4' ],
698 pingTime=500 )
699 main.Mininet2.pingLong(
700 src=main.params[ 'PING' ][ 'source5' ],
701 target=main.params[ 'PING' ][ 'target5' ],
702 pingTime=500 )
703 main.Mininet2.pingLong(
704 src=main.params[ 'PING' ][ 'source6' ],
705 target=main.params[ 'PING' ][ 'target6' ],
706 pingTime=500 )
707 main.Mininet2.pingLong(
708 src=main.params[ 'PING' ][ 'source7' ],
709 target=main.params[ 'PING' ][ 'target7' ],
710 pingTime=500 )
711 main.Mininet2.pingLong(
712 src=main.params[ 'PING' ][ 'source8' ],
713 target=main.params[ 'PING' ][ 'target8' ],
714 pingTime=500 )
715 main.Mininet2.pingLong(
716 src=main.params[ 'PING' ][ 'source9' ],
717 target=main.params[ 'PING' ][ 'target9' ],
718 pingTime=500 )
719 main.Mininet2.pingLong(
720 src=main.params[ 'PING' ][ 'source10' ],
721 target=main.params[ 'PING' ][ 'target10' ],
722 pingTime=500 )
723
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800724 main.step( "Compare ONOS Topology to MN Topology" )
725
Jon Hall5b0120a2015-06-12 17:35:53 -0700726 mnSwitches = main.Mininet1.getSwitches()
727 mnLinks = main.Mininet1.getLinks()
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800728 switchesResults1 = main.Mininet1.compareSwitches(
Jon Hall5b0120a2015-06-12 17:35:53 -0700729 mnSwitches, json.loads( devices1 ), json.loads( ports1 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800730 print "switches_Result1 = ", switchesResults1
731 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
732 onpass="ONOS1 Switches view is correct",
733 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800734
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800735 switchesResults2 = main.Mininet1.compareSwitches(
Jon Hall5b0120a2015-06-12 17:35:53 -0700736 mnSwitches, json.loads( devices1 ), json.loads( ports1 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800737 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
738 onpass="ONOS2 Switches view is correct",
739 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800740
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800741 switchesResults3 = main.Mininet1.compareSwitches(
Jon Hall5b0120a2015-06-12 17:35:53 -0700742 mnSwitches, json.loads( devices1 ), json.loads( ports1 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800743 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
744 onpass="ONOS3 Switches view is correct",
745 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800746
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800747 linksResults1 = main.Mininet1.compareLinks(
Jon Hall5b0120a2015-06-12 17:35:53 -0700748 mnSwitches, mnLinks, json.loads( links1 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800749 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
750 onpass="ONOS1 Links view is correct",
751 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800752
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800753 linksResults2 = main.Mininet1.compareLinks(
Jon Hall5b0120a2015-06-12 17:35:53 -0700754 mnSwitches, mnLinks, json.loads( links2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800755 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
756 onpass="ONOS2 Links view is correct",
757 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800758
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800759 linksResults3 = main.Mininet1.compareLinks(
Jon Hall5b0120a2015-06-12 17:35:53 -0700760 mnSwitches, mnLinks, json.loads( links3 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800761 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
762 onpass="ONOS2 Links view is correct",
763 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800764
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800765 topoResult = switchesResults1 and switchesResults2\
766 and switchesResults3 and linksResults1 and\
767 linksResults2 and linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800768
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800769 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800770 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800771 actual=topoResult and LinkUp and LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800772 onpass="Topology Check Test successful",
773 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800774
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800775 def CASE8( self ):
776 """
shahshreyaeac353b2014-11-18 17:19:20 -0800777 Intent removal
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800778 """
779 main.log.report(
shahshreyab512cd02015-01-27 17:01:47 -0800780 "This testcase removes any previously added intents" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800781 main.log.report( "__________________________________" )
782 main.log.info( "Removing any previously installed intents" )
783 main.case( "Removing intents" )
784 main.step( "Obtain the intent id's" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800785 intentResult = main.ONOScli1.intents( jsonFormat=False )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800786
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800787 intentLinewise = intentResult.split( "\n" )
shahshreyaa9d79f22014-11-18 15:41:29 -0800788 intentList = []
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800789 for line in intentLinewise:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800790 if line.startswith( "id=" ):
791 intentList.append( line )
shahshreyaa9d79f22014-11-18 15:41:29 -0800792
793 intentids = []
794 for line in intentList:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800795 intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
shahshreya4e13a062014-11-11 16:46:18 -0800796 for id in intentids:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800797 main.log.info( "id = " + id )
shahshreyaa9d79f22014-11-18 15:41:29 -0800798
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800799 main.step(
800 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -0800801 for id in intentids:
shahshreyaa47ebf42015-05-20 13:29:18 -0700802 main.ONOScli1.removeIntent( intentId=id ,purge=True )
shahshreyaa9d79f22014-11-18 15:41:29 -0800803
shahshreya234a1682015-05-27 15:41:56 -0700804 remainingIntent = main.ONOScli1.intents( jsonFormat=False )
805 main.log.info( "Remaining intents " + remainingIntent )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800806
shahshreya234a1682015-05-27 15:41:56 -0700807 case8Result = main.TRUE
808 intentResult = main.TRUE
809 if remainingIntent:
810 main.log.error( "There are still remaining intent" )
811 intentResult = main.FALSE
shahshreyaeac353b2014-11-18 17:19:20 -0800812 i = 8
shahshreya234a1682015-05-27 15:41:56 -0700813
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800814 PingResult = main.TRUE
shahshreya234a1682015-05-27 15:41:56 -0700815 """
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800816 while i < 18:
817 main.log.info(
818 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
819 ping = main.Mininet1.pingHost(
820 src="h" + str( i ), target="h" + str( i + 10 ) )
821 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -0800822 i = 19
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800823 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800824 elif ping == main.FALSE:
825 i += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800826 PingResult = main.FALSE
shahshreyaeac353b2014-11-18 17:19:20 -0800827 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800828 main.log.info( "Unknown error" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800829 PingResult = main.ERROR
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800830 # Note: If the ping result failed, that means the intents have been
831 # withdrawn correctly.
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800832 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800833 main.log.report( "Host intents have not been withdrawn correctly" )
834 # main.cleanup()
835 # main.exit()
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800836 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800837 main.log.report( "Host intents have been withdrawn correctly" )
shahshreya234a1682015-05-27 15:41:56 -0700838 """
839 case8Result = intentResult
shahshreyaeac353b2014-11-18 17:19:20 -0800840
shahshreya234a1682015-05-27 15:41:56 -0700841 if case8Result == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800842 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800843 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800844 main.log.report( "Intent removal failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800845
shahshreya234a1682015-05-27 15:41:56 -0700846 utilities.assertEquals( expect=main.TRUE, actual=case8Result,
847 onpass="Intent removal test successful",
848 onfail="Intent removal test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800849
850 def CASE9( self ):
851 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800852 This test case adds point intents. Make sure you run test case 8
853 which is host intent removal before executing this test case.
854 Else the host intent's flows will persist on switches and the pings
855 would work even if there is some issue with the point intent's flows
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800856 """
857 main.log.report(
858 "This testcase adds point intents and then does pingall" )
859 main.log.report( "__________________________________" )
860 main.log.info( "Adding point intents" )
861 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800862 "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20," +
863 "h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800864 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800865 "Add point-to-point intents for mininet hosts" +
866 " h8 and h18 or ONOS hosts h8 and h12" )
shahshreyaa47ebf42015-05-20 13:29:18 -0700867 macsDict = {}
868 for i in range( 1,29 ):
869 macsDict[ 'h' + str( i ) ]= main.Mininet1.getMacAddress( host='h'+ str( i ) )
870 print macsDict
871 # main.step(var1)
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800872 ptpIntentResult = main.ONOScli1.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -0700873 ingressDevice="of:0000000000003008/1",
874 egressDevice="of:0000000000006018/1",
875 ethType='IPV4',
876 ethSrc=macsDict.get( 'h8' ))
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800877 if ptpIntentResult == main.TRUE:
878 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800879 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800880 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800881
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800882 ptpIntentResult = main.ONOScli1.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -0700883 ingressDevice="of:0000000000006018/1",
884 egressDevice="of:0000000000003008/1",
885 ethType='IPV4',
886 ethSrc=macsDict.get( 'h18' ))
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800887 if ptpIntentResult == main.TRUE:
888 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800889 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800890 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800891
shahshreyaa47ebf42015-05-20 13:29:18 -0700892 var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
893 main.step(var2)
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800894 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800895 "of:0000000000003009/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700896 "of:0000000000006019/1",
897 ethType='IPV4',
898 ethSrc=macsDict.get( 'h9' ))
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800899 if ptpIntentResult == main.TRUE:
900 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800901 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800902 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800903
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800904 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800905 "of:0000000000006019/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700906 "of:0000000000003009/1",
907 ethType='IPV4',
908 ethSrc=macsDict.get( 'h19' ))
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800909 if ptpIntentResult == main.TRUE:
910 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800911 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800912 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800913
shahshreyaa47ebf42015-05-20 13:29:18 -0700914 var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
915 main.step(var3)
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800916 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800917 "of:0000000000003010/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700918 "of:0000000000006020/1",
919 ethType='IPV4',
920 ethSrc=macsDict.get( 'h10' ))
921
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800922 if ptpIntentResult == main.TRUE:
923 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800924 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800925 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800926
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800927 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800928 "of:0000000000006020/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700929 "of:0000000000003010/1",
930 ethType='IPV4',
931 ethSrc=macsDict.get( 'h20' ))
932
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800933 if ptpIntentResult == main.TRUE:
934 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800935 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800936 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800937
shahshreyaa47ebf42015-05-20 13:29:18 -0700938 var4 = "Add point intents for mininet hosts h11 and h21 or" +\
939 " ONOS hosts hB and h15"
940 main.case(var4)
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800941 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800942 "of:0000000000003011/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700943 "of:0000000000006021/1",
944 ethType='IPV4',
945 ethSrc=macsDict.get( 'h11' ))
946
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800947 if ptpIntentResult == main.TRUE:
948 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800949 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800950 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800951
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800952 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800953 "of:0000000000006021/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700954 "of:0000000000003011/1",
955 ethType='IPV4',
956 ethSrc=macsDict.get( 'h21' ))
957
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800958 if ptpIntentResult == main.TRUE:
959 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800960 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800961 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800962
shahshreyaa47ebf42015-05-20 13:29:18 -0700963 var5 = "Add point intents for mininet hosts h12 and h22 " +\
964 "ONOS hosts hC and h16"
965 main.case(var5)
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800966 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800967 "of:0000000000003012/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700968 "of:0000000000006022/1",
969 ethType='IPV4',
970 ethSrc=macsDict.get( 'h12' ))
971
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800972 if ptpIntentResult == main.TRUE:
973 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800974 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800975 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800976
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800977 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800978 "of:0000000000006022/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700979 "of:0000000000003012/1",
980 ethType='IPV4',
981 ethSrc=macsDict.get( 'h22' ))
982
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800983 if ptpIntentResult == main.TRUE:
984 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800985 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800986 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800987
shahshreyaa47ebf42015-05-20 13:29:18 -0700988 var6 = "Add point intents for mininet hosts h13 and h23 or" +\
989 " ONOS hosts hD and h17"
990 main.case(var6)
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800991 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800992 "of:0000000000003013/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700993 "of:0000000000006023/1",
994 ethType='IPV4',
995 ethSrc=macsDict.get( 'h13' ))
996
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800997 if ptpIntentResult == main.TRUE:
998 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800999 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001000 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001001
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001002 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001003 "of:0000000000006023/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001004 "of:0000000000003013/1",
1005 ethType='IPV4',
1006 ethSrc=macsDict.get( 'h23' ))
1007
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001008 if ptpIntentResult == main.TRUE:
1009 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001010 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001011 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001012
shahshreyaa47ebf42015-05-20 13:29:18 -07001013 var7 = "Add point intents for mininet hosts h14 and h24 or" +\
1014 " ONOS hosts hE and h18"
1015 main.case(var7)
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001016 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001017 "of:0000000000003014/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001018 "of:0000000000006024/1",
1019 ethType='IPV4',
1020 ethSrc=macsDict.get( 'h14' ))
1021
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001022 if ptpIntentResult == main.TRUE:
1023 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001024 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001025 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001026
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001027 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001028 "of:0000000000006024/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001029 "of:0000000000003014/1",
1030 ethType='IPV4',
1031 ethSrc=macsDict.get( 'h24' ))
1032
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001033 if ptpIntentResult == main.TRUE:
1034 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001035 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001036 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001037
shahshreyaa47ebf42015-05-20 13:29:18 -07001038 var8 = "Add point intents for mininet hosts h15 and h25 or" +\
1039 " ONOS hosts hF and h19"
1040 main.case(var8)
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001041 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001042 "of:0000000000003015/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001043 "of:0000000000006025/1",
1044 ethType='IPV4',
1045 ethSrc=macsDict.get( 'h15' ))
1046
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001047 if ptpIntentResult == main.TRUE:
1048 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001049 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001050 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001051
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001052 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001053 "of:0000000000006025/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001054 "of:0000000000003015/1",
1055 ethType='IPV4',
1056 ethSrc=macsDict.get( 'h25' ))
1057
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001058 if ptpIntentResult == main.TRUE:
1059 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001060 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001061 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001062
shahshreyaa47ebf42015-05-20 13:29:18 -07001063 var9 = "Add intents for mininet hosts h16 and h26 or" +\
1064 " ONOS hosts h10 and h1A"
1065 main.case(var9)
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001066 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001067 "of:0000000000003016/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001068 "of:0000000000006026/1",
1069 ethType='IPV4',
1070 ethSrc=macsDict.get( 'h16' ))
1071
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001072 if ptpIntentResult == main.TRUE:
1073 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001074 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001075 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001076
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001077 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001078 "of:0000000000006026/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001079 "of:0000000000003016/1",
1080 ethType='IPV4',
1081 ethSrc=macsDict.get( 'h26' ))
1082
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001083 if ptpIntentResult == main.TRUE:
1084 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001085 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001086 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001087
shahshreyaa47ebf42015-05-20 13:29:18 -07001088 var10 = "Add point intents for mininet hosts h17 and h27 or" +\
1089 " ONOS hosts h11 and h1B"
1090 main.case(var10)
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001091 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001092 "of:0000000000003017/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001093 "of:0000000000006027/1",
1094 ethType='IPV4',
1095 ethSrc=macsDict.get( 'h17' ))
1096
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001097 if ptpIntentResult == main.TRUE:
1098 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001099 main.log.info( "Point to point intent install successful" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001100 #main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001101
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001102 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001103 "of:0000000000006027/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001104 "of:0000000000003017/1",
1105 ethType='IPV4',
1106 ethSrc=macsDict.get( 'h27' ))
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001107
1108 print(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001109 "_______________________________________________________" +
1110 "________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001111
1112 flowHandle = main.ONOScli1.flows()
shahshreyabf739d82015-06-10 11:22:31 -07001113 print "flowHandle = ", flowHandle
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001114 main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001115
1116 count = 1
1117 i = 8
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001118 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001119 while i < 18:
1120 main.log.info(
1121 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1122 ping = main.Mininet1.pingHost(
1123 src="h" + str( i ), target="h" + str( i + 10 ) )
1124 if ping == main.FALSE and count < 5:
1125 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001126 # i = 8
1127 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001128 main.log.report( "Ping between h" +
1129 str( i ) +
1130 " and h" +
1131 str( i +
1132 10 ) +
1133 " failed. Making attempt number " +
1134 str( count ) +
1135 " in 2 seconds" )
1136 time.sleep( 2 )
1137 elif ping == main.FALSE:
1138 main.log.report( "All ping attempts between h" +
1139 str( i ) +
1140 " and h" +
1141 str( i +
1142 10 ) +
1143 "have failed" )
1144 i = 19
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001145 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001146 elif ping == main.TRUE:
1147 main.log.info( "Ping test between h" +
1148 str( i ) +
1149 " and h" +
1150 str( i +
1151 10 ) +
1152 "passed!" )
1153 i += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001154 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001155 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001156 main.log.info( "Unknown error" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001157 PingResult = main.ERROR
1158 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001159 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001160 "Ping all test after Point intents" +
1161 " addition failed. Cleaning up" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001162 # main.cleanup()
1163 # main.exit()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001164 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001165 main.log.report(
1166 "Ping all test after Point intents addition successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001167
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001168 case8Result = PingResult
1169 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001170 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001171 actual=case8Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001172 onpass="Ping all test after Point intents addition successful",
1173 onfail="Ping all test after Point intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001174
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001175 def CASE31( self ):
1176 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001177 This test case adds point intent related to
1178 SDN-IP matching on ICMP ( ethertype=IPV4, ipProto=1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001179 """
shahshreyaa9d79f22014-11-18 15:41:29 -08001180 import json
1181
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001182 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001183 "This test case adds point intent " +
1184 "related to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001185 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001186 "Adding bidirectional point intent related" +
1187 " to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001188 main.step( "Adding bidirectional point intent" )
1189 # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1190 # --ethType=IPV4 --ipProto=1 of:0000000000003008/1
1191 # of:0000000000006018/1
1192
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001193 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001194 for i in range( 8, 11 ):
1195 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001196 "Adding point intent between h" + str( i ) +
1197 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001198 host1 = "00:00:00:00:00:" + \
1199 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1200 host2 = "00:00:00:00:00:" + \
1201 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001202 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1203 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1204 for host in hostsJson:
1205 if host[ 'id' ] == host1Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001206 ip1 = host[ 'ipAddresses' ][ 0 ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001207 ip1 = str( ip1 + "/32" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001208 device1 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001209 device1 = str( device1 + "/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001210 elif host[ 'id' ] == host2Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001211 ip2 = str( host[ 'ipAddresses' ][ 0 ] ) + "/32"
1212 device2 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001213 device2 = str( device2 + "/1" )
1214
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001215 pIntentResult1 = main.ONOScli1.addPointIntent(
1216 ingressDevice=device1,
1217 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001218 ipSrc=ip1,
1219 ipDst=ip2,
1220 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
shahshreyaa47ebf42015-05-20 13:29:18 -07001221 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ], )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001222
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001223 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1224 main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001225
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001226 pIntentResult2 = main.ONOScli1.addPointIntent(
1227 ingressDevice=device2,
1228 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001229 ipSrc=ip2,
1230 ipDst=ip1,
1231 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1232 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1233
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001234 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1235 main.log.info( getIntentResult )
shahshreyaa47ebf42015-05-20 13:29:18 -07001236 if ( pIntentResult1 and pIntentResult2 ) :
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001237 # getIntentResult = main.ONOScli1.intents()
1238 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001239 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001240 "Point intent related to SDN-IP matching" +
1241 " on ICMP install successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001242
1243 time.sleep( 15 )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001244 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1245 main.log.info( "intents = " + getIntentResult )
1246 getFlowsResult = main.ONOScli1.flows()
1247 main.log.info( "flows = " + getFlowsResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001248
shahshreyae6c7cf42014-11-26 16:39:01 -08001249 count = 1
1250 i = 8
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001251 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001252 while i < 11:
1253 main.log.info(
1254 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1255 ping = main.Mininet1.pingHost(
1256 src="h" + str( i ), target="h" + str( i + 10 ) )
1257 if ping == main.FALSE and count < 3:
1258 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001259 # i = 8
1260 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001261 main.log.report( "Ping between h" +
1262 str( i ) +
1263 " and h" +
1264 str( i +
1265 10 ) +
1266 " failed. Making attempt number " +
1267 str( count ) +
1268 " in 2 seconds" )
1269 time.sleep( 2 )
1270 elif ping == main.FALSE:
1271 main.log.report( "All ping attempts between h" +
1272 str( i ) +
1273 " and h" +
1274 str( i +
1275 10 ) +
1276 "have failed" )
1277 i = 19
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001278 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001279 elif ping == main.TRUE:
1280 main.log.info( "Ping test between h" +
1281 str( i ) +
1282 " and h" +
1283 str( i +
1284 10 ) +
1285 "passed!" )
1286 i += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001287 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -08001288 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001289 main.log.info( "Unknown error" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001290 PingResult = main.ERROR
1291 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001292 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001293 "Ping test after Point intents related to" +
1294 " SDN-IP matching on ICMP failed." )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001295 # main.cleanup()
1296 # main.exit()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001297 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001298 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001299 "Ping all test after Point intents related to" +
1300 " SDN-IP matching on ICMP successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001301
shahshreyaa47ebf42015-05-20 13:29:18 -07001302 case31Result = PingResult
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001303 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001304 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001305 actual=case31Result,
1306 onpass="Point intent related to SDN-IP " +
1307 "matching on ICMP and ping test successful",
1308 onfail="Point intent related to SDN-IP" +
1309 " matching on ICMP and ping test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001310
1311 def CASE32( self ):
1312 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001313 This test case adds point intent related to SDN-IP matching on TCP
1314 ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 )
1315 Note: Although BGP port is 179, we are using 5001 because iperf
1316 is used for verifying and iperf's default port is 5001
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001317 """
shahshreyae6c7cf42014-11-26 16:39:01 -08001318 import json
1319
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001320 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001321 "This test case adds point intent" +
1322 " related to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001323 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001324 "Adding bidirectional point intent related" +
1325 " to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001326 main.step( "Adding bidirectional point intent" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001327 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001328 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1329 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1
1330 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001331
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001332 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1333 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1
1334 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001335
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001336 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1337 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1
1338 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001339
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001340 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1341 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1
1342 of:0000000000003008/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001343
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001344 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001345 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001346 for i in range( 8, 9 ):
1347 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001348 "Adding point intent between h" + str( i ) +
1349 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001350 host1 = "00:00:00:00:00:" + \
1351 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1352 host2 = "00:00:00:00:00:" + \
1353 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001354 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1355 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1356 for host in hostsJson:
1357 if host[ 'id' ] == host1Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001358 ip1 = host[ 'ipAddresses' ][ 0 ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001359 ip1 = str( ip1 + "/32" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001360 device1 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001361 device1 = str( device1 + "/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001362 elif host[ 'id' ] == host2Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001363 ip2 = str( host[ 'ipAddresses' ][ 0 ] ) + "/32"
1364 device2 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001365 device2 = str( device2 + "/1" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001366
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001367 pIntentResult1 = main.ONOScli1.addPointIntent(
1368 ingressDevice=device1,
1369 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001370 ipSrc=ip1,
1371 ipDst=ip2,
1372 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1373 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1374 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001375 pIntentResult2 = main.ONOScli1.addPointIntent(
1376 ingressDevice=device2,
1377 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001378 ipSrc=ip2,
1379 ipDst=ip1,
1380 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1381 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1382 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
1383
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001384 pIntentResult3 = main.ONOScli1.addPointIntent(
1385 ingressDevice=device1,
1386 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001387 ipSrc=ip1,
1388 ipDst=ip2,
1389 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1390 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1391 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001392 pIntentResult4 = main.ONOScli1.addPointIntent(
1393 ingressDevice=device2,
1394 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001395 ipSrc=ip2,
1396 ipDst=ip1,
1397 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1398 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1399 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
shahshreyae6c7cf42014-11-26 16:39:01 -08001400
shahshreya234a1682015-05-27 15:41:56 -07001401 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1402 main.log.info( getIntentResult )
1403 pIntentResult = main.TRUE
1404 if getIntentResult:
shahshreyab512cd02015-01-27 17:01:47 -08001405 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001406 "Point intent related to SDN-IP matching" +
1407 " on TCP install successful" )
shahshreyab512cd02015-01-27 17:01:47 -08001408 else:
1409 main.log.report(
1410 "Point intent related to SDN-IP matching" +
1411 " on TCP install failed" )
shahshreya234a1682015-05-27 15:41:56 -07001412 pIntentResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -08001413
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001414 iperfResult = main.Mininet1.iperf( 'h8', 'h18' )
1415 if iperfResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001416 main.log.report( "iperf test successful" )
1417 else:
1418 main.log.report( "iperf test failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001419
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001420 case32Result = pIntentResult and iperfResult
1421 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001422 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001423 actual=case32Result,
1424 onpass="Ping all test after Point intents addition related " +
1425 "to SDN-IP on TCP match successful",
1426 onfail="Ping all test after Point intents addition related " +
1427 "to SDN-IP on TCP match failed" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001428
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001429 def CASE33( self ):
1430 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001431 This test case adds multipoint to singlepoint intent related to
1432 SDN-IP matching on destination ip and the action is to rewrite
1433 the mac address
1434 Here the mac address to be rewritten is the mac address of the
1435 egress device
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001436 """
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001437 import json
1438 import time
1439
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001440 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001441 "This test case adds multipoint to singlepoint intent related to" +
1442 " SDN-IP matching on destination ip and " +
1443 "rewrite mac address action" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001444 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001445 "Adding multipoint to singlepoint intent related to SDN-IP" +
1446 " matching on destination ip" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001447 main.step( "Adding bidirectional multipoint to singlepoint intent" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001448 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001449 add-multi-to-single-intent --ipDst=10.0.3.0/24
1450 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1
1451 of:0000000000006018/1
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001452
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001453 add-multi-to-single-intent --ipDst=10.0.1.0/24
1454 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1
1455 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001456 """
1457 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001458 "Installing multipoint to single point " +
1459 "intent with rewrite mac address" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001460 main.step( "Uninstalling proxy arp app" )
shahshreyad524a942015-04-21 09:55:16 -07001461 # deactivating proxyarp app
1462 appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.proxyarp" )
1463 appCheck = main.ONOScli1.appToIDCheck()
1464 if appCheck != main.TRUE:
1465 main.log.warn( main.ONOScli1.apps() )
1466 main.log.warn( main.ONOScli1.appIDs() )
1467 time.sleep( 30 )
1468 main.log.info( "onos-app-proxyarp deactivated" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001469
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001470 main.step( "Changing ipaddress of hosts h8,h9 and h18" )
1471 main.Mininet1.changeIP(
1472 host='h8',
1473 intf='h8-eth0',
1474 newIP='10.0.1.1',
1475 newNetmask='255.255.255.0' )
1476 main.Mininet1.changeIP(
1477 host='h9',
1478 intf='h9-eth0',
1479 newIP='10.0.2.1',
1480 newNetmask='255.255.255.0' )
1481 main.Mininet1.changeIP(
1482 host='h10',
1483 intf='h10-eth0',
1484 newIP='10.0.3.1',
1485 newNetmask='255.255.255.0' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001486
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001487 main.step( "Changing default gateway of hosts h8,h9 and h18" )
1488 main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' )
1489 main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' )
1490 main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001491
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001492 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001493 "Assigning random mac address to the default gateways " +
1494 "since proxyarp app is uninstalled" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001495 main.Mininet1.addStaticMACAddress(
1496 host='h8',
1497 GW='10.0.1.254',
1498 macaddr='00:00:00:00:11:11' )
1499 main.Mininet1.addStaticMACAddress(
1500 host='h9',
1501 GW='10.0.2.254',
1502 macaddr='00:00:00:00:22:22' )
1503 main.Mininet1.addStaticMACAddress(
1504 host='h10',
1505 GW='10.0.3.254',
1506 macaddr='00:00:00:00:33:33' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001507
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001508 main.step( "Verify static gateway and MAC address assignment" )
1509 main.Mininet1.verifyStaticGWandMAC( host='h8' )
1510 main.Mininet1.verifyStaticGWandMAC( host='h9' )
1511 main.Mininet1.verifyStaticGWandMAC( host='h10' )
1512
shahshreyab471a3e2015-03-19 17:07:13 -07001513 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ]
1514 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ]
1515 ingressDeviceList = []
1516 ingressDeviceList.append( ingressDevice1 )
1517 ingressDeviceList.append( ingressDevice2 )
1518
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001519 main.step( "Adding multipoint to singlepoint intent" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001520 pIntentResult1 = main.ONOScli1.addMultipointToSinglepointIntent(
shahshreyab471a3e2015-03-19 17:07:13 -07001521 ingressDeviceList,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001522 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001523 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
1524 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
1525
shahshreyab471a3e2015-03-19 17:07:13 -07001526 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ]
1527 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ]
1528 ingressDeviceList = [ingressDevice1, ingressDevice2]
1529
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001530 pIntentResult2 = main.ONOScli1.addMultipointToSinglepointIntent(
shahshreyab471a3e2015-03-19 17:07:13 -07001531 ingressDeviceList,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001532 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001533 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
1534 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
1535
shahshreyab471a3e2015-03-19 17:07:13 -07001536 pIntentResult = pIntentResult1 and pIntentResult2
1537 if pIntentResult == main.FALSE:
1538 main.log.info(
1539 "Multi point to single point intent " +
1540 "installation failed" )
1541 else:
1542 pIntentResult = main.TRUE
1543 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1544 main.log.info( "intents = " + getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001545
shahshreyab471a3e2015-03-19 17:07:13 -07001546 time.sleep( 10 )
1547 getFlowsResult = main.ONOScli1.flows( jsonFormat=False )
1548 main.log.info( "flows = " + getFlowsResult )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001549
shahshreyab471a3e2015-03-19 17:07:13 -07001550 count = 1
1551 i = 8
1552 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001553
shahshreyab471a3e2015-03-19 17:07:13 -07001554 main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
1555 ping = main.Mininet1.pingHost(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001556 src="h" + str( i ), target="h" + str( i + 2 ) )
shahshreyab471a3e2015-03-19 17:07:13 -07001557 if ping == main.FALSE and count < 3:
1558 count += 1
1559 PingResult = main.FALSE
1560 main.log.report( "Ping between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001561 str( i ) +
1562 " and h" +
1563 str( i +
1564 2 ) +
1565 " failed. Making attempt number " +
1566 str( count ) +
1567 " in 2 seconds" )
shahshreyab471a3e2015-03-19 17:07:13 -07001568 time.sleep( 2 )
1569 elif ping == main.FALSE:
1570 main.log.report( "All ping attempts between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001571 str( i ) +
1572 " and h" +
1573 str( i +
1574 10 ) +
1575 "have failed" )
shahshreyab471a3e2015-03-19 17:07:13 -07001576 PingResult = main.FALSE
1577 elif ping == main.TRUE:
1578 main.log.info( "Ping test between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001579 str( i ) +
1580 " and h" +
1581 str( i +
1582 2 ) +
shahshreyaa47ebf42015-05-20 13:29:18 -07001583 " passed!" )
shahshreyab471a3e2015-03-19 17:07:13 -07001584 PingResult = main.TRUE
1585 else:
1586 main.log.info( "Unknown error" )
1587 PingResult = main.ERROR
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001588
shahshreyab471a3e2015-03-19 17:07:13 -07001589 if PingResult == main.FALSE:
1590 main.log.report( "Ping test failed." )
1591 # main.cleanup()
1592 # main.exit()
1593 if PingResult == main.TRUE:
1594 main.log.report( "Ping all successful" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001595
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001596 if pIntentResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001597 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001598 "Multi point intent with rewrite mac " +
shahshreyab471a3e2015-03-19 17:07:13 -07001599 "address installation and ping successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001600
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001601 case33Result = pIntentResult and PingResult
1602 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001603 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001604 actual=case33Result,
1605 onpass="Ping all test after multipoint to single point" +
1606 " intent addition with rewrite mac address successful",
1607 onfail="Ping all test after multipoint to single point intent" +
1608 " addition with rewrite mac address failed" )
shahshreya1f119da2015-04-21 17:16:46 -07001609
1610 def CASE20( self ):
1611 """
1612 Exit from mininet cli
1613 reinstall ONOS
1614 """
shahshreyaa47ebf42015-05-20 13:29:18 -07001615 import time
shahshreya1f119da2015-04-21 17:16:46 -07001616 cellName = main.params[ 'ENV' ][ 'cellName' ]
1617 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
1618 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
1619 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
1620 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
1621 ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
1622 ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
1623
1624 main.log.report( "This testcase exits the mininet cli and reinstalls" +
1625 "ONOS to switch over to Packet Optical topology" )
1626 main.log.report( "_____________________________________________" )
1627 main.case( "Disconnecting mininet and restarting ONOS" )
1628 main.step( "Disconnecting mininet and restarting ONOS" )
1629 mininetDisconnect = main.Mininet1.disconnect()
1630 print "mininetDisconnect = ", mininetDisconnect
1631
1632 main.step( "Removing raft logs before a clen installation of ONOS" )
1633 main.ONOSbench.onosRemoveRaftLogs()
1634
1635 main.step( "Applying cell variable to environment" )
1636 cellResult = main.ONOSbench.setCell( cellName )
1637 verifyResult = main.ONOSbench.verifyCell()
1638
shahshreyaa47ebf42015-05-20 13:29:18 -07001639 time.sleep( 5 )
1640 main.step( "Uninstalling ONOS package" )
1641 onos1UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS1Ip)
1642 onos2UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS2Ip)
1643 onos3UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS3Ip)
1644 onosUninstallResult = onos1UninstallResult and onos2UninstallResult \
1645 and onos3UninstallResult
1646 time.sleep( 15 )
shahshreya1f119da2015-04-21 17:16:46 -07001647 main.step( "Installing ONOS package" )
1648 onos1InstallResult = main.ONOSbench.onosInstall(
1649 options="-f",
1650 node=ONOS1Ip )
1651 onos2InstallResult = main.ONOSbench.onosInstall(
1652 options="-f",
1653 node=ONOS2Ip )
1654 onos3InstallResult = main.ONOSbench.onosInstall(
1655 options="-f",
1656 node=ONOS3Ip )
1657 onosInstallResult = onos1InstallResult and onos2InstallResult and\
1658 onos3InstallResult
1659 if onosInstallResult == main.TRUE:
1660 main.log.report( "Installing ONOS package successful" )
1661 else:
1662 main.log.report( "Installing ONOS package failed" )
1663
shahshreyaa47ebf42015-05-20 13:29:18 -07001664 time.sleep( 10 )
shahshreya1f119da2015-04-21 17:16:46 -07001665 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
1666 onos2Isup = main.ONOSbench.isup( ONOS2Ip )
1667 onos3Isup = main.ONOSbench.isup( ONOS3Ip )
1668 onosIsup = onos1Isup and onos2Isup and onos3Isup
1669 if onosIsup == main.TRUE:
1670 main.log.report( "ONOS instances are up and ready" )
1671 else:
1672 main.log.report( "ONOS instances may not be up" )
1673
1674 main.step( "Starting ONOS service" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001675 time.sleep( 10 )
shahshreya1f119da2015-04-21 17:16:46 -07001676 startResult = main.TRUE
1677 # startResult = main.ONOSbench.onosStart( ONOS1Ip )
1678 startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip )
1679 startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip )
1680 startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip )
1681 startResult = startcli1 and startcli2 and startcli3
1682 if startResult == main.TRUE:
1683 main.log.report( "ONOS cli starts properly" )
1684 case20Result = mininetDisconnect and cellResult and verifyResult \
1685 and onosInstallResult and onosIsup and startResult
1686
1687 utilities.assert_equals(
1688 expect=main.TRUE,
1689 actual=case20Result,
1690 onpass= "Exiting functionality mininet topology and reinstalling" +
1691 " ONOS successful",
1692 onfail= "Exiting functionality mininet topology and reinstalling" +
1693 " ONOS failed" )
1694
1695 def CASE21( self, main ):
1696 """
1697 On ONOS bench, run this command:
1698 sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1 <Ctrls>
1699 which spawns packet optical topology and copies the links
1700 json file to the onos instance.
1701 Note that in case of Packet Optical, the links are not learnt
1702 from the topology, instead the links are learnt
1703 from the json config file
1704 """
1705 main.log.report(
1706 "This testcase starts the packet layer topology and REST" )
1707 main.log.report( "_____________________________________________" )
1708 main.case( "Starting LINC-OE and other components" )
1709 main.step( "Starting LINC-OE and other components" )
1710 main.log.info( "Activate optical app" )
1711 appInstallResult = main.ONOScli1.activateApp( "org.onosproject.optical" )
1712 appCheck = main.ONOScli1.appToIDCheck()
1713 appCheck = appCheck and main.ONOScli2.appToIDCheck()
1714 appCheck = appCheck and main.ONOScli3.appToIDCheck()
1715 if appCheck != main.TRUE:
1716 main.log.warn( "Checking ONOS application unsuccesful" )
1717
1718 ctrllerIP = []
1719 ctrllerIP.append( main.params[ 'CTRL' ][ 'ip1' ] )
1720 #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip2' ] )
1721 #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip3' ] )
1722 opticalMnScript = main.LincOE2.runOpticalMnScript( ctrllerIP = ctrllerIP )
1723 case21Result = opticalMnScript and appInstallResult
1724 utilities.assert_equals(
1725 expect=main.TRUE,
1726 actual=case21Result,
1727 onpass="Packet optical topology spawned successsfully",
1728 onfail="Packet optical topology spawning failed" )
1729
1730 def CASE22( self, main ):
1731 """
1732 Curretly we use, 10 optical switches(ROADM's) and
1733 6 packet layer mininet switches each with one host.
1734 Therefore, the roadmCount variable = 10,
1735 packetLayerSWCount variable = 6, hostCount=6 and
shahshreya234a1682015-05-27 15:41:56 -07001736 links=46.
shahshreya1f119da2015-04-21 17:16:46 -07001737 All this is hardcoded in the testcase. If the topology changes,
1738 these hardcoded values need to be changed
1739 """
shahshreyaa47ebf42015-05-20 13:29:18 -07001740 import time
shahshreya1f119da2015-04-21 17:16:46 -07001741 main.log.report(
1742 "This testcase compares the optical+packet topology against what" +
1743 " is expected" )
1744 main.case( "Topology comparision" )
1745 main.step( "Topology comparision" )
1746 devicesResult = main.ONOScli3.devices( jsonFormat=False )
shahshreyaa47ebf42015-05-20 13:29:18 -07001747 time.sleep( 15 )
shahshreya1f119da2015-04-21 17:16:46 -07001748 print "devices_result = ", devicesResult
1749 devicesLinewise = devicesResult.split( "\n" )
shahshreya1f119da2015-04-21 17:16:46 -07001750 roadmCount = 0
1751 packetLayerSWCount = 0
1752 for line in devicesLinewise:
1753 components = line.split( "," )
1754 availability = components[ 1 ].split( "=" )[ 1 ]
1755 type = components[ 3 ].split( "=" )[ 1 ]
1756 if availability == 'true' and type == 'ROADM':
1757 roadmCount += 1
1758 elif availability == 'true' and type == 'SWITCH':
1759 packetLayerSWCount += 1
1760 if roadmCount == 10:
1761 print "Number of Optical Switches = %d and is" % roadmCount +\
1762 " correctly detected"
1763 main.log.info(
1764 "Number of Optical Switches = " +
1765 str( roadmCount ) +
1766 " and is correctly detected" )
1767 opticalSWResult = main.TRUE
1768 else:
1769 print "Number of Optical Switches = %d and is wrong" % roadmCount
1770 main.log.info(
1771 "Number of Optical Switches = " +
1772 str( roadmCount ) +
1773 " and is wrong" )
1774 opticalSWResult = main.FALSE
1775
1776 if packetLayerSWCount == 6:
1777 print "Number of Packet layer or mininet Switches = %d "\
1778 % packetLayerSWCount + "and is correctly detected"
1779 main.log.info(
1780 "Number of Packet layer or mininet Switches = " +
1781 str( packetLayerSWCount ) +
1782 " and is correctly detected" )
1783 packetSWResult = main.TRUE
1784 else:
1785 print "Number of Packet layer or mininet Switches = %d and"\
1786 % packetLayerSWCount + " is wrong"
1787 main.log.info(
1788 "Number of Packet layer or mininet Switches = " +
1789 str( packetLayerSWCount ) +
1790 " and is wrong" )
1791 packetSWResult = main.FALSE
1792 print "_________________________________"
1793
1794 linksResult = main.ONOScli3.links( jsonFormat=False )
1795 print "links_result = ", linksResult
1796 print "_________________________________"
1797 linkActiveCount = linksResult.count("state=ACTIVE")
1798 main.log.info( "linkActiveCount = " + str( linkActiveCount ))
shahshreya234a1682015-05-27 15:41:56 -07001799 if linkActiveCount == 46:
shahshreya1f119da2015-04-21 17:16:46 -07001800 linkActiveResult = main.TRUE
1801 main.log.info(
1802 "Number of links in ACTIVE state are correct")
1803 else:
1804 linkActiveResult = main.FALSE
1805 main.log.info(
1806 "Number of links in ACTIVE state are wrong")
1807
1808 case22Result = opticalSWResult and packetSWResult and \
1809 linkActiveResult
1810 utilities.assert_equals(
1811 expect=main.TRUE,
1812 actual=case22Result,
1813 onpass="Packet optical topology discovery successful",
1814 onfail="Packet optical topology discovery failed" )
1815
1816 def CASE23( self, main ):
1817 import time
1818 """
1819 Add bidirectional point intents between 2 packet layer( mininet )
1820 devices and
1821 ping mininet hosts
1822 """
1823 main.log.report(
1824 "This testcase adds bidirectional point intents between 2 " +
1825 "packet layer( mininet ) devices and ping mininet hosts" )
1826 main.case( "Topology comparision" )
1827 main.step( "Adding point intents" )
1828 ptpIntentResult = main.ONOScli1.addPointIntent(
1829 "of:0000ffffffff0001/1",
1830 "of:0000ffffffff0005/1" )
1831 if ptpIntentResult == main.TRUE:
1832 main.ONOScli1.intents( jsonFormat=False )
1833 main.log.info( "Point to point intent install successful" )
1834
1835 ptpIntentResult = main.ONOScli1.addPointIntent(
1836 "of:0000ffffffff0005/1",
1837 "of:0000ffffffff0001/1" )
1838 if ptpIntentResult == main.TRUE:
1839 main.ONOScli1.intents( jsonFormat=False )
1840 main.log.info( "Point to point intent install successful" )
1841
1842 time.sleep( 30 )
shahshreyabf739d82015-06-10 11:22:31 -07001843 #flowHandle = main.ONOScli1.flows()
1844 #main.log.info( "flows :" + flowHandle )
shahshreya1f119da2015-04-21 17:16:46 -07001845
1846 # Sleep for 30 seconds to provide time for the intent state to change
1847 time.sleep( 60 )
1848 intentHandle = main.ONOScli1.intents( jsonFormat=False )
1849 main.log.info( "intents :" + intentHandle )
1850
1851 PingResult = main.TRUE
1852 count = 1
1853 main.log.info( "\n\nh1 is Pinging h5" )
1854 ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
1855 # ping = main.LincOE2.pinghost()
1856 if ping == main.FALSE and count < 5:
1857 count += 1
1858 PingResult = main.FALSE
1859 main.log.info(
1860 "Ping between h1 and h5 failed. Making attempt number " +
1861 str( count ) +
1862 " in 2 seconds" )
1863 time.sleep( 2 )
1864 elif ping == main.FALSE:
1865 main.log.info( "All ping attempts between h1 and h5 have failed" )
1866 PingResult = main.FALSE
1867 elif ping == main.TRUE:
1868 main.log.info( "Ping test between h1 and h5 passed!" )
1869 PingResult = main.TRUE
1870 else:
1871 main.log.info( "Unknown error" )
1872 PingResult = main.ERROR
1873
1874 if PingResult == main.FALSE:
1875 main.log.report(
1876 "Point intents for packet optical have not ben installed" +
1877 " correctly. Cleaning up" )
1878 if PingResult == main.TRUE:
1879 main.log.report(
1880 "Point Intents for packet optical have been " +
1881 "installed correctly" )
1882
1883 case23Result = PingResult
1884 utilities.assert_equals(
1885 expect=main.TRUE,
1886 actual=case23Result,
1887 onpass= "Point intents addition for packet optical and" +
1888 "Pingall Test successful",
1889 onfail= "Point intents addition for packet optical and" +
1890 "Pingall Test NOT successful" )
1891
1892 def CASE24( self, main ):
1893 import time
1894 import json
1895 """
1896 LINC uses its own switch IDs. You can use the following
1897 command on the LINC console to find the mapping between
1898 DPIDs and LINC IDs.
1899 rp(application:get_all_key(linc)).
1900
1901 Test Rerouting of Packet Optical by bringing a port down
1902 ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
1903 so that link
1904 ( between switch1 port20 - switch5 port50 ) is inactive
1905 and do a ping test. If rerouting is successful,
1906 ping should pass. also check the flows
1907 """
1908 main.log.report(
1909 "This testcase tests rerouting and pings mininet hosts" )
1910 main.case( "Test rerouting and pings mininet hosts" )
1911 main.step( "Attach to the Linc-OE session" )
1912 attachConsole = main.LincOE1.attachLincOESession()
1913 print "attachConsole = ", attachConsole
1914
1915 main.step( "Bring a port down and verify the link state" )
1916 main.LincOE1.portDown( swId="9", ptId="20" )
1917 linksNonjson = main.ONOScli3.links( jsonFormat=False )
1918 main.log.info( "links = " + linksNonjson )
1919
1920 linkInactiveCount = linksNonjson.count("state=INACTIVE")
1921 main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
1922 if linkInactiveCount == 2:
1923 main.log.info(
1924 "Number of links in INACTIVE state are correct")
1925 else:
1926 main.log.info(
1927 "Number of links in INACTIVE state are wrong")
1928
1929 links = main.ONOScli3.links()
1930 main.log.info( "links = " + links )
1931
1932 linksResult = json.loads( links )
1933 linksStateResult = main.FALSE
1934 for item in linksResult:
1935 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
1936 'src' ][ 'port' ] == "20":
1937 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
1938 'dst' ][ 'port' ] == "50":
1939 linksState = item[ 'state' ]
1940 if linksState == "INACTIVE":
1941 main.log.info(
1942 "Links state is inactive as expected due to one" +
1943 " of the ports being down" )
1944 main.log.report(
1945 "Links state is inactive as expected due to one" +
1946 " of the ports being down" )
1947 linksStateResult = main.TRUE
1948 break
1949 else:
1950 main.log.info(
1951 "Links state is not inactive as expected" )
1952 main.log.report(
1953 "Links state is not inactive as expected" )
1954 linksStateResult = main.FALSE
1955
1956 print "links_state_result = ", linksStateResult
1957 time.sleep( 10 )
shahshreyabf739d82015-06-10 11:22:31 -07001958 #flowHandle = main.ONOScli3.flows()
1959 #main.log.info( "flows :" + flowHandle )
shahshreya1f119da2015-04-21 17:16:46 -07001960
1961 main.step( "Verify Rerouting by a ping test" )
1962 PingResult = main.TRUE
1963 count = 1
1964 main.log.info( "\n\nh1 is Pinging h5" )
1965 ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
1966 # ping = main.LincOE2.pinghost()
1967 if ping == main.FALSE and count < 5:
1968 count += 1
1969 PingResult = main.FALSE
1970 main.log.info(
1971 "Ping between h1 and h5 failed. Making attempt number " +
1972 str( count ) +
1973 " in 2 seconds" )
1974 time.sleep( 2 )
1975 elif ping == main.FALSE:
1976 main.log.info( "All ping attempts between h1 and h5 have failed" )
1977 PingResult = main.FALSE
1978 elif ping == main.TRUE:
1979 main.log.info( "Ping test between h1 and h5 passed!" )
1980 PingResult = main.TRUE
1981 else:
1982 main.log.info( "Unknown error" )
1983 PingResult = main.ERROR
1984
1985 if PingResult == main.TRUE:
1986 main.log.report( "Ping test successful " )
1987 if PingResult == main.FALSE:
1988 main.log.report( "Ping test failed" )
1989
1990 case24Result = PingResult and linksStateResult
1991 utilities.assert_equals( expect=main.TRUE, actual=case24Result,
1992 onpass="Packet optical rerouting successful",
1993 onfail="Packet optical rerouting failed" )