blob: ea61a259201d0f4d75b32b86f879d0df71aae236 [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 )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080047 # cellResult2 = main.ONOScli1.setCell( cellName )
48 # cellResult3 = main.ONOScli2.setCell( cellName )
49 # cellResult4 = main.ONOScli3.setCell( cellName )
shahshreyaf3076352015-01-23 13:52:01 -080050 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()
kelvin-onlabcf33bda2015-01-23 16:54:17 -080065 # 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-onlabcf33bda2015-01-23 16:54:17 -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 )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080084 onosInstallResult = onos1InstallResult and onos2InstallResult and\
85 onos3InstallResult
shahshreyaf3076352015-01-23 13:52:01 -080086 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
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -0800101 startResult = main.TRUE
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800102 # startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreyaf3076352015-01-23 13:52:01 -0800103 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
shahshreyaf3076352015-01-23 13:52:01 -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:
shahshreyaf3076352015-01-23 13:52:01 -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 """
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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 """
shahshreyaf3076352015-01-23 13:52:01 -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"
shahshreyaf3076352015-01-23 13:52:01 -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"
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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 )
shahshreyaf3076352015-01-23 13:52:01 -0800190 main.Mininet1.assignSwController(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800191 sw=str( i ),
192 count=3,
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -0800200 switchMastership = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800201 for i in range( 1, 29 ):
shahshreyaf3076352015-01-23 13:52:01 -0800202 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800203 print( "Response is " + str( response ) )
shahshreyaf3076352015-01-23 13:52:01 -0800204 if re.search( "tcp:" + ONOS1Ip, response ):
205 switchMastership = switchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800206 else:
shahshreyaf3076352015-01-23 13:52:01 -0800207 switchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800208
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -0800215 pingResult = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800216 time1 = time.time()
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -0800230 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800231 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -0800344 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800345 main.step( "Compare ONOS Topology to MN Topology" )
346
shahshreyaf3076352015-01-23 13:52:01 -0800347 switchesResults1 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800348 MNTopo,
349 json.loads( devices1 ) )
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -0800355 switchesResults2 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800356 MNTopo,
357 json.loads( devices2 ) )
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -0800362 switchesResults3 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800363 MNTopo,
364 json.loads( devices3 ) )
shahshreyaf3076352015-01-23 13:52:01 -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 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800372 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 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800378 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 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800384 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 """
shahshreyaf3076352015-01-23 13:52:01 -0800388 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800389 MNTopo,
390 json.loads( links1 ) )
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -0800395 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800396 MNTopo,
397 json.loads( links2 ) )
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -0800402 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800403 MNTopo,
404 json.loads( links3 ) )
shahshreyaf3076352015-01-23 13:52:01 -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\
shahshreyaf3076352015-01-23 13:52:01 -0800411 # 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
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -0800436 appUninstallResult1 = main.ONOScli1.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800437 "onos-app-fwd" )
shahshreyaf3076352015-01-23 13:52:01 -0800438 appUninstallResult2 = main.ONOScli2.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800439 "onos-app-fwd" )
shahshreyaf3076352015-01-23 13:52:01 -0800440 appUninstallResult3 = main.ONOScli3.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800441 "onos-app-fwd" )
442 main.log.info( "onos-app-fwd uninstalled" )
shahshreyae6c7cf42014-11-26 16:39:01 -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 )
shahshreyae6c7cf42014-11-26 16:39:01 -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
shahshreyaf3076352015-01-23 13:52:01 -0800454 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800455 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800456 actual=case10Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800457 onpass="Reactive forwarding app uninstallation successful",
458 onfail="Reactive forwarding app uninstallation failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -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" )
shahshreyae6c7cf42014-11-26 16:39:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -0800531 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
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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()
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -0800570 case6Result = PingResult
571 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800572 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -0800579 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800580
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800651 if LinkDown == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800652 main.log.report( "Link Down discovered properly" )
shahshreyaf3076352015-01-23 13:52:01 -0800653 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800654 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800655 actual=LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800656 onpass="Link Down discovered properly",
657 onfail="Link down was not discovered in " +
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800669 if LinkUp == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800670 main.log.report( "Link up discovered properly" )
shahshreyaf3076352015-01-23 13:52:01 -0800671 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800672 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800673 actual=LinkUp,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800674 onpass="Link up discovered properly",
675 onfail="Link up was not discovered in " +
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -0800775 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800776 main.step( "Compare ONOS Topology to MN Topology" )
777
shahshreyaf3076352015-01-23 13:52:01 -0800778 switchesResults1 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800779 MNTopo,
780 json.loads( devices1 ) )
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -0800786 switchesResults2 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800787 MNTopo,
788 json.loads( devices2 ) )
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -0800793 switchesResults3 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800794 MNTopo,
795 json.loads( devices3 ) )
shahshreyaf3076352015-01-23 13:52:01 -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 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800803 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 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800809 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 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800815 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 """
shahshreyaf3076352015-01-23 13:52:01 -0800819 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800820 MNTopo,
821 json.loads( links1 ) )
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -0800826 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800827 MNTopo,
828 json.loads( links2 ) )
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -0800833 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800834 MNTopo,
835 json.loads( links3 ) )
shahshreyaf3076352015-01-23 13:52:01 -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\
shahshreyaf3076352015-01-23 13:52:01 -0800842 # 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
shahshreyaf3076352015-01-23 13:52:01 -0800849 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800850 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -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 """
shahshreyae6c7cf42014-11-26 16:39:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -0800865 intentResult = main.ONOScli1.intents( jsonFormat=False )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800866
shahshreyaf3076352015-01-23 13:52:01 -0800867 intentLinewise = intentResult.split( "\n" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800868 intentList = []
shahshreyaf3076352015-01-23 13:52:01 -0800869 for line in intentLinewise:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800870 if line.startswith( "id=" ):
871 intentList.append( line )
shahshreyae6c7cf42014-11-26 16:39:01 -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 )
shahshreyae6c7cf42014-11-26 16:39:01 -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:
shahshreyaf3076352015-01-23 13:52:01 -0800882 main.ONOScli1.removeIntent( intentId=id )
shahshreyae6c7cf42014-11-26 16:39:01 -0800883
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyae6c7cf42014-11-26 16:39:01 -0800888 i = 8
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -0800897 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800898 elif ping == main.FALSE:
899 i += 1
shahshreyaf3076352015-01-23 13:52:01 -0800900 PingResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800901 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800902 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -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.
shahshreyaf3076352015-01-23 13:52:01 -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()
shahshreyaf3076352015-01-23 13:52:01 -0800911 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800912 main.log.report( "Host intents have been withdrawn correctly" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800913
shahshreyaf3076352015-01-23 13:52:01 -0800914 case8Result = case8Result and PingResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800915
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -0800942 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800943 "of:0000000000003008/1",
944 "of:0000000000006018/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -0800948 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800949
shahshreyaf3076352015-01-23 13:52:01 -0800950 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800951 "of:0000000000006018/1",
952 "of:0000000000003008/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -0800961 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800962 "of:0000000000003009/1",
963 "of:0000000000006019/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -0800967 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800968
shahshreyaf3076352015-01-23 13:52:01 -0800969 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800970 "of:0000000000006019/1",
971 "of:0000000000003009/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -0800980 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800981 "of:0000000000003010/1",
982 "of:0000000000006020/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -0800986 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800987
shahshreyaf3076352015-01-23 13:52:01 -0800988 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800989 "of:0000000000006020/1",
990 "of:0000000000003010/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -0800999 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001000 "of:0000000000003011/1",
1001 "of:0000000000006021/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -08001005 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001006
shahshreyaf3076352015-01-23 13:52:01 -08001007 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001008 "of:0000000000006021/1",
1009 "of:0000000000003011/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -08001018 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001019 "of:0000000000003012/1",
1020 "of:0000000000006022/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -08001024 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001025
shahshreyaf3076352015-01-23 13:52:01 -08001026 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001027 "of:0000000000006022/1",
1028 "of:0000000000003012/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -08001037 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001038 "of:0000000000003013/1",
1039 "of:0000000000006023/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
shahshreyaf3076352015-01-23 13:52:01 -08001045 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001046 "of:0000000000006023/1",
1047 "of:0000000000003013/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -08001056 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001057 "of:0000000000003014/1",
1058 "of:0000000000006024/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -08001062 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001063
shahshreyaf3076352015-01-23 13:52:01 -08001064 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001065 "of:0000000000006024/1",
1066 "of:0000000000003014/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -08001075 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001076 "of:0000000000003015/1",
1077 "of:0000000000006025/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -08001081 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001082
shahshreyaf3076352015-01-23 13:52:01 -08001083 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001084 "of:0000000000006025/1",
1085 "of:0000000000003015/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -08001094 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001095 "of:0000000000003016/1",
1096 "of:0000000000006026/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -08001100 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001101
shahshreyaf3076352015-01-23 13:52:01 -08001102 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001103 "of:0000000000006026/1",
1104 "of:0000000000003016/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -08001113 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001114 "of:0000000000003017/1",
1115 "of:0000000000006027/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -08001119 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001120
shahshreyaf3076352015-01-23 13:52:01 -08001121 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001122 "of:0000000000006027/1",
1123 "of:0000000000003017/1" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -08001148 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
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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()
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -08001189 case8Result = PingResult
1190 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001191 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -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 """
shahshreyae6c7cf42014-11-26 16:39:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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()
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -08001244 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1245 main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001246
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -08001255 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1256 main.log.info( getIntentResult )
1257 if ( pIntentResult1 and pIntentResult2 ) == main.TRUE:
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001258 # getIntentResult = main.ONOScli1.intents()
shahshreyaf3076352015-01-23 13:52:01 -08001259 # 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 )
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -08001281 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
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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()
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -08001323 case31Result = PingResult and pIntentResult1 and pIntentResult2
1324 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001325 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001326 actual=case31Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001327 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 """
shahshreyaf3076352015-01-23 13:52:01 -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()
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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' ] )
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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' ] )
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -08001424 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
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -08001437 case32Result = pIntentResult and iperfResult
1438 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001439 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001440 actual=case32Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001441 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
shahshreyaf3076352015-01-23 13:52:01 -08001479 appUninstallResult1 = main.ONOScli1.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001480 "onos-app-proxyarp" )
shahshreyaf3076352015-01-23 13:52:01 -08001481 appUninstallResult2 = main.ONOScli2.featureUninstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001482 "onos-app-proxyarp" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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 )
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -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!" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -08001589 PingResult = main.ERROR
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001590
shahshreyaf3076352015-01-23 13:52:01 -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()
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -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
shahshreyaf3076352015-01-23 13:52:01 -08001608 case33Result = pIntentResult and PingResult
1609 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001610 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001611 actual=case33Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001612 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" )