blob: 52519d837e1a88853b63bb2d75b27966cbb1549f [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()
shahshreya42efbd82015-02-05 17:06:08 -080058 main.log.info( "git_pull_result = " + str( gitPullResult ))
shahshreyaf3076352015-01-23 13:52:01 -080059 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
shahshreya42efbd82015-02-05 17:06:08 -0800109 # Starting the mininet using the old way
110 main.step( "Starting Mininet ..." )
111 netIsUp = main.Mininet1.startNet()
112 if netIsUp:
113 main.log.info("Mininet CLI is up")
114
shahshreyaf3076352015-01-23 13:52:01 -0800115 case1Result = ( packageResult and
116 cellResult and verifyResult and onosInstallResult and
117 onosIsup and startResult )
118 utilities.assertEquals( expect=main.TRUE, actual=case1Result,
119 onpass="Test startup successful",
120 onfail="Test startup NOT successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800121
122 def CASE11( self, main ):
123 """
shahshreya4e13a062014-11-11 16:46:18 -0800124 Cleanup sequence:
shahshreyaf3076352015-01-23 13:52:01 -0800125 onos-service <nodeIp> stop
shahshreya4e13a062014-11-11 16:46:18 -0800126 onos-uninstall
127
128 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800129
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800130 """
shahshreyaf3076352015-01-23 13:52:01 -0800131 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
132 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
133 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
shahshreya4e13a062014-11-11 16:46:18 -0800134
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800135 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800136
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800137 main.step( "Testing ONOS kill function" )
shahshreyaf3076352015-01-23 13:52:01 -0800138 killResult1 = main.ONOSbench.onosKill( ONOS1Ip )
139 killResult2 = main.ONOSbench.onosKill( ONOS2Ip )
140 killResult3 = main.ONOSbench.onosKill( ONOS3Ip )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800141
142 main.step( "Stopping ONOS service" )
shahshreyaf3076352015-01-23 13:52:01 -0800143 stopResult1 = main.ONOSbench.onosStop( ONOS1Ip )
144 stopResult2 = main.ONOSbench.onosStop( ONOS2Ip )
145 stopResult3 = main.ONOSbench.onosStop( ONOS3Ip )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800146
147 main.step( "Uninstalling ONOS service" )
shahshreyaf3076352015-01-23 13:52:01 -0800148 uninstallResult = main.ONOSbench.onosUninstall()
shahshreya4e13a062014-11-11 16:46:18 -0800149
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800150 def CASE3( self, main ):
151 """
shahshreya4e13a062014-11-11 16:46:18 -0800152 Test 'onos' command and its functionality in driver
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800153 """
shahshreyaf3076352015-01-23 13:52:01 -0800154 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
155 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
156 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
shahshreya4e13a062014-11-11 16:46:18 -0800157
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800158 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800159
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800160 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800161 cmdstr1 = "system:name"
shahshreyaf3076352015-01-23 13:52:01 -0800162 cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
163 main.log.info( "onos command returned: " + cmdResult1 )
164 cmdResult2 = main.ONOSbench.onosCli( ONOS2Ip, cmdstr1 )
165 main.log.info( "onos command returned: " + cmdResult2 )
166 cmdResult3 = main.ONOSbench.onosCli( ONOS3Ip, cmdstr1 )
167 main.log.info( "onos command returned: " + cmdResult3 )
shahshreya4e13a062014-11-11 16:46:18 -0800168
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800169 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800170 cmdstr2 = "onos:topology"
shahshreyaf3076352015-01-23 13:52:01 -0800171 cmdResult4 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
172 main.log.info( "onos command returned: " + cmdResult4 )
173 cmdResult5 = main.ONOSbench.onosCli( ONOS2Ip, cmdstr2 )
174 main.log.info( "onos command returned: " + cmdResult5 )
175 cmdResult6 = main.ONOSbench.onosCli( ONOS6Ip, cmdstr2 )
176 main.log.info( "onos command returned: " + cmdResult6 )
shahshreya4e13a062014-11-11 16:46:18 -0800177
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800178 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800179 import re
180 import time
shahshreyaf3076352015-01-23 13:52:01 -0800181 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
182 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
183 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
184 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
185 ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
186 ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800187
188 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800189 "This testcase is testing the assignment of all the switches" +
190 " to all controllers and discovering the hosts in reactive mode" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800191 main.log.report( "__________________________________" )
192 main.case( "Pingall Test(No intents are added)" )
193 main.step( "Assigning switches to controllers" )
194 for i in range( 1, 29 ): # 1 to ( num of switches +1 )
shahshreyaf3076352015-01-23 13:52:01 -0800195 main.Mininet1.assignSwController(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800196 sw=str( i ),
197 count=3,
shahshreyaf3076352015-01-23 13:52:01 -0800198 ip1=ONOS1Ip,
199 port1=ONOS1Port,
200 ip2=ONOS2Ip,
201 port2=ONOS2Port,
202 ip3=ONOS3Ip,
203 port3=ONOS3Port )
shahshreya4e13a062014-11-11 16:46:18 -0800204
shahshreyaf3076352015-01-23 13:52:01 -0800205 switchMastership = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800206 for i in range( 1, 29 ):
shahshreyaf3076352015-01-23 13:52:01 -0800207 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800208 print( "Response is " + str( response ) )
shahshreyaf3076352015-01-23 13:52:01 -0800209 if re.search( "tcp:" + ONOS1Ip, response ):
210 switchMastership = switchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800211 else:
shahshreyaf3076352015-01-23 13:52:01 -0800212 switchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800213
shahshreyaf3076352015-01-23 13:52:01 -0800214 if switchMastership == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800215 main.log.report( "Controller assignment successfull" )
shahshreya4e13a062014-11-11 16:46:18 -0800216 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800217 main.log.report( "Controller assignment failed" )
218 # REACTIVE FWD test
219 main.step( "Pingall" )
shahshreyaf3076352015-01-23 13:52:01 -0800220 pingResult = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800221 time1 = time.time()
shahshreyaf3076352015-01-23 13:52:01 -0800222 pingResult = main.Mininet1.pingall()
shahshreya4e13a062014-11-11 16:46:18 -0800223 time2 = time.time()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800224 print "Time for pingall: %2f seconds" % ( time2 - time1 )
225
shahshreyaf3076352015-01-23 13:52:01 -0800226 case4Result = switchMastership and pingResult
227 if pingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800228 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800229 "Pingall Test in reactive mode to" +
230 " discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800231 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800232 main.log.report(
233 "Pingall Test in reactive mode to discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800234
shahshreyaf3076352015-01-23 13:52:01 -0800235 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800236 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800237 actual=case4Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800238 onpass="Controller assignment and Pingall Test successful",
239 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800240
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800241 def CASE5( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800242 import json
243 from subprocess import Popen, PIPE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800244 # assumes that sts is already in you PYTHONPATH
245 from sts.topology.teston_topology import TestONTopology
shahshreyaf3076352015-01-23 13:52:01 -0800246 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
247 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
248 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800249
250 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800251 "This testcase is testing if all ONOS nodes are in topologyi" +
252 " sync with mininet and its peer ONOS nodes" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800253 main.log.report( "__________________________________" )
254 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800255 "Testing Mininet topology with the" +
256 " topology of multi instances ONOS" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800257 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800258 devices1 = main.ONOScli1.devices()
259 devices2 = main.ONOScli2.devices()
260 devices3 = main.ONOScli3.devices()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800261 # print "devices1 = ", devices1
262 # print "devices2 = ", devices2
263 # print "devices3 = ", devices3
shahshreya4e13a062014-11-11 16:46:18 -0800264 hosts1 = main.ONOScli1.hosts()
265 hosts2 = main.ONOScli2.hosts()
266 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800267 # print "hosts1 = ", hosts1
268 # print "hosts2 = ", hosts2
269 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800270 ports1 = main.ONOScli1.ports()
271 ports2 = main.ONOScli2.ports()
272 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800273 # print "ports1 = ", ports1
274 # print "ports2 = ", ports2
275 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800276 links1 = main.ONOScli1.links()
277 links2 = main.ONOScli2.links()
278 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800279 # print "links1 = ", links1
280 # print "links2 = ", links2
281 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800282
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800283 print "**************"
284
285 main.step( "Start continuous pings" )
286 main.Mininet2.pingLong(
287 src=main.params[ 'PING' ][ 'source1' ],
288 target=main.params[ 'PING' ][ 'target1' ],
289 pingTime=500 )
290 main.Mininet2.pingLong(
291 src=main.params[ 'PING' ][ 'source2' ],
292 target=main.params[ 'PING' ][ 'target2' ],
293 pingTime=500 )
294 main.Mininet2.pingLong(
295 src=main.params[ 'PING' ][ 'source3' ],
296 target=main.params[ 'PING' ][ 'target3' ],
297 pingTime=500 )
298 main.Mininet2.pingLong(
299 src=main.params[ 'PING' ][ 'source4' ],
300 target=main.params[ 'PING' ][ 'target4' ],
301 pingTime=500 )
302 main.Mininet2.pingLong(
303 src=main.params[ 'PING' ][ 'source5' ],
304 target=main.params[ 'PING' ][ 'target5' ],
305 pingTime=500 )
306 main.Mininet2.pingLong(
307 src=main.params[ 'PING' ][ 'source6' ],
308 target=main.params[ 'PING' ][ 'target6' ],
309 pingTime=500 )
310 main.Mininet2.pingLong(
311 src=main.params[ 'PING' ][ 'source7' ],
312 target=main.params[ 'PING' ][ 'target7' ],
313 pingTime=500 )
314 main.Mininet2.pingLong(
315 src=main.params[ 'PING' ][ 'source8' ],
316 target=main.params[ 'PING' ][ 'target8' ],
317 pingTime=500 )
318 main.Mininet2.pingLong(
319 src=main.params[ 'PING' ][ 'source9' ],
320 target=main.params[ 'PING' ][ 'target9' ],
321 pingTime=500 )
322 main.Mininet2.pingLong(
323 src=main.params[ 'PING' ][ 'source10' ],
324 target=main.params[ 'PING' ][ 'target10' ],
325 pingTime=500 )
326
327 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800328 global ctrls
329 ctrls = []
330 count = 1
331 while True:
332 temp = ()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800333 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
334 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
335 temp = temp + ( "ONOS" + str( count ), )
336 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
337 temp = temp + \
338 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
339 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800340 count = count + 1
341 else:
342 break
343 global MNTopo
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800344 Topo = TestONTopology(
345 main.Mininet1,
346 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800347 MNTopo = Topo
348
shahshreyaf3076352015-01-23 13:52:01 -0800349 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800350 main.step( "Compare ONOS Topology to MN Topology" )
351
shahshreyaf3076352015-01-23 13:52:01 -0800352 switchesResults1 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800353 MNTopo,
354 json.loads( devices1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800355 print "switches_Result1 = ", switchesResults1
356 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
357 onpass="ONOS1 Switches view is correct",
358 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800359
shahshreyaf3076352015-01-23 13:52:01 -0800360 switchesResults2 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800361 MNTopo,
362 json.loads( devices2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800363 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
364 onpass="ONOS2 Switches view is correct",
365 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800366
shahshreyaf3076352015-01-23 13:52:01 -0800367 switchesResults3 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800368 MNTopo,
369 json.loads( devices3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800370 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
371 onpass="ONOS3 Switches view is correct",
372 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800373
374 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800375 portsResults1 = main.Mininet1.comparePorts( MNTopo,
376 json.loads( ports1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800377 utilities.assertEquals( expect=main.TRUE, actual=portsResults1,
shahshreya4e13a062014-11-11 16:46:18 -0800378 onpass="ONOS1 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800379 onfail="ONOS1 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800380
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800381 portsResults2 = main.Mininet1.comparePorts( MNTopo,
382 json.loads( ports2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800383 utilities.assertEquals( expect=main.TRUE, actual=portsResults2,
shahshreya4e13a062014-11-11 16:46:18 -0800384 onpass="ONOS2 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800385 onfail="ONOS2 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800386
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800387 portsResults3 = main.Mininet1.comparePorts( MNTopo,
388 json.loads( ports3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800389 utilities.assertEquals( expect=main.TRUE, actual=portsResults3,
shahshreya4e13a062014-11-11 16:46:18 -0800390 onpass="ONOS3 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800391 onfail="ONOS3 Ports view is incorrect" )
392 """
shahshreyaf3076352015-01-23 13:52:01 -0800393 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800394 MNTopo,
395 json.loads( links1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800396 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
397 onpass="ONOS1 Links view is correct",
398 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800399
shahshreyaf3076352015-01-23 13:52:01 -0800400 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800401 MNTopo,
402 json.loads( links2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800403 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
404 onpass="ONOS2 Links view is correct",
405 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800406
shahshreyaf3076352015-01-23 13:52:01 -0800407 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800408 MNTopo,
409 json.loads( links3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800410 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
411 onpass="ONOS2 Links view is correct",
412 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800413
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800414 # topoResult = switchesResults1 and switchesResults2
415 # and switchesResults3\
shahshreyaf3076352015-01-23 13:52:01 -0800416 # and portsResults1 and portsResults2 and portsResults3\
417 # and linksResults1 and linksResults2 and linksResults3
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800418
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800419 topoResult = switchesResults1 and switchesResults2 and\
420 switchesResults3 and linksResults1 and linksResults2 and\
421 linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800422
shahshreyaf3076352015-01-23 13:52:01 -0800423 if topoResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800424 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800425 "Topology Check Test with mininet" +
426 "and ONOS instances successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800427 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800428 main.log.report(
429 "Topology Check Test with mininet and ONOS instances failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800430
shahshreyaf3076352015-01-23 13:52:01 -0800431 utilities.assertEquals( expect=main.TRUE, actual=topoResult,
432 onpass="Topology Check Test successful",
433 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800434
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800435 def CASE10( self ):
436 main.log.report(
437 "This testcase uninstalls the reactive forwarding app" )
438 main.log.report( "__________________________________" )
439 main.case( "Uninstalling reactive forwarding app" )
440 # Unistall onos-app-fwd app to disable reactive forwarding
shahshreyaf3076352015-01-23 13:52:01 -0800441 appUninstallResult1 = main.ONOScli1.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800442 "onos-app-fwd" )
shahshreyaf3076352015-01-23 13:52:01 -0800443 appUninstallResult2 = main.ONOScli2.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800444 "onos-app-fwd" )
shahshreyaf3076352015-01-23 13:52:01 -0800445 appUninstallResult3 = main.ONOScli3.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800446 "onos-app-fwd" )
447 main.log.info( "onos-app-fwd uninstalled" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800448
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800449 # After reactive forwarding is disabled,
450 # the reactive flows on switches timeout in 10-15s
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800451 # So sleep for 15s
452 time.sleep( 15 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800453
shahshreyae6c7cf42014-11-26 16:39:01 -0800454 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800455 main.log.info( hosts )
456
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800457 case10Result = appUninstallResult1 and\
458 appUninstallResult2 and appUninstallResult3
shahshreyaf3076352015-01-23 13:52:01 -0800459 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800460 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800461 actual=case10Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800462 onpass="Reactive forwarding app uninstallation successful",
463 onfail="Reactive forwarding app uninstallation failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800464
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800465 def CASE6( self ):
466 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800467 "This testcase is testing the addition of" +
468 " host intents and then doing pingall" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800469 main.log.report( "__________________________________" )
470 main.case( "Obtaining hostsfor adding host intents" )
471 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800472 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800473 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800474
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800475 main.step( "Get all devices id" )
shahshreyaf3076352015-01-23 13:52:01 -0800476 devicesIdList = main.ONOScli1.getAllDevicesId()
477 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -0800478
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800479 # ONOS displays the hosts in hex format
480 # unlike mininet which does in decimal format
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800481 # So take care while adding intents
shahshreya4e13a062014-11-11 16:46:18 -0800482
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800483 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800484 main.step( "Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,
485 h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
486 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:08/-1",
487 "00:00:00:00:00:12/-1" )
488 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:09/-1",
489 "00:00:00:00:00:13/-1" )
490 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0A/-1",
491 "00:00:00:00:00:14/-1" )
492 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0B/-1",
493 "00:00:00:00:00:15/-1" )
494 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0C/-1",
495 "00:00:00:00:00:16/-1" )
496 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0D/-1",
497 "00:00:00:00:00:17/-1" )
498 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0E/-1",
499 "00:00:00:00:00:18/-1" )
500 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0F/-1",
501 "00:00:00:00:00:19/-1" )
502 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:10/-1",
503 "00:00:00:00:00:1A/-1" )
504 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:11/-1",
505 "00:00:00:00:00:1B/-1" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800506 """
507 for i in range( 8, 18 ):
508 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800509 "Adding host intent between h" + str( i ) +
510 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800511 host1 = "00:00:00:00:00:" + \
512 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
513 host2 = "00:00:00:00:00:" + \
514 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
515 # NOTE: get host can return None
516 # TODO: handle this
shahshreyaf3076352015-01-23 13:52:01 -0800517 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
518 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
519 tmpResult = main.ONOScli1.addHostIntent( host1Id, host2Id )
shahshreya4e13a062014-11-11 16:46:18 -0800520
521 flowHandle = main.ONOScli1.flows()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800522 main.log.info( "flows:" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -0800523
524 count = 1
525 i = 8
shahshreyaf3076352015-01-23 13:52:01 -0800526 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800527 while i < 18:
528 main.log.info(
529 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
530 ping = main.Mininet1.pingHost(
531 src="h" + str( i ), target="h" + str( i + 10 ) )
532 if ping == main.FALSE and count < 5:
533 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800534 # i = 8
shahshreyaf3076352015-01-23 13:52:01 -0800535 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800536 main.log.report( "Ping between h" +
537 str( i ) +
538 " and h" +
539 str( i +
540 10 ) +
541 " failed. Making attempt number " +
542 str( count ) +
543 " in 2 seconds" )
544 time.sleep( 2 )
545 elif ping == main.FALSE:
546 main.log.report( "All ping attempts between h" +
547 str( i ) +
548 " and h" +
549 str( i +
550 10 ) +
551 "have failed" )
552 i = 19
shahshreyaf3076352015-01-23 13:52:01 -0800553 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800554 elif ping == main.TRUE:
555 main.log.info( "Ping test between h" +
556 str( i ) +
557 " and h" +
558 str( i +
559 10 ) +
560 "passed!" )
561 i += 1
shahshreyaf3076352015-01-23 13:52:01 -0800562 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800563 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800564 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -0800565 PingResult = main.ERROR
566 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800567 main.log.report(
568 "Host intents have not ben installed correctly. Cleaning up" )
569 # main.cleanup()
570 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -0800571 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800572 main.log.report( "Host intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -0800573
shahshreyaf3076352015-01-23 13:52:01 -0800574 case6Result = PingResult
575 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800576 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800577 actual=case6Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800578 onpass="Host intent addition and Pingall Test successful",
579 onfail="Host intent addition and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800580
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800581 def CASE7( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800582
shahshreyaf3076352015-01-23 13:52:01 -0800583 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800584
shahshreyaf3076352015-01-23 13:52:01 -0800585 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800586
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800587 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800588 "This testscase is killing a link to" +
589 " ensure that link discovery is consistent" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800590 main.log.report( "__________________________________" )
591 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800592 "Killing a link to Ensure that Link" +
593 " Discovery is Working Properly" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800594 main.step( "Start continuous pings" )
shahshreya4e13a062014-11-11 16:46:18 -0800595
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800596 main.Mininet2.pingLong(
597 src=main.params[ 'PING' ][ 'source1' ],
598 target=main.params[ 'PING' ][ 'target1' ],
599 pingTime=500 )
600 main.Mininet2.pingLong(
601 src=main.params[ 'PING' ][ 'source2' ],
602 target=main.params[ 'PING' ][ 'target2' ],
603 pingTime=500 )
604 main.Mininet2.pingLong(
605 src=main.params[ 'PING' ][ 'source3' ],
606 target=main.params[ 'PING' ][ 'target3' ],
607 pingTime=500 )
608 main.Mininet2.pingLong(
609 src=main.params[ 'PING' ][ 'source4' ],
610 target=main.params[ 'PING' ][ 'target4' ],
611 pingTime=500 )
612 main.Mininet2.pingLong(
613 src=main.params[ 'PING' ][ 'source5' ],
614 target=main.params[ 'PING' ][ 'target5' ],
615 pingTime=500 )
616 main.Mininet2.pingLong(
617 src=main.params[ 'PING' ][ 'source6' ],
618 target=main.params[ 'PING' ][ 'target6' ],
619 pingTime=500 )
620 main.Mininet2.pingLong(
621 src=main.params[ 'PING' ][ 'source7' ],
622 target=main.params[ 'PING' ][ 'target7' ],
623 pingTime=500 )
624 main.Mininet2.pingLong(
625 src=main.params[ 'PING' ][ 'source8' ],
626 target=main.params[ 'PING' ][ 'target8' ],
627 pingTime=500 )
628 main.Mininet2.pingLong(
629 src=main.params[ 'PING' ][ 'source9' ],
630 target=main.params[ 'PING' ][ 'target9' ],
631 pingTime=500 )
632 main.Mininet2.pingLong(
633 src=main.params[ 'PING' ][ 'source10' ],
634 target=main.params[ 'PING' ][ 'target10' ],
635 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -0800636
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800637 main.step( "Determine the current number of switches and links" )
shahshreyaf3076352015-01-23 13:52:01 -0800638 topologyOutput = main.ONOScli1.topology()
639 topologyResult = main.ONOSbench.getTopology( topologyOutput )
640 activeSwitches = topologyResult[ 'devices' ]
641 links = topologyResult[ 'links' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800642 print "activeSwitches = ", type( activeSwitches )
643 print "links = ", type( links )
644 main.log.info(
645 "Currently there are %s switches and %s links" %
646 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -0800647
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800648 main.step( "Kill Link between s3 and s28" )
649 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
shahshreyaf3076352015-01-23 13:52:01 -0800650 time.sleep( linkSleep )
651 topologyOutput = main.ONOScli2.topology()
652 LinkDown = main.ONOSbench.checkStatus(
653 topologyOutput, activeSwitches, str(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800654 int( links ) - 2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800655 if LinkDown == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800656 main.log.report( "Link Down discovered properly" )
shahshreyaf3076352015-01-23 13:52:01 -0800657 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800658 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800659 actual=LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800660 onpass="Link Down discovered properly",
661 onfail="Link down was not discovered in " +
shahshreyaf3076352015-01-23 13:52:01 -0800662 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800663 " seconds" )
shahshreya4e13a062014-11-11 16:46:18 -0800664
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800665 main.step( "Bring link between s3 and s28 back up" )
shahshreyaf3076352015-01-23 13:52:01 -0800666 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
667 time.sleep( linkSleep )
668 topologyOutput = main.ONOScli2.topology()
669 LinkUp = main.ONOSbench.checkStatus(
670 topologyOutput,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800671 activeSwitches,
672 str( links ) )
shahshreyaf3076352015-01-23 13:52:01 -0800673 if LinkUp == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800674 main.log.report( "Link up discovered properly" )
shahshreyaf3076352015-01-23 13:52:01 -0800675 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800676 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800677 actual=LinkUp,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800678 onpass="Link up discovered properly",
679 onfail="Link up was not discovered in " +
shahshreyaf3076352015-01-23 13:52:01 -0800680 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800681 " seconds" )
682
683 main.step( "Compare ONOS Topology to MN Topology" )
684 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800685 "Testing Mininet topology with the" +
686 " topology of multi instances ONOS" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800687 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800688 devices1 = main.ONOScli1.devices()
689 devices2 = main.ONOScli2.devices()
690 devices3 = main.ONOScli3.devices()
691 print "devices1 = ", devices1
692 print "devices2 = ", devices2
693 print "devices3 = ", devices3
694 hosts1 = main.ONOScli1.hosts()
695 hosts2 = main.ONOScli2.hosts()
696 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800697 # print "hosts1 = ", hosts1
698 # print "hosts2 = ", hosts2
699 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800700 ports1 = main.ONOScli1.ports()
701 ports2 = main.ONOScli2.ports()
702 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800703 # print "ports1 = ", ports1
704 # print "ports2 = ", ports2
705 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800706 links1 = main.ONOScli1.links()
707 links2 = main.ONOScli2.links()
708 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800709 # print "links1 = ", links1
710 # print "links2 = ", links2
711 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800712
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800713 print "**************"
714
715 main.step( "Start continuous pings" )
716 main.Mininet2.pingLong(
717 src=main.params[ 'PING' ][ 'source1' ],
718 target=main.params[ 'PING' ][ 'target1' ],
719 pingTime=500 )
720 main.Mininet2.pingLong(
721 src=main.params[ 'PING' ][ 'source2' ],
722 target=main.params[ 'PING' ][ 'target2' ],
723 pingTime=500 )
724 main.Mininet2.pingLong(
725 src=main.params[ 'PING' ][ 'source3' ],
726 target=main.params[ 'PING' ][ 'target3' ],
727 pingTime=500 )
728 main.Mininet2.pingLong(
729 src=main.params[ 'PING' ][ 'source4' ],
730 target=main.params[ 'PING' ][ 'target4' ],
731 pingTime=500 )
732 main.Mininet2.pingLong(
733 src=main.params[ 'PING' ][ 'source5' ],
734 target=main.params[ 'PING' ][ 'target5' ],
735 pingTime=500 )
736 main.Mininet2.pingLong(
737 src=main.params[ 'PING' ][ 'source6' ],
738 target=main.params[ 'PING' ][ 'target6' ],
739 pingTime=500 )
740 main.Mininet2.pingLong(
741 src=main.params[ 'PING' ][ 'source7' ],
742 target=main.params[ 'PING' ][ 'target7' ],
743 pingTime=500 )
744 main.Mininet2.pingLong(
745 src=main.params[ 'PING' ][ 'source8' ],
746 target=main.params[ 'PING' ][ 'target8' ],
747 pingTime=500 )
748 main.Mininet2.pingLong(
749 src=main.params[ 'PING' ][ 'source9' ],
750 target=main.params[ 'PING' ][ 'target9' ],
751 pingTime=500 )
752 main.Mininet2.pingLong(
753 src=main.params[ 'PING' ][ 'source10' ],
754 target=main.params[ 'PING' ][ 'target10' ],
755 pingTime=500 )
756
757 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800758 global ctrls
759 ctrls = []
760 count = 1
761 while True:
762 temp = ()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800763 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
764 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
765 temp = temp + ( "ONOS" + str( count ), )
766 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
767 temp = temp + \
768 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
769 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800770 count = count + 1
771 else:
772 break
773 global MNTopo
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800774 Topo = TestONTopology(
775 main.Mininet1,
776 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800777 MNTopo = Topo
778
shahshreyaf3076352015-01-23 13:52:01 -0800779 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800780 main.step( "Compare ONOS Topology to MN Topology" )
781
shahshreyaf3076352015-01-23 13:52:01 -0800782 switchesResults1 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800783 MNTopo,
784 json.loads( devices1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800785 print "switches_Result1 = ", switchesResults1
786 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
787 onpass="ONOS1 Switches view is correct",
788 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800789
shahshreyaf3076352015-01-23 13:52:01 -0800790 switchesResults2 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800791 MNTopo,
792 json.loads( devices2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800793 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
794 onpass="ONOS2 Switches view is correct",
795 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800796
shahshreyaf3076352015-01-23 13:52:01 -0800797 switchesResults3 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800798 MNTopo,
799 json.loads( devices3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800800 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
801 onpass="ONOS3 Switches view is correct",
802 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800803
804 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800805 portsResults1 = main.Mininet1.comparePorts( MNTopo,
806 json.loads( ports1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800807 utilities.assertEquals( expect=main.TRUE, actual=portsResults1,
shahshreya4e13a062014-11-11 16:46:18 -0800808 onpass="ONOS1 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800809 onfail="ONOS1 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800810
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800811 portsResults2 = main.Mininet1.comparePorts( MNTopo,
812 json.loads( ports2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800813 utilities.assertEquals( expect=main.TRUE, actual=portsResults2,
shahshreya4e13a062014-11-11 16:46:18 -0800814 onpass="ONOS2 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800815 onfail="ONOS2 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800816
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800817 portsResults3 = main.Mininet1.comparePorts( MNTopo,
818 json.loads( ports3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800819 utilities.assertEquals( expect=main.TRUE, actual=portsResults3,
shahshreya4e13a062014-11-11 16:46:18 -0800820 onpass="ONOS3 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800821 onfail="ONOS3 Ports view is incorrect" )
822 """
shahshreyaf3076352015-01-23 13:52:01 -0800823 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800824 MNTopo,
825 json.loads( links1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800826 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
827 onpass="ONOS1 Links view is correct",
828 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800829
shahshreyaf3076352015-01-23 13:52:01 -0800830 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800831 MNTopo,
832 json.loads( links2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800833 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
834 onpass="ONOS2 Links view is correct",
835 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800836
shahshreyaf3076352015-01-23 13:52:01 -0800837 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800838 MNTopo,
839 json.loads( links3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800840 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
841 onpass="ONOS2 Links view is correct",
842 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800843
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800844 # topoResult = switchesResults1 and switchesResults2
845 # and switchesResults3\
shahshreyaf3076352015-01-23 13:52:01 -0800846 # and portsResults1 and portsResults2 and portsResults3\
847 # and linksResults1 and linksResults2 and linksResults3
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800848
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800849 topoResult = switchesResults1 and switchesResults2\
850 and switchesResults3 and linksResults1 and\
851 linksResults2 and linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800852
shahshreyaf3076352015-01-23 13:52:01 -0800853 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800854 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800855 actual=topoResult and LinkUp and LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800856 onpass="Topology Check Test successful",
857 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800858
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800859 def CASE8( self ):
860 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800861 Intent removal
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800862 """
863 main.log.report(
shahshreyab512cd02015-01-27 17:01:47 -0800864 "This testcase removes any previously added intents" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800865 main.log.report( "__________________________________" )
866 main.log.info( "Removing any previously installed intents" )
867 main.case( "Removing intents" )
868 main.step( "Obtain the intent id's" )
shahshreyaf3076352015-01-23 13:52:01 -0800869 intentResult = main.ONOScli1.intents( jsonFormat=False )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800870
shahshreyaf3076352015-01-23 13:52:01 -0800871 intentLinewise = intentResult.split( "\n" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800872 intentList = []
shahshreyaf3076352015-01-23 13:52:01 -0800873 for line in intentLinewise:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800874 if line.startswith( "id=" ):
875 intentList.append( line )
shahshreyae6c7cf42014-11-26 16:39:01 -0800876
877 intentids = []
878 for line in intentList:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800879 intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
shahshreya4e13a062014-11-11 16:46:18 -0800880 for id in intentids:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800881 main.log.info( "id = " + id )
shahshreyae6c7cf42014-11-26 16:39:01 -0800882
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800883 main.step(
884 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -0800885 for id in intentids:
shahshreyaf3076352015-01-23 13:52:01 -0800886 main.ONOScli1.removeIntent( intentId=id )
shahshreyae6c7cf42014-11-26 16:39:01 -0800887
shahshreyaf3076352015-01-23 13:52:01 -0800888 intentResult = main.ONOScli1.intents( jsonFormat=False )
889 main.log.info( "intent_result = " + intentResult )
890 case8Result = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800891
shahshreyae6c7cf42014-11-26 16:39:01 -0800892 i = 8
shahshreyaf3076352015-01-23 13:52:01 -0800893 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800894 while i < 18:
895 main.log.info(
896 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
897 ping = main.Mininet1.pingHost(
898 src="h" + str( i ), target="h" + str( i + 10 ) )
899 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -0800900 i = 19
shahshreyaf3076352015-01-23 13:52:01 -0800901 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800902 elif ping == main.FALSE:
903 i += 1
shahshreyaf3076352015-01-23 13:52:01 -0800904 PingResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800905 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800906 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -0800907 PingResult = main.ERROR
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800908
909 # Note: If the ping result failed, that means the intents have been
910 # withdrawn correctly.
shahshreyaf3076352015-01-23 13:52:01 -0800911 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800912 main.log.report( "Host intents have not been withdrawn correctly" )
913 # main.cleanup()
914 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -0800915 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800916 main.log.report( "Host intents have been withdrawn correctly" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800917
shahshreyaf3076352015-01-23 13:52:01 -0800918 case8Result = case8Result and PingResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800919
shahshreyaf3076352015-01-23 13:52:01 -0800920 if case8Result == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800921 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800922 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800923 main.log.report( "Intent removal failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800924
shahshreyaf3076352015-01-23 13:52:01 -0800925 utilities.assertEquals( expect=main.FALSE, actual=case8Result,
926 onpass="Intent removal test failed",
927 onfail="Intent removal test successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800928
929 def CASE9( self ):
930 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800931 This test case adds point intents. Make sure you run test case 8
932 which is host intent removal before executing this test case.
933 Else the host intent's flows will persist on switches and the pings
934 would work even if there is some issue with the point intent's flows
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800935 """
936 main.log.report(
937 "This testcase adds point intents and then does pingall" )
938 main.log.report( "__________________________________" )
939 main.log.info( "Adding point intents" )
940 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800941 "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20," +
942 "h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800943 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800944 "Add point-to-point intents for mininet hosts" +
945 " h8 and h18 or ONOS hosts h8 and h12" )
shahshreyaf3076352015-01-23 13:52:01 -0800946 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800947 "of:0000000000003008/1",
948 "of:0000000000006018/1" )
shahshreyaf3076352015-01-23 13:52:01 -0800949 if ptpIntentResult == main.TRUE:
950 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800951 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800952 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800953
shahshreyaf3076352015-01-23 13:52:01 -0800954 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800955 "of:0000000000006018/1",
956 "of:0000000000003008/1" )
shahshreyaf3076352015-01-23 13:52:01 -0800957 if ptpIntentResult == main.TRUE:
958 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800959 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800960 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800961
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800962 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800963 "Add point-to-point intents for mininet hosts" +
964 " h9 and h19 or ONOS hosts h9 and h13" )
shahshreyaf3076352015-01-23 13:52:01 -0800965 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800966 "of:0000000000003009/1",
967 "of:0000000000006019/1" )
shahshreyaf3076352015-01-23 13:52:01 -0800968 if ptpIntentResult == main.TRUE:
969 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800970 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800971 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800972
shahshreyaf3076352015-01-23 13:52:01 -0800973 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800974 "of:0000000000006019/1",
975 "of:0000000000003009/1" )
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
981 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800982 "Add point-to-point intents for mininet" +
983 " hosts h10 and h20 or ONOS hosts hA and h14" )
shahshreyaf3076352015-01-23 13:52:01 -0800984 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800985 "of:0000000000003010/1",
986 "of:0000000000006020/1" )
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 )
shahshreya4e13a062014-11-11 16:46:18 -0800991
shahshreyaf3076352015-01-23 13:52:01 -0800992 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800993 "of:0000000000006020/1",
994 "of:0000000000003010/1" )
shahshreyaf3076352015-01-23 13:52:01 -0800995 if ptpIntentResult == main.TRUE:
996 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800997 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800998 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800999
1000 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001001 "Add point-to-point intents for mininet" +
1002 " hosts h11 and h21 or ONOS hosts hB and h15" )
shahshreyaf3076352015-01-23 13:52:01 -08001003 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001004 "of:0000000000003011/1",
1005 "of:0000000000006021/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001006 if ptpIntentResult == main.TRUE:
1007 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001008 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001009 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001010
shahshreyaf3076352015-01-23 13:52:01 -08001011 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001012 "of:0000000000006021/1",
1013 "of:0000000000003011/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001014 if ptpIntentResult == main.TRUE:
1015 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001016 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001017 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001018
1019 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001020 "Add point-to-point intents for mininet" +
1021 " hosts h12 and h22 or ONOS hosts hC and h16" )
shahshreyaf3076352015-01-23 13:52:01 -08001022 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001023 "of:0000000000003012/1",
1024 "of:0000000000006022/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001025 if ptpIntentResult == main.TRUE:
1026 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001027 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001028 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001029
shahshreyaf3076352015-01-23 13:52:01 -08001030 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001031 "of:0000000000006022/1",
1032 "of:0000000000003012/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001033 if ptpIntentResult == main.TRUE:
1034 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001035 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001036 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001037
1038 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001039 "Add point-to-point intents for mininet " +
1040 "hosts h13 and h23 or ONOS hosts hD and h17" )
shahshreyaf3076352015-01-23 13:52:01 -08001041 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001042 "of:0000000000003013/1",
1043 "of:0000000000006023/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001044 if ptpIntentResult == main.TRUE:
1045 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001046 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001047 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001048
shahshreyaf3076352015-01-23 13:52:01 -08001049 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001050 "of:0000000000006023/1",
1051 "of:0000000000003013/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001052 if ptpIntentResult == main.TRUE:
1053 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001054 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001055 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001056
1057 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001058 "Add point-to-point intents for mininet hosts" +
1059 " h14 and h24 or ONOS hosts hE and h18" )
shahshreyaf3076352015-01-23 13:52:01 -08001060 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001061 "of:0000000000003014/1",
1062 "of:0000000000006024/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001063 if ptpIntentResult == main.TRUE:
1064 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001065 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001066 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001067
shahshreyaf3076352015-01-23 13:52:01 -08001068 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001069 "of:0000000000006024/1",
1070 "of:0000000000003014/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001071 if ptpIntentResult == main.TRUE:
1072 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001073 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001074 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001075
1076 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001077 "Add point-to-point intents for mininet hosts" +
1078 " h15 and h25 or ONOS hosts hF and h19" )
shahshreyaf3076352015-01-23 13:52:01 -08001079 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001080 "of:0000000000003015/1",
1081 "of:0000000000006025/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001082 if ptpIntentResult == main.TRUE:
1083 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001084 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001085 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001086
shahshreyaf3076352015-01-23 13:52:01 -08001087 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001088 "of:0000000000006025/1",
1089 "of:0000000000003015/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001090 if ptpIntentResult == main.TRUE:
1091 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001092 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001093 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001094
1095 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001096 "Add point-to-point intents for mininet hosts" +
1097 " h16 and h26 or ONOS hosts h10 and h1A" )
shahshreyaf3076352015-01-23 13:52:01 -08001098 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001099 "of:0000000000003016/1",
1100 "of:0000000000006026/1" )
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" )
shahshreyaf3076352015-01-23 13:52:01 -08001104 # 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:0000000000006026/1",
1108 "of:0000000000003016/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001109 if ptpIntentResult == main.TRUE:
1110 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001111 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001112 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001113
1114 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001115 "Add point-to-point intents for mininet hosts h17" +
1116 " and h27 or ONOS hosts h11 and h1B" )
shahshreyaf3076352015-01-23 13:52:01 -08001117 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001118 "of:0000000000003017/1",
1119 "of:0000000000006027/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001120 if ptpIntentResult == main.TRUE:
1121 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001122 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001123 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001124
shahshreyaf3076352015-01-23 13:52:01 -08001125 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001126 "of:0000000000006027/1",
1127 "of:0000000000003017/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001128 if ptpIntentResult == main.TRUE:
1129 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001130 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001131 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001132
1133 print(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001134 "_______________________________________________________" +
1135 "________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001136
1137 flowHandle = main.ONOScli1.flows()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001138 # print "flowHandle = ", flowHandle
1139 main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001140
1141 count = 1
1142 i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001143 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001144 while i < 18:
1145 main.log.info(
1146 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1147 ping = main.Mininet1.pingHost(
1148 src="h" + str( i ), target="h" + str( i + 10 ) )
1149 if ping == main.FALSE and count < 5:
1150 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001151 # i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001152 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001153 main.log.report( "Ping between h" +
1154 str( i ) +
1155 " and h" +
1156 str( i +
1157 10 ) +
1158 " failed. Making attempt number " +
1159 str( count ) +
1160 " in 2 seconds" )
1161 time.sleep( 2 )
1162 elif ping == main.FALSE:
1163 main.log.report( "All ping attempts between h" +
1164 str( i ) +
1165 " and h" +
1166 str( i +
1167 10 ) +
1168 "have failed" )
1169 i = 19
shahshreyaf3076352015-01-23 13:52:01 -08001170 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001171 elif ping == main.TRUE:
1172 main.log.info( "Ping test between h" +
1173 str( i ) +
1174 " and h" +
1175 str( i +
1176 10 ) +
1177 "passed!" )
1178 i += 1
shahshreyaf3076352015-01-23 13:52:01 -08001179 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001180 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001181 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -08001182 PingResult = main.ERROR
1183 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001184 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001185 "Ping all test after Point intents" +
1186 " addition failed. Cleaning up" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001187 # main.cleanup()
1188 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -08001189 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001190 main.log.report(
1191 "Ping all test after Point intents addition successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001192
shahshreyaf3076352015-01-23 13:52:01 -08001193 case8Result = PingResult
1194 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001195 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001196 actual=case8Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001197 onpass="Ping all test after Point intents addition successful",
1198 onfail="Ping all test after Point intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001199
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001200 def CASE31( self ):
1201 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001202 This test case adds point intent related to
1203 SDN-IP matching on ICMP ( ethertype=IPV4, ipProto=1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001204 """
shahshreyae6c7cf42014-11-26 16:39:01 -08001205 import json
1206
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001207 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001208 "This test case adds point intent " +
1209 "related to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001210 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001211 "Adding bidirectional point intent related" +
1212 " to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001213 main.step( "Adding bidirectional point intent" )
1214 # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1215 # --ethType=IPV4 --ipProto=1 of:0000000000003008/1
1216 # of:0000000000006018/1
1217
shahshreyaf3076352015-01-23 13:52:01 -08001218 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001219 for i in range( 8, 11 ):
1220 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001221 "Adding point intent between h" + str( i ) +
1222 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001223 host1 = "00:00:00:00:00:" + \
1224 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1225 host2 = "00:00:00:00:00:" + \
1226 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
shahshreyaf3076352015-01-23 13:52:01 -08001227 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1228 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1229 for host in hostsJson:
1230 if host[ 'id' ] == host1Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001231 ip1 = host[ 'ips' ][ 0 ]
1232 ip1 = str( ip1 + "/32" )
1233 device1 = host[ 'location' ][ 'device' ]
1234 device1 = str( device1 + "/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001235 elif host[ 'id' ] == host2Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001236 ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
1237 device2 = host[ 'location' ][ "device" ]
1238 device2 = str( device2 + "/1" )
1239
shahshreyaf3076352015-01-23 13:52:01 -08001240 pIntentResult1 = main.ONOScli1.addPointIntent(
1241 ingressDevice=device1,
1242 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001243 ipSrc=ip1,
1244 ipDst=ip2,
1245 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1246 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1247
shahshreyaf3076352015-01-23 13:52:01 -08001248 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1249 main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001250
shahshreyaf3076352015-01-23 13:52:01 -08001251 pIntentResult2 = main.ONOScli1.addPointIntent(
1252 ingressDevice=device2,
1253 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001254 ipSrc=ip2,
1255 ipDst=ip1,
1256 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1257 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1258
shahshreyaf3076352015-01-23 13:52:01 -08001259 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1260 main.log.info( getIntentResult )
1261 if ( pIntentResult1 and pIntentResult2 ) == main.TRUE:
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001262 # getIntentResult = main.ONOScli1.intents()
shahshreyaf3076352015-01-23 13:52:01 -08001263 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001264 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001265 "Point intent related to SDN-IP matching" +
1266 " on ICMP install successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001267
1268 time.sleep( 15 )
shahshreyaf3076352015-01-23 13:52:01 -08001269 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1270 main.log.info( "intents = " + getIntentResult )
1271 getFlowsResult = main.ONOScli1.flows()
1272 main.log.info( "flows = " + getFlowsResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001273
shahshreyae6c7cf42014-11-26 16:39:01 -08001274 count = 1
1275 i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001276 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001277 while i < 11:
1278 main.log.info(
1279 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1280 ping = main.Mininet1.pingHost(
1281 src="h" + str( i ), target="h" + str( i + 10 ) )
1282 if ping == main.FALSE and count < 3:
1283 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001284 # i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001285 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001286 main.log.report( "Ping between h" +
1287 str( i ) +
1288 " and h" +
1289 str( i +
1290 10 ) +
1291 " failed. Making attempt number " +
1292 str( count ) +
1293 " in 2 seconds" )
1294 time.sleep( 2 )
1295 elif ping == main.FALSE:
1296 main.log.report( "All ping attempts between h" +
1297 str( i ) +
1298 " and h" +
1299 str( i +
1300 10 ) +
1301 "have failed" )
1302 i = 19
shahshreyaf3076352015-01-23 13:52:01 -08001303 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001304 elif ping == main.TRUE:
1305 main.log.info( "Ping test between h" +
1306 str( i ) +
1307 " and h" +
1308 str( i +
1309 10 ) +
1310 "passed!" )
1311 i += 1
shahshreyaf3076352015-01-23 13:52:01 -08001312 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -08001313 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001314 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -08001315 PingResult = main.ERROR
1316 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001317 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001318 "Ping test after Point intents related to" +
1319 " SDN-IP matching on ICMP failed." )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001320 # main.cleanup()
1321 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -08001322 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001323 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001324 "Ping all test after Point intents related to" +
1325 " SDN-IP matching on ICMP successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001326
shahshreyaf3076352015-01-23 13:52:01 -08001327 case31Result = PingResult and pIntentResult1 and pIntentResult2
1328 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001329 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001330 actual=case31Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001331 onpass="Point intent related to SDN-IP " +
1332 "matching on ICMP and ping test successful",
1333 onfail="Point intent related to SDN-IP" +
1334 " matching on ICMP and ping test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001335
1336 def CASE32( self ):
1337 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001338 This test case adds point intent related to SDN-IP matching on TCP
1339 ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 )
1340 Note: Although BGP port is 179, we are using 5001 because iperf
1341 is used for verifying and iperf's default port is 5001
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001342 """
shahshreyae6c7cf42014-11-26 16:39:01 -08001343 import json
1344
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001345 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001346 "This test case adds point intent" +
1347 " related to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001348 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001349 "Adding bidirectional point intent related" +
1350 " to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001351 main.step( "Adding bidirectional point intent" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001352 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001353 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1354 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1
1355 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001356
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001357 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1358 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1
1359 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001360
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001361 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1362 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1
1363 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001364
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001365 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1366 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1
1367 of:0000000000003008/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001368
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001369 """
shahshreyaf3076352015-01-23 13:52:01 -08001370 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001371 for i in range( 8, 9 ):
1372 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001373 "Adding point intent between h" + str( i ) +
1374 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001375 host1 = "00:00:00:00:00:" + \
1376 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1377 host2 = "00:00:00:00:00:" + \
1378 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
shahshreyaf3076352015-01-23 13:52:01 -08001379 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1380 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1381 for host in hostsJson:
1382 if host[ 'id' ] == host1Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001383 ip1 = host[ 'ips' ][ 0 ]
1384 ip1 = str( ip1 + "/32" )
1385 device1 = host[ 'location' ][ 'device' ]
1386 device1 = str( device1 + "/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001387 elif host[ 'id' ] == host2Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001388 ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
1389 device2 = host[ 'location' ][ "device" ]
1390 device2 = str( device2 + "/1" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001391
shahshreyaf3076352015-01-23 13:52:01 -08001392 pIntentResult1 = main.ONOScli1.addPointIntent(
1393 ingressDevice=device1,
1394 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001395 ipSrc=ip1,
1396 ipDst=ip2,
1397 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1398 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1399 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
shahshreyaf3076352015-01-23 13:52:01 -08001400 pIntentResult2 = main.ONOScli1.addPointIntent(
1401 ingressDevice=device2,
1402 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001403 ipSrc=ip2,
1404 ipDst=ip1,
1405 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1406 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1407 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
1408
shahshreyaf3076352015-01-23 13:52:01 -08001409 pIntentResult3 = main.ONOScli1.addPointIntent(
1410 ingressDevice=device1,
1411 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001412 ipSrc=ip1,
1413 ipDst=ip2,
1414 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1415 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1416 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
shahshreyaf3076352015-01-23 13:52:01 -08001417 pIntentResult4 = main.ONOScli1.addPointIntent(
1418 ingressDevice=device2,
1419 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001420 ipSrc=ip2,
1421 ipDst=ip1,
1422 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1423 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1424 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
shahshreyae6c7cf42014-11-26 16:39:01 -08001425
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001426 pIntentResult = pIntentResult1 and pIntentResult2 and\
1427 pIntentResult3 and pIntentResult4
shahshreyaf3076352015-01-23 13:52:01 -08001428 if pIntentResult == main.TRUE:
1429 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1430 main.log.info( getIntentResult )
shahshreyab512cd02015-01-27 17:01:47 -08001431 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001432 "Point intent related to SDN-IP matching" +
1433 " on TCP install successful" )
shahshreyab512cd02015-01-27 17:01:47 -08001434 else:
1435 main.log.report(
1436 "Point intent related to SDN-IP matching" +
1437 " on TCP install failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001438
shahshreyaf3076352015-01-23 13:52:01 -08001439 iperfResult = main.Mininet1.iperf( 'h8', 'h18' )
1440 if iperfResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001441 main.log.report( "iperf test successful" )
1442 else:
1443 main.log.report( "iperf test failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001444
shahshreyaf3076352015-01-23 13:52:01 -08001445 case32Result = pIntentResult and iperfResult
1446 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001447 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001448 actual=case32Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001449 onpass="Ping all test after Point intents addition related " +
1450 "to SDN-IP on TCP match successful",
1451 onfail="Ping all test after Point intents addition related " +
1452 "to SDN-IP on TCP match failed" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001453
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001454 def CASE33( self ):
1455 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001456 This test case adds multipoint to singlepoint intent related to
1457 SDN-IP matching on destination ip and the action is to rewrite
1458 the mac address
1459 Here the mac address to be rewritten is the mac address of the
1460 egress device
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001461 """
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001462 import json
1463 import time
1464
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001465 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001466 "This test case adds multipoint to singlepoint intent related to" +
1467 " SDN-IP matching on destination ip and " +
1468 "rewrite mac address action" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001469 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001470 "Adding multipoint to singlepoint intent related to SDN-IP" +
1471 " matching on destination ip" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001472 main.step( "Adding bidirectional multipoint to singlepoint intent" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001473 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001474 add-multi-to-single-intent --ipDst=10.0.3.0/24
1475 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1
1476 of:0000000000006018/1
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001477
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001478 add-multi-to-single-intent --ipDst=10.0.1.0/24
1479 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1
1480 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001481 """
1482 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001483 "Installing multipoint to single point " +
1484 "intent with rewrite mac address" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001485 main.step( "Uninstalling proxy arp app" )
1486 # Unistall onos-app-proxyarp app to disable reactive forwarding
shahshreyaf3076352015-01-23 13:52:01 -08001487 appUninstallResult1 = main.ONOScli1.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001488 "onos-app-proxyarp" )
shahshreyaf3076352015-01-23 13:52:01 -08001489 appUninstallResult2 = main.ONOScli2.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001490 "onos-app-proxyarp" )
shahshreyaf3076352015-01-23 13:52:01 -08001491 appUninstallResult3 = main.ONOScli3.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001492 "onos-app-proxyarp" )
1493 main.log.info( "onos-app-proxyarp uninstalled" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001494
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001495 main.step( "Changing ipaddress of hosts h8,h9 and h18" )
1496 main.Mininet1.changeIP(
1497 host='h8',
1498 intf='h8-eth0',
1499 newIP='10.0.1.1',
1500 newNetmask='255.255.255.0' )
1501 main.Mininet1.changeIP(
1502 host='h9',
1503 intf='h9-eth0',
1504 newIP='10.0.2.1',
1505 newNetmask='255.255.255.0' )
1506 main.Mininet1.changeIP(
1507 host='h10',
1508 intf='h10-eth0',
1509 newIP='10.0.3.1',
1510 newNetmask='255.255.255.0' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001511
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001512 main.step( "Changing default gateway of hosts h8,h9 and h18" )
1513 main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' )
1514 main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' )
1515 main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001516
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001517 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001518 "Assigning random mac address to the default gateways " +
1519 "since proxyarp app is uninstalled" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001520 main.Mininet1.addStaticMACAddress(
1521 host='h8',
1522 GW='10.0.1.254',
1523 macaddr='00:00:00:00:11:11' )
1524 main.Mininet1.addStaticMACAddress(
1525 host='h9',
1526 GW='10.0.2.254',
1527 macaddr='00:00:00:00:22:22' )
1528 main.Mininet1.addStaticMACAddress(
1529 host='h10',
1530 GW='10.0.3.254',
1531 macaddr='00:00:00:00:33:33' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001532
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001533 main.step( "Verify static gateway and MAC address assignment" )
1534 main.Mininet1.verifyStaticGWandMAC( host='h8' )
1535 main.Mininet1.verifyStaticGWandMAC( host='h9' )
1536 main.Mininet1.verifyStaticGWandMAC( host='h10' )
1537
1538 main.step( "Adding multipoint to singlepoint intent" )
shahshreyaf3076352015-01-23 13:52:01 -08001539 pIntentResult1 = main.ONOScli1.addMultipointToSinglepointIntent(
1540 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
1541 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
1542 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001543 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
1544 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
1545
shahshreyaf3076352015-01-23 13:52:01 -08001546 pIntentResult2 = main.ONOScli1.addMultipointToSinglepointIntent(
1547 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
1548 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
1549 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001550 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
1551 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
1552
shahshreyaf3076352015-01-23 13:52:01 -08001553 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1554 main.log.info( "intents = " + getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001555
1556 time.sleep( 10 )
shahshreyaf3076352015-01-23 13:52:01 -08001557 getFlowsResult = main.ONOScli1.flows( jsonFormat=False )
1558 main.log.info( "flows = " + getFlowsResult )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001559
1560 count = 1
1561 i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001562 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001563
1564 main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
1565 ping = main.Mininet1.pingHost(
1566 src="h" + str( i ), target="h" + str( i + 2 ) )
1567 if ping == main.FALSE and count < 3:
1568 count += 1
shahshreyaf3076352015-01-23 13:52:01 -08001569 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001570 main.log.report( "Ping between h" +
1571 str( i ) +
1572 " and h" +
1573 str( i +
1574 2 ) +
1575 " failed. Making attempt number " +
1576 str( count ) +
1577 " in 2 seconds" )
1578 time.sleep( 2 )
1579 elif ping == main.FALSE:
1580 main.log.report( "All ping attempts between h" +
1581 str( i ) +
1582 " and h" +
1583 str( i +
1584 10 ) +
1585 "have failed" )
shahshreyaf3076352015-01-23 13:52:01 -08001586 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001587 elif ping == main.TRUE:
1588 main.log.info( "Ping test between h" +
1589 str( i ) +
1590 " and h" +
1591 str( i +
1592 2 ) +
1593 "passed!" )
shahshreyaf3076352015-01-23 13:52:01 -08001594 PingResult = main.TRUE
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001595 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001596 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -08001597 PingResult = main.ERROR
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001598
shahshreyaf3076352015-01-23 13:52:01 -08001599 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001600 main.log.report( "Ping test failed." )
1601 # main.cleanup()
1602 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -08001603 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001604 main.log.report( "Ping all successful" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001605
shahshreyaf3076352015-01-23 13:52:01 -08001606 pIntentResult = pIntentResult1 and pIntentResult2
1607 if pIntentResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001608 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001609 "Multi point intent with rewrite mac " +
1610 "address installation successful" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001611 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001612 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001613 "Multi point intent with rewrite mac" +
1614 " address installation failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001615
shahshreyaf3076352015-01-23 13:52:01 -08001616 case33Result = pIntentResult and PingResult
1617 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001618 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001619 actual=case33Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001620 onpass="Ping all test after multipoint to single point" +
1621 " intent addition with rewrite mac address successful",
1622 onfail="Ping all test after multipoint to single point intent" +
1623 " addition with rewrite mac address failed" )