blob: 5c1244eb73745943e1a4586e1595dfdc286c841a [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 """
Devin Lim58046fa2017-07-05 16:55:00 -070022 try:
23 from tests.dependencies.ONOSSetup import ONOSSetup
24 main.testSetUp = ONOSSetup()
25 except ImportError:
26 main.log.error( "ONOSSetup not found. exiting the test" )
27 main.exit()
28 main.testSetUp.envSetupDescription()
29 stepResult = main.FALSE
pingping-lin86d9f512015-08-17 18:29:41 -070030
Devin Lim58046fa2017-07-05 16:55:00 -070031 try:
32 cellName = main.params[ 'ENV' ][ 'cellName' ]
33 ONOS1Ip = main.params['CTRL']['ip1']
34 stepResult = main.testSetUp.envSetup( specificIp=ONOS1Ip )
35 except Exception as e:
36 main.testSetUp.envSetupException( e )
37 main.testSetUp.evnSetupConclusion( stepResult )
pingping-lin86d9f512015-08-17 18:29:41 -070038
Devin Lim58046fa2017-07-05 16:55:00 -070039 case1Result = main.testSetUp.ONOSSetUp( "", newCell=False, cellname=cellName )
pingping-lin86d9f512015-08-17 18:29:41 -070040
41 if case1Result == main.FALSE:
42 main.cleanup()
43 main.exit()
44
pingping-lin500727a2015-09-02 19:53:11 -070045 def CASE4( self, main ):
pingping-lin86d9f512015-08-17 18:29:41 -070046 """
47 Test the SDN-IP functionality
48 allRoutesExpected: all expected routes for all BGP peers
49 routeIntentsExpected: all expected MultiPointToSinglePointIntent \
50 intents
51 bgpIntentsExpected: expected PointToPointIntent intents
52 allRoutesActual: all routes from ONOS LCI
53 routeIntentsActual: actual MultiPointToSinglePointIntent intents from \
54 ONOS CLI
55 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
56 """
57 import json
58 import time
59 from operator import eq
60 from time import localtime, strftime
61
pingping-lin500727a2015-09-02 19:53:11 -070062 main.case( "This case is to testing the functionality of SDN-IP with \
63 single ONOS instance" )
pingping-lin86d9f512015-08-17 18:29:41 -070064 SDNIPJSONFILEPATH = \
Jon Hall53c5e662016-04-13 16:06:56 -070065 "~/ONOS/tools/package/config/sdnip.json"
pingping-lin86d9f512015-08-17 18:29:41 -070066 # all expected routes for all BGP peers
67 allRoutesExpected = []
pingping-lin500727a2015-09-02 19:53:11 -070068 main.step( "Start to generate routes for all BGP peers" )
69 main.log.info( "Generate prefixes for host3" )
70 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
71 main.log.info( prefixesHost3 )
pingping-lin86d9f512015-08-17 18:29:41 -070072 # generate route with next hop
73 for prefix in prefixesHost3:
pingping-lin500727a2015-09-02 19:53:11 -070074 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
pingping-lin86d9f512015-08-17 18:29:41 -070075 routeIntentsExpectedHost3 = \
pingping-lin500727a2015-09-02 19:53:11 -070076 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
pingping-lin86d9f512015-08-17 18:29:41 -070077 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
pingping-lin500727a2015-09-02 19:53:11 -070078 SDNIPJSONFILEPATH )
pingping-lin86d9f512015-08-17 18:29:41 -070079
pingping-lin500727a2015-09-02 19:53:11 -070080 main.log.info( "Generate prefixes for host4" )
81 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
82 main.log.info( prefixesHost4 )
pingping-lin86d9f512015-08-17 18:29:41 -070083 # generate route with next hop
84 for prefix in prefixesHost4:
pingping-lin500727a2015-09-02 19:53:11 -070085 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
pingping-lin86d9f512015-08-17 18:29:41 -070086 routeIntentsExpectedHost4 = \
pingping-lin500727a2015-09-02 19:53:11 -070087 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
pingping-lin86d9f512015-08-17 18:29:41 -070088 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
pingping-lin500727a2015-09-02 19:53:11 -070089 SDNIPJSONFILEPATH )
pingping-lin86d9f512015-08-17 18:29:41 -070090
pingping-lin500727a2015-09-02 19:53:11 -070091 main.log.info( "Generate prefixes for host5" )
92 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
93 main.log.info( prefixesHost5 )
pingping-lin86d9f512015-08-17 18:29:41 -070094 for prefix in prefixesHost5:
pingping-lin500727a2015-09-02 19:53:11 -070095 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
pingping-lin86d9f512015-08-17 18:29:41 -070096 routeIntentsExpectedHost5 = \
pingping-lin500727a2015-09-02 19:53:11 -070097 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
pingping-lin86d9f512015-08-17 18:29:41 -070098 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
pingping-lin500727a2015-09-02 19:53:11 -070099 SDNIPJSONFILEPATH )
pingping-lin86d9f512015-08-17 18:29:41 -0700100
101 routeIntentsExpected = routeIntentsExpectedHost3 + \
102 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
103
pingping-lin500727a2015-09-02 19:53:11 -0700104 main.step( "Get links in the network" )
Devin Lim58046fa2017-07-05 16:55:00 -0700105 listResult = main.ONOScli1.links( jsonFormat = False )
pingping-lin500727a2015-09-02 19:53:11 -0700106 main.log.info( listResult )
107 main.log.info( "Activate sdn-ip application" )
Devin Lim58046fa2017-07-05 16:55:00 -0700108 main.ONOScli1.activateApp( "org.onosproject.sdnip" )
pingping-lin86d9f512015-08-17 18:29:41 -0700109 # wait sdn-ip to finish installing connectivity intents, and the BGP
110 # paths in data plane are ready.
pingping-lin500727a2015-09-02 19:53:11 -0700111 time.sleep( int( main.params[ 'timers' ][ 'SdnIpSetup' ] ) )
pingping-lin86d9f512015-08-17 18:29:41 -0700112
pingping-lin500727a2015-09-02 19:53:11 -0700113 main.step( "Login all BGP peers and add routes into peers" )
pingping-lin86d9f512015-08-17 18:29:41 -0700114
pingping-lin500727a2015-09-02 19:53:11 -0700115 main.log.info( "Login Quagga CLI on host3" )
116 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
117 main.log.info( "Enter configuration model of Quagga CLI on host3" )
118 main.QuaggaCliHost3.enterConfig( 64514 )
119 main.log.info( "Add routes to Quagga on host3" )
120 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
pingping-lin86d9f512015-08-17 18:29:41 -0700121
pingping-lin500727a2015-09-02 19:53:11 -0700122 main.log.info( "Login Quagga CLI on host4" )
123 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
124 main.log.info( "Enter configuration model of Quagga CLI on host4" )
125 main.QuaggaCliHost4.enterConfig( 64516 )
126 main.log.info( "Add routes to Quagga on host4" )
127 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
pingping-lin86d9f512015-08-17 18:29:41 -0700128
pingping-lin500727a2015-09-02 19:53:11 -0700129 main.log.info( "Login Quagga CLI on host5" )
130 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
131 main.log.info( "Enter configuration model of Quagga CLI on host5" )
132 main.QuaggaCliHost5.enterConfig( 64521 )
133 main.log.info( "Add routes to Quagga on host5" )
134 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
pingping-lin86d9f512015-08-17 18:29:41 -0700135
pingping-lin500727a2015-09-02 19:53:11 -0700136 for i in range( 101, 201 ):
137 prefixesHostX = main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
138 main.log.info( prefixesHostX )
pingping-lin86d9f512015-08-17 18:29:41 -0700139 for prefix in prefixesHostX:
pingping-lin500727a2015-09-02 19:53:11 -0700140 allRoutesExpected.append( prefix + "/" + "192.168.40."
141 + str( i - 100 ) )
pingping-lin86d9f512015-08-17 18:29:41 -0700142
143 routeIntentsExpectedHostX = \
pingping-lin500727a2015-09-02 19:53:11 -0700144 main.QuaggaCliHost.generateExpectedOnePeerRouteIntents(
145 prefixesHostX, "192.168.40." + str( i - 100 ),
146 "00:00:%02d:00:00:90" % ( i - 101 ), SDNIPJSONFILEPATH )
pingping-lin86d9f512015-08-17 18:29:41 -0700147 routeIntentsExpected = routeIntentsExpected + \
148 routeIntentsExpectedHostX
149
pingping-lin500727a2015-09-02 19:53:11 -0700150 main.log.info( "Login Quagga CLI on host" + str( i ) )
151 QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
152 QuaggaCliHostX.loginQuagga( "1.168.30." + str( i ) )
153 main.log.info( \
154 "Enter configuration model of Quagga CLI on host" + str( i ) )
155 QuaggaCliHostX.enterConfig( 65000 + i - 100 )
156 main.log.info( "Add routes to Quagga on host" + str( i ) )
157 QuaggaCliHostX.addRoutes( prefixesHostX, 1 )
pingping-lin86d9f512015-08-17 18:29:41 -0700158 # wait Quagga to finish delivery all routes to each other and to sdn-ip,
159 # plus finish installing all intents.
pingping-lin500727a2015-09-02 19:53:11 -0700160 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
161 time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
pingping-lin86d9f512015-08-17 18:29:41 -0700162 # get routes inside SDN-IP
Devin Lim58046fa2017-07-05 16:55:00 -0700163 getRoutesResult = main.ONOScli1.routes( jsonFormat = True )
pingping-lin86d9f512015-08-17 18:29:41 -0700164
165 allRoutesActual = \
pingping-lin500727a2015-09-02 19:53:11 -0700166 main.QuaggaCliHost3.extractActualRoutesMaster( getRoutesResult )
pingping-lin86d9f512015-08-17 18:29:41 -0700167
pingping-lin500727a2015-09-02 19:53:11 -0700168 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
169 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
170 main.step( "Check routes installed" )
171 main.log.info( "Routes expected:" )
172 main.log.info( allRoutesStrExpected )
173 main.log.info( "Routes get from ONOS CLI:" )
174 main.log.info( allRoutesStrActual )
175 utilities.assertEquals( \
176 expect = allRoutesStrExpected, actual = allRoutesStrActual,
177 onpass = "***Routes in SDN-IP are correct!***",
178 onfail = "***Routes in SDN-IP are wrong!***" )
pingping-lin86d9f512015-08-17 18:29:41 -0700179
Devin Lim58046fa2017-07-05 16:55:00 -0700180 getIntentsResult = main.ONOScli1.intents( jsonFormat = True )
pingping-lin86d9f512015-08-17 18:29:41 -0700181
pingping-lin500727a2015-09-02 19:53:11 -0700182 main.step( "Check MultiPointToSinglePointIntent intents installed" )
pingping-lin86d9f512015-08-17 18:29:41 -0700183 # routeIntentsExpected are generated when generating routes
184 # get route intents from ONOS CLI
185 routeIntentsActualNum = \
pingping-lin500727a2015-09-02 19:53:11 -0700186 main.QuaggaCliHost3.extractActualRouteIntentNum( getIntentsResult )
pingping-lin86d9f512015-08-17 18:29:41 -0700187 routeIntentsExpectedNum = 1030
pingping-lin500727a2015-09-02 19:53:11 -0700188 main.log.info( "MultiPointToSinglePoint Intent Num expected is:" )
189 main.log.info( routeIntentsExpectedNum )
190 main.log.info( "MultiPointToSinglePoint Intent NUM Actual is:" )
191 main.log.info( routeIntentsActualNum )
192 utilities.assertEquals( \
193 expect = True,
194 actual = eq( routeIntentsExpectedNum, routeIntentsActualNum ),
195 onpass = "***MultiPointToSinglePoint Intent Num in SDN-IP is \
pingping-lin86d9f512015-08-17 18:29:41 -0700196 correct!***",
pingping-lin500727a2015-09-02 19:53:11 -0700197 onfail = "***MultiPointToSinglePoint Intent Num in SDN-IP is \
198 wrong!***" )
pingping-lin86d9f512015-08-17 18:29:41 -0700199
pingping-lin500727a2015-09-02 19:53:11 -0700200 main.step( "Check BGP PointToPointIntent intents installed" )
pingping-lin86d9f512015-08-17 18:29:41 -0700201
202 bgpIntentsActualNum = \
pingping-lin500727a2015-09-02 19:53:11 -0700203 main.QuaggaCliHost3.extractActualBgpIntentNum( getIntentsResult )
pingping-lin86d9f512015-08-17 18:29:41 -0700204 bgpIntentsExpectedNum = 624
pingping-lin500727a2015-09-02 19:53:11 -0700205 main.log.info( "bgpIntentsExpected num is:" )
206 main.log.info( bgpIntentsExpectedNum )
207 main.log.info( "bgpIntentsActual num is:" )
208 main.log.info( bgpIntentsActualNum )
209 utilities.assertEquals( \
210 expect = True,
211 actual = eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
212 onpass = "***PointToPointIntent Intent Num in SDN-IP are correct!***",
213 onfail = "***PointToPointIntent Intent Num in SDN-IP are wrong!***" )
pingping-lin86d9f512015-08-17 18:29:41 -0700214
215 #============================= Ping Test ========================
Jon Hall53c5e662016-04-13 16:06:56 -0700216 pingTestScript = "~/OnosSystemTest/TestON/tests/SDNIPfunction/dependencies/CASE4-ping-as2host.sh"
pingping-lin86d9f512015-08-17 18:29:41 -0700217 pingTestResultsFile = \
Jon Hall53c5e662016-04-13 16:06:56 -0700218 "~/OnosSystemTest/TestON/tests/SDNIPfunction/dependencies/log/CASE4-ping-results-before-delete-routes-"\
pingping-lin500727a2015-09-02 19:53:11 -0700219 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
220 pingTestResults = main.QuaggaCliHost.pingTest( \
221 "1.168.30.100", pingTestScript, pingTestResultsFile )
222 main.log.info( pingTestResults )
pingping-lin86d9f512015-08-17 18:29:41 -0700223 # wait to finish the ping test
pingping-lin500727a2015-09-02 19:53:11 -0700224 time.sleep( int( main.params[ 'timers' ][ 'PingTestWithRoutes' ] ) )
pingping-lin86d9f512015-08-17 18:29:41 -0700225
226 #============================= Deleting Routes ==================
pingping-lin500727a2015-09-02 19:53:11 -0700227 main.step( "Check deleting routes installed" )
228 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
229 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
230 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
pingping-lin86d9f512015-08-17 18:29:41 -0700231
pingping-lin500727a2015-09-02 19:53:11 -0700232 for i in range( 101, 201 ):
233 prefixesHostX = main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
234 main.log.info( prefixesHostX )
235 QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
236 QuaggaCliHostX.deleteRoutes( prefixesHostX, 1 )
pingping-lin86d9f512015-08-17 18:29:41 -0700237 # wait Quagga to finish delivery all routes to each other and to sdn-ip,
238 # plus finish un-installing all intents.
pingping-lin500727a2015-09-02 19:53:11 -0700239 time.sleep( int( main.params[ 'timers' ][ 'RouteDelivery' ] ) )
240 time.sleep( int( main.params[ 'timers' ][ 'PathAvailable' ] ) )
pingping-lin86d9f512015-08-17 18:29:41 -0700241
Devin Lim58046fa2017-07-05 16:55:00 -0700242 getRoutesResult = main.ONOScli1.routes( jsonFormat = True )
pingping-lin86d9f512015-08-17 18:29:41 -0700243 allRoutesActual = \
pingping-lin500727a2015-09-02 19:53:11 -0700244 main.QuaggaCliHost3.extractActualRoutesMaster( getRoutesResult )
245 main.log.info( "allRoutes_actual = " )
246 main.log.info( allRoutesActual )
pingping-lin86d9f512015-08-17 18:29:41 -0700247
pingping-lin500727a2015-09-02 19:53:11 -0700248 utilities.assertEquals( \
249 expect = "[]", actual = str( allRoutesActual ),
250 onpass = "***Route number in SDN-IP is 0, correct!***",
251 onfail = "***Routes number in SDN-IP is not 0, wrong!***" )
pingping-lin86d9f512015-08-17 18:29:41 -0700252
pingping-lin500727a2015-09-02 19:53:11 -0700253 main.step( "Check intents after deleting routes" )
Devin Lim58046fa2017-07-05 16:55:00 -0700254 getIntentsResult = main.ONOScli1.intents( jsonFormat = True )
pingping-lin86d9f512015-08-17 18:29:41 -0700255 routeIntentsActualNum = \
pingping-lin500727a2015-09-02 19:53:11 -0700256 main.QuaggaCliHost3.extractActualRouteIntentNum(
257 getIntentsResult )
258 main.log.info( "route Intents Actual Num is: " )
259 main.log.info( routeIntentsActualNum )
260 utilities.assertEquals( \
261 expect = 0, actual = routeIntentsActualNum,
262 onpass = "***MultiPointToSinglePoint Intent Num in SDN-IP is 0, \
pingping-lin86d9f512015-08-17 18:29:41 -0700263 correct!***",
pingping-lin500727a2015-09-02 19:53:11 -0700264 onfail = "***MultiPointToSinglePoint Intent Num in SDN-IP is not 0, \
265 wrong!***" )
pingping-lin86d9f512015-08-17 18:29:41 -0700266
Jon Hall53c5e662016-04-13 16:06:56 -0700267 pingTestScript = "~/OnosSystemTest/TestON/tests/SDNIPfunction/dependencies/CASE4-ping-as2host.sh"
pingping-lin86d9f512015-08-17 18:29:41 -0700268 pingTestResultsFile = \
Jon Hall53c5e662016-04-13 16:06:56 -0700269 "~/OnosSystemTest/TestON/tests/SDNIPfunction/dependencies/log/CASE4-ping-results-after-delete-routes-"\
pingping-lin500727a2015-09-02 19:53:11 -0700270 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
271 pingTestResults = main.QuaggaCliHost.pingTest( \
272 "1.168.30.100", pingTestScript, pingTestResultsFile )
273 main.log.info( pingTestResults )
pingping-lin86d9f512015-08-17 18:29:41 -0700274 # wait to finish the ping test
pingping-lin500727a2015-09-02 19:53:11 -0700275 time.sleep( int( main.params[ 'timers' ][ 'PingTestWithoutRoutes' ] ) )