blob: f45fdc5e6f98164eac56150e0925f255352e97ff [file] [log] [blame]
shahshreya4e13a062014-11-11 16:46:18 -08001
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08002# Testing the basic functionality of ONOS Next
3# For sanity and driver functionality excercises only.
shahshreya4e13a062014-11-11 16:46:18 -08004
5import time
6import sys
7import os
8import re
9import time
10import json
11
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080012time.sleep( 1 )
13
shahshreya74cca802015-02-26 12:24:01 -080014class MultiProd13:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080015
16 def __init__( self ):
shahshreya4e13a062014-11-11 16:46:18 -080017 self.default = ''
18
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080019 def CASE1( self, main ):
20 """
shahshreya4e13a062014-11-11 16:46:18 -080021 Startup sequence:
shahshreyae6c7cf42014-11-26 16:39:01 -080022 cell <name>
23 onos-verify-cell
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080024 onos-remove-raft-logs
shahshreya4e13a062014-11-11 16:46:18 -080025 git pull
26 mvn clean install
27 onos-package
shahshreya4e13a062014-11-11 16:46:18 -080028 onos-install -f
29 onos-wait-for-start
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080030 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -080031 cellName = main.params[ 'ENV' ][ 'cellName' ]
32 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
33 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
34 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
35 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
36 ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
37 ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080038
39 main.case( "Setting up test environment" )
40 main.log.report(
41 "This testcase is testing setting up test environment" )
42 main.log.report( "__________________________________" )
43
44 main.step( "Applying cell variable to environment" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080045 cellResult1 = main.ONOSbench.setCell( cellName )
46 # cellResult2 = main.ONOScli1.setCell( cellName )
47 # cellResult3 = main.ONOScli2.setCell( cellName )
48 # cellResult4 = main.ONOScli3.setCell( cellName )
49 verifyResult = main.ONOSbench.verifyCell()
50 cellResult = cellResult1
shahshreyae6c7cf42014-11-26 16:39:01 -080051
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080052 main.step( "Removing raft logs before a clen installation of ONOS" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080053 removeLogResult = main.ONOSbench.onosRemoveRaftLogs()
shahshreyae6c7cf42014-11-26 16:39:01 -080054
shahshreyab512cd02015-01-27 17:01:47 -080055 main.step( "Git checkout, pull and get version" )
56 #main.ONOSbench.gitCheckout( "master" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080057 gitPullResult = main.ONOSbench.gitPull()
shahshreya1db2e292015-02-05 16:35:32 -080058 main.log.info( "git_pull_result = " + str( gitPullResult ))
kelvin-onlabcf33bda2015-01-23 16:54:17 -080059 versionResult = main.ONOSbench.getVersion( report=True )
shahshreya4e13a062014-11-11 16:46:18 -080060
kelvin-onlabcf33bda2015-01-23 16:54:17 -080061 if gitPullResult == 1:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080062 main.step( "Using mvn clean & install" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080063 cleanInstallResult = main.ONOSbench.cleanInstall()
64 # cleanInstallResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -080065
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080066 main.step( "Creating ONOS package" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080067 packageResult = main.ONOSbench.onosPackage()
shahshreya4e13a062014-11-11 16:46:18 -080068
kelvin-onlabcf33bda2015-01-23 16:54:17 -080069 # main.step( "Creating a cell" )
70 # cellCreateResult = main.ONOSbench.createCellFile( **************
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080071 # )
shahshreya4e13a062014-11-11 16:46:18 -080072
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080073 main.step( "Installing ONOS package" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080074 onos1InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080075 options="-f",
kelvin-onlabcf33bda2015-01-23 16:54:17 -080076 node=ONOS1Ip )
77 onos2InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080078 options="-f",
kelvin-onlabcf33bda2015-01-23 16:54:17 -080079 node=ONOS2Ip )
80 onos3InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080081 options="-f",
kelvin-onlabcf33bda2015-01-23 16:54:17 -080082 node=ONOS3Ip )
83 onosInstallResult = onos1InstallResult and onos2InstallResult and\
84 onos3InstallResult
85 if onosInstallResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080086 main.log.report( "Installing ONOS package successful" )
shahshreya4e13a062014-11-11 16:46:18 -080087 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080088 main.log.report( "Installing ONOS package failed" )
89
kelvin-onlabcf33bda2015-01-23 16:54:17 -080090 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
91 onos2Isup = main.ONOSbench.isup( ONOS2Ip )
92 onos3Isup = main.ONOSbench.isup( ONOS3Ip )
93 onosIsup = onos1Isup and onos2Isup and onos3Isup
94 if onosIsup == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080095 main.log.report( "ONOS instances are up and ready" )
shahshreya4e13a062014-11-11 16:46:18 -080096 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080097 main.log.report( "ONOS instances may not be up" )
shahshreya4e13a062014-11-11 16:46:18 -080098
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080099 main.step( "Starting ONOS service" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800100 startResult = main.TRUE
101 # startResult = main.ONOSbench.onosStart( ONOS1Ip )
102 startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip )
103 startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip )
104 startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800105 print startcli1
106 print startcli2
107 print startcli3
shahshreya4e13a062014-11-11 16:46:18 -0800108
shahshreya1db2e292015-02-05 16:35:32 -0800109 # Starting the mininet using the old way
110 main.step( "Starting Mininet ..." )
111 netIsUp = main.Mininet1.startNet()
112 if netIsUp:
113 main.log.info("Mininet CLI is up")
114
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800115 case1Result = ( packageResult and
116 cellResult and verifyResult and onosInstallResult and
117 onosIsup and startResult )
118 utilities.assertEquals( expect=main.TRUE, actual=case1Result,
119 onpass="Test startup successful",
120 onfail="Test startup NOT successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800121
122 def CASE11( self, main ):
123 """
shahshreya4e13a062014-11-11 16:46:18 -0800124 Cleanup sequence:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800125 onos-service <nodeIp> stop
shahshreya4e13a062014-11-11 16:46:18 -0800126 onos-uninstall
127
128 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800129
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800130 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800131 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
132 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
133 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
shahshreya4e13a062014-11-11 16:46:18 -0800134
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800135 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800136
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800137 main.step( "Testing ONOS kill function" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800138 killResult1 = main.ONOSbench.onosKill( ONOS1Ip )
139 killResult2 = main.ONOSbench.onosKill( ONOS2Ip )
140 killResult3 = main.ONOSbench.onosKill( ONOS3Ip )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800141
142 main.step( "Stopping ONOS service" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800143 stopResult1 = main.ONOSbench.onosStop( ONOS1Ip )
144 stopResult2 = main.ONOSbench.onosStop( ONOS2Ip )
145 stopResult3 = main.ONOSbench.onosStop( ONOS3Ip )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800146
147 main.step( "Uninstalling ONOS service" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800148 uninstallResult = main.ONOSbench.onosUninstall()
shahshreya4e13a062014-11-11 16:46:18 -0800149
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800150 def CASE3( self, main ):
151 """
shahshreya4e13a062014-11-11 16:46:18 -0800152 Test 'onos' command and its functionality in driver
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800153 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800154 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
155 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
156 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
shahshreya4e13a062014-11-11 16:46:18 -0800157
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800158 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800159
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800160 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800161 cmdstr1 = "system:name"
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800162 cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
163 main.log.info( "onos command returned: " + cmdResult1 )
164 cmdResult2 = main.ONOSbench.onosCli( ONOS2Ip, cmdstr1 )
165 main.log.info( "onos command returned: " + cmdResult2 )
166 cmdResult3 = main.ONOSbench.onosCli( ONOS3Ip, cmdstr1 )
167 main.log.info( "onos command returned: " + cmdResult3 )
shahshreya4e13a062014-11-11 16:46:18 -0800168
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800169 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800170 cmdstr2 = "onos:topology"
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800171 cmdResult4 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
172 main.log.info( "onos command returned: " + cmdResult4 )
173 cmdResult5 = main.ONOSbench.onosCli( ONOS2Ip, cmdstr2 )
174 main.log.info( "onos command returned: " + cmdResult5 )
175 cmdResult6 = main.ONOSbench.onosCli( ONOS6Ip, cmdstr2 )
176 main.log.info( "onos command returned: " + cmdResult6 )
shahshreya4e13a062014-11-11 16:46:18 -0800177
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800178 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800179 import re
180 import time
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800181 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
182 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
183 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
184 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
185 ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
186 ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800187
188 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800189 "This testcase is testing the assignment of all the switches" +
190 " to all controllers and discovering the hosts in reactive mode" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800191 main.log.report( "__________________________________" )
192 main.case( "Pingall Test(No intents are added)" )
193 main.step( "Assigning switches to controllers" )
194 for i in range( 1, 29 ): # 1 to ( num of switches +1 )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800195 main.Mininet1.assignSwController(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800196 sw=str( i ),
197 count=3,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800198 ip1=ONOS1Ip,
199 port1=ONOS1Port,
200 ip2=ONOS2Ip,
201 port2=ONOS2Port,
202 ip3=ONOS3Ip,
203 port3=ONOS3Port )
shahshreya4e13a062014-11-11 16:46:18 -0800204
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800205 switchMastership = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800206 for i in range( 1, 29 ):
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800207 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800208 print( "Response is " + str( response ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800209 if re.search( "tcp:" + ONOS1Ip, response ):
210 switchMastership = switchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800211 else:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800212 switchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800213
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800214 if switchMastership == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800215 main.log.report( "Controller assignment successfull" )
shahshreya4e13a062014-11-11 16:46:18 -0800216 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800217 main.log.report( "Controller assignment failed" )
shahshreyad524a942015-04-21 09:55:16 -0700218 appInstallResult = main.TRUE
219 main.log.info( "Activating reactive forwarding app" )
220 appInstallResult = main.ONOScli1.activateApp( "org.onosproject.fwd" )
221 appCheck = main.ONOScli1.appToIDCheck()
222 if appCheck != main.TRUE:
223 main.log.warn( main.ONOScli1.apps() )
224 main.log.warn( main.ONOScli1.appIDs() )
225 time.sleep( 30 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800226 # REACTIVE FWD test
227 main.step( "Pingall" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800228 pingResult = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800229 time1 = time.time()
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800230 pingResult = main.Mininet1.pingall()
shahshreya4e13a062014-11-11 16:46:18 -0800231 time2 = time.time()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800232 print "Time for pingall: %2f seconds" % ( time2 - time1 )
233
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800234 case4Result = switchMastership and pingResult
235 if pingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800236 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800237 "Pingall Test in reactive mode to" +
238 " discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800239 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800240 main.log.report(
241 "Pingall Test in reactive mode to discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800242
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800243 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800244 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800245 actual=case4Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800246 onpass="Controller assignment and Pingall Test successful",
247 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800248
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800249 def CASE5( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800250 import json
251 from subprocess import Popen, PIPE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800252 # assumes that sts is already in you PYTHONPATH
253 from sts.topology.teston_topology import TestONTopology
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800254 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
255 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
256 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800257
258 main.log.report(
shahshreyad524a942015-04-21 09:55:16 -0700259 "This testcase is testing if all ONOS nodes are in topology" +
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800260 " sync with mininet and its peer ONOS nodes" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800261 main.log.report( "__________________________________" )
262 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800263 "Testing Mininet topology with the" +
264 " topology of multi instances ONOS" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800265 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800266 devices1 = main.ONOScli1.devices()
267 devices2 = main.ONOScli2.devices()
268 devices3 = main.ONOScli3.devices()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800269 # print "devices1 = ", devices1
270 # print "devices2 = ", devices2
271 # print "devices3 = ", devices3
shahshreya4e13a062014-11-11 16:46:18 -0800272 hosts1 = main.ONOScli1.hosts()
273 hosts2 = main.ONOScli2.hosts()
274 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800275 # print "hosts1 = ", hosts1
276 # print "hosts2 = ", hosts2
277 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800278 ports1 = main.ONOScli1.ports()
279 ports2 = main.ONOScli2.ports()
280 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800281 # print "ports1 = ", ports1
282 # print "ports2 = ", ports2
283 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800284 links1 = main.ONOScli1.links()
285 links2 = main.ONOScli2.links()
286 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800287 # print "links1 = ", links1
288 # print "links2 = ", links2
289 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800290
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800291 print "**************"
292
293 main.step( "Start continuous pings" )
294 main.Mininet2.pingLong(
295 src=main.params[ 'PING' ][ 'source1' ],
296 target=main.params[ 'PING' ][ 'target1' ],
297 pingTime=500 )
298 main.Mininet2.pingLong(
299 src=main.params[ 'PING' ][ 'source2' ],
300 target=main.params[ 'PING' ][ 'target2' ],
301 pingTime=500 )
302 main.Mininet2.pingLong(
303 src=main.params[ 'PING' ][ 'source3' ],
304 target=main.params[ 'PING' ][ 'target3' ],
305 pingTime=500 )
306 main.Mininet2.pingLong(
307 src=main.params[ 'PING' ][ 'source4' ],
308 target=main.params[ 'PING' ][ 'target4' ],
309 pingTime=500 )
310 main.Mininet2.pingLong(
311 src=main.params[ 'PING' ][ 'source5' ],
312 target=main.params[ 'PING' ][ 'target5' ],
313 pingTime=500 )
314 main.Mininet2.pingLong(
315 src=main.params[ 'PING' ][ 'source6' ],
316 target=main.params[ 'PING' ][ 'target6' ],
317 pingTime=500 )
318 main.Mininet2.pingLong(
319 src=main.params[ 'PING' ][ 'source7' ],
320 target=main.params[ 'PING' ][ 'target7' ],
321 pingTime=500 )
322 main.Mininet2.pingLong(
323 src=main.params[ 'PING' ][ 'source8' ],
324 target=main.params[ 'PING' ][ 'target8' ],
325 pingTime=500 )
326 main.Mininet2.pingLong(
327 src=main.params[ 'PING' ][ 'source9' ],
328 target=main.params[ 'PING' ][ 'target9' ],
329 pingTime=500 )
330 main.Mininet2.pingLong(
331 src=main.params[ 'PING' ][ 'source10' ],
332 target=main.params[ 'PING' ][ 'target10' ],
333 pingTime=500 )
334
335 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800336 global ctrls
337 ctrls = []
338 count = 1
339 while True:
340 temp = ()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800341 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
342 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
343 temp = temp + ( "ONOS" + str( count ), )
344 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
345 temp = temp + \
346 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
347 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800348 count = count + 1
349 else:
350 break
351 global MNTopo
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800352 Topo = TestONTopology(
353 main.Mininet1,
354 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800355 MNTopo = Topo
356
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800357 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800358 main.step( "Compare ONOS Topology to MN Topology" )
359
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800360 switchesResults1 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800361 MNTopo,
362 json.loads( devices1 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800363 print "switches_Result1 = ", switchesResults1
364 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
365 onpass="ONOS1 Switches view is correct",
366 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800367
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800368 switchesResults2 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800369 MNTopo,
370 json.loads( devices2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800371 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
372 onpass="ONOS2 Switches view is correct",
373 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800374
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800375 switchesResults3 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800376 MNTopo,
377 json.loads( devices3 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800378 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
379 onpass="ONOS3 Switches view is correct",
380 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800381
382 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800383 portsResults1 = main.Mininet1.comparePorts( MNTopo,
384 json.loads( ports1 ) )
385 utilities.assertEquals( expect=main.TRUE, actual=portsResults1,
shahshreya4e13a062014-11-11 16:46:18 -0800386 onpass="ONOS1 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800387 onfail="ONOS1 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800388
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800389 portsResults2 = main.Mininet1.comparePorts( MNTopo,
390 json.loads( ports2 ) )
391 utilities.assertEquals( expect=main.TRUE, actual=portsResults2,
shahshreya4e13a062014-11-11 16:46:18 -0800392 onpass="ONOS2 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800393 onfail="ONOS2 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800394
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800395 portsResults3 = main.Mininet1.comparePorts( MNTopo,
396 json.loads( ports3 ) )
397 utilities.assertEquals( expect=main.TRUE, actual=portsResults3,
shahshreya4e13a062014-11-11 16:46:18 -0800398 onpass="ONOS3 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800399 onfail="ONOS3 Ports view is incorrect" )
400 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800401 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800402 MNTopo,
403 json.loads( links1 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800404 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
405 onpass="ONOS1 Links view is correct",
406 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800407
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800408 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800409 MNTopo,
410 json.loads( links2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800411 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
412 onpass="ONOS2 Links view is correct",
413 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800414
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800415 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800416 MNTopo,
417 json.loads( links3 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800418 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
419 onpass="ONOS2 Links view is correct",
420 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800421
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800422 # topoResult = switchesResults1 and switchesResults2
423 # and switchesResults3\
424 # and portsResults1 and portsResults2 and portsResults3\
425 # and linksResults1 and linksResults2 and linksResults3
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800426
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800427 topoResult = switchesResults1 and switchesResults2 and\
428 switchesResults3 and linksResults1 and linksResults2 and\
429 linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800430
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800431 if topoResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800432 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800433 "Topology Check Test with mininet" +
434 "and ONOS instances successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800435 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800436 main.log.report(
437 "Topology Check Test with mininet and ONOS instances failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800438
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800439 utilities.assertEquals( expect=main.TRUE, actual=topoResult,
440 onpass="Topology Check Test successful",
441 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800442
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800443 def CASE10( self ):
444 main.log.report(
445 "This testcase uninstalls the reactive forwarding app" )
446 main.log.report( "__________________________________" )
447 main.case( "Uninstalling reactive forwarding app" )
448 # Unistall onos-app-fwd app to disable reactive forwarding
shahshreyad524a942015-04-21 09:55:16 -0700449 appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.fwd" )
450 appCheck = main.ONOScli1.appToIDCheck()
451 if appCheck != main.TRUE:
452 main.log.warn( main.ONOScli1.apps() )
453 main.log.warn( main.ONOScli1.appIDs() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800454 main.log.info( "onos-app-fwd uninstalled" )
shahshreyaa9d79f22014-11-18 15:41:29 -0800455
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800456 # After reactive forwarding is disabled,
457 # the reactive flows on switches timeout in 10-15s
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800458 # So sleep for 15s
459 time.sleep( 15 )
shahshreyaa9d79f22014-11-18 15:41:29 -0800460
shahshreyae6c7cf42014-11-26 16:39:01 -0800461 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800462 main.log.info( hosts )
shahshreyad524a942015-04-21 09:55:16 -0700463 case10Result = appInstallResult
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800464 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800465 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800466 actual=case10Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800467 onpass="Reactive forwarding app uninstallation successful",
468 onfail="Reactive forwarding app uninstallation failed" )
shahshreyaa9d79f22014-11-18 15:41:29 -0800469
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800470 def CASE6( self ):
471 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800472 "This testcase is testing the addition of" +
473 " host intents and then doing pingall" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800474 main.log.report( "__________________________________" )
475 main.case( "Obtaining hostsfor adding host intents" )
476 main.step( "Get hosts" )
shahshreyaeac353b2014-11-18 17:19:20 -0800477 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800478 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800479
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800480 main.step( "Get all devices id" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800481 devicesIdList = main.ONOScli1.getAllDevicesId()
482 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -0800483
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800484 # ONOS displays the hosts in hex format
485 # unlike mininet which does in decimal format
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800486 # So take care while adding intents
shahshreya4e13a062014-11-11 16:46:18 -0800487
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800488 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800489 main.step( "Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,
490 h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
491 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:08/-1",
492 "00:00:00:00:00:12/-1" )
493 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:09/-1",
494 "00:00:00:00:00:13/-1" )
495 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0A/-1",
496 "00:00:00:00:00:14/-1" )
497 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0B/-1",
498 "00:00:00:00:00:15/-1" )
499 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0C/-1",
500 "00:00:00:00:00:16/-1" )
501 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0D/-1",
502 "00:00:00:00:00:17/-1" )
503 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0E/-1",
504 "00:00:00:00:00:18/-1" )
505 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0F/-1",
506 "00:00:00:00:00:19/-1" )
507 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:10/-1",
508 "00:00:00:00:00:1A/-1" )
509 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:11/-1",
510 "00:00:00:00:00:1B/-1" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800511 """
512 for i in range( 8, 18 ):
513 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800514 "Adding host intent between h" + str( i ) +
515 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800516 host1 = "00:00:00:00:00:" + \
517 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
518 host2 = "00:00:00:00:00:" + \
519 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
520 # NOTE: get host can return None
521 # TODO: handle this
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800522 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
523 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
524 tmpResult = main.ONOScli1.addHostIntent( host1Id, host2Id )
shahshreya4e13a062014-11-11 16:46:18 -0800525
526 flowHandle = main.ONOScli1.flows()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800527 main.log.info( "flows:" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -0800528
529 count = 1
530 i = 8
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800531 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800532 while i < 18:
533 main.log.info(
534 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
535 ping = main.Mininet1.pingHost(
536 src="h" + str( i ), target="h" + str( i + 10 ) )
537 if ping == main.FALSE and count < 5:
538 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800539 # i = 8
540 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800541 main.log.report( "Ping between h" +
542 str( i ) +
543 " and h" +
544 str( i +
545 10 ) +
546 " failed. Making attempt number " +
547 str( count ) +
548 " in 2 seconds" )
549 time.sleep( 2 )
550 elif ping == main.FALSE:
551 main.log.report( "All ping attempts between h" +
552 str( i ) +
553 " and h" +
554 str( i +
555 10 ) +
556 "have failed" )
557 i = 19
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800558 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800559 elif ping == main.TRUE:
560 main.log.info( "Ping test between h" +
561 str( i ) +
562 " and h" +
563 str( i +
564 10 ) +
565 "passed!" )
566 i += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800567 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800568 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800569 main.log.info( "Unknown error" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800570 PingResult = main.ERROR
571 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800572 main.log.report(
573 "Host intents have not ben installed correctly. Cleaning up" )
574 # main.cleanup()
575 # main.exit()
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800576 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800577 main.log.report( "Host intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -0800578
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800579 case6Result = PingResult
580 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800581 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800582 actual=case6Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800583 onpass="Host intent addition and Pingall Test successful",
584 onfail="Host intent addition and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800585
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800586 def CASE7( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800587
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800588 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800589
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800590 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800591
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800592 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800593 "This testscase is killing a link to" +
594 " ensure that link discovery is consistent" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800595 main.log.report( "__________________________________" )
596 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800597 "Killing a link to Ensure that Link" +
598 " Discovery is Working Properly" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800599 main.step( "Start continuous pings" )
shahshreya4e13a062014-11-11 16:46:18 -0800600
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800601 main.Mininet2.pingLong(
602 src=main.params[ 'PING' ][ 'source1' ],
603 target=main.params[ 'PING' ][ 'target1' ],
604 pingTime=500 )
605 main.Mininet2.pingLong(
606 src=main.params[ 'PING' ][ 'source2' ],
607 target=main.params[ 'PING' ][ 'target2' ],
608 pingTime=500 )
609 main.Mininet2.pingLong(
610 src=main.params[ 'PING' ][ 'source3' ],
611 target=main.params[ 'PING' ][ 'target3' ],
612 pingTime=500 )
613 main.Mininet2.pingLong(
614 src=main.params[ 'PING' ][ 'source4' ],
615 target=main.params[ 'PING' ][ 'target4' ],
616 pingTime=500 )
617 main.Mininet2.pingLong(
618 src=main.params[ 'PING' ][ 'source5' ],
619 target=main.params[ 'PING' ][ 'target5' ],
620 pingTime=500 )
621 main.Mininet2.pingLong(
622 src=main.params[ 'PING' ][ 'source6' ],
623 target=main.params[ 'PING' ][ 'target6' ],
624 pingTime=500 )
625 main.Mininet2.pingLong(
626 src=main.params[ 'PING' ][ 'source7' ],
627 target=main.params[ 'PING' ][ 'target7' ],
628 pingTime=500 )
629 main.Mininet2.pingLong(
630 src=main.params[ 'PING' ][ 'source8' ],
631 target=main.params[ 'PING' ][ 'target8' ],
632 pingTime=500 )
633 main.Mininet2.pingLong(
634 src=main.params[ 'PING' ][ 'source9' ],
635 target=main.params[ 'PING' ][ 'target9' ],
636 pingTime=500 )
637 main.Mininet2.pingLong(
638 src=main.params[ 'PING' ][ 'source10' ],
639 target=main.params[ 'PING' ][ 'target10' ],
640 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -0800641
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800642 main.step( "Determine the current number of switches and links" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800643 topologyOutput = main.ONOScli1.topology()
644 topologyResult = main.ONOSbench.getTopology( topologyOutput )
shahshreyab471a3e2015-03-19 17:07:13 -0700645 activeSwitches = topologyResult[ 'deviceCount' ]
646 links = topologyResult[ 'linkCount' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800647 main.log.info(
648 "Currently there are %s switches and %s links" %
649 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -0800650
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800651 main.step( "Kill Link between s3 and s28" )
652 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800653 time.sleep( linkSleep )
654 topologyOutput = main.ONOScli2.topology()
655 LinkDown = main.ONOSbench.checkStatus(
656 topologyOutput, activeSwitches, str(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800657 int( links ) - 2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800658 if LinkDown == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800659 main.log.report( "Link Down discovered properly" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800660 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800661 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800662 actual=LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800663 onpass="Link Down discovered properly",
664 onfail="Link down was not discovered in " +
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800665 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800666 " seconds" )
shahshreya4e13a062014-11-11 16:46:18 -0800667
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800668 main.step( "Bring link between s3 and s28 back up" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800669 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
670 time.sleep( linkSleep )
671 topologyOutput = main.ONOScli2.topology()
672 LinkUp = main.ONOSbench.checkStatus(
673 topologyOutput,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800674 activeSwitches,
675 str( links ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800676 if LinkUp == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800677 main.log.report( "Link up discovered properly" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800678 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800679 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800680 actual=LinkUp,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800681 onpass="Link up discovered properly",
682 onfail="Link up was not discovered in " +
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800683 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800684 " seconds" )
685
686 main.step( "Compare ONOS Topology to MN Topology" )
687 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800688 "Testing Mininet topology with the" +
689 " topology of multi instances ONOS" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800690 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800691 devices1 = main.ONOScli1.devices()
692 devices2 = main.ONOScli2.devices()
693 devices3 = main.ONOScli3.devices()
694 print "devices1 = ", devices1
695 print "devices2 = ", devices2
696 print "devices3 = ", devices3
697 hosts1 = main.ONOScli1.hosts()
698 hosts2 = main.ONOScli2.hosts()
699 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800700 # print "hosts1 = ", hosts1
701 # print "hosts2 = ", hosts2
702 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800703 ports1 = main.ONOScli1.ports()
704 ports2 = main.ONOScli2.ports()
705 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800706 # print "ports1 = ", ports1
707 # print "ports2 = ", ports2
708 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800709 links1 = main.ONOScli1.links()
710 links2 = main.ONOScli2.links()
711 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800712 # print "links1 = ", links1
713 # print "links2 = ", links2
714 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800715
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800716 print "**************"
717
718 main.step( "Start continuous pings" )
719 main.Mininet2.pingLong(
720 src=main.params[ 'PING' ][ 'source1' ],
721 target=main.params[ 'PING' ][ 'target1' ],
722 pingTime=500 )
723 main.Mininet2.pingLong(
724 src=main.params[ 'PING' ][ 'source2' ],
725 target=main.params[ 'PING' ][ 'target2' ],
726 pingTime=500 )
727 main.Mininet2.pingLong(
728 src=main.params[ 'PING' ][ 'source3' ],
729 target=main.params[ 'PING' ][ 'target3' ],
730 pingTime=500 )
731 main.Mininet2.pingLong(
732 src=main.params[ 'PING' ][ 'source4' ],
733 target=main.params[ 'PING' ][ 'target4' ],
734 pingTime=500 )
735 main.Mininet2.pingLong(
736 src=main.params[ 'PING' ][ 'source5' ],
737 target=main.params[ 'PING' ][ 'target5' ],
738 pingTime=500 )
739 main.Mininet2.pingLong(
740 src=main.params[ 'PING' ][ 'source6' ],
741 target=main.params[ 'PING' ][ 'target6' ],
742 pingTime=500 )
743 main.Mininet2.pingLong(
744 src=main.params[ 'PING' ][ 'source7' ],
745 target=main.params[ 'PING' ][ 'target7' ],
746 pingTime=500 )
747 main.Mininet2.pingLong(
748 src=main.params[ 'PING' ][ 'source8' ],
749 target=main.params[ 'PING' ][ 'target8' ],
750 pingTime=500 )
751 main.Mininet2.pingLong(
752 src=main.params[ 'PING' ][ 'source9' ],
753 target=main.params[ 'PING' ][ 'target9' ],
754 pingTime=500 )
755 main.Mininet2.pingLong(
756 src=main.params[ 'PING' ][ 'source10' ],
757 target=main.params[ 'PING' ][ 'target10' ],
758 pingTime=500 )
759
760 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800761 global ctrls
762 ctrls = []
763 count = 1
764 while True:
765 temp = ()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800766 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
767 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
768 temp = temp + ( "ONOS" + str( count ), )
769 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
770 temp = temp + \
771 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
772 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800773 count = count + 1
774 else:
775 break
776 global MNTopo
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800777 Topo = TestONTopology(
778 main.Mininet1,
779 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800780 MNTopo = Topo
781
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800782 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800783 main.step( "Compare ONOS Topology to MN Topology" )
784
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800785 switchesResults1 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800786 MNTopo,
787 json.loads( devices1 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800788 print "switches_Result1 = ", switchesResults1
789 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
790 onpass="ONOS1 Switches view is correct",
791 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800792
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800793 switchesResults2 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800794 MNTopo,
795 json.loads( devices2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800796 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
797 onpass="ONOS2 Switches view is correct",
798 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800799
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800800 switchesResults3 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800801 MNTopo,
802 json.loads( devices3 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800803 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
804 onpass="ONOS3 Switches view is correct",
805 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800806
807 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800808 portsResults1 = main.Mininet1.comparePorts( MNTopo,
809 json.loads( ports1 ) )
810 utilities.assertEquals( expect=main.TRUE, actual=portsResults1,
shahshreya4e13a062014-11-11 16:46:18 -0800811 onpass="ONOS1 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800812 onfail="ONOS1 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800813
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800814 portsResults2 = main.Mininet1.comparePorts( MNTopo,
815 json.loads( ports2 ) )
816 utilities.assertEquals( expect=main.TRUE, actual=portsResults2,
shahshreya4e13a062014-11-11 16:46:18 -0800817 onpass="ONOS2 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800818 onfail="ONOS2 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800819
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800820 portsResults3 = main.Mininet1.comparePorts( MNTopo,
821 json.loads( ports3 ) )
822 utilities.assertEquals( expect=main.TRUE, actual=portsResults3,
shahshreya4e13a062014-11-11 16:46:18 -0800823 onpass="ONOS3 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800824 onfail="ONOS3 Ports view is incorrect" )
825 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800826 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800827 MNTopo,
828 json.loads( links1 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800829 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
830 onpass="ONOS1 Links view is correct",
831 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800832
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800833 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800834 MNTopo,
835 json.loads( links2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800836 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
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 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800841 MNTopo,
842 json.loads( links3 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800843 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
844 onpass="ONOS2 Links view is correct",
845 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800846
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800847 # topoResult = switchesResults1 and switchesResults2
848 # and switchesResults3\
849 # and portsResults1 and portsResults2 and portsResults3\
850 # and linksResults1 and linksResults2 and linksResults3
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800851
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800852 topoResult = switchesResults1 and switchesResults2\
853 and switchesResults3 and linksResults1 and\
854 linksResults2 and linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800855
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800856 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800857 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800858 actual=topoResult and LinkUp and LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800859 onpass="Topology Check Test successful",
860 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800861
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800862 def CASE8( self ):
863 """
shahshreyaeac353b2014-11-18 17:19:20 -0800864 Intent removal
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800865 """
866 main.log.report(
shahshreyab512cd02015-01-27 17:01:47 -0800867 "This testcase removes any previously added intents" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800868 main.log.report( "__________________________________" )
869 main.log.info( "Removing any previously installed intents" )
870 main.case( "Removing intents" )
871 main.step( "Obtain the intent id's" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800872 intentResult = main.ONOScli1.intents( jsonFormat=False )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800873
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800874 intentLinewise = intentResult.split( "\n" )
shahshreyaa9d79f22014-11-18 15:41:29 -0800875 intentList = []
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800876 for line in intentLinewise:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800877 if line.startswith( "id=" ):
878 intentList.append( line )
shahshreyaa9d79f22014-11-18 15:41:29 -0800879
880 intentids = []
881 for line in intentList:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800882 intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
shahshreya4e13a062014-11-11 16:46:18 -0800883 for id in intentids:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800884 main.log.info( "id = " + id )
shahshreyaa9d79f22014-11-18 15:41:29 -0800885
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800886 main.step(
887 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -0800888 for id in intentids:
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800889 main.ONOScli1.removeIntent( intentId=id )
shahshreyaa9d79f22014-11-18 15:41:29 -0800890
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800891 intentResult = main.ONOScli1.intents( jsonFormat=False )
892 main.log.info( "intent_result = " + intentResult )
893 case8Result = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800894
shahshreyaeac353b2014-11-18 17:19:20 -0800895 i = 8
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800896 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800897 while i < 18:
898 main.log.info(
899 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
900 ping = main.Mininet1.pingHost(
901 src="h" + str( i ), target="h" + str( i + 10 ) )
902 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -0800903 i = 19
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800904 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800905 elif ping == main.FALSE:
906 i += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800907 PingResult = main.FALSE
shahshreyaeac353b2014-11-18 17:19:20 -0800908 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800909 main.log.info( "Unknown error" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800910 PingResult = main.ERROR
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800911
912 # Note: If the ping result failed, that means the intents have been
913 # withdrawn correctly.
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800914 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800915 main.log.report( "Host intents have not been withdrawn correctly" )
916 # main.cleanup()
917 # main.exit()
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800918 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800919 main.log.report( "Host intents have been withdrawn correctly" )
shahshreyaeac353b2014-11-18 17:19:20 -0800920
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800921 case8Result = case8Result and PingResult
shahshreyaeac353b2014-11-18 17:19:20 -0800922
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800923 if case8Result == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800924 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800925 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800926 main.log.report( "Intent removal failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800927
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800928 utilities.assertEquals( expect=main.FALSE, actual=case8Result,
929 onpass="Intent removal test failed",
930 onfail="Intent removal test successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800931
932 def CASE9( self ):
933 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800934 This test case adds point intents. Make sure you run test case 8
935 which is host intent removal before executing this test case.
936 Else the host intent's flows will persist on switches and the pings
937 would work even if there is some issue with the point intent's flows
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800938 """
939 main.log.report(
940 "This testcase adds point intents and then does pingall" )
941 main.log.report( "__________________________________" )
942 main.log.info( "Adding point intents" )
943 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800944 "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20," +
945 "h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800946 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800947 "Add point-to-point intents for mininet hosts" +
948 " h8 and h18 or ONOS hosts h8 and h12" )
949 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800950 "of:0000000000003008/1",
951 "of:0000000000006018/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800952 if ptpIntentResult == main.TRUE:
953 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800954 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800955 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800956
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800957 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800958 "of:0000000000006018/1",
959 "of:0000000000003008/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -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" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800963 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800964
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800965 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800966 "Add point-to-point intents for mininet hosts" +
967 " h9 and h19 or ONOS hosts h9 and h13" )
968 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800969 "of:0000000000003009/1",
970 "of:0000000000006019/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800971 if ptpIntentResult == main.TRUE:
972 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800973 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800974 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800975
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800976 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800977 "of:0000000000006019/1",
978 "of:0000000000003009/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800979 if ptpIntentResult == main.TRUE:
980 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800981 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800982 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800983
984 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800985 "Add point-to-point intents for mininet" +
986 " hosts h10 and h20 or ONOS hosts hA and h14" )
987 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800988 "of:0000000000003010/1",
989 "of:0000000000006020/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800990 if ptpIntentResult == main.TRUE:
991 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800992 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800993 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800994
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800995 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800996 "of:0000000000006020/1",
997 "of:0000000000003010/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800998 if ptpIntentResult == main.TRUE:
999 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001000 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001001 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001002
1003 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001004 "Add point-to-point intents for mininet" +
1005 " hosts h11 and h21 or ONOS hosts hB and h15" )
1006 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001007 "of:0000000000003011/1",
1008 "of:0000000000006021/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001009 if ptpIntentResult == main.TRUE:
1010 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001011 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001012 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001013
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001014 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001015 "of:0000000000006021/1",
1016 "of:0000000000003011/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001017 if ptpIntentResult == main.TRUE:
1018 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001019 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001020 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001021
1022 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001023 "Add point-to-point intents for mininet" +
1024 " hosts h12 and h22 or ONOS hosts hC and h16" )
1025 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001026 "of:0000000000003012/1",
1027 "of:0000000000006022/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001028 if ptpIntentResult == main.TRUE:
1029 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001030 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001031 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001032
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001033 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001034 "of:0000000000006022/1",
1035 "of:0000000000003012/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001036 if ptpIntentResult == main.TRUE:
1037 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001038 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001039 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001040
1041 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001042 "Add point-to-point intents for mininet " +
1043 "hosts h13 and h23 or ONOS hosts hD and h17" )
1044 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001045 "of:0000000000003013/1",
1046 "of:0000000000006023/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001047 if ptpIntentResult == main.TRUE:
1048 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001049 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001050 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001051
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001052 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001053 "of:0000000000006023/1",
1054 "of:0000000000003013/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001055 if ptpIntentResult == main.TRUE:
1056 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001057 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001058 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001059
1060 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001061 "Add point-to-point intents for mininet hosts" +
1062 " h14 and h24 or ONOS hosts hE and h18" )
1063 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001064 "of:0000000000003014/1",
1065 "of:0000000000006024/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001066 if ptpIntentResult == main.TRUE:
1067 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001068 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001069 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001070
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001071 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001072 "of:0000000000006024/1",
1073 "of:0000000000003014/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001074 if ptpIntentResult == main.TRUE:
1075 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001076 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001077 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001078
1079 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001080 "Add point-to-point intents for mininet hosts" +
1081 " h15 and h25 or ONOS hosts hF and h19" )
1082 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001083 "of:0000000000003015/1",
1084 "of:0000000000006025/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001085 if ptpIntentResult == main.TRUE:
1086 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001087 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001088 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001089
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001090 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001091 "of:0000000000006025/1",
1092 "of:0000000000003015/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001093 if ptpIntentResult == main.TRUE:
1094 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001095 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001096 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001097
1098 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001099 "Add point-to-point intents for mininet hosts" +
1100 " h16 and h26 or ONOS hosts h10 and h1A" )
1101 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001102 "of:0000000000003016/1",
1103 "of:0000000000006026/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001104 if ptpIntentResult == main.TRUE:
1105 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001106 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001107 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001108
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001109 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001110 "of:0000000000006026/1",
1111 "of:0000000000003016/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001112 if ptpIntentResult == main.TRUE:
1113 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001114 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001115 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001116
1117 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001118 "Add point-to-point intents for mininet hosts h17" +
1119 " and h27 or ONOS hosts h11 and h1B" )
1120 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001121 "of:0000000000003017/1",
1122 "of:0000000000006027/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001123 if ptpIntentResult == main.TRUE:
1124 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001125 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001126 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001127
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001128 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001129 "of:0000000000006027/1",
1130 "of:0000000000003017/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001131 if ptpIntentResult == main.TRUE:
1132 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001133 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001134 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001135
1136 print(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001137 "_______________________________________________________" +
1138 "________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001139
1140 flowHandle = main.ONOScli1.flows()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001141 # print "flowHandle = ", flowHandle
1142 main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001143
1144 count = 1
1145 i = 8
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001146 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001147 while i < 18:
1148 main.log.info(
1149 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1150 ping = main.Mininet1.pingHost(
1151 src="h" + str( i ), target="h" + str( i + 10 ) )
1152 if ping == main.FALSE and count < 5:
1153 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001154 # i = 8
1155 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001156 main.log.report( "Ping between h" +
1157 str( i ) +
1158 " and h" +
1159 str( i +
1160 10 ) +
1161 " failed. Making attempt number " +
1162 str( count ) +
1163 " in 2 seconds" )
1164 time.sleep( 2 )
1165 elif ping == main.FALSE:
1166 main.log.report( "All ping attempts between h" +
1167 str( i ) +
1168 " and h" +
1169 str( i +
1170 10 ) +
1171 "have failed" )
1172 i = 19
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001173 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001174 elif ping == main.TRUE:
1175 main.log.info( "Ping test between h" +
1176 str( i ) +
1177 " and h" +
1178 str( i +
1179 10 ) +
1180 "passed!" )
1181 i += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001182 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001183 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001184 main.log.info( "Unknown error" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001185 PingResult = main.ERROR
1186 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001187 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001188 "Ping all test after Point intents" +
1189 " addition failed. Cleaning up" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001190 # main.cleanup()
1191 # main.exit()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001192 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001193 main.log.report(
1194 "Ping all test after Point intents addition successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001195
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001196 case8Result = PingResult
1197 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001198 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001199 actual=case8Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001200 onpass="Ping all test after Point intents addition successful",
1201 onfail="Ping all test after Point intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001202
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001203 def CASE31( self ):
1204 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001205 This test case adds point intent related to
1206 SDN-IP matching on ICMP ( ethertype=IPV4, ipProto=1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001207 """
shahshreyaa9d79f22014-11-18 15:41:29 -08001208 import json
1209
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001210 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001211 "This test case adds point intent " +
1212 "related to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001213 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001214 "Adding bidirectional point intent related" +
1215 " to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001216 main.step( "Adding bidirectional point intent" )
1217 # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1218 # --ethType=IPV4 --ipProto=1 of:0000000000003008/1
1219 # of:0000000000006018/1
1220
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001221 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001222 for i in range( 8, 11 ):
1223 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001224 "Adding point intent between h" + str( i ) +
1225 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001226 host1 = "00:00:00:00:00:" + \
1227 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1228 host2 = "00:00:00:00:00:" + \
1229 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001230 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1231 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1232 for host in hostsJson:
1233 if host[ 'id' ] == host1Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001234 ip1 = host[ 'ips' ][ 0 ]
1235 ip1 = str( ip1 + "/32" )
1236 device1 = host[ 'location' ][ 'device' ]
1237 device1 = str( device1 + "/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001238 elif host[ 'id' ] == host2Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001239 ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
1240 device2 = host[ 'location' ][ "device" ]
1241 device2 = str( device2 + "/1" )
1242
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001243 pIntentResult1 = main.ONOScli1.addPointIntent(
1244 ingressDevice=device1,
1245 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001246 ipSrc=ip1,
1247 ipDst=ip2,
1248 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1249 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1250
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001251 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1252 main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001253
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001254 pIntentResult2 = main.ONOScli1.addPointIntent(
1255 ingressDevice=device2,
1256 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001257 ipSrc=ip2,
1258 ipDst=ip1,
1259 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1260 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1261
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001262 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1263 main.log.info( getIntentResult )
1264 if ( pIntentResult1 and pIntentResult2 ) == main.TRUE:
1265 # getIntentResult = main.ONOScli1.intents()
1266 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001267 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001268 "Point intent related to SDN-IP matching" +
1269 " on ICMP install successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001270
1271 time.sleep( 15 )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001272 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1273 main.log.info( "intents = " + getIntentResult )
1274 getFlowsResult = main.ONOScli1.flows()
1275 main.log.info( "flows = " + getFlowsResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001276
shahshreyae6c7cf42014-11-26 16:39:01 -08001277 count = 1
1278 i = 8
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001279 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001280 while i < 11:
1281 main.log.info(
1282 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1283 ping = main.Mininet1.pingHost(
1284 src="h" + str( i ), target="h" + str( i + 10 ) )
1285 if ping == main.FALSE and count < 3:
1286 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001287 # i = 8
1288 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001289 main.log.report( "Ping between h" +
1290 str( i ) +
1291 " and h" +
1292 str( i +
1293 10 ) +
1294 " failed. Making attempt number " +
1295 str( count ) +
1296 " in 2 seconds" )
1297 time.sleep( 2 )
1298 elif ping == main.FALSE:
1299 main.log.report( "All ping attempts between h" +
1300 str( i ) +
1301 " and h" +
1302 str( i +
1303 10 ) +
1304 "have failed" )
1305 i = 19
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001306 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001307 elif ping == main.TRUE:
1308 main.log.info( "Ping test between h" +
1309 str( i ) +
1310 " and h" +
1311 str( i +
1312 10 ) +
1313 "passed!" )
1314 i += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001315 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -08001316 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001317 main.log.info( "Unknown error" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001318 PingResult = main.ERROR
1319 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001320 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001321 "Ping test after Point intents related to" +
1322 " SDN-IP matching on ICMP failed." )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001323 # main.cleanup()
1324 # main.exit()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001325 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001326 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001327 "Ping all test after Point intents related to" +
1328 " SDN-IP matching on ICMP successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001329
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001330 case31Result = PingResult and pIntentResult1 and pIntentResult2
1331 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001332 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001333 actual=case31Result,
1334 onpass="Point intent related to SDN-IP " +
1335 "matching on ICMP and ping test successful",
1336 onfail="Point intent related to SDN-IP" +
1337 " matching on ICMP and ping test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001338
1339 def CASE32( self ):
1340 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001341 This test case adds point intent related to SDN-IP matching on TCP
1342 ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 )
1343 Note: Although BGP port is 179, we are using 5001 because iperf
1344 is used for verifying and iperf's default port is 5001
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001345 """
shahshreyae6c7cf42014-11-26 16:39:01 -08001346 import json
1347
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001348 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001349 "This test case adds point intent" +
1350 " related to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001351 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001352 "Adding bidirectional point intent related" +
1353 " to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001354 main.step( "Adding bidirectional point intent" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001355 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001356 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1357 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1
1358 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001359
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001360 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1361 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1
1362 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001363
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001364 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1365 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1
1366 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001367
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001368 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1369 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1
1370 of:0000000000003008/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001371
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001372 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001373 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001374 for i in range( 8, 9 ):
1375 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001376 "Adding point intent between h" + str( i ) +
1377 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001378 host1 = "00:00:00:00:00:" + \
1379 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1380 host2 = "00:00:00:00:00:" + \
1381 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001382 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1383 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1384 for host in hostsJson:
1385 if host[ 'id' ] == host1Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001386 ip1 = host[ 'ips' ][ 0 ]
1387 ip1 = str( ip1 + "/32" )
1388 device1 = host[ 'location' ][ 'device' ]
1389 device1 = str( device1 + "/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001390 elif host[ 'id' ] == host2Id:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001391 ip2 = str( host[ 'ips' ][ 0 ] ) + "/32"
1392 device2 = host[ 'location' ][ "device" ]
1393 device2 = str( device2 + "/1" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001394
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001395 pIntentResult1 = main.ONOScli1.addPointIntent(
1396 ingressDevice=device1,
1397 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001398 ipSrc=ip1,
1399 ipDst=ip2,
1400 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1401 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1402 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001403 pIntentResult2 = main.ONOScli1.addPointIntent(
1404 ingressDevice=device2,
1405 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001406 ipSrc=ip2,
1407 ipDst=ip1,
1408 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1409 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1410 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
1411
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001412 pIntentResult3 = main.ONOScli1.addPointIntent(
1413 ingressDevice=device1,
1414 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001415 ipSrc=ip1,
1416 ipDst=ip2,
1417 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1418 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1419 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001420 pIntentResult4 = main.ONOScli1.addPointIntent(
1421 ingressDevice=device2,
1422 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001423 ipSrc=ip2,
1424 ipDst=ip1,
1425 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1426 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1427 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
shahshreyae6c7cf42014-11-26 16:39:01 -08001428
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001429 pIntentResult = pIntentResult1 and pIntentResult2 and\
1430 pIntentResult3 and pIntentResult4
1431 if pIntentResult == main.TRUE:
1432 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1433 main.log.info( getIntentResult )
shahshreyab512cd02015-01-27 17:01:47 -08001434 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001435 "Point intent related to SDN-IP matching" +
1436 " on TCP install successful" )
shahshreyab512cd02015-01-27 17:01:47 -08001437 else:
1438 main.log.report(
1439 "Point intent related to SDN-IP matching" +
1440 " on TCP install failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001441
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001442 iperfResult = main.Mininet1.iperf( 'h8', 'h18' )
1443 if iperfResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001444 main.log.report( "iperf test successful" )
1445 else:
1446 main.log.report( "iperf test failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001447
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001448 case32Result = pIntentResult and iperfResult
1449 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001450 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001451 actual=case32Result,
1452 onpass="Ping all test after Point intents addition related " +
1453 "to SDN-IP on TCP match successful",
1454 onfail="Ping all test after Point intents addition related " +
1455 "to SDN-IP on TCP match failed" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001456
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001457 def CASE33( self ):
1458 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001459 This test case adds multipoint to singlepoint intent related to
1460 SDN-IP matching on destination ip and the action is to rewrite
1461 the mac address
1462 Here the mac address to be rewritten is the mac address of the
1463 egress device
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001464 """
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001465 import json
1466 import time
1467
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001468 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001469 "This test case adds multipoint to singlepoint intent related to" +
1470 " SDN-IP matching on destination ip and " +
1471 "rewrite mac address action" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001472 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001473 "Adding multipoint to singlepoint intent related to SDN-IP" +
1474 " matching on destination ip" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001475 main.step( "Adding bidirectional multipoint to singlepoint intent" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001476 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001477 add-multi-to-single-intent --ipDst=10.0.3.0/24
1478 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1
1479 of:0000000000006018/1
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001480
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001481 add-multi-to-single-intent --ipDst=10.0.1.0/24
1482 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1
1483 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001484 """
1485 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001486 "Installing multipoint to single point " +
1487 "intent with rewrite mac address" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001488 main.step( "Uninstalling proxy arp app" )
shahshreyad524a942015-04-21 09:55:16 -07001489 # deactivating proxyarp app
1490 appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.proxyarp" )
1491 appCheck = main.ONOScli1.appToIDCheck()
1492 if appCheck != main.TRUE:
1493 main.log.warn( main.ONOScli1.apps() )
1494 main.log.warn( main.ONOScli1.appIDs() )
1495 time.sleep( 30 )
1496 main.log.info( "onos-app-proxyarp deactivated" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001497
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001498 main.step( "Changing ipaddress of hosts h8,h9 and h18" )
1499 main.Mininet1.changeIP(
1500 host='h8',
1501 intf='h8-eth0',
1502 newIP='10.0.1.1',
1503 newNetmask='255.255.255.0' )
1504 main.Mininet1.changeIP(
1505 host='h9',
1506 intf='h9-eth0',
1507 newIP='10.0.2.1',
1508 newNetmask='255.255.255.0' )
1509 main.Mininet1.changeIP(
1510 host='h10',
1511 intf='h10-eth0',
1512 newIP='10.0.3.1',
1513 newNetmask='255.255.255.0' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001514
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001515 main.step( "Changing default gateway of hosts h8,h9 and h18" )
1516 main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' )
1517 main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' )
1518 main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001519
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001520 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001521 "Assigning random mac address to the default gateways " +
1522 "since proxyarp app is uninstalled" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001523 main.Mininet1.addStaticMACAddress(
1524 host='h8',
1525 GW='10.0.1.254',
1526 macaddr='00:00:00:00:11:11' )
1527 main.Mininet1.addStaticMACAddress(
1528 host='h9',
1529 GW='10.0.2.254',
1530 macaddr='00:00:00:00:22:22' )
1531 main.Mininet1.addStaticMACAddress(
1532 host='h10',
1533 GW='10.0.3.254',
1534 macaddr='00:00:00:00:33:33' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001535
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001536 main.step( "Verify static gateway and MAC address assignment" )
1537 main.Mininet1.verifyStaticGWandMAC( host='h8' )
1538 main.Mininet1.verifyStaticGWandMAC( host='h9' )
1539 main.Mininet1.verifyStaticGWandMAC( host='h10' )
1540
shahshreyab471a3e2015-03-19 17:07:13 -07001541 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ]
1542 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ]
1543 ingressDeviceList = []
1544 ingressDeviceList.append( ingressDevice1 )
1545 ingressDeviceList.append( ingressDevice2 )
1546
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001547 main.step( "Adding multipoint to singlepoint intent" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001548 pIntentResult1 = main.ONOScli1.addMultipointToSinglepointIntent(
shahshreyab471a3e2015-03-19 17:07:13 -07001549 ingressDeviceList,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001550 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001551 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
1552 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
1553
shahshreyab471a3e2015-03-19 17:07:13 -07001554 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ]
1555 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ]
1556 ingressDeviceList = [ingressDevice1, ingressDevice2]
1557
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001558 pIntentResult2 = main.ONOScli1.addMultipointToSinglepointIntent(
shahshreyab471a3e2015-03-19 17:07:13 -07001559 ingressDeviceList,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001560 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001561 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
1562 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
1563
shahshreyab471a3e2015-03-19 17:07:13 -07001564 pIntentResult = pIntentResult1 and pIntentResult2
1565 if pIntentResult == main.FALSE:
1566 main.log.info(
1567 "Multi point to single point intent " +
1568 "installation failed" )
1569 else:
1570 pIntentResult = main.TRUE
1571 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1572 main.log.info( "intents = " + getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001573
shahshreyab471a3e2015-03-19 17:07:13 -07001574 time.sleep( 10 )
1575 getFlowsResult = main.ONOScli1.flows( jsonFormat=False )
1576 main.log.info( "flows = " + getFlowsResult )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001577
shahshreyab471a3e2015-03-19 17:07:13 -07001578 count = 1
1579 i = 8
1580 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001581
shahshreyab471a3e2015-03-19 17:07:13 -07001582 main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
1583 ping = main.Mininet1.pingHost(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001584 src="h" + str( i ), target="h" + str( i + 2 ) )
shahshreyab471a3e2015-03-19 17:07:13 -07001585 if ping == main.FALSE and count < 3:
1586 count += 1
1587 PingResult = main.FALSE
1588 main.log.report( "Ping between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001589 str( i ) +
1590 " and h" +
1591 str( i +
1592 2 ) +
1593 " failed. Making attempt number " +
1594 str( count ) +
1595 " in 2 seconds" )
shahshreyab471a3e2015-03-19 17:07:13 -07001596 time.sleep( 2 )
1597 elif ping == main.FALSE:
1598 main.log.report( "All ping attempts between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001599 str( i ) +
1600 " and h" +
1601 str( i +
1602 10 ) +
1603 "have failed" )
shahshreyab471a3e2015-03-19 17:07:13 -07001604 PingResult = main.FALSE
1605 elif ping == main.TRUE:
1606 main.log.info( "Ping test between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001607 str( i ) +
1608 " and h" +
1609 str( i +
1610 2 ) +
1611 "passed!" )
shahshreyab471a3e2015-03-19 17:07:13 -07001612 PingResult = main.TRUE
1613 else:
1614 main.log.info( "Unknown error" )
1615 PingResult = main.ERROR
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001616
shahshreyab471a3e2015-03-19 17:07:13 -07001617 if PingResult == main.FALSE:
1618 main.log.report( "Ping test failed." )
1619 # main.cleanup()
1620 # main.exit()
1621 if PingResult == main.TRUE:
1622 main.log.report( "Ping all successful" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001623
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001624 if pIntentResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001625 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001626 "Multi point intent with rewrite mac " +
shahshreyab471a3e2015-03-19 17:07:13 -07001627 "address installation and ping successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001628
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001629 case33Result = pIntentResult and PingResult
1630 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001631 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001632 actual=case33Result,
1633 onpass="Ping all test after multipoint to single point" +
1634 " intent addition with rewrite mac address successful",
1635 onfail="Ping all test after multipoint to single point intent" +
1636 " addition with rewrite mac address failed" )