blob: 682b6f1ff4b88aeefc90372c57466da1be7acf26 [file] [log] [blame]
shahshreya4e13a062014-11-11 16:46:18 -08001
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08002# Testing the basic functionality of ONOS Next
3# For sanity and driver functionality excercises only.
shahshreya4e13a062014-11-11 16:46:18 -08004
5import time
6import sys
7import os
8import re
9import time
10import json
11
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080012time.sleep( 1 )
13
shahshreya4e13a062014-11-11 16:46:18 -080014class MultiProd:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080015
16 def __init__( self ):
shahshreya4e13a062014-11-11 16:46:18 -080017 self.default = ''
18
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080019 def CASE1( self, main ):
20 """
shahshreya4e13a062014-11-11 16:46:18 -080021 Startup sequence:
shahshreyae6c7cf42014-11-26 16:39:01 -080022 cell <name>
23 onos-verify-cell
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080024 onos-remove-raft-logs
shahshreya4e13a062014-11-11 16:46:18 -080025 git pull
26 mvn clean install
27 onos-package
shahshreya4e13a062014-11-11 16:46:18 -080028 onos-install -f
29 onos-wait-for-start
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080030 """
shahshreyaf3076352015-01-23 13:52:01 -080031 cellName = main.params[ 'ENV' ][ 'cellName' ]
32 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
33 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
34 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
35 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
36 ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
37 ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
shahshreya842d8b92015-06-10 14:13:33 -070038 gitPull = main.params[ 'GIT' ][ 'pull' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080039
40 main.case( "Setting up test environment" )
41 main.log.report(
42 "This testcase is testing setting up test environment" )
43 main.log.report( "__________________________________" )
44
45 main.step( "Applying cell variable to environment" )
shahshreyaf3076352015-01-23 13:52:01 -080046 cellResult1 = main.ONOSbench.setCell( cellName )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080047 # cellResult2 = main.ONOScli1.setCell( cellName )
48 # cellResult3 = main.ONOScli2.setCell( cellName )
49 # cellResult4 = main.ONOScli3.setCell( cellName )
shahshreyaf3076352015-01-23 13:52:01 -080050 verifyResult = main.ONOSbench.verifyCell()
51 cellResult = cellResult1
shahshreyae6c7cf42014-11-26 16:39:01 -080052
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080053 main.step( "Removing raft logs before a clen installation of ONOS" )
shahshreyaf3076352015-01-23 13:52:01 -080054 removeLogResult = main.ONOSbench.onosRemoveRaftLogs()
shahshreyae6c7cf42014-11-26 16:39:01 -080055
shahshreya842d8b92015-06-10 14:13:33 -070056 main.step( "Git checkout and get version" )
shahshreyaa47ebf42015-05-20 13:29:18 -070057 main.ONOSbench.gitCheckout( "master" )
shahshreya842d8b92015-06-10 14:13:33 -070058 if gitPull == 'True':
59 gitPullResult = main.ONOSbench.gitPull()
60 if gitPullResult == 1:
61 main.step( "Using mvn clean & install" )
62 main.ONOSbench.cleanInstall()
63 main.step( "Creating ONOS package" )
64 packageResult = main.ONOSbench.onosPackage()
65 elif gitPullResult == 0:
66 main.log.report(
67 "Git Pull Failed, look into logs for detailed reason" )
68 main.cleanup()
69 main.exit()
70 main.log.info( "git_pull_result = " + str( gitPullResult ))
71 else:
72 main.log.info( "Skipping git pull" )
73 main.ONOSbench.getVersion( report=True )
shahshreya234a1682015-05-27 15:41:56 -070074 packageResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -080075
kelvin-onlabcf33bda2015-01-23 16:54:17 -080076 # main.step( "Creating a cell" )
shahshreyaf3076352015-01-23 13:52:01 -080077 # cellCreateResult = main.ONOSbench.createCellFile( **************
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080078 # )
shahshreya4e13a062014-11-11 16:46:18 -080079
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080080 main.step( "Installing ONOS package" )
shahshreyaf3076352015-01-23 13:52:01 -080081 onos1InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080082 options="-f",
shahshreyaf3076352015-01-23 13:52:01 -080083 node=ONOS1Ip )
84 onos2InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080085 options="-f",
shahshreyaf3076352015-01-23 13:52:01 -080086 node=ONOS2Ip )
87 onos3InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080088 options="-f",
shahshreyaf3076352015-01-23 13:52:01 -080089 node=ONOS3Ip )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080090 onosInstallResult = onos1InstallResult and onos2InstallResult and\
91 onos3InstallResult
shahshreyaf3076352015-01-23 13:52:01 -080092 if onosInstallResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080093 main.log.report( "Installing ONOS package successful" )
shahshreya4e13a062014-11-11 16:46:18 -080094 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080095 main.log.report( "Installing ONOS package failed" )
96
shahshreyaf3076352015-01-23 13:52:01 -080097 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
98 onos2Isup = main.ONOSbench.isup( ONOS2Ip )
99 onos3Isup = main.ONOSbench.isup( ONOS3Ip )
100 onosIsup = onos1Isup and onos2Isup and onos3Isup
101 if onosIsup == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800102 main.log.report( "ONOS instances are up and ready" )
shahshreya4e13a062014-11-11 16:46:18 -0800103 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800104 main.log.report( "ONOS instances may not be up" )
shahshreya4e13a062014-11-11 16:46:18 -0800105
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800106 main.step( "Starting ONOS service" )
shahshreyaf3076352015-01-23 13:52:01 -0800107 startResult = main.TRUE
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800108 # startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreyaf3076352015-01-23 13:52:01 -0800109 startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip )
110 startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip )
111 startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800112 print startcli1
113 print startcli2
114 print startcli3
shahshreya4e13a062014-11-11 16:46:18 -0800115
shahshreya42efbd82015-02-05 17:06:08 -0800116 # Starting the mininet using the old way
117 main.step( "Starting Mininet ..." )
118 netIsUp = main.Mininet1.startNet()
119 if netIsUp:
120 main.log.info("Mininet CLI is up")
121
shahshreyaf3076352015-01-23 13:52:01 -0800122 case1Result = ( packageResult and
123 cellResult and verifyResult and onosInstallResult and
124 onosIsup and startResult )
125 utilities.assertEquals( expect=main.TRUE, actual=case1Result,
126 onpass="Test startup successful",
127 onfail="Test startup NOT successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800128
129 def CASE11( self, main ):
130 """
shahshreya4e13a062014-11-11 16:46:18 -0800131 Cleanup sequence:
shahshreyaf3076352015-01-23 13:52:01 -0800132 onos-service <nodeIp> stop
shahshreya4e13a062014-11-11 16:46:18 -0800133 onos-uninstall
134
135 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800136
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800137 """
shahshreyaf3076352015-01-23 13:52:01 -0800138 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
139 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
140 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
shahshreya4e13a062014-11-11 16:46:18 -0800141
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800142 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800143
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800144 main.step( "Testing ONOS kill function" )
shahshreyaf3076352015-01-23 13:52:01 -0800145 killResult1 = main.ONOSbench.onosKill( ONOS1Ip )
146 killResult2 = main.ONOSbench.onosKill( ONOS2Ip )
147 killResult3 = main.ONOSbench.onosKill( ONOS3Ip )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800148
149 main.step( "Stopping ONOS service" )
shahshreyaf3076352015-01-23 13:52:01 -0800150 stopResult1 = main.ONOSbench.onosStop( ONOS1Ip )
151 stopResult2 = main.ONOSbench.onosStop( ONOS2Ip )
152 stopResult3 = main.ONOSbench.onosStop( ONOS3Ip )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800153
154 main.step( "Uninstalling ONOS service" )
shahshreyaf3076352015-01-23 13:52:01 -0800155 uninstallResult = main.ONOSbench.onosUninstall()
shahshreya4e13a062014-11-11 16:46:18 -0800156
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800157 def CASE3( self, main ):
158 """
shahshreya4e13a062014-11-11 16:46:18 -0800159 Test 'onos' command and its functionality in driver
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800160 """
shahshreyaf3076352015-01-23 13:52:01 -0800161 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
162 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
163 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
shahshreya4e13a062014-11-11 16:46:18 -0800164
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800165 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800166
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800167 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800168 cmdstr1 = "system:name"
shahshreyaf3076352015-01-23 13:52:01 -0800169 cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
170 main.log.info( "onos command returned: " + cmdResult1 )
171 cmdResult2 = main.ONOSbench.onosCli( ONOS2Ip, cmdstr1 )
172 main.log.info( "onos command returned: " + cmdResult2 )
173 cmdResult3 = main.ONOSbench.onosCli( ONOS3Ip, cmdstr1 )
174 main.log.info( "onos command returned: " + cmdResult3 )
shahshreya4e13a062014-11-11 16:46:18 -0800175
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800176 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800177 cmdstr2 = "onos:topology"
shahshreyaf3076352015-01-23 13:52:01 -0800178 cmdResult4 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
179 main.log.info( "onos command returned: " + cmdResult4 )
180 cmdResult5 = main.ONOSbench.onosCli( ONOS2Ip, cmdstr2 )
181 main.log.info( "onos command returned: " + cmdResult5 )
182 cmdResult6 = main.ONOSbench.onosCli( ONOS6Ip, cmdstr2 )
183 main.log.info( "onos command returned: " + cmdResult6 )
shahshreya4e13a062014-11-11 16:46:18 -0800184
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800185 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800186 import re
187 import time
shahshreyaf3076352015-01-23 13:52:01 -0800188 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
189 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
190 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
191 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
192 ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
193 ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800194
195 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800196 "This testcase is testing the assignment of all the switches" +
197 " to all controllers and discovering the hosts in reactive mode" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800198 main.log.report( "__________________________________" )
199 main.case( "Pingall Test(No intents are added)" )
200 main.step( "Assigning switches to controllers" )
201 for i in range( 1, 29 ): # 1 to ( num of switches +1 )
shahshreyaf3076352015-01-23 13:52:01 -0800202 main.Mininet1.assignSwController(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800203 sw=str( i ),
204 count=3,
shahshreyaf3076352015-01-23 13:52:01 -0800205 ip1=ONOS1Ip,
206 port1=ONOS1Port,
207 ip2=ONOS2Ip,
208 port2=ONOS2Port,
209 ip3=ONOS3Ip,
210 port3=ONOS3Port )
shahshreya4e13a062014-11-11 16:46:18 -0800211
shahshreyaf3076352015-01-23 13:52:01 -0800212 switchMastership = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800213 for i in range( 1, 29 ):
shahshreyaf3076352015-01-23 13:52:01 -0800214 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800215 print( "Response is " + str( response ) )
shahshreyaf3076352015-01-23 13:52:01 -0800216 if re.search( "tcp:" + ONOS1Ip, response ):
217 switchMastership = switchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800218 else:
shahshreyaf3076352015-01-23 13:52:01 -0800219 switchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800220
shahshreyaf3076352015-01-23 13:52:01 -0800221 if switchMastership == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800222 main.log.report( "Controller assignment successfull" )
shahshreya4e13a062014-11-11 16:46:18 -0800223 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800224 main.log.report( "Controller assignment failed" )
shahshreyad524a942015-04-21 09:55:16 -0700225 appInstallResult = main.TRUE
226 main.log.info( "Activating reactive forwarding app" )
227 appInstallResult = main.ONOScli1.activateApp( "org.onosproject.fwd" )
228 appCheck = main.ONOScli1.appToIDCheck()
229 if appCheck != main.TRUE:
230 main.log.warn( main.ONOScli1.apps() )
231 main.log.warn( main.ONOScli1.appIDs() )
232 time.sleep( 30 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800233 # REACTIVE FWD test
234 main.step( "Pingall" )
shahshreyaf3076352015-01-23 13:52:01 -0800235 pingResult = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800236 time1 = time.time()
shahshreyaf3076352015-01-23 13:52:01 -0800237 pingResult = main.Mininet1.pingall()
shahshreya4e13a062014-11-11 16:46:18 -0800238 time2 = time.time()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800239 print "Time for pingall: %2f seconds" % ( time2 - time1 )
240
shahshreyaf3076352015-01-23 13:52:01 -0800241 case4Result = switchMastership and pingResult
242 if pingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800243 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800244 "Pingall Test in reactive mode to" +
245 " discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800246 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800247 main.log.report(
248 "Pingall Test in reactive mode to discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800249
shahshreyaf3076352015-01-23 13:52:01 -0800250 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800251 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800252 actual=case4Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800253 onpass="Controller assignment and Pingall Test successful",
254 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800255
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800256 def CASE5( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800257 import json
shahshreyaf3076352015-01-23 13:52:01 -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(
shahshreyad2ef8bf2015-04-03 15:34:55 -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
Jon Hall5b0120a2015-06-12 17:35:53 -0700294 mnSwitches = main.Mininet1.getSwitches()
295 mnLinks = main.Mininet1.getLinks()
shahshreya4e13a062014-11-11 16:46:18 -0800296
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800297 print "**************"
298
299 main.step( "Start continuous pings" )
300 main.Mininet2.pingLong(
301 src=main.params[ 'PING' ][ 'source1' ],
302 target=main.params[ 'PING' ][ 'target1' ],
303 pingTime=500 )
304 main.Mininet2.pingLong(
305 src=main.params[ 'PING' ][ 'source2' ],
306 target=main.params[ 'PING' ][ 'target2' ],
307 pingTime=500 )
308 main.Mininet2.pingLong(
309 src=main.params[ 'PING' ][ 'source3' ],
310 target=main.params[ 'PING' ][ 'target3' ],
311 pingTime=500 )
312 main.Mininet2.pingLong(
313 src=main.params[ 'PING' ][ 'source4' ],
314 target=main.params[ 'PING' ][ 'target4' ],
315 pingTime=500 )
316 main.Mininet2.pingLong(
317 src=main.params[ 'PING' ][ 'source5' ],
318 target=main.params[ 'PING' ][ 'target5' ],
319 pingTime=500 )
320 main.Mininet2.pingLong(
321 src=main.params[ 'PING' ][ 'source6' ],
322 target=main.params[ 'PING' ][ 'target6' ],
323 pingTime=500 )
324 main.Mininet2.pingLong(
325 src=main.params[ 'PING' ][ 'source7' ],
326 target=main.params[ 'PING' ][ 'target7' ],
327 pingTime=500 )
328 main.Mininet2.pingLong(
329 src=main.params[ 'PING' ][ 'source8' ],
330 target=main.params[ 'PING' ][ 'target8' ],
331 pingTime=500 )
332 main.Mininet2.pingLong(
333 src=main.params[ 'PING' ][ 'source9' ],
334 target=main.params[ 'PING' ][ 'target9' ],
335 pingTime=500 )
336 main.Mininet2.pingLong(
337 src=main.params[ 'PING' ][ 'source10' ],
338 target=main.params[ 'PING' ][ 'target10' ],
339 pingTime=500 )
340
shahshreyaf3076352015-01-23 13:52:01 -0800341 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800342 main.step( "Compare ONOS Topology to MN Topology" )
343
shahshreyaf3076352015-01-23 13:52:01 -0800344 switchesResults1 = main.Mininet1.compareSwitches(
Jon Hall5b0120a2015-06-12 17:35:53 -0700345 mnSwitches, json.loads( devices1 ), json.loads( ports1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800346 print "switches_Result1 = ", switchesResults1
347 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
348 onpass="ONOS1 Switches view is correct",
349 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800350
shahshreyaf3076352015-01-23 13:52:01 -0800351 switchesResults2 = main.Mininet1.compareSwitches(
Jon Hall5b0120a2015-06-12 17:35:53 -0700352 mnSwitches, json.loads( devices2 ), json.loads( ports2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800353 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
354 onpass="ONOS2 Switches view is correct",
355 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800356
shahshreyaf3076352015-01-23 13:52:01 -0800357 switchesResults3 = main.Mininet1.compareSwitches(
Jon Hall5b0120a2015-06-12 17:35:53 -0700358 mnSwitches, json.loads( devices3 ), json.loads( ports3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800359 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
360 onpass="ONOS3 Switches view is correct",
361 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800362
shahshreyaf3076352015-01-23 13:52:01 -0800363 linksResults1 = main.Mininet1.compareLinks(
Jon Hall5b0120a2015-06-12 17:35:53 -0700364 mnSwitches, mnLinks, json.loads( links1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800365 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
366 onpass="ONOS1 Links view is correct",
367 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800368
shahshreyaf3076352015-01-23 13:52:01 -0800369 linksResults2 = main.Mininet1.compareLinks(
Jon Hall5b0120a2015-06-12 17:35:53 -0700370 mnSwitches, mnLinks, json.loads( links2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800371 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
372 onpass="ONOS2 Links view is correct",
373 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800374
shahshreyaf3076352015-01-23 13:52:01 -0800375 linksResults3 = main.Mininet1.compareLinks(
Jon Hall5b0120a2015-06-12 17:35:53 -0700376 mnSwitches, mnLinks, json.loads( links3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800377 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
378 onpass="ONOS2 Links view is correct",
379 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800380
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800381 topoResult = switchesResults1 and switchesResults2 and\
382 switchesResults3 and linksResults1 and linksResults2 and\
383 linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800384
shahshreyaf3076352015-01-23 13:52:01 -0800385 if topoResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800386 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800387 "Topology Check Test with mininet" +
388 "and ONOS instances successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800389 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800390 main.log.report(
391 "Topology Check Test with mininet and ONOS instances failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800392
shahshreyaf3076352015-01-23 13:52:01 -0800393 utilities.assertEquals( expect=main.TRUE, actual=topoResult,
394 onpass="Topology Check Test successful",
395 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800396
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800397 def CASE10( self ):
shahshreya1f119da2015-04-21 17:16:46 -0700398 import time
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800399 main.log.report(
400 "This testcase uninstalls the reactive forwarding app" )
401 main.log.report( "__________________________________" )
402 main.case( "Uninstalling reactive forwarding app" )
403 # Unistall onos-app-fwd app to disable reactive forwarding
shahshreyad524a942015-04-21 09:55:16 -0700404 appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.fwd" )
405 appCheck = main.ONOScli1.appToIDCheck()
406 if appCheck != main.TRUE:
407 main.log.warn( main.ONOScli1.apps() )
408 main.log.warn( main.ONOScli1.appIDs() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800409 main.log.info( "onos-app-fwd uninstalled" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800410
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800411 # After reactive forwarding is disabled,
412 # the reactive flows on switches timeout in 10-15s
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800413 # So sleep for 15s
414 time.sleep( 15 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800415
shahshreyae6c7cf42014-11-26 16:39:01 -0800416 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800417 main.log.info( hosts )
shahshreyad524a942015-04-21 09:55:16 -0700418 case10Result = appInstallResult
shahshreyaf3076352015-01-23 13:52:01 -0800419 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800420 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800421 actual=case10Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800422 onpass="Reactive forwarding app uninstallation successful",
423 onfail="Reactive forwarding app uninstallation failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800424
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800425 def CASE6( self ):
426 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800427 "This testcase is testing the addition of" +
428 " host intents and then doing pingall" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800429 main.log.report( "__________________________________" )
430 main.case( "Obtaining hostsfor adding host intents" )
431 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800432 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800433 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800434
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800435 main.step( "Get all devices id" )
shahshreyaf3076352015-01-23 13:52:01 -0800436 devicesIdList = main.ONOScli1.getAllDevicesId()
437 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -0800438
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800439 # ONOS displays the hosts in hex format
440 # unlike mininet which does in decimal format
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800441 # So take care while adding intents
shahshreya4e13a062014-11-11 16:46:18 -0800442
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800443 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800444 main.step( "Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,
445 h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
446 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:08/-1",
447 "00:00:00:00:00:12/-1" )
448 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:09/-1",
449 "00:00:00:00:00:13/-1" )
450 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0A/-1",
451 "00:00:00:00:00:14/-1" )
452 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0B/-1",
453 "00:00:00:00:00:15/-1" )
454 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0C/-1",
455 "00:00:00:00:00:16/-1" )
456 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0D/-1",
457 "00:00:00:00:00:17/-1" )
458 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0E/-1",
459 "00:00:00:00:00:18/-1" )
460 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0F/-1",
461 "00:00:00:00:00:19/-1" )
462 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:10/-1",
463 "00:00:00:00:00:1A/-1" )
464 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:11/-1",
465 "00:00:00:00:00:1B/-1" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800466 """
shahshreya234a1682015-05-27 15:41:56 -0700467 intentsId = []
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800468 for i in range( 8, 18 ):
469 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800470 "Adding host intent between h" + str( i ) +
471 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800472 host1 = "00:00:00:00:00:" + \
473 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
474 host2 = "00:00:00:00:00:" + \
475 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
476 # NOTE: get host can return None
477 # TODO: handle this
shahshreyaf3076352015-01-23 13:52:01 -0800478 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
479 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
480 tmpResult = main.ONOScli1.addHostIntent( host1Id, host2Id )
shahshreya234a1682015-05-27 15:41:56 -0700481 intentsId.append( tmpResult )
482
483 checkIntent1 = main.ONOScli1.checkIntentState( intentsId )
484 checkIntent2 = main.ONOScli2.checkIntentState( intentsId )
485 checkIntent3 = main.ONOScli3.checkIntentState( intentsId )
shahshreya4e13a062014-11-11 16:46:18 -0800486
487 flowHandle = main.ONOScli1.flows()
shahshreya234a1682015-05-27 15:41:56 -0700488
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800489 main.log.info( "flows:" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -0800490
491 count = 1
492 i = 8
shahshreyaf3076352015-01-23 13:52:01 -0800493 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800494 while i < 18:
495 main.log.info(
496 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
497 ping = main.Mininet1.pingHost(
498 src="h" + str( i ), target="h" + str( i + 10 ) )
499 if ping == main.FALSE and count < 5:
500 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800501 # i = 8
shahshreyaf3076352015-01-23 13:52:01 -0800502 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800503 main.log.report( "Ping between h" +
504 str( i ) +
505 " and h" +
506 str( i +
507 10 ) +
508 " failed. Making attempt number " +
509 str( count ) +
510 " in 2 seconds" )
511 time.sleep( 2 )
512 elif ping == main.FALSE:
513 main.log.report( "All ping attempts between h" +
514 str( i ) +
515 " and h" +
516 str( i +
517 10 ) +
518 "have failed" )
519 i = 19
shahshreyaf3076352015-01-23 13:52:01 -0800520 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800521 elif ping == main.TRUE:
522 main.log.info( "Ping test between h" +
523 str( i ) +
524 " and h" +
525 str( i +
526 10 ) +
527 "passed!" )
528 i += 1
shahshreyaf3076352015-01-23 13:52:01 -0800529 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800530 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800531 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -0800532 PingResult = main.ERROR
533 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800534 main.log.report(
535 "Host intents have not ben installed correctly. Cleaning up" )
536 # main.cleanup()
537 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -0800538 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800539 main.log.report( "Host intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -0800540
shahshreya234a1682015-05-27 15:41:56 -0700541 checkIntent1 = main.ONOScli1.checkIntentState( intentsId )
542 checkIntent2 = main.ONOScli2.checkIntentState( intentsId )
543 checkIntent3 = main.ONOScli3.checkIntentState( intentsId )
544
shahshreyaf3076352015-01-23 13:52:01 -0800545 case6Result = PingResult
546 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800547 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800548 actual=case6Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800549 onpass="Host intent addition and Pingall Test successful",
550 onfail="Host intent addition and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800551
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800552 def CASE7( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800553
shahshreyaf3076352015-01-23 13:52:01 -0800554 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800555
shahshreyaf3076352015-01-23 13:52:01 -0800556 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800557
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800558 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800559 "This testscase is killing a link to" +
560 " ensure that link discovery is consistent" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800561 main.log.report( "__________________________________" )
562 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800563 "Killing a link to Ensure that Link" +
564 " Discovery is Working Properly" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800565 main.step( "Start continuous pings" )
shahshreya4e13a062014-11-11 16:46:18 -0800566
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800567 main.Mininet2.pingLong(
568 src=main.params[ 'PING' ][ 'source1' ],
569 target=main.params[ 'PING' ][ 'target1' ],
570 pingTime=500 )
571 main.Mininet2.pingLong(
572 src=main.params[ 'PING' ][ 'source2' ],
573 target=main.params[ 'PING' ][ 'target2' ],
574 pingTime=500 )
575 main.Mininet2.pingLong(
576 src=main.params[ 'PING' ][ 'source3' ],
577 target=main.params[ 'PING' ][ 'target3' ],
578 pingTime=500 )
579 main.Mininet2.pingLong(
580 src=main.params[ 'PING' ][ 'source4' ],
581 target=main.params[ 'PING' ][ 'target4' ],
582 pingTime=500 )
583 main.Mininet2.pingLong(
584 src=main.params[ 'PING' ][ 'source5' ],
585 target=main.params[ 'PING' ][ 'target5' ],
586 pingTime=500 )
587 main.Mininet2.pingLong(
588 src=main.params[ 'PING' ][ 'source6' ],
589 target=main.params[ 'PING' ][ 'target6' ],
590 pingTime=500 )
591 main.Mininet2.pingLong(
592 src=main.params[ 'PING' ][ 'source7' ],
593 target=main.params[ 'PING' ][ 'target7' ],
594 pingTime=500 )
595 main.Mininet2.pingLong(
596 src=main.params[ 'PING' ][ 'source8' ],
597 target=main.params[ 'PING' ][ 'target8' ],
598 pingTime=500 )
599 main.Mininet2.pingLong(
600 src=main.params[ 'PING' ][ 'source9' ],
601 target=main.params[ 'PING' ][ 'target9' ],
602 pingTime=500 )
603 main.Mininet2.pingLong(
604 src=main.params[ 'PING' ][ 'source10' ],
605 target=main.params[ 'PING' ][ 'target10' ],
606 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -0800607
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800608 main.step( "Determine the current number of switches and links" )
shahshreyaf3076352015-01-23 13:52:01 -0800609 topologyOutput = main.ONOScli1.topology()
610 topologyResult = main.ONOSbench.getTopology( topologyOutput )
shahshreyaa47ebf42015-05-20 13:29:18 -0700611 activeSwitches = topologyResult[ 'devices' ]
612 links = topologyResult[ 'links' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800613 main.log.info(
614 "Currently there are %s switches and %s links" %
615 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -0800616
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800617 main.step( "Kill Link between s3 and s28" )
618 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
shahshreyaf3076352015-01-23 13:52:01 -0800619 time.sleep( linkSleep )
620 topologyOutput = main.ONOScli2.topology()
621 LinkDown = main.ONOSbench.checkStatus(
622 topologyOutput, activeSwitches, str(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800623 int( links ) - 2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800624 if LinkDown == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800625 main.log.report( "Link Down discovered properly" )
shahshreyaf3076352015-01-23 13:52:01 -0800626 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800627 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800628 actual=LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800629 onpass="Link Down discovered properly",
630 onfail="Link down was not discovered in " +
shahshreyaf3076352015-01-23 13:52:01 -0800631 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800632 " seconds" )
shahshreya4e13a062014-11-11 16:46:18 -0800633
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800634 main.step( "Bring link between s3 and s28 back up" )
shahshreyaf3076352015-01-23 13:52:01 -0800635 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
636 time.sleep( linkSleep )
637 topologyOutput = main.ONOScli2.topology()
638 LinkUp = main.ONOSbench.checkStatus(
639 topologyOutput,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800640 activeSwitches,
641 str( links ) )
shahshreyaf3076352015-01-23 13:52:01 -0800642 if LinkUp == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800643 main.log.report( "Link up discovered properly" )
shahshreyaf3076352015-01-23 13:52:01 -0800644 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800645 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800646 actual=LinkUp,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800647 onpass="Link up discovered properly",
648 onfail="Link up was not discovered in " +
shahshreyaf3076352015-01-23 13:52:01 -0800649 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800650 " seconds" )
651
652 main.step( "Compare ONOS Topology to MN Topology" )
653 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800654 "Testing Mininet topology with the" +
655 " topology of multi instances ONOS" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800656 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800657 devices1 = main.ONOScli1.devices()
658 devices2 = main.ONOScli2.devices()
659 devices3 = main.ONOScli3.devices()
660 print "devices1 = ", devices1
661 print "devices2 = ", devices2
662 print "devices3 = ", devices3
663 hosts1 = main.ONOScli1.hosts()
664 hosts2 = main.ONOScli2.hosts()
665 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800666 # print "hosts1 = ", hosts1
667 # print "hosts2 = ", hosts2
668 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800669 ports1 = main.ONOScli1.ports()
670 ports2 = main.ONOScli2.ports()
671 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800672 # print "ports1 = ", ports1
673 # print "ports2 = ", ports2
674 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800675 links1 = main.ONOScli1.links()
676 links2 = main.ONOScli2.links()
677 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800678 # print "links1 = ", links1
679 # print "links2 = ", links2
680 # print "links3 = ", links3
Jon Hall5b0120a2015-06-12 17:35:53 -0700681 mnSwitches = main.Mininet1.getSwitches()
682 mnLinks = main.Mininet1.getLinks()
shahshreya4e13a062014-11-11 16:46:18 -0800683
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800684 print "**************"
685
686 main.step( "Start continuous pings" )
687 main.Mininet2.pingLong(
688 src=main.params[ 'PING' ][ 'source1' ],
689 target=main.params[ 'PING' ][ 'target1' ],
690 pingTime=500 )
691 main.Mininet2.pingLong(
692 src=main.params[ 'PING' ][ 'source2' ],
693 target=main.params[ 'PING' ][ 'target2' ],
694 pingTime=500 )
695 main.Mininet2.pingLong(
696 src=main.params[ 'PING' ][ 'source3' ],
697 target=main.params[ 'PING' ][ 'target3' ],
698 pingTime=500 )
699 main.Mininet2.pingLong(
700 src=main.params[ 'PING' ][ 'source4' ],
701 target=main.params[ 'PING' ][ 'target4' ],
702 pingTime=500 )
703 main.Mininet2.pingLong(
704 src=main.params[ 'PING' ][ 'source5' ],
705 target=main.params[ 'PING' ][ 'target5' ],
706 pingTime=500 )
707 main.Mininet2.pingLong(
708 src=main.params[ 'PING' ][ 'source6' ],
709 target=main.params[ 'PING' ][ 'target6' ],
710 pingTime=500 )
711 main.Mininet2.pingLong(
712 src=main.params[ 'PING' ][ 'source7' ],
713 target=main.params[ 'PING' ][ 'target7' ],
714 pingTime=500 )
715 main.Mininet2.pingLong(
716 src=main.params[ 'PING' ][ 'source8' ],
717 target=main.params[ 'PING' ][ 'target8' ],
718 pingTime=500 )
719 main.Mininet2.pingLong(
720 src=main.params[ 'PING' ][ 'source9' ],
721 target=main.params[ 'PING' ][ 'target9' ],
722 pingTime=500 )
723 main.Mininet2.pingLong(
724 src=main.params[ 'PING' ][ 'source10' ],
725 target=main.params[ 'PING' ][ 'target10' ],
726 pingTime=500 )
727
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800728 main.step( "Compare ONOS Topology to MN Topology" )
729
shahshreyaf3076352015-01-23 13:52:01 -0800730 switchesResults1 = main.Mininet1.compareSwitches(
Jon Hall5b0120a2015-06-12 17:35:53 -0700731 mnSwitches, json.loads( devices1 ), json.loads( ports1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800732 print "switches_Result1 = ", switchesResults1
733 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
734 onpass="ONOS1 Switches view is correct",
735 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800736
shahshreyaf3076352015-01-23 13:52:01 -0800737 switchesResults2 = main.Mininet1.compareSwitches(
Jon Hall5b0120a2015-06-12 17:35:53 -0700738 mnSwitches, json.loads( devices2 ), json.loads( ports2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800739 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
740 onpass="ONOS2 Switches view is correct",
741 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800742
shahshreyaf3076352015-01-23 13:52:01 -0800743 switchesResults3 = main.Mininet1.compareSwitches(
Jon Hall5b0120a2015-06-12 17:35:53 -0700744 mnSwitches, json.loads( devices3 ), json.loads( ports3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800745 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
746 onpass="ONOS3 Switches view is correct",
747 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800748
shahshreyaf3076352015-01-23 13:52:01 -0800749 linksResults1 = main.Mininet1.compareLinks(
Jon Hall5b0120a2015-06-12 17:35:53 -0700750 mnSwitches, mnLinks, json.loads( links1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800751 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
752 onpass="ONOS1 Links view is correct",
753 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800754
shahshreyaf3076352015-01-23 13:52:01 -0800755 linksResults2 = main.Mininet1.compareLinks(
Jon Hall5b0120a2015-06-12 17:35:53 -0700756 mnSwitches, mnLinks, json.loads( links2 ) )
757
shahshreyaf3076352015-01-23 13:52:01 -0800758 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
759 onpass="ONOS2 Links view is correct",
760 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800761
shahshreyaf3076352015-01-23 13:52:01 -0800762 linksResults3 = main.Mininet1.compareLinks(
Jon Hall5b0120a2015-06-12 17:35:53 -0700763 mnSwitches, mnLinks, json.loads( links3 ) )
764
shahshreyaf3076352015-01-23 13:52:01 -0800765 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
766 onpass="ONOS2 Links view is correct",
767 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800768
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800769 topoResult = switchesResults1 and switchesResults2\
770 and switchesResults3 and linksResults1 and\
771 linksResults2 and linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800772
shahshreyaf3076352015-01-23 13:52:01 -0800773 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800774 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800775 actual=topoResult and LinkUp and LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800776 onpass="Topology Check Test successful",
777 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800778
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800779 def CASE8( self ):
780 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800781 Intent removal
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800782 """
783 main.log.report(
shahshreyab512cd02015-01-27 17:01:47 -0800784 "This testcase removes any previously added intents" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800785 main.log.report( "__________________________________" )
786 main.log.info( "Removing any previously installed intents" )
787 main.case( "Removing intents" )
788 main.step( "Obtain the intent id's" )
shahshreyaf3076352015-01-23 13:52:01 -0800789 intentResult = main.ONOScli1.intents( jsonFormat=False )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800790
shahshreyaf3076352015-01-23 13:52:01 -0800791 intentLinewise = intentResult.split( "\n" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800792 intentList = []
shahshreyaf3076352015-01-23 13:52:01 -0800793 for line in intentLinewise:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800794 if line.startswith( "id=" ):
795 intentList.append( line )
shahshreyae6c7cf42014-11-26 16:39:01 -0800796
797 intentids = []
798 for line in intentList:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800799 intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
shahshreya4e13a062014-11-11 16:46:18 -0800800 for id in intentids:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800801 main.log.info( "id = " + id )
shahshreyae6c7cf42014-11-26 16:39:01 -0800802
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800803 main.step(
804 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -0800805 for id in intentids:
shahshreyaa47ebf42015-05-20 13:29:18 -0700806 main.ONOScli1.removeIntent( intentId=id ,purge=True )
shahshreyae6c7cf42014-11-26 16:39:01 -0800807
shahshreya234a1682015-05-27 15:41:56 -0700808 remainingIntent = main.ONOScli1.intents( jsonFormat=False )
809 main.log.info( "Remaining intents " + remainingIntent )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800810
shahshreya234a1682015-05-27 15:41:56 -0700811 case8Result = main.TRUE
812 intentResult = main.TRUE
813 if remainingIntent:
814 main.log.error( "There are still remaining intent" )
815 intentResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800816 i = 8
shahshreya234a1682015-05-27 15:41:56 -0700817
shahshreyaf3076352015-01-23 13:52:01 -0800818 PingResult = main.TRUE
shahshreya234a1682015-05-27 15:41:56 -0700819 """
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800820 while i < 18:
821 main.log.info(
822 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
823 ping = main.Mininet1.pingHost(
824 src="h" + str( i ), target="h" + str( i + 10 ) )
825 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -0800826 i = 19
shahshreyaf3076352015-01-23 13:52:01 -0800827 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800828 elif ping == main.FALSE:
829 i += 1
shahshreyaf3076352015-01-23 13:52:01 -0800830 PingResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800831 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800832 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -0800833 PingResult = main.ERROR
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800834 # Note: If the ping result failed, that means the intents have been
835 # withdrawn correctly.
shahshreyaf3076352015-01-23 13:52:01 -0800836 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800837 main.log.report( "Host intents have not been withdrawn correctly" )
838 # main.cleanup()
839 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -0800840 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800841 main.log.report( "Host intents have been withdrawn correctly" )
shahshreya234a1682015-05-27 15:41:56 -0700842 """
843 case8Result = intentResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800844
shahshreya234a1682015-05-27 15:41:56 -0700845 if case8Result == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800846 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800847 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800848 main.log.report( "Intent removal failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800849
shahshreya234a1682015-05-27 15:41:56 -0700850 utilities.assertEquals( expect=main.TRUE, actual=case8Result,
851 onpass="Intent removal test successful",
852 onfail="Intent removal test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800853
854 def CASE9( self ):
855 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800856 This test case adds point intents. Make sure you run test case 8
857 which is host intent removal before executing this test case.
858 Else the host intent's flows will persist on switches and the pings
859 would work even if there is some issue with the point intent's flows
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800860 """
861 main.log.report(
862 "This testcase adds point intents and then does pingall" )
863 main.log.report( "__________________________________" )
864 main.log.info( "Adding point intents" )
865 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800866 "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20," +
867 "h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800868 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800869 "Add point-to-point intents for mininet hosts" +
870 " h8 and h18 or ONOS hosts h8 and h12" )
shahshreyaa47ebf42015-05-20 13:29:18 -0700871 macsDict = {}
872 for i in range( 1,29 ):
873 macsDict[ 'h' + str( i ) ]= main.Mininet1.getMacAddress( host='h'+ str( i ) )
874 print macsDict
875 # main.step(var1)
shahshreyaf3076352015-01-23 13:52:01 -0800876 ptpIntentResult = main.ONOScli1.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -0700877 ingressDevice="of:0000000000003008/1",
878 egressDevice="of:0000000000006018/1",
879 ethType='IPV4',
880 ethSrc=macsDict.get( 'h8' ))
shahshreyaf3076352015-01-23 13:52:01 -0800881 if ptpIntentResult == main.TRUE:
882 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800883 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800884 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800885
shahshreyaf3076352015-01-23 13:52:01 -0800886 ptpIntentResult = main.ONOScli1.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -0700887 ingressDevice="of:0000000000006018/1",
888 egressDevice="of:0000000000003008/1",
889 ethType='IPV4',
890 ethSrc=macsDict.get( 'h18' ))
shahshreyaf3076352015-01-23 13:52:01 -0800891 if ptpIntentResult == main.TRUE:
892 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800893 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800894 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800895
shahshreyaa47ebf42015-05-20 13:29:18 -0700896 var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
897 main.step(var2)
shahshreyaf3076352015-01-23 13:52:01 -0800898 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800899 "of:0000000000003009/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700900 "of:0000000000006019/1",
901 ethType='IPV4',
902 ethSrc=macsDict.get( 'h9' ))
shahshreyaf3076352015-01-23 13:52:01 -0800903 if ptpIntentResult == main.TRUE:
904 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800905 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800906 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800907
shahshreyaf3076352015-01-23 13:52:01 -0800908 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800909 "of:0000000000006019/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700910 "of:0000000000003009/1",
911 ethType='IPV4',
912 ethSrc=macsDict.get( 'h19' ))
shahshreyaf3076352015-01-23 13:52:01 -0800913 if ptpIntentResult == main.TRUE:
914 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800915 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800916 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800917
shahshreyaa47ebf42015-05-20 13:29:18 -0700918 var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
919 main.step(var3)
shahshreyaf3076352015-01-23 13:52:01 -0800920 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800921 "of:0000000000003010/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700922 "of:0000000000006020/1",
923 ethType='IPV4',
924 ethSrc=macsDict.get( 'h10' ))
925
shahshreyaf3076352015-01-23 13:52:01 -0800926 if ptpIntentResult == main.TRUE:
927 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800928 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800929 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800930
shahshreyaf3076352015-01-23 13:52:01 -0800931 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800932 "of:0000000000006020/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700933 "of:0000000000003010/1",
934 ethType='IPV4',
935 ethSrc=macsDict.get( 'h20' ))
936
shahshreyaf3076352015-01-23 13:52:01 -0800937 if ptpIntentResult == main.TRUE:
938 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800939 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800940 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800941
shahshreyaa47ebf42015-05-20 13:29:18 -0700942 var4 = "Add point intents for mininet hosts h11 and h21 or" +\
943 " ONOS hosts hB and h15"
944 main.case(var4)
shahshreyaf3076352015-01-23 13:52:01 -0800945 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800946 "of:0000000000003011/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700947 "of:0000000000006021/1",
948 ethType='IPV4',
949 ethSrc=macsDict.get( 'h11' ))
950
shahshreyaf3076352015-01-23 13:52:01 -0800951 if ptpIntentResult == main.TRUE:
952 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800953 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800954 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800955
shahshreyaf3076352015-01-23 13:52:01 -0800956 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800957 "of:0000000000006021/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700958 "of:0000000000003011/1",
959 ethType='IPV4',
960 ethSrc=macsDict.get( 'h21' ))
961
shahshreyaf3076352015-01-23 13:52:01 -0800962 if ptpIntentResult == main.TRUE:
963 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800964 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800965 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800966
shahshreyaa47ebf42015-05-20 13:29:18 -0700967 var5 = "Add point intents for mininet hosts h12 and h22 " +\
968 "ONOS hosts hC and h16"
969 main.case(var5)
shahshreyaf3076352015-01-23 13:52:01 -0800970 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800971 "of:0000000000003012/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700972 "of:0000000000006022/1",
973 ethType='IPV4',
974 ethSrc=macsDict.get( 'h12' ))
975
shahshreyaf3076352015-01-23 13:52:01 -0800976 if ptpIntentResult == main.TRUE:
977 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800978 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800979 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800980
shahshreyaf3076352015-01-23 13:52:01 -0800981 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800982 "of:0000000000006022/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700983 "of:0000000000003012/1",
984 ethType='IPV4',
985 ethSrc=macsDict.get( 'h22' ))
986
shahshreyaf3076352015-01-23 13:52:01 -0800987 if ptpIntentResult == main.TRUE:
988 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800989 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800990 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800991
shahshreyaa47ebf42015-05-20 13:29:18 -0700992 var6 = "Add point intents for mininet hosts h13 and h23 or" +\
993 " ONOS hosts hD and h17"
994 main.case(var6)
shahshreyaf3076352015-01-23 13:52:01 -0800995 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800996 "of:0000000000003013/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700997 "of:0000000000006023/1",
998 ethType='IPV4',
999 ethSrc=macsDict.get( 'h13' ))
1000
shahshreyaf3076352015-01-23 13:52:01 -08001001 if ptpIntentResult == main.TRUE:
1002 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001003 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001004 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001005
shahshreyaf3076352015-01-23 13:52:01 -08001006 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001007 "of:0000000000006023/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001008 "of:0000000000003013/1",
1009 ethType='IPV4',
1010 ethSrc=macsDict.get( 'h23' ))
1011
shahshreyaf3076352015-01-23 13:52:01 -08001012 if ptpIntentResult == main.TRUE:
1013 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001014 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001015 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001016
shahshreyaa47ebf42015-05-20 13:29:18 -07001017 var7 = "Add point intents for mininet hosts h14 and h24 or" +\
1018 " ONOS hosts hE and h18"
1019 main.case(var7)
shahshreyaf3076352015-01-23 13:52:01 -08001020 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001021 "of:0000000000003014/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001022 "of:0000000000006024/1",
1023 ethType='IPV4',
1024 ethSrc=macsDict.get( 'h14' ))
1025
shahshreyaf3076352015-01-23 13:52:01 -08001026 if ptpIntentResult == main.TRUE:
1027 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001028 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001029 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001030
shahshreyaf3076352015-01-23 13:52:01 -08001031 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001032 "of:0000000000006024/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001033 "of:0000000000003014/1",
1034 ethType='IPV4',
1035 ethSrc=macsDict.get( 'h24' ))
1036
shahshreyaf3076352015-01-23 13:52:01 -08001037 if ptpIntentResult == main.TRUE:
1038 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001039 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001040 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001041
shahshreyaa47ebf42015-05-20 13:29:18 -07001042 var8 = "Add point intents for mininet hosts h15 and h25 or" +\
1043 " ONOS hosts hF and h19"
1044 main.case(var8)
shahshreyaf3076352015-01-23 13:52:01 -08001045 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001046 "of:0000000000003015/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001047 "of:0000000000006025/1",
1048 ethType='IPV4',
1049 ethSrc=macsDict.get( 'h15' ))
1050
shahshreyaf3076352015-01-23 13:52:01 -08001051 if ptpIntentResult == main.TRUE:
1052 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001053 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001054 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001055
shahshreyaf3076352015-01-23 13:52:01 -08001056 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001057 "of:0000000000006025/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001058 "of:0000000000003015/1",
1059 ethType='IPV4',
1060 ethSrc=macsDict.get( 'h25' ))
1061
shahshreyaf3076352015-01-23 13:52:01 -08001062 if ptpIntentResult == main.TRUE:
1063 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001064 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001065 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001066
shahshreyaa47ebf42015-05-20 13:29:18 -07001067 var9 = "Add intents for mininet hosts h16 and h26 or" +\
1068 " ONOS hosts h10 and h1A"
1069 main.case(var9)
shahshreyaf3076352015-01-23 13:52:01 -08001070 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001071 "of:0000000000003016/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001072 "of:0000000000006026/1",
1073 ethType='IPV4',
1074 ethSrc=macsDict.get( 'h16' ))
1075
shahshreyaf3076352015-01-23 13:52:01 -08001076 if ptpIntentResult == main.TRUE:
1077 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001078 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001079 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001080
shahshreyaf3076352015-01-23 13:52:01 -08001081 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001082 "of:0000000000006026/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001083 "of:0000000000003016/1",
1084 ethType='IPV4',
1085 ethSrc=macsDict.get( 'h26' ))
1086
shahshreyaf3076352015-01-23 13:52:01 -08001087 if ptpIntentResult == main.TRUE:
1088 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001089 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001090 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001091
shahshreyaa47ebf42015-05-20 13:29:18 -07001092 var10 = "Add point intents for mininet hosts h17 and h27 or" +\
1093 " ONOS hosts h11 and h1B"
1094 main.case(var10)
shahshreyaf3076352015-01-23 13:52:01 -08001095 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001096 "of:0000000000003017/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001097 "of:0000000000006027/1",
1098 ethType='IPV4',
1099 ethSrc=macsDict.get( 'h17' ))
1100
shahshreyaf3076352015-01-23 13:52:01 -08001101 if ptpIntentResult == main.TRUE:
1102 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001103 main.log.info( "Point to point intent install successful" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001104 #main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001105
shahshreyaf3076352015-01-23 13:52:01 -08001106 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001107 "of:0000000000006027/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001108 "of:0000000000003017/1",
1109 ethType='IPV4',
1110 ethSrc=macsDict.get( 'h27' ))
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001111
1112 print(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001113 "_______________________________________________________" +
1114 "________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001115
1116 flowHandle = main.ONOScli1.flows()
shahshreyabf739d82015-06-10 11:22:31 -07001117 print "flowHandle = ", flowHandle
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001118 main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001119
1120 count = 1
1121 i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001122 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001123 while i < 18:
1124 main.log.info(
1125 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1126 ping = main.Mininet1.pingHost(
1127 src="h" + str( i ), target="h" + str( i + 10 ) )
1128 if ping == main.FALSE and count < 5:
1129 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001130 # i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001131 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001132 main.log.report( "Ping between h" +
1133 str( i ) +
1134 " and h" +
1135 str( i +
1136 10 ) +
1137 " failed. Making attempt number " +
1138 str( count ) +
1139 " in 2 seconds" )
1140 time.sleep( 2 )
1141 elif ping == main.FALSE:
1142 main.log.report( "All ping attempts between h" +
1143 str( i ) +
1144 " and h" +
1145 str( i +
1146 10 ) +
1147 "have failed" )
1148 i = 19
shahshreyaf3076352015-01-23 13:52:01 -08001149 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001150 elif ping == main.TRUE:
1151 main.log.info( "Ping test between h" +
1152 str( i ) +
1153 " and h" +
1154 str( i +
1155 10 ) +
1156 "passed!" )
1157 i += 1
shahshreyaf3076352015-01-23 13:52:01 -08001158 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001159 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001160 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -08001161 PingResult = main.ERROR
1162 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001163 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001164 "Ping all test after Point intents" +
1165 " addition failed. Cleaning up" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001166 # main.cleanup()
1167 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -08001168 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001169 main.log.report(
1170 "Ping all test after Point intents addition successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001171
shahshreyaf3076352015-01-23 13:52:01 -08001172 case8Result = PingResult
1173 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001174 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001175 actual=case8Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001176 onpass="Ping all test after Point intents addition successful",
1177 onfail="Ping all test after Point intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001178
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001179 def CASE31( self ):
1180 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001181 This test case adds point intent related to
1182 SDN-IP matching on ICMP ( ethertype=IPV4, ipProto=1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001183 """
shahshreyae6c7cf42014-11-26 16:39:01 -08001184 import json
1185
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001186 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001187 "This test case adds point intent " +
1188 "related to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001189 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001190 "Adding bidirectional point intent related" +
1191 " to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001192 main.step( "Adding bidirectional point intent" )
1193 # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1194 # --ethType=IPV4 --ipProto=1 of:0000000000003008/1
1195 # of:0000000000006018/1
1196
shahshreyaf3076352015-01-23 13:52:01 -08001197 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001198 for i in range( 8, 11 ):
1199 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001200 "Adding point intent between h" + str( i ) +
1201 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001202 host1 = "00:00:00:00:00:" + \
1203 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1204 host2 = "00:00:00:00:00:" + \
1205 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
shahshreyaf3076352015-01-23 13:52:01 -08001206 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1207 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1208 for host in hostsJson:
1209 if host[ 'id' ] == host1Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001210 ip1 = host[ 'ipAddresses' ][ 0 ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001211 ip1 = str( ip1 + "/32" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001212 device1 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001213 device1 = str( device1 + "/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001214 elif host[ 'id' ] == host2Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001215 ip2 = str( host[ 'ipAddresses' ][ 0 ] ) + "/32"
1216 device2 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001217 device2 = str( device2 + "/1" )
1218
shahshreyaf3076352015-01-23 13:52:01 -08001219 pIntentResult1 = main.ONOScli1.addPointIntent(
1220 ingressDevice=device1,
1221 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001222 ipSrc=ip1,
1223 ipDst=ip2,
1224 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
shahshreyaa47ebf42015-05-20 13:29:18 -07001225 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ], )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001226
shahshreyaf3076352015-01-23 13:52:01 -08001227 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1228 main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001229
shahshreyaf3076352015-01-23 13:52:01 -08001230 pIntentResult2 = main.ONOScli1.addPointIntent(
1231 ingressDevice=device2,
1232 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001233 ipSrc=ip2,
1234 ipDst=ip1,
1235 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1236 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1237
shahshreyaf3076352015-01-23 13:52:01 -08001238 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1239 main.log.info( getIntentResult )
shahshreyaa47ebf42015-05-20 13:29:18 -07001240 if ( pIntentResult1 and pIntentResult2 ) :
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001241 # getIntentResult = main.ONOScli1.intents()
shahshreyaf3076352015-01-23 13:52:01 -08001242 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001243 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001244 "Point intent related to SDN-IP matching" +
1245 " on ICMP install successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001246
1247 time.sleep( 15 )
shahshreyaf3076352015-01-23 13:52:01 -08001248 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1249 main.log.info( "intents = " + getIntentResult )
1250 getFlowsResult = main.ONOScli1.flows()
1251 main.log.info( "flows = " + getFlowsResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001252
shahshreyae6c7cf42014-11-26 16:39:01 -08001253 count = 1
1254 i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001255 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001256 while i < 11:
1257 main.log.info(
1258 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1259 ping = main.Mininet1.pingHost(
1260 src="h" + str( i ), target="h" + str( i + 10 ) )
1261 if ping == main.FALSE and count < 3:
1262 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001263 # i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001264 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001265 main.log.report( "Ping between h" +
1266 str( i ) +
1267 " and h" +
1268 str( i +
1269 10 ) +
1270 " failed. Making attempt number " +
1271 str( count ) +
1272 " in 2 seconds" )
1273 time.sleep( 2 )
1274 elif ping == main.FALSE:
1275 main.log.report( "All ping attempts between h" +
1276 str( i ) +
1277 " and h" +
1278 str( i +
1279 10 ) +
1280 "have failed" )
1281 i = 19
shahshreyaf3076352015-01-23 13:52:01 -08001282 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001283 elif ping == main.TRUE:
1284 main.log.info( "Ping test between h" +
1285 str( i ) +
1286 " and h" +
1287 str( i +
1288 10 ) +
1289 "passed!" )
1290 i += 1
shahshreyaf3076352015-01-23 13:52:01 -08001291 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -08001292 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001293 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -08001294 PingResult = main.ERROR
1295 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001296 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001297 "Ping test after Point intents related to" +
1298 " SDN-IP matching on ICMP failed." )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001299 # main.cleanup()
1300 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -08001301 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001302 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001303 "Ping all test after Point intents related to" +
1304 " SDN-IP matching on ICMP successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001305
shahshreyaa47ebf42015-05-20 13:29:18 -07001306 case31Result = PingResult
shahshreyaf3076352015-01-23 13:52:01 -08001307 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001308 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001309 actual=case31Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001310 onpass="Point intent related to SDN-IP " +
1311 "matching on ICMP and ping test successful",
1312 onfail="Point intent related to SDN-IP" +
1313 " matching on ICMP and ping test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001314
1315 def CASE32( self ):
1316 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001317 This test case adds point intent related to SDN-IP matching on TCP
1318 ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 )
1319 Note: Although BGP port is 179, we are using 5001 because iperf
1320 is used for verifying and iperf's default port is 5001
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001321 """
shahshreyae6c7cf42014-11-26 16:39:01 -08001322 import json
1323
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001324 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001325 "This test case adds point intent" +
1326 " related to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001327 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001328 "Adding bidirectional point intent related" +
1329 " to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001330 main.step( "Adding bidirectional point intent" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001331 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001332 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1333 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1
1334 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001335
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001336 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1337 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1
1338 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001339
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001340 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1341 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1
1342 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001343
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001344 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1345 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1
1346 of:0000000000003008/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001347
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001348 """
shahshreyaf3076352015-01-23 13:52:01 -08001349 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001350 for i in range( 8, 9 ):
1351 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001352 "Adding point intent between h" + str( i ) +
1353 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001354 host1 = "00:00:00:00:00:" + \
1355 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1356 host2 = "00:00:00:00:00:" + \
1357 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
shahshreyaf3076352015-01-23 13:52:01 -08001358 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1359 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1360 for host in hostsJson:
1361 if host[ 'id' ] == host1Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001362 ip1 = host[ 'ipAddresses' ][ 0 ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001363 ip1 = str( ip1 + "/32" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001364 device1 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001365 device1 = str( device1 + "/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001366 elif host[ 'id' ] == host2Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001367 ip2 = str( host[ 'ipAddresses' ][ 0 ] ) + "/32"
1368 device2 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001369 device2 = str( device2 + "/1" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001370
shahshreyaf3076352015-01-23 13:52:01 -08001371 pIntentResult1 = main.ONOScli1.addPointIntent(
1372 ingressDevice=device1,
1373 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001374 ipSrc=ip1,
1375 ipDst=ip2,
1376 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1377 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1378 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
shahshreyaf3076352015-01-23 13:52:01 -08001379 pIntentResult2 = main.ONOScli1.addPointIntent(
1380 ingressDevice=device2,
1381 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001382 ipSrc=ip2,
1383 ipDst=ip1,
1384 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1385 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1386 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
1387
shahshreyaf3076352015-01-23 13:52:01 -08001388 pIntentResult3 = main.ONOScli1.addPointIntent(
1389 ingressDevice=device1,
1390 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001391 ipSrc=ip1,
1392 ipDst=ip2,
1393 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1394 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1395 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
shahshreyaf3076352015-01-23 13:52:01 -08001396 pIntentResult4 = main.ONOScli1.addPointIntent(
1397 ingressDevice=device2,
1398 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001399 ipSrc=ip2,
1400 ipDst=ip1,
1401 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1402 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1403 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
shahshreyae6c7cf42014-11-26 16:39:01 -08001404
shahshreya234a1682015-05-27 15:41:56 -07001405 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1406 main.log.info( getIntentResult )
1407 pIntentResult = main.TRUE
1408 if getIntentResult:
shahshreyab512cd02015-01-27 17:01:47 -08001409 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001410 "Point intent related to SDN-IP matching" +
1411 " on TCP install successful" )
shahshreyab512cd02015-01-27 17:01:47 -08001412 else:
1413 main.log.report(
1414 "Point intent related to SDN-IP matching" +
1415 " on TCP install failed" )
shahshreya234a1682015-05-27 15:41:56 -07001416 pIntentResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -08001417
shahshreyaf3076352015-01-23 13:52:01 -08001418 iperfResult = main.Mininet1.iperf( 'h8', 'h18' )
1419 if iperfResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001420 main.log.report( "iperf test successful" )
1421 else:
1422 main.log.report( "iperf test failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001423
shahshreyaf3076352015-01-23 13:52:01 -08001424 case32Result = pIntentResult and iperfResult
1425 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001426 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001427 actual=case32Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001428 onpass="Ping all test after Point intents addition related " +
1429 "to SDN-IP on TCP match successful",
1430 onfail="Ping all test after Point intents addition related " +
1431 "to SDN-IP on TCP match failed" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001432
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001433 def CASE33( self ):
1434 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001435 This test case adds multipoint to singlepoint intent related to
1436 SDN-IP matching on destination ip and the action is to rewrite
1437 the mac address
1438 Here the mac address to be rewritten is the mac address of the
1439 egress device
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001440 """
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001441 import json
1442 import time
1443
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001444 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001445 "This test case adds multipoint to singlepoint intent related to" +
1446 " SDN-IP matching on destination ip and " +
1447 "rewrite mac address action" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001448 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001449 "Adding multipoint to singlepoint intent related to SDN-IP" +
1450 " matching on destination ip" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001451 main.step( "Adding bidirectional multipoint to singlepoint intent" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001452 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001453 add-multi-to-single-intent --ipDst=10.0.3.0/24
1454 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1
1455 of:0000000000006018/1
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001456
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001457 add-multi-to-single-intent --ipDst=10.0.1.0/24
1458 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1
1459 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001460 """
1461 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001462 "Installing multipoint to single point " +
1463 "intent with rewrite mac address" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001464 main.step( "Uninstalling proxy arp app" )
shahshreyad524a942015-04-21 09:55:16 -07001465 # deactivating proxyarp app
1466 appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.proxyarp" )
1467 appCheck = main.ONOScli1.appToIDCheck()
1468 if appCheck != main.TRUE:
1469 main.log.warn( main.ONOScli1.apps() )
1470 main.log.warn( main.ONOScli1.appIDs() )
1471 time.sleep( 30 )
1472 main.log.info( "onos-app-proxyarp deactivated" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001473
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001474 main.step( "Changing ipaddress of hosts h8,h9 and h18" )
1475 main.Mininet1.changeIP(
1476 host='h8',
1477 intf='h8-eth0',
1478 newIP='10.0.1.1',
1479 newNetmask='255.255.255.0' )
1480 main.Mininet1.changeIP(
1481 host='h9',
1482 intf='h9-eth0',
1483 newIP='10.0.2.1',
1484 newNetmask='255.255.255.0' )
1485 main.Mininet1.changeIP(
1486 host='h10',
1487 intf='h10-eth0',
1488 newIP='10.0.3.1',
1489 newNetmask='255.255.255.0' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001490
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001491 main.step( "Changing default gateway of hosts h8,h9 and h18" )
1492 main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' )
1493 main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' )
1494 main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001495
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001496 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001497 "Assigning random mac address to the default gateways " +
1498 "since proxyarp app is uninstalled" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001499 main.Mininet1.addStaticMACAddress(
1500 host='h8',
1501 GW='10.0.1.254',
1502 macaddr='00:00:00:00:11:11' )
1503 main.Mininet1.addStaticMACAddress(
1504 host='h9',
1505 GW='10.0.2.254',
1506 macaddr='00:00:00:00:22:22' )
1507 main.Mininet1.addStaticMACAddress(
1508 host='h10',
1509 GW='10.0.3.254',
1510 macaddr='00:00:00:00:33:33' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001511
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001512 main.step( "Verify static gateway and MAC address assignment" )
1513 main.Mininet1.verifyStaticGWandMAC( host='h8' )
1514 main.Mininet1.verifyStaticGWandMAC( host='h9' )
1515 main.Mininet1.verifyStaticGWandMAC( host='h10' )
1516
shahshreyab471a3e2015-03-19 17:07:13 -07001517 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ]
1518 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ]
1519 ingressDeviceList = []
1520 ingressDeviceList.append( ingressDevice1 )
1521 ingressDeviceList.append( ingressDevice2 )
1522
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001523 main.step( "Adding multipoint to singlepoint intent" )
shahshreyaf3076352015-01-23 13:52:01 -08001524 pIntentResult1 = main.ONOScli1.addMultipointToSinglepointIntent(
shahshreyab471a3e2015-03-19 17:07:13 -07001525 ingressDeviceList,
shahshreyaf3076352015-01-23 13:52:01 -08001526 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001527 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
1528 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
1529
shahshreyab471a3e2015-03-19 17:07:13 -07001530 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ]
1531 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ]
1532 ingressDeviceList = [ingressDevice1, ingressDevice2]
1533
shahshreyaf3076352015-01-23 13:52:01 -08001534 pIntentResult2 = main.ONOScli1.addMultipointToSinglepointIntent(
shahshreyab471a3e2015-03-19 17:07:13 -07001535 ingressDeviceList,
shahshreyaf3076352015-01-23 13:52:01 -08001536 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001537 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
1538 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
1539
shahshreyab471a3e2015-03-19 17:07:13 -07001540 pIntentResult = pIntentResult1 and pIntentResult2
1541 if pIntentResult == main.FALSE:
1542 main.log.info(
1543 "Multi point to single point intent " +
1544 "installation failed" )
1545 else:
1546 pIntentResult = main.TRUE
1547 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1548 main.log.info( "intents = " + getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001549
shahshreyab471a3e2015-03-19 17:07:13 -07001550 time.sleep( 10 )
1551 getFlowsResult = main.ONOScli1.flows( jsonFormat=False )
1552 main.log.info( "flows = " + getFlowsResult )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001553
shahshreyab471a3e2015-03-19 17:07:13 -07001554 count = 1
1555 i = 8
1556 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001557
shahshreyab471a3e2015-03-19 17:07:13 -07001558 main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
1559 ping = main.Mininet1.pingHost(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001560 src="h" + str( i ), target="h" + str( i + 2 ) )
shahshreyab471a3e2015-03-19 17:07:13 -07001561 if ping == main.FALSE and count < 3:
1562 count += 1
1563 PingResult = main.FALSE
1564 main.log.report( "Ping between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001565 str( i ) +
1566 " and h" +
1567 str( i +
1568 2 ) +
1569 " failed. Making attempt number " +
1570 str( count ) +
1571 " in 2 seconds" )
shahshreyab471a3e2015-03-19 17:07:13 -07001572 time.sleep( 2 )
1573 elif ping == main.FALSE:
1574 main.log.report( "All ping attempts between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001575 str( i ) +
1576 " and h" +
1577 str( i +
1578 10 ) +
1579 "have failed" )
shahshreyab471a3e2015-03-19 17:07:13 -07001580 PingResult = main.FALSE
1581 elif ping == main.TRUE:
1582 main.log.info( "Ping test between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001583 str( i ) +
1584 " and h" +
1585 str( i +
1586 2 ) +
shahshreyaa47ebf42015-05-20 13:29:18 -07001587 " passed!" )
shahshreyab471a3e2015-03-19 17:07:13 -07001588 PingResult = main.TRUE
1589 else:
1590 main.log.info( "Unknown error" )
1591 PingResult = main.ERROR
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001592
shahshreyab471a3e2015-03-19 17:07:13 -07001593 if PingResult == main.FALSE:
1594 main.log.report( "Ping test failed." )
1595 # main.cleanup()
1596 # main.exit()
1597 if PingResult == main.TRUE:
1598 main.log.report( "Ping all successful" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001599
shahshreyaf3076352015-01-23 13:52:01 -08001600 if pIntentResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001601 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001602 "Multi point intent with rewrite mac " +
shahshreyab471a3e2015-03-19 17:07:13 -07001603 "address installation and ping successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001604
shahshreyaf3076352015-01-23 13:52:01 -08001605 case33Result = pIntentResult and PingResult
1606 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001607 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001608 actual=case33Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001609 onpass="Ping all test after multipoint to single point" +
1610 " intent addition with rewrite mac address successful",
1611 onfail="Ping all test after multipoint to single point intent" +
1612 " addition with rewrite mac address failed" )
shahshreya1f119da2015-04-21 17:16:46 -07001613
1614 def CASE20( self ):
1615 """
1616 Exit from mininet cli
1617 reinstall ONOS
1618 """
shahshreyaa47ebf42015-05-20 13:29:18 -07001619 import time
shahshreya1f119da2015-04-21 17:16:46 -07001620 cellName = main.params[ 'ENV' ][ 'cellName' ]
1621 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
1622 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
1623 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
1624 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
1625 ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
1626 ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
1627
1628 main.log.report( "This testcase exits the mininet cli and reinstalls" +
1629 "ONOS to switch over to Packet Optical topology" )
1630 main.log.report( "_____________________________________________" )
1631 main.case( "Disconnecting mininet and restarting ONOS" )
1632 main.step( "Disconnecting mininet and restarting ONOS" )
1633 mininetDisconnect = main.Mininet1.disconnect()
1634 print "mininetDisconnect = ", mininetDisconnect
1635
1636 main.step( "Removing raft logs before a clen installation of ONOS" )
1637 main.ONOSbench.onosRemoveRaftLogs()
1638
1639 main.step( "Applying cell variable to environment" )
1640 cellResult = main.ONOSbench.setCell( cellName )
1641 verifyResult = main.ONOSbench.verifyCell()
1642
shahshreyaa47ebf42015-05-20 13:29:18 -07001643 time.sleep( 5 )
1644 main.step( "Uninstalling ONOS package" )
1645 onos1UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS1Ip)
1646 onos2UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS2Ip)
1647 onos3UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS3Ip)
1648 onosUninstallResult = onos1UninstallResult and onos2UninstallResult \
1649 and onos3UninstallResult
1650 time.sleep( 15 )
shahshreya1f119da2015-04-21 17:16:46 -07001651 main.step( "Installing ONOS package" )
1652 onos1InstallResult = main.ONOSbench.onosInstall(
1653 options="-f",
1654 node=ONOS1Ip )
1655 onos2InstallResult = main.ONOSbench.onosInstall(
1656 options="-f",
1657 node=ONOS2Ip )
1658 onos3InstallResult = main.ONOSbench.onosInstall(
1659 options="-f",
1660 node=ONOS3Ip )
1661 onosInstallResult = onos1InstallResult and onos2InstallResult and\
1662 onos3InstallResult
1663 if onosInstallResult == main.TRUE:
1664 main.log.report( "Installing ONOS package successful" )
1665 else:
1666 main.log.report( "Installing ONOS package failed" )
1667
shahshreyaa47ebf42015-05-20 13:29:18 -07001668 time.sleep( 10 )
shahshreya1f119da2015-04-21 17:16:46 -07001669 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
1670 onos2Isup = main.ONOSbench.isup( ONOS2Ip )
1671 onos3Isup = main.ONOSbench.isup( ONOS3Ip )
1672 onosIsup = onos1Isup and onos2Isup and onos3Isup
1673 if onosIsup == main.TRUE:
1674 main.log.report( "ONOS instances are up and ready" )
1675 else:
1676 main.log.report( "ONOS instances may not be up" )
1677
1678 main.step( "Starting ONOS service" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001679 time.sleep( 10 )
shahshreya1f119da2015-04-21 17:16:46 -07001680 startResult = main.TRUE
1681 # startResult = main.ONOSbench.onosStart( ONOS1Ip )
1682 startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip )
1683 startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip )
1684 startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip )
1685 startResult = startcli1 and startcli2 and startcli3
1686 if startResult == main.TRUE:
1687 main.log.report( "ONOS cli starts properly" )
1688 case20Result = mininetDisconnect and cellResult and verifyResult \
1689 and onosInstallResult and onosIsup and startResult
1690
1691 utilities.assert_equals(
1692 expect=main.TRUE,
1693 actual=case20Result,
1694 onpass= "Exiting functionality mininet topology and reinstalling" +
1695 " ONOS successful",
1696 onfail= "Exiting functionality mininet topology and reinstalling" +
1697 " ONOS failed" )
1698
1699 def CASE21( self, main ):
1700 """
1701 On ONOS bench, run this command:
1702 sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1 <Ctrls>
1703 which spawns packet optical topology and copies the links
1704 json file to the onos instance.
1705 Note that in case of Packet Optical, the links are not learnt
1706 from the topology, instead the links are learnt
1707 from the json config file
1708 """
1709 main.log.report(
1710 "This testcase starts the packet layer topology and REST" )
1711 main.log.report( "_____________________________________________" )
1712 main.case( "Starting LINC-OE and other components" )
1713 main.step( "Starting LINC-OE and other components" )
1714 main.log.info( "Activate optical app" )
1715 appInstallResult = main.ONOScli1.activateApp( "org.onosproject.optical" )
1716 appCheck = main.ONOScli1.appToIDCheck()
1717 appCheck = appCheck and main.ONOScli2.appToIDCheck()
1718 appCheck = appCheck and main.ONOScli3.appToIDCheck()
1719 if appCheck != main.TRUE:
1720 main.log.warn( "Checking ONOS application unsuccesful" )
1721
1722 ctrllerIP = []
1723 ctrllerIP.append( main.params[ 'CTRL' ][ 'ip1' ] )
1724 #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip2' ] )
1725 #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip3' ] )
1726 opticalMnScript = main.LincOE2.runOpticalMnScript( ctrllerIP = ctrllerIP )
1727 case21Result = opticalMnScript and appInstallResult
1728 utilities.assert_equals(
1729 expect=main.TRUE,
1730 actual=case21Result,
1731 onpass="Packet optical topology spawned successsfully",
1732 onfail="Packet optical topology spawning failed" )
1733
1734 def CASE22( self, main ):
1735 """
1736 Curretly we use, 10 optical switches(ROADM's) and
1737 6 packet layer mininet switches each with one host.
1738 Therefore, the roadmCount variable = 10,
1739 packetLayerSWCount variable = 6, hostCount=6 and
shahshreyaa47ebf42015-05-20 13:29:18 -07001740 links=46.
shahshreya1f119da2015-04-21 17:16:46 -07001741 All this is hardcoded in the testcase. If the topology changes,
1742 these hardcoded values need to be changed
1743 """
shahshreyaa47ebf42015-05-20 13:29:18 -07001744 import time
shahshreya1f119da2015-04-21 17:16:46 -07001745 main.log.report(
1746 "This testcase compares the optical+packet topology against what" +
1747 " is expected" )
1748 main.case( "Topology comparision" )
1749 main.step( "Topology comparision" )
1750 devicesResult = main.ONOScli3.devices( jsonFormat=False )
shahshreyaa47ebf42015-05-20 13:29:18 -07001751 time.sleep( 15 )
shahshreya1f119da2015-04-21 17:16:46 -07001752 print "devices_result = ", devicesResult
1753 devicesLinewise = devicesResult.split( "\n" )
shahshreya1f119da2015-04-21 17:16:46 -07001754 roadmCount = 0
1755 packetLayerSWCount = 0
1756 for line in devicesLinewise:
1757 components = line.split( "," )
1758 availability = components[ 1 ].split( "=" )[ 1 ]
1759 type = components[ 3 ].split( "=" )[ 1 ]
1760 if availability == 'true' and type == 'ROADM':
1761 roadmCount += 1
1762 elif availability == 'true' and type == 'SWITCH':
1763 packetLayerSWCount += 1
1764 if roadmCount == 10:
1765 print "Number of Optical Switches = %d and is" % roadmCount +\
1766 " correctly detected"
1767 main.log.info(
1768 "Number of Optical Switches = " +
1769 str( roadmCount ) +
1770 " and is correctly detected" )
1771 opticalSWResult = main.TRUE
1772 else:
1773 print "Number of Optical Switches = %d and is wrong" % roadmCount
1774 main.log.info(
1775 "Number of Optical Switches = " +
1776 str( roadmCount ) +
1777 " and is wrong" )
1778 opticalSWResult = main.FALSE
1779
1780 if packetLayerSWCount == 6:
1781 print "Number of Packet layer or mininet Switches = %d "\
1782 % packetLayerSWCount + "and is correctly detected"
1783 main.log.info(
1784 "Number of Packet layer or mininet Switches = " +
1785 str( packetLayerSWCount ) +
1786 " and is correctly detected" )
1787 packetSWResult = main.TRUE
1788 else:
1789 print "Number of Packet layer or mininet Switches = %d and"\
1790 % packetLayerSWCount + " is wrong"
1791 main.log.info(
1792 "Number of Packet layer or mininet Switches = " +
1793 str( packetLayerSWCount ) +
1794 " and is wrong" )
1795 packetSWResult = main.FALSE
1796 print "_________________________________"
1797
1798 linksResult = main.ONOScli3.links( jsonFormat=False )
1799 print "links_result = ", linksResult
1800 print "_________________________________"
1801 linkActiveCount = linksResult.count("state=ACTIVE")
1802 main.log.info( "linkActiveCount = " + str( linkActiveCount ))
shahshreyaa47ebf42015-05-20 13:29:18 -07001803 if linkActiveCount == 46:
shahshreya1f119da2015-04-21 17:16:46 -07001804 linkActiveResult = main.TRUE
1805 main.log.info(
1806 "Number of links in ACTIVE state are correct")
1807 else:
1808 linkActiveResult = main.FALSE
1809 main.log.info(
1810 "Number of links in ACTIVE state are wrong")
1811
1812 case22Result = opticalSWResult and packetSWResult and \
1813 linkActiveResult
1814 utilities.assert_equals(
1815 expect=main.TRUE,
1816 actual=case22Result,
1817 onpass="Packet optical topology discovery successful",
1818 onfail="Packet optical topology discovery failed" )
1819
1820 def CASE23( self, main ):
1821 import time
1822 """
1823 Add bidirectional point intents between 2 packet layer( mininet )
1824 devices and
1825 ping mininet hosts
1826 """
1827 main.log.report(
1828 "This testcase adds bidirectional point intents between 2 " +
1829 "packet layer( mininet ) devices and ping mininet hosts" )
1830 main.case( "Topology comparision" )
1831 main.step( "Adding point intents" )
1832 ptpIntentResult = main.ONOScli1.addPointIntent(
1833 "of:0000ffffffff0001/1",
1834 "of:0000ffffffff0005/1" )
1835 if ptpIntentResult == main.TRUE:
1836 main.ONOScli1.intents( jsonFormat=False )
1837 main.log.info( "Point to point intent install successful" )
1838
1839 ptpIntentResult = main.ONOScli1.addPointIntent(
1840 "of:0000ffffffff0005/1",
1841 "of:0000ffffffff0001/1" )
1842 if ptpIntentResult == main.TRUE:
1843 main.ONOScli1.intents( jsonFormat=False )
1844 main.log.info( "Point to point intent install successful" )
1845
1846 time.sleep( 30 )
shahshreyabf739d82015-06-10 11:22:31 -07001847 #flowHandle = main.ONOScli1.flows()
1848 #main.log.info( "flows :" + flowHandle )
shahshreya1f119da2015-04-21 17:16:46 -07001849
1850 # Sleep for 30 seconds to provide time for the intent state to change
1851 time.sleep( 60 )
1852 intentHandle = main.ONOScli1.intents( jsonFormat=False )
1853 main.log.info( "intents :" + intentHandle )
1854
1855 PingResult = main.TRUE
1856 count = 1
1857 main.log.info( "\n\nh1 is Pinging h5" )
1858 ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
1859 # ping = main.LincOE2.pinghost()
1860 if ping == main.FALSE and count < 5:
1861 count += 1
1862 PingResult = main.FALSE
1863 main.log.info(
1864 "Ping between h1 and h5 failed. Making attempt number " +
1865 str( count ) +
1866 " in 2 seconds" )
1867 time.sleep( 2 )
1868 elif ping == main.FALSE:
1869 main.log.info( "All ping attempts between h1 and h5 have failed" )
1870 PingResult = main.FALSE
1871 elif ping == main.TRUE:
1872 main.log.info( "Ping test between h1 and h5 passed!" )
1873 PingResult = main.TRUE
1874 else:
1875 main.log.info( "Unknown error" )
1876 PingResult = main.ERROR
1877
1878 if PingResult == main.FALSE:
1879 main.log.report(
1880 "Point intents for packet optical have not ben installed" +
1881 " correctly. Cleaning up" )
1882 if PingResult == main.TRUE:
1883 main.log.report(
1884 "Point Intents for packet optical have been " +
1885 "installed correctly" )
1886
1887 case23Result = PingResult
1888 utilities.assert_equals(
1889 expect=main.TRUE,
1890 actual=case23Result,
1891 onpass= "Point intents addition for packet optical and" +
1892 "Pingall Test successful",
1893 onfail= "Point intents addition for packet optical and" +
1894 "Pingall Test NOT successful" )
1895
1896 def CASE24( self, main ):
1897 import time
1898 import json
1899 """
1900 LINC uses its own switch IDs. You can use the following
1901 command on the LINC console to find the mapping between
1902 DPIDs and LINC IDs.
1903 rp(application:get_all_key(linc)).
1904
1905 Test Rerouting of Packet Optical by bringing a port down
1906 ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
1907 so that link
1908 ( between switch1 port20 - switch5 port50 ) is inactive
1909 and do a ping test. If rerouting is successful,
1910 ping should pass. also check the flows
1911 """
1912 main.log.report(
1913 "This testcase tests rerouting and pings mininet hosts" )
1914 main.case( "Test rerouting and pings mininet hosts" )
1915 main.step( "Attach to the Linc-OE session" )
1916 attachConsole = main.LincOE1.attachLincOESession()
1917 print "attachConsole = ", attachConsole
1918
1919 main.step( "Bring a port down and verify the link state" )
1920 main.LincOE1.portDown( swId="9", ptId="20" )
1921 linksNonjson = main.ONOScli3.links( jsonFormat=False )
1922 main.log.info( "links = " + linksNonjson )
1923
1924 linkInactiveCount = linksNonjson.count("state=INACTIVE")
1925 main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
1926 if linkInactiveCount == 2:
1927 main.log.info(
1928 "Number of links in INACTIVE state are correct")
1929 else:
1930 main.log.info(
1931 "Number of links in INACTIVE state are wrong")
1932
1933 links = main.ONOScli3.links()
1934 main.log.info( "links = " + links )
1935
1936 linksResult = json.loads( links )
1937 linksStateResult = main.FALSE
1938 for item in linksResult:
1939 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
1940 'src' ][ 'port' ] == "20":
1941 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
1942 'dst' ][ 'port' ] == "50":
1943 linksState = item[ 'state' ]
1944 if linksState == "INACTIVE":
1945 main.log.info(
1946 "Links state is inactive as expected due to one" +
1947 " of the ports being down" )
1948 main.log.report(
1949 "Links state is inactive as expected due to one" +
1950 " of the ports being down" )
1951 linksStateResult = main.TRUE
1952 break
1953 else:
1954 main.log.info(
1955 "Links state is not inactive as expected" )
1956 main.log.report(
1957 "Links state is not inactive as expected" )
1958 linksStateResult = main.FALSE
1959
1960 print "links_state_result = ", linksStateResult
1961 time.sleep( 10 )
shahshreyabf739d82015-06-10 11:22:31 -07001962 #flowHandle = main.ONOScli3.flows()
1963 #main.log.info( "flows :" + flowHandle )
shahshreya1f119da2015-04-21 17:16:46 -07001964
1965 main.step( "Verify Rerouting by a ping test" )
1966 PingResult = main.TRUE
1967 count = 1
1968 main.log.info( "\n\nh1 is Pinging h5" )
1969 ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
1970 # ping = main.LincOE2.pinghost()
1971 if ping == main.FALSE and count < 5:
1972 count += 1
1973 PingResult = main.FALSE
1974 main.log.info(
1975 "Ping between h1 and h5 failed. Making attempt number " +
1976 str( count ) +
1977 " in 2 seconds" )
1978 time.sleep( 2 )
1979 elif ping == main.FALSE:
1980 main.log.info( "All ping attempts between h1 and h5 have failed" )
1981 PingResult = main.FALSE
1982 elif ping == main.TRUE:
1983 main.log.info( "Ping test between h1 and h5 passed!" )
1984 PingResult = main.TRUE
1985 else:
1986 main.log.info( "Unknown error" )
1987 PingResult = main.ERROR
1988
1989 if PingResult == main.TRUE:
1990 main.log.report( "Ping test successful " )
1991 if PingResult == main.FALSE:
1992 main.log.report( "Ping test failed" )
1993
1994 case24Result = PingResult and linksStateResult
1995 utilities.assert_equals( expect=main.TRUE, actual=case24Result,
1996 onpass="Packet optical rerouting successful",
1997 onfail="Packet optical rerouting failed" )