blob: 2abd94cb073bd270e7a1e1e42bb7a8630b283906 [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
shahshreya4e13a062014-11-11 16:46:18 -080014class MultiProd:
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 """
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -080045 cellResult1 = main.ONOSbench.setCell( cellName )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080046 # cellResult2 = main.ONOScli1.setCell( cellName )
47 # cellResult3 = main.ONOScli2.setCell( cellName )
48 # cellResult4 = main.ONOScli3.setCell( cellName )
shahshreyaf3076352015-01-23 13:52:01 -080049 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" )
shahshreyaf3076352015-01-23 13:52:01 -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" )
shahshreyaf3076352015-01-23 13:52:01 -080057 gitPullResult = main.ONOSbench.gitPull()
shahshreya42efbd82015-02-05 17:06:08 -080058 main.log.info( "git_pull_result = " + str( gitPullResult ))
shahshreyaf3076352015-01-23 13:52:01 -080059 versionResult = main.ONOSbench.getVersion( report=True )
shahshreya4e13a062014-11-11 16:46:18 -080060
shahshreya234a1682015-05-27 15:41:56 -070061 packageResult = main.TRUE
shahshreyaa47ebf42015-05-20 13:29:18 -070062 if gitPullResult == 100:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080063 main.step( "Using mvn clean & install" )
shahshreyaf3076352015-01-23 13:52:01 -080064 cleanInstallResult = main.ONOSbench.cleanInstall()
shahshreya234a1682015-05-27 15:41:56 -070065 main.step( "Creating ONOS package" )
66 packageResult = main.ONOSbench.onosPackage()
kelvin-onlabcf33bda2015-01-23 16:54:17 -080067 # cleanInstallResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -080068
shahshreya4e13a062014-11-11 16:46:18 -080069
kelvin-onlabcf33bda2015-01-23 16:54:17 -080070 # main.step( "Creating a cell" )
shahshreyaf3076352015-01-23 13:52:01 -080071 # cellCreateResult = main.ONOSbench.createCellFile( **************
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080072 # )
shahshreya4e13a062014-11-11 16:46:18 -080073
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080074 main.step( "Installing ONOS package" )
shahshreyaf3076352015-01-23 13:52:01 -080075 onos1InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080076 options="-f",
shahshreyaf3076352015-01-23 13:52:01 -080077 node=ONOS1Ip )
78 onos2InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080079 options="-f",
shahshreyaf3076352015-01-23 13:52:01 -080080 node=ONOS2Ip )
81 onos3InstallResult = main.ONOSbench.onosInstall(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080082 options="-f",
shahshreyaf3076352015-01-23 13:52:01 -080083 node=ONOS3Ip )
kelvin-onlabcf33bda2015-01-23 16:54:17 -080084 onosInstallResult = onos1InstallResult and onos2InstallResult and\
85 onos3InstallResult
shahshreyaf3076352015-01-23 13:52:01 -080086 if onosInstallResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080087 main.log.report( "Installing ONOS package successful" )
shahshreya4e13a062014-11-11 16:46:18 -080088 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080089 main.log.report( "Installing ONOS package failed" )
90
shahshreyaf3076352015-01-23 13:52:01 -080091 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
92 onos2Isup = main.ONOSbench.isup( ONOS2Ip )
93 onos3Isup = main.ONOSbench.isup( ONOS3Ip )
94 onosIsup = onos1Isup and onos2Isup and onos3Isup
95 if onosIsup == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080096 main.log.report( "ONOS instances are up and ready" )
shahshreya4e13a062014-11-11 16:46:18 -080097 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -080098 main.log.report( "ONOS instances may not be up" )
shahshreya4e13a062014-11-11 16:46:18 -080099
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800100 main.step( "Starting ONOS service" )
shahshreyaf3076352015-01-23 13:52:01 -0800101 startResult = main.TRUE
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800102 # startResult = main.ONOSbench.onosStart( ONOS1Ip )
shahshreyaf3076352015-01-23 13:52:01 -0800103 startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip )
104 startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip )
105 startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip )
shahshreya4e13a062014-11-11 16:46:18 -0800106 print startcli1
107 print startcli2
108 print startcli3
shahshreya4e13a062014-11-11 16:46:18 -0800109
shahshreya42efbd82015-02-05 17:06:08 -0800110 # Starting the mininet using the old way
111 main.step( "Starting Mininet ..." )
112 netIsUp = main.Mininet1.startNet()
113 if netIsUp:
114 main.log.info("Mininet CLI is up")
115
shahshreyaf3076352015-01-23 13:52:01 -0800116 case1Result = ( packageResult and
117 cellResult and verifyResult and onosInstallResult and
118 onosIsup and startResult )
119 utilities.assertEquals( expect=main.TRUE, actual=case1Result,
120 onpass="Test startup successful",
121 onfail="Test startup NOT successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800122
123 def CASE11( self, main ):
124 """
shahshreya4e13a062014-11-11 16:46:18 -0800125 Cleanup sequence:
shahshreyaf3076352015-01-23 13:52:01 -0800126 onos-service <nodeIp> stop
shahshreya4e13a062014-11-11 16:46:18 -0800127 onos-uninstall
128
129 TODO: Define rest of cleanup
shahshreya4e13a062014-11-11 16:46:18 -0800130
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800131 """
shahshreyaf3076352015-01-23 13:52:01 -0800132 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
133 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
134 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
shahshreya4e13a062014-11-11 16:46:18 -0800135
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800136 main.case( "Cleaning up test environment" )
shahshreya4e13a062014-11-11 16:46:18 -0800137
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800138 main.step( "Testing ONOS kill function" )
shahshreyaf3076352015-01-23 13:52:01 -0800139 killResult1 = main.ONOSbench.onosKill( ONOS1Ip )
140 killResult2 = main.ONOSbench.onosKill( ONOS2Ip )
141 killResult3 = main.ONOSbench.onosKill( ONOS3Ip )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800142
143 main.step( "Stopping ONOS service" )
shahshreyaf3076352015-01-23 13:52:01 -0800144 stopResult1 = main.ONOSbench.onosStop( ONOS1Ip )
145 stopResult2 = main.ONOSbench.onosStop( ONOS2Ip )
146 stopResult3 = main.ONOSbench.onosStop( ONOS3Ip )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800147
148 main.step( "Uninstalling ONOS service" )
shahshreyaf3076352015-01-23 13:52:01 -0800149 uninstallResult = main.ONOSbench.onosUninstall()
shahshreya4e13a062014-11-11 16:46:18 -0800150
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800151 def CASE3( self, main ):
152 """
shahshreya4e13a062014-11-11 16:46:18 -0800153 Test 'onos' command and its functionality in driver
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800154 """
shahshreyaf3076352015-01-23 13:52:01 -0800155 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
156 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
157 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
shahshreya4e13a062014-11-11 16:46:18 -0800158
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800159 main.case( "Testing 'onos' command" )
shahshreya4e13a062014-11-11 16:46:18 -0800160
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800161 main.step( "Sending command 'onos -w <onos-ip> system:name'" )
shahshreya4e13a062014-11-11 16:46:18 -0800162 cmdstr1 = "system:name"
shahshreyaf3076352015-01-23 13:52:01 -0800163 cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
164 main.log.info( "onos command returned: " + cmdResult1 )
165 cmdResult2 = main.ONOSbench.onosCli( ONOS2Ip, cmdstr1 )
166 main.log.info( "onos command returned: " + cmdResult2 )
167 cmdResult3 = main.ONOSbench.onosCli( ONOS3Ip, cmdstr1 )
168 main.log.info( "onos command returned: " + cmdResult3 )
shahshreya4e13a062014-11-11 16:46:18 -0800169
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800170 main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
shahshreya4e13a062014-11-11 16:46:18 -0800171 cmdstr2 = "onos:topology"
shahshreyaf3076352015-01-23 13:52:01 -0800172 cmdResult4 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
173 main.log.info( "onos command returned: " + cmdResult4 )
174 cmdResult5 = main.ONOSbench.onosCli( ONOS2Ip, cmdstr2 )
175 main.log.info( "onos command returned: " + cmdResult5 )
176 cmdResult6 = main.ONOSbench.onosCli( ONOS6Ip, cmdstr2 )
177 main.log.info( "onos command returned: " + cmdResult6 )
shahshreya4e13a062014-11-11 16:46:18 -0800178
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800179 def CASE4( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800180 import re
181 import time
shahshreyaf3076352015-01-23 13:52:01 -0800182 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
183 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
184 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
185 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
186 ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
187 ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800188
189 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800190 "This testcase is testing the assignment of all the switches" +
191 " to all controllers and discovering the hosts in reactive mode" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800192 main.log.report( "__________________________________" )
193 main.case( "Pingall Test(No intents are added)" )
194 main.step( "Assigning switches to controllers" )
195 for i in range( 1, 29 ): # 1 to ( num of switches +1 )
shahshreyaf3076352015-01-23 13:52:01 -0800196 main.Mininet1.assignSwController(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800197 sw=str( i ),
198 count=3,
shahshreyaf3076352015-01-23 13:52:01 -0800199 ip1=ONOS1Ip,
200 port1=ONOS1Port,
201 ip2=ONOS2Ip,
202 port2=ONOS2Port,
203 ip3=ONOS3Ip,
204 port3=ONOS3Port )
shahshreya4e13a062014-11-11 16:46:18 -0800205
shahshreyaf3076352015-01-23 13:52:01 -0800206 switchMastership = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800207 for i in range( 1, 29 ):
shahshreyaf3076352015-01-23 13:52:01 -0800208 response = main.Mininet1.getSwController( "s" + str( i ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800209 print( "Response is " + str( response ) )
shahshreyaf3076352015-01-23 13:52:01 -0800210 if re.search( "tcp:" + ONOS1Ip, response ):
211 switchMastership = switchMastership and main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800212 else:
shahshreyaf3076352015-01-23 13:52:01 -0800213 switchMastership = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800214
shahshreyaf3076352015-01-23 13:52:01 -0800215 if switchMastership == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800216 main.log.report( "Controller assignment successfull" )
shahshreya4e13a062014-11-11 16:46:18 -0800217 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800218 main.log.report( "Controller assignment failed" )
shahshreyad524a942015-04-21 09:55:16 -0700219 appInstallResult = main.TRUE
220 main.log.info( "Activating reactive forwarding app" )
221 appInstallResult = main.ONOScli1.activateApp( "org.onosproject.fwd" )
222 appCheck = main.ONOScli1.appToIDCheck()
223 if appCheck != main.TRUE:
224 main.log.warn( main.ONOScli1.apps() )
225 main.log.warn( main.ONOScli1.appIDs() )
226 time.sleep( 30 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800227 # REACTIVE FWD test
228 main.step( "Pingall" )
shahshreyaf3076352015-01-23 13:52:01 -0800229 pingResult = main.FALSE
shahshreya4e13a062014-11-11 16:46:18 -0800230 time1 = time.time()
shahshreyaf3076352015-01-23 13:52:01 -0800231 pingResult = main.Mininet1.pingall()
shahshreya4e13a062014-11-11 16:46:18 -0800232 time2 = time.time()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800233 print "Time for pingall: %2f seconds" % ( time2 - time1 )
234
shahshreyaf3076352015-01-23 13:52:01 -0800235 case4Result = switchMastership and pingResult
236 if pingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800237 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800238 "Pingall Test in reactive mode to" +
239 " discover the hosts successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800240 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800241 main.log.report(
242 "Pingall Test in reactive mode to discover the hosts failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800243
shahshreyaf3076352015-01-23 13:52:01 -0800244 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800245 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800246 actual=case4Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800247 onpass="Controller assignment and Pingall Test successful",
248 onfail="Controller assignment and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800249
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800250 def CASE5( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800251 import json
252 from subprocess import Popen, PIPE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800253 # assumes that sts is already in you PYTHONPATH
254 from sts.topology.teston_topology import TestONTopology
shahshreyaf3076352015-01-23 13:52:01 -0800255 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
256 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
257 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800258
259 main.log.report(
shahshreyad2ef8bf2015-04-03 15:34:55 -0700260 "This testcase is testing if all ONOS nodes are in topology" +
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800261 " sync with mininet and its peer ONOS nodes" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800262 main.log.report( "__________________________________" )
263 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800264 "Testing Mininet topology with the" +
265 " topology of multi instances ONOS" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800266 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800267 devices1 = main.ONOScli1.devices()
268 devices2 = main.ONOScli2.devices()
269 devices3 = main.ONOScli3.devices()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800270 # print "devices1 = ", devices1
271 # print "devices2 = ", devices2
272 # print "devices3 = ", devices3
shahshreya4e13a062014-11-11 16:46:18 -0800273 hosts1 = main.ONOScli1.hosts()
274 hosts2 = main.ONOScli2.hosts()
275 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800276 # print "hosts1 = ", hosts1
277 # print "hosts2 = ", hosts2
278 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800279 ports1 = main.ONOScli1.ports()
280 ports2 = main.ONOScli2.ports()
281 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800282 # print "ports1 = ", ports1
283 # print "ports2 = ", ports2
284 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800285 links1 = main.ONOScli1.links()
286 links2 = main.ONOScli2.links()
287 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800288 # print "links1 = ", links1
289 # print "links2 = ", links2
290 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800291
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800292 print "**************"
293
294 main.step( "Start continuous pings" )
295 main.Mininet2.pingLong(
296 src=main.params[ 'PING' ][ 'source1' ],
297 target=main.params[ 'PING' ][ 'target1' ],
298 pingTime=500 )
299 main.Mininet2.pingLong(
300 src=main.params[ 'PING' ][ 'source2' ],
301 target=main.params[ 'PING' ][ 'target2' ],
302 pingTime=500 )
303 main.Mininet2.pingLong(
304 src=main.params[ 'PING' ][ 'source3' ],
305 target=main.params[ 'PING' ][ 'target3' ],
306 pingTime=500 )
307 main.Mininet2.pingLong(
308 src=main.params[ 'PING' ][ 'source4' ],
309 target=main.params[ 'PING' ][ 'target4' ],
310 pingTime=500 )
311 main.Mininet2.pingLong(
312 src=main.params[ 'PING' ][ 'source5' ],
313 target=main.params[ 'PING' ][ 'target5' ],
314 pingTime=500 )
315 main.Mininet2.pingLong(
316 src=main.params[ 'PING' ][ 'source6' ],
317 target=main.params[ 'PING' ][ 'target6' ],
318 pingTime=500 )
319 main.Mininet2.pingLong(
320 src=main.params[ 'PING' ][ 'source7' ],
321 target=main.params[ 'PING' ][ 'target7' ],
322 pingTime=500 )
323 main.Mininet2.pingLong(
324 src=main.params[ 'PING' ][ 'source8' ],
325 target=main.params[ 'PING' ][ 'target8' ],
326 pingTime=500 )
327 main.Mininet2.pingLong(
328 src=main.params[ 'PING' ][ 'source9' ],
329 target=main.params[ 'PING' ][ 'target9' ],
330 pingTime=500 )
331 main.Mininet2.pingLong(
332 src=main.params[ 'PING' ][ 'source10' ],
333 target=main.params[ 'PING' ][ 'target10' ],
334 pingTime=500 )
335
336 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800337 global ctrls
338 ctrls = []
339 count = 1
340 while True:
341 temp = ()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800342 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
343 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
344 temp = temp + ( "ONOS" + str( count ), )
345 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
346 temp = temp + \
347 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
348 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800349 count = count + 1
350 else:
351 break
352 global MNTopo
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800353 Topo = TestONTopology(
354 main.Mininet1,
355 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800356 MNTopo = Topo
357
shahshreyaf3076352015-01-23 13:52:01 -0800358 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800359 main.step( "Compare ONOS Topology to MN Topology" )
360
shahshreyaf3076352015-01-23 13:52:01 -0800361 switchesResults1 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800362 MNTopo,
363 json.loads( devices1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800364 print "switches_Result1 = ", switchesResults1
365 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
366 onpass="ONOS1 Switches view is correct",
367 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800368
shahshreyaf3076352015-01-23 13:52:01 -0800369 switchesResults2 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800370 MNTopo,
371 json.loads( devices2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800372 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
373 onpass="ONOS2 Switches view is correct",
374 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800375
shahshreyaf3076352015-01-23 13:52:01 -0800376 switchesResults3 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800377 MNTopo,
378 json.loads( devices3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800379 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
380 onpass="ONOS3 Switches view is correct",
381 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800382
383 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800384 portsResults1 = main.Mininet1.comparePorts( MNTopo,
385 json.loads( ports1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800386 utilities.assertEquals( expect=main.TRUE, actual=portsResults1,
shahshreya4e13a062014-11-11 16:46:18 -0800387 onpass="ONOS1 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800388 onfail="ONOS1 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800389
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800390 portsResults2 = main.Mininet1.comparePorts( MNTopo,
391 json.loads( ports2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800392 utilities.assertEquals( expect=main.TRUE, actual=portsResults2,
shahshreya4e13a062014-11-11 16:46:18 -0800393 onpass="ONOS2 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800394 onfail="ONOS2 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800395
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800396 portsResults3 = main.Mininet1.comparePorts( MNTopo,
397 json.loads( ports3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800398 utilities.assertEquals( expect=main.TRUE, actual=portsResults3,
shahshreya4e13a062014-11-11 16:46:18 -0800399 onpass="ONOS3 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800400 onfail="ONOS3 Ports view is incorrect" )
401 """
shahshreyaf3076352015-01-23 13:52:01 -0800402 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800403 MNTopo,
404 json.loads( links1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800405 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
406 onpass="ONOS1 Links view is correct",
407 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800408
shahshreyaf3076352015-01-23 13:52:01 -0800409 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800410 MNTopo,
411 json.loads( links2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800412 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
413 onpass="ONOS2 Links view is correct",
414 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800415
shahshreyaf3076352015-01-23 13:52:01 -0800416 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800417 MNTopo,
418 json.loads( links3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800419 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
420 onpass="ONOS2 Links view is correct",
421 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800422
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800423 # topoResult = switchesResults1 and switchesResults2
424 # and switchesResults3\
shahshreyaf3076352015-01-23 13:52:01 -0800425 # and portsResults1 and portsResults2 and portsResults3\
426 # and linksResults1 and linksResults2 and linksResults3
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800427
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800428 topoResult = switchesResults1 and switchesResults2 and\
429 switchesResults3 and linksResults1 and linksResults2 and\
430 linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800431
shahshreyaf3076352015-01-23 13:52:01 -0800432 if topoResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800433 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800434 "Topology Check Test with mininet" +
435 "and ONOS instances successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800436 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800437 main.log.report(
438 "Topology Check Test with mininet and ONOS instances failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800439
shahshreyaf3076352015-01-23 13:52:01 -0800440 utilities.assertEquals( expect=main.TRUE, actual=topoResult,
441 onpass="Topology Check Test successful",
442 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800443
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800444 def CASE10( self ):
shahshreya1f119da2015-04-21 17:16:46 -0700445 import time
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800446 main.log.report(
447 "This testcase uninstalls the reactive forwarding app" )
448 main.log.report( "__________________________________" )
449 main.case( "Uninstalling reactive forwarding app" )
450 # Unistall onos-app-fwd app to disable reactive forwarding
shahshreyad524a942015-04-21 09:55:16 -0700451 appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.fwd" )
452 appCheck = main.ONOScli1.appToIDCheck()
453 if appCheck != main.TRUE:
454 main.log.warn( main.ONOScli1.apps() )
455 main.log.warn( main.ONOScli1.appIDs() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800456 main.log.info( "onos-app-fwd uninstalled" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800457
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800458 # After reactive forwarding is disabled,
459 # the reactive flows on switches timeout in 10-15s
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800460 # So sleep for 15s
461 time.sleep( 15 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800462
shahshreyae6c7cf42014-11-26 16:39:01 -0800463 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800464 main.log.info( hosts )
shahshreyad524a942015-04-21 09:55:16 -0700465 case10Result = appInstallResult
shahshreyaf3076352015-01-23 13:52:01 -0800466 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800467 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800468 actual=case10Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800469 onpass="Reactive forwarding app uninstallation successful",
470 onfail="Reactive forwarding app uninstallation failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800471
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800472 def CASE6( self ):
473 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800474 "This testcase is testing the addition of" +
475 " host intents and then doing pingall" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800476 main.log.report( "__________________________________" )
477 main.case( "Obtaining hostsfor adding host intents" )
478 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800479 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800480 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800481
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800482 main.step( "Get all devices id" )
shahshreyaf3076352015-01-23 13:52:01 -0800483 devicesIdList = main.ONOScli1.getAllDevicesId()
484 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -0800485
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800486 # ONOS displays the hosts in hex format
487 # unlike mininet which does in decimal format
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800488 # So take care while adding intents
shahshreya4e13a062014-11-11 16:46:18 -0800489
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800490 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800491 main.step( "Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,
492 h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
493 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:08/-1",
494 "00:00:00:00:00:12/-1" )
495 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:09/-1",
496 "00:00:00:00:00:13/-1" )
497 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0A/-1",
498 "00:00:00:00:00:14/-1" )
499 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0B/-1",
500 "00:00:00:00:00:15/-1" )
501 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0C/-1",
502 "00:00:00:00:00:16/-1" )
503 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0D/-1",
504 "00:00:00:00:00:17/-1" )
505 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0E/-1",
506 "00:00:00:00:00:18/-1" )
507 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0F/-1",
508 "00:00:00:00:00:19/-1" )
509 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:10/-1",
510 "00:00:00:00:00:1A/-1" )
511 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:11/-1",
512 "00:00:00:00:00:1B/-1" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800513 """
shahshreya234a1682015-05-27 15:41:56 -0700514 intentsId = []
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800515 for i in range( 8, 18 ):
516 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800517 "Adding host intent between h" + str( i ) +
518 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800519 host1 = "00:00:00:00:00:" + \
520 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
521 host2 = "00:00:00:00:00:" + \
522 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
523 # NOTE: get host can return None
524 # TODO: handle this
shahshreyaf3076352015-01-23 13:52:01 -0800525 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
526 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
527 tmpResult = main.ONOScli1.addHostIntent( host1Id, host2Id )
shahshreya234a1682015-05-27 15:41:56 -0700528 intentsId.append( tmpResult )
529
530 checkIntent1 = main.ONOScli1.checkIntentState( intentsId )
531 checkIntent2 = main.ONOScli2.checkIntentState( intentsId )
532 checkIntent3 = main.ONOScli3.checkIntentState( intentsId )
shahshreya4e13a062014-11-11 16:46:18 -0800533
534 flowHandle = main.ONOScli1.flows()
shahshreya234a1682015-05-27 15:41:56 -0700535
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800536 main.log.info( "flows:" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -0800537
538 count = 1
539 i = 8
shahshreyaf3076352015-01-23 13:52:01 -0800540 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800541 while i < 18:
542 main.log.info(
543 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
544 ping = main.Mininet1.pingHost(
545 src="h" + str( i ), target="h" + str( i + 10 ) )
546 if ping == main.FALSE and count < 5:
547 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800548 # i = 8
shahshreyaf3076352015-01-23 13:52:01 -0800549 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800550 main.log.report( "Ping between h" +
551 str( i ) +
552 " and h" +
553 str( i +
554 10 ) +
555 " failed. Making attempt number " +
556 str( count ) +
557 " in 2 seconds" )
558 time.sleep( 2 )
559 elif ping == main.FALSE:
560 main.log.report( "All ping attempts between h" +
561 str( i ) +
562 " and h" +
563 str( i +
564 10 ) +
565 "have failed" )
566 i = 19
shahshreyaf3076352015-01-23 13:52:01 -0800567 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800568 elif ping == main.TRUE:
569 main.log.info( "Ping test between h" +
570 str( i ) +
571 " and h" +
572 str( i +
573 10 ) +
574 "passed!" )
575 i += 1
shahshreyaf3076352015-01-23 13:52:01 -0800576 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800577 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800578 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -0800579 PingResult = main.ERROR
580 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800581 main.log.report(
582 "Host intents have not ben installed correctly. Cleaning up" )
583 # main.cleanup()
584 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -0800585 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800586 main.log.report( "Host intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -0800587
shahshreya234a1682015-05-27 15:41:56 -0700588 checkIntent1 = main.ONOScli1.checkIntentState( intentsId )
589 checkIntent2 = main.ONOScli2.checkIntentState( intentsId )
590 checkIntent3 = main.ONOScli3.checkIntentState( intentsId )
591
shahshreyaf3076352015-01-23 13:52:01 -0800592 case6Result = PingResult
593 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800594 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800595 actual=case6Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800596 onpass="Host intent addition and Pingall Test successful",
597 onfail="Host intent addition and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800598
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800599 def CASE7( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800600
shahshreyaf3076352015-01-23 13:52:01 -0800601 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800602
shahshreyaf3076352015-01-23 13:52:01 -0800603 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800604
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800605 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800606 "This testscase is killing a link to" +
607 " ensure that link discovery is consistent" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800608 main.log.report( "__________________________________" )
609 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800610 "Killing a link to Ensure that Link" +
611 " Discovery is Working Properly" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800612 main.step( "Start continuous pings" )
shahshreya4e13a062014-11-11 16:46:18 -0800613
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800614 main.Mininet2.pingLong(
615 src=main.params[ 'PING' ][ 'source1' ],
616 target=main.params[ 'PING' ][ 'target1' ],
617 pingTime=500 )
618 main.Mininet2.pingLong(
619 src=main.params[ 'PING' ][ 'source2' ],
620 target=main.params[ 'PING' ][ 'target2' ],
621 pingTime=500 )
622 main.Mininet2.pingLong(
623 src=main.params[ 'PING' ][ 'source3' ],
624 target=main.params[ 'PING' ][ 'target3' ],
625 pingTime=500 )
626 main.Mininet2.pingLong(
627 src=main.params[ 'PING' ][ 'source4' ],
628 target=main.params[ 'PING' ][ 'target4' ],
629 pingTime=500 )
630 main.Mininet2.pingLong(
631 src=main.params[ 'PING' ][ 'source5' ],
632 target=main.params[ 'PING' ][ 'target5' ],
633 pingTime=500 )
634 main.Mininet2.pingLong(
635 src=main.params[ 'PING' ][ 'source6' ],
636 target=main.params[ 'PING' ][ 'target6' ],
637 pingTime=500 )
638 main.Mininet2.pingLong(
639 src=main.params[ 'PING' ][ 'source7' ],
640 target=main.params[ 'PING' ][ 'target7' ],
641 pingTime=500 )
642 main.Mininet2.pingLong(
643 src=main.params[ 'PING' ][ 'source8' ],
644 target=main.params[ 'PING' ][ 'target8' ],
645 pingTime=500 )
646 main.Mininet2.pingLong(
647 src=main.params[ 'PING' ][ 'source9' ],
648 target=main.params[ 'PING' ][ 'target9' ],
649 pingTime=500 )
650 main.Mininet2.pingLong(
651 src=main.params[ 'PING' ][ 'source10' ],
652 target=main.params[ 'PING' ][ 'target10' ],
653 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -0800654
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800655 main.step( "Determine the current number of switches and links" )
shahshreyaf3076352015-01-23 13:52:01 -0800656 topologyOutput = main.ONOScli1.topology()
657 topologyResult = main.ONOSbench.getTopology( topologyOutput )
shahshreyaa47ebf42015-05-20 13:29:18 -0700658 activeSwitches = topologyResult[ 'devices' ]
659 links = topologyResult[ 'links' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800660 main.log.info(
661 "Currently there are %s switches and %s links" %
662 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -0800663
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800664 main.step( "Kill Link between s3 and s28" )
665 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
shahshreyaf3076352015-01-23 13:52:01 -0800666 time.sleep( linkSleep )
667 topologyOutput = main.ONOScli2.topology()
668 LinkDown = main.ONOSbench.checkStatus(
669 topologyOutput, activeSwitches, str(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800670 int( links ) - 2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800671 if LinkDown == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800672 main.log.report( "Link Down discovered properly" )
shahshreyaf3076352015-01-23 13:52:01 -0800673 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800674 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800675 actual=LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800676 onpass="Link Down discovered properly",
677 onfail="Link down was not discovered in " +
shahshreyaf3076352015-01-23 13:52:01 -0800678 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800679 " seconds" )
shahshreya4e13a062014-11-11 16:46:18 -0800680
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800681 main.step( "Bring link between s3 and s28 back up" )
shahshreyaf3076352015-01-23 13:52:01 -0800682 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
683 time.sleep( linkSleep )
684 topologyOutput = main.ONOScli2.topology()
685 LinkUp = main.ONOSbench.checkStatus(
686 topologyOutput,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800687 activeSwitches,
688 str( links ) )
shahshreyaf3076352015-01-23 13:52:01 -0800689 if LinkUp == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800690 main.log.report( "Link up discovered properly" )
shahshreyaf3076352015-01-23 13:52:01 -0800691 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800692 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800693 actual=LinkUp,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800694 onpass="Link up discovered properly",
695 onfail="Link up was not discovered in " +
shahshreyaf3076352015-01-23 13:52:01 -0800696 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800697 " seconds" )
698
699 main.step( "Compare ONOS Topology to MN Topology" )
700 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800701 "Testing Mininet topology with the" +
702 " topology of multi instances ONOS" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800703 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800704 devices1 = main.ONOScli1.devices()
705 devices2 = main.ONOScli2.devices()
706 devices3 = main.ONOScli3.devices()
707 print "devices1 = ", devices1
708 print "devices2 = ", devices2
709 print "devices3 = ", devices3
710 hosts1 = main.ONOScli1.hosts()
711 hosts2 = main.ONOScli2.hosts()
712 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800713 # print "hosts1 = ", hosts1
714 # print "hosts2 = ", hosts2
715 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800716 ports1 = main.ONOScli1.ports()
717 ports2 = main.ONOScli2.ports()
718 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800719 # print "ports1 = ", ports1
720 # print "ports2 = ", ports2
721 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800722 links1 = main.ONOScli1.links()
723 links2 = main.ONOScli2.links()
724 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800725 # print "links1 = ", links1
726 # print "links2 = ", links2
727 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800728
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800729 print "**************"
730
731 main.step( "Start continuous pings" )
732 main.Mininet2.pingLong(
733 src=main.params[ 'PING' ][ 'source1' ],
734 target=main.params[ 'PING' ][ 'target1' ],
735 pingTime=500 )
736 main.Mininet2.pingLong(
737 src=main.params[ 'PING' ][ 'source2' ],
738 target=main.params[ 'PING' ][ 'target2' ],
739 pingTime=500 )
740 main.Mininet2.pingLong(
741 src=main.params[ 'PING' ][ 'source3' ],
742 target=main.params[ 'PING' ][ 'target3' ],
743 pingTime=500 )
744 main.Mininet2.pingLong(
745 src=main.params[ 'PING' ][ 'source4' ],
746 target=main.params[ 'PING' ][ 'target4' ],
747 pingTime=500 )
748 main.Mininet2.pingLong(
749 src=main.params[ 'PING' ][ 'source5' ],
750 target=main.params[ 'PING' ][ 'target5' ],
751 pingTime=500 )
752 main.Mininet2.pingLong(
753 src=main.params[ 'PING' ][ 'source6' ],
754 target=main.params[ 'PING' ][ 'target6' ],
755 pingTime=500 )
756 main.Mininet2.pingLong(
757 src=main.params[ 'PING' ][ 'source7' ],
758 target=main.params[ 'PING' ][ 'target7' ],
759 pingTime=500 )
760 main.Mininet2.pingLong(
761 src=main.params[ 'PING' ][ 'source8' ],
762 target=main.params[ 'PING' ][ 'target8' ],
763 pingTime=500 )
764 main.Mininet2.pingLong(
765 src=main.params[ 'PING' ][ 'source9' ],
766 target=main.params[ 'PING' ][ 'target9' ],
767 pingTime=500 )
768 main.Mininet2.pingLong(
769 src=main.params[ 'PING' ][ 'source10' ],
770 target=main.params[ 'PING' ][ 'target10' ],
771 pingTime=500 )
772
773 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800774 global ctrls
775 ctrls = []
776 count = 1
777 while True:
778 temp = ()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800779 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
780 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
781 temp = temp + ( "ONOS" + str( count ), )
782 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
783 temp = temp + \
784 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
785 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800786 count = count + 1
787 else:
788 break
789 global MNTopo
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800790 Topo = TestONTopology(
791 main.Mininet1,
792 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800793 MNTopo = Topo
794
shahshreyaf3076352015-01-23 13:52:01 -0800795 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800796 main.step( "Compare ONOS Topology to MN Topology" )
797
shahshreyaf3076352015-01-23 13:52:01 -0800798 switchesResults1 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800799 MNTopo,
800 json.loads( devices1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800801 print "switches_Result1 = ", switchesResults1
802 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
803 onpass="ONOS1 Switches view is correct",
804 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800805
shahshreyaf3076352015-01-23 13:52:01 -0800806 switchesResults2 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800807 MNTopo,
808 json.loads( devices2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800809 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
810 onpass="ONOS2 Switches view is correct",
811 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800812
shahshreyaf3076352015-01-23 13:52:01 -0800813 switchesResults3 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800814 MNTopo,
815 json.loads( devices3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800816 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
817 onpass="ONOS3 Switches view is correct",
818 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800819
820 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800821 portsResults1 = main.Mininet1.comparePorts( MNTopo,
822 json.loads( ports1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800823 utilities.assertEquals( expect=main.TRUE, actual=portsResults1,
shahshreya4e13a062014-11-11 16:46:18 -0800824 onpass="ONOS1 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800825 onfail="ONOS1 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800826
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800827 portsResults2 = main.Mininet1.comparePorts( MNTopo,
828 json.loads( ports2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800829 utilities.assertEquals( expect=main.TRUE, actual=portsResults2,
shahshreya4e13a062014-11-11 16:46:18 -0800830 onpass="ONOS2 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800831 onfail="ONOS2 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800832
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800833 portsResults3 = main.Mininet1.comparePorts( MNTopo,
834 json.loads( ports3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800835 utilities.assertEquals( expect=main.TRUE, actual=portsResults3,
shahshreya4e13a062014-11-11 16:46:18 -0800836 onpass="ONOS3 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800837 onfail="ONOS3 Ports view is incorrect" )
838 """
shahshreyaf3076352015-01-23 13:52:01 -0800839 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800840 MNTopo,
841 json.loads( links1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800842 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
843 onpass="ONOS1 Links view is correct",
844 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800845
shahshreyaf3076352015-01-23 13:52:01 -0800846 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800847 MNTopo,
848 json.loads( links2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800849 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
850 onpass="ONOS2 Links view is correct",
851 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800852
shahshreyaf3076352015-01-23 13:52:01 -0800853 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800854 MNTopo,
855 json.loads( links3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800856 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
857 onpass="ONOS2 Links view is correct",
858 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800859
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800860 # topoResult = switchesResults1 and switchesResults2
861 # and switchesResults3\
shahshreyaf3076352015-01-23 13:52:01 -0800862 # and portsResults1 and portsResults2 and portsResults3\
863 # and linksResults1 and linksResults2 and linksResults3
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800864
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800865 topoResult = switchesResults1 and switchesResults2\
866 and switchesResults3 and linksResults1 and\
867 linksResults2 and linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800868
shahshreyaf3076352015-01-23 13:52:01 -0800869 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800870 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800871 actual=topoResult and LinkUp and LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800872 onpass="Topology Check Test successful",
873 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800874
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800875 def CASE8( self ):
876 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800877 Intent removal
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800878 """
879 main.log.report(
shahshreyab512cd02015-01-27 17:01:47 -0800880 "This testcase removes any previously added intents" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800881 main.log.report( "__________________________________" )
882 main.log.info( "Removing any previously installed intents" )
883 main.case( "Removing intents" )
884 main.step( "Obtain the intent id's" )
shahshreyaf3076352015-01-23 13:52:01 -0800885 intentResult = main.ONOScli1.intents( jsonFormat=False )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800886
shahshreyaf3076352015-01-23 13:52:01 -0800887 intentLinewise = intentResult.split( "\n" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800888 intentList = []
shahshreyaf3076352015-01-23 13:52:01 -0800889 for line in intentLinewise:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800890 if line.startswith( "id=" ):
891 intentList.append( line )
shahshreyae6c7cf42014-11-26 16:39:01 -0800892
893 intentids = []
894 for line in intentList:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800895 intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
shahshreya4e13a062014-11-11 16:46:18 -0800896 for id in intentids:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800897 main.log.info( "id = " + id )
shahshreyae6c7cf42014-11-26 16:39:01 -0800898
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800899 main.step(
900 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -0800901 for id in intentids:
shahshreyaa47ebf42015-05-20 13:29:18 -0700902 main.ONOScli1.removeIntent( intentId=id ,purge=True )
shahshreyae6c7cf42014-11-26 16:39:01 -0800903
shahshreya234a1682015-05-27 15:41:56 -0700904 remainingIntent = main.ONOScli1.intents( jsonFormat=False )
905 main.log.info( "Remaining intents " + remainingIntent )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800906
shahshreya234a1682015-05-27 15:41:56 -0700907 case8Result = main.TRUE
908 intentResult = main.TRUE
909 if remainingIntent:
910 main.log.error( "There are still remaining intent" )
911 intentResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800912 i = 8
shahshreya234a1682015-05-27 15:41:56 -0700913
shahshreyaf3076352015-01-23 13:52:01 -0800914 PingResult = main.TRUE
shahshreya234a1682015-05-27 15:41:56 -0700915 """
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800916 while i < 18:
917 main.log.info(
918 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
919 ping = main.Mininet1.pingHost(
920 src="h" + str( i ), target="h" + str( i + 10 ) )
921 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -0800922 i = 19
shahshreyaf3076352015-01-23 13:52:01 -0800923 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800924 elif ping == main.FALSE:
925 i += 1
shahshreyaf3076352015-01-23 13:52:01 -0800926 PingResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800927 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800928 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -0800929 PingResult = main.ERROR
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800930 # Note: If the ping result failed, that means the intents have been
931 # withdrawn correctly.
shahshreyaf3076352015-01-23 13:52:01 -0800932 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800933 main.log.report( "Host intents have not been withdrawn correctly" )
934 # main.cleanup()
935 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -0800936 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800937 main.log.report( "Host intents have been withdrawn correctly" )
shahshreya234a1682015-05-27 15:41:56 -0700938 """
939 case8Result = intentResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800940
shahshreya234a1682015-05-27 15:41:56 -0700941 if case8Result == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800942 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800943 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800944 main.log.report( "Intent removal failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800945
shahshreya234a1682015-05-27 15:41:56 -0700946 utilities.assertEquals( expect=main.TRUE, actual=case8Result,
947 onpass="Intent removal test successful",
948 onfail="Intent removal test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800949
950 def CASE9( self ):
951 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800952 This test case adds point intents. Make sure you run test case 8
953 which is host intent removal before executing this test case.
954 Else the host intent's flows will persist on switches and the pings
955 would work even if there is some issue with the point intent's flows
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800956 """
957 main.log.report(
958 "This testcase adds point intents and then does pingall" )
959 main.log.report( "__________________________________" )
960 main.log.info( "Adding point intents" )
961 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800962 "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20," +
963 "h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800964 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800965 "Add point-to-point intents for mininet hosts" +
966 " h8 and h18 or ONOS hosts h8 and h12" )
shahshreyaa47ebf42015-05-20 13:29:18 -0700967 macsDict = {}
968 for i in range( 1,29 ):
969 macsDict[ 'h' + str( i ) ]= main.Mininet1.getMacAddress( host='h'+ str( i ) )
970 print macsDict
971 # main.step(var1)
shahshreyaf3076352015-01-23 13:52:01 -0800972 ptpIntentResult = main.ONOScli1.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -0700973 ingressDevice="of:0000000000003008/1",
974 egressDevice="of:0000000000006018/1",
975 ethType='IPV4',
976 ethSrc=macsDict.get( 'h8' ))
shahshreyaf3076352015-01-23 13:52:01 -0800977 if ptpIntentResult == main.TRUE:
978 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800979 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800980 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800981
shahshreyaf3076352015-01-23 13:52:01 -0800982 ptpIntentResult = main.ONOScli1.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -0700983 ingressDevice="of:0000000000006018/1",
984 egressDevice="of:0000000000003008/1",
985 ethType='IPV4',
986 ethSrc=macsDict.get( 'h18' ))
shahshreyaf3076352015-01-23 13:52:01 -0800987 if ptpIntentResult == main.TRUE:
988 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800989 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800990 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800991
shahshreyaa47ebf42015-05-20 13:29:18 -0700992 var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
993 main.step(var2)
shahshreyaf3076352015-01-23 13:52:01 -0800994 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800995 "of:0000000000003009/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700996 "of:0000000000006019/1",
997 ethType='IPV4',
998 ethSrc=macsDict.get( 'h9' ))
shahshreyaf3076352015-01-23 13:52:01 -0800999 if ptpIntentResult == main.TRUE:
1000 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001001 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001002 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001003
shahshreyaf3076352015-01-23 13:52:01 -08001004 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001005 "of:0000000000006019/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001006 "of:0000000000003009/1",
1007 ethType='IPV4',
1008 ethSrc=macsDict.get( 'h19' ))
shahshreyaf3076352015-01-23 13:52:01 -08001009 if ptpIntentResult == main.TRUE:
1010 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001011 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001012 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001013
shahshreyaa47ebf42015-05-20 13:29:18 -07001014 var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
1015 main.step(var3)
shahshreyaf3076352015-01-23 13:52:01 -08001016 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001017 "of:0000000000003010/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001018 "of:0000000000006020/1",
1019 ethType='IPV4',
1020 ethSrc=macsDict.get( 'h10' ))
1021
shahshreyaf3076352015-01-23 13:52:01 -08001022 if ptpIntentResult == main.TRUE:
1023 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001024 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001025 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001026
shahshreyaf3076352015-01-23 13:52:01 -08001027 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001028 "of:0000000000006020/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001029 "of:0000000000003010/1",
1030 ethType='IPV4',
1031 ethSrc=macsDict.get( 'h20' ))
1032
shahshreyaf3076352015-01-23 13:52:01 -08001033 if ptpIntentResult == main.TRUE:
1034 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001035 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001036 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001037
shahshreyaa47ebf42015-05-20 13:29:18 -07001038 var4 = "Add point intents for mininet hosts h11 and h21 or" +\
1039 " ONOS hosts hB and h15"
1040 main.case(var4)
shahshreyaf3076352015-01-23 13:52:01 -08001041 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001042 "of:0000000000003011/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001043 "of:0000000000006021/1",
1044 ethType='IPV4',
1045 ethSrc=macsDict.get( 'h11' ))
1046
shahshreyaf3076352015-01-23 13:52:01 -08001047 if ptpIntentResult == main.TRUE:
1048 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001049 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001050 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001051
shahshreyaf3076352015-01-23 13:52:01 -08001052 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001053 "of:0000000000006021/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001054 "of:0000000000003011/1",
1055 ethType='IPV4',
1056 ethSrc=macsDict.get( 'h21' ))
1057
shahshreyaf3076352015-01-23 13:52:01 -08001058 if ptpIntentResult == main.TRUE:
1059 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001060 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001061 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001062
shahshreyaa47ebf42015-05-20 13:29:18 -07001063 var5 = "Add point intents for mininet hosts h12 and h22 " +\
1064 "ONOS hosts hC and h16"
1065 main.case(var5)
shahshreyaf3076352015-01-23 13:52:01 -08001066 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001067 "of:0000000000003012/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001068 "of:0000000000006022/1",
1069 ethType='IPV4',
1070 ethSrc=macsDict.get( 'h12' ))
1071
shahshreyaf3076352015-01-23 13:52:01 -08001072 if ptpIntentResult == main.TRUE:
1073 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001074 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001075 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001076
shahshreyaf3076352015-01-23 13:52:01 -08001077 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001078 "of:0000000000006022/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001079 "of:0000000000003012/1",
1080 ethType='IPV4',
1081 ethSrc=macsDict.get( 'h22' ))
1082
shahshreyaf3076352015-01-23 13:52:01 -08001083 if ptpIntentResult == main.TRUE:
1084 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001085 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001086 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001087
shahshreyaa47ebf42015-05-20 13:29:18 -07001088 var6 = "Add point intents for mininet hosts h13 and h23 or" +\
1089 " ONOS hosts hD and h17"
1090 main.case(var6)
shahshreyaf3076352015-01-23 13:52:01 -08001091 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001092 "of:0000000000003013/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001093 "of:0000000000006023/1",
1094 ethType='IPV4',
1095 ethSrc=macsDict.get( 'h13' ))
1096
shahshreyaf3076352015-01-23 13:52:01 -08001097 if ptpIntentResult == main.TRUE:
1098 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001099 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001100 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001101
shahshreyaf3076352015-01-23 13:52:01 -08001102 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001103 "of:0000000000006023/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001104 "of:0000000000003013/1",
1105 ethType='IPV4',
1106 ethSrc=macsDict.get( 'h23' ))
1107
shahshreyaf3076352015-01-23 13:52:01 -08001108 if ptpIntentResult == main.TRUE:
1109 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001110 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001111 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001112
shahshreyaa47ebf42015-05-20 13:29:18 -07001113 var7 = "Add point intents for mininet hosts h14 and h24 or" +\
1114 " ONOS hosts hE and h18"
1115 main.case(var7)
shahshreyaf3076352015-01-23 13:52:01 -08001116 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001117 "of:0000000000003014/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001118 "of:0000000000006024/1",
1119 ethType='IPV4',
1120 ethSrc=macsDict.get( 'h14' ))
1121
shahshreyaf3076352015-01-23 13:52:01 -08001122 if ptpIntentResult == main.TRUE:
1123 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001124 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001125 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001126
shahshreyaf3076352015-01-23 13:52:01 -08001127 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001128 "of:0000000000006024/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001129 "of:0000000000003014/1",
1130 ethType='IPV4',
1131 ethSrc=macsDict.get( 'h24' ))
1132
shahshreyaf3076352015-01-23 13:52:01 -08001133 if ptpIntentResult == main.TRUE:
1134 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001135 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001136 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001137
shahshreyaa47ebf42015-05-20 13:29:18 -07001138 var8 = "Add point intents for mininet hosts h15 and h25 or" +\
1139 " ONOS hosts hF and h19"
1140 main.case(var8)
shahshreyaf3076352015-01-23 13:52:01 -08001141 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001142 "of:0000000000003015/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001143 "of:0000000000006025/1",
1144 ethType='IPV4',
1145 ethSrc=macsDict.get( 'h15' ))
1146
shahshreyaf3076352015-01-23 13:52:01 -08001147 if ptpIntentResult == main.TRUE:
1148 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001149 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001150 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001151
shahshreyaf3076352015-01-23 13:52:01 -08001152 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001153 "of:0000000000006025/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001154 "of:0000000000003015/1",
1155 ethType='IPV4',
1156 ethSrc=macsDict.get( 'h25' ))
1157
shahshreyaf3076352015-01-23 13:52:01 -08001158 if ptpIntentResult == main.TRUE:
1159 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001160 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001161 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001162
shahshreyaa47ebf42015-05-20 13:29:18 -07001163 var9 = "Add intents for mininet hosts h16 and h26 or" +\
1164 " ONOS hosts h10 and h1A"
1165 main.case(var9)
shahshreyaf3076352015-01-23 13:52:01 -08001166 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001167 "of:0000000000003016/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001168 "of:0000000000006026/1",
1169 ethType='IPV4',
1170 ethSrc=macsDict.get( 'h16' ))
1171
shahshreyaf3076352015-01-23 13:52:01 -08001172 if ptpIntentResult == main.TRUE:
1173 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001174 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001175 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001176
shahshreyaf3076352015-01-23 13:52:01 -08001177 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001178 "of:0000000000006026/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001179 "of:0000000000003016/1",
1180 ethType='IPV4',
1181 ethSrc=macsDict.get( 'h26' ))
1182
shahshreyaf3076352015-01-23 13:52:01 -08001183 if ptpIntentResult == main.TRUE:
1184 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001185 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001186 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001187
shahshreyaa47ebf42015-05-20 13:29:18 -07001188 var10 = "Add point intents for mininet hosts h17 and h27 or" +\
1189 " ONOS hosts h11 and h1B"
1190 main.case(var10)
shahshreyaf3076352015-01-23 13:52:01 -08001191 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001192 "of:0000000000003017/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001193 "of:0000000000006027/1",
1194 ethType='IPV4',
1195 ethSrc=macsDict.get( 'h17' ))
1196
shahshreyaf3076352015-01-23 13:52:01 -08001197 if ptpIntentResult == main.TRUE:
1198 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001199 main.log.info( "Point to point intent install successful" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001200 #main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001201
shahshreyaf3076352015-01-23 13:52:01 -08001202 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001203 "of:0000000000006027/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001204 "of:0000000000003017/1",
1205 ethType='IPV4',
1206 ethSrc=macsDict.get( 'h27' ))
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001207
1208 print(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001209 "_______________________________________________________" +
1210 "________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001211
1212 flowHandle = main.ONOScli1.flows()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001213 # print "flowHandle = ", flowHandle
1214 main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001215
1216 count = 1
1217 i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001218 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001219 while i < 18:
1220 main.log.info(
1221 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1222 ping = main.Mininet1.pingHost(
1223 src="h" + str( i ), target="h" + str( i + 10 ) )
1224 if ping == main.FALSE and count < 5:
1225 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001226 # i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001227 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001228 main.log.report( "Ping between h" +
1229 str( i ) +
1230 " and h" +
1231 str( i +
1232 10 ) +
1233 " failed. Making attempt number " +
1234 str( count ) +
1235 " in 2 seconds" )
1236 time.sleep( 2 )
1237 elif ping == main.FALSE:
1238 main.log.report( "All ping attempts between h" +
1239 str( i ) +
1240 " and h" +
1241 str( i +
1242 10 ) +
1243 "have failed" )
1244 i = 19
shahshreyaf3076352015-01-23 13:52:01 -08001245 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001246 elif ping == main.TRUE:
1247 main.log.info( "Ping test between h" +
1248 str( i ) +
1249 " and h" +
1250 str( i +
1251 10 ) +
1252 "passed!" )
1253 i += 1
shahshreyaf3076352015-01-23 13:52:01 -08001254 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001255 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001256 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -08001257 PingResult = main.ERROR
1258 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001259 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001260 "Ping all test after Point intents" +
1261 " addition failed. Cleaning up" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001262 # main.cleanup()
1263 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -08001264 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001265 main.log.report(
1266 "Ping all test after Point intents addition successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001267
shahshreyaf3076352015-01-23 13:52:01 -08001268 case8Result = PingResult
1269 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001270 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001271 actual=case8Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001272 onpass="Ping all test after Point intents addition successful",
1273 onfail="Ping all test after Point intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001274
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001275 def CASE31( self ):
1276 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001277 This test case adds point intent related to
1278 SDN-IP matching on ICMP ( ethertype=IPV4, ipProto=1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001279 """
shahshreyae6c7cf42014-11-26 16:39:01 -08001280 import json
1281
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001282 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001283 "This test case adds point intent " +
1284 "related to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001285 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001286 "Adding bidirectional point intent related" +
1287 " to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001288 main.step( "Adding bidirectional point intent" )
1289 # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1290 # --ethType=IPV4 --ipProto=1 of:0000000000003008/1
1291 # of:0000000000006018/1
1292
shahshreyaf3076352015-01-23 13:52:01 -08001293 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001294 for i in range( 8, 11 ):
1295 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001296 "Adding point intent between h" + str( i ) +
1297 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001298 host1 = "00:00:00:00:00:" + \
1299 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1300 host2 = "00:00:00:00:00:" + \
1301 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
shahshreyaf3076352015-01-23 13:52:01 -08001302 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1303 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1304 for host in hostsJson:
1305 if host[ 'id' ] == host1Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001306 ip1 = host[ 'ipAddresses' ][ 0 ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001307 ip1 = str( ip1 + "/32" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001308 device1 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001309 device1 = str( device1 + "/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001310 elif host[ 'id' ] == host2Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001311 ip2 = str( host[ 'ipAddresses' ][ 0 ] ) + "/32"
1312 device2 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001313 device2 = str( device2 + "/1" )
1314
shahshreyaf3076352015-01-23 13:52:01 -08001315 pIntentResult1 = main.ONOScli1.addPointIntent(
1316 ingressDevice=device1,
1317 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001318 ipSrc=ip1,
1319 ipDst=ip2,
1320 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
shahshreyaa47ebf42015-05-20 13:29:18 -07001321 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ], )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001322
shahshreyaf3076352015-01-23 13:52:01 -08001323 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1324 main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001325
shahshreyaf3076352015-01-23 13:52:01 -08001326 pIntentResult2 = main.ONOScli1.addPointIntent(
1327 ingressDevice=device2,
1328 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001329 ipSrc=ip2,
1330 ipDst=ip1,
1331 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1332 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1333
shahshreyaf3076352015-01-23 13:52:01 -08001334 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1335 main.log.info( getIntentResult )
shahshreyaa47ebf42015-05-20 13:29:18 -07001336 if ( pIntentResult1 and pIntentResult2 ) :
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001337 # getIntentResult = main.ONOScli1.intents()
shahshreyaf3076352015-01-23 13:52:01 -08001338 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001339 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001340 "Point intent related to SDN-IP matching" +
1341 " on ICMP install successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001342
1343 time.sleep( 15 )
shahshreyaf3076352015-01-23 13:52:01 -08001344 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1345 main.log.info( "intents = " + getIntentResult )
1346 getFlowsResult = main.ONOScli1.flows()
1347 main.log.info( "flows = " + getFlowsResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001348
shahshreyae6c7cf42014-11-26 16:39:01 -08001349 count = 1
1350 i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001351 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001352 while i < 11:
1353 main.log.info(
1354 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1355 ping = main.Mininet1.pingHost(
1356 src="h" + str( i ), target="h" + str( i + 10 ) )
1357 if ping == main.FALSE and count < 3:
1358 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001359 # i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001360 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001361 main.log.report( "Ping between h" +
1362 str( i ) +
1363 " and h" +
1364 str( i +
1365 10 ) +
1366 " failed. Making attempt number " +
1367 str( count ) +
1368 " in 2 seconds" )
1369 time.sleep( 2 )
1370 elif ping == main.FALSE:
1371 main.log.report( "All ping attempts between h" +
1372 str( i ) +
1373 " and h" +
1374 str( i +
1375 10 ) +
1376 "have failed" )
1377 i = 19
shahshreyaf3076352015-01-23 13:52:01 -08001378 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001379 elif ping == main.TRUE:
1380 main.log.info( "Ping test between h" +
1381 str( i ) +
1382 " and h" +
1383 str( i +
1384 10 ) +
1385 "passed!" )
1386 i += 1
shahshreyaf3076352015-01-23 13:52:01 -08001387 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -08001388 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001389 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -08001390 PingResult = main.ERROR
1391 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001392 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001393 "Ping test after Point intents related to" +
1394 " SDN-IP matching on ICMP failed." )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001395 # main.cleanup()
1396 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -08001397 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001398 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001399 "Ping all test after Point intents related to" +
1400 " SDN-IP matching on ICMP successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001401
shahshreyaa47ebf42015-05-20 13:29:18 -07001402 case31Result = PingResult
shahshreyaf3076352015-01-23 13:52:01 -08001403 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001404 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001405 actual=case31Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001406 onpass="Point intent related to SDN-IP " +
1407 "matching on ICMP and ping test successful",
1408 onfail="Point intent related to SDN-IP" +
1409 " matching on ICMP and ping test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001410
1411 def CASE32( self ):
1412 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001413 This test case adds point intent related to SDN-IP matching on TCP
1414 ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 )
1415 Note: Although BGP port is 179, we are using 5001 because iperf
1416 is used for verifying and iperf's default port is 5001
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001417 """
shahshreyae6c7cf42014-11-26 16:39:01 -08001418 import json
1419
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001420 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001421 "This test case adds point intent" +
1422 " related to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001423 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001424 "Adding bidirectional point intent related" +
1425 " to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001426 main.step( "Adding bidirectional point intent" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001427 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001428 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1429 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1
1430 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001431
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001432 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1433 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1
1434 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001435
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001436 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1437 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1
1438 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001439
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001440 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1441 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1
1442 of:0000000000003008/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001443
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001444 """
shahshreyaf3076352015-01-23 13:52:01 -08001445 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001446 for i in range( 8, 9 ):
1447 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001448 "Adding point intent between h" + str( i ) +
1449 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001450 host1 = "00:00:00:00:00:" + \
1451 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1452 host2 = "00:00:00:00:00:" + \
1453 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
shahshreyaf3076352015-01-23 13:52:01 -08001454 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1455 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1456 for host in hostsJson:
1457 if host[ 'id' ] == host1Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001458 ip1 = host[ 'ipAddresses' ][ 0 ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001459 ip1 = str( ip1 + "/32" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001460 device1 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001461 device1 = str( device1 + "/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001462 elif host[ 'id' ] == host2Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001463 ip2 = str( host[ 'ipAddresses' ][ 0 ] ) + "/32"
1464 device2 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001465 device2 = str( device2 + "/1" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001466
shahshreyaf3076352015-01-23 13:52:01 -08001467 pIntentResult1 = main.ONOScli1.addPointIntent(
1468 ingressDevice=device1,
1469 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001470 ipSrc=ip1,
1471 ipDst=ip2,
1472 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1473 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1474 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
shahshreyaf3076352015-01-23 13:52:01 -08001475 pIntentResult2 = main.ONOScli1.addPointIntent(
1476 ingressDevice=device2,
1477 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001478 ipSrc=ip2,
1479 ipDst=ip1,
1480 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1481 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1482 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
1483
shahshreyaf3076352015-01-23 13:52:01 -08001484 pIntentResult3 = main.ONOScli1.addPointIntent(
1485 ingressDevice=device1,
1486 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001487 ipSrc=ip1,
1488 ipDst=ip2,
1489 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1490 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1491 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
shahshreyaf3076352015-01-23 13:52:01 -08001492 pIntentResult4 = main.ONOScli1.addPointIntent(
1493 ingressDevice=device2,
1494 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001495 ipSrc=ip2,
1496 ipDst=ip1,
1497 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1498 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1499 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
shahshreyae6c7cf42014-11-26 16:39:01 -08001500
shahshreya234a1682015-05-27 15:41:56 -07001501 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1502 main.log.info( getIntentResult )
1503 pIntentResult = main.TRUE
1504 if getIntentResult:
shahshreyab512cd02015-01-27 17:01:47 -08001505 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001506 "Point intent related to SDN-IP matching" +
1507 " on TCP install successful" )
shahshreyab512cd02015-01-27 17:01:47 -08001508 else:
1509 main.log.report(
1510 "Point intent related to SDN-IP matching" +
1511 " on TCP install failed" )
shahshreya234a1682015-05-27 15:41:56 -07001512 pIntentResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -08001513
shahshreyaf3076352015-01-23 13:52:01 -08001514 iperfResult = main.Mininet1.iperf( 'h8', 'h18' )
1515 if iperfResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001516 main.log.report( "iperf test successful" )
1517 else:
1518 main.log.report( "iperf test failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001519
shahshreyaf3076352015-01-23 13:52:01 -08001520 case32Result = pIntentResult and iperfResult
1521 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001522 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001523 actual=case32Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001524 onpass="Ping all test after Point intents addition related " +
1525 "to SDN-IP on TCP match successful",
1526 onfail="Ping all test after Point intents addition related " +
1527 "to SDN-IP on TCP match failed" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001528
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001529 def CASE33( self ):
1530 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001531 This test case adds multipoint to singlepoint intent related to
1532 SDN-IP matching on destination ip and the action is to rewrite
1533 the mac address
1534 Here the mac address to be rewritten is the mac address of the
1535 egress device
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001536 """
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001537 import json
1538 import time
1539
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001540 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001541 "This test case adds multipoint to singlepoint intent related to" +
1542 " SDN-IP matching on destination ip and " +
1543 "rewrite mac address action" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001544 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001545 "Adding multipoint to singlepoint intent related to SDN-IP" +
1546 " matching on destination ip" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001547 main.step( "Adding bidirectional multipoint to singlepoint intent" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001548 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001549 add-multi-to-single-intent --ipDst=10.0.3.0/24
1550 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1
1551 of:0000000000006018/1
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001552
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001553 add-multi-to-single-intent --ipDst=10.0.1.0/24
1554 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1
1555 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001556 """
1557 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001558 "Installing multipoint to single point " +
1559 "intent with rewrite mac address" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001560 main.step( "Uninstalling proxy arp app" )
shahshreyad524a942015-04-21 09:55:16 -07001561 # deactivating proxyarp app
1562 appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.proxyarp" )
1563 appCheck = main.ONOScli1.appToIDCheck()
1564 if appCheck != main.TRUE:
1565 main.log.warn( main.ONOScli1.apps() )
1566 main.log.warn( main.ONOScli1.appIDs() )
1567 time.sleep( 30 )
1568 main.log.info( "onos-app-proxyarp deactivated" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001569
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001570 main.step( "Changing ipaddress of hosts h8,h9 and h18" )
1571 main.Mininet1.changeIP(
1572 host='h8',
1573 intf='h8-eth0',
1574 newIP='10.0.1.1',
1575 newNetmask='255.255.255.0' )
1576 main.Mininet1.changeIP(
1577 host='h9',
1578 intf='h9-eth0',
1579 newIP='10.0.2.1',
1580 newNetmask='255.255.255.0' )
1581 main.Mininet1.changeIP(
1582 host='h10',
1583 intf='h10-eth0',
1584 newIP='10.0.3.1',
1585 newNetmask='255.255.255.0' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001586
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001587 main.step( "Changing default gateway of hosts h8,h9 and h18" )
1588 main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' )
1589 main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' )
1590 main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001591
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001592 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001593 "Assigning random mac address to the default gateways " +
1594 "since proxyarp app is uninstalled" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001595 main.Mininet1.addStaticMACAddress(
1596 host='h8',
1597 GW='10.0.1.254',
1598 macaddr='00:00:00:00:11:11' )
1599 main.Mininet1.addStaticMACAddress(
1600 host='h9',
1601 GW='10.0.2.254',
1602 macaddr='00:00:00:00:22:22' )
1603 main.Mininet1.addStaticMACAddress(
1604 host='h10',
1605 GW='10.0.3.254',
1606 macaddr='00:00:00:00:33:33' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001607
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001608 main.step( "Verify static gateway and MAC address assignment" )
1609 main.Mininet1.verifyStaticGWandMAC( host='h8' )
1610 main.Mininet1.verifyStaticGWandMAC( host='h9' )
1611 main.Mininet1.verifyStaticGWandMAC( host='h10' )
1612
shahshreyab471a3e2015-03-19 17:07:13 -07001613 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ]
1614 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ]
1615 ingressDeviceList = []
1616 ingressDeviceList.append( ingressDevice1 )
1617 ingressDeviceList.append( ingressDevice2 )
1618
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001619 main.step( "Adding multipoint to singlepoint intent" )
shahshreyaf3076352015-01-23 13:52:01 -08001620 pIntentResult1 = main.ONOScli1.addMultipointToSinglepointIntent(
shahshreyab471a3e2015-03-19 17:07:13 -07001621 ingressDeviceList,
shahshreyaf3076352015-01-23 13:52:01 -08001622 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001623 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
1624 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
1625
shahshreyab471a3e2015-03-19 17:07:13 -07001626 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ]
1627 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ]
1628 ingressDeviceList = [ingressDevice1, ingressDevice2]
1629
shahshreyaf3076352015-01-23 13:52:01 -08001630 pIntentResult2 = main.ONOScli1.addMultipointToSinglepointIntent(
shahshreyab471a3e2015-03-19 17:07:13 -07001631 ingressDeviceList,
shahshreyaf3076352015-01-23 13:52:01 -08001632 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001633 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
1634 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
1635
shahshreyab471a3e2015-03-19 17:07:13 -07001636 pIntentResult = pIntentResult1 and pIntentResult2
1637 if pIntentResult == main.FALSE:
1638 main.log.info(
1639 "Multi point to single point intent " +
1640 "installation failed" )
1641 else:
1642 pIntentResult = main.TRUE
1643 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1644 main.log.info( "intents = " + getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001645
shahshreyab471a3e2015-03-19 17:07:13 -07001646 time.sleep( 10 )
1647 getFlowsResult = main.ONOScli1.flows( jsonFormat=False )
1648 main.log.info( "flows = " + getFlowsResult )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001649
shahshreyab471a3e2015-03-19 17:07:13 -07001650 count = 1
1651 i = 8
1652 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001653
shahshreyab471a3e2015-03-19 17:07:13 -07001654 main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
1655 ping = main.Mininet1.pingHost(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001656 src="h" + str( i ), target="h" + str( i + 2 ) )
shahshreyab471a3e2015-03-19 17:07:13 -07001657 if ping == main.FALSE and count < 3:
1658 count += 1
1659 PingResult = main.FALSE
1660 main.log.report( "Ping between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001661 str( i ) +
1662 " and h" +
1663 str( i +
1664 2 ) +
1665 " failed. Making attempt number " +
1666 str( count ) +
1667 " in 2 seconds" )
shahshreyab471a3e2015-03-19 17:07:13 -07001668 time.sleep( 2 )
1669 elif ping == main.FALSE:
1670 main.log.report( "All ping attempts between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001671 str( i ) +
1672 " and h" +
1673 str( i +
1674 10 ) +
1675 "have failed" )
shahshreyab471a3e2015-03-19 17:07:13 -07001676 PingResult = main.FALSE
1677 elif ping == main.TRUE:
1678 main.log.info( "Ping test between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001679 str( i ) +
1680 " and h" +
1681 str( i +
1682 2 ) +
shahshreyaa47ebf42015-05-20 13:29:18 -07001683 " passed!" )
shahshreyab471a3e2015-03-19 17:07:13 -07001684 PingResult = main.TRUE
1685 else:
1686 main.log.info( "Unknown error" )
1687 PingResult = main.ERROR
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001688
shahshreyab471a3e2015-03-19 17:07:13 -07001689 if PingResult == main.FALSE:
1690 main.log.report( "Ping test failed." )
1691 # main.cleanup()
1692 # main.exit()
1693 if PingResult == main.TRUE:
1694 main.log.report( "Ping all successful" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001695
shahshreyaf3076352015-01-23 13:52:01 -08001696 if pIntentResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001697 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001698 "Multi point intent with rewrite mac " +
shahshreyab471a3e2015-03-19 17:07:13 -07001699 "address installation and ping successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001700
shahshreyaf3076352015-01-23 13:52:01 -08001701 case33Result = pIntentResult and PingResult
1702 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001703 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001704 actual=case33Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001705 onpass="Ping all test after multipoint to single point" +
1706 " intent addition with rewrite mac address successful",
1707 onfail="Ping all test after multipoint to single point intent" +
1708 " addition with rewrite mac address failed" )
shahshreya1f119da2015-04-21 17:16:46 -07001709
1710 def CASE20( self ):
1711 """
1712 Exit from mininet cli
1713 reinstall ONOS
1714 """
shahshreyaa47ebf42015-05-20 13:29:18 -07001715 import time
shahshreya1f119da2015-04-21 17:16:46 -07001716 cellName = main.params[ 'ENV' ][ 'cellName' ]
1717 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
1718 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
1719 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
1720 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
1721 ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
1722 ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
1723
1724 main.log.report( "This testcase exits the mininet cli and reinstalls" +
1725 "ONOS to switch over to Packet Optical topology" )
1726 main.log.report( "_____________________________________________" )
1727 main.case( "Disconnecting mininet and restarting ONOS" )
1728 main.step( "Disconnecting mininet and restarting ONOS" )
1729 mininetDisconnect = main.Mininet1.disconnect()
1730 print "mininetDisconnect = ", mininetDisconnect
1731
1732 main.step( "Removing raft logs before a clen installation of ONOS" )
1733 main.ONOSbench.onosRemoveRaftLogs()
1734
1735 main.step( "Applying cell variable to environment" )
1736 cellResult = main.ONOSbench.setCell( cellName )
1737 verifyResult = main.ONOSbench.verifyCell()
1738
shahshreyaa47ebf42015-05-20 13:29:18 -07001739 time.sleep( 5 )
1740 main.step( "Uninstalling ONOS package" )
1741 onos1UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS1Ip)
1742 onos2UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS2Ip)
1743 onos3UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS3Ip)
1744 onosUninstallResult = onos1UninstallResult and onos2UninstallResult \
1745 and onos3UninstallResult
1746 time.sleep( 15 )
shahshreya1f119da2015-04-21 17:16:46 -07001747 main.step( "Installing ONOS package" )
1748 onos1InstallResult = main.ONOSbench.onosInstall(
1749 options="-f",
1750 node=ONOS1Ip )
1751 onos2InstallResult = main.ONOSbench.onosInstall(
1752 options="-f",
1753 node=ONOS2Ip )
1754 onos3InstallResult = main.ONOSbench.onosInstall(
1755 options="-f",
1756 node=ONOS3Ip )
1757 onosInstallResult = onos1InstallResult and onos2InstallResult and\
1758 onos3InstallResult
1759 if onosInstallResult == main.TRUE:
1760 main.log.report( "Installing ONOS package successful" )
1761 else:
1762 main.log.report( "Installing ONOS package failed" )
1763
shahshreyaa47ebf42015-05-20 13:29:18 -07001764 time.sleep( 10 )
shahshreya1f119da2015-04-21 17:16:46 -07001765 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
1766 onos2Isup = main.ONOSbench.isup( ONOS2Ip )
1767 onos3Isup = main.ONOSbench.isup( ONOS3Ip )
1768 onosIsup = onos1Isup and onos2Isup and onos3Isup
1769 if onosIsup == main.TRUE:
1770 main.log.report( "ONOS instances are up and ready" )
1771 else:
1772 main.log.report( "ONOS instances may not be up" )
1773
1774 main.step( "Starting ONOS service" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001775 time.sleep( 10 )
shahshreya1f119da2015-04-21 17:16:46 -07001776 startResult = main.TRUE
1777 # startResult = main.ONOSbench.onosStart( ONOS1Ip )
1778 startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip )
1779 startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip )
1780 startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip )
1781 startResult = startcli1 and startcli2 and startcli3
1782 if startResult == main.TRUE:
1783 main.log.report( "ONOS cli starts properly" )
1784 case20Result = mininetDisconnect and cellResult and verifyResult \
1785 and onosInstallResult and onosIsup and startResult
1786
1787 utilities.assert_equals(
1788 expect=main.TRUE,
1789 actual=case20Result,
1790 onpass= "Exiting functionality mininet topology and reinstalling" +
1791 " ONOS successful",
1792 onfail= "Exiting functionality mininet topology and reinstalling" +
1793 " ONOS failed" )
1794
1795 def CASE21( self, main ):
1796 """
1797 On ONOS bench, run this command:
1798 sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1 <Ctrls>
1799 which spawns packet optical topology and copies the links
1800 json file to the onos instance.
1801 Note that in case of Packet Optical, the links are not learnt
1802 from the topology, instead the links are learnt
1803 from the json config file
1804 """
1805 main.log.report(
1806 "This testcase starts the packet layer topology and REST" )
1807 main.log.report( "_____________________________________________" )
1808 main.case( "Starting LINC-OE and other components" )
1809 main.step( "Starting LINC-OE and other components" )
1810 main.log.info( "Activate optical app" )
1811 appInstallResult = main.ONOScli1.activateApp( "org.onosproject.optical" )
1812 appCheck = main.ONOScli1.appToIDCheck()
1813 appCheck = appCheck and main.ONOScli2.appToIDCheck()
1814 appCheck = appCheck and main.ONOScli3.appToIDCheck()
1815 if appCheck != main.TRUE:
1816 main.log.warn( "Checking ONOS application unsuccesful" )
1817
1818 ctrllerIP = []
1819 ctrllerIP.append( main.params[ 'CTRL' ][ 'ip1' ] )
1820 #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip2' ] )
1821 #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip3' ] )
1822 opticalMnScript = main.LincOE2.runOpticalMnScript( ctrllerIP = ctrllerIP )
1823 case21Result = opticalMnScript and appInstallResult
1824 utilities.assert_equals(
1825 expect=main.TRUE,
1826 actual=case21Result,
1827 onpass="Packet optical topology spawned successsfully",
1828 onfail="Packet optical topology spawning failed" )
1829
1830 def CASE22( self, main ):
1831 """
1832 Curretly we use, 10 optical switches(ROADM's) and
1833 6 packet layer mininet switches each with one host.
1834 Therefore, the roadmCount variable = 10,
1835 packetLayerSWCount variable = 6, hostCount=6 and
shahshreyaa47ebf42015-05-20 13:29:18 -07001836 links=46.
shahshreya1f119da2015-04-21 17:16:46 -07001837 All this is hardcoded in the testcase. If the topology changes,
1838 these hardcoded values need to be changed
1839 """
shahshreyaa47ebf42015-05-20 13:29:18 -07001840 import time
shahshreya1f119da2015-04-21 17:16:46 -07001841 main.log.report(
1842 "This testcase compares the optical+packet topology against what" +
1843 " is expected" )
1844 main.case( "Topology comparision" )
1845 main.step( "Topology comparision" )
1846 devicesResult = main.ONOScli3.devices( jsonFormat=False )
shahshreyaa47ebf42015-05-20 13:29:18 -07001847 time.sleep( 15 )
shahshreya1f119da2015-04-21 17:16:46 -07001848 print "devices_result = ", devicesResult
1849 devicesLinewise = devicesResult.split( "\n" )
shahshreya1f119da2015-04-21 17:16:46 -07001850 roadmCount = 0
1851 packetLayerSWCount = 0
1852 for line in devicesLinewise:
1853 components = line.split( "," )
1854 availability = components[ 1 ].split( "=" )[ 1 ]
1855 type = components[ 3 ].split( "=" )[ 1 ]
1856 if availability == 'true' and type == 'ROADM':
1857 roadmCount += 1
1858 elif availability == 'true' and type == 'SWITCH':
1859 packetLayerSWCount += 1
1860 if roadmCount == 10:
1861 print "Number of Optical Switches = %d and is" % roadmCount +\
1862 " correctly detected"
1863 main.log.info(
1864 "Number of Optical Switches = " +
1865 str( roadmCount ) +
1866 " and is correctly detected" )
1867 opticalSWResult = main.TRUE
1868 else:
1869 print "Number of Optical Switches = %d and is wrong" % roadmCount
1870 main.log.info(
1871 "Number of Optical Switches = " +
1872 str( roadmCount ) +
1873 " and is wrong" )
1874 opticalSWResult = main.FALSE
1875
1876 if packetLayerSWCount == 6:
1877 print "Number of Packet layer or mininet Switches = %d "\
1878 % packetLayerSWCount + "and is correctly detected"
1879 main.log.info(
1880 "Number of Packet layer or mininet Switches = " +
1881 str( packetLayerSWCount ) +
1882 " and is correctly detected" )
1883 packetSWResult = main.TRUE
1884 else:
1885 print "Number of Packet layer or mininet Switches = %d and"\
1886 % packetLayerSWCount + " is wrong"
1887 main.log.info(
1888 "Number of Packet layer or mininet Switches = " +
1889 str( packetLayerSWCount ) +
1890 " and is wrong" )
1891 packetSWResult = main.FALSE
1892 print "_________________________________"
1893
1894 linksResult = main.ONOScli3.links( jsonFormat=False )
1895 print "links_result = ", linksResult
1896 print "_________________________________"
1897 linkActiveCount = linksResult.count("state=ACTIVE")
1898 main.log.info( "linkActiveCount = " + str( linkActiveCount ))
shahshreyaa47ebf42015-05-20 13:29:18 -07001899 if linkActiveCount == 46:
shahshreya1f119da2015-04-21 17:16:46 -07001900 linkActiveResult = main.TRUE
1901 main.log.info(
1902 "Number of links in ACTIVE state are correct")
1903 else:
1904 linkActiveResult = main.FALSE
1905 main.log.info(
1906 "Number of links in ACTIVE state are wrong")
1907
1908 case22Result = opticalSWResult and packetSWResult and \
1909 linkActiveResult
1910 utilities.assert_equals(
1911 expect=main.TRUE,
1912 actual=case22Result,
1913 onpass="Packet optical topology discovery successful",
1914 onfail="Packet optical topology discovery failed" )
1915
1916 def CASE23( self, main ):
1917 import time
1918 """
1919 Add bidirectional point intents between 2 packet layer( mininet )
1920 devices and
1921 ping mininet hosts
1922 """
1923 main.log.report(
1924 "This testcase adds bidirectional point intents between 2 " +
1925 "packet layer( mininet ) devices and ping mininet hosts" )
1926 main.case( "Topology comparision" )
1927 main.step( "Adding point intents" )
1928 ptpIntentResult = main.ONOScli1.addPointIntent(
1929 "of:0000ffffffff0001/1",
1930 "of:0000ffffffff0005/1" )
1931 if ptpIntentResult == main.TRUE:
1932 main.ONOScli1.intents( jsonFormat=False )
1933 main.log.info( "Point to point intent install successful" )
1934
1935 ptpIntentResult = main.ONOScli1.addPointIntent(
1936 "of:0000ffffffff0005/1",
1937 "of:0000ffffffff0001/1" )
1938 if ptpIntentResult == main.TRUE:
1939 main.ONOScli1.intents( jsonFormat=False )
1940 main.log.info( "Point to point intent install successful" )
1941
1942 time.sleep( 30 )
1943 flowHandle = main.ONOScli1.flows()
1944 main.log.info( "flows :" + flowHandle )
1945
1946 # Sleep for 30 seconds to provide time for the intent state to change
1947 time.sleep( 60 )
1948 intentHandle = main.ONOScli1.intents( jsonFormat=False )
1949 main.log.info( "intents :" + intentHandle )
1950
1951 PingResult = main.TRUE
1952 count = 1
1953 main.log.info( "\n\nh1 is Pinging h5" )
1954 ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
1955 # ping = main.LincOE2.pinghost()
1956 if ping == main.FALSE and count < 5:
1957 count += 1
1958 PingResult = main.FALSE
1959 main.log.info(
1960 "Ping between h1 and h5 failed. Making attempt number " +
1961 str( count ) +
1962 " in 2 seconds" )
1963 time.sleep( 2 )
1964 elif ping == main.FALSE:
1965 main.log.info( "All ping attempts between h1 and h5 have failed" )
1966 PingResult = main.FALSE
1967 elif ping == main.TRUE:
1968 main.log.info( "Ping test between h1 and h5 passed!" )
1969 PingResult = main.TRUE
1970 else:
1971 main.log.info( "Unknown error" )
1972 PingResult = main.ERROR
1973
1974 if PingResult == main.FALSE:
1975 main.log.report(
1976 "Point intents for packet optical have not ben installed" +
1977 " correctly. Cleaning up" )
1978 if PingResult == main.TRUE:
1979 main.log.report(
1980 "Point Intents for packet optical have been " +
1981 "installed correctly" )
1982
1983 case23Result = PingResult
1984 utilities.assert_equals(
1985 expect=main.TRUE,
1986 actual=case23Result,
1987 onpass= "Point intents addition for packet optical and" +
1988 "Pingall Test successful",
1989 onfail= "Point intents addition for packet optical and" +
1990 "Pingall Test NOT successful" )
1991
1992 def CASE24( self, main ):
1993 import time
1994 import json
1995 """
1996 LINC uses its own switch IDs. You can use the following
1997 command on the LINC console to find the mapping between
1998 DPIDs and LINC IDs.
1999 rp(application:get_all_key(linc)).
2000
2001 Test Rerouting of Packet Optical by bringing a port down
2002 ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
2003 so that link
2004 ( between switch1 port20 - switch5 port50 ) is inactive
2005 and do a ping test. If rerouting is successful,
2006 ping should pass. also check the flows
2007 """
2008 main.log.report(
2009 "This testcase tests rerouting and pings mininet hosts" )
2010 main.case( "Test rerouting and pings mininet hosts" )
2011 main.step( "Attach to the Linc-OE session" )
2012 attachConsole = main.LincOE1.attachLincOESession()
2013 print "attachConsole = ", attachConsole
2014
2015 main.step( "Bring a port down and verify the link state" )
2016 main.LincOE1.portDown( swId="9", ptId="20" )
2017 linksNonjson = main.ONOScli3.links( jsonFormat=False )
2018 main.log.info( "links = " + linksNonjson )
2019
2020 linkInactiveCount = linksNonjson.count("state=INACTIVE")
2021 main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
2022 if linkInactiveCount == 2:
2023 main.log.info(
2024 "Number of links in INACTIVE state are correct")
2025 else:
2026 main.log.info(
2027 "Number of links in INACTIVE state are wrong")
2028
2029 links = main.ONOScli3.links()
2030 main.log.info( "links = " + links )
2031
2032 linksResult = json.loads( links )
2033 linksStateResult = main.FALSE
2034 for item in linksResult:
2035 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
2036 'src' ][ 'port' ] == "20":
2037 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
2038 'dst' ][ 'port' ] == "50":
2039 linksState = item[ 'state' ]
2040 if linksState == "INACTIVE":
2041 main.log.info(
2042 "Links state is inactive as expected due to one" +
2043 " of the ports being down" )
2044 main.log.report(
2045 "Links state is inactive as expected due to one" +
2046 " of the ports being down" )
2047 linksStateResult = main.TRUE
2048 break
2049 else:
2050 main.log.info(
2051 "Links state is not inactive as expected" )
2052 main.log.report(
2053 "Links state is not inactive as expected" )
2054 linksStateResult = main.FALSE
2055
2056 print "links_state_result = ", linksStateResult
2057 time.sleep( 10 )
2058 flowHandle = main.ONOScli3.flows()
2059 main.log.info( "flows :" + flowHandle )
2060
2061 main.step( "Verify Rerouting by a ping test" )
2062 PingResult = main.TRUE
2063 count = 1
2064 main.log.info( "\n\nh1 is Pinging h5" )
2065 ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
2066 # ping = main.LincOE2.pinghost()
2067 if ping == main.FALSE and count < 5:
2068 count += 1
2069 PingResult = main.FALSE
2070 main.log.info(
2071 "Ping between h1 and h5 failed. Making attempt number " +
2072 str( count ) +
2073 " in 2 seconds" )
2074 time.sleep( 2 )
2075 elif ping == main.FALSE:
2076 main.log.info( "All ping attempts between h1 and h5 have failed" )
2077 PingResult = main.FALSE
2078 elif ping == main.TRUE:
2079 main.log.info( "Ping test between h1 and h5 passed!" )
2080 PingResult = main.TRUE
2081 else:
2082 main.log.info( "Unknown error" )
2083 PingResult = main.ERROR
2084
2085 if PingResult == main.TRUE:
2086 main.log.report( "Ping test successful " )
2087 if PingResult == main.FALSE:
2088 main.log.report( "Ping test failed" )
2089
2090 case24Result = PingResult and linksStateResult
2091 utilities.assert_equals( expect=main.TRUE, actual=case24Result,
2092 onpass="Packet optical rerouting successful",
2093 onfail="Packet optical rerouting failed" )