blob: 1c19c30f3c770f05ae5d8ddcbac6f4b69151cc15 [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" )
Jon Hallbd60ea02016-08-23 10:03:59 -070054 packageResult = main.ONOSbench.buckBuild()
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
You Wangf5de25b2017-01-06 15:13:01 -080060 main.step( "Set up ONOS secure SSH" )
61 secureSshResult = main.ONOSbench.onosSecureSSH( node=ONOS1Ip )
62
pingping-lin500727a2015-09-02 19:53:11 -070063 main.step( "Checking if ONOS is up yet" )
64 for i in range( 2 ):
65 onos1Isup = main.ONOSbench.isup( ONOS1Ip, timeout = 420 )
pingping-lin86d9f512015-08-17 18:29:41 -070066 if onos1Isup:
67 break
68 if not onos1Isup:
pingping-lin500727a2015-09-02 19:53:11 -070069 main.log.report( "ONOS1 didn't start!" )
pingping-lin86d9f512015-08-17 18:29:41 -070070
pingping-lin500727a2015-09-02 19:53:11 -070071 cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
72 commandlineTimeout = 100, onosStartTimeout = 600 )
pingping-lin86d9f512015-08-17 18:29:41 -070073
pingping-lin500727a2015-09-02 19:53:11 -070074 case1Result = ( cleanInstallResult and packageResult and
pingping-lin86d9f512015-08-17 18:29:41 -070075 cellResult and verifyResult and
76 onos1InstallResult and
Chiyu Chengef109502016-11-21 15:51:38 -080077 onos1Isup and secureSshResult and
78 cliResult )
pingping-lin86d9f512015-08-17 18:29:41 -070079
pingping-lin500727a2015-09-02 19:53:11 -070080 utilities.assert_equals( expect = main.TRUE, actual = case1Result,
81 onpass = "ONOS startup successful",
82 onfail = "ONOS startup NOT successful" )
pingping-lin86d9f512015-08-17 18:29:41 -070083
84 if case1Result == main.FALSE:
85 main.cleanup()
86 main.exit()
87
pingping-lin500727a2015-09-02 19:53:11 -070088 def CASE4( self, main ):
pingping-lin86d9f512015-08-17 18:29:41 -070089 """
90 Test the SDN-IP functionality
91 allRoutesExpected: all expected routes for all BGP peers
92 routeIntentsExpected: all expected MultiPointToSinglePointIntent \
93 intents
94 bgpIntentsExpected: expected PointToPointIntent intents
95 allRoutesActual: all routes from ONOS LCI
96 routeIntentsActual: actual MultiPointToSinglePointIntent intents from \
97 ONOS CLI
98 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
99 """
100 import json
101 import time
102 from operator import eq
103 from time import localtime, strftime
104
pingping-lin500727a2015-09-02 19:53:11 -0700105 main.case( "This case is to testing the functionality of SDN-IP with \
106 single ONOS instance" )
pingping-lin86d9f512015-08-17 18:29:41 -0700107 SDNIPJSONFILEPATH = \
Jon Hall53c5e662016-04-13 16:06:56 -0700108 "~/ONOS/tools/package/config/sdnip.json"
pingping-lin86d9f512015-08-17 18:29:41 -0700109 # all expected routes for all BGP peers
110 allRoutesExpected = []
pingping-lin500727a2015-09-02 19:53:11 -0700111 main.step( "Start to generate routes for all BGP peers" )
112 main.log.info( "Generate prefixes for host3" )
113 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
114 main.log.info( prefixesHost3 )
pingping-lin86d9f512015-08-17 18:29:41 -0700115 # generate route with next hop
116 for prefix in prefixesHost3:
pingping-lin500727a2015-09-02 19:53:11 -0700117 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
pingping-lin86d9f512015-08-17 18:29:41 -0700118 routeIntentsExpectedHost3 = \
pingping-lin500727a2015-09-02 19:53:11 -0700119 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
pingping-lin86d9f512015-08-17 18:29:41 -0700120 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
pingping-lin500727a2015-09-02 19:53:11 -0700121 SDNIPJSONFILEPATH )
pingping-lin86d9f512015-08-17 18:29:41 -0700122
pingping-lin500727a2015-09-02 19:53:11 -0700123 main.log.info( "Generate prefixes for host4" )
124 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
125 main.log.info( prefixesHost4 )
pingping-lin86d9f512015-08-17 18:29:41 -0700126 # generate route with next hop
127 for prefix in prefixesHost4:
pingping-lin500727a2015-09-02 19:53:11 -0700128 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
pingping-lin86d9f512015-08-17 18:29:41 -0700129 routeIntentsExpectedHost4 = \
pingping-lin500727a2015-09-02 19:53:11 -0700130 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
pingping-lin86d9f512015-08-17 18:29:41 -0700131 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
pingping-lin500727a2015-09-02 19:53:11 -0700132 SDNIPJSONFILEPATH )
pingping-lin86d9f512015-08-17 18:29:41 -0700133
pingping-lin500727a2015-09-02 19:53:11 -0700134 main.log.info( "Generate prefixes for host5" )
135 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
136 main.log.info( prefixesHost5 )
pingping-lin86d9f512015-08-17 18:29:41 -0700137 for prefix in prefixesHost5:
pingping-lin500727a2015-09-02 19:53:11 -0700138 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
pingping-lin86d9f512015-08-17 18:29:41 -0700139 routeIntentsExpectedHost5 = \
pingping-lin500727a2015-09-02 19:53:11 -0700140 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
pingping-lin86d9f512015-08-17 18:29:41 -0700141 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
pingping-lin500727a2015-09-02 19:53:11 -0700142 SDNIPJSONFILEPATH )
pingping-lin86d9f512015-08-17 18:29:41 -0700143
144 routeIntentsExpected = routeIntentsExpectedHost3 + \
145 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
146
pingping-lin500727a2015-09-02 19:53:11 -0700147 main.step( "Get links in the network" )
148 listResult = main.ONOScli.links( jsonFormat = False )
149 main.log.info( listResult )
150 main.log.info( "Activate sdn-ip application" )
151 main.ONOScli.activateApp( "org.onosproject.sdnip" )
pingping-lin86d9f512015-08-17 18:29:41 -0700152 # wait sdn-ip to finish installing connectivity intents, and the BGP
153 # paths in data plane are ready.
pingping-lin500727a2015-09-02 19:53:11 -0700154 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
pingping-lin86d9f512015-08-17 18:29:41 -0700155
pingping-lin500727a2015-09-02 19:53:11 -0700156 main.step( "Login all BGP peers and add routes into peers" )
pingping-lin86d9f512015-08-17 18:29:41 -0700157
pingping-lin500727a2015-09-02 19:53:11 -0700158 main.log.info( "Login Quagga CLI on host3" )
159 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
160 main.log.info( "Enter configuration model of Quagga CLI on host3" )
161 main.QuaggaCliHost3.enterConfig( 64514 )
162 main.log.info( "Add routes to Quagga on host3" )
163 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
pingping-lin86d9f512015-08-17 18:29:41 -0700164
pingping-lin500727a2015-09-02 19:53:11 -0700165 main.log.info( "Login Quagga CLI on host4" )
166 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
167 main.log.info( "Enter configuration model of Quagga CLI on host4" )
168 main.QuaggaCliHost4.enterConfig( 64516 )
169 main.log.info( "Add routes to Quagga on host4" )
170 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
pingping-lin86d9f512015-08-17 18:29:41 -0700171
pingping-lin500727a2015-09-02 19:53:11 -0700172 main.log.info( "Login Quagga CLI on host5" )
173 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
174 main.log.info( "Enter configuration model of Quagga CLI on host5" )
175 main.QuaggaCliHost5.enterConfig( 64521 )
176 main.log.info( "Add routes to Quagga on host5" )
177 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
pingping-lin86d9f512015-08-17 18:29:41 -0700178
pingping-lin500727a2015-09-02 19:53:11 -0700179 for i in range( 101, 201 ):
180 prefixesHostX = main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
181 main.log.info( prefixesHostX )
pingping-lin86d9f512015-08-17 18:29:41 -0700182 for prefix in prefixesHostX:
pingping-lin500727a2015-09-02 19:53:11 -0700183 allRoutesExpected.append( prefix + "/" + "192.168.40."
184 + str( i - 100 ) )
pingping-lin86d9f512015-08-17 18:29:41 -0700185
186 routeIntentsExpectedHostX = \
pingping-lin500727a2015-09-02 19:53:11 -0700187 main.QuaggaCliHost.generateExpectedOnePeerRouteIntents(
188 prefixesHostX, "192.168.40." + str( i - 100 ),
189 "00:00:%02d:00:00:90" % ( i - 101 ), SDNIPJSONFILEPATH )
pingping-lin86d9f512015-08-17 18:29:41 -0700190 routeIntentsExpected = routeIntentsExpected + \
191 routeIntentsExpectedHostX
192
pingping-lin500727a2015-09-02 19:53:11 -0700193 main.log.info( "Login Quagga CLI on host" + str( i ) )
194 QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
195 QuaggaCliHostX.loginQuagga( "1.168.30." + str( i ) )
196 main.log.info( \
197 "Enter configuration model of Quagga CLI on host" + str( i ) )
198 QuaggaCliHostX.enterConfig( 65000 + i - 100 )
199 main.log.info( "Add routes to Quagga on host" + str( i ) )
200 QuaggaCliHostX.addRoutes( prefixesHostX, 1 )
pingping-lin86d9f512015-08-17 18:29:41 -0700201 # wait Quagga to finish delivery all routes to each other and to sdn-ip,
202 # plus finish installing all intents.
pingping-lin500727a2015-09-02 19:53:11 -0700203 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
204 time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
pingping-lin86d9f512015-08-17 18:29:41 -0700205 # get routes inside SDN-IP
pingping-lin500727a2015-09-02 19:53:11 -0700206 getRoutesResult = main.ONOScli.routes( jsonFormat = True )
pingping-lin86d9f512015-08-17 18:29:41 -0700207
208 allRoutesActual = \
pingping-lin500727a2015-09-02 19:53:11 -0700209 main.QuaggaCliHost3.extractActualRoutesMaster( getRoutesResult )
pingping-lin86d9f512015-08-17 18:29:41 -0700210
pingping-lin500727a2015-09-02 19:53:11 -0700211 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
212 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
213 main.step( "Check routes installed" )
214 main.log.info( "Routes expected:" )
215 main.log.info( allRoutesStrExpected )
216 main.log.info( "Routes get from ONOS CLI:" )
217 main.log.info( allRoutesStrActual )
218 utilities.assertEquals( \
219 expect = allRoutesStrExpected, actual = allRoutesStrActual,
220 onpass = "***Routes in SDN-IP are correct!***",
221 onfail = "***Routes in SDN-IP are wrong!***" )
pingping-lin86d9f512015-08-17 18:29:41 -0700222
pingping-lin500727a2015-09-02 19:53:11 -0700223 getIntentsResult = main.ONOScli.intents( jsonFormat = True )
pingping-lin86d9f512015-08-17 18:29:41 -0700224
pingping-lin500727a2015-09-02 19:53:11 -0700225 main.step( "Check MultiPointToSinglePointIntent intents installed" )
pingping-lin86d9f512015-08-17 18:29:41 -0700226 # routeIntentsExpected are generated when generating routes
227 # get route intents from ONOS CLI
228 routeIntentsActualNum = \
pingping-lin500727a2015-09-02 19:53:11 -0700229 main.QuaggaCliHost3.extractActualRouteIntentNum( getIntentsResult )
pingping-lin86d9f512015-08-17 18:29:41 -0700230 routeIntentsExpectedNum = 1030
pingping-lin500727a2015-09-02 19:53:11 -0700231 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
232 main.log.info( routeIntentsExpectedNum )
233 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
234 main.log.info( routeIntentsActualNum )
235 utilities.assertEquals( \
236 expect = True,
237 actual = eq( routeIntentsExpectedNum, routeIntentsActualNum ),
238 onpass = "***MultiPointToSinglePoint Intent Num in SDN-IP is \
pingping-lin86d9f512015-08-17 18:29:41 -0700239 correct!***",
pingping-lin500727a2015-09-02 19:53:11 -0700240 onfail = "***MultiPointToSinglePoint Intent Num in SDN-IP is \
241 wrong!***" )
pingping-lin86d9f512015-08-17 18:29:41 -0700242
pingping-lin500727a2015-09-02 19:53:11 -0700243 main.step( "Check BGP PointToPointIntent intents installed" )
pingping-lin86d9f512015-08-17 18:29:41 -0700244
245 bgpIntentsActualNum = \
pingping-lin500727a2015-09-02 19:53:11 -0700246 main.QuaggaCliHost3.extractActualBgpIntentNum( getIntentsResult )
pingping-lin86d9f512015-08-17 18:29:41 -0700247 bgpIntentsExpectedNum = 624
pingping-lin500727a2015-09-02 19:53:11 -0700248 main.log.info( "bgpIntentsExpected num is:" )
249 main.log.info( bgpIntentsExpectedNum )
250 main.log.info( "bgpIntentsActual num is:" )
251 main.log.info( bgpIntentsActualNum )
252 utilities.assertEquals( \
253 expect = True,
254 actual = eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
255 onpass = "***PointToPointIntent Intent Num in SDN-IP are correct!***",
256 onfail = "***PointToPointIntent Intent Num in SDN-IP are wrong!***" )
pingping-lin86d9f512015-08-17 18:29:41 -0700257
258 #============================= Ping Test ========================
Jon Hall53c5e662016-04-13 16:06:56 -0700259 pingTestScript = "~/OnosSystemTest/TestON/tests/SDNIPfunction/dependencies/CASE4-ping-as2host.sh"
pingping-lin86d9f512015-08-17 18:29:41 -0700260 pingTestResultsFile = \
Jon Hall53c5e662016-04-13 16:06:56 -0700261 "~/OnosSystemTest/TestON/tests/SDNIPfunction/dependencies/log/CASE4-ping-results-before-delete-routes-"\
pingping-lin500727a2015-09-02 19:53:11 -0700262 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
263 pingTestResults = main.QuaggaCliHost.pingTest( \
264 "1.168.30.100", pingTestScript, pingTestResultsFile )
265 main.log.info( pingTestResults )
pingping-lin86d9f512015-08-17 18:29:41 -0700266 # wait to finish the ping test
pingping-lin500727a2015-09-02 19:53:11 -0700267 time.sleep( int( main.params[ 'timers' ][ 'PingTestWithRoutes' ] ) )
pingping-lin86d9f512015-08-17 18:29:41 -0700268
269 #============================= Deleting Routes ==================
pingping-lin500727a2015-09-02 19:53:11 -0700270 main.step( "Check deleting routes installed" )
271 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
272 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
273 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
pingping-lin86d9f512015-08-17 18:29:41 -0700274
pingping-lin500727a2015-09-02 19:53:11 -0700275 for i in range( 101, 201 ):
276 prefixesHostX = main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
277 main.log.info( prefixesHostX )
278 QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
279 QuaggaCliHostX.deleteRoutes( prefixesHostX, 1 )
pingping-lin86d9f512015-08-17 18:29:41 -0700280 # wait Quagga to finish delivery all routes to each other and to sdn-ip,
281 # plus finish un-installing all intents.
pingping-lin500727a2015-09-02 19:53:11 -0700282 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
283 time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
pingping-lin86d9f512015-08-17 18:29:41 -0700284
pingping-lin500727a2015-09-02 19:53:11 -0700285 getRoutesResult = main.ONOScli.routes( jsonFormat = True )
pingping-lin86d9f512015-08-17 18:29:41 -0700286 allRoutesActual = \
pingping-lin500727a2015-09-02 19:53:11 -0700287 main.QuaggaCliHost3.extractActualRoutesMaster( getRoutesResult )
288 main.log.info( "allRoutes_actual = " )
289 main.log.info( allRoutesActual )
pingping-lin86d9f512015-08-17 18:29:41 -0700290
pingping-lin500727a2015-09-02 19:53:11 -0700291 utilities.assertEquals( \
292 expect = "[]", actual = str( allRoutesActual ),
293 onpass = "***Route number in SDN-IP is 0, correct!***",
294 onfail = "***Routes number in SDN-IP is not 0, wrong!***" )
pingping-lin86d9f512015-08-17 18:29:41 -0700295
pingping-lin500727a2015-09-02 19:53:11 -0700296 main.step( "Check intents after deleting routes" )
297 getIntentsResult = main.ONOScli.intents( jsonFormat = True )
pingping-lin86d9f512015-08-17 18:29:41 -0700298 routeIntentsActualNum = \
pingping-lin500727a2015-09-02 19:53:11 -0700299 main.QuaggaCliHost3.extractActualRouteIntentNum(
300 getIntentsResult )
301 main.log.info( "route Intents Actual Num is: " )
302 main.log.info( routeIntentsActualNum )
303 utilities.assertEquals( \
304 expect = 0, actual = routeIntentsActualNum,
305 onpass = "***MultiPointToSinglePoint Intent Num in SDN-IP is 0, \
pingping-lin86d9f512015-08-17 18:29:41 -0700306 correct!***",
pingping-lin500727a2015-09-02 19:53:11 -0700307 onfail = "***MultiPointToSinglePoint Intent Num in SDN-IP is not 0, \
308 wrong!***" )
pingping-lin86d9f512015-08-17 18:29:41 -0700309
Jon Hall53c5e662016-04-13 16:06:56 -0700310 pingTestScript = "~/OnosSystemTest/TestON/tests/SDNIPfunction/dependencies/CASE4-ping-as2host.sh"
pingping-lin86d9f512015-08-17 18:29:41 -0700311 pingTestResultsFile = \
Jon Hall53c5e662016-04-13 16:06:56 -0700312 "~/OnosSystemTest/TestON/tests/SDNIPfunction/dependencies/log/CASE4-ping-results-after-delete-routes-"\
pingping-lin500727a2015-09-02 19:53:11 -0700313 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
314 pingTestResults = main.QuaggaCliHost.pingTest( \
315 "1.168.30.100", pingTestScript, pingTestResultsFile )
316 main.log.info( pingTestResults )
pingping-lin86d9f512015-08-17 18:29:41 -0700317 # wait to finish the ping test
pingping-lin500727a2015-09-02 19:53:11 -0700318 time.sleep( int( main.params[ 'timers' ][ 'PingTestWithoutRoutes' ] ) )