blob: a553eaee68580ba60eb1046d82d6e068ed8124a5 [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" )
shahshreyaa47ebf42015-05-20 13:29:18 -070056 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
shahshreyaa47ebf42015-05-20 13:29:18 -070061 if gitPullResult == 100:
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 ):
shahshreya1f119da2015-04-21 17:16:46 -0700444 import time
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800445 main.log.report(
446 "This testcase uninstalls the reactive forwarding app" )
447 main.log.report( "__________________________________" )
448 main.case( "Uninstalling reactive forwarding app" )
449 # Unistall onos-app-fwd app to disable reactive forwarding
shahshreyad524a942015-04-21 09:55:16 -0700450 appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.fwd" )
451 appCheck = main.ONOScli1.appToIDCheck()
452 if appCheck != main.TRUE:
453 main.log.warn( main.ONOScli1.apps() )
454 main.log.warn( main.ONOScli1.appIDs() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800455 main.log.info( "onos-app-fwd uninstalled" )
shahshreyaa9d79f22014-11-18 15:41:29 -0800456
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800457 # After reactive forwarding is disabled,
458 # the reactive flows on switches timeout in 10-15s
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800459 # So sleep for 15s
460 time.sleep( 15 )
shahshreyaa9d79f22014-11-18 15:41:29 -0800461
shahshreyae6c7cf42014-11-26 16:39:01 -0800462 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800463 main.log.info( hosts )
shahshreyad524a942015-04-21 09:55:16 -0700464 case10Result = appInstallResult
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800465 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800466 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800467 actual=case10Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800468 onpass="Reactive forwarding app uninstallation successful",
469 onfail="Reactive forwarding app uninstallation failed" )
shahshreyaa9d79f22014-11-18 15:41:29 -0800470
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800471 def CASE6( self ):
472 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800473 "This testcase is testing the addition of" +
474 " host intents and then doing pingall" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800475 main.log.report( "__________________________________" )
476 main.case( "Obtaining hostsfor adding host intents" )
477 main.step( "Get hosts" )
shahshreyaeac353b2014-11-18 17:19:20 -0800478 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800479 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800480
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800481 main.step( "Get all devices id" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800482 devicesIdList = main.ONOScli1.getAllDevicesId()
483 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -0800484
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800485 # ONOS displays the hosts in hex format
486 # unlike mininet which does in decimal format
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800487 # So take care while adding intents
shahshreya4e13a062014-11-11 16:46:18 -0800488
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800489 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800490 main.step( "Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,
491 h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
492 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:08/-1",
493 "00:00:00:00:00:12/-1" )
494 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:09/-1",
495 "00:00:00:00:00:13/-1" )
496 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0A/-1",
497 "00:00:00:00:00:14/-1" )
498 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0B/-1",
499 "00:00:00:00:00:15/-1" )
500 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0C/-1",
501 "00:00:00:00:00:16/-1" )
502 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0D/-1",
503 "00:00:00:00:00:17/-1" )
504 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0E/-1",
505 "00:00:00:00:00:18/-1" )
506 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0F/-1",
507 "00:00:00:00:00:19/-1" )
508 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:10/-1",
509 "00:00:00:00:00:1A/-1" )
510 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:11/-1",
511 "00:00:00:00:00:1B/-1" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800512 """
513 for i in range( 8, 18 ):
514 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800515 "Adding host intent between h" + str( i ) +
516 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800517 host1 = "00:00:00:00:00:" + \
518 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
519 host2 = "00:00:00:00:00:" + \
520 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
521 # NOTE: get host can return None
522 # TODO: handle this
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800523 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
524 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
525 tmpResult = main.ONOScli1.addHostIntent( host1Id, host2Id )
shahshreya4e13a062014-11-11 16:46:18 -0800526
527 flowHandle = main.ONOScli1.flows()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800528 main.log.info( "flows:" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -0800529
530 count = 1
531 i = 8
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800532 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800533 while i < 18:
534 main.log.info(
535 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
536 ping = main.Mininet1.pingHost(
537 src="h" + str( i ), target="h" + str( i + 10 ) )
538 if ping == main.FALSE and count < 5:
539 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800540 # i = 8
541 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800542 main.log.report( "Ping between h" +
543 str( i ) +
544 " and h" +
545 str( i +
546 10 ) +
547 " failed. Making attempt number " +
548 str( count ) +
549 " in 2 seconds" )
550 time.sleep( 2 )
551 elif ping == main.FALSE:
552 main.log.report( "All ping attempts between h" +
553 str( i ) +
554 " and h" +
555 str( i +
556 10 ) +
557 "have failed" )
558 i = 19
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800559 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800560 elif ping == main.TRUE:
561 main.log.info( "Ping test between h" +
562 str( i ) +
563 " and h" +
564 str( i +
565 10 ) +
566 "passed!" )
567 i += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800568 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800569 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800570 main.log.info( "Unknown error" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800571 PingResult = main.ERROR
572 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800573 main.log.report(
574 "Host intents have not ben installed correctly. Cleaning up" )
575 # main.cleanup()
576 # main.exit()
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800577 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800578 main.log.report( "Host intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -0800579
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800580 case6Result = PingResult
581 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800582 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800583 actual=case6Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800584 onpass="Host intent addition and Pingall Test successful",
585 onfail="Host intent addition and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800586
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800587 def CASE7( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800588
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800589 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800590
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800591 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800592
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800593 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800594 "This testscase is killing a link to" +
595 " ensure that link discovery is consistent" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800596 main.log.report( "__________________________________" )
597 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800598 "Killing a link to Ensure that Link" +
599 " Discovery is Working Properly" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800600 main.step( "Start continuous pings" )
shahshreya4e13a062014-11-11 16:46:18 -0800601
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800602 main.Mininet2.pingLong(
603 src=main.params[ 'PING' ][ 'source1' ],
604 target=main.params[ 'PING' ][ 'target1' ],
605 pingTime=500 )
606 main.Mininet2.pingLong(
607 src=main.params[ 'PING' ][ 'source2' ],
608 target=main.params[ 'PING' ][ 'target2' ],
609 pingTime=500 )
610 main.Mininet2.pingLong(
611 src=main.params[ 'PING' ][ 'source3' ],
612 target=main.params[ 'PING' ][ 'target3' ],
613 pingTime=500 )
614 main.Mininet2.pingLong(
615 src=main.params[ 'PING' ][ 'source4' ],
616 target=main.params[ 'PING' ][ 'target4' ],
617 pingTime=500 )
618 main.Mininet2.pingLong(
619 src=main.params[ 'PING' ][ 'source5' ],
620 target=main.params[ 'PING' ][ 'target5' ],
621 pingTime=500 )
622 main.Mininet2.pingLong(
623 src=main.params[ 'PING' ][ 'source6' ],
624 target=main.params[ 'PING' ][ 'target6' ],
625 pingTime=500 )
626 main.Mininet2.pingLong(
627 src=main.params[ 'PING' ][ 'source7' ],
628 target=main.params[ 'PING' ][ 'target7' ],
629 pingTime=500 )
630 main.Mininet2.pingLong(
631 src=main.params[ 'PING' ][ 'source8' ],
632 target=main.params[ 'PING' ][ 'target8' ],
633 pingTime=500 )
634 main.Mininet2.pingLong(
635 src=main.params[ 'PING' ][ 'source9' ],
636 target=main.params[ 'PING' ][ 'target9' ],
637 pingTime=500 )
638 main.Mininet2.pingLong(
639 src=main.params[ 'PING' ][ 'source10' ],
640 target=main.params[ 'PING' ][ 'target10' ],
641 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -0800642
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800643 main.step( "Determine the current number of switches and links" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800644 topologyOutput = main.ONOScli1.topology()
645 topologyResult = main.ONOSbench.getTopology( topologyOutput )
shahshreyaa47ebf42015-05-20 13:29:18 -0700646 activeSwitches = topologyResult[ 'devices' ]
647 links = topologyResult[ 'links' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800648 main.log.info(
649 "Currently there are %s switches and %s links" %
650 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -0800651
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800652 main.step( "Kill Link between s3 and s28" )
653 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800654 time.sleep( linkSleep )
655 topologyOutput = main.ONOScli2.topology()
656 LinkDown = main.ONOSbench.checkStatus(
657 topologyOutput, activeSwitches, str(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800658 int( links ) - 2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800659 if LinkDown == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800660 main.log.report( "Link Down discovered properly" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800661 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800662 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800663 actual=LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800664 onpass="Link Down discovered properly",
665 onfail="Link down was not discovered in " +
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800666 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800667 " seconds" )
shahshreya4e13a062014-11-11 16:46:18 -0800668
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800669 main.step( "Bring link between s3 and s28 back up" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800670 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
671 time.sleep( linkSleep )
672 topologyOutput = main.ONOScli2.topology()
673 LinkUp = main.ONOSbench.checkStatus(
674 topologyOutput,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800675 activeSwitches,
676 str( links ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800677 if LinkUp == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800678 main.log.report( "Link up discovered properly" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800679 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800680 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800681 actual=LinkUp,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800682 onpass="Link up discovered properly",
683 onfail="Link up was not discovered in " +
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800684 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800685 " seconds" )
686
687 main.step( "Compare ONOS Topology to MN Topology" )
688 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800689 "Testing Mininet topology with the" +
690 " topology of multi instances ONOS" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800691 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800692 devices1 = main.ONOScli1.devices()
693 devices2 = main.ONOScli2.devices()
694 devices3 = main.ONOScli3.devices()
695 print "devices1 = ", devices1
696 print "devices2 = ", devices2
697 print "devices3 = ", devices3
698 hosts1 = main.ONOScli1.hosts()
699 hosts2 = main.ONOScli2.hosts()
700 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800701 # print "hosts1 = ", hosts1
702 # print "hosts2 = ", hosts2
703 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800704 ports1 = main.ONOScli1.ports()
705 ports2 = main.ONOScli2.ports()
706 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800707 # print "ports1 = ", ports1
708 # print "ports2 = ", ports2
709 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800710 links1 = main.ONOScli1.links()
711 links2 = main.ONOScli2.links()
712 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800713 # print "links1 = ", links1
714 # print "links2 = ", links2
715 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800716
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800717 print "**************"
718
719 main.step( "Start continuous pings" )
720 main.Mininet2.pingLong(
721 src=main.params[ 'PING' ][ 'source1' ],
722 target=main.params[ 'PING' ][ 'target1' ],
723 pingTime=500 )
724 main.Mininet2.pingLong(
725 src=main.params[ 'PING' ][ 'source2' ],
726 target=main.params[ 'PING' ][ 'target2' ],
727 pingTime=500 )
728 main.Mininet2.pingLong(
729 src=main.params[ 'PING' ][ 'source3' ],
730 target=main.params[ 'PING' ][ 'target3' ],
731 pingTime=500 )
732 main.Mininet2.pingLong(
733 src=main.params[ 'PING' ][ 'source4' ],
734 target=main.params[ 'PING' ][ 'target4' ],
735 pingTime=500 )
736 main.Mininet2.pingLong(
737 src=main.params[ 'PING' ][ 'source5' ],
738 target=main.params[ 'PING' ][ 'target5' ],
739 pingTime=500 )
740 main.Mininet2.pingLong(
741 src=main.params[ 'PING' ][ 'source6' ],
742 target=main.params[ 'PING' ][ 'target6' ],
743 pingTime=500 )
744 main.Mininet2.pingLong(
745 src=main.params[ 'PING' ][ 'source7' ],
746 target=main.params[ 'PING' ][ 'target7' ],
747 pingTime=500 )
748 main.Mininet2.pingLong(
749 src=main.params[ 'PING' ][ 'source8' ],
750 target=main.params[ 'PING' ][ 'target8' ],
751 pingTime=500 )
752 main.Mininet2.pingLong(
753 src=main.params[ 'PING' ][ 'source9' ],
754 target=main.params[ 'PING' ][ 'target9' ],
755 pingTime=500 )
756 main.Mininet2.pingLong(
757 src=main.params[ 'PING' ][ 'source10' ],
758 target=main.params[ 'PING' ][ 'target10' ],
759 pingTime=500 )
760
761 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800762 global ctrls
763 ctrls = []
764 count = 1
765 while True:
766 temp = ()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800767 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
768 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
769 temp = temp + ( "ONOS" + str( count ), )
770 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
771 temp = temp + \
772 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
773 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800774 count = count + 1
775 else:
776 break
777 global MNTopo
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800778 Topo = TestONTopology(
779 main.Mininet1,
780 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800781 MNTopo = Topo
782
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800783 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800784 main.step( "Compare ONOS Topology to MN Topology" )
785
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800786 switchesResults1 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800787 MNTopo,
788 json.loads( devices1 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800789 print "switches_Result1 = ", switchesResults1
790 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
791 onpass="ONOS1 Switches view is correct",
792 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800793
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800794 switchesResults2 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800795 MNTopo,
796 json.loads( devices2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800797 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
798 onpass="ONOS2 Switches view is correct",
799 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800800
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800801 switchesResults3 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800802 MNTopo,
803 json.loads( devices3 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800804 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
805 onpass="ONOS3 Switches view is correct",
806 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800807
808 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800809 portsResults1 = main.Mininet1.comparePorts( MNTopo,
810 json.loads( ports1 ) )
811 utilities.assertEquals( expect=main.TRUE, actual=portsResults1,
shahshreya4e13a062014-11-11 16:46:18 -0800812 onpass="ONOS1 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800813 onfail="ONOS1 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800814
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800815 portsResults2 = main.Mininet1.comparePorts( MNTopo,
816 json.loads( ports2 ) )
817 utilities.assertEquals( expect=main.TRUE, actual=portsResults2,
shahshreya4e13a062014-11-11 16:46:18 -0800818 onpass="ONOS2 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800819 onfail="ONOS2 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800820
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800821 portsResults3 = main.Mininet1.comparePorts( MNTopo,
822 json.loads( ports3 ) )
823 utilities.assertEquals( expect=main.TRUE, actual=portsResults3,
shahshreya4e13a062014-11-11 16:46:18 -0800824 onpass="ONOS3 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800825 onfail="ONOS3 Ports view is incorrect" )
826 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800827 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800828 MNTopo,
829 json.loads( links1 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800830 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
831 onpass="ONOS1 Links view is correct",
832 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800833
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800834 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800835 MNTopo,
836 json.loads( links2 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800837 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
838 onpass="ONOS2 Links view is correct",
839 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800840
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800841 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800842 MNTopo,
843 json.loads( links3 ) )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800844 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
845 onpass="ONOS2 Links view is correct",
846 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800847
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800848 # topoResult = switchesResults1 and switchesResults2
849 # and switchesResults3\
850 # and portsResults1 and portsResults2 and portsResults3\
851 # and linksResults1 and linksResults2 and linksResults3
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800852
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800853 topoResult = switchesResults1 and switchesResults2\
854 and switchesResults3 and linksResults1 and\
855 linksResults2 and linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800856
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800857 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800858 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800859 actual=topoResult and LinkUp and LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800860 onpass="Topology Check Test successful",
861 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800862
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800863 def CASE8( self ):
864 """
shahshreyaeac353b2014-11-18 17:19:20 -0800865 Intent removal
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800866 """
867 main.log.report(
shahshreyab512cd02015-01-27 17:01:47 -0800868 "This testcase removes any previously added intents" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800869 main.log.report( "__________________________________" )
870 main.log.info( "Removing any previously installed intents" )
871 main.case( "Removing intents" )
872 main.step( "Obtain the intent id's" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800873 intentResult = main.ONOScli1.intents( jsonFormat=False )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800874
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800875 intentLinewise = intentResult.split( "\n" )
shahshreyaa9d79f22014-11-18 15:41:29 -0800876 intentList = []
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800877 for line in intentLinewise:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800878 if line.startswith( "id=" ):
879 intentList.append( line )
shahshreyaa9d79f22014-11-18 15:41:29 -0800880
881 intentids = []
882 for line in intentList:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800883 intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
shahshreya4e13a062014-11-11 16:46:18 -0800884 for id in intentids:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800885 main.log.info( "id = " + id )
shahshreyaa9d79f22014-11-18 15:41:29 -0800886
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800887 main.step(
888 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -0800889 for id in intentids:
shahshreyaa47ebf42015-05-20 13:29:18 -0700890 main.ONOScli1.removeIntent( intentId=id ,purge=True )
shahshreyaa9d79f22014-11-18 15:41:29 -0800891
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800892 intentResult = main.ONOScli1.intents( jsonFormat=False )
893 main.log.info( "intent_result = " + intentResult )
894 case8Result = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800895
shahshreyaeac353b2014-11-18 17:19:20 -0800896 i = 8
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800897 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800898 while i < 18:
899 main.log.info(
900 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
901 ping = main.Mininet1.pingHost(
902 src="h" + str( i ), target="h" + str( i + 10 ) )
903 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -0800904 i = 19
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800905 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800906 elif ping == main.FALSE:
907 i += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800908 PingResult = main.FALSE
shahshreyaeac353b2014-11-18 17:19:20 -0800909 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800910 main.log.info( "Unknown error" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800911 PingResult = main.ERROR
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800912 # 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" )
shahshreyaa47ebf42015-05-20 13:29:18 -0700949 macsDict = {}
950 for i in range( 1,29 ):
951 macsDict[ 'h' + str( i ) ]= main.Mininet1.getMacAddress( host='h'+ str( i ) )
952 print macsDict
953 # main.step(var1)
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800954 ptpIntentResult = main.ONOScli1.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -0700955 ingressDevice="of:0000000000003008/1",
956 egressDevice="of:0000000000006018/1",
957 ethType='IPV4',
958 ethSrc=macsDict.get( 'h8' ))
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800959 if ptpIntentResult == main.TRUE:
960 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800961 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800962 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800963
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800964 ptpIntentResult = main.ONOScli1.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -0700965 ingressDevice="of:0000000000006018/1",
966 egressDevice="of:0000000000003008/1",
967 ethType='IPV4',
968 ethSrc=macsDict.get( 'h18' ))
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800969 if ptpIntentResult == main.TRUE:
970 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800971 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800972 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800973
shahshreyaa47ebf42015-05-20 13:29:18 -0700974 var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
975 main.step(var2)
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800976 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800977 "of:0000000000003009/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700978 "of:0000000000006019/1",
979 ethType='IPV4',
980 ethSrc=macsDict.get( 'h9' ))
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800981 if ptpIntentResult == main.TRUE:
982 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800983 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800984 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800985
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800986 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800987 "of:0000000000006019/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700988 "of:0000000000003009/1",
989 ethType='IPV4',
990 ethSrc=macsDict.get( 'h19' ))
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800991 if ptpIntentResult == main.TRUE:
992 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800993 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800994 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800995
shahshreyaa47ebf42015-05-20 13:29:18 -0700996 var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
997 main.step(var3)
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800998 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800999 "of:0000000000003010/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001000 "of:0000000000006020/1",
1001 ethType='IPV4',
1002 ethSrc=macsDict.get( 'h10' ))
1003
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001004 if ptpIntentResult == main.TRUE:
1005 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001006 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001007 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001008
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001009 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001010 "of:0000000000006020/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001011 "of:0000000000003010/1",
1012 ethType='IPV4',
1013 ethSrc=macsDict.get( 'h20' ))
1014
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001015 if ptpIntentResult == main.TRUE:
1016 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001017 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001018 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001019
shahshreyaa47ebf42015-05-20 13:29:18 -07001020 var4 = "Add point intents for mininet hosts h11 and h21 or" +\
1021 " ONOS hosts hB and h15"
1022 main.case(var4)
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001023 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001024 "of:0000000000003011/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001025 "of:0000000000006021/1",
1026 ethType='IPV4',
1027 ethSrc=macsDict.get( 'h11' ))
1028
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001029 if ptpIntentResult == main.TRUE:
1030 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001031 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001032 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001033
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001034 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001035 "of:0000000000006021/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001036 "of:0000000000003011/1",
1037 ethType='IPV4',
1038 ethSrc=macsDict.get( 'h21' ))
1039
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001040 if ptpIntentResult == main.TRUE:
1041 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001042 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001043 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001044
shahshreyaa47ebf42015-05-20 13:29:18 -07001045 var5 = "Add point intents for mininet hosts h12 and h22 " +\
1046 "ONOS hosts hC and h16"
1047 main.case(var5)
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001048 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001049 "of:0000000000003012/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001050 "of:0000000000006022/1",
1051 ethType='IPV4',
1052 ethSrc=macsDict.get( 'h12' ))
1053
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001054 if ptpIntentResult == main.TRUE:
1055 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001056 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001057 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001058
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001059 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001060 "of:0000000000006022/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001061 "of:0000000000003012/1",
1062 ethType='IPV4',
1063 ethSrc=macsDict.get( 'h22' ))
1064
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001065 if ptpIntentResult == main.TRUE:
1066 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001067 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001068 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001069
shahshreyaa47ebf42015-05-20 13:29:18 -07001070 var6 = "Add point intents for mininet hosts h13 and h23 or" +\
1071 " ONOS hosts hD and h17"
1072 main.case(var6)
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001073 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001074 "of:0000000000003013/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001075 "of:0000000000006023/1",
1076 ethType='IPV4',
1077 ethSrc=macsDict.get( 'h13' ))
1078
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001079 if ptpIntentResult == main.TRUE:
1080 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001081 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001082 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001083
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001084 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001085 "of:0000000000006023/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001086 "of:0000000000003013/1",
1087 ethType='IPV4',
1088 ethSrc=macsDict.get( 'h23' ))
1089
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001090 if ptpIntentResult == main.TRUE:
1091 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001092 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001093 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001094
shahshreyaa47ebf42015-05-20 13:29:18 -07001095 var7 = "Add point intents for mininet hosts h14 and h24 or" +\
1096 " ONOS hosts hE and h18"
1097 main.case(var7)
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001098 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001099 "of:0000000000003014/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001100 "of:0000000000006024/1",
1101 ethType='IPV4',
1102 ethSrc=macsDict.get( 'h14' ))
1103
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:0000000000006024/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001111 "of:0000000000003014/1",
1112 ethType='IPV4',
1113 ethSrc=macsDict.get( 'h24' ))
1114
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001115 if ptpIntentResult == main.TRUE:
1116 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001117 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001118 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001119
shahshreyaa47ebf42015-05-20 13:29:18 -07001120 var8 = "Add point intents for mininet hosts h15 and h25 or" +\
1121 " ONOS hosts hF and h19"
1122 main.case(var8)
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001123 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001124 "of:0000000000003015/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001125 "of:0000000000006025/1",
1126 ethType='IPV4',
1127 ethSrc=macsDict.get( 'h15' ))
1128
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001129 if ptpIntentResult == main.TRUE:
1130 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001131 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001132 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001133
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001134 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001135 "of:0000000000006025/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001136 "of:0000000000003015/1",
1137 ethType='IPV4',
1138 ethSrc=macsDict.get( 'h25' ))
1139
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001140 if ptpIntentResult == main.TRUE:
1141 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001142 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001143 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001144
shahshreyaa47ebf42015-05-20 13:29:18 -07001145 var9 = "Add intents for mininet hosts h16 and h26 or" +\
1146 " ONOS hosts h10 and h1A"
1147 main.case(var9)
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001148 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001149 "of:0000000000003016/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001150 "of:0000000000006026/1",
1151 ethType='IPV4',
1152 ethSrc=macsDict.get( 'h16' ))
1153
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001154 if ptpIntentResult == main.TRUE:
1155 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001156 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001157 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001158
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001159 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001160 "of:0000000000006026/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001161 "of:0000000000003016/1",
1162 ethType='IPV4',
1163 ethSrc=macsDict.get( 'h26' ))
1164
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001165 if ptpIntentResult == main.TRUE:
1166 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001167 main.log.info( "Point to point intent install successful" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001168 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001169
shahshreyaa47ebf42015-05-20 13:29:18 -07001170 var10 = "Add point intents for mininet hosts h17 and h27 or" +\
1171 " ONOS hosts h11 and h1B"
1172 main.case(var10)
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001173 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001174 "of:0000000000003017/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001175 "of:0000000000006027/1",
1176 ethType='IPV4',
1177 ethSrc=macsDict.get( 'h17' ))
1178
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001179 if ptpIntentResult == main.TRUE:
1180 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001181 main.log.info( "Point to point intent install successful" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001182 #main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001183
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001184 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001185 "of:0000000000006027/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001186 "of:0000000000003017/1",
1187 ethType='IPV4',
1188 ethSrc=macsDict.get( 'h27' ))
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001189
1190 print(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001191 "_______________________________________________________" +
1192 "________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001193
1194 flowHandle = main.ONOScli1.flows()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001195 # print "flowHandle = ", flowHandle
1196 main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001197
1198 count = 1
1199 i = 8
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001200 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001201 while i < 18:
1202 main.log.info(
1203 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1204 ping = main.Mininet1.pingHost(
1205 src="h" + str( i ), target="h" + str( i + 10 ) )
1206 if ping == main.FALSE and count < 5:
1207 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001208 # i = 8
1209 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001210 main.log.report( "Ping between h" +
1211 str( i ) +
1212 " and h" +
1213 str( i +
1214 10 ) +
1215 " failed. Making attempt number " +
1216 str( count ) +
1217 " in 2 seconds" )
1218 time.sleep( 2 )
1219 elif ping == main.FALSE:
1220 main.log.report( "All ping attempts between h" +
1221 str( i ) +
1222 " and h" +
1223 str( i +
1224 10 ) +
1225 "have failed" )
1226 i = 19
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001227 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001228 elif ping == main.TRUE:
1229 main.log.info( "Ping test between h" +
1230 str( i ) +
1231 " and h" +
1232 str( i +
1233 10 ) +
1234 "passed!" )
1235 i += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001236 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001237 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001238 main.log.info( "Unknown error" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001239 PingResult = main.ERROR
1240 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001241 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001242 "Ping all test after Point intents" +
1243 " addition failed. Cleaning up" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001244 # main.cleanup()
1245 # main.exit()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001246 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001247 main.log.report(
1248 "Ping all test after Point intents addition successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001249
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001250 case8Result = PingResult
1251 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001252 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001253 actual=case8Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001254 onpass="Ping all test after Point intents addition successful",
1255 onfail="Ping all test after Point intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001256
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001257 def CASE31( self ):
1258 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001259 This test case adds point intent related to
1260 SDN-IP matching on ICMP ( ethertype=IPV4, ipProto=1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001261 """
shahshreyaa9d79f22014-11-18 15:41:29 -08001262 import json
1263
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001264 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001265 "This test case adds point intent " +
1266 "related to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001267 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001268 "Adding bidirectional point intent related" +
1269 " to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001270 main.step( "Adding bidirectional point intent" )
1271 # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1272 # --ethType=IPV4 --ipProto=1 of:0000000000003008/1
1273 # of:0000000000006018/1
1274
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001275 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001276 for i in range( 8, 11 ):
1277 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001278 "Adding point intent between h" + str( i ) +
1279 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001280 host1 = "00:00:00:00:00:" + \
1281 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1282 host2 = "00:00:00:00:00:" + \
1283 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001284 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1285 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1286 for host in hostsJson:
1287 if host[ 'id' ] == host1Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001288 ip1 = host[ 'ipAddresses' ][ 0 ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001289 ip1 = str( ip1 + "/32" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001290 device1 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001291 device1 = str( device1 + "/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001292 elif host[ 'id' ] == host2Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001293 ip2 = str( host[ 'ipAddresses' ][ 0 ] ) + "/32"
1294 device2 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001295 device2 = str( device2 + "/1" )
1296
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001297 pIntentResult1 = main.ONOScli1.addPointIntent(
1298 ingressDevice=device1,
1299 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001300 ipSrc=ip1,
1301 ipDst=ip2,
1302 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
shahshreyaa47ebf42015-05-20 13:29:18 -07001303 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ], )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001304
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001305 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1306 main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001307
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001308 pIntentResult2 = main.ONOScli1.addPointIntent(
1309 ingressDevice=device2,
1310 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001311 ipSrc=ip2,
1312 ipDst=ip1,
1313 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1314 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1315
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001316 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1317 main.log.info( getIntentResult )
shahshreyaa47ebf42015-05-20 13:29:18 -07001318 if ( pIntentResult1 and pIntentResult2 ) :
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001319 # getIntentResult = main.ONOScli1.intents()
1320 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001321 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001322 "Point intent related to SDN-IP matching" +
1323 " on ICMP install successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001324
1325 time.sleep( 15 )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001326 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1327 main.log.info( "intents = " + getIntentResult )
1328 getFlowsResult = main.ONOScli1.flows()
1329 main.log.info( "flows = " + getFlowsResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001330
shahshreyae6c7cf42014-11-26 16:39:01 -08001331 count = 1
1332 i = 8
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001333 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001334 while i < 11:
1335 main.log.info(
1336 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1337 ping = main.Mininet1.pingHost(
1338 src="h" + str( i ), target="h" + str( i + 10 ) )
1339 if ping == main.FALSE and count < 3:
1340 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001341 # i = 8
1342 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001343 main.log.report( "Ping between h" +
1344 str( i ) +
1345 " and h" +
1346 str( i +
1347 10 ) +
1348 " failed. Making attempt number " +
1349 str( count ) +
1350 " in 2 seconds" )
1351 time.sleep( 2 )
1352 elif ping == main.FALSE:
1353 main.log.report( "All ping attempts between h" +
1354 str( i ) +
1355 " and h" +
1356 str( i +
1357 10 ) +
1358 "have failed" )
1359 i = 19
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001360 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001361 elif ping == main.TRUE:
1362 main.log.info( "Ping test between h" +
1363 str( i ) +
1364 " and h" +
1365 str( i +
1366 10 ) +
1367 "passed!" )
1368 i += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001369 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -08001370 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001371 main.log.info( "Unknown error" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001372 PingResult = main.ERROR
1373 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001374 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001375 "Ping test after Point intents related to" +
1376 " SDN-IP matching on ICMP failed." )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001377 # main.cleanup()
1378 # main.exit()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001379 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001380 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001381 "Ping all test after Point intents related to" +
1382 " SDN-IP matching on ICMP successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001383
shahshreyaa47ebf42015-05-20 13:29:18 -07001384 case31Result = PingResult
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001385 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001386 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001387 actual=case31Result,
1388 onpass="Point intent related to SDN-IP " +
1389 "matching on ICMP and ping test successful",
1390 onfail="Point intent related to SDN-IP" +
1391 " matching on ICMP and ping test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001392
1393 def CASE32( self ):
1394 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001395 This test case adds point intent related to SDN-IP matching on TCP
1396 ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 )
1397 Note: Although BGP port is 179, we are using 5001 because iperf
1398 is used for verifying and iperf's default port is 5001
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001399 """
shahshreyae6c7cf42014-11-26 16:39:01 -08001400 import json
1401
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001402 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001403 "This test case adds point intent" +
1404 " related to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001405 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001406 "Adding bidirectional point intent related" +
1407 " to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001408 main.step( "Adding bidirectional point intent" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001409 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001410 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1411 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1
1412 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001413
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001414 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1415 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1
1416 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001417
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001418 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1419 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1
1420 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001421
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001422 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1423 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1
1424 of:0000000000003008/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001425
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001426 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001427 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001428 for i in range( 8, 9 ):
1429 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001430 "Adding point intent between h" + str( i ) +
1431 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001432 host1 = "00:00:00:00:00:" + \
1433 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1434 host2 = "00:00:00:00:00:" + \
1435 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001436 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1437 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1438 for host in hostsJson:
1439 if host[ 'id' ] == host1Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001440 ip1 = host[ 'ipAddresses' ][ 0 ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001441 ip1 = str( ip1 + "/32" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001442 device1 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001443 device1 = str( device1 + "/1" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001444 elif host[ 'id' ] == host2Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001445 ip2 = str( host[ 'ipAddresses' ][ 0 ] ) + "/32"
1446 device2 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001447 device2 = str( device2 + "/1" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001448
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001449 pIntentResult1 = main.ONOScli1.addPointIntent(
1450 ingressDevice=device1,
1451 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001452 ipSrc=ip1,
1453 ipDst=ip2,
1454 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1455 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1456 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001457 pIntentResult2 = main.ONOScli1.addPointIntent(
1458 ingressDevice=device2,
1459 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001460 ipSrc=ip2,
1461 ipDst=ip1,
1462 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1463 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1464 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
1465
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001466 pIntentResult3 = main.ONOScli1.addPointIntent(
1467 ingressDevice=device1,
1468 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001469 ipSrc=ip1,
1470 ipDst=ip2,
1471 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1472 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1473 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001474 pIntentResult4 = main.ONOScli1.addPointIntent(
1475 ingressDevice=device2,
1476 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001477 ipSrc=ip2,
1478 ipDst=ip1,
1479 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1480 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1481 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
shahshreyae6c7cf42014-11-26 16:39:01 -08001482
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001483 pIntentResult = pIntentResult1 and pIntentResult2 and\
1484 pIntentResult3 and pIntentResult4
1485 if pIntentResult == main.TRUE:
1486 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1487 main.log.info( getIntentResult )
shahshreyab512cd02015-01-27 17:01:47 -08001488 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001489 "Point intent related to SDN-IP matching" +
1490 " on TCP install successful" )
shahshreyab512cd02015-01-27 17:01:47 -08001491 else:
1492 main.log.report(
1493 "Point intent related to SDN-IP matching" +
1494 " on TCP install failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001495
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001496 iperfResult = main.Mininet1.iperf( 'h8', 'h18' )
1497 if iperfResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001498 main.log.report( "iperf test successful" )
1499 else:
1500 main.log.report( "iperf test failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001501
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001502 case32Result = pIntentResult and iperfResult
1503 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001504 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001505 actual=case32Result,
1506 onpass="Ping all test after Point intents addition related " +
1507 "to SDN-IP on TCP match successful",
1508 onfail="Ping all test after Point intents addition related " +
1509 "to SDN-IP on TCP match failed" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001510
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001511 def CASE33( self ):
1512 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001513 This test case adds multipoint to singlepoint intent related to
1514 SDN-IP matching on destination ip and the action is to rewrite
1515 the mac address
1516 Here the mac address to be rewritten is the mac address of the
1517 egress device
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001518 """
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001519 import json
1520 import time
1521
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001522 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001523 "This test case adds multipoint to singlepoint intent related to" +
1524 " SDN-IP matching on destination ip and " +
1525 "rewrite mac address action" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001526 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001527 "Adding multipoint to singlepoint intent related to SDN-IP" +
1528 " matching on destination ip" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001529 main.step( "Adding bidirectional multipoint to singlepoint intent" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001530 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001531 add-multi-to-single-intent --ipDst=10.0.3.0/24
1532 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1
1533 of:0000000000006018/1
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001534
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001535 add-multi-to-single-intent --ipDst=10.0.1.0/24
1536 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1
1537 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001538 """
1539 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001540 "Installing multipoint to single point " +
1541 "intent with rewrite mac address" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001542 main.step( "Uninstalling proxy arp app" )
shahshreyad524a942015-04-21 09:55:16 -07001543 # deactivating proxyarp app
1544 appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.proxyarp" )
1545 appCheck = main.ONOScli1.appToIDCheck()
1546 if appCheck != main.TRUE:
1547 main.log.warn( main.ONOScli1.apps() )
1548 main.log.warn( main.ONOScli1.appIDs() )
1549 time.sleep( 30 )
1550 main.log.info( "onos-app-proxyarp deactivated" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001551
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001552 main.step( "Changing ipaddress of hosts h8,h9 and h18" )
1553 main.Mininet1.changeIP(
1554 host='h8',
1555 intf='h8-eth0',
1556 newIP='10.0.1.1',
1557 newNetmask='255.255.255.0' )
1558 main.Mininet1.changeIP(
1559 host='h9',
1560 intf='h9-eth0',
1561 newIP='10.0.2.1',
1562 newNetmask='255.255.255.0' )
1563 main.Mininet1.changeIP(
1564 host='h10',
1565 intf='h10-eth0',
1566 newIP='10.0.3.1',
1567 newNetmask='255.255.255.0' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001568
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001569 main.step( "Changing default gateway of hosts h8,h9 and h18" )
1570 main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' )
1571 main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' )
1572 main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001573
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001574 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001575 "Assigning random mac address to the default gateways " +
1576 "since proxyarp app is uninstalled" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001577 main.Mininet1.addStaticMACAddress(
1578 host='h8',
1579 GW='10.0.1.254',
1580 macaddr='00:00:00:00:11:11' )
1581 main.Mininet1.addStaticMACAddress(
1582 host='h9',
1583 GW='10.0.2.254',
1584 macaddr='00:00:00:00:22:22' )
1585 main.Mininet1.addStaticMACAddress(
1586 host='h10',
1587 GW='10.0.3.254',
1588 macaddr='00:00:00:00:33:33' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001589
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001590 main.step( "Verify static gateway and MAC address assignment" )
1591 main.Mininet1.verifyStaticGWandMAC( host='h8' )
1592 main.Mininet1.verifyStaticGWandMAC( host='h9' )
1593 main.Mininet1.verifyStaticGWandMAC( host='h10' )
1594
shahshreyab471a3e2015-03-19 17:07:13 -07001595 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ]
1596 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ]
1597 ingressDeviceList = []
1598 ingressDeviceList.append( ingressDevice1 )
1599 ingressDeviceList.append( ingressDevice2 )
1600
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001601 main.step( "Adding multipoint to singlepoint intent" )
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001602 pIntentResult1 = main.ONOScli1.addMultipointToSinglepointIntent(
shahshreyab471a3e2015-03-19 17:07:13 -07001603 ingressDeviceList,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001604 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001605 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
1606 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
1607
shahshreyab471a3e2015-03-19 17:07:13 -07001608 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ]
1609 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ]
1610 ingressDeviceList = [ingressDevice1, ingressDevice2]
1611
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001612 pIntentResult2 = main.ONOScli1.addMultipointToSinglepointIntent(
shahshreyab471a3e2015-03-19 17:07:13 -07001613 ingressDeviceList,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001614 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001615 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
1616 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
1617
shahshreyab471a3e2015-03-19 17:07:13 -07001618 pIntentResult = pIntentResult1 and pIntentResult2
1619 if pIntentResult == main.FALSE:
1620 main.log.info(
1621 "Multi point to single point intent " +
1622 "installation failed" )
1623 else:
1624 pIntentResult = main.TRUE
1625 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1626 main.log.info( "intents = " + getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001627
shahshreyab471a3e2015-03-19 17:07:13 -07001628 time.sleep( 10 )
1629 getFlowsResult = main.ONOScli1.flows( jsonFormat=False )
1630 main.log.info( "flows = " + getFlowsResult )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001631
shahshreyab471a3e2015-03-19 17:07:13 -07001632 count = 1
1633 i = 8
1634 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001635
shahshreyab471a3e2015-03-19 17:07:13 -07001636 main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
1637 ping = main.Mininet1.pingHost(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001638 src="h" + str( i ), target="h" + str( i + 2 ) )
shahshreyab471a3e2015-03-19 17:07:13 -07001639 if ping == main.FALSE and count < 3:
1640 count += 1
1641 PingResult = main.FALSE
1642 main.log.report( "Ping between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001643 str( i ) +
1644 " and h" +
1645 str( i +
1646 2 ) +
1647 " failed. Making attempt number " +
1648 str( count ) +
1649 " in 2 seconds" )
shahshreyab471a3e2015-03-19 17:07:13 -07001650 time.sleep( 2 )
1651 elif ping == main.FALSE:
1652 main.log.report( "All ping attempts between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001653 str( i ) +
1654 " and h" +
1655 str( i +
1656 10 ) +
1657 "have failed" )
shahshreyab471a3e2015-03-19 17:07:13 -07001658 PingResult = main.FALSE
1659 elif ping == main.TRUE:
1660 main.log.info( "Ping test between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001661 str( i ) +
1662 " and h" +
1663 str( i +
1664 2 ) +
shahshreyaa47ebf42015-05-20 13:29:18 -07001665 " passed!" )
shahshreyab471a3e2015-03-19 17:07:13 -07001666 PingResult = main.TRUE
1667 else:
1668 main.log.info( "Unknown error" )
1669 PingResult = main.ERROR
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001670
shahshreyab471a3e2015-03-19 17:07:13 -07001671 if PingResult == main.FALSE:
1672 main.log.report( "Ping test failed." )
1673 # main.cleanup()
1674 # main.exit()
1675 if PingResult == main.TRUE:
1676 main.log.report( "Ping all successful" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001677
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001678 if pIntentResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001679 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001680 "Multi point intent with rewrite mac " +
shahshreyab471a3e2015-03-19 17:07:13 -07001681 "address installation and ping successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001682
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001683 case33Result = pIntentResult and PingResult
1684 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001685 expect=main.TRUE,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001686 actual=case33Result,
1687 onpass="Ping all test after multipoint to single point" +
1688 " intent addition with rewrite mac address successful",
1689 onfail="Ping all test after multipoint to single point intent" +
1690 " addition with rewrite mac address failed" )
shahshreya1f119da2015-04-21 17:16:46 -07001691
1692 def CASE20( self ):
1693 """
1694 Exit from mininet cli
1695 reinstall ONOS
1696 """
shahshreyaa47ebf42015-05-20 13:29:18 -07001697 import time
shahshreya1f119da2015-04-21 17:16:46 -07001698 cellName = main.params[ 'ENV' ][ 'cellName' ]
1699 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
1700 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
1701 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
1702 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
1703 ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
1704 ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
1705
1706 main.log.report( "This testcase exits the mininet cli and reinstalls" +
1707 "ONOS to switch over to Packet Optical topology" )
1708 main.log.report( "_____________________________________________" )
1709 main.case( "Disconnecting mininet and restarting ONOS" )
1710 main.step( "Disconnecting mininet and restarting ONOS" )
1711 mininetDisconnect = main.Mininet1.disconnect()
1712 print "mininetDisconnect = ", mininetDisconnect
1713
1714 main.step( "Removing raft logs before a clen installation of ONOS" )
1715 main.ONOSbench.onosRemoveRaftLogs()
1716
1717 main.step( "Applying cell variable to environment" )
1718 cellResult = main.ONOSbench.setCell( cellName )
1719 verifyResult = main.ONOSbench.verifyCell()
1720
shahshreyaa47ebf42015-05-20 13:29:18 -07001721 time.sleep( 5 )
1722 main.step( "Uninstalling ONOS package" )
1723 onos1UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS1Ip)
1724 onos2UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS2Ip)
1725 onos3UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS3Ip)
1726 onosUninstallResult = onos1UninstallResult and onos2UninstallResult \
1727 and onos3UninstallResult
1728 time.sleep( 15 )
shahshreya1f119da2015-04-21 17:16:46 -07001729 main.step( "Installing ONOS package" )
1730 onos1InstallResult = main.ONOSbench.onosInstall(
1731 options="-f",
1732 node=ONOS1Ip )
1733 onos2InstallResult = main.ONOSbench.onosInstall(
1734 options="-f",
1735 node=ONOS2Ip )
1736 onos3InstallResult = main.ONOSbench.onosInstall(
1737 options="-f",
1738 node=ONOS3Ip )
1739 onosInstallResult = onos1InstallResult and onos2InstallResult and\
1740 onos3InstallResult
1741 if onosInstallResult == main.TRUE:
1742 main.log.report( "Installing ONOS package successful" )
1743 else:
1744 main.log.report( "Installing ONOS package failed" )
1745
shahshreyaa47ebf42015-05-20 13:29:18 -07001746 time.sleep( 10 )
shahshreya1f119da2015-04-21 17:16:46 -07001747 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
1748 onos2Isup = main.ONOSbench.isup( ONOS2Ip )
1749 onos3Isup = main.ONOSbench.isup( ONOS3Ip )
1750 onosIsup = onos1Isup and onos2Isup and onos3Isup
1751 if onosIsup == main.TRUE:
1752 main.log.report( "ONOS instances are up and ready" )
1753 else:
1754 main.log.report( "ONOS instances may not be up" )
1755
1756 main.step( "Starting ONOS service" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001757 time.sleep( 10 )
shahshreya1f119da2015-04-21 17:16:46 -07001758 startResult = main.TRUE
1759 # startResult = main.ONOSbench.onosStart( ONOS1Ip )
1760 startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip )
1761 startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip )
1762 startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip )
1763 startResult = startcli1 and startcli2 and startcli3
1764 if startResult == main.TRUE:
1765 main.log.report( "ONOS cli starts properly" )
1766 case20Result = mininetDisconnect and cellResult and verifyResult \
1767 and onosInstallResult and onosIsup and startResult
1768
1769 utilities.assert_equals(
1770 expect=main.TRUE,
1771 actual=case20Result,
1772 onpass= "Exiting functionality mininet topology and reinstalling" +
1773 " ONOS successful",
1774 onfail= "Exiting functionality mininet topology and reinstalling" +
1775 " ONOS failed" )
1776
1777 def CASE21( self, main ):
1778 """
1779 On ONOS bench, run this command:
1780 sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1 <Ctrls>
1781 which spawns packet optical topology and copies the links
1782 json file to the onos instance.
1783 Note that in case of Packet Optical, the links are not learnt
1784 from the topology, instead the links are learnt
1785 from the json config file
1786 """
1787 main.log.report(
1788 "This testcase starts the packet layer topology and REST" )
1789 main.log.report( "_____________________________________________" )
1790 main.case( "Starting LINC-OE and other components" )
1791 main.step( "Starting LINC-OE and other components" )
1792 main.log.info( "Activate optical app" )
1793 appInstallResult = main.ONOScli1.activateApp( "org.onosproject.optical" )
1794 appCheck = main.ONOScli1.appToIDCheck()
1795 appCheck = appCheck and main.ONOScli2.appToIDCheck()
1796 appCheck = appCheck and main.ONOScli3.appToIDCheck()
1797 if appCheck != main.TRUE:
1798 main.log.warn( "Checking ONOS application unsuccesful" )
1799
1800 ctrllerIP = []
1801 ctrllerIP.append( main.params[ 'CTRL' ][ 'ip1' ] )
1802 #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip2' ] )
1803 #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip3' ] )
1804 opticalMnScript = main.LincOE2.runOpticalMnScript( ctrllerIP = ctrllerIP )
1805 case21Result = opticalMnScript and appInstallResult
1806 utilities.assert_equals(
1807 expect=main.TRUE,
1808 actual=case21Result,
1809 onpass="Packet optical topology spawned successsfully",
1810 onfail="Packet optical topology spawning failed" )
1811
1812 def CASE22( self, main ):
1813 """
1814 Curretly we use, 10 optical switches(ROADM's) and
1815 6 packet layer mininet switches each with one host.
1816 Therefore, the roadmCount variable = 10,
1817 packetLayerSWCount variable = 6, hostCount=6 and
1818 links=42.
1819 All this is hardcoded in the testcase. If the topology changes,
1820 these hardcoded values need to be changed
1821 """
shahshreyaa47ebf42015-05-20 13:29:18 -07001822 import time
shahshreya1f119da2015-04-21 17:16:46 -07001823 main.log.report(
1824 "This testcase compares the optical+packet topology against what" +
1825 " is expected" )
1826 main.case( "Topology comparision" )
1827 main.step( "Topology comparision" )
1828 devicesResult = main.ONOScli3.devices( jsonFormat=False )
shahshreyaa47ebf42015-05-20 13:29:18 -07001829 time.sleep( 15 )
shahshreya1f119da2015-04-21 17:16:46 -07001830 print "devices_result = ", devicesResult
1831 devicesLinewise = devicesResult.split( "\n" )
shahshreya1f119da2015-04-21 17:16:46 -07001832 roadmCount = 0
1833 packetLayerSWCount = 0
1834 for line in devicesLinewise:
1835 components = line.split( "," )
1836 availability = components[ 1 ].split( "=" )[ 1 ]
1837 type = components[ 3 ].split( "=" )[ 1 ]
1838 if availability == 'true' and type == 'ROADM':
1839 roadmCount += 1
1840 elif availability == 'true' and type == 'SWITCH':
1841 packetLayerSWCount += 1
1842 if roadmCount == 10:
1843 print "Number of Optical Switches = %d and is" % roadmCount +\
1844 " correctly detected"
1845 main.log.info(
1846 "Number of Optical Switches = " +
1847 str( roadmCount ) +
1848 " and is correctly detected" )
1849 opticalSWResult = main.TRUE
1850 else:
1851 print "Number of Optical Switches = %d and is wrong" % roadmCount
1852 main.log.info(
1853 "Number of Optical Switches = " +
1854 str( roadmCount ) +
1855 " and is wrong" )
1856 opticalSWResult = main.FALSE
1857
1858 if packetLayerSWCount == 6:
1859 print "Number of Packet layer or mininet Switches = %d "\
1860 % packetLayerSWCount + "and is correctly detected"
1861 main.log.info(
1862 "Number of Packet layer or mininet Switches = " +
1863 str( packetLayerSWCount ) +
1864 " and is correctly detected" )
1865 packetSWResult = main.TRUE
1866 else:
1867 print "Number of Packet layer or mininet Switches = %d and"\
1868 % packetLayerSWCount + " is wrong"
1869 main.log.info(
1870 "Number of Packet layer or mininet Switches = " +
1871 str( packetLayerSWCount ) +
1872 " and is wrong" )
1873 packetSWResult = main.FALSE
1874 print "_________________________________"
1875
1876 linksResult = main.ONOScli3.links( jsonFormat=False )
1877 print "links_result = ", linksResult
1878 print "_________________________________"
1879 linkActiveCount = linksResult.count("state=ACTIVE")
1880 main.log.info( "linkActiveCount = " + str( linkActiveCount ))
1881 if linkActiveCount == 42:
1882 linkActiveResult = main.TRUE
1883 main.log.info(
1884 "Number of links in ACTIVE state are correct")
1885 else:
1886 linkActiveResult = main.FALSE
1887 main.log.info(
1888 "Number of links in ACTIVE state are wrong")
1889
1890 case22Result = opticalSWResult and packetSWResult and \
1891 linkActiveResult
1892 utilities.assert_equals(
1893 expect=main.TRUE,
1894 actual=case22Result,
1895 onpass="Packet optical topology discovery successful",
1896 onfail="Packet optical topology discovery failed" )
1897
1898 def CASE23( self, main ):
1899 import time
1900 """
1901 Add bidirectional point intents between 2 packet layer( mininet )
1902 devices and
1903 ping mininet hosts
1904 """
1905 main.log.report(
1906 "This testcase adds bidirectional point intents between 2 " +
1907 "packet layer( mininet ) devices and ping mininet hosts" )
1908 main.case( "Topology comparision" )
1909 main.step( "Adding point intents" )
1910 ptpIntentResult = main.ONOScli1.addPointIntent(
1911 "of:0000ffffffff0001/1",
1912 "of:0000ffffffff0005/1" )
1913 if ptpIntentResult == main.TRUE:
1914 main.ONOScli1.intents( jsonFormat=False )
1915 main.log.info( "Point to point intent install successful" )
1916
1917 ptpIntentResult = main.ONOScli1.addPointIntent(
1918 "of:0000ffffffff0005/1",
1919 "of:0000ffffffff0001/1" )
1920 if ptpIntentResult == main.TRUE:
1921 main.ONOScli1.intents( jsonFormat=False )
1922 main.log.info( "Point to point intent install successful" )
1923
1924 time.sleep( 30 )
1925 flowHandle = main.ONOScli1.flows()
1926 main.log.info( "flows :" + flowHandle )
1927
1928 # Sleep for 30 seconds to provide time for the intent state to change
1929 time.sleep( 60 )
1930 intentHandle = main.ONOScli1.intents( jsonFormat=False )
1931 main.log.info( "intents :" + intentHandle )
1932
1933 PingResult = main.TRUE
1934 count = 1
1935 main.log.info( "\n\nh1 is Pinging h5" )
1936 ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
1937 # ping = main.LincOE2.pinghost()
1938 if ping == main.FALSE and count < 5:
1939 count += 1
1940 PingResult = main.FALSE
1941 main.log.info(
1942 "Ping between h1 and h5 failed. Making attempt number " +
1943 str( count ) +
1944 " in 2 seconds" )
1945 time.sleep( 2 )
1946 elif ping == main.FALSE:
1947 main.log.info( "All ping attempts between h1 and h5 have failed" )
1948 PingResult = main.FALSE
1949 elif ping == main.TRUE:
1950 main.log.info( "Ping test between h1 and h5 passed!" )
1951 PingResult = main.TRUE
1952 else:
1953 main.log.info( "Unknown error" )
1954 PingResult = main.ERROR
1955
1956 if PingResult == main.FALSE:
1957 main.log.report(
1958 "Point intents for packet optical have not ben installed" +
1959 " correctly. Cleaning up" )
1960 if PingResult == main.TRUE:
1961 main.log.report(
1962 "Point Intents for packet optical have been " +
1963 "installed correctly" )
1964
1965 case23Result = PingResult
1966 utilities.assert_equals(
1967 expect=main.TRUE,
1968 actual=case23Result,
1969 onpass= "Point intents addition for packet optical and" +
1970 "Pingall Test successful",
1971 onfail= "Point intents addition for packet optical and" +
1972 "Pingall Test NOT successful" )
1973
1974 def CASE24( self, main ):
1975 import time
1976 import json
1977 """
1978 LINC uses its own switch IDs. You can use the following
1979 command on the LINC console to find the mapping between
1980 DPIDs and LINC IDs.
1981 rp(application:get_all_key(linc)).
1982
1983 Test Rerouting of Packet Optical by bringing a port down
1984 ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
1985 so that link
1986 ( between switch1 port20 - switch5 port50 ) is inactive
1987 and do a ping test. If rerouting is successful,
1988 ping should pass. also check the flows
1989 """
1990 main.log.report(
1991 "This testcase tests rerouting and pings mininet hosts" )
1992 main.case( "Test rerouting and pings mininet hosts" )
1993 main.step( "Attach to the Linc-OE session" )
1994 attachConsole = main.LincOE1.attachLincOESession()
1995 print "attachConsole = ", attachConsole
1996
1997 main.step( "Bring a port down and verify the link state" )
1998 main.LincOE1.portDown( swId="9", ptId="20" )
1999 linksNonjson = main.ONOScli3.links( jsonFormat=False )
2000 main.log.info( "links = " + linksNonjson )
2001
2002 linkInactiveCount = linksNonjson.count("state=INACTIVE")
2003 main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
2004 if linkInactiveCount == 2:
2005 main.log.info(
2006 "Number of links in INACTIVE state are correct")
2007 else:
2008 main.log.info(
2009 "Number of links in INACTIVE state are wrong")
2010
2011 links = main.ONOScli3.links()
2012 main.log.info( "links = " + links )
2013
2014 linksResult = json.loads( links )
2015 linksStateResult = main.FALSE
2016 for item in linksResult:
2017 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
2018 'src' ][ 'port' ] == "20":
2019 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
2020 'dst' ][ 'port' ] == "50":
2021 linksState = item[ 'state' ]
2022 if linksState == "INACTIVE":
2023 main.log.info(
2024 "Links state is inactive as expected due to one" +
2025 " of the ports being down" )
2026 main.log.report(
2027 "Links state is inactive as expected due to one" +
2028 " of the ports being down" )
2029 linksStateResult = main.TRUE
2030 break
2031 else:
2032 main.log.info(
2033 "Links state is not inactive as expected" )
2034 main.log.report(
2035 "Links state is not inactive as expected" )
2036 linksStateResult = main.FALSE
2037
2038 print "links_state_result = ", linksStateResult
2039 time.sleep( 10 )
2040 flowHandle = main.ONOScli3.flows()
2041 main.log.info( "flows :" + flowHandle )
2042
2043 main.step( "Verify Rerouting by a ping test" )
2044 PingResult = main.TRUE
2045 count = 1
2046 main.log.info( "\n\nh1 is Pinging h5" )
2047 ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
2048 # ping = main.LincOE2.pinghost()
2049 if ping == main.FALSE and count < 5:
2050 count += 1
2051 PingResult = main.FALSE
2052 main.log.info(
2053 "Ping between h1 and h5 failed. Making attempt number " +
2054 str( count ) +
2055 " in 2 seconds" )
2056 time.sleep( 2 )
2057 elif ping == main.FALSE:
2058 main.log.info( "All ping attempts between h1 and h5 have failed" )
2059 PingResult = main.FALSE
2060 elif ping == main.TRUE:
2061 main.log.info( "Ping test between h1 and h5 passed!" )
2062 PingResult = main.TRUE
2063 else:
2064 main.log.info( "Unknown error" )
2065 PingResult = main.ERROR
2066
2067 if PingResult == main.TRUE:
2068 main.log.report( "Ping test successful " )
2069 if PingResult == main.FALSE:
2070 main.log.report( "Ping test failed" )
2071
2072 case24Result = PingResult and linksStateResult
2073 utilities.assert_equals( expect=main.TRUE, actual=case24Result,
2074 onpass="Packet optical rerouting successful",
2075 onfail="Packet optical rerouting failed" )