blob: 4d342cacaf4275e13203df897a2585db881795b2 [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 MultiProd:
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 """
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -080062 if gitPullResult == 1:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080063 main.step( "Using mvn clean & install" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -080068 packageResult = main.ONOSbench.onosPackage()
shahshreya4e13a062014-11-11 16:46:18 -080069
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080070 #main.step( "Creating a cell" )
shahshreyaf3076352015-01-23 13:52:01 -080071 # 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" )
shahshreyaf3076352015-01-23 13:52:01 -080075 onos1InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080076 options="-f",
shahshreyaf3076352015-01-23 13:52:01 -080077 node=ONOS1Ip )
78 onos2InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080079 options="-f",
shahshreyaf3076352015-01-23 13:52:01 -080080 node=ONOS2Ip )
81 onos3InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080082 options="-f",
shahshreyaf3076352015-01-23 13:52:01 -080083 node=ONOS3Ip )
84 onosInstallResult = onos1InstallResult and onos2InstallResult and 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
shahshreyaf3076352015-01-23 13:52:01 -080090 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
91 onos2Isup = main.ONOSbench.isup( ONOS2Ip )
92 onos3Isup = main.ONOSbench.isup( ONOS3Ip )
93 onosIsup = onos1Isup and onos2Isup and onos3Isup
94 if onosIsup == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080095 main.log.report( "ONOS instances are up and ready" )
shahshreya4e13a062014-11-11 16:46:18 -080096 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080097 main.log.report( "ONOS instances may not be up" )
shahshreya4e13a062014-11-11 16:46:18 -080098
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080099 main.step( "Starting ONOS service" )
shahshreyaf3076352015-01-23 13:52:01 -0800100 startResult = main.TRUE
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
shahshreyaf3076352015-01-23 13:52:01 -0800109 case1Result = ( packageResult and
110 cellResult and verifyResult and onosInstallResult and
111 onosIsup and startResult )
112 utilities.assertEquals( expect=main.TRUE, actual=case1Result,
113 onpass="Test startup successful",
114 onfail="Test startup NOT successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800115
116 def CASE11( self, main ):
117 """
shahshreya4e13a062014-11-11 16:46:18 -0800118 Cleanup sequence:
shahshreyaf3076352015-01-23 13:52:01 -0800119 onos-service <nodeIp> stop
shahshreya4e13a062014-11-11 16:46:18 -0800120 onos-uninstall
121
122 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800123
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800124 """
shahshreyaf3076352015-01-23 13:52:01 -0800125 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
126 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
127 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
shahshreya4e13a062014-11-11 16:46:18 -0800128
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800129 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800130
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800131 main.step( "Testing ONOS kill function" )
shahshreyaf3076352015-01-23 13:52:01 -0800132 killResult1 = main.ONOSbench.onosKill( ONOS1Ip )
133 killResult2 = main.ONOSbench.onosKill( ONOS2Ip )
134 killResult3 = main.ONOSbench.onosKill( ONOS3Ip )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800135
136 main.step( "Stopping ONOS service" )
shahshreyaf3076352015-01-23 13:52:01 -0800137 stopResult1 = main.ONOSbench.onosStop( ONOS1Ip )
138 stopResult2 = main.ONOSbench.onosStop( ONOS2Ip )
139 stopResult3 = main.ONOSbench.onosStop( ONOS3Ip )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800140
141 main.step( "Uninstalling ONOS service" )
shahshreyaf3076352015-01-23 13:52:01 -0800142 uninstallResult = main.ONOSbench.onosUninstall()
shahshreya4e13a062014-11-11 16:46:18 -0800143
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800144 def CASE3( self, main ):
145 """
shahshreya4e13a062014-11-11 16:46:18 -0800146 Test 'onos' command and its functionality in driver
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800147 """
shahshreyaf3076352015-01-23 13:52:01 -0800148 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
149 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
150 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
shahshreya4e13a062014-11-11 16:46:18 -0800151
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800152 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800153
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800154 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800155 cmdstr1 = "system:name"
shahshreyaf3076352015-01-23 13:52:01 -0800156 cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
157 main.log.info( "onos command returned: " + cmdResult1 )
158 cmdResult2 = main.ONOSbench.onosCli( ONOS2Ip, cmdstr1 )
159 main.log.info( "onos command returned: " + cmdResult2 )
160 cmdResult3 = main.ONOSbench.onosCli( ONOS3Ip, cmdstr1 )
161 main.log.info( "onos command returned: " + cmdResult3 )
shahshreya4e13a062014-11-11 16:46:18 -0800162
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800163 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800164 cmdstr2 = "onos:topology"
shahshreyaf3076352015-01-23 13:52:01 -0800165 cmdResult4 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
166 main.log.info( "onos command returned: " + cmdResult4 )
167 cmdResult5 = main.ONOSbench.onosCli( ONOS2Ip, cmdstr2 )
168 main.log.info( "onos command returned: " + cmdResult5 )
169 cmdResult6 = main.ONOSbench.onosCli( ONOS6Ip, cmdstr2 )
170 main.log.info( "onos command returned: " + cmdResult6 )
shahshreya4e13a062014-11-11 16:46:18 -0800171
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800172 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800173 import re
174 import time
shahshreyaf3076352015-01-23 13:52:01 -0800175 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
176 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
177 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
178 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
179 ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
180 ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800181
182 main.log.report(
183 "This testcase is testing the assignment of all the switches to all controllers and discovering the hosts in reactive mode" )
184 main.log.report( "__________________________________" )
185 main.case( "Pingall Test(No intents are added)" )
186 main.step( "Assigning switches to controllers" )
187 for i in range( 1, 29 ): # 1 to ( num of switches +1 )
shahshreyaf3076352015-01-23 13:52:01 -0800188 main.Mininet1.assignSwController(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800189 sw=str( i ),
190 count=3,
shahshreyaf3076352015-01-23 13:52:01 -0800191 ip1=ONOS1Ip,
192 port1=ONOS1Port,
193 ip2=ONOS2Ip,
194 port2=ONOS2Port,
195 ip3=ONOS3Ip,
196 port3=ONOS3Port )
shahshreya4e13a062014-11-11 16:46:18 -0800197
shahshreyaf3076352015-01-23 13:52:01 -0800198 switchMastership = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800199 for i in range( 1, 29 ):
shahshreyaf3076352015-01-23 13:52:01 -0800200 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800201 print( "Response is " + str( response ) )
shahshreyaf3076352015-01-23 13:52:01 -0800202 if re.search( "tcp:" + ONOS1Ip, response ):
203 switchMastership = switchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800204 else:
shahshreyaf3076352015-01-23 13:52:01 -0800205 switchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800206
shahshreyaf3076352015-01-23 13:52:01 -0800207 if switchMastership == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800208 main.log.report( "Controller assignment successfull" )
shahshreya4e13a062014-11-11 16:46:18 -0800209 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800210 main.log.report( "Controller assignment failed" )
211 # REACTIVE FWD test
212 main.step( "Pingall" )
shahshreyaf3076352015-01-23 13:52:01 -0800213 pingResult = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800214 time1 = time.time()
shahshreyaf3076352015-01-23 13:52:01 -0800215 pingResult = main.Mininet1.pingall()
shahshreya4e13a062014-11-11 16:46:18 -0800216 time2 = time.time()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800217 print "Time for pingall: %2f seconds" % ( time2 - time1 )
218
shahshreyaf3076352015-01-23 13:52:01 -0800219 case4Result = switchMastership and pingResult
220 if pingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800221 main.log.report(
222 "Pingall Test in reactive mode to discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800223 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800224 main.log.report(
225 "Pingall Test in reactive mode to discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800226
shahshreyaf3076352015-01-23 13:52:01 -0800227 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800228 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800229 actual=case4Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800230 onpass="Controller assignment and Pingall Test successful",
231 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800232
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800233 def CASE5( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800234 import json
235 from subprocess import Popen, PIPE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800236 # assumes that sts is already in you PYTHONPATH
237 from sts.topology.teston_topology import TestONTopology
shahshreyaf3076352015-01-23 13:52:01 -0800238 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
239 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
240 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800241
242 main.log.report(
243 "This testcase is testing if all ONOS nodes are in topology sync with mininet and its peer ONOS nodes" )
244 main.log.report( "__________________________________" )
245 main.case(
246 "Testing Mininet topology with the topology of multi instances ONOS" )
247 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800248 devices1 = main.ONOScli1.devices()
249 devices2 = main.ONOScli2.devices()
250 devices3 = main.ONOScli3.devices()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800251 # print "devices1 = ", devices1
252 # print "devices2 = ", devices2
253 # print "devices3 = ", devices3
shahshreya4e13a062014-11-11 16:46:18 -0800254 hosts1 = main.ONOScli1.hosts()
255 hosts2 = main.ONOScli2.hosts()
256 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800257 # print "hosts1 = ", hosts1
258 # print "hosts2 = ", hosts2
259 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800260 ports1 = main.ONOScli1.ports()
261 ports2 = main.ONOScli2.ports()
262 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800263 # print "ports1 = ", ports1
264 # print "ports2 = ", ports2
265 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800266 links1 = main.ONOScli1.links()
267 links2 = main.ONOScli2.links()
268 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800269 # print "links1 = ", links1
270 # print "links2 = ", links2
271 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800272
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800273 print "**************"
274
275 main.step( "Start continuous pings" )
276 main.Mininet2.pingLong(
277 src=main.params[ 'PING' ][ 'source1' ],
278 target=main.params[ 'PING' ][ 'target1' ],
279 pingTime=500 )
280 main.Mininet2.pingLong(
281 src=main.params[ 'PING' ][ 'source2' ],
282 target=main.params[ 'PING' ][ 'target2' ],
283 pingTime=500 )
284 main.Mininet2.pingLong(
285 src=main.params[ 'PING' ][ 'source3' ],
286 target=main.params[ 'PING' ][ 'target3' ],
287 pingTime=500 )
288 main.Mininet2.pingLong(
289 src=main.params[ 'PING' ][ 'source4' ],
290 target=main.params[ 'PING' ][ 'target4' ],
291 pingTime=500 )
292 main.Mininet2.pingLong(
293 src=main.params[ 'PING' ][ 'source5' ],
294 target=main.params[ 'PING' ][ 'target5' ],
295 pingTime=500 )
296 main.Mininet2.pingLong(
297 src=main.params[ 'PING' ][ 'source6' ],
298 target=main.params[ 'PING' ][ 'target6' ],
299 pingTime=500 )
300 main.Mininet2.pingLong(
301 src=main.params[ 'PING' ][ 'source7' ],
302 target=main.params[ 'PING' ][ 'target7' ],
303 pingTime=500 )
304 main.Mininet2.pingLong(
305 src=main.params[ 'PING' ][ 'source8' ],
306 target=main.params[ 'PING' ][ 'target8' ],
307 pingTime=500 )
308 main.Mininet2.pingLong(
309 src=main.params[ 'PING' ][ 'source9' ],
310 target=main.params[ 'PING' ][ 'target9' ],
311 pingTime=500 )
312 main.Mininet2.pingLong(
313 src=main.params[ 'PING' ][ 'source10' ],
314 target=main.params[ 'PING' ][ 'target10' ],
315 pingTime=500 )
316
317 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800318 global ctrls
319 ctrls = []
320 count = 1
321 while True:
322 temp = ()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800323 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
324 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
325 temp = temp + ( "ONOS" + str( count ), )
326 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
327 temp = temp + \
328 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
329 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800330 count = count + 1
331 else:
332 break
333 global MNTopo
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800334 Topo = TestONTopology(
335 main.Mininet1,
336 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800337 MNTopo = Topo
338
shahshreyaf3076352015-01-23 13:52:01 -0800339 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800340 main.step( "Compare ONOS Topology to MN Topology" )
341
shahshreyaf3076352015-01-23 13:52:01 -0800342 switchesResults1 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800343 MNTopo,
344 json.loads( devices1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800345 print "switches_Result1 = ", switchesResults1
346 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
347 onpass="ONOS1 Switches view is correct",
348 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800349
shahshreyaf3076352015-01-23 13:52:01 -0800350 switchesResults2 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800351 MNTopo,
352 json.loads( devices2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800353 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
354 onpass="ONOS2 Switches view is correct",
355 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800356
shahshreyaf3076352015-01-23 13:52:01 -0800357 switchesResults3 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800358 MNTopo,
359 json.loads( devices3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800360 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
361 onpass="ONOS3 Switches view is correct",
362 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800363
364 """
shahshreyaf3076352015-01-23 13:52:01 -0800365 portsResults1 = main.Mininet1.comparePorts( MNTopo, json.loads( ports1 ) )
366 utilities.assertEquals( expect=main.TRUE, actual=portsResults1,
shahshreya4e13a062014-11-11 16:46:18 -0800367 onpass="ONOS1 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800368 onfail="ONOS1 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800369
shahshreyaf3076352015-01-23 13:52:01 -0800370 portsResults2 = main.Mininet1.comparePorts( MNTopo, json.loads( ports2 ) )
371 utilities.assertEquals( expect=main.TRUE, actual=portsResults2,
shahshreya4e13a062014-11-11 16:46:18 -0800372 onpass="ONOS2 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800373 onfail="ONOS2 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800374
shahshreyaf3076352015-01-23 13:52:01 -0800375 portsResults3 = main.Mininet1.comparePorts( MNTopo, json.loads( ports3 ) )
376 utilities.assertEquals( expect=main.TRUE, actual=portsResults3,
shahshreya4e13a062014-11-11 16:46:18 -0800377 onpass="ONOS3 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800378 onfail="ONOS3 Ports view is incorrect" )
379 """
shahshreyaf3076352015-01-23 13:52:01 -0800380 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800381 MNTopo,
382 json.loads( links1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800383 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
384 onpass="ONOS1 Links view is correct",
385 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800386
shahshreyaf3076352015-01-23 13:52:01 -0800387 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800388 MNTopo,
389 json.loads( links2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800390 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
391 onpass="ONOS2 Links view is correct",
392 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800393
shahshreyaf3076352015-01-23 13:52:01 -0800394 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800395 MNTopo,
396 json.loads( links3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800397 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
398 onpass="ONOS2 Links view is correct",
399 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800400
shahshreyaf3076352015-01-23 13:52:01 -0800401 #topoResult = switchesResults1 and switchesResults2 and switchesResults3\
402 # and portsResults1 and portsResults2 and portsResults3\
403 # and linksResults1 and linksResults2 and linksResults3
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800404
shahshreyaf3076352015-01-23 13:52:01 -0800405 topoResult = switchesResults1 and switchesResults2 and switchesResults3\
406 and linksResults1 and linksResults2 and linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800407
shahshreyaf3076352015-01-23 13:52:01 -0800408 if topoResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800409 main.log.report(
410 "Topology Check Test with mininet and ONOS instances successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800411 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800412 main.log.report(
413 "Topology Check Test with mininet and ONOS instances failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800414
shahshreyaf3076352015-01-23 13:52:01 -0800415 utilities.assertEquals( expect=main.TRUE, actual=topoResult,
416 onpass="Topology Check Test successful",
417 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800418
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800419 def CASE10( self ):
420 main.log.report(
421 "This testcase uninstalls the reactive forwarding app" )
422 main.log.report( "__________________________________" )
423 main.case( "Uninstalling reactive forwarding app" )
424 # Unistall onos-app-fwd app to disable reactive forwarding
shahshreyaf3076352015-01-23 13:52:01 -0800425 appUninstallResult1 = main.ONOScli1.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800426 "onos-app-fwd" )
shahshreyaf3076352015-01-23 13:52:01 -0800427 appUninstallResult2 = main.ONOScli2.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800428 "onos-app-fwd" )
shahshreyaf3076352015-01-23 13:52:01 -0800429 appUninstallResult3 = main.ONOScli3.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800430 "onos-app-fwd" )
431 main.log.info( "onos-app-fwd uninstalled" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800432
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800433 # After reactive forwarding is disabled, the reactive flows on switches timeout in 10-15s
434 # So sleep for 15s
435 time.sleep( 15 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800436
shahshreyae6c7cf42014-11-26 16:39:01 -0800437 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800438 main.log.info( hosts )
439
shahshreyaf3076352015-01-23 13:52:01 -0800440 case10Result = appUninstallResult1 and appUninstallResult2 and appUninstallResult3
441 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800442 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800443 actual=case10Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800444 onpass="Reactive forwarding app uninstallation successful",
445 onfail="Reactive forwarding app uninstallation failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800446
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800447 def CASE6( self ):
448 main.log.report(
449 "This testcase is testing the addition of host intents and then doing pingall" )
450 main.log.report( "__________________________________" )
451 main.case( "Obtaining hostsfor adding host intents" )
452 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800453 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800454 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800455
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800456 main.step( "Get all devices id" )
shahshreyaf3076352015-01-23 13:52:01 -0800457 devicesIdList = main.ONOScli1.getAllDevicesId()
458 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -0800459
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800460 # ONOS displays the hosts in hex format unlike mininet which does in decimal format
461 # So take care while adding intents
shahshreya4e13a062014-11-11 16:46:18 -0800462
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800463 """
464 main.step( "Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
shahshreyaf3076352015-01-23 13:52:01 -0800465 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
466 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
467 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
468 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
469 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
470 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
471 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
472 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
473 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
474 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800475 """
476 for i in range( 8, 18 ):
477 main.log.info(
478 "Adding host intent between h" + str( i ) + " and h" + str( i + 10 ) )
479 host1 = "00:00:00:00:00:" + \
480 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
481 host2 = "00:00:00:00:00:" + \
482 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
483 # NOTE: get host can return None
484 # TODO: handle this
shahshreyaf3076352015-01-23 13:52:01 -0800485 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
486 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
487 tmpResult = main.ONOScli1.addHostIntent( host1Id, host2Id )
shahshreya4e13a062014-11-11 16:46:18 -0800488
489 flowHandle = main.ONOScli1.flows()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800490 # print "flowHandle = ", flowHandle
491 main.log.info( "flows:" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -0800492
493 count = 1
494 i = 8
shahshreyaf3076352015-01-23 13:52:01 -0800495 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800496 while i < 18:
497 main.log.info(
498 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
499 ping = main.Mininet1.pingHost(
500 src="h" + str( i ), target="h" + str( i + 10 ) )
501 if ping == main.FALSE and count < 5:
502 count += 1
shahshreya4e13a062014-11-11 16:46:18 -0800503 #i = 8
shahshreyaf3076352015-01-23 13:52:01 -0800504 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800505 main.log.report( "Ping between h" +
506 str( i ) +
507 " and h" +
508 str( i +
509 10 ) +
510 " failed. Making attempt number " +
511 str( count ) +
512 " in 2 seconds" )
513 time.sleep( 2 )
514 elif ping == main.FALSE:
515 main.log.report( "All ping attempts between h" +
516 str( i ) +
517 " and h" +
518 str( i +
519 10 ) +
520 "have failed" )
521 i = 19
shahshreyaf3076352015-01-23 13:52:01 -0800522 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800523 elif ping == main.TRUE:
524 main.log.info( "Ping test between h" +
525 str( i ) +
526 " and h" +
527 str( i +
528 10 ) +
529 "passed!" )
530 i += 1
shahshreyaf3076352015-01-23 13:52:01 -0800531 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800532 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800533 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -0800534 PingResult = main.ERROR
535 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800536 main.log.report(
537 "Host intents have not ben installed correctly. Cleaning up" )
538 # main.cleanup()
539 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -0800540 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800541 main.log.report( "Host intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -0800542
shahshreyaf3076352015-01-23 13:52:01 -0800543 case6Result = PingResult
544 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800545 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800546 actual=case6Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800547 onpass="Host intent addition and Pingall Test successful",
548 onfail="Host intent addition and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800549
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800550 def CASE7( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800551
shahshreyaf3076352015-01-23 13:52:01 -0800552 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800553
shahshreyaf3076352015-01-23 13:52:01 -0800554 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800555
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800556 main.log.report(
557 "This testscase is killing a link to ensure that link discovery is consistent" )
558 main.log.report( "__________________________________" )
559 main.case(
560 "Killing a link to Ensure that Link Discovery is Working Properly" )
561 main.step( "Start continuous pings" )
shahshreya4e13a062014-11-11 16:46:18 -0800562
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800563 main.Mininet2.pingLong(
564 src=main.params[ 'PING' ][ 'source1' ],
565 target=main.params[ 'PING' ][ 'target1' ],
566 pingTime=500 )
567 main.Mininet2.pingLong(
568 src=main.params[ 'PING' ][ 'source2' ],
569 target=main.params[ 'PING' ][ 'target2' ],
570 pingTime=500 )
571 main.Mininet2.pingLong(
572 src=main.params[ 'PING' ][ 'source3' ],
573 target=main.params[ 'PING' ][ 'target3' ],
574 pingTime=500 )
575 main.Mininet2.pingLong(
576 src=main.params[ 'PING' ][ 'source4' ],
577 target=main.params[ 'PING' ][ 'target4' ],
578 pingTime=500 )
579 main.Mininet2.pingLong(
580 src=main.params[ 'PING' ][ 'source5' ],
581 target=main.params[ 'PING' ][ 'target5' ],
582 pingTime=500 )
583 main.Mininet2.pingLong(
584 src=main.params[ 'PING' ][ 'source6' ],
585 target=main.params[ 'PING' ][ 'target6' ],
586 pingTime=500 )
587 main.Mininet2.pingLong(
588 src=main.params[ 'PING' ][ 'source7' ],
589 target=main.params[ 'PING' ][ 'target7' ],
590 pingTime=500 )
591 main.Mininet2.pingLong(
592 src=main.params[ 'PING' ][ 'source8' ],
593 target=main.params[ 'PING' ][ 'target8' ],
594 pingTime=500 )
595 main.Mininet2.pingLong(
596 src=main.params[ 'PING' ][ 'source9' ],
597 target=main.params[ 'PING' ][ 'target9' ],
598 pingTime=500 )
599 main.Mininet2.pingLong(
600 src=main.params[ 'PING' ][ 'source10' ],
601 target=main.params[ 'PING' ][ 'target10' ],
602 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -0800603
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800604 main.step( "Determine the current number of switches and links" )
shahshreyaf3076352015-01-23 13:52:01 -0800605 topologyOutput = main.ONOScli1.topology()
606 topologyResult = main.ONOSbench.getTopology( topologyOutput )
607 activeSwitches = topologyResult[ 'devices' ]
608 links = topologyResult[ 'links' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800609 print "activeSwitches = ", type( activeSwitches )
610 print "links = ", type( links )
611 main.log.info(
612 "Currently there are %s switches and %s links" %
613 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -0800614
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800615 main.step( "Kill Link between s3 and s28" )
616 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
shahshreyaf3076352015-01-23 13:52:01 -0800617 time.sleep( linkSleep )
618 topologyOutput = main.ONOScli2.topology()
619 LinkDown = main.ONOSbench.checkStatus(
620 topologyOutput, activeSwitches, str(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800621 int( links ) - 2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800622 if LinkDown == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800623 main.log.report( "Link Down discovered properly" )
shahshreyaf3076352015-01-23 13:52:01 -0800624 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800625 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800626 actual=LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800627 onpass="Link Down discovered properly",
628 onfail="Link down was not discovered in " +
shahshreyaf3076352015-01-23 13:52:01 -0800629 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800630 " seconds" )
shahshreya4e13a062014-11-11 16:46:18 -0800631
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800632 main.step( "Bring link between s3 and s28 back up" )
shahshreyaf3076352015-01-23 13:52:01 -0800633 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
634 time.sleep( linkSleep )
635 topologyOutput = main.ONOScli2.topology()
636 LinkUp = main.ONOSbench.checkStatus(
637 topologyOutput,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800638 activeSwitches,
639 str( links ) )
shahshreyaf3076352015-01-23 13:52:01 -0800640 if LinkUp == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800641 main.log.report( "Link up discovered properly" )
shahshreyaf3076352015-01-23 13:52:01 -0800642 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800643 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800644 actual=LinkUp,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800645 onpass="Link up discovered properly",
646 onfail="Link up was not discovered in " +
shahshreyaf3076352015-01-23 13:52:01 -0800647 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800648 " seconds" )
649
650 main.step( "Compare ONOS Topology to MN Topology" )
651 main.case(
652 "Testing Mininet topology with the topology of multi instances ONOS" )
653 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800654 devices1 = main.ONOScli1.devices()
655 devices2 = main.ONOScli2.devices()
656 devices3 = main.ONOScli3.devices()
657 print "devices1 = ", devices1
658 print "devices2 = ", devices2
659 print "devices3 = ", devices3
660 hosts1 = main.ONOScli1.hosts()
661 hosts2 = main.ONOScli2.hosts()
662 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800663 # print "hosts1 = ", hosts1
664 # print "hosts2 = ", hosts2
665 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800666 ports1 = main.ONOScli1.ports()
667 ports2 = main.ONOScli2.ports()
668 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800669 # print "ports1 = ", ports1
670 # print "ports2 = ", ports2
671 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800672 links1 = main.ONOScli1.links()
673 links2 = main.ONOScli2.links()
674 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800675 # print "links1 = ", links1
676 # print "links2 = ", links2
677 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800678
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800679 print "**************"
680
681 main.step( "Start continuous pings" )
682 main.Mininet2.pingLong(
683 src=main.params[ 'PING' ][ 'source1' ],
684 target=main.params[ 'PING' ][ 'target1' ],
685 pingTime=500 )
686 main.Mininet2.pingLong(
687 src=main.params[ 'PING' ][ 'source2' ],
688 target=main.params[ 'PING' ][ 'target2' ],
689 pingTime=500 )
690 main.Mininet2.pingLong(
691 src=main.params[ 'PING' ][ 'source3' ],
692 target=main.params[ 'PING' ][ 'target3' ],
693 pingTime=500 )
694 main.Mininet2.pingLong(
695 src=main.params[ 'PING' ][ 'source4' ],
696 target=main.params[ 'PING' ][ 'target4' ],
697 pingTime=500 )
698 main.Mininet2.pingLong(
699 src=main.params[ 'PING' ][ 'source5' ],
700 target=main.params[ 'PING' ][ 'target5' ],
701 pingTime=500 )
702 main.Mininet2.pingLong(
703 src=main.params[ 'PING' ][ 'source6' ],
704 target=main.params[ 'PING' ][ 'target6' ],
705 pingTime=500 )
706 main.Mininet2.pingLong(
707 src=main.params[ 'PING' ][ 'source7' ],
708 target=main.params[ 'PING' ][ 'target7' ],
709 pingTime=500 )
710 main.Mininet2.pingLong(
711 src=main.params[ 'PING' ][ 'source8' ],
712 target=main.params[ 'PING' ][ 'target8' ],
713 pingTime=500 )
714 main.Mininet2.pingLong(
715 src=main.params[ 'PING' ][ 'source9' ],
716 target=main.params[ 'PING' ][ 'target9' ],
717 pingTime=500 )
718 main.Mininet2.pingLong(
719 src=main.params[ 'PING' ][ 'source10' ],
720 target=main.params[ 'PING' ][ 'target10' ],
721 pingTime=500 )
722
723 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800724 global ctrls
725 ctrls = []
726 count = 1
727 while True:
728 temp = ()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800729 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
730 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
731 temp = temp + ( "ONOS" + str( count ), )
732 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
733 temp = temp + \
734 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
735 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800736 count = count + 1
737 else:
738 break
739 global MNTopo
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800740 Topo = TestONTopology(
741 main.Mininet1,
742 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800743 MNTopo = Topo
744
shahshreyaf3076352015-01-23 13:52:01 -0800745 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800746 main.step( "Compare ONOS Topology to MN Topology" )
747
shahshreyaf3076352015-01-23 13:52:01 -0800748 switchesResults1 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800749 MNTopo,
750 json.loads( devices1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800751 print "switches_Result1 = ", switchesResults1
752 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
753 onpass="ONOS1 Switches view is correct",
754 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800755
shahshreyaf3076352015-01-23 13:52:01 -0800756 switchesResults2 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800757 MNTopo,
758 json.loads( devices2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800759 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
760 onpass="ONOS2 Switches view is correct",
761 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800762
shahshreyaf3076352015-01-23 13:52:01 -0800763 switchesResults3 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800764 MNTopo,
765 json.loads( devices3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800766 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
767 onpass="ONOS3 Switches view is correct",
768 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800769
770 """
shahshreyaf3076352015-01-23 13:52:01 -0800771 portsResults1 = main.Mininet1.comparePorts( MNTopo, json.loads( ports1 ) )
772 utilities.assertEquals( expect=main.TRUE, actual=portsResults1,
shahshreya4e13a062014-11-11 16:46:18 -0800773 onpass="ONOS1 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800774 onfail="ONOS1 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800775
shahshreyaf3076352015-01-23 13:52:01 -0800776 portsResults2 = main.Mininet1.comparePorts( MNTopo, json.loads( ports2 ) )
777 utilities.assertEquals( expect=main.TRUE, actual=portsResults2,
shahshreya4e13a062014-11-11 16:46:18 -0800778 onpass="ONOS2 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800779 onfail="ONOS2 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800780
shahshreyaf3076352015-01-23 13:52:01 -0800781 portsResults3 = main.Mininet1.comparePorts( MNTopo, json.loads( ports3 ) )
782 utilities.assertEquals( expect=main.TRUE, actual=portsResults3,
shahshreya4e13a062014-11-11 16:46:18 -0800783 onpass="ONOS3 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800784 onfail="ONOS3 Ports view is incorrect" )
785 """
shahshreyaf3076352015-01-23 13:52:01 -0800786 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800787 MNTopo,
788 json.loads( links1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800789 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
790 onpass="ONOS1 Links view is correct",
791 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800792
shahshreyaf3076352015-01-23 13:52:01 -0800793 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800794 MNTopo,
795 json.loads( links2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800796 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
797 onpass="ONOS2 Links view is correct",
798 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800799
shahshreyaf3076352015-01-23 13:52:01 -0800800 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800801 MNTopo,
802 json.loads( links3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800803 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
804 onpass="ONOS2 Links view is correct",
805 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800806
shahshreyaf3076352015-01-23 13:52:01 -0800807 #topoResult = switchesResults1 and switchesResults2 and switchesResults3\
808 # and portsResults1 and portsResults2 and portsResults3\
809 # and linksResults1 and linksResults2 and linksResults3
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800810
shahshreyaf3076352015-01-23 13:52:01 -0800811 topoResult = switchesResults1 and switchesResults2 and switchesResults3\
812 and linksResults1 and linksResults2 and linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800813
shahshreyaf3076352015-01-23 13:52:01 -0800814 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800815 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800816 actual=topoResult and LinkUp and LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800817 onpass="Topology Check Test successful",
818 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800819
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800820 def CASE8( self ):
821 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800822 Intent removal
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800823 """
824 main.log.report(
825 "This testcase removes host any previously added intents" )
826 main.log.report( "__________________________________" )
827 main.log.info( "Removing any previously installed intents" )
828 main.case( "Removing intents" )
829 main.step( "Obtain the intent id's" )
shahshreyaf3076352015-01-23 13:52:01 -0800830 intentResult = main.ONOScli1.intents( jsonFormat=False )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800831
shahshreyaf3076352015-01-23 13:52:01 -0800832 intentLinewise = intentResult.split( "\n" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800833 intentList = []
shahshreyaf3076352015-01-23 13:52:01 -0800834 for line in intentLinewise:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800835 if line.startswith( "id=" ):
836 intentList.append( line )
shahshreyae6c7cf42014-11-26 16:39:01 -0800837
838 intentids = []
839 for line in intentList:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800840 intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
shahshreya4e13a062014-11-11 16:46:18 -0800841 for id in intentids:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800842 main.log.info( "id = " + id )
shahshreyae6c7cf42014-11-26 16:39:01 -0800843
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800844 main.step(
845 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -0800846 for id in intentids:
shahshreyaf3076352015-01-23 13:52:01 -0800847 main.ONOScli1.removeIntent( intentId=id )
shahshreyae6c7cf42014-11-26 16:39:01 -0800848
shahshreyaf3076352015-01-23 13:52:01 -0800849 intentResult = main.ONOScli1.intents( jsonFormat=False )
850 main.log.info( "intent_result = " + intentResult )
851 case8Result = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800852
shahshreyae6c7cf42014-11-26 16:39:01 -0800853 i = 8
shahshreyaf3076352015-01-23 13:52:01 -0800854 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800855 while i < 18:
856 main.log.info(
857 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
858 ping = main.Mininet1.pingHost(
859 src="h" + str( i ), target="h" + str( i + 10 ) )
860 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -0800861 i = 19
shahshreyaf3076352015-01-23 13:52:01 -0800862 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800863 elif ping == main.FALSE:
864 i += 1
shahshreyaf3076352015-01-23 13:52:01 -0800865 PingResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800866 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800867 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -0800868 PingResult = main.ERROR
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800869
870 # Note: If the ping result failed, that means the intents have been
871 # withdrawn correctly.
shahshreyaf3076352015-01-23 13:52:01 -0800872 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800873 main.log.report( "Host intents have not been withdrawn correctly" )
874 # main.cleanup()
875 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -0800876 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800877 main.log.report( "Host intents have been withdrawn correctly" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800878
shahshreyaf3076352015-01-23 13:52:01 -0800879 case8Result = case8Result and PingResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800880
shahshreyaf3076352015-01-23 13:52:01 -0800881 if case8Result == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800882 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800883 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800884 main.log.report( "Intent removal failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800885
shahshreyaf3076352015-01-23 13:52:01 -0800886 utilities.assertEquals( expect=main.FALSE, actual=case8Result,
887 onpass="Intent removal test failed",
888 onfail="Intent removal test successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800889
890 def CASE9( self ):
891 """
shahshreya4e13a062014-11-11 16:46:18 -0800892 This test case adds point intents. Make sure you run test case 8 which is host intent removal before executing this test case.
893 Else the host intent's flows will persist on switches and the pings would work even if there is some issue with the point intent's flows
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800894 """
895 main.log.report(
896 "This testcase adds point intents and then does pingall" )
897 main.log.report( "__________________________________" )
898 main.log.info( "Adding point intents" )
899 main.case(
900 "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20,h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
901 main.step(
902 "Add point-to-point intents for mininet hosts h8 and h18 or ONOS hosts h8 and h12" )
shahshreyaf3076352015-01-23 13:52:01 -0800903 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800904 "of:0000000000003008/1",
905 "of:0000000000006018/1" )
shahshreyaf3076352015-01-23 13:52:01 -0800906 if ptpIntentResult == main.TRUE:
907 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800908 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800909 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800910
shahshreyaf3076352015-01-23 13:52:01 -0800911 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800912 "of:0000000000006018/1",
913 "of:0000000000003008/1" )
shahshreyaf3076352015-01-23 13:52:01 -0800914 if ptpIntentResult == main.TRUE:
915 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800916 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800917 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800918
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800919 main.step(
920 "Add point-to-point intents for mininet hosts h9 and h19 or ONOS hosts h9 and h13" )
shahshreyaf3076352015-01-23 13:52:01 -0800921 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800922 "of:0000000000003009/1",
923 "of:0000000000006019/1" )
shahshreyaf3076352015-01-23 13:52:01 -0800924 if ptpIntentResult == main.TRUE:
925 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800926 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800927 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800928
shahshreyaf3076352015-01-23 13:52:01 -0800929 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800930 "of:0000000000006019/1",
931 "of:0000000000003009/1" )
shahshreyaf3076352015-01-23 13:52:01 -0800932 if ptpIntentResult == main.TRUE:
933 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800934 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800935 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800936
937 main.step(
938 "Add point-to-point intents for mininet hosts h10 and h20 or ONOS hosts hA and h14" )
shahshreyaf3076352015-01-23 13:52:01 -0800939 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800940 "of:0000000000003010/1",
941 "of:0000000000006020/1" )
shahshreyaf3076352015-01-23 13:52:01 -0800942 if ptpIntentResult == main.TRUE:
943 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800944 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800945 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800946
shahshreyaf3076352015-01-23 13:52:01 -0800947 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800948 "of:0000000000006020/1",
949 "of:0000000000003010/1" )
shahshreyaf3076352015-01-23 13:52:01 -0800950 if ptpIntentResult == main.TRUE:
951 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800952 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800953 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800954
955 main.step(
956 "Add point-to-point intents for mininet hosts h11 and h21 or ONOS hosts hB and h15" )
shahshreyaf3076352015-01-23 13:52:01 -0800957 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800958 "of:0000000000003011/1",
959 "of:0000000000006021/1" )
shahshreyaf3076352015-01-23 13:52:01 -0800960 if ptpIntentResult == main.TRUE:
961 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800962 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800963 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800964
shahshreyaf3076352015-01-23 13:52:01 -0800965 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800966 "of:0000000000006021/1",
967 "of:0000000000003011/1" )
shahshreyaf3076352015-01-23 13:52:01 -0800968 if ptpIntentResult == main.TRUE:
969 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800970 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800971 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800972
973 main.step(
974 "Add point-to-point intents for mininet hosts h12 and h22 or ONOS hosts hC and h16" )
shahshreyaf3076352015-01-23 13:52:01 -0800975 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800976 "of:0000000000003012/1",
977 "of:0000000000006022/1" )
shahshreyaf3076352015-01-23 13:52:01 -0800978 if ptpIntentResult == main.TRUE:
979 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800980 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800981 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800982
shahshreyaf3076352015-01-23 13:52:01 -0800983 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800984 "of:0000000000006022/1",
985 "of:0000000000003012/1" )
shahshreyaf3076352015-01-23 13:52:01 -0800986 if ptpIntentResult == main.TRUE:
987 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800988 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800989 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800990
991 main.step(
992 "Add point-to-point intents for mininet hosts h13 and h23 or ONOS hosts hD and h17" )
shahshreyaf3076352015-01-23 13:52:01 -0800993 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800994 "of:0000000000003013/1",
995 "of:0000000000006023/1" )
shahshreyaf3076352015-01-23 13:52:01 -0800996 if ptpIntentResult == main.TRUE:
997 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800998 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800999 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001000
shahshreyaf3076352015-01-23 13:52:01 -08001001 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001002 "of:0000000000006023/1",
1003 "of:0000000000003013/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -08001007 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001008
1009 main.step(
1010 "Add point-to-point intents for mininet hosts h14 and h24 or ONOS hosts hE and h18" )
shahshreyaf3076352015-01-23 13:52:01 -08001011 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001012 "of:0000000000003014/1",
1013 "of:0000000000006024/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001014 if ptpIntentResult == main.TRUE:
1015 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001016 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001017 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001018
shahshreyaf3076352015-01-23 13:52:01 -08001019 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001020 "of:0000000000006024/1",
1021 "of:0000000000003014/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001022 if ptpIntentResult == main.TRUE:
1023 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001024 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001025 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001026
1027 main.step(
1028 "Add point-to-point intents for mininet hosts h15 and h25 or ONOS hosts hF and h19" )
shahshreyaf3076352015-01-23 13:52:01 -08001029 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001030 "of:0000000000003015/1",
1031 "of:0000000000006025/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001032 if ptpIntentResult == main.TRUE:
1033 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001034 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001035 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001036
shahshreyaf3076352015-01-23 13:52:01 -08001037 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001038 "of:0000000000006025/1",
1039 "of:0000000000003015/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -08001043 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001044
1045 main.step(
1046 "Add point-to-point intents for mininet hosts h16 and h26 or ONOS hosts h10 and h1A" )
shahshreyaf3076352015-01-23 13:52:01 -08001047 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001048 "of:0000000000003016/1",
1049 "of:0000000000006026/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -08001053 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001054
shahshreyaf3076352015-01-23 13:52:01 -08001055 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001056 "of:0000000000006026/1",
1057 "of:0000000000003016/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001058 if ptpIntentResult == main.TRUE:
1059 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001060 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001061 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001062
1063 main.step(
1064 "Add point-to-point intents for mininet hosts h17 and h27 or ONOS hosts h11 and h1B" )
shahshreyaf3076352015-01-23 13:52:01 -08001065 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001066 "of:0000000000003017/1",
1067 "of:0000000000006027/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001068 if ptpIntentResult == main.TRUE:
1069 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001070 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001071 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001072
shahshreyaf3076352015-01-23 13:52:01 -08001073 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001074 "of:0000000000006027/1",
1075 "of:0000000000003017/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001076 if ptpIntentResult == main.TRUE:
1077 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001078 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001079 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001080
1081 print(
1082 "_______________________________________________________________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001083
1084 flowHandle = main.ONOScli1.flows()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001085 # print "flowHandle = ", flowHandle
1086 main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001087
1088 count = 1
1089 i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001090 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001091 while i < 18:
1092 main.log.info(
1093 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1094 ping = main.Mininet1.pingHost(
1095 src="h" + str( i ), target="h" + str( i + 10 ) )
1096 if ping == main.FALSE and count < 5:
1097 count += 1
shahshreya4e13a062014-11-11 16:46:18 -08001098 #i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001099 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001100 main.log.report( "Ping between h" +
1101 str( i ) +
1102 " and h" +
1103 str( i +
1104 10 ) +
1105 " failed. Making attempt number " +
1106 str( count ) +
1107 " in 2 seconds" )
1108 time.sleep( 2 )
1109 elif ping == main.FALSE:
1110 main.log.report( "All ping attempts between h" +
1111 str( i ) +
1112 " and h" +
1113 str( i +
1114 10 ) +
1115 "have failed" )
1116 i = 19
shahshreyaf3076352015-01-23 13:52:01 -08001117 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001118 elif ping == main.TRUE:
1119 main.log.info( "Ping test between h" +
1120 str( i ) +
1121 " and h" +
1122 str( i +
1123 10 ) +
1124 "passed!" )
1125 i += 1
shahshreyaf3076352015-01-23 13:52:01 -08001126 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001127 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001128 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -08001129 PingResult = main.ERROR
1130 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001131 main.log.report(
1132 "Ping all test after Point intents addition failed. Cleaning up" )
1133 # main.cleanup()
1134 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -08001135 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001136 main.log.report(
1137 "Ping all test after Point intents addition successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001138
shahshreyaf3076352015-01-23 13:52:01 -08001139 case8Result = PingResult
1140 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001141 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001142 actual=case8Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001143 onpass="Ping all test after Point intents addition successful",
1144 onfail="Ping all test after Point intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001145
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001146 def CASE31( self ):
1147 """
1148 This test case adds point intent related to SDN-IP matching on ICMP ( ethertype=IPV4, ipProto=1 )
1149 """
shahshreyae6c7cf42014-11-26 16:39:01 -08001150 import json
1151
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001152 main.log.report(
1153 "This test case adds point intent related to SDN-IP matching on ICMP" )
1154 main.case(
1155 "Adding bidirectional point intent related to SDN-IP matching on ICMP" )
1156 main.step( "Adding bidirectional point intent" )
1157 # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1158 # --ethType=IPV4 --ipProto=1 of:0000000000003008/1
1159 # of:0000000000006018/1
1160
shahshreyaf3076352015-01-23 13:52:01 -08001161 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001162 for i in range( 8, 11 ):
1163 main.log.info(
1164 "Adding point intent between h" + str( i ) + " and h" + str( i + 10 ) )
1165 host1 = "00:00:00:00:00:" + \
1166 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1167 host2 = "00:00:00:00:00:" + \
1168 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
shahshreyaf3076352015-01-23 13:52:01 -08001169 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1170 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1171 for host in hostsJson:
1172 if host[ 'id' ] == host1Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001173 ip1 = host[ 'ips' ][ 0 ]
1174 ip1 = str( ip1 + "/32" )
1175 device1 = host[ 'location' ][ 'device' ]
1176 device1 = str( device1 + "/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001177 elif host[ 'id' ] == host2Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001178 ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
1179 device2 = host[ 'location' ][ "device" ]
1180 device2 = str( device2 + "/1" )
1181
shahshreyaf3076352015-01-23 13:52:01 -08001182 pIntentResult1 = main.ONOScli1.addPointIntent(
1183 ingressDevice=device1,
1184 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001185 ipSrc=ip1,
1186 ipDst=ip2,
1187 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1188 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1189
shahshreyaf3076352015-01-23 13:52:01 -08001190 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1191 main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001192
shahshreyaf3076352015-01-23 13:52:01 -08001193 pIntentResult2 = main.ONOScli1.addPointIntent(
1194 ingressDevice=device2,
1195 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001196 ipSrc=ip2,
1197 ipDst=ip1,
1198 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1199 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1200
shahshreyaf3076352015-01-23 13:52:01 -08001201 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1202 main.log.info( getIntentResult )
1203 if ( pIntentResult1 and pIntentResult2 ) == main.TRUE:
1204 #getIntentResult = main.ONOScli1.intents()
1205 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001206 main.log.info(
1207 "Point intent related to SDN-IP matching on ICMP install successful" )
1208
1209 time.sleep( 15 )
shahshreyaf3076352015-01-23 13:52:01 -08001210 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1211 main.log.info( "intents = " + getIntentResult )
1212 getFlowsResult = main.ONOScli1.flows()
1213 main.log.info( "flows = " + getFlowsResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001214
shahshreyae6c7cf42014-11-26 16:39:01 -08001215 count = 1
1216 i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001217 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001218 while i < 11:
1219 main.log.info(
1220 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1221 ping = main.Mininet1.pingHost(
1222 src="h" + str( i ), target="h" + str( i + 10 ) )
1223 if ping == main.FALSE and count < 3:
1224 count += 1
shahshreyae6c7cf42014-11-26 16:39:01 -08001225 #i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001226 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001227 main.log.report( "Ping between h" +
1228 str( i ) +
1229 " and h" +
1230 str( i +
1231 10 ) +
1232 " failed. Making attempt number " +
1233 str( count ) +
1234 " in 2 seconds" )
1235 time.sleep( 2 )
1236 elif ping == main.FALSE:
1237 main.log.report( "All ping attempts between h" +
1238 str( i ) +
1239 " and h" +
1240 str( i +
1241 10 ) +
1242 "have failed" )
1243 i = 19
shahshreyaf3076352015-01-23 13:52:01 -08001244 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001245 elif ping == main.TRUE:
1246 main.log.info( "Ping test between h" +
1247 str( i ) +
1248 " and h" +
1249 str( i +
1250 10 ) +
1251 "passed!" )
1252 i += 1
shahshreyaf3076352015-01-23 13:52:01 -08001253 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -08001254 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001255 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -08001256 PingResult = main.ERROR
1257 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001258 main.log.report(
1259 "Ping test after Point intents related to SDN-IP matching on ICMP failed." )
1260 # main.cleanup()
1261 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -08001262 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001263 main.log.report(
1264 "Ping all test after Point intents related to SDN-IP matching on ICMP successful" )
1265
shahshreyaf3076352015-01-23 13:52:01 -08001266 case31Result = PingResult and pIntentResult1 and pIntentResult2
1267 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001268 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001269 actual=case31Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001270 onpass="Point intent related to SDN-IP matching on ICMP and ping test successful",
1271 onfail="Point intent related to SDN-IP matching on ICMP and ping test failed" )
1272
1273 def CASE32( self ):
1274 """
1275 This test case adds point intent related to SDN-IP matching on TCP ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 )
shahshreyae6c7cf42014-11-26 16:39:01 -08001276 Note: Although BGP port is 179, we are using 5001 because iperf is used for verifying and iperf's default port is 5001
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001277 """
shahshreyae6c7cf42014-11-26 16:39:01 -08001278 import json
1279
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001280 main.log.report(
1281 "This test case adds point intent related to SDN-IP matching on TCP" )
1282 main.case(
1283 "Adding bidirectional point intent related to SDN-IP matching on TCP" )
1284 main.step( "Adding bidirectional point intent" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001285 """
1286 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1 of:0000000000006018/1
1287
1288 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001289
shahshreyae6c7cf42014-11-26 16:39:01 -08001290 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1 of:0000000000006018/1
1291
1292 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1 of:0000000000003008/1
1293
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001294 """
shahshreyaf3076352015-01-23 13:52:01 -08001295 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001296 for i in range( 8, 9 ):
1297 main.log.info(
1298 "Adding point intent between h" + str( i ) + " and h" + str( i + 10 ) )
1299 host1 = "00:00:00:00:00:" + \
1300 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1301 host2 = "00:00:00:00:00:" + \
1302 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
shahshreyaf3076352015-01-23 13:52:01 -08001303 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1304 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1305 for host in hostsJson:
1306 if host[ 'id' ] == host1Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001307 ip1 = host[ 'ips' ][ 0 ]
1308 ip1 = str( ip1 + "/32" )
1309 device1 = host[ 'location' ][ 'device' ]
1310 device1 = str( device1 + "/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001311 elif host[ 'id' ] == host2Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001312 ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
1313 device2 = host[ 'location' ][ "device" ]
1314 device2 = str( device2 + "/1" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001315
shahshreyaf3076352015-01-23 13:52:01 -08001316 pIntentResult1 = main.ONOScli1.addPointIntent(
1317 ingressDevice=device1,
1318 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001319 ipSrc=ip1,
1320 ipDst=ip2,
1321 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1322 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1323 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
shahshreyaf3076352015-01-23 13:52:01 -08001324 pIntentResult2 = main.ONOScli1.addPointIntent(
1325 ingressDevice=device2,
1326 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001327 ipSrc=ip2,
1328 ipDst=ip1,
1329 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1330 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1331 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
1332
shahshreyaf3076352015-01-23 13:52:01 -08001333 pIntentResult3 = main.ONOScli1.addPointIntent(
1334 ingressDevice=device1,
1335 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001336 ipSrc=ip1,
1337 ipDst=ip2,
1338 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1339 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1340 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
shahshreyaf3076352015-01-23 13:52:01 -08001341 pIntentResult4 = main.ONOScli1.addPointIntent(
1342 ingressDevice=device2,
1343 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001344 ipSrc=ip2,
1345 ipDst=ip1,
1346 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1347 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1348 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
shahshreyae6c7cf42014-11-26 16:39:01 -08001349
shahshreyaf3076352015-01-23 13:52:01 -08001350 pIntentResult = pIntentResult1 and pIntentResult2 and pIntentResult3 and pIntentResult4
1351 if pIntentResult == main.TRUE:
1352 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1353 main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001354 main.log.info(
1355 "Point intent related to SDN-IP matching on TCP install successful" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001356
shahshreyaf3076352015-01-23 13:52:01 -08001357 iperfResult = main.Mininet1.iperf( 'h8', 'h18' )
1358 if iperfResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001359 main.log.report( "iperf test successful" )
1360 else:
1361 main.log.report( "iperf test failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001362
shahshreyaf3076352015-01-23 13:52:01 -08001363 case32Result = pIntentResult and iperfResult
1364 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001365 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001366 actual=case32Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001367 onpass="Ping all test after Point intents addition related to SDN-IP on TCP match successful",
1368 onfail="Ping all test after Point intents addition related to SDN-IP on TCP match failed" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001369
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001370 def CASE33( self ):
1371 """
1372 This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and the action is to rewrite the mac address
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001373 Here the mac address to be rewritten is the mac address of the egress device
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001374 """
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001375 import json
1376 import time
1377
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001378 main.log.report(
1379 "This test case adds multipoint to singlepoint intent related to SDN-IP matching on destination ip and rewrite mac address action" )
1380 main.case(
1381 "Adding multipoint to singlepoint intent related to SDN-IP matching on destination ip" )
1382 main.step( "Adding bidirectional multipoint to singlepoint intent" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001383 """
1384 add-multi-to-single-intent --ipDst=10.0.3.0/24 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1 of:0000000000006018/1
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001385
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001386 add-multi-to-single-intent --ipDst=10.0.1.0/24 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1 of:0000000000003008/1
1387 """
1388 main.case(
1389 "Installing multipoint to single point intent with rewrite mac address" )
1390 main.step( "Uninstalling proxy arp app" )
1391 # Unistall onos-app-proxyarp app to disable reactive forwarding
shahshreyaf3076352015-01-23 13:52:01 -08001392 appUninstallResult1 = main.ONOScli1.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001393 "onos-app-proxyarp" )
shahshreyaf3076352015-01-23 13:52:01 -08001394 appUninstallResult2 = main.ONOScli2.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001395 "onos-app-proxyarp" )
shahshreyaf3076352015-01-23 13:52:01 -08001396 appUninstallResult3 = main.ONOScli3.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001397 "onos-app-proxyarp" )
1398 main.log.info( "onos-app-proxyarp uninstalled" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001399
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001400 main.step( "Changing ipaddress of hosts h8,h9 and h18" )
1401 main.Mininet1.changeIP(
1402 host='h8',
1403 intf='h8-eth0',
1404 newIP='10.0.1.1',
1405 newNetmask='255.255.255.0' )
1406 main.Mininet1.changeIP(
1407 host='h9',
1408 intf='h9-eth0',
1409 newIP='10.0.2.1',
1410 newNetmask='255.255.255.0' )
1411 main.Mininet1.changeIP(
1412 host='h10',
1413 intf='h10-eth0',
1414 newIP='10.0.3.1',
1415 newNetmask='255.255.255.0' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001416
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001417 main.step( "Changing default gateway of hosts h8,h9 and h18" )
1418 main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' )
1419 main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' )
1420 main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001421
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001422 main.step(
1423 "Assigning random mac address to the default gateways since proxyarp app is uninstalled" )
1424 main.Mininet1.addStaticMACAddress(
1425 host='h8',
1426 GW='10.0.1.254',
1427 macaddr='00:00:00:00:11:11' )
1428 main.Mininet1.addStaticMACAddress(
1429 host='h9',
1430 GW='10.0.2.254',
1431 macaddr='00:00:00:00:22:22' )
1432 main.Mininet1.addStaticMACAddress(
1433 host='h10',
1434 GW='10.0.3.254',
1435 macaddr='00:00:00:00:33:33' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001436
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001437 main.step( "Verify static gateway and MAC address assignment" )
1438 main.Mininet1.verifyStaticGWandMAC( host='h8' )
1439 main.Mininet1.verifyStaticGWandMAC( host='h9' )
1440 main.Mininet1.verifyStaticGWandMAC( host='h10' )
1441
1442 main.step( "Adding multipoint to singlepoint intent" )
shahshreyaf3076352015-01-23 13:52:01 -08001443 pIntentResult1 = main.ONOScli1.addMultipointToSinglepointIntent(
1444 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
1445 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
1446 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001447 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
1448 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
1449
shahshreyaf3076352015-01-23 13:52:01 -08001450 pIntentResult2 = main.ONOScli1.addMultipointToSinglepointIntent(
1451 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
1452 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ],
1453 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001454 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
1455 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
1456
shahshreyaf3076352015-01-23 13:52:01 -08001457 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1458 main.log.info( "intents = " + getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001459
1460 time.sleep( 10 )
shahshreyaf3076352015-01-23 13:52:01 -08001461 getFlowsResult = main.ONOScli1.flows( jsonFormat=False )
1462 main.log.info( "flows = " + getFlowsResult )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001463
1464 count = 1
1465 i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001466 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001467
1468 main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
1469 ping = main.Mininet1.pingHost(
1470 src="h" + str( i ), target="h" + str( i + 2 ) )
1471 if ping == main.FALSE and count < 3:
1472 count += 1
shahshreyaf3076352015-01-23 13:52:01 -08001473 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001474 main.log.report( "Ping between h" +
1475 str( i ) +
1476 " and h" +
1477 str( i +
1478 2 ) +
1479 " failed. Making attempt number " +
1480 str( count ) +
1481 " in 2 seconds" )
1482 time.sleep( 2 )
1483 elif ping == main.FALSE:
1484 main.log.report( "All ping attempts between h" +
1485 str( i ) +
1486 " and h" +
1487 str( i +
1488 10 ) +
1489 "have failed" )
shahshreyaf3076352015-01-23 13:52:01 -08001490 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001491 elif ping == main.TRUE:
1492 main.log.info( "Ping test between h" +
1493 str( i ) +
1494 " and h" +
1495 str( i +
1496 2 ) +
1497 "passed!" )
shahshreyaf3076352015-01-23 13:52:01 -08001498 PingResult = main.TRUE
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001499 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001500 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -08001501 PingResult = main.ERROR
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001502
shahshreyaf3076352015-01-23 13:52:01 -08001503 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001504 main.log.report( "Ping test failed." )
1505 # main.cleanup()
1506 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -08001507 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001508 main.log.report( "Ping all successful" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001509
shahshreyaf3076352015-01-23 13:52:01 -08001510 pIntentResult = pIntentResult1 and pIntentResult2
1511 if pIntentResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001512 main.log.info(
1513 "Multi point intent with rewrite mac address installation successful" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001514 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001515 main.log.info(
1516 "Multi point intent with rewrite mac address installation failed" )
1517
shahshreyaf3076352015-01-23 13:52:01 -08001518 case33Result = pIntentResult and PingResult
1519 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001520 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001521 actual=case33Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001522 onpass="Ping all test after multipoint to single point intent addition with rewrite mac address successful",
1523 onfail="Ping all test after multipoint to single point intent addition with rewrite mac address failed" )