blob: 44a828c031487da7c1c4bf629d596d81155f1c98 [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
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800383 portsResults1 = main.Mininet1.comparePorts( MNTopo,
384 json.loads( ports1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800385 utilities.assertEquals( expect=main.TRUE, actual=portsResults1,
shahshreya4e13a062014-11-11 16:46:18 -0800386 onpass="ONOS1 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800387 onfail="ONOS1 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800388
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800389 portsResults2 = main.Mininet1.comparePorts( MNTopo,
390 json.loads( ports2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800391 utilities.assertEquals( expect=main.TRUE, actual=portsResults2,
shahshreya4e13a062014-11-11 16:46:18 -0800392 onpass="ONOS2 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800393 onfail="ONOS2 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800394
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800395 portsResults3 = main.Mininet1.comparePorts( MNTopo,
396 json.loads( ports3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800397 utilities.assertEquals( expect=main.TRUE, actual=portsResults3,
shahshreya4e13a062014-11-11 16:46:18 -0800398 onpass="ONOS3 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800399 onfail="ONOS3 Ports view is incorrect" )
shahshreyabf739d82015-06-10 11:22:31 -0700400
shahshreyaf3076352015-01-23 13:52:01 -0800401 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800402 MNTopo,
403 json.loads( links1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800404 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
405 onpass="ONOS1 Links view is correct",
406 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800407
shahshreyaf3076352015-01-23 13:52:01 -0800408 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800409 MNTopo,
410 json.loads( links2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800411 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
412 onpass="ONOS2 Links view is correct",
413 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800414
shahshreyaf3076352015-01-23 13:52:01 -0800415 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800416 MNTopo,
417 json.loads( links3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800418 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
419 onpass="ONOS2 Links view is correct",
420 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800421
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800422 # topoResult = switchesResults1 and switchesResults2
423 # and switchesResults3\
shahshreyaf3076352015-01-23 13:52:01 -0800424 # and portsResults1 and portsResults2 and portsResults3\
425 # and linksResults1 and linksResults2 and linksResults3
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800426
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800427 topoResult = switchesResults1 and switchesResults2 and\
428 switchesResults3 and linksResults1 and linksResults2 and\
429 linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800430
shahshreyaf3076352015-01-23 13:52:01 -0800431 if topoResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800432 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800433 "Topology Check Test with mininet" +
434 "and ONOS instances successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800435 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800436 main.log.report(
437 "Topology Check Test with mininet and ONOS instances failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800438
shahshreyaf3076352015-01-23 13:52:01 -0800439 utilities.assertEquals( expect=main.TRUE, actual=topoResult,
440 onpass="Topology Check Test successful",
441 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800442
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800443 def CASE10( self ):
shahshreya1f119da2015-04-21 17:16:46 -0700444 import time
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800445 main.log.report(
446 "This testcase uninstalls the reactive forwarding app" )
447 main.log.report( "__________________________________" )
448 main.case( "Uninstalling reactive forwarding app" )
449 # Unistall onos-app-fwd app to disable reactive forwarding
shahshreyad524a942015-04-21 09:55:16 -0700450 appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.fwd" )
451 appCheck = main.ONOScli1.appToIDCheck()
452 if appCheck != main.TRUE:
453 main.log.warn( main.ONOScli1.apps() )
454 main.log.warn( main.ONOScli1.appIDs() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800455 main.log.info( "onos-app-fwd uninstalled" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800456
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800457 # After reactive forwarding is disabled,
458 # the reactive flows on switches timeout in 10-15s
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800459 # So sleep for 15s
460 time.sleep( 15 )
shahshreyae6c7cf42014-11-26 16:39:01 -0800461
shahshreyae6c7cf42014-11-26 16:39:01 -0800462 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800463 main.log.info( hosts )
shahshreyad524a942015-04-21 09:55:16 -0700464 case10Result = appInstallResult
shahshreyaf3076352015-01-23 13:52:01 -0800465 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800466 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800467 actual=case10Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800468 onpass="Reactive forwarding app uninstallation successful",
469 onfail="Reactive forwarding app uninstallation failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800470
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800471 def CASE6( self ):
472 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800473 "This testcase is testing the addition of" +
474 " host intents and then doing pingall" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800475 main.log.report( "__________________________________" )
476 main.case( "Obtaining hostsfor adding host intents" )
477 main.step( "Get hosts" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800478 hosts = main.ONOScli1.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800479 main.log.info( hosts )
shahshreya4e13a062014-11-11 16:46:18 -0800480
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800481 main.step( "Get all devices id" )
shahshreyaf3076352015-01-23 13:52:01 -0800482 devicesIdList = main.ONOScli1.getAllDevicesId()
483 main.log.info( devicesIdList )
shahshreya4e13a062014-11-11 16:46:18 -0800484
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800485 # ONOS displays the hosts in hex format
486 # unlike mininet which does in decimal format
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800487 # So take care while adding intents
shahshreya4e13a062014-11-11 16:46:18 -0800488
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800489 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800490 main.step( "Add host intents for mn hosts(h8-h18,h9-h19,h10-h20,
491 h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
492 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:08/-1",
493 "00:00:00:00:00:12/-1" )
494 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:09/-1",
495 "00:00:00:00:00:13/-1" )
496 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0A/-1",
497 "00:00:00:00:00:14/-1" )
498 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0B/-1",
499 "00:00:00:00:00:15/-1" )
500 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0C/-1",
501 "00:00:00:00:00:16/-1" )
502 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0D/-1",
503 "00:00:00:00:00:17/-1" )
504 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0E/-1",
505 "00:00:00:00:00:18/-1" )
506 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:0F/-1",
507 "00:00:00:00:00:19/-1" )
508 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:10/-1",
509 "00:00:00:00:00:1A/-1" )
510 hthIntentResult = main.ONOScli1.addHostIntent( "00:00:00:00:00:11/-1",
511 "00:00:00:00:00:1B/-1" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800512 """
shahshreya234a1682015-05-27 15:41:56 -0700513 intentsId = []
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800514 for i in range( 8, 18 ):
515 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800516 "Adding host intent between h" + str( i ) +
517 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800518 host1 = "00:00:00:00:00:" + \
519 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
520 host2 = "00:00:00:00:00:" + \
521 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
522 # NOTE: get host can return None
523 # TODO: handle this
shahshreyaf3076352015-01-23 13:52:01 -0800524 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
525 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
526 tmpResult = main.ONOScli1.addHostIntent( host1Id, host2Id )
shahshreya234a1682015-05-27 15:41:56 -0700527 intentsId.append( tmpResult )
528
529 checkIntent1 = main.ONOScli1.checkIntentState( intentsId )
530 checkIntent2 = main.ONOScli2.checkIntentState( intentsId )
531 checkIntent3 = main.ONOScli3.checkIntentState( intentsId )
shahshreya4e13a062014-11-11 16:46:18 -0800532
533 flowHandle = main.ONOScli1.flows()
shahshreya234a1682015-05-27 15:41:56 -0700534
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800535 main.log.info( "flows:" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -0800536
537 count = 1
538 i = 8
shahshreyaf3076352015-01-23 13:52:01 -0800539 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800540 while i < 18:
541 main.log.info(
542 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
543 ping = main.Mininet1.pingHost(
544 src="h" + str( i ), target="h" + str( i + 10 ) )
545 if ping == main.FALSE and count < 5:
546 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800547 # i = 8
shahshreyaf3076352015-01-23 13:52:01 -0800548 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800549 main.log.report( "Ping between h" +
550 str( i ) +
551 " and h" +
552 str( i +
553 10 ) +
554 " failed. Making attempt number " +
555 str( count ) +
556 " in 2 seconds" )
557 time.sleep( 2 )
558 elif ping == main.FALSE:
559 main.log.report( "All ping attempts between h" +
560 str( i ) +
561 " and h" +
562 str( i +
563 10 ) +
564 "have failed" )
565 i = 19
shahshreyaf3076352015-01-23 13:52:01 -0800566 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800567 elif ping == main.TRUE:
568 main.log.info( "Ping test between h" +
569 str( i ) +
570 " and h" +
571 str( i +
572 10 ) +
573 "passed!" )
574 i += 1
shahshreyaf3076352015-01-23 13:52:01 -0800575 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -0800576 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800577 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -0800578 PingResult = main.ERROR
579 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800580 main.log.report(
581 "Host intents have not ben installed correctly. Cleaning up" )
582 # main.cleanup()
583 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -0800584 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800585 main.log.report( "Host intents have been installed correctly" )
shahshreya4e13a062014-11-11 16:46:18 -0800586
shahshreya234a1682015-05-27 15:41:56 -0700587 checkIntent1 = main.ONOScli1.checkIntentState( intentsId )
588 checkIntent2 = main.ONOScli2.checkIntentState( intentsId )
589 checkIntent3 = main.ONOScli3.checkIntentState( intentsId )
590
shahshreyaf3076352015-01-23 13:52:01 -0800591 case6Result = PingResult
592 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800593 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800594 actual=case6Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800595 onpass="Host intent addition and Pingall Test successful",
596 onfail="Host intent addition and Pingall Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800597
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800598 def CASE7( self, main ):
shahshreya4e13a062014-11-11 16:46:18 -0800599
shahshreyaf3076352015-01-23 13:52:01 -0800600 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
shahshreya4e13a062014-11-11 16:46:18 -0800601
shahshreyaf3076352015-01-23 13:52:01 -0800602 linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
shahshreya4e13a062014-11-11 16:46:18 -0800603
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800604 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800605 "This testscase is killing a link to" +
606 " ensure that link discovery is consistent" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800607 main.log.report( "__________________________________" )
608 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800609 "Killing a link to Ensure that Link" +
610 " Discovery is Working Properly" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800611 main.step( "Start continuous pings" )
shahshreya4e13a062014-11-11 16:46:18 -0800612
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800613 main.Mininet2.pingLong(
614 src=main.params[ 'PING' ][ 'source1' ],
615 target=main.params[ 'PING' ][ 'target1' ],
616 pingTime=500 )
617 main.Mininet2.pingLong(
618 src=main.params[ 'PING' ][ 'source2' ],
619 target=main.params[ 'PING' ][ 'target2' ],
620 pingTime=500 )
621 main.Mininet2.pingLong(
622 src=main.params[ 'PING' ][ 'source3' ],
623 target=main.params[ 'PING' ][ 'target3' ],
624 pingTime=500 )
625 main.Mininet2.pingLong(
626 src=main.params[ 'PING' ][ 'source4' ],
627 target=main.params[ 'PING' ][ 'target4' ],
628 pingTime=500 )
629 main.Mininet2.pingLong(
630 src=main.params[ 'PING' ][ 'source5' ],
631 target=main.params[ 'PING' ][ 'target5' ],
632 pingTime=500 )
633 main.Mininet2.pingLong(
634 src=main.params[ 'PING' ][ 'source6' ],
635 target=main.params[ 'PING' ][ 'target6' ],
636 pingTime=500 )
637 main.Mininet2.pingLong(
638 src=main.params[ 'PING' ][ 'source7' ],
639 target=main.params[ 'PING' ][ 'target7' ],
640 pingTime=500 )
641 main.Mininet2.pingLong(
642 src=main.params[ 'PING' ][ 'source8' ],
643 target=main.params[ 'PING' ][ 'target8' ],
644 pingTime=500 )
645 main.Mininet2.pingLong(
646 src=main.params[ 'PING' ][ 'source9' ],
647 target=main.params[ 'PING' ][ 'target9' ],
648 pingTime=500 )
649 main.Mininet2.pingLong(
650 src=main.params[ 'PING' ][ 'source10' ],
651 target=main.params[ 'PING' ][ 'target10' ],
652 pingTime=500 )
shahshreya4e13a062014-11-11 16:46:18 -0800653
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800654 main.step( "Determine the current number of switches and links" )
shahshreyaf3076352015-01-23 13:52:01 -0800655 topologyOutput = main.ONOScli1.topology()
656 topologyResult = main.ONOSbench.getTopology( topologyOutput )
shahshreyaa47ebf42015-05-20 13:29:18 -0700657 activeSwitches = topologyResult[ 'devices' ]
658 links = topologyResult[ 'links' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800659 main.log.info(
660 "Currently there are %s switches and %s links" %
661 ( str( activeSwitches ), str( links ) ) )
shahshreya4e13a062014-11-11 16:46:18 -0800662
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800663 main.step( "Kill Link between s3 and s28" )
664 main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
shahshreyaf3076352015-01-23 13:52:01 -0800665 time.sleep( linkSleep )
666 topologyOutput = main.ONOScli2.topology()
667 LinkDown = main.ONOSbench.checkStatus(
668 topologyOutput, activeSwitches, str(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800669 int( links ) - 2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800670 if LinkDown == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800671 main.log.report( "Link Down discovered properly" )
shahshreyaf3076352015-01-23 13:52:01 -0800672 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800673 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800674 actual=LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800675 onpass="Link Down discovered properly",
676 onfail="Link down was not discovered in " +
shahshreyaf3076352015-01-23 13:52:01 -0800677 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800678 " seconds" )
shahshreya4e13a062014-11-11 16:46:18 -0800679
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800680 main.step( "Bring link between s3 and s28 back up" )
shahshreyaf3076352015-01-23 13:52:01 -0800681 LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
682 time.sleep( linkSleep )
683 topologyOutput = main.ONOScli2.topology()
684 LinkUp = main.ONOSbench.checkStatus(
685 topologyOutput,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800686 activeSwitches,
687 str( links ) )
shahshreyaf3076352015-01-23 13:52:01 -0800688 if LinkUp == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800689 main.log.report( "Link up discovered properly" )
shahshreyaf3076352015-01-23 13:52:01 -0800690 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800691 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800692 actual=LinkUp,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800693 onpass="Link up discovered properly",
694 onfail="Link up was not discovered in " +
shahshreyaf3076352015-01-23 13:52:01 -0800695 str( linkSleep ) +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800696 " seconds" )
697
698 main.step( "Compare ONOS Topology to MN Topology" )
699 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800700 "Testing Mininet topology with the" +
701 " topology of multi instances ONOS" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800702 main.step( "Collecting topology information from ONOS" )
shahshreya4e13a062014-11-11 16:46:18 -0800703 devices1 = main.ONOScli1.devices()
704 devices2 = main.ONOScli2.devices()
705 devices3 = main.ONOScli3.devices()
706 print "devices1 = ", devices1
707 print "devices2 = ", devices2
708 print "devices3 = ", devices3
709 hosts1 = main.ONOScli1.hosts()
710 hosts2 = main.ONOScli2.hosts()
711 hosts3 = main.ONOScli3.hosts()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800712 # print "hosts1 = ", hosts1
713 # print "hosts2 = ", hosts2
714 # print "hosts3 = ", hosts3
shahshreya4e13a062014-11-11 16:46:18 -0800715 ports1 = main.ONOScli1.ports()
716 ports2 = main.ONOScli2.ports()
717 ports3 = main.ONOScli3.ports()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800718 # print "ports1 = ", ports1
719 # print "ports2 = ", ports2
720 # print "ports3 = ", ports3
shahshreya4e13a062014-11-11 16:46:18 -0800721 links1 = main.ONOScli1.links()
722 links2 = main.ONOScli2.links()
723 links3 = main.ONOScli3.links()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800724 # print "links1 = ", links1
725 # print "links2 = ", links2
726 # print "links3 = ", links3
shahshreya4e13a062014-11-11 16:46:18 -0800727
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800728 print "**************"
729
730 main.step( "Start continuous pings" )
731 main.Mininet2.pingLong(
732 src=main.params[ 'PING' ][ 'source1' ],
733 target=main.params[ 'PING' ][ 'target1' ],
734 pingTime=500 )
735 main.Mininet2.pingLong(
736 src=main.params[ 'PING' ][ 'source2' ],
737 target=main.params[ 'PING' ][ 'target2' ],
738 pingTime=500 )
739 main.Mininet2.pingLong(
740 src=main.params[ 'PING' ][ 'source3' ],
741 target=main.params[ 'PING' ][ 'target3' ],
742 pingTime=500 )
743 main.Mininet2.pingLong(
744 src=main.params[ 'PING' ][ 'source4' ],
745 target=main.params[ 'PING' ][ 'target4' ],
746 pingTime=500 )
747 main.Mininet2.pingLong(
748 src=main.params[ 'PING' ][ 'source5' ],
749 target=main.params[ 'PING' ][ 'target5' ],
750 pingTime=500 )
751 main.Mininet2.pingLong(
752 src=main.params[ 'PING' ][ 'source6' ],
753 target=main.params[ 'PING' ][ 'target6' ],
754 pingTime=500 )
755 main.Mininet2.pingLong(
756 src=main.params[ 'PING' ][ 'source7' ],
757 target=main.params[ 'PING' ][ 'target7' ],
758 pingTime=500 )
759 main.Mininet2.pingLong(
760 src=main.params[ 'PING' ][ 'source8' ],
761 target=main.params[ 'PING' ][ 'target8' ],
762 pingTime=500 )
763 main.Mininet2.pingLong(
764 src=main.params[ 'PING' ][ 'source9' ],
765 target=main.params[ 'PING' ][ 'target9' ],
766 pingTime=500 )
767 main.Mininet2.pingLong(
768 src=main.params[ 'PING' ][ 'source10' ],
769 target=main.params[ 'PING' ][ 'target10' ],
770 pingTime=500 )
771
772 main.step( "Create TestONTopology object" )
shahshreya4e13a062014-11-11 16:46:18 -0800773 global ctrls
774 ctrls = []
775 count = 1
776 while True:
777 temp = ()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800778 if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
779 temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
780 temp = temp + ( "ONOS" + str( count ), )
781 temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
782 temp = temp + \
783 ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
784 ctrls.append( temp )
shahshreya4e13a062014-11-11 16:46:18 -0800785 count = count + 1
786 else:
787 break
788 global MNTopo
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800789 Topo = TestONTopology(
790 main.Mininet1,
791 ctrls ) # can also add Intent API info for intent operations
shahshreya4e13a062014-11-11 16:46:18 -0800792 MNTopo = Topo
793
shahshreyaf3076352015-01-23 13:52:01 -0800794 TopologyCheck = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800795 main.step( "Compare ONOS Topology to MN Topology" )
796
shahshreyaf3076352015-01-23 13:52:01 -0800797 switchesResults1 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800798 MNTopo,
799 json.loads( devices1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800800 print "switches_Result1 = ", switchesResults1
801 utilities.assertEquals( expect=main.TRUE, actual=switchesResults1,
802 onpass="ONOS1 Switches view is correct",
803 onfail="ONOS1 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800804
shahshreyaf3076352015-01-23 13:52:01 -0800805 switchesResults2 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800806 MNTopo,
807 json.loads( devices2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800808 utilities.assertEquals( expect=main.TRUE, actual=switchesResults2,
809 onpass="ONOS2 Switches view is correct",
810 onfail="ONOS2 Switches view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800811
shahshreyaf3076352015-01-23 13:52:01 -0800812 switchesResults3 = main.Mininet1.compareSwitches(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800813 MNTopo,
814 json.loads( devices3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800815 utilities.assertEquals( expect=main.TRUE, actual=switchesResults3,
816 onpass="ONOS3 Switches view is correct",
817 onfail="ONOS3 Switches view is incorrect" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800818
819 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800820 portsResults1 = main.Mininet1.comparePorts( MNTopo,
821 json.loads( ports1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800822 utilities.assertEquals( expect=main.TRUE, actual=portsResults1,
shahshreya4e13a062014-11-11 16:46:18 -0800823 onpass="ONOS1 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800824 onfail="ONOS1 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800825
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800826 portsResults2 = main.Mininet1.comparePorts( MNTopo,
827 json.loads( ports2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800828 utilities.assertEquals( expect=main.TRUE, actual=portsResults2,
shahshreya4e13a062014-11-11 16:46:18 -0800829 onpass="ONOS2 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800830 onfail="ONOS2 Ports view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800831
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800832 portsResults3 = main.Mininet1.comparePorts( MNTopo,
833 json.loads( ports3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800834 utilities.assertEquals( expect=main.TRUE, actual=portsResults3,
shahshreya4e13a062014-11-11 16:46:18 -0800835 onpass="ONOS3 Ports view is correct",
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800836 onfail="ONOS3 Ports view is incorrect" )
837 """
shahshreyaf3076352015-01-23 13:52:01 -0800838 linksResults1 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800839 MNTopo,
840 json.loads( links1 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800841 utilities.assertEquals( expect=main.TRUE, actual=linksResults1,
842 onpass="ONOS1 Links view is correct",
843 onfail="ONOS1 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800844
shahshreyaf3076352015-01-23 13:52:01 -0800845 linksResults2 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800846 MNTopo,
847 json.loads( links2 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800848 utilities.assertEquals( expect=main.TRUE, actual=linksResults2,
849 onpass="ONOS2 Links view is correct",
850 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800851
shahshreyaf3076352015-01-23 13:52:01 -0800852 linksResults3 = main.Mininet1.compareLinks(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800853 MNTopo,
854 json.loads( links3 ) )
shahshreyaf3076352015-01-23 13:52:01 -0800855 utilities.assertEquals( expect=main.TRUE, actual=linksResults3,
856 onpass="ONOS2 Links view is correct",
857 onfail="ONOS2 Links view is incorrect" )
shahshreya4e13a062014-11-11 16:46:18 -0800858
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800859 # topoResult = switchesResults1 and switchesResults2
860 # and switchesResults3\
shahshreyaf3076352015-01-23 13:52:01 -0800861 # and portsResults1 and portsResults2 and portsResults3\
862 # and linksResults1 and linksResults2 and linksResults3
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800863
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800864 topoResult = switchesResults1 and switchesResults2\
865 and switchesResults3 and linksResults1 and\
866 linksResults2 and linksResults3
shahshreya4e13a062014-11-11 16:46:18 -0800867
shahshreyaf3076352015-01-23 13:52:01 -0800868 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800869 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -0800870 actual=topoResult and LinkUp and LinkDown,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800871 onpass="Topology Check Test successful",
872 onfail="Topology Check Test NOT successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800873
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800874 def CASE8( self ):
875 """
shahshreyae6c7cf42014-11-26 16:39:01 -0800876 Intent removal
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800877 """
878 main.log.report(
shahshreyab512cd02015-01-27 17:01:47 -0800879 "This testcase removes any previously added intents" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800880 main.log.report( "__________________________________" )
881 main.log.info( "Removing any previously installed intents" )
882 main.case( "Removing intents" )
883 main.step( "Obtain the intent id's" )
shahshreyaf3076352015-01-23 13:52:01 -0800884 intentResult = main.ONOScli1.intents( jsonFormat=False )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800885
shahshreyaf3076352015-01-23 13:52:01 -0800886 intentLinewise = intentResult.split( "\n" )
shahshreyae6c7cf42014-11-26 16:39:01 -0800887 intentList = []
shahshreyaf3076352015-01-23 13:52:01 -0800888 for line in intentLinewise:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800889 if line.startswith( "id=" ):
890 intentList.append( line )
shahshreyae6c7cf42014-11-26 16:39:01 -0800891
892 intentids = []
893 for line in intentList:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800894 intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
shahshreya4e13a062014-11-11 16:46:18 -0800895 for id in intentids:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800896 main.log.info( "id = " + id )
shahshreyae6c7cf42014-11-26 16:39:01 -0800897
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800898 main.step(
899 "Iterate through the intentids list and remove each intent" )
shahshreya4e13a062014-11-11 16:46:18 -0800900 for id in intentids:
shahshreyaa47ebf42015-05-20 13:29:18 -0700901 main.ONOScli1.removeIntent( intentId=id ,purge=True )
shahshreyae6c7cf42014-11-26 16:39:01 -0800902
shahshreya234a1682015-05-27 15:41:56 -0700903 remainingIntent = main.ONOScli1.intents( jsonFormat=False )
904 main.log.info( "Remaining intents " + remainingIntent )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800905
shahshreya234a1682015-05-27 15:41:56 -0700906 case8Result = main.TRUE
907 intentResult = main.TRUE
908 if remainingIntent:
909 main.log.error( "There are still remaining intent" )
910 intentResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800911 i = 8
shahshreya234a1682015-05-27 15:41:56 -0700912
shahshreyaf3076352015-01-23 13:52:01 -0800913 PingResult = main.TRUE
shahshreya234a1682015-05-27 15:41:56 -0700914 """
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800915 while i < 18:
916 main.log.info(
917 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
918 ping = main.Mininet1.pingHost(
919 src="h" + str( i ), target="h" + str( i + 10 ) )
920 if ping == main.TRUE:
shahshreyae6c7cf42014-11-26 16:39:01 -0800921 i = 19
shahshreyaf3076352015-01-23 13:52:01 -0800922 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800923 elif ping == main.FALSE:
924 i += 1
shahshreyaf3076352015-01-23 13:52:01 -0800925 PingResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -0800926 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800927 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -0800928 PingResult = main.ERROR
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800929 # Note: If the ping result failed, that means the intents have been
930 # withdrawn correctly.
shahshreyaf3076352015-01-23 13:52:01 -0800931 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800932 main.log.report( "Host intents have not been withdrawn correctly" )
933 # main.cleanup()
934 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -0800935 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800936 main.log.report( "Host intents have been withdrawn correctly" )
shahshreya234a1682015-05-27 15:41:56 -0700937 """
938 case8Result = intentResult
shahshreyae6c7cf42014-11-26 16:39:01 -0800939
shahshreya234a1682015-05-27 15:41:56 -0700940 if case8Result == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800941 main.log.report( "Intent removal successful" )
shahshreya4e13a062014-11-11 16:46:18 -0800942 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800943 main.log.report( "Intent removal failed" )
shahshreya4e13a062014-11-11 16:46:18 -0800944
shahshreya234a1682015-05-27 15:41:56 -0700945 utilities.assertEquals( expect=main.TRUE, actual=case8Result,
946 onpass="Intent removal test successful",
947 onfail="Intent removal test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800948
949 def CASE9( self ):
950 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800951 This test case adds point intents. Make sure you run test case 8
952 which is host intent removal before executing this test case.
953 Else the host intent's flows will persist on switches and the pings
954 would work even if there is some issue with the point intent's flows
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800955 """
956 main.log.report(
957 "This testcase adds point intents and then does pingall" )
958 main.log.report( "__________________________________" )
959 main.log.info( "Adding point intents" )
960 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800961 "Adding bidirectional point for mn hosts(h8-h18,h9-h19,h10-h20," +
962 "h11-h21,h12-h22,h13-h23,h14-h24,h15-h25,h16-h26,h17-h27)" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800963 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -0800964 "Add point-to-point intents for mininet hosts" +
965 " h8 and h18 or ONOS hosts h8 and h12" )
shahshreyaa47ebf42015-05-20 13:29:18 -0700966 macsDict = {}
967 for i in range( 1,29 ):
968 macsDict[ 'h' + str( i ) ]= main.Mininet1.getMacAddress( host='h'+ str( i ) )
969 print macsDict
970 # main.step(var1)
shahshreyaf3076352015-01-23 13:52:01 -0800971 ptpIntentResult = main.ONOScli1.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -0700972 ingressDevice="of:0000000000003008/1",
973 egressDevice="of:0000000000006018/1",
974 ethType='IPV4',
975 ethSrc=macsDict.get( 'h8' ))
shahshreyaf3076352015-01-23 13:52:01 -0800976 if ptpIntentResult == main.TRUE:
977 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800978 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800979 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800980
shahshreyaf3076352015-01-23 13:52:01 -0800981 ptpIntentResult = main.ONOScli1.addPointIntent(
shahshreyaa47ebf42015-05-20 13:29:18 -0700982 ingressDevice="of:0000000000006018/1",
983 egressDevice="of:0000000000003008/1",
984 ethType='IPV4',
985 ethSrc=macsDict.get( 'h18' ))
shahshreyaf3076352015-01-23 13:52:01 -0800986 if ptpIntentResult == main.TRUE:
987 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800988 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -0800989 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -0800990
shahshreyaa47ebf42015-05-20 13:29:18 -0700991 var2 = "Add point intents for mn hosts h9&h19 or ONOS hosts h9&h13"
992 main.step(var2)
shahshreyaf3076352015-01-23 13:52:01 -0800993 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -0800994 "of:0000000000003009/1",
shahshreyaa47ebf42015-05-20 13:29:18 -0700995 "of:0000000000006019/1",
996 ethType='IPV4',
997 ethSrc=macsDict.get( 'h9' ))
shahshreyaf3076352015-01-23 13:52:01 -0800998 if ptpIntentResult == main.TRUE:
999 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001000 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001001 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001002
shahshreyaf3076352015-01-23 13:52:01 -08001003 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001004 "of:0000000000006019/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001005 "of:0000000000003009/1",
1006 ethType='IPV4',
1007 ethSrc=macsDict.get( 'h19' ))
shahshreyaf3076352015-01-23 13:52:01 -08001008 if ptpIntentResult == main.TRUE:
1009 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001010 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001011 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001012
shahshreyaa47ebf42015-05-20 13:29:18 -07001013 var3 = "Add point intents for MN hosts h10&h20 or ONOS hosts hA&h14"
1014 main.step(var3)
shahshreyaf3076352015-01-23 13:52:01 -08001015 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001016 "of:0000000000003010/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001017 "of:0000000000006020/1",
1018 ethType='IPV4',
1019 ethSrc=macsDict.get( 'h10' ))
1020
shahshreyaf3076352015-01-23 13:52:01 -08001021 if ptpIntentResult == main.TRUE:
1022 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001023 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001024 # main.log.info( getIntentResult )
shahshreya4e13a062014-11-11 16:46:18 -08001025
shahshreyaf3076352015-01-23 13:52:01 -08001026 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001027 "of:0000000000006020/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001028 "of:0000000000003010/1",
1029 ethType='IPV4',
1030 ethSrc=macsDict.get( 'h20' ))
1031
shahshreyaf3076352015-01-23 13:52:01 -08001032 if ptpIntentResult == main.TRUE:
1033 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001034 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001035 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001036
shahshreyaa47ebf42015-05-20 13:29:18 -07001037 var4 = "Add point intents for mininet hosts h11 and h21 or" +\
1038 " ONOS hosts hB and h15"
1039 main.case(var4)
shahshreyaf3076352015-01-23 13:52:01 -08001040 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001041 "of:0000000000003011/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001042 "of:0000000000006021/1",
1043 ethType='IPV4',
1044 ethSrc=macsDict.get( 'h11' ))
1045
shahshreyaf3076352015-01-23 13:52:01 -08001046 if ptpIntentResult == main.TRUE:
1047 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001048 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001049 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001050
shahshreyaf3076352015-01-23 13:52:01 -08001051 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001052 "of:0000000000006021/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001053 "of:0000000000003011/1",
1054 ethType='IPV4',
1055 ethSrc=macsDict.get( 'h21' ))
1056
shahshreyaf3076352015-01-23 13:52:01 -08001057 if ptpIntentResult == main.TRUE:
1058 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001059 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001060 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001061
shahshreyaa47ebf42015-05-20 13:29:18 -07001062 var5 = "Add point intents for mininet hosts h12 and h22 " +\
1063 "ONOS hosts hC and h16"
1064 main.case(var5)
shahshreyaf3076352015-01-23 13:52:01 -08001065 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001066 "of:0000000000003012/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001067 "of:0000000000006022/1",
1068 ethType='IPV4',
1069 ethSrc=macsDict.get( 'h12' ))
1070
shahshreyaf3076352015-01-23 13:52:01 -08001071 if ptpIntentResult == main.TRUE:
1072 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001073 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001074 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001075
shahshreyaf3076352015-01-23 13:52:01 -08001076 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001077 "of:0000000000006022/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001078 "of:0000000000003012/1",
1079 ethType='IPV4',
1080 ethSrc=macsDict.get( 'h22' ))
1081
shahshreyaf3076352015-01-23 13:52:01 -08001082 if ptpIntentResult == main.TRUE:
1083 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001084 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001085 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001086
shahshreyaa47ebf42015-05-20 13:29:18 -07001087 var6 = "Add point intents for mininet hosts h13 and h23 or" +\
1088 " ONOS hosts hD and h17"
1089 main.case(var6)
shahshreyaf3076352015-01-23 13:52:01 -08001090 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001091 "of:0000000000003013/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001092 "of:0000000000006023/1",
1093 ethType='IPV4',
1094 ethSrc=macsDict.get( 'h13' ))
1095
shahshreyaf3076352015-01-23 13:52:01 -08001096 if ptpIntentResult == main.TRUE:
1097 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001098 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001099 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001100
shahshreyaf3076352015-01-23 13:52:01 -08001101 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001102 "of:0000000000006023/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001103 "of:0000000000003013/1",
1104 ethType='IPV4',
1105 ethSrc=macsDict.get( 'h23' ))
1106
shahshreyaf3076352015-01-23 13:52:01 -08001107 if ptpIntentResult == main.TRUE:
1108 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001109 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001110 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001111
shahshreyaa47ebf42015-05-20 13:29:18 -07001112 var7 = "Add point intents for mininet hosts h14 and h24 or" +\
1113 " ONOS hosts hE and h18"
1114 main.case(var7)
shahshreyaf3076352015-01-23 13:52:01 -08001115 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001116 "of:0000000000003014/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001117 "of:0000000000006024/1",
1118 ethType='IPV4',
1119 ethSrc=macsDict.get( 'h14' ))
1120
shahshreyaf3076352015-01-23 13:52:01 -08001121 if ptpIntentResult == main.TRUE:
1122 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001123 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001124 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001125
shahshreyaf3076352015-01-23 13:52:01 -08001126 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001127 "of:0000000000006024/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001128 "of:0000000000003014/1",
1129 ethType='IPV4',
1130 ethSrc=macsDict.get( 'h24' ))
1131
shahshreyaf3076352015-01-23 13:52:01 -08001132 if ptpIntentResult == main.TRUE:
1133 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001134 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001135 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001136
shahshreyaa47ebf42015-05-20 13:29:18 -07001137 var8 = "Add point intents for mininet hosts h15 and h25 or" +\
1138 " ONOS hosts hF and h19"
1139 main.case(var8)
shahshreyaf3076352015-01-23 13:52:01 -08001140 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001141 "of:0000000000003015/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001142 "of:0000000000006025/1",
1143 ethType='IPV4',
1144 ethSrc=macsDict.get( 'h15' ))
1145
shahshreyaf3076352015-01-23 13:52:01 -08001146 if ptpIntentResult == main.TRUE:
1147 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001148 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001149 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001150
shahshreyaf3076352015-01-23 13:52:01 -08001151 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001152 "of:0000000000006025/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001153 "of:0000000000003015/1",
1154 ethType='IPV4',
1155 ethSrc=macsDict.get( 'h25' ))
1156
shahshreyaf3076352015-01-23 13:52:01 -08001157 if ptpIntentResult == main.TRUE:
1158 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001159 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001160 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001161
shahshreyaa47ebf42015-05-20 13:29:18 -07001162 var9 = "Add intents for mininet hosts h16 and h26 or" +\
1163 " ONOS hosts h10 and h1A"
1164 main.case(var9)
shahshreyaf3076352015-01-23 13:52:01 -08001165 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001166 "of:0000000000003016/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001167 "of:0000000000006026/1",
1168 ethType='IPV4',
1169 ethSrc=macsDict.get( 'h16' ))
1170
shahshreyaf3076352015-01-23 13:52:01 -08001171 if ptpIntentResult == main.TRUE:
1172 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001173 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001174 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001175
shahshreyaf3076352015-01-23 13:52:01 -08001176 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001177 "of:0000000000006026/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001178 "of:0000000000003016/1",
1179 ethType='IPV4',
1180 ethSrc=macsDict.get( 'h26' ))
1181
shahshreyaf3076352015-01-23 13:52:01 -08001182 if ptpIntentResult == main.TRUE:
1183 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001184 main.log.info( "Point to point intent install successful" )
shahshreyaf3076352015-01-23 13:52:01 -08001185 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001186
shahshreyaa47ebf42015-05-20 13:29:18 -07001187 var10 = "Add point intents for mininet hosts h17 and h27 or" +\
1188 " ONOS hosts h11 and h1B"
1189 main.case(var10)
shahshreyaf3076352015-01-23 13:52:01 -08001190 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001191 "of:0000000000003017/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001192 "of:0000000000006027/1",
1193 ethType='IPV4',
1194 ethSrc=macsDict.get( 'h17' ))
1195
shahshreyaf3076352015-01-23 13:52:01 -08001196 if ptpIntentResult == main.TRUE:
1197 getIntentResult = main.ONOScli1.intents()
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001198 main.log.info( "Point to point intent install successful" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001199 #main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001200
shahshreyaf3076352015-01-23 13:52:01 -08001201 ptpIntentResult = main.ONOScli1.addPointIntent(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001202 "of:0000000000006027/1",
shahshreyaa47ebf42015-05-20 13:29:18 -07001203 "of:0000000000003017/1",
1204 ethType='IPV4',
1205 ethSrc=macsDict.get( 'h27' ))
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001206
1207 print(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001208 "_______________________________________________________" +
1209 "________________________________" )
shahshreya4e13a062014-11-11 16:46:18 -08001210
1211 flowHandle = main.ONOScli1.flows()
shahshreyabf739d82015-06-10 11:22:31 -07001212 print "flowHandle = ", flowHandle
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001213 main.log.info( "flows :" + flowHandle )
shahshreya4e13a062014-11-11 16:46:18 -08001214
1215 count = 1
1216 i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001217 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001218 while i < 18:
1219 main.log.info(
1220 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1221 ping = main.Mininet1.pingHost(
1222 src="h" + str( i ), target="h" + str( i + 10 ) )
1223 if ping == main.FALSE and count < 5:
1224 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001225 # i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001226 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001227 main.log.report( "Ping between h" +
1228 str( i ) +
1229 " and h" +
1230 str( i +
1231 10 ) +
1232 " failed. Making attempt number " +
1233 str( count ) +
1234 " in 2 seconds" )
1235 time.sleep( 2 )
1236 elif ping == main.FALSE:
1237 main.log.report( "All ping attempts between h" +
1238 str( i ) +
1239 " and h" +
1240 str( i +
1241 10 ) +
1242 "have failed" )
1243 i = 19
shahshreyaf3076352015-01-23 13:52:01 -08001244 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001245 elif ping == main.TRUE:
1246 main.log.info( "Ping test between h" +
1247 str( i ) +
1248 " and h" +
1249 str( i +
1250 10 ) +
1251 "passed!" )
1252 i += 1
shahshreyaf3076352015-01-23 13:52:01 -08001253 PingResult = main.TRUE
shahshreya4e13a062014-11-11 16:46:18 -08001254 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001255 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -08001256 PingResult = main.ERROR
1257 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001258 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001259 "Ping all test after Point intents" +
1260 " addition failed. Cleaning up" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001261 # main.cleanup()
1262 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -08001263 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001264 main.log.report(
1265 "Ping all test after Point intents addition successful" )
shahshreya4e13a062014-11-11 16:46:18 -08001266
shahshreyaf3076352015-01-23 13:52:01 -08001267 case8Result = PingResult
1268 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001269 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001270 actual=case8Result,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001271 onpass="Ping all test after Point intents addition successful",
1272 onfail="Ping all test after Point intents addition failed" )
shahshreya4e13a062014-11-11 16:46:18 -08001273
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001274 def CASE31( self ):
1275 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001276 This test case adds point intent related to
1277 SDN-IP matching on ICMP ( ethertype=IPV4, ipProto=1 )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001278 """
shahshreyae6c7cf42014-11-26 16:39:01 -08001279 import json
1280
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001281 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001282 "This test case adds point intent " +
1283 "related to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001284 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001285 "Adding bidirectional point intent related" +
1286 " to SDN-IP matching on ICMP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001287 main.step( "Adding bidirectional point intent" )
1288 # add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1289 # --ethType=IPV4 --ipProto=1 of:0000000000003008/1
1290 # of:0000000000006018/1
1291
shahshreyaf3076352015-01-23 13:52:01 -08001292 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001293 for i in range( 8, 11 ):
1294 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001295 "Adding point intent between h" + str( i ) +
1296 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001297 host1 = "00:00:00:00:00:" + \
1298 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1299 host2 = "00:00:00:00:00:" + \
1300 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
shahshreyaf3076352015-01-23 13:52:01 -08001301 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1302 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1303 for host in hostsJson:
1304 if host[ 'id' ] == host1Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001305 ip1 = host[ 'ipAddresses' ][ 0 ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001306 ip1 = str( ip1 + "/32" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001307 device1 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001308 device1 = str( device1 + "/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001309 elif host[ 'id' ] == host2Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001310 ip2 = str( host[ 'ipAddresses' ][ 0 ] ) + "/32"
1311 device2 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001312 device2 = str( device2 + "/1" )
1313
shahshreyaf3076352015-01-23 13:52:01 -08001314 pIntentResult1 = main.ONOScli1.addPointIntent(
1315 ingressDevice=device1,
1316 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001317 ipSrc=ip1,
1318 ipDst=ip2,
1319 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
shahshreyaa47ebf42015-05-20 13:29:18 -07001320 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ], )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001321
shahshreyaf3076352015-01-23 13:52:01 -08001322 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1323 main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001324
shahshreyaf3076352015-01-23 13:52:01 -08001325 pIntentResult2 = main.ONOScli1.addPointIntent(
1326 ingressDevice=device2,
1327 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001328 ipSrc=ip2,
1329 ipDst=ip1,
1330 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1331 ipProto=main.params[ 'SDNIP' ][ 'icmpProto' ] )
1332
shahshreyaf3076352015-01-23 13:52:01 -08001333 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1334 main.log.info( getIntentResult )
shahshreyaa47ebf42015-05-20 13:29:18 -07001335 if ( pIntentResult1 and pIntentResult2 ) :
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001336 # getIntentResult = main.ONOScli1.intents()
shahshreyaf3076352015-01-23 13:52:01 -08001337 # main.log.info( getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001338 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001339 "Point intent related to SDN-IP matching" +
1340 " on ICMP install successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001341
1342 time.sleep( 15 )
shahshreyaf3076352015-01-23 13:52:01 -08001343 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1344 main.log.info( "intents = " + getIntentResult )
1345 getFlowsResult = main.ONOScli1.flows()
1346 main.log.info( "flows = " + getFlowsResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001347
shahshreyae6c7cf42014-11-26 16:39:01 -08001348 count = 1
1349 i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001350 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001351 while i < 11:
1352 main.log.info(
1353 "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
1354 ping = main.Mininet1.pingHost(
1355 src="h" + str( i ), target="h" + str( i + 10 ) )
1356 if ping == main.FALSE and count < 3:
1357 count += 1
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001358 # i = 8
shahshreyaf3076352015-01-23 13:52:01 -08001359 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001360 main.log.report( "Ping between h" +
1361 str( i ) +
1362 " and h" +
1363 str( i +
1364 10 ) +
1365 " failed. Making attempt number " +
1366 str( count ) +
1367 " in 2 seconds" )
1368 time.sleep( 2 )
1369 elif ping == main.FALSE:
1370 main.log.report( "All ping attempts between h" +
1371 str( i ) +
1372 " and h" +
1373 str( i +
1374 10 ) +
1375 "have failed" )
1376 i = 19
shahshreyaf3076352015-01-23 13:52:01 -08001377 PingResult = main.FALSE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001378 elif ping == main.TRUE:
1379 main.log.info( "Ping test between h" +
1380 str( i ) +
1381 " and h" +
1382 str( i +
1383 10 ) +
1384 "passed!" )
1385 i += 1
shahshreyaf3076352015-01-23 13:52:01 -08001386 PingResult = main.TRUE
shahshreyae6c7cf42014-11-26 16:39:01 -08001387 else:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001388 main.log.info( "Unknown error" )
shahshreyaf3076352015-01-23 13:52:01 -08001389 PingResult = main.ERROR
1390 if PingResult == main.FALSE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001391 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001392 "Ping test after Point intents related to" +
1393 " SDN-IP matching on ICMP failed." )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001394 # main.cleanup()
1395 # main.exit()
shahshreyaf3076352015-01-23 13:52:01 -08001396 if PingResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001397 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001398 "Ping all test after Point intents related to" +
1399 " SDN-IP matching on ICMP successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001400
shahshreyaa47ebf42015-05-20 13:29:18 -07001401 case31Result = PingResult
shahshreyaf3076352015-01-23 13:52:01 -08001402 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001403 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001404 actual=case31Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001405 onpass="Point intent related to SDN-IP " +
1406 "matching on ICMP and ping test successful",
1407 onfail="Point intent related to SDN-IP" +
1408 " matching on ICMP and ping test failed" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001409
1410 def CASE32( self ):
1411 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001412 This test case adds point intent related to SDN-IP matching on TCP
1413 ( ethertype=IPV4, ipProto=6, DefaultPort for iperf=5001 )
1414 Note: Although BGP port is 179, we are using 5001 because iperf
1415 is used for verifying and iperf's default port is 5001
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001416 """
shahshreyae6c7cf42014-11-26 16:39:01 -08001417 import json
1418
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001419 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001420 "This test case adds point intent" +
1421 " related to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001422 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001423 "Adding bidirectional point intent related" +
1424 " to SDN-IP matching on TCP" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001425 main.step( "Adding bidirectional point intent" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001426 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001427 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1428 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000003008/1
1429 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001430
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001431 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1432 --ethType=IPV4 --ipProto=6 --tcpDst=5001 of:0000000000006018/1
1433 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001434
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001435 add-point-intent --ipSrc=10.0.0.8/32 --ipDst=10.0.0.18/32
1436 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000003008/1
1437 of:0000000000006018/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001438
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001439 add-point-intent --ipSrc=10.0.0.18/32 --ipDst=10.0.0.8/32
1440 --ethType=IPV4 --ipProto=6 --tcpSrc=5001 of:0000000000006018/1
1441 of:0000000000003008/1
shahshreyae6c7cf42014-11-26 16:39:01 -08001442
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001443 """
shahshreyaf3076352015-01-23 13:52:01 -08001444 hostsJson = json.loads( main.ONOScli1.hosts() )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001445 for i in range( 8, 9 ):
1446 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001447 "Adding point intent between h" + str( i ) +
1448 " and h" + str( i + 10 ) )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001449 host1 = "00:00:00:00:00:" + \
1450 str( hex( i )[ 2: ] ).zfill( 2 ).upper()
1451 host2 = "00:00:00:00:00:" + \
1452 str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
shahshreyaf3076352015-01-23 13:52:01 -08001453 host1Id = main.ONOScli1.getHost( host1 )[ 'id' ]
1454 host2Id = main.ONOScli1.getHost( host2 )[ 'id' ]
1455 for host in hostsJson:
1456 if host[ 'id' ] == host1Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001457 ip1 = host[ 'ipAddresses' ][ 0 ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001458 ip1 = str( ip1 + "/32" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001459 device1 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001460 device1 = str( device1 + "/1" )
shahshreyaf3076352015-01-23 13:52:01 -08001461 elif host[ 'id' ] == host2Id:
shahshreyaa47ebf42015-05-20 13:29:18 -07001462 ip2 = str( host[ 'ipAddresses' ][ 0 ] ) + "/32"
1463 device2 = host[ 'location' ][ 'elementId' ]
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001464 device2 = str( device2 + "/1" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001465
shahshreyaf3076352015-01-23 13:52:01 -08001466 pIntentResult1 = main.ONOScli1.addPointIntent(
1467 ingressDevice=device1,
1468 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001469 ipSrc=ip1,
1470 ipDst=ip2,
1471 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1472 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1473 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
shahshreyaf3076352015-01-23 13:52:01 -08001474 pIntentResult2 = main.ONOScli1.addPointIntent(
1475 ingressDevice=device2,
1476 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001477 ipSrc=ip2,
1478 ipDst=ip1,
1479 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1480 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1481 tcpDst=main.params[ 'SDNIP' ][ 'dstPort' ] )
1482
shahshreyaf3076352015-01-23 13:52:01 -08001483 pIntentResult3 = main.ONOScli1.addPointIntent(
1484 ingressDevice=device1,
1485 egressDevice=device2,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001486 ipSrc=ip1,
1487 ipDst=ip2,
1488 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1489 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1490 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
shahshreyaf3076352015-01-23 13:52:01 -08001491 pIntentResult4 = main.ONOScli1.addPointIntent(
1492 ingressDevice=device2,
1493 egressDevice=device1,
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001494 ipSrc=ip2,
1495 ipDst=ip1,
1496 ethType=main.params[ 'SDNIP' ][ 'ethType' ],
1497 ipProto=main.params[ 'SDNIP' ][ 'tcpProto' ],
1498 tcpSrc=main.params[ 'SDNIP' ][ 'srcPort' ] )
shahshreyae6c7cf42014-11-26 16:39:01 -08001499
shahshreya234a1682015-05-27 15:41:56 -07001500 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1501 main.log.info( getIntentResult )
1502 pIntentResult = main.TRUE
1503 if getIntentResult:
shahshreyab512cd02015-01-27 17:01:47 -08001504 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001505 "Point intent related to SDN-IP matching" +
1506 " on TCP install successful" )
shahshreyab512cd02015-01-27 17:01:47 -08001507 else:
1508 main.log.report(
1509 "Point intent related to SDN-IP matching" +
1510 " on TCP install failed" )
shahshreya234a1682015-05-27 15:41:56 -07001511 pIntentResult = main.FALSE
shahshreyae6c7cf42014-11-26 16:39:01 -08001512
shahshreyaf3076352015-01-23 13:52:01 -08001513 iperfResult = main.Mininet1.iperf( 'h8', 'h18' )
1514 if iperfResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001515 main.log.report( "iperf test successful" )
1516 else:
1517 main.log.report( "iperf test failed" )
shahshreyae6c7cf42014-11-26 16:39:01 -08001518
shahshreyaf3076352015-01-23 13:52:01 -08001519 case32Result = pIntentResult and iperfResult
1520 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001521 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001522 actual=case32Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001523 onpass="Ping all test after Point intents addition related " +
1524 "to SDN-IP on TCP match successful",
1525 onfail="Ping all test after Point intents addition related " +
1526 "to SDN-IP on TCP match failed" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001527
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001528 def CASE33( self ):
1529 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001530 This test case adds multipoint to singlepoint intent related to
1531 SDN-IP matching on destination ip and the action is to rewrite
1532 the mac address
1533 Here the mac address to be rewritten is the mac address of the
1534 egress device
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001535 """
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001536 import json
1537 import time
1538
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001539 main.log.report(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001540 "This test case adds multipoint to singlepoint intent related to" +
1541 " SDN-IP matching on destination ip and " +
1542 "rewrite mac address action" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001543 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001544 "Adding multipoint to singlepoint intent related to SDN-IP" +
1545 " matching on destination ip" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001546 main.step( "Adding bidirectional multipoint to singlepoint intent" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001547 """
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001548 add-multi-to-single-intent --ipDst=10.0.3.0/24
1549 --setEthDst=00:00:00:00:00:12 of:0000000000003008/1 0000000000003009/1
1550 of:0000000000006018/1
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001551
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001552 add-multi-to-single-intent --ipDst=10.0.1.0/24
1553 --setEthDst=00:00:00:00:00:08 of:0000000000006018/1 0000000000003009/1
1554 of:0000000000003008/1
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001555 """
1556 main.case(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001557 "Installing multipoint to single point " +
1558 "intent with rewrite mac address" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001559 main.step( "Uninstalling proxy arp app" )
shahshreyad524a942015-04-21 09:55:16 -07001560 # deactivating proxyarp app
1561 appInstallResult = main.ONOScli1.deactivateApp( "org.onosproject.proxyarp" )
1562 appCheck = main.ONOScli1.appToIDCheck()
1563 if appCheck != main.TRUE:
1564 main.log.warn( main.ONOScli1.apps() )
1565 main.log.warn( main.ONOScli1.appIDs() )
1566 time.sleep( 30 )
1567 main.log.info( "onos-app-proxyarp deactivated" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001568
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001569 main.step( "Changing ipaddress of hosts h8,h9 and h18" )
1570 main.Mininet1.changeIP(
1571 host='h8',
1572 intf='h8-eth0',
1573 newIP='10.0.1.1',
1574 newNetmask='255.255.255.0' )
1575 main.Mininet1.changeIP(
1576 host='h9',
1577 intf='h9-eth0',
1578 newIP='10.0.2.1',
1579 newNetmask='255.255.255.0' )
1580 main.Mininet1.changeIP(
1581 host='h10',
1582 intf='h10-eth0',
1583 newIP='10.0.3.1',
1584 newNetmask='255.255.255.0' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001585
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001586 main.step( "Changing default gateway of hosts h8,h9 and h18" )
1587 main.Mininet1.changeDefaultGateway( host='h8', newGW='10.0.1.254' )
1588 main.Mininet1.changeDefaultGateway( host='h9', newGW='10.0.2.254' )
1589 main.Mininet1.changeDefaultGateway( host='h10', newGW='10.0.3.254' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001590
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001591 main.step(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001592 "Assigning random mac address to the default gateways " +
1593 "since proxyarp app is uninstalled" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001594 main.Mininet1.addStaticMACAddress(
1595 host='h8',
1596 GW='10.0.1.254',
1597 macaddr='00:00:00:00:11:11' )
1598 main.Mininet1.addStaticMACAddress(
1599 host='h9',
1600 GW='10.0.2.254',
1601 macaddr='00:00:00:00:22:22' )
1602 main.Mininet1.addStaticMACAddress(
1603 host='h10',
1604 GW='10.0.3.254',
1605 macaddr='00:00:00:00:33:33' )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001606
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001607 main.step( "Verify static gateway and MAC address assignment" )
1608 main.Mininet1.verifyStaticGWandMAC( host='h8' )
1609 main.Mininet1.verifyStaticGWandMAC( host='h9' )
1610 main.Mininet1.verifyStaticGWandMAC( host='h10' )
1611
shahshreyab471a3e2015-03-19 17:07:13 -07001612 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ]
1613 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ]
1614 ingressDeviceList = []
1615 ingressDeviceList.append( ingressDevice1 )
1616 ingressDeviceList.append( ingressDevice2 )
1617
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001618 main.step( "Adding multipoint to singlepoint intent" )
shahshreyaf3076352015-01-23 13:52:01 -08001619 pIntentResult1 = main.ONOScli1.addMultipointToSinglepointIntent(
shahshreyab471a3e2015-03-19 17:07:13 -07001620 ingressDeviceList,
shahshreyaf3076352015-01-23 13:52:01 -08001621 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001622 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip1' ],
1623 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac1' ] )
1624
shahshreyab471a3e2015-03-19 17:07:13 -07001625 ingressDevice1=main.params[ 'MULTIPOINT_INTENT' ][ 'device3' ]
1626 ingressDevice2=main.params[ 'MULTIPOINT_INTENT' ][ 'device2' ]
1627 ingressDeviceList = [ingressDevice1, ingressDevice2]
1628
shahshreyaf3076352015-01-23 13:52:01 -08001629 pIntentResult2 = main.ONOScli1.addMultipointToSinglepointIntent(
shahshreyab471a3e2015-03-19 17:07:13 -07001630 ingressDeviceList,
shahshreyaf3076352015-01-23 13:52:01 -08001631 egressDevice=main.params[ 'MULTIPOINT_INTENT' ][ 'device1' ],
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001632 ipDst=main.params[ 'MULTIPOINT_INTENT' ][ 'ip2' ],
1633 setEthDst=main.params[ 'MULTIPOINT_INTENT' ][ 'mac2' ] )
1634
shahshreyab471a3e2015-03-19 17:07:13 -07001635 pIntentResult = pIntentResult1 and pIntentResult2
1636 if pIntentResult == main.FALSE:
1637 main.log.info(
1638 "Multi point to single point intent " +
1639 "installation failed" )
1640 else:
1641 pIntentResult = main.TRUE
1642 getIntentResult = main.ONOScli1.intents( jsonFormat=False )
1643 main.log.info( "intents = " + getIntentResult )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001644
shahshreyab471a3e2015-03-19 17:07:13 -07001645 time.sleep( 10 )
1646 getFlowsResult = main.ONOScli1.flows( jsonFormat=False )
1647 main.log.info( "flows = " + getFlowsResult )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001648
shahshreyab471a3e2015-03-19 17:07:13 -07001649 count = 1
1650 i = 8
1651 PingResult = main.TRUE
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001652
shahshreyab471a3e2015-03-19 17:07:13 -07001653 main.log.info( "\n\nh" + str( i ) + " is Pinging h" + str( i + 2 ) )
1654 ping = main.Mininet1.pingHost(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001655 src="h" + str( i ), target="h" + str( i + 2 ) )
shahshreyab471a3e2015-03-19 17:07:13 -07001656 if ping == main.FALSE and count < 3:
1657 count += 1
1658 PingResult = main.FALSE
1659 main.log.report( "Ping between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001660 str( i ) +
1661 " and h" +
1662 str( i +
1663 2 ) +
1664 " failed. Making attempt number " +
1665 str( count ) +
1666 " in 2 seconds" )
shahshreyab471a3e2015-03-19 17:07:13 -07001667 time.sleep( 2 )
1668 elif ping == main.FALSE:
1669 main.log.report( "All ping attempts between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001670 str( i ) +
1671 " and h" +
1672 str( i +
1673 10 ) +
1674 "have failed" )
shahshreyab471a3e2015-03-19 17:07:13 -07001675 PingResult = main.FALSE
1676 elif ping == main.TRUE:
1677 main.log.info( "Ping test between h" +
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001678 str( i ) +
1679 " and h" +
1680 str( i +
1681 2 ) +
shahshreyaa47ebf42015-05-20 13:29:18 -07001682 " passed!" )
shahshreyab471a3e2015-03-19 17:07:13 -07001683 PingResult = main.TRUE
1684 else:
1685 main.log.info( "Unknown error" )
1686 PingResult = main.ERROR
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001687
shahshreyab471a3e2015-03-19 17:07:13 -07001688 if PingResult == main.FALSE:
1689 main.log.report( "Ping test failed." )
1690 # main.cleanup()
1691 # main.exit()
1692 if PingResult == main.TRUE:
1693 main.log.report( "Ping all successful" )
shahshreyaf1b1b9f2014-12-04 16:59:20 -08001694
shahshreyaf3076352015-01-23 13:52:01 -08001695 if pIntentResult == main.TRUE:
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001696 main.log.info(
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001697 "Multi point intent with rewrite mac " +
shahshreyab471a3e2015-03-19 17:07:13 -07001698 "address installation and ping successful" )
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001699
shahshreyaf3076352015-01-23 13:52:01 -08001700 case33Result = pIntentResult and PingResult
1701 utilities.assertEquals(
kelvin-onlabeaa2eb32015-01-16 15:58:18 -08001702 expect=main.TRUE,
shahshreyaf3076352015-01-23 13:52:01 -08001703 actual=case33Result,
kelvin-onlabcf33bda2015-01-23 16:54:17 -08001704 onpass="Ping all test after multipoint to single point" +
1705 " intent addition with rewrite mac address successful",
1706 onfail="Ping all test after multipoint to single point intent" +
1707 " addition with rewrite mac address failed" )
shahshreya1f119da2015-04-21 17:16:46 -07001708
1709 def CASE20( self ):
1710 """
1711 Exit from mininet cli
1712 reinstall ONOS
1713 """
shahshreyaa47ebf42015-05-20 13:29:18 -07001714 import time
shahshreya1f119da2015-04-21 17:16:46 -07001715 cellName = main.params[ 'ENV' ][ 'cellName' ]
1716 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
1717 ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
1718 ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ]
1719 ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
1720 ONOS2Port = main.params[ 'CTRL' ][ 'port2' ]
1721 ONOS3Port = main.params[ 'CTRL' ][ 'port3' ]
1722
1723 main.log.report( "This testcase exits the mininet cli and reinstalls" +
1724 "ONOS to switch over to Packet Optical topology" )
1725 main.log.report( "_____________________________________________" )
1726 main.case( "Disconnecting mininet and restarting ONOS" )
1727 main.step( "Disconnecting mininet and restarting ONOS" )
1728 mininetDisconnect = main.Mininet1.disconnect()
1729 print "mininetDisconnect = ", mininetDisconnect
1730
1731 main.step( "Removing raft logs before a clen installation of ONOS" )
1732 main.ONOSbench.onosRemoveRaftLogs()
1733
1734 main.step( "Applying cell variable to environment" )
1735 cellResult = main.ONOSbench.setCell( cellName )
1736 verifyResult = main.ONOSbench.verifyCell()
1737
shahshreyaa47ebf42015-05-20 13:29:18 -07001738 time.sleep( 5 )
1739 main.step( "Uninstalling ONOS package" )
1740 onos1UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS1Ip)
1741 onos2UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS2Ip)
1742 onos3UninstallResult = main.ONOSbench.onosUninstall( nodeIp = ONOS3Ip)
1743 onosUninstallResult = onos1UninstallResult and onos2UninstallResult \
1744 and onos3UninstallResult
1745 time.sleep( 15 )
shahshreya1f119da2015-04-21 17:16:46 -07001746 main.step( "Installing ONOS package" )
1747 onos1InstallResult = main.ONOSbench.onosInstall(
1748 options="-f",
1749 node=ONOS1Ip )
1750 onos2InstallResult = main.ONOSbench.onosInstall(
1751 options="-f",
1752 node=ONOS2Ip )
1753 onos3InstallResult = main.ONOSbench.onosInstall(
1754 options="-f",
1755 node=ONOS3Ip )
1756 onosInstallResult = onos1InstallResult and onos2InstallResult and\
1757 onos3InstallResult
1758 if onosInstallResult == main.TRUE:
1759 main.log.report( "Installing ONOS package successful" )
1760 else:
1761 main.log.report( "Installing ONOS package failed" )
1762
shahshreyaa47ebf42015-05-20 13:29:18 -07001763 time.sleep( 10 )
shahshreya1f119da2015-04-21 17:16:46 -07001764 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
1765 onos2Isup = main.ONOSbench.isup( ONOS2Ip )
1766 onos3Isup = main.ONOSbench.isup( ONOS3Ip )
1767 onosIsup = onos1Isup and onos2Isup and onos3Isup
1768 if onosIsup == main.TRUE:
1769 main.log.report( "ONOS instances are up and ready" )
1770 else:
1771 main.log.report( "ONOS instances may not be up" )
1772
1773 main.step( "Starting ONOS service" )
shahshreyaa47ebf42015-05-20 13:29:18 -07001774 time.sleep( 10 )
shahshreya1f119da2015-04-21 17:16:46 -07001775 startResult = main.TRUE
1776 # startResult = main.ONOSbench.onosStart( ONOS1Ip )
1777 startcli1 = main.ONOScli1.startOnosCli( ONOSIp=ONOS1Ip )
1778 startcli2 = main.ONOScli2.startOnosCli( ONOSIp=ONOS2Ip )
1779 startcli3 = main.ONOScli3.startOnosCli( ONOSIp=ONOS3Ip )
1780 startResult = startcli1 and startcli2 and startcli3
1781 if startResult == main.TRUE:
1782 main.log.report( "ONOS cli starts properly" )
1783 case20Result = mininetDisconnect and cellResult and verifyResult \
1784 and onosInstallResult and onosIsup and startResult
1785
1786 utilities.assert_equals(
1787 expect=main.TRUE,
1788 actual=case20Result,
1789 onpass= "Exiting functionality mininet topology and reinstalling" +
1790 " ONOS successful",
1791 onfail= "Exiting functionality mininet topology and reinstalling" +
1792 " ONOS failed" )
1793
1794 def CASE21( self, main ):
1795 """
1796 On ONOS bench, run this command:
1797 sudo -E python ~/onos/tools/test/topos/opticalTest.py -OC1 <Ctrls>
1798 which spawns packet optical topology and copies the links
1799 json file to the onos instance.
1800 Note that in case of Packet Optical, the links are not learnt
1801 from the topology, instead the links are learnt
1802 from the json config file
1803 """
1804 main.log.report(
1805 "This testcase starts the packet layer topology and REST" )
1806 main.log.report( "_____________________________________________" )
1807 main.case( "Starting LINC-OE and other components" )
1808 main.step( "Starting LINC-OE and other components" )
1809 main.log.info( "Activate optical app" )
1810 appInstallResult = main.ONOScli1.activateApp( "org.onosproject.optical" )
1811 appCheck = main.ONOScli1.appToIDCheck()
1812 appCheck = appCheck and main.ONOScli2.appToIDCheck()
1813 appCheck = appCheck and main.ONOScli3.appToIDCheck()
1814 if appCheck != main.TRUE:
1815 main.log.warn( "Checking ONOS application unsuccesful" )
1816
1817 ctrllerIP = []
1818 ctrllerIP.append( main.params[ 'CTRL' ][ 'ip1' ] )
1819 #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip2' ] )
1820 #ctrllerIP.append( main.params[ 'CTRL' ][ 'ip3' ] )
1821 opticalMnScript = main.LincOE2.runOpticalMnScript( ctrllerIP = ctrllerIP )
1822 case21Result = opticalMnScript and appInstallResult
1823 utilities.assert_equals(
1824 expect=main.TRUE,
1825 actual=case21Result,
1826 onpass="Packet optical topology spawned successsfully",
1827 onfail="Packet optical topology spawning failed" )
1828
1829 def CASE22( self, main ):
1830 """
1831 Curretly we use, 10 optical switches(ROADM's) and
1832 6 packet layer mininet switches each with one host.
1833 Therefore, the roadmCount variable = 10,
1834 packetLayerSWCount variable = 6, hostCount=6 and
shahshreyaa47ebf42015-05-20 13:29:18 -07001835 links=46.
shahshreya1f119da2015-04-21 17:16:46 -07001836 All this is hardcoded in the testcase. If the topology changes,
1837 these hardcoded values need to be changed
1838 """
shahshreyaa47ebf42015-05-20 13:29:18 -07001839 import time
shahshreya1f119da2015-04-21 17:16:46 -07001840 main.log.report(
1841 "This testcase compares the optical+packet topology against what" +
1842 " is expected" )
1843 main.case( "Topology comparision" )
1844 main.step( "Topology comparision" )
1845 devicesResult = main.ONOScli3.devices( jsonFormat=False )
shahshreyaa47ebf42015-05-20 13:29:18 -07001846 time.sleep( 15 )
shahshreya1f119da2015-04-21 17:16:46 -07001847 print "devices_result = ", devicesResult
1848 devicesLinewise = devicesResult.split( "\n" )
shahshreya1f119da2015-04-21 17:16:46 -07001849 roadmCount = 0
1850 packetLayerSWCount = 0
1851 for line in devicesLinewise:
1852 components = line.split( "," )
1853 availability = components[ 1 ].split( "=" )[ 1 ]
1854 type = components[ 3 ].split( "=" )[ 1 ]
1855 if availability == 'true' and type == 'ROADM':
1856 roadmCount += 1
1857 elif availability == 'true' and type == 'SWITCH':
1858 packetLayerSWCount += 1
1859 if roadmCount == 10:
1860 print "Number of Optical Switches = %d and is" % roadmCount +\
1861 " correctly detected"
1862 main.log.info(
1863 "Number of Optical Switches = " +
1864 str( roadmCount ) +
1865 " and is correctly detected" )
1866 opticalSWResult = main.TRUE
1867 else:
1868 print "Number of Optical Switches = %d and is wrong" % roadmCount
1869 main.log.info(
1870 "Number of Optical Switches = " +
1871 str( roadmCount ) +
1872 " and is wrong" )
1873 opticalSWResult = main.FALSE
1874
1875 if packetLayerSWCount == 6:
1876 print "Number of Packet layer or mininet Switches = %d "\
1877 % packetLayerSWCount + "and is correctly detected"
1878 main.log.info(
1879 "Number of Packet layer or mininet Switches = " +
1880 str( packetLayerSWCount ) +
1881 " and is correctly detected" )
1882 packetSWResult = main.TRUE
1883 else:
1884 print "Number of Packet layer or mininet Switches = %d and"\
1885 % packetLayerSWCount + " is wrong"
1886 main.log.info(
1887 "Number of Packet layer or mininet Switches = " +
1888 str( packetLayerSWCount ) +
1889 " and is wrong" )
1890 packetSWResult = main.FALSE
1891 print "_________________________________"
1892
1893 linksResult = main.ONOScli3.links( jsonFormat=False )
1894 print "links_result = ", linksResult
1895 print "_________________________________"
1896 linkActiveCount = linksResult.count("state=ACTIVE")
1897 main.log.info( "linkActiveCount = " + str( linkActiveCount ))
shahshreyaa47ebf42015-05-20 13:29:18 -07001898 if linkActiveCount == 46:
shahshreya1f119da2015-04-21 17:16:46 -07001899 linkActiveResult = main.TRUE
1900 main.log.info(
1901 "Number of links in ACTIVE state are correct")
1902 else:
1903 linkActiveResult = main.FALSE
1904 main.log.info(
1905 "Number of links in ACTIVE state are wrong")
1906
1907 case22Result = opticalSWResult and packetSWResult and \
1908 linkActiveResult
1909 utilities.assert_equals(
1910 expect=main.TRUE,
1911 actual=case22Result,
1912 onpass="Packet optical topology discovery successful",
1913 onfail="Packet optical topology discovery failed" )
1914
1915 def CASE23( self, main ):
1916 import time
1917 """
1918 Add bidirectional point intents between 2 packet layer( mininet )
1919 devices and
1920 ping mininet hosts
1921 """
1922 main.log.report(
1923 "This testcase adds bidirectional point intents between 2 " +
1924 "packet layer( mininet ) devices and ping mininet hosts" )
1925 main.case( "Topology comparision" )
1926 main.step( "Adding point intents" )
1927 ptpIntentResult = main.ONOScli1.addPointIntent(
1928 "of:0000ffffffff0001/1",
1929 "of:0000ffffffff0005/1" )
1930 if ptpIntentResult == main.TRUE:
1931 main.ONOScli1.intents( jsonFormat=False )
1932 main.log.info( "Point to point intent install successful" )
1933
1934 ptpIntentResult = main.ONOScli1.addPointIntent(
1935 "of:0000ffffffff0005/1",
1936 "of:0000ffffffff0001/1" )
1937 if ptpIntentResult == main.TRUE:
1938 main.ONOScli1.intents( jsonFormat=False )
1939 main.log.info( "Point to point intent install successful" )
1940
1941 time.sleep( 30 )
shahshreyabf739d82015-06-10 11:22:31 -07001942 #flowHandle = main.ONOScli1.flows()
1943 #main.log.info( "flows :" + flowHandle )
shahshreya1f119da2015-04-21 17:16:46 -07001944
1945 # Sleep for 30 seconds to provide time for the intent state to change
1946 time.sleep( 60 )
1947 intentHandle = main.ONOScli1.intents( jsonFormat=False )
1948 main.log.info( "intents :" + intentHandle )
1949
1950 PingResult = main.TRUE
1951 count = 1
1952 main.log.info( "\n\nh1 is Pinging h5" )
1953 ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
1954 # ping = main.LincOE2.pinghost()
1955 if ping == main.FALSE and count < 5:
1956 count += 1
1957 PingResult = main.FALSE
1958 main.log.info(
1959 "Ping between h1 and h5 failed. Making attempt number " +
1960 str( count ) +
1961 " in 2 seconds" )
1962 time.sleep( 2 )
1963 elif ping == main.FALSE:
1964 main.log.info( "All ping attempts between h1 and h5 have failed" )
1965 PingResult = main.FALSE
1966 elif ping == main.TRUE:
1967 main.log.info( "Ping test between h1 and h5 passed!" )
1968 PingResult = main.TRUE
1969 else:
1970 main.log.info( "Unknown error" )
1971 PingResult = main.ERROR
1972
1973 if PingResult == main.FALSE:
1974 main.log.report(
1975 "Point intents for packet optical have not ben installed" +
1976 " correctly. Cleaning up" )
1977 if PingResult == main.TRUE:
1978 main.log.report(
1979 "Point Intents for packet optical have been " +
1980 "installed correctly" )
1981
1982 case23Result = PingResult
1983 utilities.assert_equals(
1984 expect=main.TRUE,
1985 actual=case23Result,
1986 onpass= "Point intents addition for packet optical and" +
1987 "Pingall Test successful",
1988 onfail= "Point intents addition for packet optical and" +
1989 "Pingall Test NOT successful" )
1990
1991 def CASE24( self, main ):
1992 import time
1993 import json
1994 """
1995 LINC uses its own switch IDs. You can use the following
1996 command on the LINC console to find the mapping between
1997 DPIDs and LINC IDs.
1998 rp(application:get_all_key(linc)).
1999
2000 Test Rerouting of Packet Optical by bringing a port down
2001 ( port 20 ) of a switch( switchID=1, or LincOE switchID =9 ),
2002 so that link
2003 ( between switch1 port20 - switch5 port50 ) is inactive
2004 and do a ping test. If rerouting is successful,
2005 ping should pass. also check the flows
2006 """
2007 main.log.report(
2008 "This testcase tests rerouting and pings mininet hosts" )
2009 main.case( "Test rerouting and pings mininet hosts" )
2010 main.step( "Attach to the Linc-OE session" )
2011 attachConsole = main.LincOE1.attachLincOESession()
2012 print "attachConsole = ", attachConsole
2013
2014 main.step( "Bring a port down and verify the link state" )
2015 main.LincOE1.portDown( swId="9", ptId="20" )
2016 linksNonjson = main.ONOScli3.links( jsonFormat=False )
2017 main.log.info( "links = " + linksNonjson )
2018
2019 linkInactiveCount = linksNonjson.count("state=INACTIVE")
2020 main.log.info( "linkInactiveCount = " + str( linkInactiveCount ))
2021 if linkInactiveCount == 2:
2022 main.log.info(
2023 "Number of links in INACTIVE state are correct")
2024 else:
2025 main.log.info(
2026 "Number of links in INACTIVE state are wrong")
2027
2028 links = main.ONOScli3.links()
2029 main.log.info( "links = " + links )
2030
2031 linksResult = json.loads( links )
2032 linksStateResult = main.FALSE
2033 for item in linksResult:
2034 if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
2035 'src' ][ 'port' ] == "20":
2036 if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff05" and item[
2037 'dst' ][ 'port' ] == "50":
2038 linksState = item[ 'state' ]
2039 if linksState == "INACTIVE":
2040 main.log.info(
2041 "Links state is inactive as expected due to one" +
2042 " of the ports being down" )
2043 main.log.report(
2044 "Links state is inactive as expected due to one" +
2045 " of the ports being down" )
2046 linksStateResult = main.TRUE
2047 break
2048 else:
2049 main.log.info(
2050 "Links state is not inactive as expected" )
2051 main.log.report(
2052 "Links state is not inactive as expected" )
2053 linksStateResult = main.FALSE
2054
2055 print "links_state_result = ", linksStateResult
2056 time.sleep( 10 )
shahshreyabf739d82015-06-10 11:22:31 -07002057 #flowHandle = main.ONOScli3.flows()
2058 #main.log.info( "flows :" + flowHandle )
shahshreya1f119da2015-04-21 17:16:46 -07002059
2060 main.step( "Verify Rerouting by a ping test" )
2061 PingResult = main.TRUE
2062 count = 1
2063 main.log.info( "\n\nh1 is Pinging h5" )
2064 ping = main.LincOE2.pingHostOptical( src="h1", target="h5" )
2065 # ping = main.LincOE2.pinghost()
2066 if ping == main.FALSE and count < 5:
2067 count += 1
2068 PingResult = main.FALSE
2069 main.log.info(
2070 "Ping between h1 and h5 failed. Making attempt number " +
2071 str( count ) +
2072 " in 2 seconds" )
2073 time.sleep( 2 )
2074 elif ping == main.FALSE:
2075 main.log.info( "All ping attempts between h1 and h5 have failed" )
2076 PingResult = main.FALSE
2077 elif ping == main.TRUE:
2078 main.log.info( "Ping test between h1 and h5 passed!" )
2079 PingResult = main.TRUE
2080 else:
2081 main.log.info( "Unknown error" )
2082 PingResult = main.ERROR
2083
2084 if PingResult == main.TRUE:
2085 main.log.report( "Ping test successful " )
2086 if PingResult == main.FALSE:
2087 main.log.report( "Ping test failed" )
2088
2089 case24Result = PingResult and linksStateResult
2090 utilities.assert_equals( expect=main.TRUE, actual=case24Result,
2091 onpass="Packet optical rerouting successful",
2092 onfail="Packet optical rerouting failed" )