blob: d3ed75788e3ffebebe0122180495850fcc762ca4 [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' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080038
39 main.case( "Setting up test environment" )
40 main.log.report(
41 "This testcase is testing setting up test environment" )
42 main.log.report( "__________________________________" )
43
44 main.step( "Applying cell variable to environment" )
shahshreyaf3076352015-01-23 13:52:01 -080045 cellResult1 = main.ONOSbench.setCell( cellName )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080046 # cellResult2 = main.ONOScli1.setCell( cellName )
47 # cellResult3 = main.ONOScli2.setCell( cellName )
48 # cellResult4 = main.ONOScli3.setCell( cellName )
shahshreyaf3076352015-01-23 13:52:01 -080049 verifyResult = main.ONOSbench.verifyCell()
50 cellResult = cellResult1
shahshreyae6c7cf42014-11-26 16:39:01 -080051
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080052 main.step( "Removing raft logs before a clen installation of ONOS" )
shahshreyaf3076352015-01-23 13:52:01 -080053 removeLogResult = main.ONOSbench.onosRemoveRaftLogs()
shahshreyae6c7cf42014-11-26 16:39:01 -080054
shahshreyab512cd02015-01-27 17:01:47 -080055 main.step( "Git checkout, pull and get version" )
56 #main.ONOSbench.gitCheckout( "master" )
shahshreyaf3076352015-01-23 13:52:01 -080057 gitPullResult = main.ONOSbench.gitPull()
58 print "git_pull_result = ", gitPullResult
59 versionResult = main.ONOSbench.getVersion( report=True )
shahshreya4e13a062014-11-11 16:46:18 -080060
shahshreyaf3076352015-01-23 13:52:01 -080061 if gitPullResult == 1:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080062 main.step( "Using mvn clean & install" )
shahshreyaf3076352015-01-23 13:52:01 -080063 cleanInstallResult = main.ONOSbench.cleanInstall()
kelvin-onlabcf33bda2015-01-23 16:54:17 -080064 # cleanInstallResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -080065
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080066 main.step( "Creating ONOS package" )
shahshreyaf3076352015-01-23 13:52:01 -080067 packageResult = main.ONOSbench.onosPackage()
shahshreya4e13a062014-11-11 16:46:18 -080068
kelvin-onlabcf33bda2015-01-23 16:54:17 -080069 # main.step( "Creating a cell" )
shahshreyaf3076352015-01-23 13:52:01 -080070 # cellCreateResult = main.ONOSbench.createCellFile( **************
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080071 # )
shahshreya4e13a062014-11-11 16:46:18 -080072
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080073 main.step( "Installing ONOS package" )
shahshreyaf3076352015-01-23 13:52:01 -080074 onos1InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080075 options="-f",
shahshreyaf3076352015-01-23 13:52:01 -080076 node=ONOS1Ip )
77 onos2InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080078 options="-f",
shahshreyaf3076352015-01-23 13:52:01 -080079 node=ONOS2Ip )
80 onos3InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080081 options="-f",
shahshreyaf3076352015-01-23 13:52:01 -080082 node=ONOS3Ip )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080083 onosInstallResult = onos1InstallResult and onos2InstallResult and\
84 onos3InstallResult
shahshreyaf3076352015-01-23 13:52:01 -080085 if onosInstallResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080086 main.log.report( "Installing ONOS package successful" )
shahshreya4e13a062014-11-11 16:46:18 -080087 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080088 main.log.report( "Installing ONOS package failed" )
89
shahshreyaf3076352015-01-23 13:52:01 -080090 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
91 onos2Isup = main.ONOSbench.isup( ONOS2Ip )
92 onos3Isup = main.ONOSbench.isup( ONOS3Ip )
93 onosIsup = onos1Isup and onos2Isup and onos3Isup
94 if onosIsup == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080095 main.log.report( "ONOS instances are up and ready" )
shahshreya4e13a062014-11-11 16:46:18 -080096 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080097 main.log.report( "ONOS instances may not be up" )
shahshreya4e13a062014-11-11 16:46:18 -080098
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080099 main.step( "Starting ONOS service" )
shahshreyaf3076352015-01-23 13:52:01 -0800100 startResult = main.TRUE
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800101 # startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreyaf3076352015-01-23 13:52:01 -0800102 startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip )
103 startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip )
104 startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800105 print startcli1
106 print startcli2
107 print startcli3
shahshreya4e13a062014-11-11 16:46:18 -0800108
shahshreyaf3076352015-01-23 13:52:01 -0800109 case1Result = ( packageResult and
110 cellResult and verifyResult and onosInstallResult and
111 onosIsup and startResult )
112 utilities.assertEquals( expect=main.TRUE, actual=case1Result,
113 onpass="Test startup successful",
114 onfail="Test startup NOT successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800115
116 def CASE11( self, main ):
117 """
shahshreya4e13a062014-11-11 16:46:18 -0800118 Cleanup sequence:
shahshreyaf3076352015-01-23 13:52:01 -0800119 onos-service <nodeIp> stop
shahshreya4e13a062014-11-11 16:46:18 -0800120 onos-uninstall
121
122 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800123
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800124 """
shahshreyaf3076352015-01-23 13:52:01 -0800125 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
126 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
127 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
shahshreya4e13a062014-11-11 16:46:18 -0800128
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800129 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800130
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800131 main.step( "Testing ONOS kill function" )
shahshreyaf3076352015-01-23 13:52:01 -0800132 killResult1 = main.ONOSbench.onosKill( ONOS1Ip )
133 killResult2 = main.ONOSbench.onosKill( ONOS2Ip )
134 killResult3 = main.ONOSbench.onosKill( ONOS3Ip )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800135
136 main.step( "Stopping ONOS service" )
shahshreyaf3076352015-01-23 13:52:01 -0800137 stopResult1 = main.ONOSbench.onosStop( ONOS1Ip )
138 stopResult2 = main.ONOSbench.onosStop( ONOS2Ip )
139 stopResult3 = main.ONOSbench.onosStop( ONOS3Ip )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800140
141 main.step( "Uninstalling ONOS service" )
shahshreyaf3076352015-01-23 13:52:01 -0800142 uninstallResult = main.ONOSbench.onosUninstall()
shahshreya4e13a062014-11-11 16:46:18 -0800143
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800144 def CASE3( self, main ):
145 """
shahshreya4e13a062014-11-11 16:46:18 -0800146 Test 'onos' command and its functionality in driver
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800147 """
shahshreyaf3076352015-01-23 13:52:01 -0800148 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
149 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
150 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
shahshreya4e13a062014-11-11 16:46:18 -0800151
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800152 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800153
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800154 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800155 cmdstr1 = "system:name"
shahshreyaf3076352015-01-23 13:52:01 -0800156 cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
157 main.log.info( "onos command returned: " + cmdResult1 )
158 cmdResult2 = main.ONOSbench.onosCli( ONOS2Ip, cmdstr1 )
159 main.log.info( "onos command returned: " + cmdResult2 )
160 cmdResult3 = main.ONOSbench.onosCli( ONOS3Ip, cmdstr1 )
161 main.log.info( "onos command returned: " + cmdResult3 )
shahshreya4e13a062014-11-11 16:46:18 -0800162
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800163 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800164 cmdstr2 = "onos:topology"
shahshreyaf3076352015-01-23 13:52:01 -0800165 cmdResult4 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
166 main.log.info( "onos command returned: " + cmdResult4 )
167 cmdResult5 = main.ONOSbench.onosCli( ONOS2Ip, cmdstr2 )
168 main.log.info( "onos command returned: " + cmdResult5 )
169 cmdResult6 = main.ONOSbench.onosCli( ONOS6Ip, cmdstr2 )
170 main.log.info( "onos command returned: " + cmdResult6 )
shahshreya4e13a062014-11-11 16:46:18 -0800171
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800172 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800173 import re
174 import time
shahshreyaf3076352015-01-23 13:52:01 -0800175 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
176 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
177 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
178 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
179 ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
180 ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800181
182 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800183 "This testcase is testing the assignment of all the switches" +
184 " to all controllers and discovering the hosts in reactive mode" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800185 main.log.report( "__________________________________" )
186 main.case( "Pingall Test(No intents are added)" )
187 main.step( "Assigning switches to controllers" )
188 for i in range( 1, 29 ): # 1 to ( num of switches +1 )
shahshreyaf3076352015-01-23 13:52:01 -0800189 main.Mininet1.assignSwController(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800190 sw=str( i ),
191 count=3,
shahshreyaf3076352015-01-23 13:52:01 -0800192 ip1=ONOS1Ip,
193 port1=ONOS1Port,
194 ip2=ONOS2Ip,
195 port2=ONOS2Port,
196 ip3=ONOS3Ip,
197 port3=ONOS3Port )
shahshreya4e13a062014-11-11 16:46:18 -0800198
shahshreyaf3076352015-01-23 13:52:01 -0800199 switchMastership = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800200 for i in range( 1, 29 ):
shahshreyaf3076352015-01-23 13:52:01 -0800201 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800202 print( "Response is " + str( response ) )
shahshreyaf3076352015-01-23 13:52:01 -0800203 if re.search( "tcp:" + ONOS1Ip, response ):
204 switchMastership = switchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800205 else:
shahshreyaf3076352015-01-23 13:52:01 -0800206 switchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800207
shahshreyaf3076352015-01-23 13:52:01 -0800208 if switchMastership == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800209 main.log.report( "Controller assignment successfull" )
shahshreya4e13a062014-11-11 16:46:18 -0800210 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800211 main.log.report( "Controller assignment failed" )
212 # REACTIVE FWD test
213 main.step( "Pingall" )
shahshreyaf3076352015-01-23 13:52:01 -0800214 pingResult = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800215 time1 = time.time()
shahshreyaf3076352015-01-23 13:52:01 -0800216 pingResult = main.Mininet1.pingall()
shahshreya4e13a062014-11-11 16:46:18 -0800217 time2 = time.time()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800218 print "Time for pingall: %2f seconds" % ( time2 - time1 )
219
shahshreyaf3076352015-01-23 13:52:01 -0800220 case4Result = switchMastership and pingResult
221 if pingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800222 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800223 "Pingall Test in reactive mode to" +
224 " discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800225 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800226 main.log.report(
227 "Pingall Test in reactive mode to discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800228
shahshreyaf3076352015-01-23 13:52:01 -0800229 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800230 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800231 actual=case4Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800232 onpass="Controller assignment and Pingall Test successful",
233 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800234
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800235 def CASE5( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800236 import json
237 from subprocess import Popen, PIPE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800238 # assumes that sts is already in you PYTHONPATH
239 from sts.topology.teston_topology import TestONTopology
shahshreyaf3076352015-01-23 13:52:01 -0800240 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
241 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
242 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800243
244 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800245 "This testcase is testing if all ONOS nodes are in topologyi" +
246 " sync with mininet and its peer ONOS nodes" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800247 main.log.report( "__________________________________" )
248 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800249 "Testing Mininet topology with the" +
250 " topology of multi instances ONOS" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800251 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800252 devices1 = main.ONOScli1.devices()
253 devices2 = main.ONOScli2.devices()
254 devices3 = main.ONOScli3.devices()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800255 # print "devices1 = ", devices1
256 # print "devices2 = ", devices2
257 # print "devices3 = ", devices3
shahshreya4e13a062014-11-11 16:46:18 -0800258 hosts1 = main.ONOScli1.hosts()
259 hosts2 = main.ONOScli2.hosts()
260 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800261 # print "hosts1 = ", hosts1
262 # print "hosts2 = ", hosts2
263 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800264 ports1 = main.ONOScli1.ports()
265 ports2 = main.ONOScli2.ports()
266 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800267 # print "ports1 = ", ports1
268 # print "ports2 = ", ports2
269 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800270 links1 = main.ONOScli1.links()
271 links2 = main.ONOScli2.links()
272 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800273 # print "links1 = ", links1
274 # print "links2 = ", links2
275 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800276
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800277 print "**************"
278
279 main.step( "Start continuous pings" )
280 main.Mininet2.pingLong(
281 src=main.params[ 'PING' ][ 'source1' ],
282 target=main.params[ 'PING' ][ 'target1' ],
283 pingTime=500 )
284 main.Mininet2.pingLong(
285 src=main.params[ 'PING' ][ 'source2' ],
286 target=main.params[ 'PING' ][ 'target2' ],
287 pingTime=500 )
288 main.Mininet2.pingLong(
289 src=main.params[ 'PING' ][ 'source3' ],
290 target=main.params[ 'PING' ][ 'target3' ],
291 pingTime=500 )
292 main.Mininet2.pingLong(
293 src=main.params[ 'PING' ][ 'source4' ],
294 target=main.params[ 'PING' ][ 'target4' ],
295 pingTime=500 )
296 main.Mininet2.pingLong(
297 src=main.params[ 'PING' ][ 'source5' ],
298 target=main.params[ 'PING' ][ 'target5' ],
299 pingTime=500 )
300 main.Mininet2.pingLong(
301 src=main.params[ 'PING' ][ 'source6' ],
302 target=main.params[ 'PING' ][ 'target6' ],
303 pingTime=500 )
304 main.Mininet2.pingLong(
305 src=main.params[ 'PING' ][ 'source7' ],
306 target=main.params[ 'PING' ][ 'target7' ],
307 pingTime=500 )
308 main.Mininet2.pingLong(
309 src=main.params[ 'PING' ][ 'source8' ],
310 target=main.params[ 'PING' ][ 'target8' ],
311 pingTime=500 )
312 main.Mininet2.pingLong(
313 src=main.params[ 'PING' ][ 'source9' ],
314 target=main.params[ 'PING' ][ 'target9' ],
315 pingTime=500 )
316 main.Mininet2.pingLong(
317 src=main.params[ 'PING' ][ 'source10' ],
318 target=main.params[ 'PING' ][ 'target10' ],
319 pingTime=500 )
320
321 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800322 global ctrls
323 ctrls = []
324 count = 1
325 while True:
326 temp = ()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800327 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
328 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
329 temp = temp + ( "ONOS" + str( count ), )
330 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
331 temp = temp + \
332 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
333 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800334 count = count + 1
335 else:
336 break
337 global MNTopo
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800338 Topo = TestONTopology(
339 main.Mininet1,
340 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800341 MNTopo = Topo
342
shahshreyaf3076352015-01-23 13:52:01 -0800343 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800344 main.step( "Compare ONOS Topology to MN Topology" )
345
shahshreyaf3076352015-01-23 13:52:01 -0800346 switchesResults1 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800347 MNTopo,
348 json.loads( devices1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800349 print "switches_Result1 = ", switchesResults1
350 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
351 onpass="ONOS1 Switches view is correct",
352 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800353
shahshreyaf3076352015-01-23 13:52:01 -0800354 switchesResults2 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800355 MNTopo,
356 json.loads( devices2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800357 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
358 onpass="ONOS2 Switches view is correct",
359 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800360
shahshreyaf3076352015-01-23 13:52:01 -0800361 switchesResults3 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800362 MNTopo,
363 json.loads( devices3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800364 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
365 onpass="ONOS3 Switches view is correct",
366 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800367
368 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800369 portsResults1 = main.Mininet1.comparePorts( MNTopo,
370 json.loads( ports1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800371 utilities.assertEquals( expect=main.TRUE, actual=portsResults1,
shahshreya4e13a062014-11-11 16:46:18 -0800372 onpass="ONOS1 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800373 onfail="ONOS1 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800374
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800375 portsResults2 = main.Mininet1.comparePorts( MNTopo,
376 json.loads( ports2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800377 utilities.assertEquals( expect=main.TRUE, actual=portsResults2,
shahshreya4e13a062014-11-11 16:46:18 -0800378 onpass="ONOS2 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800379 onfail="ONOS2 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800380
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800381 portsResults3 = main.Mininet1.comparePorts( MNTopo,
382 json.loads( ports3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800383 utilities.assertEquals( expect=main.TRUE, actual=portsResults3,
shahshreya4e13a062014-11-11 16:46:18 -0800384 onpass="ONOS3 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800385 onfail="ONOS3 Ports view is incorrect" )
386 """
shahshreyaf3076352015-01-23 13:52:01 -0800387 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800388 MNTopo,
389 json.loads( links1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800390 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
391 onpass="ONOS1 Links view is correct",
392 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800393
shahshreyaf3076352015-01-23 13:52:01 -0800394 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800395 MNTopo,
396 json.loads( links2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800397 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
398 onpass="ONOS2 Links view is correct",
399 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800400
shahshreyaf3076352015-01-23 13:52:01 -0800401 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800402 MNTopo,
403 json.loads( links3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800404 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
405 onpass="ONOS2 Links view is correct",
406 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800407
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800408 # topoResult = switchesResults1 and switchesResults2
409 # and switchesResults3\
shahshreyaf3076352015-01-23 13:52:01 -0800410 # and portsResults1 and portsResults2 and portsResults3\
411 # and linksResults1 and linksResults2 and linksResults3
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800412
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800413 topoResult = switchesResults1 and switchesResults2 and\
414 switchesResults3 and linksResults1 and linksResults2 and\
415 linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800416
shahshreyaf3076352015-01-23 13:52:01 -0800417 if topoResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800418 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800419 "Topology Check Test with mininet" +
420 "and ONOS instances successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800421 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800422 main.log.report(
423 "Topology Check Test with mininet and ONOS instances failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800424
shahshreyaf3076352015-01-23 13:52:01 -0800425 utilities.assertEquals( expect=main.TRUE, actual=topoResult,
426 onpass="Topology Check Test successful",
427 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800428
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800429 def CASE10( self ):
430 main.log.report(
431 "This testcase uninstalls the reactive forwarding app" )
432 main.log.report( "__________________________________" )
433 main.case( "Uninstalling reactive forwarding app" )
434 # Unistall onos-app-fwd app to disable reactive forwarding
shahshreyaf3076352015-01-23 13:52:01 -0800435 appUninstallResult1 = main.ONOScli1.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800436 "onos-app-fwd" )
shahshreyaf3076352015-01-23 13:52:01 -0800437 appUninstallResult2 = main.ONOScli2.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800438 "onos-app-fwd" )
shahshreyaf3076352015-01-23 13:52:01 -0800439 appUninstallResult3 = main.ONOScli3.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800440 "onos-app-fwd" )
441 main.log.info( "onos-app-fwd uninstalled" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800442
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800443 # After reactive forwarding is disabled,
444 # the reactive flows on switches timeout in 10-15s
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800445 # So sleep for 15s
446 time.sleep( 15 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800447
shahshreyae6c7cf42014-11-26 16:39:01 -0800448 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800449 main.log.info( hosts )
450
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800451 case10Result = appUninstallResult1 and\
452 appUninstallResult2 and appUninstallResult3
shahshreyaf3076352015-01-23 13:52:01 -0800453 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800454 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800455 actual=case10Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800456 onpass="Reactive forwarding app uninstallation successful",
457 onfail="Reactive forwarding app uninstallation failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800458
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800459 def CASE6( self ):
460 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800461 "This testcase is testing the addition of" +
462 " host intents and then doing pingall" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800463 main.log.report( "__________________________________" )
464 main.case( "Obtaining hostsfor adding host intents" )
465 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800466 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800467 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800468
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800469 main.step( "Get all devices id" )
shahshreyaf3076352015-01-23 13:52:01 -0800470 devicesIdList = main.ONOScli1.getAllDevicesId()
471 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -0800472
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800473 # ONOS displays the hosts in hex format
474 # unlike mininet which does in decimal format
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800475 # So take care while adding intents
shahshreya4e13a062014-11-11 16:46:18 -0800476
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800477 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800478 main.step( "Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,
479 h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
480 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:08/-1",
481 "00:00:00:00:00:12/-1" )
482 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:09/-1",
483 "00:00:00:00:00:13/-1" )
484 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0A/-1",
485 "00:00:00:00:00:14/-1" )
486 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0B/-1",
487 "00:00:00:00:00:15/-1" )
488 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0C/-1",
489 "00:00:00:00:00:16/-1" )
490 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0D/-1",
491 "00:00:00:00:00:17/-1" )
492 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0E/-1",
493 "00:00:00:00:00:18/-1" )
494 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0F/-1",
495 "00:00:00:00:00:19/-1" )
496 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:10/-1",
497 "00:00:00:00:00:1A/-1" )
498 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:11/-1",
499 "00:00:00:00:00:1B/-1" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800500 """
501 for i in range( 8, 18 ):
502 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800503 "Adding host intent between h" + str( i ) +
504 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800505 host1 = "00:00:00:00:00:" + \
506 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
507 host2 = "00:00:00:00:00:" + \
508 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
509 # NOTE: get host can return None
510 # TODO: handle this
shahshreyaf3076352015-01-23 13:52:01 -0800511 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
512 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
513 tmpResult = main.ONOScli1.addHostIntent( host1Id, host2Id )
shahshreya4e13a062014-11-11 16:46:18 -0800514
515 flowHandle = main.ONOScli1.flows()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800516 main.log.info( "flows:" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -0800517
518 count = 1
519 i = 8
shahshreyaf3076352015-01-23 13:52:01 -0800520 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800521 while i < 18:
522 main.log.info(
523 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
524 ping = main.Mininet1.pingHost(
525 src="h" + str( i ), target="h" + str( i + 10 ) )
526 if ping == main.FALSE and count < 5:
527 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800528 # i = 8
shahshreyaf3076352015-01-23 13:52:01 -0800529 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800530 main.log.report( "Ping between h" +
531 str( i ) +
532 " and h" +
533 str( i +
534 10 ) +
535 " failed. Making attempt number " +
536 str( count ) +
537 " in 2 seconds" )
538 time.sleep( 2 )
539 elif ping == main.FALSE:
540 main.log.report( "All ping attempts between h" +
541 str( i ) +
542 " and h" +
543 str( i +
544 10 ) +
545 "have failed" )
546 i = 19
shahshreyaf3076352015-01-23 13:52:01 -0800547 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800548 elif ping == main.TRUE:
549 main.log.info( "Ping test between h" +
550 str( i ) +
551 " and h" +
552 str( i +
553 10 ) +
554 "passed!" )
555 i += 1
shahshreyaf3076352015-01-23 13:52:01 -0800556 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800557 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800558 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -0800559 PingResult = main.ERROR
560 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800561 main.log.report(
562 "Host intents have not ben installed correctly. Cleaning up" )
563 # main.cleanup()
564 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -0800565 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800566 main.log.report( "Host intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -0800567
shahshreyaf3076352015-01-23 13:52:01 -0800568 case6Result = PingResult
569 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800570 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800571 actual=case6Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800572 onpass="Host intent addition and Pingall Test successful",
573 onfail="Host intent addition and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800574
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800575 def CASE7( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800576
shahshreyaf3076352015-01-23 13:52:01 -0800577 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800578
shahshreyaf3076352015-01-23 13:52:01 -0800579 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800580
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800581 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800582 "This testscase is killing a link to" +
583 " ensure that link discovery is consistent" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800584 main.log.report( "__________________________________" )
585 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800586 "Killing a link to Ensure that Link" +
587 " Discovery is Working Properly" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800588 main.step( "Start continuous pings" )
shahshreya4e13a062014-11-11 16:46:18 -0800589
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800590 main.Mininet2.pingLong(
591 src=main.params[ 'PING' ][ 'source1' ],
592 target=main.params[ 'PING' ][ 'target1' ],
593 pingTime=500 )
594 main.Mininet2.pingLong(
595 src=main.params[ 'PING' ][ 'source2' ],
596 target=main.params[ 'PING' ][ 'target2' ],
597 pingTime=500 )
598 main.Mininet2.pingLong(
599 src=main.params[ 'PING' ][ 'source3' ],
600 target=main.params[ 'PING' ][ 'target3' ],
601 pingTime=500 )
602 main.Mininet2.pingLong(
603 src=main.params[ 'PING' ][ 'source4' ],
604 target=main.params[ 'PING' ][ 'target4' ],
605 pingTime=500 )
606 main.Mininet2.pingLong(
607 src=main.params[ 'PING' ][ 'source5' ],
608 target=main.params[ 'PING' ][ 'target5' ],
609 pingTime=500 )
610 main.Mininet2.pingLong(
611 src=main.params[ 'PING' ][ 'source6' ],
612 target=main.params[ 'PING' ][ 'target6' ],
613 pingTime=500 )
614 main.Mininet2.pingLong(
615 src=main.params[ 'PING' ][ 'source7' ],
616 target=main.params[ 'PING' ][ 'target7' ],
617 pingTime=500 )
618 main.Mininet2.pingLong(
619 src=main.params[ 'PING' ][ 'source8' ],
620 target=main.params[ 'PING' ][ 'target8' ],
621 pingTime=500 )
622 main.Mininet2.pingLong(
623 src=main.params[ 'PING' ][ 'source9' ],
624 target=main.params[ 'PING' ][ 'target9' ],
625 pingTime=500 )
626 main.Mininet2.pingLong(
627 src=main.params[ 'PING' ][ 'source10' ],
628 target=main.params[ 'PING' ][ 'target10' ],
629 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -0800630
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800631 main.step( "Determine the current number of switches and links" )
shahshreyaf3076352015-01-23 13:52:01 -0800632 topologyOutput = main.ONOScli1.topology()
633 topologyResult = main.ONOSbench.getTopology( topologyOutput )
634 activeSwitches = topologyResult[ 'devices' ]
635 links = topologyResult[ 'links' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800636 print "activeSwitches = ", type( activeSwitches )
637 print "links = ", type( links )
638 main.log.info(
639 "Currently there are %s switches and %s links" %
640 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -0800641
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800642 main.step( "Kill Link between s3 and s28" )
643 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
shahshreyaf3076352015-01-23 13:52:01 -0800644 time.sleep( linkSleep )
645 topologyOutput = main.ONOScli2.topology()
646 LinkDown = main.ONOSbench.checkStatus(
647 topologyOutput, activeSwitches, str(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800648 int( links ) - 2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800649 if LinkDown == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800650 main.log.report( "Link Down discovered properly" )
shahshreyaf3076352015-01-23 13:52:01 -0800651 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800652 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800653 actual=LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800654 onpass="Link Down discovered properly",
655 onfail="Link down was not discovered in " +
shahshreyaf3076352015-01-23 13:52:01 -0800656 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800657 " seconds" )
shahshreya4e13a062014-11-11 16:46:18 -0800658
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800659 main.step( "Bring link between s3 and s28 back up" )
shahshreyaf3076352015-01-23 13:52:01 -0800660 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
661 time.sleep( linkSleep )
662 topologyOutput = main.ONOScli2.topology()
663 LinkUp = main.ONOSbench.checkStatus(
664 topologyOutput,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800665 activeSwitches,
666 str( links ) )
shahshreyaf3076352015-01-23 13:52:01 -0800667 if LinkUp == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800668 main.log.report( "Link up discovered properly" )
shahshreyaf3076352015-01-23 13:52:01 -0800669 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800670 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800671 actual=LinkUp,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800672 onpass="Link up discovered properly",
673 onfail="Link up was not discovered in " +
shahshreyaf3076352015-01-23 13:52:01 -0800674 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800675 " seconds" )
676
677 main.step( "Compare ONOS Topology to MN Topology" )
678 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800679 "Testing Mininet topology with the" +
680 " topology of multi instances ONOS" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800681 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800682 devices1 = main.ONOScli1.devices()
683 devices2 = main.ONOScli2.devices()
684 devices3 = main.ONOScli3.devices()
685 print "devices1 = ", devices1
686 print "devices2 = ", devices2
687 print "devices3 = ", devices3
688 hosts1 = main.ONOScli1.hosts()
689 hosts2 = main.ONOScli2.hosts()
690 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800691 # print "hosts1 = ", hosts1
692 # print "hosts2 = ", hosts2
693 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800694 ports1 = main.ONOScli1.ports()
695 ports2 = main.ONOScli2.ports()
696 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800697 # print "ports1 = ", ports1
698 # print "ports2 = ", ports2
699 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800700 links1 = main.ONOScli1.links()
701 links2 = main.ONOScli2.links()
702 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800703 # print "links1 = ", links1
704 # print "links2 = ", links2
705 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800706
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800707 print "**************"
708
709 main.step( "Start continuous pings" )
710 main.Mininet2.pingLong(
711 src=main.params[ 'PING' ][ 'source1' ],
712 target=main.params[ 'PING' ][ 'target1' ],
713 pingTime=500 )
714 main.Mininet2.pingLong(
715 src=main.params[ 'PING' ][ 'source2' ],
716 target=main.params[ 'PING' ][ 'target2' ],
717 pingTime=500 )
718 main.Mininet2.pingLong(
719 src=main.params[ 'PING' ][ 'source3' ],
720 target=main.params[ 'PING' ][ 'target3' ],
721 pingTime=500 )
722 main.Mininet2.pingLong(
723 src=main.params[ 'PING' ][ 'source4' ],
724 target=main.params[ 'PING' ][ 'target4' ],
725 pingTime=500 )
726 main.Mininet2.pingLong(
727 src=main.params[ 'PING' ][ 'source5' ],
728 target=main.params[ 'PING' ][ 'target5' ],
729 pingTime=500 )
730 main.Mininet2.pingLong(
731 src=main.params[ 'PING' ][ 'source6' ],
732 target=main.params[ 'PING' ][ 'target6' ],
733 pingTime=500 )
734 main.Mininet2.pingLong(
735 src=main.params[ 'PING' ][ 'source7' ],
736 target=main.params[ 'PING' ][ 'target7' ],
737 pingTime=500 )
738 main.Mininet2.pingLong(
739 src=main.params[ 'PING' ][ 'source8' ],
740 target=main.params[ 'PING' ][ 'target8' ],
741 pingTime=500 )
742 main.Mininet2.pingLong(
743 src=main.params[ 'PING' ][ 'source9' ],
744 target=main.params[ 'PING' ][ 'target9' ],
745 pingTime=500 )
746 main.Mininet2.pingLong(
747 src=main.params[ 'PING' ][ 'source10' ],
748 target=main.params[ 'PING' ][ 'target10' ],
749 pingTime=500 )
750
751 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800752 global ctrls
753 ctrls = []
754 count = 1
755 while True:
756 temp = ()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800757 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
758 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
759 temp = temp + ( "ONOS" + str( count ), )
760 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
761 temp = temp + \
762 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
763 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800764 count = count + 1
765 else:
766 break
767 global MNTopo
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800768 Topo = TestONTopology(
769 main.Mininet1,
770 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800771 MNTopo = Topo
772
shahshreyaf3076352015-01-23 13:52:01 -0800773 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800774 main.step( "Compare ONOS Topology to MN Topology" )
775
shahshreyaf3076352015-01-23 13:52:01 -0800776 switchesResults1 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800777 MNTopo,
778 json.loads( devices1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800779 print "switches_Result1 = ", switchesResults1
780 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
781 onpass="ONOS1 Switches view is correct",
782 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800783
shahshreyaf3076352015-01-23 13:52:01 -0800784 switchesResults2 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800785 MNTopo,
786 json.loads( devices2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800787 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
788 onpass="ONOS2 Switches view is correct",
789 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800790
shahshreyaf3076352015-01-23 13:52:01 -0800791 switchesResults3 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800792 MNTopo,
793 json.loads( devices3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800794 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
795 onpass="ONOS3 Switches view is correct",
796 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800797
798 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800799 portsResults1 = main.Mininet1.comparePorts( MNTopo,
800 json.loads( ports1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800801 utilities.assertEquals( expect=main.TRUE, actual=portsResults1,
shahshreya4e13a062014-11-11 16:46:18 -0800802 onpass="ONOS1 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800803 onfail="ONOS1 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800804
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800805 portsResults2 = main.Mininet1.comparePorts( MNTopo,
806 json.loads( ports2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800807 utilities.assertEquals( expect=main.TRUE, actual=portsResults2,
shahshreya4e13a062014-11-11 16:46:18 -0800808 onpass="ONOS2 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800809 onfail="ONOS2 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800810
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800811 portsResults3 = main.Mininet1.comparePorts( MNTopo,
812 json.loads( ports3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800813 utilities.assertEquals( expect=main.TRUE, actual=portsResults3,
shahshreya4e13a062014-11-11 16:46:18 -0800814 onpass="ONOS3 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800815 onfail="ONOS3 Ports view is incorrect" )
816 """
shahshreyaf3076352015-01-23 13:52:01 -0800817 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800818 MNTopo,
819 json.loads( links1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800820 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
821 onpass="ONOS1 Links view is correct",
822 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800823
shahshreyaf3076352015-01-23 13:52:01 -0800824 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800825 MNTopo,
826 json.loads( links2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800827 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
828 onpass="ONOS2 Links view is correct",
829 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800830
shahshreyaf3076352015-01-23 13:52:01 -0800831 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800832 MNTopo,
833 json.loads( links3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800834 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
835 onpass="ONOS2 Links view is correct",
836 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800837
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800838 # topoResult = switchesResults1 and switchesResults2
839 # and switchesResults3\
shahshreyaf3076352015-01-23 13:52:01 -0800840 # and portsResults1 and portsResults2 and portsResults3\
841 # and linksResults1 and linksResults2 and linksResults3
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800842
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800843 topoResult = switchesResults1 and switchesResults2\
844 and switchesResults3 and linksResults1 and\
845 linksResults2 and linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800846
shahshreyaf3076352015-01-23 13:52:01 -0800847 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800848 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800849 actual=topoResult and LinkUp and LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800850 onpass="Topology Check Test successful",
851 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800852
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800853 def CASE8( self ):
854 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800855 Intent removal
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800856 """
857 main.log.report(
shahshreyab512cd02015-01-27 17:01:47 -0800858 "This testcase removes any previously added intents" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800859 main.log.report( "__________________________________" )
860 main.log.info( "Removing any previously installed intents" )
861 main.case( "Removing intents" )
862 main.step( "Obtain the intent id's" )
shahshreyaf3076352015-01-23 13:52:01 -0800863 intentResult = main.ONOScli1.intents( jsonFormat=False )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800864
shahshreyaf3076352015-01-23 13:52:01 -0800865 intentLinewise = intentResult.split( "\n" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800866 intentList = []
shahshreyaf3076352015-01-23 13:52:01 -0800867 for line in intentLinewise:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800868 if line.startswith( "id=" ):
869 intentList.append( line )
shahshreyae6c7cf42014-11-26 16:39:01 -0800870
871 intentids = []
872 for line in intentList:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800873 intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
shahshreya4e13a062014-11-11 16:46:18 -0800874 for id in intentids:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800875 main.log.info( "id = " + id )
shahshreyae6c7cf42014-11-26 16:39:01 -0800876
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800877 main.step(
878 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -0800879 for id in intentids:
shahshreyaf3076352015-01-23 13:52:01 -0800880 main.ONOScli1.removeIntent( intentId=id )
shahshreyae6c7cf42014-11-26 16:39:01 -0800881
shahshreyaf3076352015-01-23 13:52:01 -0800882 intentResult = main.ONOScli1.intents( jsonFormat=False )
883 main.log.info( "intent_result = " + intentResult )
884 case8Result = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800885
shahshreyae6c7cf42014-11-26 16:39:01 -0800886 i = 8
shahshreyaf3076352015-01-23 13:52:01 -0800887 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800888 while i < 18:
889 main.log.info(
890 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
891 ping = main.Mininet1.pingHost(
892 src="h" + str( i ), target="h" + str( i + 10 ) )
893 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -0800894 i = 19
shahshreyaf3076352015-01-23 13:52:01 -0800895 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800896 elif ping == main.FALSE:
897 i += 1
shahshreyaf3076352015-01-23 13:52:01 -0800898 PingResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800899 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800900 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -0800901 PingResult = main.ERROR
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800902
903 # Note: If the ping result failed, that means the intents have been
904 # withdrawn correctly.
shahshreyaf3076352015-01-23 13:52:01 -0800905 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800906 main.log.report( "Host intents have not been withdrawn correctly" )
907 # main.cleanup()
908 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -0800909 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800910 main.log.report( "Host intents have been withdrawn correctly" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800911
shahshreyaf3076352015-01-23 13:52:01 -0800912 case8Result = case8Result and PingResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800913
shahshreyaf3076352015-01-23 13:52:01 -0800914 if case8Result == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800915 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800916 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800917 main.log.report( "Intent removal failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800918
shahshreyaf3076352015-01-23 13:52:01 -0800919 utilities.assertEquals( expect=main.FALSE, actual=case8Result,
920 onpass="Intent removal test failed",
921 onfail="Intent removal test successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800922
923 def CASE9( self ):
924 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800925 This test case adds point intents. Make sure you run test case 8
926 which is host intent removal before executing this test case.
927 Else the host intent's flows will persist on switches and the pings
928 would work even if there is some issue with the point intent's flows
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800929 """
930 main.log.report(
931 "This testcase adds point intents and then does pingall" )
932 main.log.report( "__________________________________" )
933 main.log.info( "Adding point intents" )
934 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800935 "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20," +
936 "h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800937 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800938 "Add point-to-point intents for mininet hosts" +
939 " h8 and h18 or ONOS hosts h8 and h12" )
shahshreyaf3076352015-01-23 13:52:01 -0800940 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800941 "of:0000000000003008/1",
942 "of:0000000000006018/1" )
shahshreyaf3076352015-01-23 13:52:01 -0800943 if ptpIntentResult == main.TRUE:
944 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800945 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800946 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800947
shahshreyaf3076352015-01-23 13:52:01 -0800948 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800949 "of:0000000000006018/1",
950 "of:0000000000003008/1" )
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 )
shahshreya4e13a062014-11-11 16:46:18 -0800955
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800956 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800957 "Add point-to-point intents for mininet hosts" +
958 " h9 and h19 or ONOS hosts h9 and h13" )
shahshreyaf3076352015-01-23 13:52:01 -0800959 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800960 "of:0000000000003009/1",
961 "of:0000000000006019/1" )
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 )
shahshreya4e13a062014-11-11 16:46:18 -0800966
shahshreyaf3076352015-01-23 13:52:01 -0800967 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800968 "of:0000000000006019/1",
969 "of:0000000000003009/1" )
shahshreyaf3076352015-01-23 13:52:01 -0800970 if ptpIntentResult == main.TRUE:
971 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800972 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800973 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800974
975 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800976 "Add point-to-point intents for mininet" +
977 " hosts h10 and h20 or ONOS hosts hA and h14" )
shahshreyaf3076352015-01-23 13:52:01 -0800978 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800979 "of:0000000000003010/1",
980 "of:0000000000006020/1" )
shahshreyaf3076352015-01-23 13:52:01 -0800981 if ptpIntentResult == main.TRUE:
982 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800983 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800984 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800985
shahshreyaf3076352015-01-23 13:52:01 -0800986 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800987 "of:0000000000006020/1",
988 "of:0000000000003010/1" )
shahshreyaf3076352015-01-23 13:52:01 -0800989 if ptpIntentResult == main.TRUE:
990 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800991 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800992 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800993
994 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800995 "Add point-to-point intents for mininet" +
996 " hosts h11 and h21 or ONOS hosts hB and h15" )
shahshreyaf3076352015-01-23 13:52:01 -0800997 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800998 "of:0000000000003011/1",
999 "of:0000000000006021/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001000 if ptpIntentResult == main.TRUE:
1001 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001002 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001003 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001004
shahshreyaf3076352015-01-23 13:52:01 -08001005 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001006 "of:0000000000006021/1",
1007 "of:0000000000003011/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001008 if ptpIntentResult == main.TRUE:
1009 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001010 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001011 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001012
1013 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001014 "Add point-to-point intents for mininet" +
1015 " hosts h12 and h22 or ONOS hosts hC and h16" )
shahshreyaf3076352015-01-23 13:52:01 -08001016 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001017 "of:0000000000003012/1",
1018 "of:0000000000006022/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001019 if ptpIntentResult == main.TRUE:
1020 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001021 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001022 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001023
shahshreyaf3076352015-01-23 13:52:01 -08001024 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001025 "of:0000000000006022/1",
1026 "of:0000000000003012/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001027 if ptpIntentResult == main.TRUE:
1028 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001029 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001030 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001031
1032 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001033 "Add point-to-point intents for mininet " +
1034 "hosts h13 and h23 or ONOS hosts hD and h17" )
shahshreyaf3076352015-01-23 13:52:01 -08001035 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001036 "of:0000000000003013/1",
1037 "of:0000000000006023/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001038 if ptpIntentResult == main.TRUE:
1039 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001040 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001041 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001042
shahshreyaf3076352015-01-23 13:52:01 -08001043 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001044 "of:0000000000006023/1",
1045 "of:0000000000003013/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001046 if ptpIntentResult == main.TRUE:
1047 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001048 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001049 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001050
1051 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001052 "Add point-to-point intents for mininet hosts" +
1053 " h14 and h24 or ONOS hosts hE and h18" )
shahshreyaf3076352015-01-23 13:52:01 -08001054 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001055 "of:0000000000003014/1",
1056 "of:0000000000006024/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001057 if ptpIntentResult == main.TRUE:
1058 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001059 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001060 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001061
shahshreyaf3076352015-01-23 13:52:01 -08001062 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001063 "of:0000000000006024/1",
1064 "of:0000000000003014/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001065 if ptpIntentResult == main.TRUE:
1066 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001067 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001068 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001069
1070 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001071 "Add point-to-point intents for mininet hosts" +
1072 " h15 and h25 or ONOS hosts hF and h19" )
shahshreyaf3076352015-01-23 13:52:01 -08001073 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001074 "of:0000000000003015/1",
1075 "of:0000000000006025/1" )
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:0000000000006025/1",
1083 "of:0000000000003015/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001084 if ptpIntentResult == main.TRUE:
1085 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001086 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001087 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001088
1089 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001090 "Add point-to-point intents for mininet hosts" +
1091 " h16 and h26 or ONOS hosts h10 and h1A" )
shahshreyaf3076352015-01-23 13:52:01 -08001092 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001093 "of:0000000000003016/1",
1094 "of:0000000000006026/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001095 if ptpIntentResult == main.TRUE:
1096 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001097 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001098 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001099
shahshreyaf3076352015-01-23 13:52:01 -08001100 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001101 "of:0000000000006026/1",
1102 "of:0000000000003016/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001103 if ptpIntentResult == main.TRUE:
1104 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001105 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001106 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001107
1108 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001109 "Add point-to-point intents for mininet hosts h17" +
1110 " and h27 or ONOS hosts h11 and h1B" )
shahshreyaf3076352015-01-23 13:52:01 -08001111 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001112 "of:0000000000003017/1",
1113 "of:0000000000006027/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001114 if ptpIntentResult == main.TRUE:
1115 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001116 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001117 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001118
shahshreyaf3076352015-01-23 13:52:01 -08001119 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001120 "of:0000000000006027/1",
1121 "of:0000000000003017/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001122 if ptpIntentResult == main.TRUE:
1123 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001124 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001125 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001126
1127 print(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001128 "_______________________________________________________" +
1129 "________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001130
1131 flowHandle = main.ONOScli1.flows()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001132 # print "flowHandle = ", flowHandle
1133 main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001134
1135 count = 1
1136 i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001137 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001138 while i < 18:
1139 main.log.info(
1140 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1141 ping = main.Mininet1.pingHost(
1142 src="h" + str( i ), target="h" + str( i + 10 ) )
1143 if ping == main.FALSE and count < 5:
1144 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001145 # i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001146 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001147 main.log.report( "Ping between h" +
1148 str( i ) +
1149 " and h" +
1150 str( i +
1151 10 ) +
1152 " failed. Making attempt number " +
1153 str( count ) +
1154 " in 2 seconds" )
1155 time.sleep( 2 )
1156 elif ping == main.FALSE:
1157 main.log.report( "All ping attempts between h" +
1158 str( i ) +
1159 " and h" +
1160 str( i +
1161 10 ) +
1162 "have failed" )
1163 i = 19
shahshreyaf3076352015-01-23 13:52:01 -08001164 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001165 elif ping == main.TRUE:
1166 main.log.info( "Ping test between h" +
1167 str( i ) +
1168 " and h" +
1169 str( i +
1170 10 ) +
1171 "passed!" )
1172 i += 1
shahshreyaf3076352015-01-23 13:52:01 -08001173 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001174 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001175 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -08001176 PingResult = main.ERROR
1177 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001178 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001179 "Ping all test after Point intents" +
1180 " addition failed. Cleaning up" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001181 # main.cleanup()
1182 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -08001183 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001184 main.log.report(
1185 "Ping all test after Point intents addition successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001186
shahshreyaf3076352015-01-23 13:52:01 -08001187 case8Result = PingResult
1188 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001189 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001190 actual=case8Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001191 onpass="Ping all test after Point intents addition successful",
1192 onfail="Ping all test after Point intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001193
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001194 def CASE31( self ):
1195 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001196 This test case adds point intent related to
1197 SDN-IP matching on ICMP ( ethertype=IPV4, ipProto=1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001198 """
shahshreyae6c7cf42014-11-26 16:39:01 -08001199 import json
1200
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001201 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001202 "This test case adds point intent " +
1203 "related to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001204 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001205 "Adding bidirectional point intent related" +
1206 " to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001207 main.step( "Adding bidirectional point intent" )
1208 # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1209 # --ethType=IPV4 --ipProto=1 of:0000000000003008/1
1210 # of:0000000000006018/1
1211
shahshreyaf3076352015-01-23 13:52:01 -08001212 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001213 for i in range( 8, 11 ):
1214 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001215 "Adding point intent between h" + str( i ) +
1216 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001217 host1 = "00:00:00:00:00:" + \
1218 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1219 host2 = "00:00:00:00:00:" + \
1220 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
shahshreyaf3076352015-01-23 13:52:01 -08001221 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1222 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1223 for host in hostsJson:
1224 if host[ 'id' ] == host1Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001225 ip1 = host[ 'ips' ][ 0 ]
1226 ip1 = str( ip1 + "/32" )
1227 device1 = host[ 'location' ][ 'device' ]
1228 device1 = str( device1 + "/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001229 elif host[ 'id' ] == host2Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001230 ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
1231 device2 = host[ 'location' ][ "device" ]
1232 device2 = str( device2 + "/1" )
1233
shahshreyaf3076352015-01-23 13:52:01 -08001234 pIntentResult1 = main.ONOScli1.addPointIntent(
1235 ingressDevice=device1,
1236 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001237 ipSrc=ip1,
1238 ipDst=ip2,
1239 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1240 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1241
shahshreyaf3076352015-01-23 13:52:01 -08001242 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1243 main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001244
shahshreyaf3076352015-01-23 13:52:01 -08001245 pIntentResult2 = main.ONOScli1.addPointIntent(
1246 ingressDevice=device2,
1247 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001248 ipSrc=ip2,
1249 ipDst=ip1,
1250 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1251 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1252
shahshreyaf3076352015-01-23 13:52:01 -08001253 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1254 main.log.info( getIntentResult )
1255 if ( pIntentResult1 and pIntentResult2 ) == main.TRUE:
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001256 # getIntentResult = main.ONOScli1.intents()
shahshreyaf3076352015-01-23 13:52:01 -08001257 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001258 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001259 "Point intent related to SDN-IP matching" +
1260 " on ICMP install successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001261
1262 time.sleep( 15 )
shahshreyaf3076352015-01-23 13:52:01 -08001263 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1264 main.log.info( "intents = " + getIntentResult )
1265 getFlowsResult = main.ONOScli1.flows()
1266 main.log.info( "flows = " + getFlowsResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001267
shahshreyae6c7cf42014-11-26 16:39:01 -08001268 count = 1
1269 i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001270 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001271 while i < 11:
1272 main.log.info(
1273 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1274 ping = main.Mininet1.pingHost(
1275 src="h" + str( i ), target="h" + str( i + 10 ) )
1276 if ping == main.FALSE and count < 3:
1277 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001278 # i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001279 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001280 main.log.report( "Ping between h" +
1281 str( i ) +
1282 " and h" +
1283 str( i +
1284 10 ) +
1285 " failed. Making attempt number " +
1286 str( count ) +
1287 " in 2 seconds" )
1288 time.sleep( 2 )
1289 elif ping == main.FALSE:
1290 main.log.report( "All ping attempts between h" +
1291 str( i ) +
1292 " and h" +
1293 str( i +
1294 10 ) +
1295 "have failed" )
1296 i = 19
shahshreyaf3076352015-01-23 13:52:01 -08001297 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001298 elif ping == main.TRUE:
1299 main.log.info( "Ping test between h" +
1300 str( i ) +
1301 " and h" +
1302 str( i +
1303 10 ) +
1304 "passed!" )
1305 i += 1
shahshreyaf3076352015-01-23 13:52:01 -08001306 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -08001307 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001308 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -08001309 PingResult = main.ERROR
1310 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001311 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001312 "Ping test after Point intents related to" +
1313 " SDN-IP matching on ICMP failed." )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001314 # main.cleanup()
1315 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -08001316 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001317 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001318 "Ping all test after Point intents related to" +
1319 " SDN-IP matching on ICMP successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001320
shahshreyaf3076352015-01-23 13:52:01 -08001321 case31Result = PingResult and pIntentResult1 and pIntentResult2
1322 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001323 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001324 actual=case31Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001325 onpass="Point intent related to SDN-IP " +
1326 "matching on ICMP and ping test successful",
1327 onfail="Point intent related to SDN-IP" +
1328 " matching on ICMP and ping test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001329
1330 def CASE32( self ):
1331 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001332 This test case adds point intent related to SDN-IP matching on TCP
1333 ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 )
1334 Note: Although BGP port is 179, we are using 5001 because iperf
1335 is used for verifying and iperf's default port is 5001
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001336 """
shahshreyae6c7cf42014-11-26 16:39:01 -08001337 import json
1338
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001339 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001340 "This test case adds point intent" +
1341 " related to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001342 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001343 "Adding bidirectional point intent related" +
1344 " to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001345 main.step( "Adding bidirectional point intent" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001346 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001347 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1348 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1
1349 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001350
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001351 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1352 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1
1353 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001354
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001355 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1356 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1
1357 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001358
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001359 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1360 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1
1361 of:0000000000003008/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001362
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001363 """
shahshreyaf3076352015-01-23 13:52:01 -08001364 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001365 for i in range( 8, 9 ):
1366 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001367 "Adding point intent between h" + str( i ) +
1368 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001369 host1 = "00:00:00:00:00:" + \
1370 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1371 host2 = "00:00:00:00:00:" + \
1372 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
shahshreyaf3076352015-01-23 13:52:01 -08001373 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1374 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1375 for host in hostsJson:
1376 if host[ 'id' ] == host1Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001377 ip1 = host[ 'ips' ][ 0 ]
1378 ip1 = str( ip1 + "/32" )
1379 device1 = host[ 'location' ][ 'device' ]
1380 device1 = str( device1 + "/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001381 elif host[ 'id' ] == host2Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001382 ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
1383 device2 = host[ 'location' ][ "device" ]
1384 device2 = str( device2 + "/1" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001385
shahshreyaf3076352015-01-23 13:52:01 -08001386 pIntentResult1 = main.ONOScli1.addPointIntent(
1387 ingressDevice=device1,
1388 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001389 ipSrc=ip1,
1390 ipDst=ip2,
1391 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1392 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1393 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
shahshreyaf3076352015-01-23 13:52:01 -08001394 pIntentResult2 = main.ONOScli1.addPointIntent(
1395 ingressDevice=device2,
1396 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001397 ipSrc=ip2,
1398 ipDst=ip1,
1399 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1400 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1401 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
1402
shahshreyaf3076352015-01-23 13:52:01 -08001403 pIntentResult3 = main.ONOScli1.addPointIntent(
1404 ingressDevice=device1,
1405 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001406 ipSrc=ip1,
1407 ipDst=ip2,
1408 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1409 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1410 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
shahshreyaf3076352015-01-23 13:52:01 -08001411 pIntentResult4 = main.ONOScli1.addPointIntent(
1412 ingressDevice=device2,
1413 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001414 ipSrc=ip2,
1415 ipDst=ip1,
1416 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1417 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1418 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
shahshreyae6c7cf42014-11-26 16:39:01 -08001419
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001420 pIntentResult = pIntentResult1 and pIntentResult2 and\
1421 pIntentResult3 and pIntentResult4
shahshreyaf3076352015-01-23 13:52:01 -08001422 if pIntentResult == main.TRUE:
1423 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1424 main.log.info( getIntentResult )
shahshreyab512cd02015-01-27 17:01:47 -08001425 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001426 "Point intent related to SDN-IP matching" +
1427 " on TCP install successful" )
shahshreyab512cd02015-01-27 17:01:47 -08001428 else:
1429 main.log.report(
1430 "Point intent related to SDN-IP matching" +
1431 " on TCP install failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001432
shahshreyaf3076352015-01-23 13:52:01 -08001433 iperfResult = main.Mininet1.iperf( 'h8', 'h18' )
1434 if iperfResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001435 main.log.report( "iperf test successful" )
1436 else:
1437 main.log.report( "iperf test failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001438
shahshreyaf3076352015-01-23 13:52:01 -08001439 case32Result = pIntentResult and iperfResult
1440 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001441 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001442 actual=case32Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001443 onpass="Ping all test after Point intents addition related " +
1444 "to SDN-IP on TCP match successful",
1445 onfail="Ping all test after Point intents addition related " +
1446 "to SDN-IP on TCP match failed" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001447
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001448 def CASE33( self ):
1449 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001450 This test case adds multipoint to singlepoint intent related to
1451 SDN-IP matching on destination ip and the action is to rewrite
1452 the mac address
1453 Here the mac address to be rewritten is the mac address of the
1454 egress device
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001455 """
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001456 import json
1457 import time
1458
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001459 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001460 "This test case adds multipoint to singlepoint intent related to" +
1461 " SDN-IP matching on destination ip and " +
1462 "rewrite mac address action" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001463 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001464 "Adding multipoint to singlepoint intent related to SDN-IP" +
1465 " matching on destination ip" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001466 main.step( "Adding bidirectional multipoint to singlepoint intent" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001467 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001468 add-multi-to-single-intent --ipDst=10.0.3.0/24
1469 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1
1470 of:0000000000006018/1
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001471
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001472 add-multi-to-single-intent --ipDst=10.0.1.0/24
1473 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1
1474 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001475 """
1476 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001477 "Installing multipoint to single point " +
1478 "intent with rewrite mac address" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001479 main.step( "Uninstalling proxy arp app" )
1480 # Unistall onos-app-proxyarp app to disable reactive forwarding
shahshreyaf3076352015-01-23 13:52:01 -08001481 appUninstallResult1 = main.ONOScli1.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001482 "onos-app-proxyarp" )
shahshreyaf3076352015-01-23 13:52:01 -08001483 appUninstallResult2 = main.ONOScli2.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001484 "onos-app-proxyarp" )
shahshreyaf3076352015-01-23 13:52:01 -08001485 appUninstallResult3 = main.ONOScli3.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001486 "onos-app-proxyarp" )
1487 main.log.info( "onos-app-proxyarp uninstalled" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001488
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001489 main.step( "Changing ipaddress of hosts h8,h9 and h18" )
1490 main.Mininet1.changeIP(
1491 host='h8',
1492 intf='h8-eth0',
1493 newIP='10.0.1.1',
1494 newNetmask='255.255.255.0' )
1495 main.Mininet1.changeIP(
1496 host='h9',
1497 intf='h9-eth0',
1498 newIP='10.0.2.1',
1499 newNetmask='255.255.255.0' )
1500 main.Mininet1.changeIP(
1501 host='h10',
1502 intf='h10-eth0',
1503 newIP='10.0.3.1',
1504 newNetmask='255.255.255.0' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001505
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001506 main.step( "Changing default gateway of hosts h8,h9 and h18" )
1507 main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' )
1508 main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' )
1509 main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001510
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001511 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001512 "Assigning random mac address to the default gateways " +
1513 "since proxyarp app is uninstalled" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001514 main.Mininet1.addStaticMACAddress(
1515 host='h8',
1516 GW='10.0.1.254',
1517 macaddr='00:00:00:00:11:11' )
1518 main.Mininet1.addStaticMACAddress(
1519 host='h9',
1520 GW='10.0.2.254',
1521 macaddr='00:00:00:00:22:22' )
1522 main.Mininet1.addStaticMACAddress(
1523 host='h10',
1524 GW='10.0.3.254',
1525 macaddr='00:00:00:00:33:33' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001526
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001527 main.step( "Verify static gateway and MAC address assignment" )
1528 main.Mininet1.verifyStaticGWandMAC( host='h8' )
1529 main.Mininet1.verifyStaticGWandMAC( host='h9' )
1530 main.Mininet1.verifyStaticGWandMAC( host='h10' )
1531
1532 main.step( "Adding multipoint to singlepoint intent" )
shahshreyaf3076352015-01-23 13:52:01 -08001533 pIntentResult1 = main.ONOScli1.addMultipointToSinglepointIntent(
1534 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
1535 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
1536 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001537 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
1538 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
1539
shahshreyaf3076352015-01-23 13:52:01 -08001540 pIntentResult2 = main.ONOScli1.addMultipointToSinglepointIntent(
1541 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
1542 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
1543 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001544 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
1545 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
1546
shahshreyaf3076352015-01-23 13:52:01 -08001547 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1548 main.log.info( "intents = " + getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001549
1550 time.sleep( 10 )
shahshreyaf3076352015-01-23 13:52:01 -08001551 getFlowsResult = main.ONOScli1.flows( jsonFormat=False )
1552 main.log.info( "flows = " + getFlowsResult )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001553
1554 count = 1
1555 i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001556 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001557
1558 main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
1559 ping = main.Mininet1.pingHost(
1560 src="h" + str( i ), target="h" + str( i + 2 ) )
1561 if ping == main.FALSE and count < 3:
1562 count += 1
shahshreyaf3076352015-01-23 13:52:01 -08001563 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001564 main.log.report( "Ping between h" +
1565 str( i ) +
1566 " and h" +
1567 str( i +
1568 2 ) +
1569 " failed. Making attempt number " +
1570 str( count ) +
1571 " in 2 seconds" )
1572 time.sleep( 2 )
1573 elif ping == main.FALSE:
1574 main.log.report( "All ping attempts between h" +
1575 str( i ) +
1576 " and h" +
1577 str( i +
1578 10 ) +
1579 "have failed" )
shahshreyaf3076352015-01-23 13:52:01 -08001580 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001581 elif ping == main.TRUE:
1582 main.log.info( "Ping test between h" +
1583 str( i ) +
1584 " and h" +
1585 str( i +
1586 2 ) +
1587 "passed!" )
shahshreyaf3076352015-01-23 13:52:01 -08001588 PingResult = main.TRUE
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001589 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001590 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -08001591 PingResult = main.ERROR
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001592
shahshreyaf3076352015-01-23 13:52:01 -08001593 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001594 main.log.report( "Ping test failed." )
1595 # main.cleanup()
1596 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -08001597 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001598 main.log.report( "Ping all successful" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001599
shahshreyaf3076352015-01-23 13:52:01 -08001600 pIntentResult = pIntentResult1 and pIntentResult2
1601 if pIntentResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001602 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001603 "Multi point intent with rewrite mac " +
1604 "address installation successful" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001605 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001606 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001607 "Multi point intent with rewrite mac" +
1608 " address installation failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001609
shahshreyaf3076352015-01-23 13:52:01 -08001610 case33Result = pIntentResult and PingResult
1611 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001612 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001613 actual=case33Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001614 onpass="Ping all test after multipoint to single point" +
1615 " intent addition with rewrite mac address successful",
1616 onfail="Ping all test after multipoint to single point intent" +
1617 " addition with rewrite mac address failed" )