blob: cbf27a47904fa83f6997dc80eb8bddd8140c744b [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
14
shahshreya4e13a062014-11-11 16:46:18 -080015class MultiProd13:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080016
17 def __init__( self ):
shahshreya4e13a062014-11-11 16:46:18 -080018 self.default = ''
19
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080020 def CASE1( self, main ):
21 """
shahshreya4e13a062014-11-11 16:46:18 -080022 Startup sequence:
shahshreyae6c7cf42014-11-26 16:39:01 -080023 cell <name>
24 onos-verify-cell
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080025 onos-remove-raft-logs
shahshreya4e13a062014-11-11 16:46:18 -080026 git pull
27 mvn clean install
28 onos-package
shahshreya4e13a062014-11-11 16:46:18 -080029 onos-install -f
30 onos-wait-for-start
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080031 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -080032 cellName = main.params[ 'ENV' ][ 'cellName' ]
33 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
34 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
35 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
36 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
37 ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
38 ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080039
40 main.case( "Setting up test environment" )
41 main.log.report(
42 "This testcase is testing setting up test environment" )
43 main.log.report( "__________________________________" )
44
45 main.step( "Applying cell variable to environment" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080046 cellResult1 = main.ONOSbench.setCell( cellName )
47 # cellResult2 = main.ONOScli1.setCell( cellName )
48 # cellResult3 = main.ONOScli2.setCell( cellName )
49 # cellResult4 = main.ONOScli3.setCell( cellName )
50 verifyResult = main.ONOSbench.verifyCell()
51 cellResult = cellResult1
shahshreyae6c7cf42014-11-26 16:39:01 -080052
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080053 main.step( "Removing raft logs before a clen installation of ONOS" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080054 removeLogResult = main.ONOSbench.onosRemoveRaftLogs()
shahshreyae6c7cf42014-11-26 16:39:01 -080055
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080056 main.step( "Git checkout and pull master and get version" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080057 main.ONOSbench.gitCheckout( "master" )
58 gitPullResult = main.ONOSbench.gitPull()
59 print "git_pull_result = ", gitPullResult
60 versionResult = main.ONOSbench.getVersion( report=True )
shahshreya4e13a062014-11-11 16:46:18 -080061
kelvin-onlabcf33bda2015-01-23 16:54:17 -080062 if gitPullResult == 1:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080063 main.step( "Using mvn clean & install" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080064 cleanInstallResult = main.ONOSbench.cleanInstall()
65 # cleanInstallResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -080066
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080067 main.step( "Creating ONOS package" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080068 packageResult = main.ONOSbench.onosPackage()
shahshreya4e13a062014-11-11 16:46:18 -080069
kelvin-onlabcf33bda2015-01-23 16:54:17 -080070 # main.step( "Creating a cell" )
71 # cellCreateResult = main.ONOSbench.createCellFile( **************
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080072 # )
shahshreya4e13a062014-11-11 16:46:18 -080073
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080074 main.step( "Installing ONOS package" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080075 onos1InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080076 options="-f",
kelvin-onlabcf33bda2015-01-23 16:54:17 -080077 node=ONOS1Ip )
78 onos2InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080079 options="-f",
kelvin-onlabcf33bda2015-01-23 16:54:17 -080080 node=ONOS2Ip )
81 onos3InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080082 options="-f",
kelvin-onlabcf33bda2015-01-23 16:54:17 -080083 node=ONOS3Ip )
84 onosInstallResult = onos1InstallResult and onos2InstallResult and\
85 onos3InstallResult
86 if onosInstallResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080087 main.log.report( "Installing ONOS package successful" )
shahshreya4e13a062014-11-11 16:46:18 -080088 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080089 main.log.report( "Installing ONOS package failed" )
90
kelvin-onlabcf33bda2015-01-23 16:54:17 -080091 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
92 onos2Isup = main.ONOSbench.isup( ONOS2Ip )
93 onos3Isup = main.ONOSbench.isup( ONOS3Ip )
94 onosIsup = onos1Isup and onos2Isup and onos3Isup
95 if onosIsup == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080096 main.log.report( "ONOS instances are up and ready" )
shahshreya4e13a062014-11-11 16:46:18 -080097 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080098 main.log.report( "ONOS instances may not be up" )
shahshreya4e13a062014-11-11 16:46:18 -080099
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800100 main.step( "Starting ONOS service" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800101 startResult = main.TRUE
102 # startResult = main.ONOSbench.onosStart( ONOS1Ip )
103 startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip )
104 startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip )
105 startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800106 print startcli1
107 print startcli2
108 print startcli3
shahshreya4e13a062014-11-11 16:46:18 -0800109
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800110 case1Result = ( packageResult and
111 cellResult and verifyResult and onosInstallResult and
112 onosIsup and startResult )
113 utilities.assertEquals( expect=main.TRUE, actual=case1Result,
114 onpass="Test startup successful",
115 onfail="Test startup NOT successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800116
117 def CASE11( self, main ):
118 """
shahshreya4e13a062014-11-11 16:46:18 -0800119 Cleanup sequence:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800120 onos-service <nodeIp> stop
shahshreya4e13a062014-11-11 16:46:18 -0800121 onos-uninstall
122
123 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800124
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800125 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800126 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
127 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
128 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
shahshreya4e13a062014-11-11 16:46:18 -0800129
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800130 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800131
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800132 main.step( "Testing ONOS kill function" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800133 killResult1 = main.ONOSbench.onosKill( ONOS1Ip )
134 killResult2 = main.ONOSbench.onosKill( ONOS2Ip )
135 killResult3 = main.ONOSbench.onosKill( ONOS3Ip )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800136
137 main.step( "Stopping ONOS service" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800138 stopResult1 = main.ONOSbench.onosStop( ONOS1Ip )
139 stopResult2 = main.ONOSbench.onosStop( ONOS2Ip )
140 stopResult3 = main.ONOSbench.onosStop( ONOS3Ip )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800141
142 main.step( "Uninstalling ONOS service" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800143 uninstallResult = main.ONOSbench.onosUninstall()
shahshreya4e13a062014-11-11 16:46:18 -0800144
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800145 def CASE3( self, main ):
146 """
shahshreya4e13a062014-11-11 16:46:18 -0800147 Test 'onos' command and its functionality in driver
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800148 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800149 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
150 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
151 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
shahshreya4e13a062014-11-11 16:46:18 -0800152
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800153 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800154
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800155 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800156 cmdstr1 = "system:name"
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800157 cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
158 main.log.info( "onos command returned: " + cmdResult1 )
159 cmdResult2 = main.ONOSbench.onosCli( ONOS2Ip, cmdstr1 )
160 main.log.info( "onos command returned: " + cmdResult2 )
161 cmdResult3 = main.ONOSbench.onosCli( ONOS3Ip, cmdstr1 )
162 main.log.info( "onos command returned: " + cmdResult3 )
shahshreya4e13a062014-11-11 16:46:18 -0800163
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800164 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800165 cmdstr2 = "onos:topology"
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800166 cmdResult4 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
167 main.log.info( "onos command returned: " + cmdResult4 )
168 cmdResult5 = main.ONOSbench.onosCli( ONOS2Ip, cmdstr2 )
169 main.log.info( "onos command returned: " + cmdResult5 )
170 cmdResult6 = main.ONOSbench.onosCli( ONOS6Ip, cmdstr2 )
171 main.log.info( "onos command returned: " + cmdResult6 )
shahshreya4e13a062014-11-11 16:46:18 -0800172
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800173 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800174 import re
175 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800176 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
177 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
178 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
179 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
180 ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
181 ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800182
183 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800184 "This testcase is testing the assignment of all the switches" +
185 " to all controllers and discovering the hosts in reactive mode" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800186 main.log.report( "__________________________________" )
187 main.case( "Pingall Test(No intents are added)" )
188 main.step( "Assigning switches to controllers" )
189 for i in range( 1, 29 ): # 1 to ( num of switches +1 )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800190 main.Mininet1.assignSwController(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800191 sw=str( i ),
192 count=3,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800193 ip1=ONOS1Ip,
194 port1=ONOS1Port,
195 ip2=ONOS2Ip,
196 port2=ONOS2Port,
197 ip3=ONOS3Ip,
198 port3=ONOS3Port )
shahshreya4e13a062014-11-11 16:46:18 -0800199
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800200 switchMastership = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800201 for i in range( 1, 29 ):
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800202 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800203 print( "Response is " + str( response ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800204 if re.search( "tcp:" + ONOS1Ip, response ):
205 switchMastership = switchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800206 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800207 switchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800208
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800209 if switchMastership == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800210 main.log.report( "Controller assignment successfull" )
shahshreya4e13a062014-11-11 16:46:18 -0800211 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800212 main.log.report( "Controller assignment failed" )
213 # REACTIVE FWD test
214 main.step( "Pingall" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800215 pingResult = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800216 time1 = time.time()
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800217 pingResult = main.Mininet1.pingall()
shahshreya4e13a062014-11-11 16:46:18 -0800218 time2 = time.time()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800219 print "Time for pingall: %2f seconds" % ( time2 - time1 )
220
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800221 case4Result = switchMastership and pingResult
222 if pingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800223 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800224 "Pingall Test in reactive mode to" +
225 " discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800226 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800227 main.log.report(
228 "Pingall Test in reactive mode to discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800229
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800230 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800231 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800232 actual=case4Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800233 onpass="Controller assignment and Pingall Test successful",
234 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800235
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800236 def CASE5( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800237 import json
238 from subprocess import Popen, PIPE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800239 # assumes that sts is already in you PYTHONPATH
240 from sts.topology.teston_topology import TestONTopology
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800241 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
242 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
243 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800244
245 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800246 "This testcase is testing if all ONOS nodes are in topologyi" +
247 " sync with mininet and its peer ONOS nodes" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800248 main.log.report( "__________________________________" )
249 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800250 "Testing Mininet topology with the" +
251 " topology of multi instances ONOS" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800252 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800253 devices1 = main.ONOScli1.devices()
254 devices2 = main.ONOScli2.devices()
255 devices3 = main.ONOScli3.devices()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800256 # print "devices1 = ", devices1
257 # print "devices2 = ", devices2
258 # print "devices3 = ", devices3
shahshreya4e13a062014-11-11 16:46:18 -0800259 hosts1 = main.ONOScli1.hosts()
260 hosts2 = main.ONOScli2.hosts()
261 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800262 # print "hosts1 = ", hosts1
263 # print "hosts2 = ", hosts2
264 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800265 ports1 = main.ONOScli1.ports()
266 ports2 = main.ONOScli2.ports()
267 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800268 # print "ports1 = ", ports1
269 # print "ports2 = ", ports2
270 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800271 links1 = main.ONOScli1.links()
272 links2 = main.ONOScli2.links()
273 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800274 # print "links1 = ", links1
275 # print "links2 = ", links2
276 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800277
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800278 print "**************"
279
280 main.step( "Start continuous pings" )
281 main.Mininet2.pingLong(
282 src=main.params[ 'PING' ][ 'source1' ],
283 target=main.params[ 'PING' ][ 'target1' ],
284 pingTime=500 )
285 main.Mininet2.pingLong(
286 src=main.params[ 'PING' ][ 'source2' ],
287 target=main.params[ 'PING' ][ 'target2' ],
288 pingTime=500 )
289 main.Mininet2.pingLong(
290 src=main.params[ 'PING' ][ 'source3' ],
291 target=main.params[ 'PING' ][ 'target3' ],
292 pingTime=500 )
293 main.Mininet2.pingLong(
294 src=main.params[ 'PING' ][ 'source4' ],
295 target=main.params[ 'PING' ][ 'target4' ],
296 pingTime=500 )
297 main.Mininet2.pingLong(
298 src=main.params[ 'PING' ][ 'source5' ],
299 target=main.params[ 'PING' ][ 'target5' ],
300 pingTime=500 )
301 main.Mininet2.pingLong(
302 src=main.params[ 'PING' ][ 'source6' ],
303 target=main.params[ 'PING' ][ 'target6' ],
304 pingTime=500 )
305 main.Mininet2.pingLong(
306 src=main.params[ 'PING' ][ 'source7' ],
307 target=main.params[ 'PING' ][ 'target7' ],
308 pingTime=500 )
309 main.Mininet2.pingLong(
310 src=main.params[ 'PING' ][ 'source8' ],
311 target=main.params[ 'PING' ][ 'target8' ],
312 pingTime=500 )
313 main.Mininet2.pingLong(
314 src=main.params[ 'PING' ][ 'source9' ],
315 target=main.params[ 'PING' ][ 'target9' ],
316 pingTime=500 )
317 main.Mininet2.pingLong(
318 src=main.params[ 'PING' ][ 'source10' ],
319 target=main.params[ 'PING' ][ 'target10' ],
320 pingTime=500 )
321
322 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800323 global ctrls
324 ctrls = []
325 count = 1
326 while True:
327 temp = ()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800328 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
329 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
330 temp = temp + ( "ONOS" + str( count ), )
331 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
332 temp = temp + \
333 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
334 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800335 count = count + 1
336 else:
337 break
338 global MNTopo
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800339 Topo = TestONTopology(
340 main.Mininet1,
341 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800342 MNTopo = Topo
343
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800344 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800345 main.step( "Compare ONOS Topology to MN Topology" )
346
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800347 switchesResults1 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800348 MNTopo,
349 json.loads( devices1 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800350 print "switches_Result1 = ", switchesResults1
351 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
352 onpass="ONOS1 Switches view is correct",
353 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800354
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800355 switchesResults2 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800356 MNTopo,
357 json.loads( devices2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800358 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
359 onpass="ONOS2 Switches view is correct",
360 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800361
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800362 switchesResults3 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800363 MNTopo,
364 json.loads( devices3 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800365 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
366 onpass="ONOS3 Switches view is correct",
367 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800368
369 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800370 portsResults1 = main.Mininet1.comparePorts( MNTopo,
371 json.loads( ports1 ) )
372 utilities.assertEquals( expect=main.TRUE, actual=portsResults1,
shahshreya4e13a062014-11-11 16:46:18 -0800373 onpass="ONOS1 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800374 onfail="ONOS1 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800375
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800376 portsResults2 = main.Mininet1.comparePorts( MNTopo,
377 json.loads( ports2 ) )
378 utilities.assertEquals( expect=main.TRUE, actual=portsResults2,
shahshreya4e13a062014-11-11 16:46:18 -0800379 onpass="ONOS2 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800380 onfail="ONOS2 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800381
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800382 portsResults3 = main.Mininet1.comparePorts( MNTopo,
383 json.loads( ports3 ) )
384 utilities.assertEquals( expect=main.TRUE, actual=portsResults3,
shahshreya4e13a062014-11-11 16:46:18 -0800385 onpass="ONOS3 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800386 onfail="ONOS3 Ports view is incorrect" )
387 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800388 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800389 MNTopo,
390 json.loads( links1 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800391 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
392 onpass="ONOS1 Links view is correct",
393 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800394
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800395 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800396 MNTopo,
397 json.loads( links2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800398 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
399 onpass="ONOS2 Links view is correct",
400 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800401
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800402 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800403 MNTopo,
404 json.loads( links3 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800405 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
406 onpass="ONOS2 Links view is correct",
407 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800408
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800409 # topoResult = switchesResults1 and switchesResults2
410 # and switchesResults3\
411 # and portsResults1 and portsResults2 and portsResults3\
412 # and linksResults1 and linksResults2 and linksResults3
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800413
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800414 topoResult = switchesResults1 and switchesResults2 and\
415 switchesResults3 and linksResults1 and linksResults2 and\
416 linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800417
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800418 if topoResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800419 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800420 "Topology Check Test with mininet" +
421 "and ONOS instances successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800422 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800423 main.log.report(
424 "Topology Check Test with mininet and ONOS instances failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800425
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800426 utilities.assertEquals( expect=main.TRUE, actual=topoResult,
427 onpass="Topology Check Test successful",
428 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800429
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800430 def CASE10( self ):
431 main.log.report(
432 "This testcase uninstalls the reactive forwarding app" )
433 main.log.report( "__________________________________" )
434 main.case( "Uninstalling reactive forwarding app" )
435 # Unistall onos-app-fwd app to disable reactive forwarding
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800436 appUninstallResult1 = main.ONOScli1.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800437 "onos-app-fwd" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800438 appUninstallResult2 = main.ONOScli2.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800439 "onos-app-fwd" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800440 appUninstallResult3 = main.ONOScli3.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800441 "onos-app-fwd" )
442 main.log.info( "onos-app-fwd uninstalled" )
shahshreyaa9d79f22014-11-18 15:41:29 -0800443
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800444 # After reactive forwarding is disabled,
445 # the reactive flows on switches timeout in 10-15s
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800446 # So sleep for 15s
447 time.sleep( 15 )
shahshreyaa9d79f22014-11-18 15:41:29 -0800448
shahshreyae6c7cf42014-11-26 16:39:01 -0800449 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800450 main.log.info( hosts )
451
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800452 case10Result = appUninstallResult1 and\
453 appUninstallResult2 and appUninstallResult3
454 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800455 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800456 actual=case10Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800457 onpass="Reactive forwarding app uninstallation successful",
458 onfail="Reactive forwarding app uninstallation failed" )
shahshreyaa9d79f22014-11-18 15:41:29 -0800459
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800460 def CASE6( self ):
461 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800462 "This testcase is testing the addition of" +
463 " host intents and then doing pingall" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800464 main.log.report( "__________________________________" )
465 main.case( "Obtaining hostsfor adding host intents" )
466 main.step( "Get hosts" )
shahshreyaeac353b2014-11-18 17:19:20 -0800467 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800468 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800469
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800470 main.step( "Get all devices id" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800471 devicesIdList = main.ONOScli1.getAllDevicesId()
472 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -0800473
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800474 # ONOS displays the hosts in hex format
475 # unlike mininet which does in decimal format
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800476 # So take care while adding intents
shahshreya4e13a062014-11-11 16:46:18 -0800477
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800478 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800479 main.step( "Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,
480 h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
481 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:08/-1",
482 "00:00:00:00:00:12/-1" )
483 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:09/-1",
484 "00:00:00:00:00:13/-1" )
485 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0A/-1",
486 "00:00:00:00:00:14/-1" )
487 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0B/-1",
488 "00:00:00:00:00:15/-1" )
489 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0C/-1",
490 "00:00:00:00:00:16/-1" )
491 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0D/-1",
492 "00:00:00:00:00:17/-1" )
493 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0E/-1",
494 "00:00:00:00:00:18/-1" )
495 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0F/-1",
496 "00:00:00:00:00:19/-1" )
497 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:10/-1",
498 "00:00:00:00:00:1A/-1" )
499 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:11/-1",
500 "00:00:00:00:00:1B/-1" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800501 """
502 for i in range( 8, 18 ):
503 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800504 "Adding host intent between h" + str( i ) +
505 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800506 host1 = "00:00:00:00:00:" + \
507 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
508 host2 = "00:00:00:00:00:" + \
509 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
510 # NOTE: get host can return None
511 # TODO: handle this
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800512 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
513 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
514 tmpResult = main.ONOScli1.addHostIntent( host1Id, host2Id )
shahshreya4e13a062014-11-11 16:46:18 -0800515
516 flowHandle = main.ONOScli1.flows()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800517 # print "flowHandle = ", flowHandle
518 main.log.info( "flows:" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -0800519
520 count = 1
521 i = 8
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800522 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800523 while i < 18:
524 main.log.info(
525 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
526 ping = main.Mininet1.pingHost(
527 src="h" + str( i ), target="h" + str( i + 10 ) )
528 if ping == main.FALSE and count < 5:
529 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800530 # i = 8
531 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800532 main.log.report( "Ping between h" +
533 str( i ) +
534 " and h" +
535 str( i +
536 10 ) +
537 " failed. Making attempt number " +
538 str( count ) +
539 " in 2 seconds" )
540 time.sleep( 2 )
541 elif ping == main.FALSE:
542 main.log.report( "All ping attempts between h" +
543 str( i ) +
544 " and h" +
545 str( i +
546 10 ) +
547 "have failed" )
548 i = 19
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800549 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800550 elif ping == main.TRUE:
551 main.log.info( "Ping test between h" +
552 str( i ) +
553 " and h" +
554 str( i +
555 10 ) +
556 "passed!" )
557 i += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800558 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800559 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800560 main.log.info( "Unknown error" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800561 PingResult = main.ERROR
562 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800563 main.log.report(
564 "Host intents have not ben installed correctly. Cleaning up" )
565 # main.cleanup()
566 # main.exit()
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800567 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800568 main.log.report( "Host intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -0800569
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800570 case6Result = PingResult
571 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800572 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800573 actual=case6Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800574 onpass="Host intent addition and Pingall Test successful",
575 onfail="Host intent addition and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800576
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800577 def CASE7( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800578
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800579 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800580
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800581 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800582
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800583 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800584 "This testscase is killing a link to" +
585 " ensure that link discovery is consistent" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800586 main.log.report( "__________________________________" )
587 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800588 "Killing a link to Ensure that Link" +
589 " Discovery is Working Properly" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800590 main.step( "Start continuous pings" )
shahshreya4e13a062014-11-11 16:46:18 -0800591
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800592 main.Mininet2.pingLong(
593 src=main.params[ 'PING' ][ 'source1' ],
594 target=main.params[ 'PING' ][ 'target1' ],
595 pingTime=500 )
596 main.Mininet2.pingLong(
597 src=main.params[ 'PING' ][ 'source2' ],
598 target=main.params[ 'PING' ][ 'target2' ],
599 pingTime=500 )
600 main.Mininet2.pingLong(
601 src=main.params[ 'PING' ][ 'source3' ],
602 target=main.params[ 'PING' ][ 'target3' ],
603 pingTime=500 )
604 main.Mininet2.pingLong(
605 src=main.params[ 'PING' ][ 'source4' ],
606 target=main.params[ 'PING' ][ 'target4' ],
607 pingTime=500 )
608 main.Mininet2.pingLong(
609 src=main.params[ 'PING' ][ 'source5' ],
610 target=main.params[ 'PING' ][ 'target5' ],
611 pingTime=500 )
612 main.Mininet2.pingLong(
613 src=main.params[ 'PING' ][ 'source6' ],
614 target=main.params[ 'PING' ][ 'target6' ],
615 pingTime=500 )
616 main.Mininet2.pingLong(
617 src=main.params[ 'PING' ][ 'source7' ],
618 target=main.params[ 'PING' ][ 'target7' ],
619 pingTime=500 )
620 main.Mininet2.pingLong(
621 src=main.params[ 'PING' ][ 'source8' ],
622 target=main.params[ 'PING' ][ 'target8' ],
623 pingTime=500 )
624 main.Mininet2.pingLong(
625 src=main.params[ 'PING' ][ 'source9' ],
626 target=main.params[ 'PING' ][ 'target9' ],
627 pingTime=500 )
628 main.Mininet2.pingLong(
629 src=main.params[ 'PING' ][ 'source10' ],
630 target=main.params[ 'PING' ][ 'target10' ],
631 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -0800632
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800633 main.step( "Determine the current number of switches and links" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800634 topologyOutput = main.ONOScli1.topology()
635 topologyResult = main.ONOSbench.getTopology( topologyOutput )
636 activeSwitches = topologyResult[ 'devices' ]
637 links = topologyResult[ 'links' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800638 print "activeSwitches = ", type( activeSwitches )
639 print "links = ", type( links )
640 main.log.info(
641 "Currently there are %s switches and %s links" %
642 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -0800643
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800644 main.step( "Kill Link between s3 and s28" )
645 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800646 time.sleep( linkSleep )
647 topologyOutput = main.ONOScli2.topology()
648 LinkDown = main.ONOSbench.checkStatus(
649 topologyOutput, activeSwitches, str(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800650 int( links ) - 2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800651 if LinkDown == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800652 main.log.report( "Link Down discovered properly" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800653 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800654 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800655 actual=LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800656 onpass="Link Down discovered properly",
657 onfail="Link down was not discovered in " +
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800658 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800659 " seconds" )
shahshreya4e13a062014-11-11 16:46:18 -0800660
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800661 main.step( "Bring link between s3 and s28 back up" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800662 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
663 time.sleep( linkSleep )
664 topologyOutput = main.ONOScli2.topology()
665 LinkUp = main.ONOSbench.checkStatus(
666 topologyOutput,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800667 activeSwitches,
668 str( links ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800669 if LinkUp == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800670 main.log.report( "Link up discovered properly" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800671 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800672 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800673 actual=LinkUp,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800674 onpass="Link up discovered properly",
675 onfail="Link up was not discovered in " +
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800676 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800677 " seconds" )
678
679 main.step( "Compare ONOS Topology to MN Topology" )
680 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800681 "Testing Mininet topology with the" +
682 " topology of multi instances ONOS" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800683 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800684 devices1 = main.ONOScli1.devices()
685 devices2 = main.ONOScli2.devices()
686 devices3 = main.ONOScli3.devices()
687 print "devices1 = ", devices1
688 print "devices2 = ", devices2
689 print "devices3 = ", devices3
690 hosts1 = main.ONOScli1.hosts()
691 hosts2 = main.ONOScli2.hosts()
692 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800693 # print "hosts1 = ", hosts1
694 # print "hosts2 = ", hosts2
695 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800696 ports1 = main.ONOScli1.ports()
697 ports2 = main.ONOScli2.ports()
698 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800699 # print "ports1 = ", ports1
700 # print "ports2 = ", ports2
701 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800702 links1 = main.ONOScli1.links()
703 links2 = main.ONOScli2.links()
704 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800705 # print "links1 = ", links1
706 # print "links2 = ", links2
707 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800708
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800709 print "**************"
710
711 main.step( "Start continuous pings" )
712 main.Mininet2.pingLong(
713 src=main.params[ 'PING' ][ 'source1' ],
714 target=main.params[ 'PING' ][ 'target1' ],
715 pingTime=500 )
716 main.Mininet2.pingLong(
717 src=main.params[ 'PING' ][ 'source2' ],
718 target=main.params[ 'PING' ][ 'target2' ],
719 pingTime=500 )
720 main.Mininet2.pingLong(
721 src=main.params[ 'PING' ][ 'source3' ],
722 target=main.params[ 'PING' ][ 'target3' ],
723 pingTime=500 )
724 main.Mininet2.pingLong(
725 src=main.params[ 'PING' ][ 'source4' ],
726 target=main.params[ 'PING' ][ 'target4' ],
727 pingTime=500 )
728 main.Mininet2.pingLong(
729 src=main.params[ 'PING' ][ 'source5' ],
730 target=main.params[ 'PING' ][ 'target5' ],
731 pingTime=500 )
732 main.Mininet2.pingLong(
733 src=main.params[ 'PING' ][ 'source6' ],
734 target=main.params[ 'PING' ][ 'target6' ],
735 pingTime=500 )
736 main.Mininet2.pingLong(
737 src=main.params[ 'PING' ][ 'source7' ],
738 target=main.params[ 'PING' ][ 'target7' ],
739 pingTime=500 )
740 main.Mininet2.pingLong(
741 src=main.params[ 'PING' ][ 'source8' ],
742 target=main.params[ 'PING' ][ 'target8' ],
743 pingTime=500 )
744 main.Mininet2.pingLong(
745 src=main.params[ 'PING' ][ 'source9' ],
746 target=main.params[ 'PING' ][ 'target9' ],
747 pingTime=500 )
748 main.Mininet2.pingLong(
749 src=main.params[ 'PING' ][ 'source10' ],
750 target=main.params[ 'PING' ][ 'target10' ],
751 pingTime=500 )
752
753 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800754 global ctrls
755 ctrls = []
756 count = 1
757 while True:
758 temp = ()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800759 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
760 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
761 temp = temp + ( "ONOS" + str( count ), )
762 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
763 temp = temp + \
764 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
765 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800766 count = count + 1
767 else:
768 break
769 global MNTopo
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800770 Topo = TestONTopology(
771 main.Mininet1,
772 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800773 MNTopo = Topo
774
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800775 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800776 main.step( "Compare ONOS Topology to MN Topology" )
777
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800778 switchesResults1 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800779 MNTopo,
780 json.loads( devices1 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800781 print "switches_Result1 = ", switchesResults1
782 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
783 onpass="ONOS1 Switches view is correct",
784 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800785
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800786 switchesResults2 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800787 MNTopo,
788 json.loads( devices2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800789 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
790 onpass="ONOS2 Switches view is correct",
791 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800792
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800793 switchesResults3 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800794 MNTopo,
795 json.loads( devices3 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800796 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
797 onpass="ONOS3 Switches view is correct",
798 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800799
800 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800801 portsResults1 = main.Mininet1.comparePorts( MNTopo,
802 json.loads( ports1 ) )
803 utilities.assertEquals( expect=main.TRUE, actual=portsResults1,
shahshreya4e13a062014-11-11 16:46:18 -0800804 onpass="ONOS1 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800805 onfail="ONOS1 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800806
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800807 portsResults2 = main.Mininet1.comparePorts( MNTopo,
808 json.loads( ports2 ) )
809 utilities.assertEquals( expect=main.TRUE, actual=portsResults2,
shahshreya4e13a062014-11-11 16:46:18 -0800810 onpass="ONOS2 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800811 onfail="ONOS2 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800812
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800813 portsResults3 = main.Mininet1.comparePorts( MNTopo,
814 json.loads( ports3 ) )
815 utilities.assertEquals( expect=main.TRUE, actual=portsResults3,
shahshreya4e13a062014-11-11 16:46:18 -0800816 onpass="ONOS3 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800817 onfail="ONOS3 Ports view is incorrect" )
818 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800819 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800820 MNTopo,
821 json.loads( links1 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800822 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
823 onpass="ONOS1 Links view is correct",
824 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800825
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800826 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800827 MNTopo,
828 json.loads( links2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800829 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
830 onpass="ONOS2 Links view is correct",
831 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800832
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800833 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800834 MNTopo,
835 json.loads( links3 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800836 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
837 onpass="ONOS2 Links view is correct",
838 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800839
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800840 # topoResult = switchesResults1 and switchesResults2
841 # and switchesResults3\
842 # and portsResults1 and portsResults2 and portsResults3\
843 # and linksResults1 and linksResults2 and linksResults3
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800844
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800845 topoResult = switchesResults1 and switchesResults2\
846 and switchesResults3 and linksResults1 and\
847 linksResults2 and linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800848
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800849 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800850 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800851 actual=topoResult and LinkUp and LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800852 onpass="Topology Check Test successful",
853 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800854
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800855 def CASE8( self ):
856 """
shahshreyaeac353b2014-11-18 17:19:20 -0800857 Intent removal
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800858 """
859 main.log.report(
860 "This testcase removes host any previously added intents" )
861 main.log.report( "__________________________________" )
862 main.log.info( "Removing any previously installed intents" )
863 main.case( "Removing intents" )
864 main.step( "Obtain the intent id's" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800865 intentResult = main.ONOScli1.intents( jsonFormat=False )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800866
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800867 intentLinewise = intentResult.split( "\n" )
shahshreyaa9d79f22014-11-18 15:41:29 -0800868 intentList = []
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800869 for line in intentLinewise:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800870 if line.startswith( "id=" ):
871 intentList.append( line )
shahshreyaa9d79f22014-11-18 15:41:29 -0800872
873 intentids = []
874 for line in intentList:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800875 intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
shahshreya4e13a062014-11-11 16:46:18 -0800876 for id in intentids:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800877 main.log.info( "id = " + id )
shahshreyaa9d79f22014-11-18 15:41:29 -0800878
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800879 main.step(
880 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -0800881 for id in intentids:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800882 main.ONOScli1.removeIntent( intentId=id )
shahshreyaa9d79f22014-11-18 15:41:29 -0800883
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800884 intentResult = main.ONOScli1.intents( jsonFormat=False )
885 main.log.info( "intent_result = " + intentResult )
886 case8Result = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800887
shahshreyaeac353b2014-11-18 17:19:20 -0800888 i = 8
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800889 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800890 while i < 18:
891 main.log.info(
892 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
893 ping = main.Mininet1.pingHost(
894 src="h" + str( i ), target="h" + str( i + 10 ) )
895 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -0800896 i = 19
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800897 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800898 elif ping == main.FALSE:
899 i += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800900 PingResult = main.FALSE
shahshreyaeac353b2014-11-18 17:19:20 -0800901 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800902 main.log.info( "Unknown error" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800903 PingResult = main.ERROR
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800904
905 # Note: If the ping result failed, that means the intents have been
906 # withdrawn correctly.
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800907 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800908 main.log.report( "Host intents have not been withdrawn correctly" )
909 # main.cleanup()
910 # main.exit()
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800911 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800912 main.log.report( "Host intents have been withdrawn correctly" )
shahshreyaeac353b2014-11-18 17:19:20 -0800913
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800914 case8Result = case8Result and PingResult
shahshreyaeac353b2014-11-18 17:19:20 -0800915
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800916 if case8Result == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800917 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800918 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800919 main.log.report( "Intent removal failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800920
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800921 utilities.assertEquals( expect=main.FALSE, actual=case8Result,
922 onpass="Intent removal test failed",
923 onfail="Intent removal test successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800924
925 def CASE9( self ):
926 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800927 This test case adds point intents. Make sure you run test case 8
928 which is host intent removal before executing this test case.
929 Else the host intent's flows will persist on switches and the pings
930 would work even if there is some issue with the point intent's flows
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800931 """
932 main.log.report(
933 "This testcase adds point intents and then does pingall" )
934 main.log.report( "__________________________________" )
935 main.log.info( "Adding point intents" )
936 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800937 "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20," +
938 "h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800939 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800940 "Add point-to-point intents for mininet hosts" +
941 " h8 and h18 or ONOS hosts h8 and h12" )
942 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800943 "of:0000000000003008/1",
944 "of:0000000000006018/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800945 if ptpIntentResult == main.TRUE:
946 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800947 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800948 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800949
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800950 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800951 "of:0000000000006018/1",
952 "of:0000000000003008/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800953 if ptpIntentResult == main.TRUE:
954 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800955 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800956 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800957
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800958 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800959 "Add point-to-point intents for mininet hosts" +
960 " h9 and h19 or ONOS hosts h9 and h13" )
961 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800962 "of:0000000000003009/1",
963 "of:0000000000006019/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800964 if ptpIntentResult == main.TRUE:
965 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800966 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800967 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800968
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800969 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800970 "of:0000000000006019/1",
971 "of:0000000000003009/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800972 if ptpIntentResult == main.TRUE:
973 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800974 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800975 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800976
977 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800978 "Add point-to-point intents for mininet" +
979 " hosts h10 and h20 or ONOS hosts hA and h14" )
980 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800981 "of:0000000000003010/1",
982 "of:0000000000006020/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800983 if ptpIntentResult == main.TRUE:
984 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800985 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800986 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800987
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800988 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800989 "of:0000000000006020/1",
990 "of:0000000000003010/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800991 if ptpIntentResult == main.TRUE:
992 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800993 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800994 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800995
996 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800997 "Add point-to-point intents for mininet" +
998 " hosts h11 and h21 or ONOS hosts hB and h15" )
999 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001000 "of:0000000000003011/1",
1001 "of:0000000000006021/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001002 if ptpIntentResult == main.TRUE:
1003 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001004 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001005 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001006
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001007 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001008 "of:0000000000006021/1",
1009 "of:0000000000003011/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001010 if ptpIntentResult == main.TRUE:
1011 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001012 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001013 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001014
1015 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001016 "Add point-to-point intents for mininet" +
1017 " hosts h12 and h22 or ONOS hosts hC and h16" )
1018 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001019 "of:0000000000003012/1",
1020 "of:0000000000006022/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001021 if ptpIntentResult == main.TRUE:
1022 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001023 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001024 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001025
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001026 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001027 "of:0000000000006022/1",
1028 "of:0000000000003012/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001029 if ptpIntentResult == main.TRUE:
1030 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001031 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001032 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001033
1034 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001035 "Add point-to-point intents for mininet " +
1036 "hosts h13 and h23 or ONOS hosts hD and h17" )
1037 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001038 "of:0000000000003013/1",
1039 "of:0000000000006023/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001040 if ptpIntentResult == main.TRUE:
1041 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001042 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001043 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001044
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001045 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001046 "of:0000000000006023/1",
1047 "of:0000000000003013/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001048 if ptpIntentResult == main.TRUE:
1049 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001050 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001051 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001052
1053 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001054 "Add point-to-point intents for mininet hosts" +
1055 " h14 and h24 or ONOS hosts hE and h18" )
1056 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001057 "of:0000000000003014/1",
1058 "of:0000000000006024/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001059 if ptpIntentResult == main.TRUE:
1060 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001061 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001062 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001063
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001064 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001065 "of:0000000000006024/1",
1066 "of:0000000000003014/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001067 if ptpIntentResult == main.TRUE:
1068 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001069 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001070 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001071
1072 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001073 "Add point-to-point intents for mininet hosts" +
1074 " h15 and h25 or ONOS hosts hF and h19" )
1075 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001076 "of:0000000000003015/1",
1077 "of:0000000000006025/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001078 if ptpIntentResult == main.TRUE:
1079 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001080 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001081 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001082
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001083 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001084 "of:0000000000006025/1",
1085 "of:0000000000003015/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001086 if ptpIntentResult == main.TRUE:
1087 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001088 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001089 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001090
1091 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001092 "Add point-to-point intents for mininet hosts" +
1093 " h16 and h26 or ONOS hosts h10 and h1A" )
1094 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001095 "of:0000000000003016/1",
1096 "of:0000000000006026/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001097 if ptpIntentResult == main.TRUE:
1098 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001099 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001100 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001101
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001102 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001103 "of:0000000000006026/1",
1104 "of:0000000000003016/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001105 if ptpIntentResult == main.TRUE:
1106 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001107 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001108 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001109
1110 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001111 "Add point-to-point intents for mininet hosts h17" +
1112 " and h27 or ONOS hosts h11 and h1B" )
1113 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001114 "of:0000000000003017/1",
1115 "of:0000000000006027/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001116 if ptpIntentResult == main.TRUE:
1117 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001118 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001119 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001120
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001121 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001122 "of:0000000000006027/1",
1123 "of:0000000000003017/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001124 if ptpIntentResult == main.TRUE:
1125 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001126 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001127 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001128
1129 print(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001130 "_______________________________________________________" +
1131 "________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001132
1133 flowHandle = main.ONOScli1.flows()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001134 # print "flowHandle = ", flowHandle
1135 main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001136
1137 count = 1
1138 i = 8
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001139 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001140 while i < 18:
1141 main.log.info(
1142 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1143 ping = main.Mininet1.pingHost(
1144 src="h" + str( i ), target="h" + str( i + 10 ) )
1145 if ping == main.FALSE and count < 5:
1146 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001147 # i = 8
1148 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001149 main.log.report( "Ping between h" +
1150 str( i ) +
1151 " and h" +
1152 str( i +
1153 10 ) +
1154 " failed. Making attempt number " +
1155 str( count ) +
1156 " in 2 seconds" )
1157 time.sleep( 2 )
1158 elif ping == main.FALSE:
1159 main.log.report( "All ping attempts between h" +
1160 str( i ) +
1161 " and h" +
1162 str( i +
1163 10 ) +
1164 "have failed" )
1165 i = 19
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001166 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001167 elif ping == main.TRUE:
1168 main.log.info( "Ping test between h" +
1169 str( i ) +
1170 " and h" +
1171 str( i +
1172 10 ) +
1173 "passed!" )
1174 i += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001175 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001176 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001177 main.log.info( "Unknown error" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001178 PingResult = main.ERROR
1179 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001180 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001181 "Ping all test after Point intents" +
1182 " addition failed. Cleaning up" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001183 # main.cleanup()
1184 # main.exit()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001185 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001186 main.log.report(
1187 "Ping all test after Point intents addition successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001188
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001189 case8Result = PingResult
1190 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001191 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001192 actual=case8Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001193 onpass="Ping all test after Point intents addition successful",
1194 onfail="Ping all test after Point intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001195
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001196 def CASE31( self ):
1197 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001198 This test case adds point intent related to
1199 SDN-IP matching on ICMP ( ethertype=IPV4, ipProto=1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001200 """
shahshreyaa9d79f22014-11-18 15:41:29 -08001201 import json
1202
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001203 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001204 "This test case adds point intent " +
1205 "related to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001206 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001207 "Adding bidirectional point intent related" +
1208 " to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001209 main.step( "Adding bidirectional point intent" )
1210 # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1211 # --ethType=IPV4 --ipProto=1 of:0000000000003008/1
1212 # of:0000000000006018/1
1213
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001214 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001215 for i in range( 8, 11 ):
1216 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001217 "Adding point intent between h" + str( i ) +
1218 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001219 host1 = "00:00:00:00:00:" + \
1220 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1221 host2 = "00:00:00:00:00:" + \
1222 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001223 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1224 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1225 for host in hostsJson:
1226 if host[ 'id' ] == host1Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001227 ip1 = host[ 'ips' ][ 0 ]
1228 ip1 = str( ip1 + "/32" )
1229 device1 = host[ 'location' ][ 'device' ]
1230 device1 = str( device1 + "/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001231 elif host[ 'id' ] == host2Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001232 ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
1233 device2 = host[ 'location' ][ "device" ]
1234 device2 = str( device2 + "/1" )
1235
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001236 pIntentResult1 = main.ONOScli1.addPointIntent(
1237 ingressDevice=device1,
1238 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001239 ipSrc=ip1,
1240 ipDst=ip2,
1241 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1242 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1243
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001244 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1245 main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001246
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001247 pIntentResult2 = main.ONOScli1.addPointIntent(
1248 ingressDevice=device2,
1249 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001250 ipSrc=ip2,
1251 ipDst=ip1,
1252 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1253 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1254
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001255 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1256 main.log.info( getIntentResult )
1257 if ( pIntentResult1 and pIntentResult2 ) == main.TRUE:
1258 # getIntentResult = main.ONOScli1.intents()
1259 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001260 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001261 "Point intent related to SDN-IP matching" +
1262 " on ICMP install successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001263
1264 time.sleep( 15 )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001265 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1266 main.log.info( "intents = " + getIntentResult )
1267 getFlowsResult = main.ONOScli1.flows()
1268 main.log.info( "flows = " + getFlowsResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001269
shahshreyae6c7cf42014-11-26 16:39:01 -08001270 count = 1
1271 i = 8
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001272 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001273 while i < 11:
1274 main.log.info(
1275 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1276 ping = main.Mininet1.pingHost(
1277 src="h" + str( i ), target="h" + str( i + 10 ) )
1278 if ping == main.FALSE and count < 3:
1279 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001280 # i = 8
1281 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001282 main.log.report( "Ping between h" +
1283 str( i ) +
1284 " and h" +
1285 str( i +
1286 10 ) +
1287 " failed. Making attempt number " +
1288 str( count ) +
1289 " in 2 seconds" )
1290 time.sleep( 2 )
1291 elif ping == main.FALSE:
1292 main.log.report( "All ping attempts between h" +
1293 str( i ) +
1294 " and h" +
1295 str( i +
1296 10 ) +
1297 "have failed" )
1298 i = 19
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001299 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001300 elif ping == main.TRUE:
1301 main.log.info( "Ping test between h" +
1302 str( i ) +
1303 " and h" +
1304 str( i +
1305 10 ) +
1306 "passed!" )
1307 i += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001308 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -08001309 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001310 main.log.info( "Unknown error" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001311 PingResult = main.ERROR
1312 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001313 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001314 "Ping test after Point intents related to" +
1315 " SDN-IP matching on ICMP failed." )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001316 # main.cleanup()
1317 # main.exit()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001318 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001319 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001320 "Ping all test after Point intents related to" +
1321 " SDN-IP matching on ICMP successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001322
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001323 case31Result = PingResult and pIntentResult1 and pIntentResult2
1324 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001325 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001326 actual=case31Result,
1327 onpass="Point intent related to SDN-IP " +
1328 "matching on ICMP and ping test successful",
1329 onfail="Point intent related to SDN-IP" +
1330 " matching on ICMP and ping test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001331
1332 def CASE32( self ):
1333 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001334 This test case adds point intent related to SDN-IP matching on TCP
1335 ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 )
1336 Note: Although BGP port is 179, we are using 5001 because iperf
1337 is used for verifying and iperf's default port is 5001
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001338 """
shahshreyae6c7cf42014-11-26 16:39:01 -08001339 import json
1340
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001341 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001342 "This test case adds point intent" +
1343 " related to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001344 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001345 "Adding bidirectional point intent related" +
1346 " to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001347 main.step( "Adding bidirectional point intent" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001348 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001349 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1350 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1
1351 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001352
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001353 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1354 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1
1355 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001356
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001357 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1358 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1
1359 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001360
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001361 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1362 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1
1363 of:0000000000003008/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001364
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001365 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001366 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001367 for i in range( 8, 9 ):
1368 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001369 "Adding point intent between h" + str( i ) +
1370 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001371 host1 = "00:00:00:00:00:" + \
1372 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1373 host2 = "00:00:00:00:00:" + \
1374 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001375 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1376 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1377 for host in hostsJson:
1378 if host[ 'id' ] == host1Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001379 ip1 = host[ 'ips' ][ 0 ]
1380 ip1 = str( ip1 + "/32" )
1381 device1 = host[ 'location' ][ 'device' ]
1382 device1 = str( device1 + "/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001383 elif host[ 'id' ] == host2Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001384 ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
1385 device2 = host[ 'location' ][ "device" ]
1386 device2 = str( device2 + "/1" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001387
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001388 pIntentResult1 = main.ONOScli1.addPointIntent(
1389 ingressDevice=device1,
1390 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001391 ipSrc=ip1,
1392 ipDst=ip2,
1393 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1394 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1395 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001396 pIntentResult2 = main.ONOScli1.addPointIntent(
1397 ingressDevice=device2,
1398 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001399 ipSrc=ip2,
1400 ipDst=ip1,
1401 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1402 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1403 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
1404
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001405 pIntentResult3 = main.ONOScli1.addPointIntent(
1406 ingressDevice=device1,
1407 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001408 ipSrc=ip1,
1409 ipDst=ip2,
1410 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1411 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1412 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001413 pIntentResult4 = main.ONOScli1.addPointIntent(
1414 ingressDevice=device2,
1415 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001416 ipSrc=ip2,
1417 ipDst=ip1,
1418 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1419 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1420 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
shahshreyae6c7cf42014-11-26 16:39:01 -08001421
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001422 pIntentResult = pIntentResult1 and pIntentResult2 and\
1423 pIntentResult3 and pIntentResult4
1424 if pIntentResult == main.TRUE:
1425 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1426 main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001427 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001428 "Point intent related to SDN-IP matching" +
1429 " on TCP install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001430
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001431 iperfResult = main.Mininet1.iperf( 'h8', 'h18' )
1432 if iperfResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001433 main.log.report( "iperf test successful" )
1434 else:
1435 main.log.report( "iperf test failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001436
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001437 case32Result = pIntentResult and iperfResult
1438 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001439 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001440 actual=case32Result,
1441 onpass="Ping all test after Point intents addition related " +
1442 "to SDN-IP on TCP match successful",
1443 onfail="Ping all test after Point intents addition related " +
1444 "to SDN-IP on TCP match failed" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001445
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001446 def CASE33( self ):
1447 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001448 This test case adds multipoint to singlepoint intent related to
1449 SDN-IP matching on destination ip and the action is to rewrite
1450 the mac address
1451 Here the mac address to be rewritten is the mac address of the
1452 egress device
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001453 """
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001454 import json
1455 import time
1456
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001457 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001458 "This test case adds multipoint to singlepoint intent related to" +
1459 " SDN-IP matching on destination ip and " +
1460 "rewrite mac address action" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001461 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001462 "Adding multipoint to singlepoint intent related to SDN-IP" +
1463 " matching on destination ip" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001464 main.step( "Adding bidirectional multipoint to singlepoint intent" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001465 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001466 add-multi-to-single-intent --ipDst=10.0.3.0/24
1467 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1
1468 of:0000000000006018/1
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001469
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001470 add-multi-to-single-intent --ipDst=10.0.1.0/24
1471 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1
1472 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001473 """
1474 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001475 "Installing multipoint to single point " +
1476 "intent with rewrite mac address" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001477 main.step( "Uninstalling proxy arp app" )
1478 # Unistall onos-app-proxyarp app to disable reactive forwarding
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001479 appUninstallResult1 = main.ONOScli1.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001480 "onos-app-proxyarp" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001481 appUninstallResult2 = main.ONOScli2.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001482 "onos-app-proxyarp" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001483 appUninstallResult3 = main.ONOScli3.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001484 "onos-app-proxyarp" )
1485 main.log.info( "onos-app-proxyarp uninstalled" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001486
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001487 main.step( "Changing ipaddress of hosts h8,h9 and h18" )
1488 main.Mininet1.changeIP(
1489 host='h8',
1490 intf='h8-eth0',
1491 newIP='10.0.1.1',
1492 newNetmask='255.255.255.0' )
1493 main.Mininet1.changeIP(
1494 host='h9',
1495 intf='h9-eth0',
1496 newIP='10.0.2.1',
1497 newNetmask='255.255.255.0' )
1498 main.Mininet1.changeIP(
1499 host='h10',
1500 intf='h10-eth0',
1501 newIP='10.0.3.1',
1502 newNetmask='255.255.255.0' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001503
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001504 main.step( "Changing default gateway of hosts h8,h9 and h18" )
1505 main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' )
1506 main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' )
1507 main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001508
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001509 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001510 "Assigning random mac address to the default gateways " +
1511 "since proxyarp app is uninstalled" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001512 main.Mininet1.addStaticMACAddress(
1513 host='h8',
1514 GW='10.0.1.254',
1515 macaddr='00:00:00:00:11:11' )
1516 main.Mininet1.addStaticMACAddress(
1517 host='h9',
1518 GW='10.0.2.254',
1519 macaddr='00:00:00:00:22:22' )
1520 main.Mininet1.addStaticMACAddress(
1521 host='h10',
1522 GW='10.0.3.254',
1523 macaddr='00:00:00:00:33:33' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001524
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001525 main.step( "Verify static gateway and MAC address assignment" )
1526 main.Mininet1.verifyStaticGWandMAC( host='h8' )
1527 main.Mininet1.verifyStaticGWandMAC( host='h9' )
1528 main.Mininet1.verifyStaticGWandMAC( host='h10' )
1529
1530 main.step( "Adding multipoint to singlepoint intent" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001531 pIntentResult1 = main.ONOScli1.addMultipointToSinglepointIntent(
1532 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
1533 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
1534 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001535 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
1536 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
1537
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001538 pIntentResult2 = main.ONOScli1.addMultipointToSinglepointIntent(
1539 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
1540 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
1541 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001542 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
1543 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
1544
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001545 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1546 main.log.info( "intents = " + getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001547
1548 time.sleep( 10 )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001549 getFlowsResult = main.ONOScli1.flows( jsonFormat=False )
1550 main.log.info( "flows = " + getFlowsResult )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001551
1552 count = 1
1553 i = 8
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001554 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001555
1556 main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
1557 ping = main.Mininet1.pingHost(
1558 src="h" + str( i ), target="h" + str( i + 2 ) )
1559 if ping == main.FALSE and count < 3:
1560 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001561 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001562 main.log.report( "Ping between h" +
1563 str( i ) +
1564 " and h" +
1565 str( i +
1566 2 ) +
1567 " failed. Making attempt number " +
1568 str( count ) +
1569 " in 2 seconds" )
1570 time.sleep( 2 )
1571 elif ping == main.FALSE:
1572 main.log.report( "All ping attempts between h" +
1573 str( i ) +
1574 " and h" +
1575 str( i +
1576 10 ) +
1577 "have failed" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001578 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001579 elif ping == main.TRUE:
1580 main.log.info( "Ping test between h" +
1581 str( i ) +
1582 " and h" +
1583 str( i +
1584 2 ) +
1585 "passed!" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001586 PingResult = main.TRUE
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001587 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001588 main.log.info( "Unknown error" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001589 PingResult = main.ERROR
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001590
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001591 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001592 main.log.report( "Ping test failed." )
1593 # main.cleanup()
1594 # main.exit()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001595 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001596 main.log.report( "Ping all successful" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001597
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001598 pIntentResult = pIntentResult1 and pIntentResult2
1599 if pIntentResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001600 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001601 "Multi point intent with rewrite mac " +
1602 "address installation successful" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001603 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001604 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001605 "Multi point intent with rewrite mac" +
1606 " address installation failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001607
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001608 case33Result = pIntentResult and PingResult
1609 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001610 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001611 actual=case33Result,
1612 onpass="Ping all test after multipoint to single point" +
1613 " intent addition with rewrite mac address successful",
1614 onfail="Ping all test after multipoint to single point intent" +
1615 " addition with rewrite mac address failed" )