blob: 01aad3363abca1708e14c303cc124da77eadef41 [file] [log] [blame]
pingping-lin86d9f512015-08-17 18:29:41 -07001# Testing the functionality of SDN-IP with single ONOS instance
2class SDNIPfunction:
3
pingping-lin500727a2015-09-02 19:53:11 -07004 def __init__( self ):
pingping-lin86d9f512015-08-17 18:29:41 -07005 self.default = ''
6 global branchName
7
8
9 # This case is to setup ONOS
pingping-lin500727a2015-09-02 19:53:11 -070010 def CASE100( self, main ):
pingping-lin86d9f512015-08-17 18:29:41 -070011 """
12 CASE100 is to compile ONOS and install it
13 Startup sequence:
14 cell <name>
15 onos-verify-cell
16 git pull
17 mvn clean install
18 onos-package
19 onos-install -f
20 onos-wait-for-start
21 """
pingping-lin500727a2015-09-02 19:53:11 -070022 main.case( "Setting up test environment" )
pingping-lin86d9f512015-08-17 18:29:41 -070023
24 cellName = main.params[ 'ENV' ][ 'cellName' ]
25 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
26
pingping-lin500727a2015-09-02 19:53:11 -070027 main.step( "Applying cell variable to environment" )
28 cellResult = main.ONOSbench.setCell( cellName )
pingping-lin86d9f512015-08-17 18:29:41 -070029 verifyResult = main.ONOSbench.verifyCell()
30
31 branchName = main.ONOSbench.getBranchName()
pingping-lin500727a2015-09-02 19:53:11 -070032 main.log.info( "ONOS is on branch: " + branchName )
pingping-lin86d9f512015-08-17 18:29:41 -070033
pingping-lin500727a2015-09-02 19:53:11 -070034 main.log.report( "Uninstalling ONOS" )
35 main.ONOSbench.onosUninstall( ONOS1Ip )
pingping-lin86d9f512015-08-17 18:29:41 -070036
37 # cleanInstallResult = main.TRUE
38 # gitPullResult = main.TRUE
39
pingping-lin500727a2015-09-02 19:53:11 -070040 main.step( "Git pull" )
pingping-lin86d9f512015-08-17 18:29:41 -070041 gitPullResult = main.ONOSbench.gitPull()
42
pingping-lin500727a2015-09-02 19:53:11 -070043 main.step( "Using mvn clean install" )
pingping-lin86d9f512015-08-17 18:29:41 -070044 if gitPullResult == main.TRUE:
pingping-lin500727a2015-09-02 19:53:11 -070045 cleanInstallResult = main.ONOSbench.cleanInstall( mciTimeout = 1000 )
pingping-lin86d9f512015-08-17 18:29:41 -070046 else:
pingping-lin500727a2015-09-02 19:53:11 -070047 main.log.warn( "Did not pull new code so skipping mvn " +
48 "clean install" )
pingping-lin86d9f512015-08-17 18:29:41 -070049 cleanInstallResult = main.TRUE
50
pingping-lin500727a2015-09-02 19:53:11 -070051 main.ONOSbench.getVersion( report = True )
pingping-lin86d9f512015-08-17 18:29:41 -070052
pingping-lin500727a2015-09-02 19:53:11 -070053 main.step( "Creating ONOS package" )
54 packageResult = main.ONOSbench.onosPackage( opTimeout = 500 )
pingping-lin86d9f512015-08-17 18:29:41 -070055
pingping-lin500727a2015-09-02 19:53:11 -070056 main.step( "Installing ONOS package" )
57 onos1InstallResult = main.ONOSbench.onosInstall( options = "-f",
58 node = ONOS1Ip )
pingping-lin86d9f512015-08-17 18:29:41 -070059
pingping-lin500727a2015-09-02 19:53:11 -070060 main.step( "Checking if ONOS is up yet" )
61 for i in range( 2 ):
62 onos1Isup = main.ONOSbench.isup( ONOS1Ip, timeout = 420 )
pingping-lin86d9f512015-08-17 18:29:41 -070063 if onos1Isup:
64 break
65 if not onos1Isup:
pingping-lin500727a2015-09-02 19:53:11 -070066 main.log.report( "ONOS1 didn't start!" )
pingping-lin86d9f512015-08-17 18:29:41 -070067
pingping-lin500727a2015-09-02 19:53:11 -070068 cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
69 commandlineTimeout = 100, onosStartTimeout = 600 )
pingping-lin86d9f512015-08-17 18:29:41 -070070
pingping-lin500727a2015-09-02 19:53:11 -070071 case1Result = ( cleanInstallResult and packageResult and
pingping-lin86d9f512015-08-17 18:29:41 -070072 cellResult and verifyResult and
73 onos1InstallResult and
pingping-lin500727a2015-09-02 19:53:11 -070074 onos1Isup and cliResult )
pingping-lin86d9f512015-08-17 18:29:41 -070075
pingping-lin500727a2015-09-02 19:53:11 -070076 utilities.assert_equals( expect = main.TRUE, actual = case1Result,
77 onpass = "ONOS startup successful",
78 onfail = "ONOS startup NOT successful" )
pingping-lin86d9f512015-08-17 18:29:41 -070079
80 if case1Result == main.FALSE:
81 main.cleanup()
82 main.exit()
83
pingping-lin500727a2015-09-02 19:53:11 -070084 def CASE4( self, main ):
pingping-lin86d9f512015-08-17 18:29:41 -070085 """
86 Test the SDN-IP functionality
87 allRoutesExpected: all expected routes for all BGP peers
88 routeIntentsExpected: all expected MultiPointToSinglePointIntent \
89 intents
90 bgpIntentsExpected: expected PointToPointIntent intents
91 allRoutesActual: all routes from ONOS LCI
92 routeIntentsActual: actual MultiPointToSinglePointIntent intents from \
93 ONOS CLI
94 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
95 """
96 import json
97 import time
98 from operator import eq
99 from time import localtime, strftime
100
pingping-lin500727a2015-09-02 19:53:11 -0700101 main.case( "This case is to testing the functionality of SDN-IP with \
102 single ONOS instance" )
pingping-lin86d9f512015-08-17 18:29:41 -0700103 SDNIPJSONFILEPATH = \
Jon Hall53c5e662016-04-13 16:06:56 -0700104 "~/ONOS/tools/package/config/sdnip.json"
pingping-lin86d9f512015-08-17 18:29:41 -0700105 # all expected routes for all BGP peers
106 allRoutesExpected = []
pingping-lin500727a2015-09-02 19:53:11 -0700107 main.step( "Start to generate routes for all BGP peers" )
108 main.log.info( "Generate prefixes for host3" )
109 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
110 main.log.info( prefixesHost3 )
pingping-lin86d9f512015-08-17 18:29:41 -0700111 # generate route with next hop
112 for prefix in prefixesHost3:
pingping-lin500727a2015-09-02 19:53:11 -0700113 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
pingping-lin86d9f512015-08-17 18:29:41 -0700114 routeIntentsExpectedHost3 = \
pingping-lin500727a2015-09-02 19:53:11 -0700115 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
pingping-lin86d9f512015-08-17 18:29:41 -0700116 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
pingping-lin500727a2015-09-02 19:53:11 -0700117 SDNIPJSONFILEPATH )
pingping-lin86d9f512015-08-17 18:29:41 -0700118
pingping-lin500727a2015-09-02 19:53:11 -0700119 main.log.info( "Generate prefixes for host4" )
120 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
121 main.log.info( prefixesHost4 )
pingping-lin86d9f512015-08-17 18:29:41 -0700122 # generate route with next hop
123 for prefix in prefixesHost4:
pingping-lin500727a2015-09-02 19:53:11 -0700124 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
pingping-lin86d9f512015-08-17 18:29:41 -0700125 routeIntentsExpectedHost4 = \
pingping-lin500727a2015-09-02 19:53:11 -0700126 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
pingping-lin86d9f512015-08-17 18:29:41 -0700127 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
pingping-lin500727a2015-09-02 19:53:11 -0700128 SDNIPJSONFILEPATH )
pingping-lin86d9f512015-08-17 18:29:41 -0700129
pingping-lin500727a2015-09-02 19:53:11 -0700130 main.log.info( "Generate prefixes for host5" )
131 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
132 main.log.info( prefixesHost5 )
pingping-lin86d9f512015-08-17 18:29:41 -0700133 for prefix in prefixesHost5:
pingping-lin500727a2015-09-02 19:53:11 -0700134 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
pingping-lin86d9f512015-08-17 18:29:41 -0700135 routeIntentsExpectedHost5 = \
pingping-lin500727a2015-09-02 19:53:11 -0700136 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
pingping-lin86d9f512015-08-17 18:29:41 -0700137 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
pingping-lin500727a2015-09-02 19:53:11 -0700138 SDNIPJSONFILEPATH )
pingping-lin86d9f512015-08-17 18:29:41 -0700139
140 routeIntentsExpected = routeIntentsExpectedHost3 + \
141 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
142
pingping-lin500727a2015-09-02 19:53:11 -0700143 main.step( "Get links in the network" )
144 listResult = main.ONOScli.links( jsonFormat = False )
145 main.log.info( listResult )
146 main.log.info( "Activate sdn-ip application" )
147 main.ONOScli.activateApp( "org.onosproject.sdnip" )
pingping-lin86d9f512015-08-17 18:29:41 -0700148 # wait sdn-ip to finish installing connectivity intents, and the BGP
149 # paths in data plane are ready.
pingping-lin500727a2015-09-02 19:53:11 -0700150 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
pingping-lin86d9f512015-08-17 18:29:41 -0700151
pingping-lin500727a2015-09-02 19:53:11 -0700152 main.step( "Login all BGP peers and add routes into peers" )
pingping-lin86d9f512015-08-17 18:29:41 -0700153
pingping-lin500727a2015-09-02 19:53:11 -0700154 main.log.info( "Login Quagga CLI on host3" )
155 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
156 main.log.info( "Enter configuration model of Quagga CLI on host3" )
157 main.QuaggaCliHost3.enterConfig( 64514 )
158 main.log.info( "Add routes to Quagga on host3" )
159 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
pingping-lin86d9f512015-08-17 18:29:41 -0700160
pingping-lin500727a2015-09-02 19:53:11 -0700161 main.log.info( "Login Quagga CLI on host4" )
162 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
163 main.log.info( "Enter configuration model of Quagga CLI on host4" )
164 main.QuaggaCliHost4.enterConfig( 64516 )
165 main.log.info( "Add routes to Quagga on host4" )
166 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
pingping-lin86d9f512015-08-17 18:29:41 -0700167
pingping-lin500727a2015-09-02 19:53:11 -0700168 main.log.info( "Login Quagga CLI on host5" )
169 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
170 main.log.info( "Enter configuration model of Quagga CLI on host5" )
171 main.QuaggaCliHost5.enterConfig( 64521 )
172 main.log.info( "Add routes to Quagga on host5" )
173 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
pingping-lin86d9f512015-08-17 18:29:41 -0700174
pingping-lin500727a2015-09-02 19:53:11 -0700175 for i in range( 101, 201 ):
176 prefixesHostX = main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
177 main.log.info( prefixesHostX )
pingping-lin86d9f512015-08-17 18:29:41 -0700178 for prefix in prefixesHostX:
pingping-lin500727a2015-09-02 19:53:11 -0700179 allRoutesExpected.append( prefix + "/" + "192.168.40."
180 + str( i - 100 ) )
pingping-lin86d9f512015-08-17 18:29:41 -0700181
182 routeIntentsExpectedHostX = \
pingping-lin500727a2015-09-02 19:53:11 -0700183 main.QuaggaCliHost.generateExpectedOnePeerRouteIntents(
184 prefixesHostX, "192.168.40." + str( i - 100 ),
185 "00:00:%02d:00:00:90" % ( i - 101 ), SDNIPJSONFILEPATH )
pingping-lin86d9f512015-08-17 18:29:41 -0700186 routeIntentsExpected = routeIntentsExpected + \
187 routeIntentsExpectedHostX
188
pingping-lin500727a2015-09-02 19:53:11 -0700189 main.log.info( "Login Quagga CLI on host" + str( i ) )
190 QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
191 QuaggaCliHostX.loginQuagga( "1.168.30." + str( i ) )
192 main.log.info( \
193 "Enter configuration model of Quagga CLI on host" + str( i ) )
194 QuaggaCliHostX.enterConfig( 65000 + i - 100 )
195 main.log.info( "Add routes to Quagga on host" + str( i ) )
196 QuaggaCliHostX.addRoutes( prefixesHostX, 1 )
pingping-lin86d9f512015-08-17 18:29:41 -0700197 # wait Quagga to finish delivery all routes to each other and to sdn-ip,
198 # plus finish installing all intents.
pingping-lin500727a2015-09-02 19:53:11 -0700199 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
200 time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
pingping-lin86d9f512015-08-17 18:29:41 -0700201 # get routes inside SDN-IP
pingping-lin500727a2015-09-02 19:53:11 -0700202 getRoutesResult = main.ONOScli.routes( jsonFormat = True )
pingping-lin86d9f512015-08-17 18:29:41 -0700203
204 allRoutesActual = \
pingping-lin500727a2015-09-02 19:53:11 -0700205 main.QuaggaCliHost3.extractActualRoutesMaster( getRoutesResult )
pingping-lin86d9f512015-08-17 18:29:41 -0700206
pingping-lin500727a2015-09-02 19:53:11 -0700207 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
208 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
209 main.step( "Check routes installed" )
210 main.log.info( "Routes expected:" )
211 main.log.info( allRoutesStrExpected )
212 main.log.info( "Routes get from ONOS CLI:" )
213 main.log.info( allRoutesStrActual )
214 utilities.assertEquals( \
215 expect = allRoutesStrExpected, actual = allRoutesStrActual,
216 onpass = "***Routes in SDN-IP are correct!***",
217 onfail = "***Routes in SDN-IP are wrong!***" )
pingping-lin86d9f512015-08-17 18:29:41 -0700218
pingping-lin500727a2015-09-02 19:53:11 -0700219 getIntentsResult = main.ONOScli.intents( jsonFormat = True )
pingping-lin86d9f512015-08-17 18:29:41 -0700220
pingping-lin500727a2015-09-02 19:53:11 -0700221 main.step( "Check MultiPointToSinglePointIntent intents installed" )
pingping-lin86d9f512015-08-17 18:29:41 -0700222 # routeIntentsExpected are generated when generating routes
223 # get route intents from ONOS CLI
224 routeIntentsActualNum = \
pingping-lin500727a2015-09-02 19:53:11 -0700225 main.QuaggaCliHost3.extractActualRouteIntentNum( getIntentsResult )
pingping-lin86d9f512015-08-17 18:29:41 -0700226 routeIntentsExpectedNum = 1030
pingping-lin500727a2015-09-02 19:53:11 -0700227 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
228 main.log.info( routeIntentsExpectedNum )
229 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
230 main.log.info( routeIntentsActualNum )
231 utilities.assertEquals( \
232 expect = True,
233 actual = eq( routeIntentsExpectedNum, routeIntentsActualNum ),
234 onpass = "***MultiPointToSinglePoint Intent Num in SDN-IP is \
pingping-lin86d9f512015-08-17 18:29:41 -0700235 correct!***",
pingping-lin500727a2015-09-02 19:53:11 -0700236 onfail = "***MultiPointToSinglePoint Intent Num in SDN-IP is \
237 wrong!***" )
pingping-lin86d9f512015-08-17 18:29:41 -0700238
pingping-lin500727a2015-09-02 19:53:11 -0700239 main.step( "Check BGP PointToPointIntent intents installed" )
pingping-lin86d9f512015-08-17 18:29:41 -0700240
241 bgpIntentsActualNum = \
pingping-lin500727a2015-09-02 19:53:11 -0700242 main.QuaggaCliHost3.extractActualBgpIntentNum( getIntentsResult )
pingping-lin86d9f512015-08-17 18:29:41 -0700243 bgpIntentsExpectedNum = 624
pingping-lin500727a2015-09-02 19:53:11 -0700244 main.log.info( "bgpIntentsExpected num is:" )
245 main.log.info( bgpIntentsExpectedNum )
246 main.log.info( "bgpIntentsActual num is:" )
247 main.log.info( bgpIntentsActualNum )
248 utilities.assertEquals( \
249 expect = True,
250 actual = eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
251 onpass = "***PointToPointIntent Intent Num in SDN-IP are correct!***",
252 onfail = "***PointToPointIntent Intent Num in SDN-IP are wrong!***" )
pingping-lin86d9f512015-08-17 18:29:41 -0700253
254 #============================= Ping Test ========================
Jon Hall53c5e662016-04-13 16:06:56 -0700255 pingTestScript = "~/OnosSystemTest/TestON/tests/SDNIPfunction/dependencies/CASE4-ping-as2host.sh"
pingping-lin86d9f512015-08-17 18:29:41 -0700256 pingTestResultsFile = \
Jon Hall53c5e662016-04-13 16:06:56 -0700257 "~/OnosSystemTest/TestON/tests/SDNIPfunction/dependencies/log/CASE4-ping-results-before-delete-routes-"\
pingping-lin500727a2015-09-02 19:53:11 -0700258 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
259 pingTestResults = main.QuaggaCliHost.pingTest( \
260 "1.168.30.100", pingTestScript, pingTestResultsFile )
261 main.log.info( pingTestResults )
pingping-lin86d9f512015-08-17 18:29:41 -0700262 # wait to finish the ping test
pingping-lin500727a2015-09-02 19:53:11 -0700263 time.sleep( int( main.params[ 'timers' ][ 'PingTestWithRoutes' ] ) )
pingping-lin86d9f512015-08-17 18:29:41 -0700264
265 #============================= Deleting Routes ==================
pingping-lin500727a2015-09-02 19:53:11 -0700266 main.step( "Check deleting routes installed" )
267 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
268 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
269 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
pingping-lin86d9f512015-08-17 18:29:41 -0700270
pingping-lin500727a2015-09-02 19:53:11 -0700271 for i in range( 101, 201 ):
272 prefixesHostX = main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
273 main.log.info( prefixesHostX )
274 QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
275 QuaggaCliHostX.deleteRoutes( prefixesHostX, 1 )
pingping-lin86d9f512015-08-17 18:29:41 -0700276 # wait Quagga to finish delivery all routes to each other and to sdn-ip,
277 # plus finish un-installing all intents.
pingping-lin500727a2015-09-02 19:53:11 -0700278 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
279 time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
pingping-lin86d9f512015-08-17 18:29:41 -0700280
pingping-lin500727a2015-09-02 19:53:11 -0700281 getRoutesResult = main.ONOScli.routes( jsonFormat = True )
pingping-lin86d9f512015-08-17 18:29:41 -0700282 allRoutesActual = \
pingping-lin500727a2015-09-02 19:53:11 -0700283 main.QuaggaCliHost3.extractActualRoutesMaster( getRoutesResult )
284 main.log.info( "allRoutes_actual = " )
285 main.log.info( allRoutesActual )
pingping-lin86d9f512015-08-17 18:29:41 -0700286
pingping-lin500727a2015-09-02 19:53:11 -0700287 utilities.assertEquals( \
288 expect = "[]", actual = str( allRoutesActual ),
289 onpass = "***Route number in SDN-IP is 0, correct!***",
290 onfail = "***Routes number in SDN-IP is not 0, wrong!***" )
pingping-lin86d9f512015-08-17 18:29:41 -0700291
pingping-lin500727a2015-09-02 19:53:11 -0700292 main.step( "Check intents after deleting routes" )
293 getIntentsResult = main.ONOScli.intents( jsonFormat = True )
pingping-lin86d9f512015-08-17 18:29:41 -0700294 routeIntentsActualNum = \
pingping-lin500727a2015-09-02 19:53:11 -0700295 main.QuaggaCliHost3.extractActualRouteIntentNum(
296 getIntentsResult )
297 main.log.info( "route Intents Actual Num is: " )
298 main.log.info( routeIntentsActualNum )
299 utilities.assertEquals( \
300 expect = 0, actual = routeIntentsActualNum,
301 onpass = "***MultiPointToSinglePoint Intent Num in SDN-IP is 0, \
pingping-lin86d9f512015-08-17 18:29:41 -0700302 correct!***",
pingping-lin500727a2015-09-02 19:53:11 -0700303 onfail = "***MultiPointToSinglePoint Intent Num in SDN-IP is not 0, \
304 wrong!***" )
pingping-lin86d9f512015-08-17 18:29:41 -0700305
Jon Hall53c5e662016-04-13 16:06:56 -0700306 pingTestScript = "~/OnosSystemTest/TestON/tests/SDNIPfunction/dependencies/CASE4-ping-as2host.sh"
pingping-lin86d9f512015-08-17 18:29:41 -0700307 pingTestResultsFile = \
Jon Hall53c5e662016-04-13 16:06:56 -0700308 "~/OnosSystemTest/TestON/tests/SDNIPfunction/dependencies/log/CASE4-ping-results-after-delete-routes-"\
pingping-lin500727a2015-09-02 19:53:11 -0700309 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
310 pingTestResults = main.QuaggaCliHost.pingTest( \
311 "1.168.30.100", pingTestScript, pingTestResultsFile )
312 main.log.info( pingTestResults )
pingping-lin86d9f512015-08-17 18:29:41 -0700313 # wait to finish the ping test
pingping-lin500727a2015-09-02 19:53:11 -0700314 time.sleep( int( main.params[ 'timers' ][ 'PingTestWithoutRoutes' ] ) )