blob: 6c0b8d758be498e39c959fdeec681e29a07f5514 [file] [log] [blame]
shahshreya4e13a062014-11-11 16:46:18 -08001
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08002# Testing the basic functionality of ONOS Next
3# For sanity and driver functionality excercises only.
shahshreya4e13a062014-11-11 16:46:18 -08004
5import time
6import sys
7import os
8import re
9import time
10import json
11
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080012time.sleep( 1 )
13
shahshreya74cca802015-02-26 12:24:01 -080014class MultiProd13:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080015
16 def __init__( self ):
shahshreya4e13a062014-11-11 16:46:18 -080017 self.default = ''
18
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080019 def CASE1( self, main ):
20 """
shahshreya4e13a062014-11-11 16:46:18 -080021 Startup sequence:
shahshreyae6c7cf42014-11-26 16:39:01 -080022 cell <name>
23 onos-verify-cell
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080024 onos-remove-raft-logs
shahshreya4e13a062014-11-11 16:46:18 -080025 git pull
26 mvn clean install
27 onos-package
shahshreya4e13a062014-11-11 16:46:18 -080028 onos-install -f
29 onos-wait-for-start
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080030 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -080031 cellName = main.params[ 'ENV' ][ 'cellName' ]
32 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
33 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
34 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
35 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
36 ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
37 ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080045 cellResult1 = main.ONOSbench.setCell( cellName )
46 # cellResult2 = main.ONOScli1.setCell( cellName )
47 # cellResult3 = main.ONOScli2.setCell( cellName )
48 # cellResult4 = main.ONOScli3.setCell( cellName )
49 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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080057 gitPullResult = main.ONOSbench.gitPull()
shahshreya1db2e292015-02-05 16:35:32 -080058 main.log.info( "git_pull_result = " + str( gitPullResult ))
kelvin-onlabcf33bda2015-01-23 16:54:17 -080059 versionResult = main.ONOSbench.getVersion( report=True )
shahshreya4e13a062014-11-11 16:46:18 -080060
kelvin-onlabcf33bda2015-01-23 16:54:17 -080061 if gitPullResult == 1:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080062 main.step( "Using mvn clean & install" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080063 cleanInstallResult = main.ONOSbench.cleanInstall()
64 # cleanInstallResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -080065
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080066 main.step( "Creating ONOS package" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -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" )
70 # 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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080074 onos1InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080075 options="-f",
kelvin-onlabcf33bda2015-01-23 16:54:17 -080076 node=ONOS1Ip )
77 onos2InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080078 options="-f",
kelvin-onlabcf33bda2015-01-23 16:54:17 -080079 node=ONOS2Ip )
80 onos3InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080081 options="-f",
kelvin-onlabcf33bda2015-01-23 16:54:17 -080082 node=ONOS3Ip )
83 onosInstallResult = onos1InstallResult and onos2InstallResult and\
84 onos3InstallResult
85 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
kelvin-onlabcf33bda2015-01-23 16:54:17 -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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800100 startResult = main.TRUE
101 # startResult = main.ONOSbench.onosStart( ONOS1Ip )
102 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
shahshreya1db2e292015-02-05 16:35:32 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -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:
kelvin-onlabcf33bda2015-01-23 16:54:17 -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 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -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 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -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"
kelvin-onlabcf33bda2015-01-23 16:54:17 -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"
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -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 )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800195 main.Mininet1.assignSwController(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800196 sw=str( i ),
197 count=3,
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800205 switchMastership = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800206 for i in range( 1, 29 ):
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800207 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800208 print( "Response is " + str( response ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800209 if re.search( "tcp:" + ONOS1Ip, response ):
210 switchMastership = switchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800211 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800212 switchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800213
kelvin-onlabcf33bda2015-01-23 16:54:17 -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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800220 pingResult = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800221 time1 = time.time()
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800235 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800236 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800349 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800350 main.step( "Compare ONOS Topology to MN Topology" )
351
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800352 switchesResults1 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800353 MNTopo,
354 json.loads( devices1 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800360 switchesResults2 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800361 MNTopo,
362 json.loads( devices2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800367 switchesResults3 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800368 MNTopo,
369 json.loads( devices3 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -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 ) )
377 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 ) )
383 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 ) )
389 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 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800393 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800394 MNTopo,
395 json.loads( links1 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800400 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800401 MNTopo,
402 json.loads( links2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800407 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800408 MNTopo,
409 json.loads( links3 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -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\
416 # 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
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800441 appUninstallResult1 = main.ONOScli1.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800442 "onos-app-fwd" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800443 appUninstallResult2 = main.ONOScli2.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800444 "onos-app-fwd" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800445 appUninstallResult3 = main.ONOScli3.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800446 "onos-app-fwd" )
447 main.log.info( "onos-app-fwd uninstalled" )
shahshreyaa9d79f22014-11-18 15:41:29 -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 )
shahshreyaa9d79f22014-11-18 15:41:29 -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
459 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800460 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800461 actual=case10Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800462 onpass="Reactive forwarding app uninstallation successful",
463 onfail="Reactive forwarding app uninstallation failed" )
shahshreyaa9d79f22014-11-18 15:41:29 -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" )
shahshreyaeac353b2014-11-18 17:19:20 -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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
535 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
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -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()
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800574 case6Result = PingResult
575 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800576 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -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
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800583 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800584
kelvin-onlabcf33bda2015-01-23 16:54:17 -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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800638 topologyOutput = main.ONOScli1.topology()
639 topologyResult = main.ONOSbench.getTopology( topologyOutput )
shahshreyab471a3e2015-03-19 17:07:13 -0700640 activeSwitches = topologyResult[ 'deviceCount' ]
641 links = topologyResult[ 'linkCount' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800642 main.log.info(
643 "Currently there are %s switches and %s links" %
644 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -0800645
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800646 main.step( "Kill Link between s3 and s28" )
647 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800648 time.sleep( linkSleep )
649 topologyOutput = main.ONOScli2.topology()
650 LinkDown = main.ONOSbench.checkStatus(
651 topologyOutput, activeSwitches, str(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800652 int( links ) - 2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800653 if LinkDown == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800654 main.log.report( "Link Down discovered properly" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800655 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800656 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800657 actual=LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800658 onpass="Link Down discovered properly",
659 onfail="Link down was not discovered in " +
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800660 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800661 " seconds" )
shahshreya4e13a062014-11-11 16:46:18 -0800662
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800663 main.step( "Bring link between s3 and s28 back up" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800664 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
665 time.sleep( linkSleep )
666 topologyOutput = main.ONOScli2.topology()
667 LinkUp = main.ONOSbench.checkStatus(
668 topologyOutput,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800669 activeSwitches,
670 str( links ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800671 if LinkUp == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800672 main.log.report( "Link up discovered properly" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800673 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800674 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800675 actual=LinkUp,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800676 onpass="Link up discovered properly",
677 onfail="Link up was not discovered in " +
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800678 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800679 " seconds" )
680
681 main.step( "Compare ONOS Topology to MN Topology" )
682 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800683 "Testing Mininet topology with the" +
684 " topology of multi instances ONOS" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800685 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800686 devices1 = main.ONOScli1.devices()
687 devices2 = main.ONOScli2.devices()
688 devices3 = main.ONOScli3.devices()
689 print "devices1 = ", devices1
690 print "devices2 = ", devices2
691 print "devices3 = ", devices3
692 hosts1 = main.ONOScli1.hosts()
693 hosts2 = main.ONOScli2.hosts()
694 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800695 # print "hosts1 = ", hosts1
696 # print "hosts2 = ", hosts2
697 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800698 ports1 = main.ONOScli1.ports()
699 ports2 = main.ONOScli2.ports()
700 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800701 # print "ports1 = ", ports1
702 # print "ports2 = ", ports2
703 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800704 links1 = main.ONOScli1.links()
705 links2 = main.ONOScli2.links()
706 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800707 # print "links1 = ", links1
708 # print "links2 = ", links2
709 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800710
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800711 print "**************"
712
713 main.step( "Start continuous pings" )
714 main.Mininet2.pingLong(
715 src=main.params[ 'PING' ][ 'source1' ],
716 target=main.params[ 'PING' ][ 'target1' ],
717 pingTime=500 )
718 main.Mininet2.pingLong(
719 src=main.params[ 'PING' ][ 'source2' ],
720 target=main.params[ 'PING' ][ 'target2' ],
721 pingTime=500 )
722 main.Mininet2.pingLong(
723 src=main.params[ 'PING' ][ 'source3' ],
724 target=main.params[ 'PING' ][ 'target3' ],
725 pingTime=500 )
726 main.Mininet2.pingLong(
727 src=main.params[ 'PING' ][ 'source4' ],
728 target=main.params[ 'PING' ][ 'target4' ],
729 pingTime=500 )
730 main.Mininet2.pingLong(
731 src=main.params[ 'PING' ][ 'source5' ],
732 target=main.params[ 'PING' ][ 'target5' ],
733 pingTime=500 )
734 main.Mininet2.pingLong(
735 src=main.params[ 'PING' ][ 'source6' ],
736 target=main.params[ 'PING' ][ 'target6' ],
737 pingTime=500 )
738 main.Mininet2.pingLong(
739 src=main.params[ 'PING' ][ 'source7' ],
740 target=main.params[ 'PING' ][ 'target7' ],
741 pingTime=500 )
742 main.Mininet2.pingLong(
743 src=main.params[ 'PING' ][ 'source8' ],
744 target=main.params[ 'PING' ][ 'target8' ],
745 pingTime=500 )
746 main.Mininet2.pingLong(
747 src=main.params[ 'PING' ][ 'source9' ],
748 target=main.params[ 'PING' ][ 'target9' ],
749 pingTime=500 )
750 main.Mininet2.pingLong(
751 src=main.params[ 'PING' ][ 'source10' ],
752 target=main.params[ 'PING' ][ 'target10' ],
753 pingTime=500 )
754
755 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800756 global ctrls
757 ctrls = []
758 count = 1
759 while True:
760 temp = ()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800761 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
762 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
763 temp = temp + ( "ONOS" + str( count ), )
764 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
765 temp = temp + \
766 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
767 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800768 count = count + 1
769 else:
770 break
771 global MNTopo
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800772 Topo = TestONTopology(
773 main.Mininet1,
774 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800775 MNTopo = Topo
776
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800777 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800778 main.step( "Compare ONOS Topology to MN Topology" )
779
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800780 switchesResults1 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800781 MNTopo,
782 json.loads( devices1 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800783 print "switches_Result1 = ", switchesResults1
784 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
785 onpass="ONOS1 Switches view is correct",
786 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800787
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800788 switchesResults2 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800789 MNTopo,
790 json.loads( devices2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800791 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
792 onpass="ONOS2 Switches view is correct",
793 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800794
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800795 switchesResults3 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800796 MNTopo,
797 json.loads( devices3 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800798 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
799 onpass="ONOS3 Switches view is correct",
800 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800801
802 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800803 portsResults1 = main.Mininet1.comparePorts( MNTopo,
804 json.loads( ports1 ) )
805 utilities.assertEquals( expect=main.TRUE, actual=portsResults1,
shahshreya4e13a062014-11-11 16:46:18 -0800806 onpass="ONOS1 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800807 onfail="ONOS1 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800808
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800809 portsResults2 = main.Mininet1.comparePorts( MNTopo,
810 json.loads( ports2 ) )
811 utilities.assertEquals( expect=main.TRUE, actual=portsResults2,
shahshreya4e13a062014-11-11 16:46:18 -0800812 onpass="ONOS2 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800813 onfail="ONOS2 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800814
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800815 portsResults3 = main.Mininet1.comparePorts( MNTopo,
816 json.loads( ports3 ) )
817 utilities.assertEquals( expect=main.TRUE, actual=portsResults3,
shahshreya4e13a062014-11-11 16:46:18 -0800818 onpass="ONOS3 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800819 onfail="ONOS3 Ports view is incorrect" )
820 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800821 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800822 MNTopo,
823 json.loads( links1 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800824 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
825 onpass="ONOS1 Links view is correct",
826 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800827
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800828 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800829 MNTopo,
830 json.loads( links2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800831 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
832 onpass="ONOS2 Links view is correct",
833 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800834
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800835 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800836 MNTopo,
837 json.loads( links3 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800838 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
839 onpass="ONOS2 Links view is correct",
840 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800841
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800842 # topoResult = switchesResults1 and switchesResults2
843 # and switchesResults3\
844 # and portsResults1 and portsResults2 and portsResults3\
845 # and linksResults1 and linksResults2 and linksResults3
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800846
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800847 topoResult = switchesResults1 and switchesResults2\
848 and switchesResults3 and linksResults1 and\
849 linksResults2 and linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800850
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800851 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800852 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800853 actual=topoResult and LinkUp and LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800854 onpass="Topology Check Test successful",
855 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800856
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800857 def CASE8( self ):
858 """
shahshreyaeac353b2014-11-18 17:19:20 -0800859 Intent removal
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800860 """
861 main.log.report(
shahshreyab512cd02015-01-27 17:01:47 -0800862 "This testcase removes any previously added intents" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800863 main.log.report( "__________________________________" )
864 main.log.info( "Removing any previously installed intents" )
865 main.case( "Removing intents" )
866 main.step( "Obtain the intent id's" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800867 intentResult = main.ONOScli1.intents( jsonFormat=False )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800868
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800869 intentLinewise = intentResult.split( "\n" )
shahshreyaa9d79f22014-11-18 15:41:29 -0800870 intentList = []
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800871 for line in intentLinewise:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800872 if line.startswith( "id=" ):
873 intentList.append( line )
shahshreyaa9d79f22014-11-18 15:41:29 -0800874
875 intentids = []
876 for line in intentList:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800877 intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
shahshreya4e13a062014-11-11 16:46:18 -0800878 for id in intentids:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800879 main.log.info( "id = " + id )
shahshreyaa9d79f22014-11-18 15:41:29 -0800880
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800881 main.step(
882 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -0800883 for id in intentids:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800884 main.ONOScli1.removeIntent( intentId=id )
shahshreyaa9d79f22014-11-18 15:41:29 -0800885
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800886 intentResult = main.ONOScli1.intents( jsonFormat=False )
887 main.log.info( "intent_result = " + intentResult )
888 case8Result = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800889
shahshreyaeac353b2014-11-18 17:19:20 -0800890 i = 8
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800891 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800892 while i < 18:
893 main.log.info(
894 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
895 ping = main.Mininet1.pingHost(
896 src="h" + str( i ), target="h" + str( i + 10 ) )
897 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -0800898 i = 19
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800899 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800900 elif ping == main.FALSE:
901 i += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800902 PingResult = main.FALSE
shahshreyaeac353b2014-11-18 17:19:20 -0800903 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800904 main.log.info( "Unknown error" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800905 PingResult = main.ERROR
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800906
907 # Note: If the ping result failed, that means the intents have been
908 # withdrawn correctly.
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800909 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800910 main.log.report( "Host intents have not been withdrawn correctly" )
911 # main.cleanup()
912 # main.exit()
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800913 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800914 main.log.report( "Host intents have been withdrawn correctly" )
shahshreyaeac353b2014-11-18 17:19:20 -0800915
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800916 case8Result = case8Result and PingResult
shahshreyaeac353b2014-11-18 17:19:20 -0800917
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800918 if case8Result == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800919 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800920 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800921 main.log.report( "Intent removal failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800922
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800923 utilities.assertEquals( expect=main.FALSE, actual=case8Result,
924 onpass="Intent removal test failed",
925 onfail="Intent removal test successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800926
927 def CASE9( self ):
928 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800929 This test case adds point intents. Make sure you run test case 8
930 which is host intent removal before executing this test case.
931 Else the host intent's flows will persist on switches and the pings
932 would work even if there is some issue with the point intent's flows
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800933 """
934 main.log.report(
935 "This testcase adds point intents and then does pingall" )
936 main.log.report( "__________________________________" )
937 main.log.info( "Adding point intents" )
938 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800939 "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20," +
940 "h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800941 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800942 "Add point-to-point intents for mininet hosts" +
943 " h8 and h18 or ONOS hosts h8 and h12" )
944 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800945 "of:0000000000003008/1",
946 "of:0000000000006018/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800947 if ptpIntentResult == main.TRUE:
948 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800949 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800950 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800951
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800952 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800953 "of:0000000000006018/1",
954 "of:0000000000003008/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800955 if ptpIntentResult == main.TRUE:
956 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800957 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800958 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800959
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800960 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800961 "Add point-to-point intents for mininet hosts" +
962 " h9 and h19 or ONOS hosts h9 and h13" )
963 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800964 "of:0000000000003009/1",
965 "of:0000000000006019/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800966 if ptpIntentResult == main.TRUE:
967 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800968 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800969 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800970
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800971 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800972 "of:0000000000006019/1",
973 "of:0000000000003009/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800974 if ptpIntentResult == main.TRUE:
975 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800976 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800977 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800978
979 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800980 "Add point-to-point intents for mininet" +
981 " hosts h10 and h20 or ONOS hosts hA and h14" )
982 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800983 "of:0000000000003010/1",
984 "of:0000000000006020/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800985 if ptpIntentResult == main.TRUE:
986 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800987 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800988 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800989
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800990 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800991 "of:0000000000006020/1",
992 "of:0000000000003010/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800993 if ptpIntentResult == main.TRUE:
994 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800995 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800996 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800997
998 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800999 "Add point-to-point intents for mininet" +
1000 " hosts h11 and h21 or ONOS hosts hB and h15" )
1001 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001002 "of:0000000000003011/1",
1003 "of:0000000000006021/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001004 if ptpIntentResult == main.TRUE:
1005 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001006 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001007 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001008
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001009 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001010 "of:0000000000006021/1",
1011 "of:0000000000003011/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001012 if ptpIntentResult == main.TRUE:
1013 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001014 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001015 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001016
1017 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001018 "Add point-to-point intents for mininet" +
1019 " hosts h12 and h22 or ONOS hosts hC and h16" )
1020 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001021 "of:0000000000003012/1",
1022 "of:0000000000006022/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001023 if ptpIntentResult == main.TRUE:
1024 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001025 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001026 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001027
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001028 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001029 "of:0000000000006022/1",
1030 "of:0000000000003012/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001031 if ptpIntentResult == main.TRUE:
1032 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001033 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001034 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001035
1036 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001037 "Add point-to-point intents for mininet " +
1038 "hosts h13 and h23 or ONOS hosts hD and h17" )
1039 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001040 "of:0000000000003013/1",
1041 "of:0000000000006023/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001042 if ptpIntentResult == main.TRUE:
1043 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001044 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001045 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001046
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001047 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001048 "of:0000000000006023/1",
1049 "of:0000000000003013/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001050 if ptpIntentResult == main.TRUE:
1051 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001052 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001053 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001054
1055 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001056 "Add point-to-point intents for mininet hosts" +
1057 " h14 and h24 or ONOS hosts hE and h18" )
1058 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001059 "of:0000000000003014/1",
1060 "of:0000000000006024/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001061 if ptpIntentResult == main.TRUE:
1062 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001063 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001064 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001065
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001066 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001067 "of:0000000000006024/1",
1068 "of:0000000000003014/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001069 if ptpIntentResult == main.TRUE:
1070 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001071 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001072 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001073
1074 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001075 "Add point-to-point intents for mininet hosts" +
1076 " h15 and h25 or ONOS hosts hF and h19" )
1077 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001078 "of:0000000000003015/1",
1079 "of:0000000000006025/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001080 if ptpIntentResult == main.TRUE:
1081 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001082 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001083 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001084
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001085 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001086 "of:0000000000006025/1",
1087 "of:0000000000003015/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001088 if ptpIntentResult == main.TRUE:
1089 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001090 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001091 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001092
1093 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001094 "Add point-to-point intents for mininet hosts" +
1095 " h16 and h26 or ONOS hosts h10 and h1A" )
1096 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001097 "of:0000000000003016/1",
1098 "of:0000000000006026/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001099 if ptpIntentResult == main.TRUE:
1100 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001101 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001102 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001103
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001104 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001105 "of:0000000000006026/1",
1106 "of:0000000000003016/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001107 if ptpIntentResult == main.TRUE:
1108 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001109 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001110 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001111
1112 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001113 "Add point-to-point intents for mininet hosts h17" +
1114 " and h27 or ONOS hosts h11 and h1B" )
1115 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001116 "of:0000000000003017/1",
1117 "of:0000000000006027/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001118 if ptpIntentResult == main.TRUE:
1119 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001120 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001121 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001122
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001123 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001124 "of:0000000000006027/1",
1125 "of:0000000000003017/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001126 if ptpIntentResult == main.TRUE:
1127 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001128 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001129 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001130
1131 print(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001132 "_______________________________________________________" +
1133 "________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001134
1135 flowHandle = main.ONOScli1.flows()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001136 # print "flowHandle = ", flowHandle
1137 main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001138
1139 count = 1
1140 i = 8
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001141 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001142 while i < 18:
1143 main.log.info(
1144 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1145 ping = main.Mininet1.pingHost(
1146 src="h" + str( i ), target="h" + str( i + 10 ) )
1147 if ping == main.FALSE and count < 5:
1148 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001149 # i = 8
1150 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001151 main.log.report( "Ping between h" +
1152 str( i ) +
1153 " and h" +
1154 str( i +
1155 10 ) +
1156 " failed. Making attempt number " +
1157 str( count ) +
1158 " in 2 seconds" )
1159 time.sleep( 2 )
1160 elif ping == main.FALSE:
1161 main.log.report( "All ping attempts between h" +
1162 str( i ) +
1163 " and h" +
1164 str( i +
1165 10 ) +
1166 "have failed" )
1167 i = 19
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001168 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001169 elif ping == main.TRUE:
1170 main.log.info( "Ping test between h" +
1171 str( i ) +
1172 " and h" +
1173 str( i +
1174 10 ) +
1175 "passed!" )
1176 i += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001177 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001178 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001179 main.log.info( "Unknown error" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001180 PingResult = main.ERROR
1181 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001182 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001183 "Ping all test after Point intents" +
1184 " addition failed. Cleaning up" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001185 # main.cleanup()
1186 # main.exit()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001187 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001188 main.log.report(
1189 "Ping all test after Point intents addition successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001190
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001191 case8Result = PingResult
1192 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001193 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001194 actual=case8Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001195 onpass="Ping all test after Point intents addition successful",
1196 onfail="Ping all test after Point intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001197
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001198 def CASE31( self ):
1199 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001200 This test case adds point intent related to
1201 SDN-IP matching on ICMP ( ethertype=IPV4, ipProto=1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001202 """
shahshreyaa9d79f22014-11-18 15:41:29 -08001203 import json
1204
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001205 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001206 "This test case adds point intent " +
1207 "related to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001208 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001209 "Adding bidirectional point intent related" +
1210 " to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001211 main.step( "Adding bidirectional point intent" )
1212 # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1213 # --ethType=IPV4 --ipProto=1 of:0000000000003008/1
1214 # of:0000000000006018/1
1215
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001216 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001217 for i in range( 8, 11 ):
1218 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001219 "Adding point intent between h" + str( i ) +
1220 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001221 host1 = "00:00:00:00:00:" + \
1222 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1223 host2 = "00:00:00:00:00:" + \
1224 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001225 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1226 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1227 for host in hostsJson:
1228 if host[ 'id' ] == host1Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001229 ip1 = host[ 'ips' ][ 0 ]
1230 ip1 = str( ip1 + "/32" )
1231 device1 = host[ 'location' ][ 'device' ]
1232 device1 = str( device1 + "/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001233 elif host[ 'id' ] == host2Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001234 ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
1235 device2 = host[ 'location' ][ "device" ]
1236 device2 = str( device2 + "/1" )
1237
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001238 pIntentResult1 = main.ONOScli1.addPointIntent(
1239 ingressDevice=device1,
1240 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001241 ipSrc=ip1,
1242 ipDst=ip2,
1243 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1244 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1245
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001246 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1247 main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001248
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001249 pIntentResult2 = main.ONOScli1.addPointIntent(
1250 ingressDevice=device2,
1251 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001252 ipSrc=ip2,
1253 ipDst=ip1,
1254 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1255 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1256
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001257 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1258 main.log.info( getIntentResult )
1259 if ( pIntentResult1 and pIntentResult2 ) == main.TRUE:
1260 # getIntentResult = main.ONOScli1.intents()
1261 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001262 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001263 "Point intent related to SDN-IP matching" +
1264 " on ICMP install successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001265
1266 time.sleep( 15 )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001267 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1268 main.log.info( "intents = " + getIntentResult )
1269 getFlowsResult = main.ONOScli1.flows()
1270 main.log.info( "flows = " + getFlowsResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001271
shahshreyae6c7cf42014-11-26 16:39:01 -08001272 count = 1
1273 i = 8
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001274 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001275 while i < 11:
1276 main.log.info(
1277 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1278 ping = main.Mininet1.pingHost(
1279 src="h" + str( i ), target="h" + str( i + 10 ) )
1280 if ping == main.FALSE and count < 3:
1281 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001282 # i = 8
1283 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001284 main.log.report( "Ping between h" +
1285 str( i ) +
1286 " and h" +
1287 str( i +
1288 10 ) +
1289 " failed. Making attempt number " +
1290 str( count ) +
1291 " in 2 seconds" )
1292 time.sleep( 2 )
1293 elif ping == main.FALSE:
1294 main.log.report( "All ping attempts between h" +
1295 str( i ) +
1296 " and h" +
1297 str( i +
1298 10 ) +
1299 "have failed" )
1300 i = 19
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001301 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001302 elif ping == main.TRUE:
1303 main.log.info( "Ping test between h" +
1304 str( i ) +
1305 " and h" +
1306 str( i +
1307 10 ) +
1308 "passed!" )
1309 i += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001310 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -08001311 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001312 main.log.info( "Unknown error" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001313 PingResult = main.ERROR
1314 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001315 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001316 "Ping test after Point intents related to" +
1317 " SDN-IP matching on ICMP failed." )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001318 # main.cleanup()
1319 # main.exit()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001320 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001321 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001322 "Ping all test after Point intents related to" +
1323 " SDN-IP matching on ICMP successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001324
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001325 case31Result = PingResult and pIntentResult1 and pIntentResult2
1326 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001327 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001328 actual=case31Result,
1329 onpass="Point intent related to SDN-IP " +
1330 "matching on ICMP and ping test successful",
1331 onfail="Point intent related to SDN-IP" +
1332 " matching on ICMP and ping test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001333
1334 def CASE32( self ):
1335 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001336 This test case adds point intent related to SDN-IP matching on TCP
1337 ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 )
1338 Note: Although BGP port is 179, we are using 5001 because iperf
1339 is used for verifying and iperf's default port is 5001
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001340 """
shahshreyae6c7cf42014-11-26 16:39:01 -08001341 import json
1342
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001343 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001344 "This test case adds point intent" +
1345 " related to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001346 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001347 "Adding bidirectional point intent related" +
1348 " to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001349 main.step( "Adding bidirectional point intent" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001350 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001351 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1352 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1
1353 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001354
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001355 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1356 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1
1357 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001358
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001359 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1360 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1
1361 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001362
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001363 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1364 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1
1365 of:0000000000003008/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001366
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001367 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001368 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001369 for i in range( 8, 9 ):
1370 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001371 "Adding point intent between h" + str( i ) +
1372 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001373 host1 = "00:00:00:00:00:" + \
1374 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1375 host2 = "00:00:00:00:00:" + \
1376 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001377 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1378 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1379 for host in hostsJson:
1380 if host[ 'id' ] == host1Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001381 ip1 = host[ 'ips' ][ 0 ]
1382 ip1 = str( ip1 + "/32" )
1383 device1 = host[ 'location' ][ 'device' ]
1384 device1 = str( device1 + "/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001385 elif host[ 'id' ] == host2Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001386 ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
1387 device2 = host[ 'location' ][ "device" ]
1388 device2 = str( device2 + "/1" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001389
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001390 pIntentResult1 = main.ONOScli1.addPointIntent(
1391 ingressDevice=device1,
1392 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001393 ipSrc=ip1,
1394 ipDst=ip2,
1395 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1396 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1397 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001398 pIntentResult2 = main.ONOScli1.addPointIntent(
1399 ingressDevice=device2,
1400 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001401 ipSrc=ip2,
1402 ipDst=ip1,
1403 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1404 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1405 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
1406
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001407 pIntentResult3 = main.ONOScli1.addPointIntent(
1408 ingressDevice=device1,
1409 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001410 ipSrc=ip1,
1411 ipDst=ip2,
1412 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1413 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1414 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001415 pIntentResult4 = main.ONOScli1.addPointIntent(
1416 ingressDevice=device2,
1417 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001418 ipSrc=ip2,
1419 ipDst=ip1,
1420 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1421 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1422 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
shahshreyae6c7cf42014-11-26 16:39:01 -08001423
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001424 pIntentResult = pIntentResult1 and pIntentResult2 and\
1425 pIntentResult3 and pIntentResult4
1426 if pIntentResult == main.TRUE:
1427 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1428 main.log.info( getIntentResult )
shahshreyab512cd02015-01-27 17:01:47 -08001429 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001430 "Point intent related to SDN-IP matching" +
1431 " on TCP install successful" )
shahshreyab512cd02015-01-27 17:01:47 -08001432 else:
1433 main.log.report(
1434 "Point intent related to SDN-IP matching" +
1435 " on TCP install failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001436
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001437 iperfResult = main.Mininet1.iperf( 'h8', 'h18' )
1438 if iperfResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001439 main.log.report( "iperf test successful" )
1440 else:
1441 main.log.report( "iperf test failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001442
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001443 case32Result = pIntentResult and iperfResult
1444 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001445 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001446 actual=case32Result,
1447 onpass="Ping all test after Point intents addition related " +
1448 "to SDN-IP on TCP match successful",
1449 onfail="Ping all test after Point intents addition related " +
1450 "to SDN-IP on TCP match failed" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001451
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001452 def CASE33( self ):
1453 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001454 This test case adds multipoint to singlepoint intent related to
1455 SDN-IP matching on destination ip and the action is to rewrite
1456 the mac address
1457 Here the mac address to be rewritten is the mac address of the
1458 egress device
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001459 """
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001460 import json
1461 import time
1462
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001463 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001464 "This test case adds multipoint to singlepoint intent related to" +
1465 " SDN-IP matching on destination ip and " +
1466 "rewrite mac address action" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001467 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001468 "Adding multipoint to singlepoint intent related to SDN-IP" +
1469 " matching on destination ip" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001470 main.step( "Adding bidirectional multipoint to singlepoint intent" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001471 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001472 add-multi-to-single-intent --ipDst=10.0.3.0/24
1473 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1
1474 of:0000000000006018/1
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001475
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001476 add-multi-to-single-intent --ipDst=10.0.1.0/24
1477 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1
1478 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001479 """
1480 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001481 "Installing multipoint to single point " +
1482 "intent with rewrite mac address" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001483 main.step( "Uninstalling proxy arp app" )
1484 # Unistall onos-app-proxyarp app to disable reactive forwarding
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001485 appUninstallResult1 = main.ONOScli1.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001486 "onos-app-proxyarp" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001487 appUninstallResult2 = main.ONOScli2.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001488 "onos-app-proxyarp" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001489 appUninstallResult3 = main.ONOScli3.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001490 "onos-app-proxyarp" )
1491 main.log.info( "onos-app-proxyarp uninstalled" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001492
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001493 main.step( "Changing ipaddress of hosts h8,h9 and h18" )
1494 main.Mininet1.changeIP(
1495 host='h8',
1496 intf='h8-eth0',
1497 newIP='10.0.1.1',
1498 newNetmask='255.255.255.0' )
1499 main.Mininet1.changeIP(
1500 host='h9',
1501 intf='h9-eth0',
1502 newIP='10.0.2.1',
1503 newNetmask='255.255.255.0' )
1504 main.Mininet1.changeIP(
1505 host='h10',
1506 intf='h10-eth0',
1507 newIP='10.0.3.1',
1508 newNetmask='255.255.255.0' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001509
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001510 main.step( "Changing default gateway of hosts h8,h9 and h18" )
1511 main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' )
1512 main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' )
1513 main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001514
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001515 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001516 "Assigning random mac address to the default gateways " +
1517 "since proxyarp app is uninstalled" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001518 main.Mininet1.addStaticMACAddress(
1519 host='h8',
1520 GW='10.0.1.254',
1521 macaddr='00:00:00:00:11:11' )
1522 main.Mininet1.addStaticMACAddress(
1523 host='h9',
1524 GW='10.0.2.254',
1525 macaddr='00:00:00:00:22:22' )
1526 main.Mininet1.addStaticMACAddress(
1527 host='h10',
1528 GW='10.0.3.254',
1529 macaddr='00:00:00:00:33:33' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001530
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001531 main.step( "Verify static gateway and MAC address assignment" )
1532 main.Mininet1.verifyStaticGWandMAC( host='h8' )
1533 main.Mininet1.verifyStaticGWandMAC( host='h9' )
1534 main.Mininet1.verifyStaticGWandMAC( host='h10' )
1535
shahshreyab471a3e2015-03-19 17:07:13 -07001536 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ]
1537 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ]
1538 ingressDeviceList = []
1539 ingressDeviceList.append( ingressDevice1 )
1540 ingressDeviceList.append( ingressDevice2 )
1541
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001542 main.step( "Adding multipoint to singlepoint intent" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001543 pIntentResult1 = main.ONOScli1.addMultipointToSinglepointIntent(
shahshreyab471a3e2015-03-19 17:07:13 -07001544 ingressDeviceList,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001545 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001546 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
1547 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
1548
shahshreyab471a3e2015-03-19 17:07:13 -07001549 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ]
1550 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ]
1551 ingressDeviceList = [ingressDevice1, ingressDevice2]
1552
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001553 pIntentResult2 = main.ONOScli1.addMultipointToSinglepointIntent(
shahshreyab471a3e2015-03-19 17:07:13 -07001554 ingressDeviceList,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001555 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001556 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
1557 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
1558
shahshreyab471a3e2015-03-19 17:07:13 -07001559 pIntentResult = pIntentResult1 and pIntentResult2
1560 if pIntentResult == main.FALSE:
1561 main.log.info(
1562 "Multi point to single point intent " +
1563 "installation failed" )
1564 else:
1565 pIntentResult = main.TRUE
1566 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1567 main.log.info( "intents = " + getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001568
shahshreyab471a3e2015-03-19 17:07:13 -07001569 time.sleep( 10 )
1570 getFlowsResult = main.ONOScli1.flows( jsonFormat=False )
1571 main.log.info( "flows = " + getFlowsResult )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001572
shahshreyab471a3e2015-03-19 17:07:13 -07001573 count = 1
1574 i = 8
1575 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001576
shahshreyab471a3e2015-03-19 17:07:13 -07001577 main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
1578 ping = main.Mininet1.pingHost(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001579 src="h" + str( i ), target="h" + str( i + 2 ) )
shahshreyab471a3e2015-03-19 17:07:13 -07001580 if ping == main.FALSE and count < 3:
1581 count += 1
1582 PingResult = main.FALSE
1583 main.log.report( "Ping between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001584 str( i ) +
1585 " and h" +
1586 str( i +
1587 2 ) +
1588 " failed. Making attempt number " +
1589 str( count ) +
1590 " in 2 seconds" )
shahshreyab471a3e2015-03-19 17:07:13 -07001591 time.sleep( 2 )
1592 elif ping == main.FALSE:
1593 main.log.report( "All ping attempts between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001594 str( i ) +
1595 " and h" +
1596 str( i +
1597 10 ) +
1598 "have failed" )
shahshreyab471a3e2015-03-19 17:07:13 -07001599 PingResult = main.FALSE
1600 elif ping == main.TRUE:
1601 main.log.info( "Ping test between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001602 str( i ) +
1603 " and h" +
1604 str( i +
1605 2 ) +
1606 "passed!" )
shahshreyab471a3e2015-03-19 17:07:13 -07001607 PingResult = main.TRUE
1608 else:
1609 main.log.info( "Unknown error" )
1610 PingResult = main.ERROR
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001611
shahshreyab471a3e2015-03-19 17:07:13 -07001612 if PingResult == main.FALSE:
1613 main.log.report( "Ping test failed." )
1614 # main.cleanup()
1615 # main.exit()
1616 if PingResult == main.TRUE:
1617 main.log.report( "Ping all successful" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001618
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001619 if pIntentResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001620 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001621 "Multi point intent with rewrite mac " +
shahshreyab471a3e2015-03-19 17:07:13 -07001622 "address installation and ping successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001623
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001624 case33Result = pIntentResult and PingResult
1625 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001626 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001627 actual=case33Result,
1628 onpass="Ping all test after multipoint to single point" +
1629 " intent addition with rewrite mac address successful",
1630 onfail="Ping all test after multipoint to single point intent" +
1631 " addition with rewrite mac address failed" )