blob: 43bf580a941e6d3567db291002e44f886f8714b2 [file] [log] [blame]
pingping-lin8b306ac2014-11-17 18:13:51 -08001
pingping-lin26521182015-01-30 14:52:39 -08002# Testing the functionality of SDN-IP with single ONOS instance
pingping-lin8b306ac2014-11-17 18:13:51 -08003class SdnIpTest:
kelvin-onlab8a832582015-01-16 17:06:11 -08004
5 def __init__( self ):
pingping-lin8b306ac2014-11-17 18:13:51 -08006 self.default = ''
pingping-lin529dad22015-02-02 16:57:35 -08007 global branchName
pingping-lin7048cb02015-01-30 15:09:46 -08008
pingping-lin26521182015-01-30 14:52:39 -08009 # This case is to setup ONOS
pingping-lina600d9b2015-01-30 13:57:26 -080010 def CASE100( self, main ):
pingping-lina600d9b2015-01-30 13:57:26 -080011 """
12 CASE100 is to compile ONOS and push it to the test machines
13 Startup sequence:
14 git pull
15 mvn clean install
16 onos-package
17 cell <name>
18 onos-verify-cell
19 onos-install -f
20 onos-wait-for-start
21 """
pingping-linc8fcd0c2015-05-20 15:22:46 -070022 import time
pingping-lina600d9b2015-01-30 13:57:26 -080023 main.case( "Setting up test environment" )
pingping-lin8b306ac2014-11-17 18:13:51 -080024
pingping-lina600d9b2015-01-30 13:57:26 -080025 cellName = main.params[ 'ENV' ][ 'cellName' ]
26 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
pingping-linc1c696e2015-01-27 13:46:44 -080027
pingping-lina600d9b2015-01-30 13:57:26 -080028 main.step( "Applying cell variable to environment" )
29 cellResult = main.ONOSbench.setCell( cellName )
30 verifyResult = main.ONOSbench.verifyCell()
pingping-lin26521182015-01-30 14:52:39 -080031
pingping-lin529dad22015-02-02 16:57:35 -080032 branchName = main.ONOSbench.getBranchName()
33 main.log.info( "ONOS is on branch: " + branchName )
34
pingping-lina600d9b2015-01-30 13:57:26 -080035 main.log.report( "Uninstalling ONOS" )
36 main.ONOSbench.onosUninstall( ONOS1Ip )
pingping-linc1c696e2015-01-27 13:46:44 -080037
pingping-lina600d9b2015-01-30 13:57:26 -080038 cleanInstallResult = main.TRUE
39 gitPullResult = main.TRUE
pingping-lin26521182015-01-30 14:52:39 -080040
pingping-lina600d9b2015-01-30 13:57:26 -080041 main.step( "Git pull" )
pingping-lina600d9b2015-01-30 13:57:26 -080042 gitPullResult = main.ONOSbench.gitPull()
pingping-lin26521182015-01-30 14:52:39 -080043
pingping-lina600d9b2015-01-30 13:57:26 -080044 main.step( "Using mvn clean & install" )
45 cleanInstallResult = main.TRUE
pingping-lin529dad22015-02-02 16:57:35 -080046# if gitPullResult == main.TRUE:
47# cleanInstallResult = main.ONOSbench.cleanInstall()
48# else:
49# main.log.warn( "Did not pull new code so skipping mvn " +
50# "clean install" )
pingping-lin57a56ce2015-05-20 16:43:48 -070051 cleanInstallResult = main.ONOSbench.cleanInstall( mciTimeout= 1000 )
pingping-lina600d9b2015-01-30 13:57:26 -080052 main.ONOSbench.getVersion( report=True )
pingping-lin7048cb02015-01-30 15:09:46 -080053
pingping-lina600d9b2015-01-30 13:57:26 -080054 main.step( "Creating ONOS package" )
pingping-lin57a56ce2015-05-20 16:43:48 -070055 packageResult = main.ONOSbench.onosPackage( opTimeout=500 )
pingping-lin7048cb02015-01-30 15:09:46 -080056
pingping-lina600d9b2015-01-30 13:57:26 -080057 main.step( "Installing ONOS package" )
58 onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
59 node=ONOS1Ip )
pingping-lin7048cb02015-01-30 15:09:46 -080060
pingping-lina600d9b2015-01-30 13:57:26 -080061 main.step( "Checking if ONOS is up yet" )
62 for i in range( 2 ):
pingping-lina0ac6922015-05-20 17:54:43 -070063 onos1Isup = main.ONOSbench.isup( ONOS1Ip, timeout=420 )
pingping-lina600d9b2015-01-30 13:57:26 -080064 if onos1Isup:
65 break
66 if not onos1Isup:
67 main.log.report( "ONOS1 didn't start!" )
pingping-lin7048cb02015-01-30 15:09:46 -080068
pingping-lin57a56ce2015-05-20 16:43:48 -070069 cliResult = main.ONOScli.startOnosCli( ONOS1Ip,
70 commandlineTimeout=100, onosStartTimeout=600)
pingping-lin7048cb02015-01-30 15:09:46 -080071
pingping-lina600d9b2015-01-30 13:57:26 -080072 case1Result = ( cleanInstallResult and packageResult and
73 cellResult and verifyResult and
74 onos1InstallResult and
75 onos1Isup and cliResult )
pingping-lin7048cb02015-01-30 15:09:46 -080076
pingping-lina600d9b2015-01-30 13:57:26 -080077 utilities.assert_equals( expect=main.TRUE, actual=case1Result,
pingping-lin26521182015-01-30 14:52:39 -080078 onpass="ONOS startup successful",
79 onfail="ONOS startup NOT successful" )
pingping-lin7048cb02015-01-30 15:09:46 -080080
pingping-lina600d9b2015-01-30 13:57:26 -080081 if case1Result == main.FALSE:
82 main.cleanup()
83 main.exit()
pingping-linc1c696e2015-01-27 13:46:44 -080084
85 def CASE4( self, main ):
kelvin-onlab8a832582015-01-16 17:06:11 -080086 """
pingping-lin8b306ac2014-11-17 18:13:51 -080087 Test the SDN-IP functionality
pingping-linc1c696e2015-01-27 13:46:44 -080088 allRoutesExpected: all expected routes for all BGP peers
pingping-lin00e4f7f2015-01-27 16:30:06 -080089 routeIntentsExpected: all expected MultiPointToSinglePointIntent \
90 intents
pingping-linc1c696e2015-01-27 13:46:44 -080091 bgpIntentsExpected: expected PointToPointIntent intents
92 allRoutesActual: all routes from ONOS LCI
pingping-lin79011132015-01-27 15:27:27 -080093 routeIntentsActual: actual MultiPointToSinglePointIntent intents from \
94 ONOS CLI
pingping-linc1c696e2015-01-27 13:46:44 -080095 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
kelvin-onlab8a832582015-01-16 17:06:11 -080096 """
pingping-lin8b306ac2014-11-17 18:13:51 -080097 import time
98 import json
99 from operator import eq
pingping-lin01355a62014-12-02 20:58:14 -0800100 from time import localtime, strftime
pingping-linc6b86fa2014-12-01 16:18:10 -0800101
pingping-lin26521182015-01-30 14:52:39 -0800102 main.case("This case is to testing the functionality of SDN-IP with \
103 single ONOS instance" )
pingping-lin79011132015-01-27 15:27:27 -0800104 SDNIPJSONFILEPATH = \
pingping-lina600d9b2015-01-30 13:57:26 -0800105 "/home/admin/ONOS/tools/package/config/sdnip.json"
pingping-lin6f6332e2014-11-19 19:13:58 -0800106 # all expected routes for all BGP peers
pingping-linc1c696e2015-01-27 13:46:44 -0800107 allRoutesExpected = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800108 main.step( "Start to generate routes for all BGP peers" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800109 main.log.info( "Generate prefixes for host3" )
pingping-linc1c696e2015-01-27 13:46:44 -0800110 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
111 main.log.info( prefixesHost3 )
pingping-lin36fbe802014-11-25 16:01:14 -0800112 # generate route with next hop
pingping-linc1c696e2015-01-27 13:46:44 -0800113 for prefix in prefixesHost3:
114 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
pingping-lin79011132015-01-27 15:27:27 -0800115 routeIntentsExpectedHost3 = \
116 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
117 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
118 SDNIPJSONFILEPATH )
pingping-lin6f6332e2014-11-19 19:13:58 -0800119
kelvin-onlab8a832582015-01-16 17:06:11 -0800120 main.log.info( "Generate prefixes for host4" )
pingping-linc1c696e2015-01-27 13:46:44 -0800121 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
122 main.log.info( prefixesHost4 )
pingping-lin36fbe802014-11-25 16:01:14 -0800123 # generate route with next hop
pingping-linc1c696e2015-01-27 13:46:44 -0800124 for prefix in prefixesHost4:
125 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
pingping-lin79011132015-01-27 15:27:27 -0800126 routeIntentsExpectedHost4 = \
127 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
128 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
129 SDNIPJSONFILEPATH )
pingping-lin6f6332e2014-11-19 19:13:58 -0800130
pingping-linc1c696e2015-01-27 13:46:44 -0800131 main.log.info( "Generate prefixes for host5" )
132 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
133 main.log.info( prefixesHost5 )
134 for prefix in prefixesHost5:
135 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
pingping-lin79011132015-01-27 15:27:27 -0800136 routeIntentsExpectedHost5 = \
137 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
138 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
139 SDNIPJSONFILEPATH )
pingping-lin8b306ac2014-11-17 18:13:51 -0800140
pingping-linc1c696e2015-01-27 13:46:44 -0800141 routeIntentsExpected = routeIntentsExpectedHost3 + \
142 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
pingping-lin7048cb02015-01-30 15:09:46 -0800143
kelvin-onlab8a832582015-01-16 17:06:11 -0800144 main.step( "Get devices in the network" )
pingping-linc1c696e2015-01-27 13:46:44 -0800145 listResult = main.ONOScli.devices( jsonFormat=False )
146 main.log.info( listResult )
kelvin-onlab8a832582015-01-16 17:06:11 -0800147 time.sleep( 10 )
pingping-linf30cf272015-05-29 15:54:07 -0700148 main.log.info( "Activate sdn-ip application" )
149 main.ONOScli.activateApp( "org.onosproject.sdnip" )
150 time.sleep( 10 )
151 main.step( "Login all BGP peers and add routes into peers" )
152
153 main.log.info( "Login Quagga CLI on host3" )
154 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
155 main.log.info( "Enter configuration model of Quagga CLI on host3" )
156 main.QuaggaCliHost3.enterConfig( 64514 )
157 main.log.info( "Add routes to Quagga on host3" )
158 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
159
160 main.log.info( "Login Quagga CLI on host4" )
161 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
162 main.log.info( "Enter configuration model of Quagga CLI on host4" )
163 main.QuaggaCliHost4.enterConfig( 64516 )
164 main.log.info( "Add routes to Quagga on host4" )
165 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
166
167 main.log.info( "Login Quagga CLI on host5" )
168 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
169 main.log.info( "Enter configuration model of Quagga CLI on host5" )
170 main.QuaggaCliHost5.enterConfig( 64521 )
171 main.log.info( "Add routes to Quagga on host5" )
172 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
173
174 for i in range( 101, 201 ):
175 prefixesHostX = main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
176 main.log.info( prefixesHostX )
177 for prefix in prefixesHostX:
178 allRoutesExpected.append( prefix + "/" + "192.168.40."
179 + str( i - 100 ) )
180
181 routeIntentsExpectedHostX = \
182 main.QuaggaCliHost.generateExpectedOnePeerRouteIntents(
183 prefixesHostX, "192.168.40." + str( i - 100 ),
184 "00:00:%02d:00:00:90" % ( i - 101 ), SDNIPJSONFILEPATH )
185 routeIntentsExpected = routeIntentsExpected + \
186 routeIntentsExpectedHostX
187
188 main.log.info( "Login Quagga CLI on host" + str( i ) )
189 QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
190 QuaggaCliHostX.loginQuagga( "1.168.30." + str( i ) )
191 main.log.info(
192 "Enter configuration model of Quagga CLI on host" + str( i ) )
193 QuaggaCliHostX.enterConfig( 65000 + i - 100 )
194 main.log.info( "Add routes to Quagga on host" + str( i ) )
195 QuaggaCliHostX.addRoutes( prefixesHostX, 1 )
196
197 time.sleep( 60 )
198 # get routes inside SDN-IP
199 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
200
201 allRoutesActual = \
202 main.QuaggaCliHost3.extractActualRoutesMaster( getRoutesResult )
203
204 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
205 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
206 main.step( "Check routes installed" )
207 main.log.info( "Routes expected:" )
208 main.log.info( allRoutesStrExpected )
209 main.log.info( "Routes get from ONOS CLI:" )
210 main.log.info( allRoutesStrActual )
211 utilities.assertEquals(
212 expect=allRoutesStrExpected, actual=allRoutesStrActual,
213 onpass="***Routes in SDN-IP are correct!***",
214 onfail="***Routes in SDN-IP are wrong!***" )
215 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
216 main.log.report(
217 "***Routes in SDN-IP after adding routes are correct!***" )
218 else:
219 main.log.report(
220 "***Routes in SDN-IP after adding routes are wrong!***" )
221
222 time.sleep( 20 )
223 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
224
225 main.step( "Check MultiPointToSinglePointIntent intents installed" )
226 # routeIntentsExpected are generated when generating routes
227 # get route intents from ONOS CLI
228 routeIntentsActualNum = \
229 main.QuaggaCliHost3.extractActualRouteIntentNum( getIntentsResult )
230 routeIntentsExpectedNum = 1030
231 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 \
239 correct!***",
240 onfail="***MultiPointToSinglePoint Intent Num in SDN-IP is \
241 wrong!***" )
242
243 if( eq( routeIntentsExpectedNum, routeIntentsActualNum ) ):
244 main.log.report( "***MultiPointToSinglePoint Intents before \
245 deleting routes correct!***" )
246 else:
247 main.log.report( "***MultiPointToSinglePoint Intents before \
248 deleting routes wrong!***" )
249
250 main.step( "Check BGP PointToPointIntent intents installed" )
251
252 bgpIntentsActualNum = \
253 main.QuaggaCliHost3.extractActualBgpIntentNum( getIntentsResult )
254 bgpIntentsExpectedNum = 624
255 main.log.info( "bgpIntentsExpected num is:" )
256 main.log.info( bgpIntentsExpectedNum )
257 main.log.info( "bgpIntentsActual num is:" )
258 main.log.info( bgpIntentsActualNum)
259 utilities.assertEquals(
260 expect=True,
261 actual=eq( bgpIntentsExpectedNum, bgpIntentsActualNum ),
262 onpass="***PointToPointIntent Intent Num in SDN-IP are correct!***",
263 onfail="***PointToPointIntent Intent Num in SDN-IP are wrong!***" )
264 if ( eq( bgpIntentsExpectedNum, bgpIntentsActualNum ) ):
265 main.log.report(
266 "***PointToPointIntent Intents in SDN-IP are correct!***" )
267 else:
268 main.log.report(
269 "***PointToPointIntent Intents in SDN-IP are wrong!***" )
270
271 #============================= Ping Test ========================
272 # Wait until all MultiPointToSinglePoint intents are in system
273 time.sleep( 20 )
274 pingTestScript = "~/SDNIP/test-tools/CASE4-ping-as2host.sh"
275 pingTestResultsFile = \
276 "~/SDNIP/SdnIpIntentDemo/log/CASE4-ping-results-before-delete-routes-"\
277 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
278 pingTestResults = main.QuaggaCliHost.pingTest(
279 "1.168.30.100", pingTestScript, pingTestResultsFile )
280 main.log.info( pingTestResults )
281 time.sleep( 20 )
282
283 #============================= Deleting Routes ==================
284 main.step( "Check deleting routes installed" )
285 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
286 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
287 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
288
289 for i in range( 101, 201 ):
290 prefixesHostX = main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
291 main.log.info( prefixesHostX )
292 QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
293 QuaggaCliHostX.deleteRoutes( prefixesHostX, 1 )
294
295 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
296 allRoutesActual = \
297 main.QuaggaCliHost3.extractActualRoutesMaster( getRoutesResult )
298 main.log.info( "allRoutes_actual = " )
299 main.log.info( allRoutesActual )
300
301 utilities.assertEquals(
302 expect="[]", actual=str( allRoutesActual ),
303 onpass="***Route number in SDN-IP is 0, correct!***",
304 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
305
306 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
307 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
308 else:
309 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
310
311 main.step( "Check intents after deleting routes" )
312 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
313 routeIntentsActualNum = \
314 main.QuaggaCliHost3.extractActualRouteIntentNum(
315 getIntentsResult )
316 main.log.info( "route Intents Actual Num is: " )
317 main.log.info( routeIntentsActualNum )
318 utilities.assertEquals(
319 expect=0, actual=routeIntentsActualNum,
320 onpass="***MultiPointToSinglePoint Intent Num in SDN-IP is 0, \
321 correct!***",
322 onfail="***MultiPointToSinglePoint Intent Num in SDN-IP is not 0, \
323 wrong!***" )
324
325 if( eq( 0, routeIntentsActualNum ) ):
326 main.log.report( "***MultiPointToSinglePoint Intents after \
327 deleting routes correct!***" )
328 else:
329 main.log.report( "***MultiPointToSinglePoint Intents after \
330 deleting routes wrong!***" )
331
332 time.sleep( 20 )
333 pingTestScript = "~/SDNIP/test-tools/CASE4-ping-as2host.sh"
334 pingTestResultsFile = \
335 "~/SDNIP/SdnIpIntentDemo/log/CASE4-ping-results-after-delete-routes-"\
336 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
337 pingTestResults = main.QuaggaCliHost.pingTest(
338 "1.168.30.100", pingTestScript, pingTestResultsFile )
339 main.log.info( pingTestResults )
340 time.sleep( 100 )
341
342 def CASE_4_origin( self, main ):
343 """
344 Test the SDN-IP functionality
345 allRoutesExpected: all expected routes for all BGP peers
346 routeIntentsExpected: all expected MultiPointToSinglePointIntent \
347 intents
348 bgpIntentsExpected: expected PointToPointIntent intents
349 allRoutesActual: all routes from ONOS LCI
350 routeIntentsActual: actual MultiPointToSinglePointIntent intents from \
351 ONOS CLI
352 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
353 """
354 import time
355 import json
356 from operator import eq
357 from time import localtime, strftime
358
359 main.case("This case is to testing the functionality of SDN-IP with \
360 single ONOS instance" )
361 SDNIPJSONFILEPATH = \
362 "/home/admin/ONOS/tools/package/config/sdnip.json"
363 # all expected routes for all BGP peers
364 allRoutesExpected = []
365 main.step( "Start to generate routes for all BGP peers" )
366 main.log.info( "Generate prefixes for host3" )
367 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
368 main.log.info( prefixesHost3 )
369 # generate route with next hop
370 for prefix in prefixesHost3:
371 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
372 routeIntentsExpectedHost3 = \
373 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
374 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
375 SDNIPJSONFILEPATH )
376
377 main.log.info( "Generate prefixes for host4" )
378 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
379 main.log.info( prefixesHost4 )
380 # generate route with next hop
381 for prefix in prefixesHost4:
382 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
383 routeIntentsExpectedHost4 = \
384 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
385 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
386 SDNIPJSONFILEPATH )
387
388 main.log.info( "Generate prefixes for host5" )
389 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
390 main.log.info( prefixesHost5 )
391 for prefix in prefixesHost5:
392 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
393 routeIntentsExpectedHost5 = \
394 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
395 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
396 SDNIPJSONFILEPATH )
397
398 routeIntentsExpected = routeIntentsExpectedHost3 + \
399 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
400
401 main.step( "Get devices in the network" )
402 listResult = main.ONOScli.devices( jsonFormat=False )
403 main.log.info( listResult )
404 time.sleep( 10 )
405 if branchName == "onos-1.1":
406 main.log.info( "Installing sdn-ip feature" )
407 main.ONOScli.featureInstall( "onos-app-sdnip" )
408 else:
409 main.log.info( "Activate sdn-ip application" )
410 main.ONOScli.activateApp( "org.onosproject.sdnip" )
411 #main.log.info( "Installing sdn-ip feature" )
412 #main.ONOScli.featureInstall( "onos-app-sdnip" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800413 time.sleep( 10 )
414 main.step( "Login all BGP peers and add routes into peers" )
pingping-linc1c696e2015-01-27 13:46:44 -0800415
kelvin-onlab8a832582015-01-16 17:06:11 -0800416 main.log.info( "Login Quagga CLI on host3" )
417 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
418 main.log.info( "Enter configuration model of Quagga CLI on host3" )
pingping-linc1c696e2015-01-27 13:46:44 -0800419 main.QuaggaCliHost3.enterConfig( 64514 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800420 main.log.info( "Add routes to Quagga on host3" )
pingping-linc1c696e2015-01-27 13:46:44 -0800421 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
pingping-linbc230942014-12-03 18:36:27 -0800422
kelvin-onlab8a832582015-01-16 17:06:11 -0800423 main.log.info( "Login Quagga CLI on host4" )
424 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
425 main.log.info( "Enter configuration model of Quagga CLI on host4" )
pingping-linc1c696e2015-01-27 13:46:44 -0800426 main.QuaggaCliHost4.enterConfig( 64516 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800427 main.log.info( "Add routes to Quagga on host4" )
pingping-linc1c696e2015-01-27 13:46:44 -0800428 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
429
430 main.log.info( "Login Quagga CLI on host5" )
431 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
432 main.log.info( "Enter configuration model of Quagga CLI on host5" )
433 main.QuaggaCliHost5.enterConfig( 64521 )
434 main.log.info( "Add routes to Quagga on host5" )
435 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
436
437 for i in range( 101, 201 ):
438 prefixesHostX = main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
439 main.log.info( prefixesHostX )
440 for prefix in prefixesHostX:
pingping-lin7048cb02015-01-30 15:09:46 -0800441 allRoutesExpected.append( prefix + "/" + "192.168.40."
442 + str( i - 100 ) )
pingping-linc1c696e2015-01-27 13:46:44 -0800443
pingping-lin79011132015-01-27 15:27:27 -0800444 routeIntentsExpectedHostX = \
445 main.QuaggaCliHost.generateExpectedOnePeerRouteIntents(
446 prefixesHostX, "192.168.40." + str( i - 100 ),
447 "00:00:%02d:00:00:90" % ( i - 101 ), SDNIPJSONFILEPATH )
pingping-linc1c696e2015-01-27 13:46:44 -0800448 routeIntentsExpected = routeIntentsExpected + \
449 routeIntentsExpectedHostX
450
451 main.log.info( "Login Quagga CLI on host" + str( i ) )
452 QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
453 QuaggaCliHostX.loginQuagga( "1.168.30." + str( i ) )
454 main.log.info(
455 "Enter configuration model of Quagga CLI on host" + str( i ) )
456 QuaggaCliHostX.enterConfig( 65000 + i - 100 )
457 main.log.info( "Add routes to Quagga on host" + str( i ) )
458 QuaggaCliHostX.addRoutes( prefixesHostX, 1 )
459
kelvin-onlab8a832582015-01-16 17:06:11 -0800460 time.sleep( 60 )
pingping-linc1c696e2015-01-27 13:46:44 -0800461 # get routes inside SDN-IP
462 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
pingping-linc6b86fa2014-12-01 16:18:10 -0800463
pingping-lin8b306ac2014-11-17 18:13:51 -0800464 # parse routes from ONOS CLI
pingping-linc8fcd0c2015-05-20 15:22:46 -0700465 #if branchName == "master":
466 # allRoutesActual = \
467 # main.QuaggaCliHost3.extractActualRoutesMaster( getRoutesResult )
468 #elif branchName == "onos-1.0":
469 # allRoutesActual = \
470 # main.QuaggaCliHost3.extractActualRoutesOneDotZero( getRoutesResult )
471 #else:
472 # main.log("ONOS is on wrong branch")
473 # exit
474
475 allRoutesActual = \
pingping-lin529dad22015-02-02 16:57:35 -0800476 main.QuaggaCliHost3.extractActualRoutesMaster( getRoutesResult )
pingping-lin7048cb02015-01-30 15:09:46 -0800477
pingping-linc1c696e2015-01-27 13:46:44 -0800478 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
479 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800480 main.step( "Check routes installed" )
481 main.log.info( "Routes expected:" )
pingping-linc1c696e2015-01-27 13:46:44 -0800482 main.log.info( allRoutesStrExpected )
kelvin-onlab8a832582015-01-16 17:06:11 -0800483 main.log.info( "Routes get from ONOS CLI:" )
pingping-linc1c696e2015-01-27 13:46:44 -0800484 main.log.info( allRoutesStrActual )
485 utilities.assertEquals(
486 expect=allRoutesStrExpected, actual=allRoutesStrActual,
pingping-lin79011132015-01-27 15:27:27 -0800487 onpass="***Routes in SDN-IP are correct!***",
488 onfail="***Routes in SDN-IP are wrong!***" )
pingping-linc1c696e2015-01-27 13:46:44 -0800489 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800490 main.log.report(
491 "***Routes in SDN-IP after adding routes are correct!***" )
pingping-lin3d87a132014-12-04 14:22:49 -0800492 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800493 main.log.report(
494 "***Routes in SDN-IP after adding routes are wrong!***" )
pingping-lin8b306ac2014-11-17 18:13:51 -0800495
kelvin-onlab8a832582015-01-16 17:06:11 -0800496 time.sleep( 20 )
pingping-linc1c696e2015-01-27 13:46:44 -0800497 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
pingping-lin6f6332e2014-11-19 19:13:58 -0800498
kelvin-onlab8a832582015-01-16 17:06:11 -0800499 main.step( "Check MultiPointToSinglePointIntent intents installed" )
pingping-linc1c696e2015-01-27 13:46:44 -0800500 # routeIntentsExpected are generated when generating routes
pingping-lin26521182015-01-30 14:52:39 -0800501 # get route intents from ONOS CLI
pingping-lin79011132015-01-27 15:27:27 -0800502 routeIntentsActual = \
pingping-lin00e4f7f2015-01-27 16:30:06 -0800503 main.QuaggaCliHost3.extractActualRouteIntents(
504 getIntentsResult )
pingping-linc1c696e2015-01-27 13:46:44 -0800505 routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
506 routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800507 main.log.info( "MultiPointToSinglePoint intents expected:" )
pingping-linc1c696e2015-01-27 13:46:44 -0800508 main.log.info( routeIntentsStrExpected )
kelvin-onlab8a832582015-01-16 17:06:11 -0800509 main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" )
pingping-linc1c696e2015-01-27 13:46:44 -0800510 main.log.info( routeIntentsStrActual )
511 utilities.assertEquals(
pingping-lin79011132015-01-27 15:27:27 -0800512 expect=True,
513 actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
514 onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
515 correct!***",
516 onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
517 wrong!***" )
pingping-lin6f6332e2014-11-19 19:13:58 -0800518
pingping-linc1c696e2015-01-27 13:46:44 -0800519 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
pingping-lin79011132015-01-27 15:27:27 -0800520 main.log.report( "***MultiPointToSinglePoint Intents before \
521 deleting routes correct!***" )
pingping-lin3d87a132014-12-04 14:22:49 -0800522 else:
pingping-lin79011132015-01-27 15:27:27 -0800523 main.log.report( "***MultiPointToSinglePoint Intents before \
524 deleting routes wrong!***" )
pingping-lin6f6332e2014-11-19 19:13:58 -0800525
kelvin-onlab8a832582015-01-16 17:06:11 -0800526 main.step( "Check BGP PointToPointIntent intents installed" )
pingping-lin6f6332e2014-11-19 19:13:58 -0800527 # bgp intents expected
pingping-lin79011132015-01-27 15:27:27 -0800528 bgpIntentsExpected = \
529 main.QuaggaCliHost3.generateExpectedBgpIntents( SDNIPJSONFILEPATH )
pingping-lin6f6332e2014-11-19 19:13:58 -0800530 # get BGP intents from ONOS CLI
pingping-lin79011132015-01-27 15:27:27 -0800531 bgpIntentsActual = \
532 main.QuaggaCliHost3.extractActualBgpIntents( getIntentsResult )
pingping-lin3228e132014-11-20 17:49:02 -0800533
pingping-linc1c696e2015-01-27 13:46:44 -0800534 bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
535 bgpIntentsStrActual = str( bgpIntentsActual )
kelvin-onlab8a832582015-01-16 17:06:11 -0800536 main.log.info( "PointToPointIntent intents expected:" )
pingping-linc1c696e2015-01-27 13:46:44 -0800537 main.log.info( bgpIntentsStrExpected )
kelvin-onlab8a832582015-01-16 17:06:11 -0800538 main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
pingping-linc1c696e2015-01-27 13:46:44 -0800539 main.log.info( bgpIntentsStrActual )
pingping-lin3228e132014-11-20 17:49:02 -0800540
pingping-linc1c696e2015-01-27 13:46:44 -0800541 utilities.assertEquals(
pingping-lin79011132015-01-27 15:27:27 -0800542 expect=True,
543 actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
544 onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
545 onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
pingping-lin8b306ac2014-11-17 18:13:51 -0800546
pingping-linc1c696e2015-01-27 13:46:44 -0800547 if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800548 main.log.report(
549 "***PointToPointIntent Intents in SDN-IP are correct!***" )
pingping-lin3d87a132014-12-04 14:22:49 -0800550 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800551 main.log.report(
552 "***PointToPointIntent Intents in SDN-IP are wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -0800553
pingping-linc6b86fa2014-12-01 16:18:10 -0800554 #============================= Ping Test ========================
pingping-lin26521182015-01-30 14:52:39 -0800555 # Wait until all MultiPointToSinglePoint intents are in system
kelvin-onlab8a832582015-01-16 17:06:11 -0800556 time.sleep( 20 )
pingping-linc1c696e2015-01-27 13:46:44 -0800557 pingTestScript = "~/SDNIP/test-tools/CASE4-ping-as2host.sh"
pingping-lin79011132015-01-27 15:27:27 -0800558 pingTestResultsFile = \
559 "~/SDNIP/SdnIpIntentDemo/log/CASE4-ping-results-before-delete-routes-" \
560 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
pingping-linc1c696e2015-01-27 13:46:44 -0800561 pingTestResults = main.QuaggaCliHost.pingTest(
pingping-lin79011132015-01-27 15:27:27 -0800562 "1.168.30.100", pingTestScript, pingTestResultsFile )
pingping-linc1c696e2015-01-27 13:46:44 -0800563 main.log.info( pingTestResults )
564 time.sleep( 20 )
pingping-linc6b86fa2014-12-01 16:18:10 -0800565
566 #============================= Deleting Routes ==================
kelvin-onlab8a832582015-01-16 17:06:11 -0800567 main.step( "Check deleting routes installed" )
pingping-linc1c696e2015-01-27 13:46:44 -0800568 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
569 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
570 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
pingping-linc6b86fa2014-12-01 16:18:10 -0800571
pingping-linc1c696e2015-01-27 13:46:44 -0800572 for i in range( 101, 201 ):
573 prefixesHostX = main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
574 main.log.info( prefixesHostX )
575 QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
576 QuaggaCliHostX.deleteRoutes( prefixesHostX, 1 )
577
578 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
pingping-lin79011132015-01-27 15:27:27 -0800579 allRoutesActual = \
580 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
kelvin-onlab8a832582015-01-16 17:06:11 -0800581 main.log.info( "allRoutes_actual = " )
pingping-linc1c696e2015-01-27 13:46:44 -0800582 main.log.info( allRoutesActual )
pingping-linc6b86fa2014-12-01 16:18:10 -0800583
pingping-lin79011132015-01-27 15:27:27 -0800584 utilities.assertEquals(
585 expect="[]", actual=str( allRoutesActual ),
586 onpass="***Route number in SDN-IP is 0, correct!***",
587 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800588
pingping-linc1c696e2015-01-27 13:46:44 -0800589 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800590 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
pingping-lin3d87a132014-12-04 14:22:49 -0800591 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800592 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -0800593
kelvin-onlab8a832582015-01-16 17:06:11 -0800594 main.step( "Check intents after deleting routes" )
pingping-linc1c696e2015-01-27 13:46:44 -0800595 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
pingping-lin79011132015-01-27 15:27:27 -0800596 routeIntentsActual = \
pingping-lin00e4f7f2015-01-27 16:30:06 -0800597 main.QuaggaCliHost3.extractActualRouteIntents(
598 getIntentsResult )
kelvin-onlab8a832582015-01-16 17:06:11 -0800599 main.log.info( "main.ONOScli.intents()= " )
pingping-linc1c696e2015-01-27 13:46:44 -0800600 main.log.info( routeIntentsActual )
pingping-lin79011132015-01-27 15:27:27 -0800601 utilities.assertEquals(
602 expect="[]", actual=str( routeIntentsActual ),
603 onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, \
604 correct!***",
605 onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, \
606 wrong!***" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800607
pingping-linc1c696e2015-01-27 13:46:44 -0800608 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
pingping-lin79011132015-01-27 15:27:27 -0800609 main.log.report( "***MultiPointToSinglePoint Intents after \
610 deleting routes correct!***" )
pingping-lin3d87a132014-12-04 14:22:49 -0800611 else:
pingping-lin79011132015-01-27 15:27:27 -0800612 main.log.report( "***MultiPointToSinglePoint Intents after \
613 deleting routes wrong!***" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800614
kelvin-onlab8a832582015-01-16 17:06:11 -0800615 time.sleep( 20 )
pingping-linc1c696e2015-01-27 13:46:44 -0800616 pingTestScript = "~/SDNIP/test-tools/CASE4-ping-as2host.sh"
pingping-lin79011132015-01-27 15:27:27 -0800617 pingTestResultsFile = \
pingping-lin26521182015-01-30 14:52:39 -0800618 "~/SDNIP/SdnIpIntentDemo/log/CASE4-ping-results-after-delete-routes-"\
pingping-lin79011132015-01-27 15:27:27 -0800619 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
pingping-linc1c696e2015-01-27 13:46:44 -0800620 pingTestResults = main.QuaggaCliHost.pingTest(
pingping-lin79011132015-01-27 15:27:27 -0800621 "1.168.30.100", pingTestScript, pingTestResultsFile )
pingping-linc1c696e2015-01-27 13:46:44 -0800622 main.log.info( pingTestResults )
623 time.sleep( 100 )
624
pingping-linc1c696e2015-01-27 13:46:44 -0800625 def CASE3( self, main ):
626 """
627 Test the SDN-IP functionality
628 allRoutesExpected: all expected routes for all BGP peers
pingping-lin26521182015-01-30 14:52:39 -0800629 routeIntentsExpected: all expected MultiPointToSinglePointIntent \
630 intents
pingping-linc1c696e2015-01-27 13:46:44 -0800631 bgpIntentsExpected: expected PointToPointIntent intents
632 allRoutesActual: all routes from ONOS LCI
pingping-lin79011132015-01-27 15:27:27 -0800633 routeIntentsActual: actual MultiPointToSinglePointIntent intents from \
634 ONOS CLI
pingping-linc1c696e2015-01-27 13:46:44 -0800635 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
636 """
637 import time
638 import json
639 from operator import eq
640 # from datetime import datetime
641 from time import localtime, strftime
642
pingping-lin00e4f7f2015-01-27 16:30:06 -0800643 main.case( "The test case is to help to setup the TestON \
644 environment and test new drivers" )
pingping-linc1c696e2015-01-27 13:46:44 -0800645 # SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
pingping-lin79011132015-01-27 15:27:27 -0800646 SDNIPJSONFILEPATH = \
pingping-lina600d9b2015-01-30 13:57:26 -0800647 "/home/admin/ONOS/tools/package/config/sdnip.json"
pingping-linc1c696e2015-01-27 13:46:44 -0800648 # all expected routes for all BGP peers
649 allRoutesExpected = []
650 main.step( "Start to generate routes for all BGP peers" )
651 main.log.info( "Generate prefixes for host3" )
652 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
653 main.log.info( prefixesHost3 )
654 # generate route with next hop
655 for prefix in prefixesHost3:
656 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
pingping-lin79011132015-01-27 15:27:27 -0800657 routeIntentsExpectedHost3 = \
658 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
659 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
660 SDNIPJSONFILEPATH )
pingping-linc1c696e2015-01-27 13:46:44 -0800661
662 main.log.info( "Generate prefixes for host4" )
663 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
664 main.log.info( prefixesHost4 )
665 # generate route with next hop
666 for prefix in prefixesHost4:
667 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
pingping-lin79011132015-01-27 15:27:27 -0800668 routeIntentsExpectedHost4 = \
669 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
670 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
671 SDNIPJSONFILEPATH )
pingping-linc1c696e2015-01-27 13:46:44 -0800672
673 routeIntentsExpected = routeIntentsExpectedHost3 + \
674 routeIntentsExpectedHost4
675
pingping-linc1c696e2015-01-27 13:46:44 -0800676 cellName = main.params[ 'ENV' ][ 'cellName' ]
677 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
678 main.step( "Set cell for ONOS-cli environment" )
679 main.ONOScli.setCell( cellName )
680 verifyResult = main.ONOSbench.verifyCell()
681
682 main.log.report( "Removing raft logs" )
683 main.ONOSbench.onosRemoveRaftLogs()
684 main.log.report( "Uninstalling ONOS" )
685 main.ONOSbench.onosUninstall( ONOS1Ip )
686
687 main.step( "Installing ONOS package" )
688 onos1InstallResult = main.ONOSbench.onosInstall(
689 options="-f", node=ONOS1Ip )
690
691 main.step( "Checking if ONOS is up yet" )
692 time.sleep( 60 )
693 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
694 if not onos1Isup:
695 main.log.report( "ONOS1 didn't start!" )
696
697 main.step( "Start ONOS-cli" )
698
699 main.ONOScli.startOnosCli( ONOS1Ip )
700
701 main.step( "Get devices in the network" )
702 listResult = main.ONOScli.devices( jsonFormat=False )
703 main.log.info( listResult )
704 time.sleep( 10 )
pingping-linf30cf272015-05-29 15:54:07 -0700705 if branchName == "onos-1.1":
706 main.log.info( "Installing sdn-ip feature" )
707 main.ONOScli.featureInstall( "onos-app-sdnip" )
708 else:
709 main.log.info( "Activate sdn-ip application" )
710 main.ONOScli.activateApp( "org.onosproject.sdnip" )
pingping-linc1c696e2015-01-27 13:46:44 -0800711 time.sleep( 10 )
712 main.step( "Login all BGP peers and add routes into peers" )
713
714 main.log.info( "Login Quagga CLI on host3" )
715 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
716 main.log.info( "Enter configuration model of Quagga CLI on host3" )
717 main.QuaggaCliHost3.enterConfig( 64514 )
718 main.log.info( "Add routes to Quagga on host3" )
719 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
720
721 main.log.info( "Login Quagga CLI on host4" )
722 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
723 main.log.info( "Enter configuration model of Quagga CLI on host4" )
724 main.QuaggaCliHost4.enterConfig( 64516 )
725 main.log.info( "Add routes to Quagga on host4" )
726 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
727
728 for i in range( 101, 201 ):
pingping-lin00e4f7f2015-01-27 16:30:06 -0800729 prefixesHostX = \
730 main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
pingping-linc1c696e2015-01-27 13:46:44 -0800731 main.log.info( prefixesHostX )
732 for prefix in prefixesHostX:
733 allRoutesExpected.append(
734 prefix + "/" + "192.168.40." + str( i - 100 ) )
735
pingping-lin79011132015-01-27 15:27:27 -0800736 routeIntentsExpectedHostX = \
737 main.QuaggaCliHost.generateExpectedOnePeerRouteIntents(
738 prefixesHostX, "192.168.40." + str( i - 100 ),
739 "00:00:%02d:00:00:90" % ( i - 101 ), SDNIPJSONFILEPATH )
pingping-linc1c696e2015-01-27 13:46:44 -0800740 routeIntentsExpected = routeIntentsExpected + \
741 routeIntentsExpectedHostX
742
743 main.log.info( "Login Quagga CLI on host" + str( i ) )
744 QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
745 QuaggaCliHostX.loginQuagga( "1.168.30." + str( i ) )
746 main.log.info(
747 "Enter configuration model of Quagga CLI on host" + str( i ) )
748 QuaggaCliHostX.enterConfig( 65000 + i - 100 )
749 main.log.info( "Add routes to Quagga on host" + str( i ) )
750 QuaggaCliHostX.addRoutes( prefixesHostX, 1 )
751
752 time.sleep( 60 )
753
754 # get routes inside SDN-IP
755 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
756
757 # parse routes from ONOS CLI
pingping-lin79011132015-01-27 15:27:27 -0800758 allRoutesActual = \
759 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
pingping-linc1c696e2015-01-27 13:46:44 -0800760
761 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
762 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
763 main.step( "Check routes installed" )
764 main.log.info( "Routes expected:" )
765 main.log.info( allRoutesStrExpected )
766 main.log.info( "Routes get from ONOS CLI:" )
767 main.log.info( allRoutesStrActual )
768 utilities.assertEquals(
769 expect=allRoutesStrExpected, actual=allRoutesStrActual,
pingping-lin79011132015-01-27 15:27:27 -0800770 onpass="***Routes in SDN-IP are correct!***",
771 onfail="***Routes in SDN-IP are wrong!***" )
pingping-linc1c696e2015-01-27 13:46:44 -0800772 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
773 main.log.report(
774 "***Routes in SDN-IP after adding routes are correct!***" )
775 else:
776 main.log.report(
777 "***Routes in SDN-IP after adding routes are wrong!***" )
778
779 time.sleep( 20 )
780 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
781
782 main.step( "Check MultiPointToSinglePointIntent intents installed" )
783 # routeIntentsExpected are generated when generating routes
784 # get rpoute intents from ONOS CLI
pingping-lin79011132015-01-27 15:27:27 -0800785 routeIntentsActual = \
pingping-lin00e4f7f2015-01-27 16:30:06 -0800786 main.QuaggaCliHost3.extractActualRouteIntents(
787 getIntentsResult )
pingping-linc1c696e2015-01-27 13:46:44 -0800788 routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
789 routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" )
790 main.log.info( "MultiPointToSinglePoint intents expected:" )
791 main.log.info( routeIntentsStrExpected )
792 main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" )
793 main.log.info( routeIntentsStrActual )
794 utilities.assertEquals(
pingping-lin79011132015-01-27 15:27:27 -0800795 expect=True,
796 actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
797 onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
798 correct!***",
799 onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
800 wrong!***" )
pingping-linc1c696e2015-01-27 13:46:44 -0800801
802 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
803 main.log.report(
pingping-lin79011132015-01-27 15:27:27 -0800804 "***MultiPointToSinglePoint Intents before deleting routes \
805 correct!***" )
pingping-linc1c696e2015-01-27 13:46:44 -0800806 else:
807 main.log.report(
pingping-lin79011132015-01-27 15:27:27 -0800808 "***MultiPointToSinglePoint Intents before deleting routes \
809 wrong!***" )
pingping-linc1c696e2015-01-27 13:46:44 -0800810
811 main.step( "Check BGP PointToPointIntent intents installed" )
812 # bgp intents expected
813 bgpIntentsExpected = main.QuaggaCliHost3.generateExpectedBgpIntents(
814 SDNIPJSONFILEPATH )
815 # get BGP intents from ONOS CLI
816 bgpIntentsActual = main.QuaggaCliHost3.extractActualBgpIntents(
817 getIntentsResult )
818
819 bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
820 bgpIntentsStrActual = str( bgpIntentsActual )
821 main.log.info( "PointToPointIntent intents expected:" )
822 main.log.info( bgpIntentsStrExpected )
823 main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
824 main.log.info( bgpIntentsStrActual )
825
826 utilities.assertEquals(
pingping-lin79011132015-01-27 15:27:27 -0800827 expect=True,
828 actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
829 onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
830 onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
pingping-linc1c696e2015-01-27 13:46:44 -0800831
832 if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
833 main.log.report(
834 "***PointToPointIntent Intents in SDN-IP are correct!***" )
835 else:
836 main.log.report(
837 "***PointToPointIntent Intents in SDN-IP are wrong!***" )
838
839 #============================= Ping Test ========================
840 # wait until all MultiPointToSinglePoint
841 time.sleep( 20 )
842 pingTestScript = "~/SDNIP/test-tools/CASE3-ping-as2host.sh"
pingping-lin79011132015-01-27 15:27:27 -0800843 pingTestResultsFile = \
844 "~/SDNIP/SdnIpIntentDemo/log/CASE3-ping-results-before-delete-routes-" \
845 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
pingping-linc1c696e2015-01-27 13:46:44 -0800846 pingTestResults = main.QuaggaCliHost.pingTest(
pingping-lin79011132015-01-27 15:27:27 -0800847 "1.168.30.100", pingTestScript, pingTestResultsFile )
pingping-linc1c696e2015-01-27 13:46:44 -0800848 main.log.info( pingTestResults )
849 time.sleep( 20 )
850
851 #============================= Deleting Routes ==================
852 main.step( "Check deleting routes installed" )
853 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
854 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
855 for i in range( 101, 201 ):
pingping-lin00e4f7f2015-01-27 16:30:06 -0800856 prefixesHostX = \
857 main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
pingping-linc1c696e2015-01-27 13:46:44 -0800858 main.log.info( prefixesHostX )
859 QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
860 QuaggaCliHostX.deleteRoutes( prefixesHostX, 1 )
861
862 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
863 allRoutesActual = main.QuaggaCliHost3.extractActualRoutes(
864 getRoutesResult )
865 main.log.info( "allRoutes_actual = " )
866 main.log.info( allRoutesActual )
867
pingping-lin79011132015-01-27 15:27:27 -0800868 utilities.assertEquals(
869 expect="[]", actual=str( allRoutesActual ),
870 onpass="***Route number in SDN-IP is 0, correct!***",
871 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
pingping-linc1c696e2015-01-27 13:46:44 -0800872
873 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
pingping-lin00e4f7f2015-01-27 16:30:06 -0800874 main.log.report(
875 "***Routes in SDN-IP after deleting correct!***" )
pingping-linc1c696e2015-01-27 13:46:44 -0800876 else:
pingping-lin00e4f7f2015-01-27 16:30:06 -0800877 main.log.report(
878 "***Routes in SDN-IP after deleting wrong!***" )
pingping-linc1c696e2015-01-27 13:46:44 -0800879
880 main.step( "Check intents after deleting routes" )
881 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
pingping-lin79011132015-01-27 15:27:27 -0800882 routeIntentsActual = \
pingping-lin00e4f7f2015-01-27 16:30:06 -0800883 main.QuaggaCliHost3.extractActualRouteIntents(
884 getIntentsResult )
pingping-linc1c696e2015-01-27 13:46:44 -0800885 main.log.info( "main.ONOScli.intents()= " )
886 main.log.info( routeIntentsActual )
pingping-lin79011132015-01-27 15:27:27 -0800887 utilities.assertEquals(
888 expect="[]", actual=str( routeIntentsActual ),
pingping-lin00e4f7f2015-01-27 16:30:06 -0800889 onpass="***MultiPointToSinglePoint Intents number in SDN-IP is \
890 0, correct!***",
891 onfail="***MultiPointToSinglePoint Intents number in SDN-IP is \
892 0, wrong!***" )
pingping-linc1c696e2015-01-27 13:46:44 -0800893
894 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
895 main.log.report(
pingping-lin79011132015-01-27 15:27:27 -0800896 "***MultiPointToSinglePoint Intents after deleting routes \
897 correct!***" )
pingping-linc1c696e2015-01-27 13:46:44 -0800898 else:
899 main.log.report(
pingping-lin79011132015-01-27 15:27:27 -0800900 "***MultiPointToSinglePoint Intents after deleting routes \
901 wrong!***" )
pingping-linc1c696e2015-01-27 13:46:44 -0800902
903 time.sleep( 20 )
904 pingTestScript = "~/SDNIP/test-tools/CASE3-ping-as2host.sh"
pingping-lin79011132015-01-27 15:27:27 -0800905 pingTestResultsFile = \
906 "~/SDNIP/SdnIpIntentDemo/log/CASE3-ping-results-after-delete-routes-" \
907 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
pingping-linc1c696e2015-01-27 13:46:44 -0800908 pingTestResults = main.QuaggaCliHost.pingTest(
pingping-lin79011132015-01-27 15:27:27 -0800909 "1.168.30.100", pingTestScript, pingTestResultsFile )
pingping-linc1c696e2015-01-27 13:46:44 -0800910 main.log.info( pingTestResults )
911 time.sleep( 100 )
912
913 # main.step( "Test whether Mininet is started" )
914 # main.Mininet2.handle.sendline( "xterm host1" )
915 # main.Mininet2.handle.expect( "mininet>" )
916
917 def CASE1( self, main ):
918 """
919 Test the SDN-IP functionality
920 allRoutesExpected: all expected routes for all BGP peers
pingping-lin00e4f7f2015-01-27 16:30:06 -0800921 routeIntentsExpected: all expected MultiPointToSinglePointIntent \
922 intents
pingping-linc1c696e2015-01-27 13:46:44 -0800923 bgpIntentsExpected: expected PointToPointIntent intents
924 allRoutesActual: all routes from ONOS LCI
pingping-lin00e4f7f2015-01-27 16:30:06 -0800925 routeIntentsActual: actual MultiPointToSinglePointIntent intents \
926 from ONOS CLI
pingping-linc1c696e2015-01-27 13:46:44 -0800927 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
928 """
929 import time
930 import json
931 from operator import eq
932 # from datetime import datetime
933 from time import localtime, strftime
934
pingping-lin79011132015-01-27 15:27:27 -0800935 main.case("The test case is to help to setup the TestON environment \
936 and test new drivers" )
pingping-linc1c696e2015-01-27 13:46:44 -0800937 SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
938 # all expected routes for all BGP peers
939 allRoutesExpected = []
940 main.step( "Start to generate routes for all BGP peers" )
941 # bgpPeerHosts = []
942 # for i in range( 3, 5 ):
943 # bgpPeerHosts.append( "host" + str( i ) )
944 # main.log.info( "BGP Peer Hosts are:" + bgpPeerHosts )
945
946 # for i in range( 3, 5 ):
947 # QuaggaCliHost = "QuaggaCliHost" + str( i )
948 # prefixes = main.QuaggaCliHost.generatePrefixes( 3, 10 )
949
950 # main.log.info( prefixes )
951 # allRoutesExpected.append( prefixes )
952 main.log.info( "Generate prefixes for host3" )
953 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
954 main.log.info( prefixesHost3 )
955 # generate route with next hop
956 for prefix in prefixesHost3:
957 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
pingping-lin79011132015-01-27 15:27:27 -0800958 routeIntentsExpectedHost3 = \
959 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
960 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
961 SDNIPJSONFILEPATH )
pingping-linc1c696e2015-01-27 13:46:44 -0800962
963 main.log.info( "Generate prefixes for host4" )
964 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
965 main.log.info( prefixesHost4 )
966 # generate route with next hop
967 for prefix in prefixesHost4:
968 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
pingping-lin79011132015-01-27 15:27:27 -0800969 routeIntentsExpectedHost4 = \
970 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
971 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
972 SDNIPJSONFILEPATH )
pingping-linc1c696e2015-01-27 13:46:44 -0800973
974 routeIntentsExpected = routeIntentsExpectedHost3 + \
975 routeIntentsExpectedHost4
976
977 cellName = main.params[ 'ENV' ][ 'cellName' ]
978 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
979 main.step( "Set cell for ONOS-cli environment" )
980 main.ONOScli.setCell( cellName )
981 verifyResult = main.ONOSbench.verifyCell()
982 main.log.report( "Removing raft logs" )
983 main.ONOSbench.onosRemoveRaftLogs()
984 main.log.report( "Uninstalling ONOS" )
985 main.ONOSbench.onosUninstall( ONOS1Ip )
986 main.step( "Creating ONOS package" )
987 packageResult = main.ONOSbench.onosPackage()
988
989 main.step( "Starting ONOS service" )
990 # TODO: start ONOS from Mininet Script
991 # startResult = main.ONOSbench.onosStart( "127.0.0.1" )
992 main.step( "Installing ONOS package" )
993 onos1InstallResult = main.ONOSbench.onosInstall(
994 options="-f", node=ONOS1Ip )
995
996 main.step( "Checking if ONOS is up yet" )
997 time.sleep( 60 )
998 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
999 if not onos1Isup:
1000 main.log.report( "ONOS1 didn't start!" )
1001
1002 main.step( "Start ONOS-cli" )
1003 # TODO: change the hardcode in startOnosCli method in ONOS CLI driver
1004
1005 main.ONOScli.startOnosCli( ONOS1Ip )
1006
1007 main.step( "Get devices in the network" )
1008 listResult = main.ONOScli.devices( jsonFormat=False )
1009 main.log.info( listResult )
1010 time.sleep( 10 )
1011 main.log.info( "Installing sdn-ip feature" )
1012 main.ONOScli.featureInstall( "onos-app-sdnip" )
1013 time.sleep( 10 )
1014 main.step( "Login all BGP peers and add routes into peers" )
1015 main.log.info( "Login Quagga CLI on host3" )
1016 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
1017 main.log.info( "Enter configuration model of Quagga CLI on host3" )
1018 main.QuaggaCliHost3.enterConfig( 64514 )
1019 main.log.info( "Add routes to Quagga on host3" )
1020 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
1021
1022 main.log.info( "Login Quagga CLI on host4" )
1023 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
1024 main.log.info( "Enter configuration model of Quagga CLI on host4" )
1025 main.QuaggaCliHost4.enterConfig( 64516 )
1026 main.log.info( "Add routes to Quagga on host4" )
1027 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
1028 time.sleep( 60 )
1029
1030 # get all routes inside SDN-IP
1031 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1032
1033 # parse routes from ONOS CLI
pingping-lin79011132015-01-27 15:27:27 -08001034 allRoutesActual = \
1035 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
pingping-linc1c696e2015-01-27 13:46:44 -08001036
1037 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
1038 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
1039 main.step( "Check routes installed" )
1040 main.log.info( "Routes expected:" )
1041 main.log.info( allRoutesStrExpected )
1042 main.log.info( "Routes get from ONOS CLI:" )
1043 main.log.info( allRoutesStrActual )
1044 utilities.assertEquals(
1045 expect=allRoutesStrExpected, actual=allRoutesStrActual,
pingping-lin79011132015-01-27 15:27:27 -08001046 onpass="***Routes in SDN-IP are correct!***",
1047 onfail="***Routes in SDN-IP are wrong!***" )
pingping-linc1c696e2015-01-27 13:46:44 -08001048 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1049 main.log.report(
1050 "***Routes in SDN-IP after adding routes are correct!***" )
1051 else:
1052 main.log.report(
1053 "***Routes in SDN-IP after adding routes are wrong!***" )
1054
1055 time.sleep( 20 )
1056 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
1057
1058 main.step( "Check MultiPointToSinglePointIntent intents installed" )
1059 # routeIntentsExpected are generated when generating routes
1060 # get rpoute intents from ONOS CLI
pingping-lin79011132015-01-27 15:27:27 -08001061 routeIntentsActual = \
pingping-lin00e4f7f2015-01-27 16:30:06 -08001062 main.QuaggaCliHost3.extractActualRouteIntents(
1063 getIntentsResult )
pingping-linc1c696e2015-01-27 13:46:44 -08001064 routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
1065 routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" )
1066 main.log.info( "MultiPointToSinglePoint intents expected:" )
1067 main.log.info( routeIntentsStrExpected )
1068 main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" )
1069 main.log.info( routeIntentsStrActual )
1070 utilities.assertEquals(
pingping-lin79011132015-01-27 15:27:27 -08001071 expect=True,
1072 actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
1073 onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
1074 correct!***",
1075 onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
1076 wrong!***" )
pingping-linc1c696e2015-01-27 13:46:44 -08001077
1078 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
1079 main.log.report(
pingping-lin79011132015-01-27 15:27:27 -08001080 "***MultiPointToSinglePoint Intents before deleting routes \
1081 correct!***" )
pingping-linc1c696e2015-01-27 13:46:44 -08001082 else:
1083 main.log.report(
pingping-lin79011132015-01-27 15:27:27 -08001084 "***MultiPointToSinglePoint Intents before deleting routes \
1085 wrong!***" )
pingping-linc1c696e2015-01-27 13:46:44 -08001086
1087 main.step( "Check BGP PointToPointIntent intents installed" )
1088 # bgp intents expected
pingping-lin79011132015-01-27 15:27:27 -08001089 bgpIntentsExpected = \
1090 main.QuaggaCliHost3.generateExpectedBgpIntents( SDNIPJSONFILEPATH )
pingping-linc1c696e2015-01-27 13:46:44 -08001091 # get BGP intents from ONOS CLI
1092 bgpIntentsActual = main.QuaggaCliHost3.extractActualBgpIntents(
1093 getIntentsResult )
1094
1095 bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
1096 bgpIntentsStrActual = str( bgpIntentsActual )
1097 main.log.info( "PointToPointIntent intents expected:" )
1098 main.log.info( bgpIntentsStrExpected )
1099 main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
1100 main.log.info( bgpIntentsStrActual )
1101
1102 utilities.assertEquals(
pingping-lin79011132015-01-27 15:27:27 -08001103 expect=True,
1104 actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
1105 onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
1106 onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
pingping-linc1c696e2015-01-27 13:46:44 -08001107
1108 if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
1109 main.log.report(
1110 "***PointToPointIntent Intents in SDN-IP are correct!***" )
1111 else:
1112 main.log.report(
1113 "***PointToPointIntent Intents in SDN-IP are wrong!***" )
1114
1115 #============================= Ping Test ========================
1116 # wait until all MultiPointToSinglePoint
1117 time.sleep( 20 )
1118 pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
pingping-lin79011132015-01-27 15:27:27 -08001119 pingTestResultsFile = \
1120 "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-before-delete-routes-" \
1121 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
pingping-linc1c696e2015-01-27 13:46:44 -08001122 pingTestResults = main.QuaggaCliHost.pingTest(
pingping-lin79011132015-01-27 15:27:27 -08001123 "1.168.30.100", pingTestScript, pingTestResultsFile )
pingping-linc1c696e2015-01-27 13:46:44 -08001124 main.log.info( pingTestResults )
1125
1126 # ping test
1127
1128 #============================= Deleting Routes ==================
1129 main.step( "Check deleting routes installed" )
1130 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
1131 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
1132
1133 # main.log.info( "main.ONOScli.get_routes_num() = " )
1134 # main.log.info( main.ONOScli.getRoutesNum() )
1135 # utilities.assertEquals( expect="Total SDN-IP routes = 1", actual=
1136 # main.ONOScli.getRoutesNum(),
1137 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
pingping-lin79011132015-01-27 15:27:27 -08001138 allRoutesActual = \
1139 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
pingping-linc1c696e2015-01-27 13:46:44 -08001140 main.log.info( "allRoutes_actual = " )
1141 main.log.info( allRoutesActual )
1142
pingping-lin79011132015-01-27 15:27:27 -08001143 utilities.assertEquals(
1144 expect="[]", actual=str( allRoutesActual ),
1145 onpass="***Route number in SDN-IP is 0, correct!***",
1146 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
pingping-linc1c696e2015-01-27 13:46:44 -08001147
1148 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
pingping-lin00e4f7f2015-01-27 16:30:06 -08001149 main.log.report(
1150 "***Routes in SDN-IP after deleting correct!***" )
pingping-linc1c696e2015-01-27 13:46:44 -08001151 else:
pingping-lin00e4f7f2015-01-27 16:30:06 -08001152 main.log.report(
1153 "***Routes in SDN-IP after deleting wrong!***" )
pingping-linc1c696e2015-01-27 13:46:44 -08001154
1155 main.step( "Check intents after deleting routes" )
1156 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
pingping-lin79011132015-01-27 15:27:27 -08001157 routeIntentsActual = \
pingping-lin00e4f7f2015-01-27 16:30:06 -08001158 main.QuaggaCliHost3.extractActualRouteIntents(
1159 getIntentsResult )
pingping-linc1c696e2015-01-27 13:46:44 -08001160 main.log.info( "main.ONOScli.intents()= " )
1161 main.log.info( routeIntentsActual )
pingping-lin79011132015-01-27 15:27:27 -08001162 utilities.assertEquals(
1163 expect="[]", actual=str( routeIntentsActual ),
pingping-lin00e4f7f2015-01-27 16:30:06 -08001164 onpass="***MultiPointToSinglePoint Intents number in SDN-IP is \
1165 0, correct!***",
1166 onfail="***MultiPointToSinglePoint Intents number in SDN-IP is \
1167 0, wrong!***" )
pingping-linc1c696e2015-01-27 13:46:44 -08001168
1169 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
1170 main.log.report(
pingping-lin79011132015-01-27 15:27:27 -08001171 "***MultiPointToSinglePoint Intents after deleting routes \
1172 correct!***" )
pingping-linc1c696e2015-01-27 13:46:44 -08001173 else:
1174 main.log.report(
pingping-lin79011132015-01-27 15:27:27 -08001175 "***MultiPointToSinglePoint Intents after deleting routes \
1176 wrong!***" )
pingping-linc1c696e2015-01-27 13:46:44 -08001177
1178 time.sleep( 20 )
1179 pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
pingping-lin79011132015-01-27 15:27:27 -08001180 pingTestResultsFile = \
1181 "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-after-delete-routes-" \
1182 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
pingping-linc1c696e2015-01-27 13:46:44 -08001183 pingTestResults = main.QuaggaCliHost.pingTest(
pingping-lin79011132015-01-27 15:27:27 -08001184 "1.168.30.100", pingTestScript, pingTestResultsFile )
pingping-linc1c696e2015-01-27 13:46:44 -08001185 main.log.info( pingTestResults )
kelvin-onlab8a832582015-01-16 17:06:11 -08001186 time.sleep( 30 )
pingping-linc6b86fa2014-12-01 16:18:10 -08001187
kelvin-onlab8a832582015-01-16 17:06:11 -08001188 # main.step( "Test whether Mininet is started" )
1189 # main.Mininet2.handle.sendline( "xterm host1" )
1190 # main.Mininet2.handle.expect( "mininet>" )
pingping-lin8b306ac2014-11-17 18:13:51 -08001191
kelvin-onlab8a832582015-01-16 17:06:11 -08001192 def CASE2( self, main ):
1193 """
pingping-lin3d87a132014-12-04 14:22:49 -08001194 Test the SDN-IP functionality
pingping-linc1c696e2015-01-27 13:46:44 -08001195 allRoutesExpected: all expected routes for all BGP peers
pingping-lin00e4f7f2015-01-27 16:30:06 -08001196 routeIntentsExpected: all expected MultiPointToSinglePointIntent \
1197 intents
pingping-linc1c696e2015-01-27 13:46:44 -08001198 bgpIntentsExpected: expected PointToPointIntent intents
1199 allRoutesActual: all routes from ONOS LCI
pingping-lin00e4f7f2015-01-27 16:30:06 -08001200 routeIntentsActual: actual MultiPointToSinglePointIntent intents \
1201 from ONOS CLI
pingping-linc1c696e2015-01-27 13:46:44 -08001202 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
kelvin-onlab8a832582015-01-16 17:06:11 -08001203 """
pingping-lin3d87a132014-12-04 14:22:49 -08001204 import time
1205 import json
1206 from operator import eq
1207 from time import localtime, strftime
1208
kelvin-onlab8a832582015-01-16 17:06:11 -08001209 main.case(
pingping-lin00e4f7f2015-01-27 16:30:06 -08001210 "The test case is to help to setup the TestON environment and \
1211 test new drivers" )
pingping-linc1c696e2015-01-27 13:46:44 -08001212 SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
pingping-lin3d87a132014-12-04 14:22:49 -08001213 # all expected routes for all BGP peers
pingping-linc1c696e2015-01-27 13:46:44 -08001214 allRoutesExpected = []
kelvin-onlab8a832582015-01-16 17:06:11 -08001215 main.step( "Start to generate routes for all BGP peers" )
pingping-lin3d87a132014-12-04 14:22:49 -08001216
kelvin-onlab8a832582015-01-16 17:06:11 -08001217 main.log.info( "Generate prefixes for host3" )
pingping-linc1c696e2015-01-27 13:46:44 -08001218 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
1219 main.log.info( prefixesHost3 )
pingping-lin3d87a132014-12-04 14:22:49 -08001220 # generate route with next hop
pingping-linc1c696e2015-01-27 13:46:44 -08001221 for prefix in prefixesHost3:
1222 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
pingping-lin79011132015-01-27 15:27:27 -08001223 routeIntentsExpectedHost3 = \
1224 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
1225 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
1226 SDNIPJSONFILEPATH )
pingping-lin3d87a132014-12-04 14:22:49 -08001227
kelvin-onlab8a832582015-01-16 17:06:11 -08001228 main.log.info( "Generate prefixes for host4" )
pingping-linc1c696e2015-01-27 13:46:44 -08001229 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
1230 main.log.info( prefixesHost4 )
pingping-lin3d87a132014-12-04 14:22:49 -08001231 # generate route with next hop
pingping-linc1c696e2015-01-27 13:46:44 -08001232 for prefix in prefixesHost4:
1233 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
pingping-lin79011132015-01-27 15:27:27 -08001234 routeIntentsExpectedHost4 = \
1235 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
1236 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
1237 SDNIPJSONFILEPATH )
pingping-lin3d87a132014-12-04 14:22:49 -08001238
pingping-linc1c696e2015-01-27 13:46:44 -08001239 routeIntentsExpected = routeIntentsExpectedHost3 + \
1240 routeIntentsExpectedHost4
pingping-lin3d87a132014-12-04 14:22:49 -08001241
kelvin-onlab8a832582015-01-16 17:06:11 -08001242 main.log.report( "Removing raft logs" )
pingping-linc1c696e2015-01-27 13:46:44 -08001243 main.ONOSbench.onosRemoveRaftLogs()
kelvin-onlab8a832582015-01-16 17:06:11 -08001244 main.log.report( "Uninstalling ONOS" )
pingping-linc1c696e2015-01-27 13:46:44 -08001245 main.ONOSbench.onosUninstall( ONOS1Ip )
pingping-lin3d87a132014-12-04 14:22:49 -08001246
pingping-linc1c696e2015-01-27 13:46:44 -08001247 cellName = main.params[ 'ENV' ][ 'cellName' ]
1248 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
kelvin-onlab8a832582015-01-16 17:06:11 -08001249 main.step( "Set cell for ONOS-cli environment" )
pingping-linc1c696e2015-01-27 13:46:44 -08001250 main.ONOScli.setCell( cellName )
1251 verifyResult = main.ONOSbench.verifyCell()
1252 # main.log.report( "Removing raft logs" )
1253 # main.ONOSbench.onosRemoveRaftLogs()
1254 # main.log.report( "Uninstalling ONOS" )
1255 # main.ONOSbench.onosUninstall( ONOS1Ip )
kelvin-onlab8a832582015-01-16 17:06:11 -08001256 main.step( "Creating ONOS package" )
pingping-linc1c696e2015-01-27 13:46:44 -08001257 # packageResult = main.ONOSbench.onosPackage()
pingping-lin3d87a132014-12-04 14:22:49 -08001258
kelvin-onlab8a832582015-01-16 17:06:11 -08001259 main.step( "Installing ONOS package" )
pingping-linc1c696e2015-01-27 13:46:44 -08001260 # onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
1261 # node=ONOS1Ip )
pingping-lin3d87a132014-12-04 14:22:49 -08001262
kelvin-onlab8a832582015-01-16 17:06:11 -08001263 main.step( "Checking if ONOS is up yet" )
pingping-linc1c696e2015-01-27 13:46:44 -08001264 # time.sleep( 60 )
1265 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
1266 if not onos1Isup:
kelvin-onlab8a832582015-01-16 17:06:11 -08001267 main.log.report( "ONOS1 didn't start!" )
pingping-lin3d87a132014-12-04 14:22:49 -08001268
kelvin-onlab8a832582015-01-16 17:06:11 -08001269 main.step( "Start ONOS-cli" )
pingping-linc1c696e2015-01-27 13:46:44 -08001270 main.ONOScli.startOnosCli( ONOS1Ip )
pingping-lin3d87a132014-12-04 14:22:49 -08001271
kelvin-onlab8a832582015-01-16 17:06:11 -08001272 main.step( "Get devices in the network" )
pingping-linc1c696e2015-01-27 13:46:44 -08001273 listResult = main.ONOScli.devices( jsonFormat=False )
1274 main.log.info( listResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001275 time.sleep( 10 )
1276 main.log.info( "Installing sdn-ip feature" )
pingping-linc1c696e2015-01-27 13:46:44 -08001277 main.ONOScli.featureInstall( "onos-app-sdnip" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001278 time.sleep( 10 )
pingping-lin3d87a132014-12-04 14:22:49 -08001279
kelvin-onlab8a832582015-01-16 17:06:11 -08001280 main.step( "Check BGP PointToPointIntent intents installed" )
pingping-lin3d87a132014-12-04 14:22:49 -08001281 # bgp intents expected
pingping-linc1c696e2015-01-27 13:46:44 -08001282 bgpIntentsExpected = main.QuaggaCliHost3.generateExpectedBgpIntents(
1283 SDNIPJSONFILEPATH )
pingping-lin3d87a132014-12-04 14:22:49 -08001284 # get BGP intents from ONOS CLI
pingping-linc1c696e2015-01-27 13:46:44 -08001285 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
1286 bgpIntentsActual = main.QuaggaCliHost3.extractActualBgpIntents(
1287 getIntentsResult )
pingping-lin3d87a132014-12-04 14:22:49 -08001288
pingping-linc1c696e2015-01-27 13:46:44 -08001289 bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
1290 bgpIntentsStrActual = str( bgpIntentsActual )
kelvin-onlab8a832582015-01-16 17:06:11 -08001291 main.log.info( "PointToPointIntent intents expected:" )
pingping-linc1c696e2015-01-27 13:46:44 -08001292 main.log.info( bgpIntentsStrExpected )
kelvin-onlab8a832582015-01-16 17:06:11 -08001293 main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
pingping-linc1c696e2015-01-27 13:46:44 -08001294 main.log.info( bgpIntentsStrActual )
pingping-lin3d87a132014-12-04 14:22:49 -08001295
pingping-linc1c696e2015-01-27 13:46:44 -08001296 utilities.assertEquals(
pingping-lin79011132015-01-27 15:27:27 -08001297 expect=True,
1298 actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
1299 onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
1300 onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001301
pingping-linc1c696e2015-01-27 13:46:44 -08001302 if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -08001303 main.log.report(
1304 "***PointToPointIntent Intents in SDN-IP are correct!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001305 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001306 main.log.report(
1307 "***PointToPointIntent Intents in SDN-IP are wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001308
pingping-linc1c696e2015-01-27 13:46:44 -08001309 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
1310 routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
1311 pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
1312 # roundNum = 0;
kelvin-onlab8a832582015-01-16 17:06:11 -08001313 # while( True ):
pingping-linc1c696e2015-01-27 13:46:44 -08001314 for roundNum in range( 1, 6 ):
pingping-lin3d87a132014-12-04 14:22:49 -08001315 # round = round + 1;
pingping-linc1c696e2015-01-27 13:46:44 -08001316 main.log.report( "The Round " + str( roundNum ) +
pingping-lin00e4f7f2015-01-27 16:30:06 -08001317 " test starts................................" )
pingping-lin3d87a132014-12-04 14:22:49 -08001318
kelvin-onlab8a832582015-01-16 17:06:11 -08001319 main.step( "Login all BGP peers and add routes into peers" )
1320 main.log.info( "Login Quagga CLI on host3" )
1321 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
pingping-lin00e4f7f2015-01-27 16:30:06 -08001322 main.log.info(
1323 "Enter configuration model of Quagga CLI on host3" )
pingping-linc1c696e2015-01-27 13:46:44 -08001324 main.QuaggaCliHost3.enterConfig( 64514 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001325 main.log.info( "Add routes to Quagga on host3" )
pingping-linc1c696e2015-01-27 13:46:44 -08001326 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
pingping-lin3d87a132014-12-04 14:22:49 -08001327
kelvin-onlab8a832582015-01-16 17:06:11 -08001328 main.log.info( "Login Quagga CLI on host4" )
1329 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
pingping-lin00e4f7f2015-01-27 16:30:06 -08001330 main.log.info(
1331 "Enter configuration model of Quagga CLI on host4" )
pingping-linc1c696e2015-01-27 13:46:44 -08001332 main.QuaggaCliHost4.enterConfig( 64516 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001333 main.log.info( "Add routes to Quagga on host4" )
pingping-linc1c696e2015-01-27 13:46:44 -08001334 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001335 time.sleep( 60 )
pingping-lin3d87a132014-12-04 14:22:49 -08001336
1337 # get all routes inside SDN-IP
pingping-linc1c696e2015-01-27 13:46:44 -08001338 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
pingping-lin3d87a132014-12-04 14:22:49 -08001339
1340 # parse routes from ONOS CLI
pingping-lin79011132015-01-27 15:27:27 -08001341 allRoutesActual = \
1342 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
pingping-lin3d87a132014-12-04 14:22:49 -08001343
pingping-linc1c696e2015-01-27 13:46:44 -08001344 # allRoutesStrExpected = str( sorted( allRoutesExpected ) )
1345 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001346 main.step( "Check routes installed" )
1347 main.log.info( "Routes expected:" )
pingping-linc1c696e2015-01-27 13:46:44 -08001348 main.log.info( allRoutesStrExpected )
kelvin-onlab8a832582015-01-16 17:06:11 -08001349 main.log.info( "Routes get from ONOS CLI:" )
pingping-linc1c696e2015-01-27 13:46:44 -08001350 main.log.info( allRoutesStrActual )
1351 utilities.assertEquals(
1352 expect=allRoutesStrExpected, actual=allRoutesStrActual,
pingping-lin79011132015-01-27 15:27:27 -08001353 onpass="***Routes in SDN-IP are correct!***",
1354 onfail="***Routes in SDN-IP are wrong!***" )
pingping-linc1c696e2015-01-27 13:46:44 -08001355 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -08001356 main.log.report(
1357 "***Routes in SDN-IP after adding correct!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001358 else:
pingping-lin00e4f7f2015-01-27 16:30:06 -08001359 main.log.report(
1360 "***Routes in SDN-IP after adding wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001361
kelvin-onlab8a832582015-01-16 17:06:11 -08001362 time.sleep( 20 )
pingping-linc1c696e2015-01-27 13:46:44 -08001363 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
pingping-lin3d87a132014-12-04 14:22:49 -08001364
kelvin-onlab8a832582015-01-16 17:06:11 -08001365 main.step(
1366 "Check MultiPointToSinglePointIntent intents installed" )
pingping-linc1c696e2015-01-27 13:46:44 -08001367 # routeIntentsExpected are generated when generating routes
pingping-lin3d87a132014-12-04 14:22:49 -08001368 # get route intents from ONOS CLI
pingping-lin79011132015-01-27 15:27:27 -08001369 routeIntentsActual = \
pingping-lin00e4f7f2015-01-27 16:30:06 -08001370 main.QuaggaCliHost3.extractActualRouteIntents(
1371 getIntentsResult )
pingping-linc1c696e2015-01-27 13:46:44 -08001372 # routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
1373 routeIntentsStrActual = str(
pingping-lin79011132015-01-27 15:27:27 -08001374 routeIntentsActual ).replace( 'u', "" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001375 main.log.info( "MultiPointToSinglePoint intents expected:" )
pingping-linc1c696e2015-01-27 13:46:44 -08001376 main.log.info( routeIntentsStrExpected )
kelvin-onlab8a832582015-01-16 17:06:11 -08001377 main.log.info(
1378 "MultiPointToSinglePoint intents get from ONOS CLI:" )
pingping-linc1c696e2015-01-27 13:46:44 -08001379 main.log.info( routeIntentsStrActual )
1380 utilities.assertEquals(
pingping-lin79011132015-01-27 15:27:27 -08001381 expect=True,
1382 actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
1383 onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
1384 correct!***",
1385 onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
1386 wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001387
pingping-linc1c696e2015-01-27 13:46:44 -08001388 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -08001389 main.log.report(
pingping-lin79011132015-01-27 15:27:27 -08001390 "***MultiPointToSinglePoint Intents after adding routes \
1391 correct!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001392 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001393 main.log.report(
pingping-lin79011132015-01-27 15:27:27 -08001394 "***MultiPointToSinglePoint Intents after adding routes \
1395 wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001396
1397 #============================= Ping Test ========================
1398 # wait until all MultiPointToSinglePoint
kelvin-onlab8a832582015-01-16 17:06:11 -08001399 time.sleep( 20 )
pingping-linc1c696e2015-01-27 13:46:44 -08001400 # pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
pingping-lin00e4f7f2015-01-27 16:30:06 -08001401 pingTestResultsFile = \
1402 "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" \
pingping-lin79011132015-01-27 15:27:27 -08001403 + str( roundNum ) + "-ping-results-before-delete-routes-" \
1404 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
pingping-linc1c696e2015-01-27 13:46:44 -08001405 pingTestResults = main.QuaggaCliHost.pingTest(
pingping-lin79011132015-01-27 15:27:27 -08001406 "1.168.30.100", pingTestScript, pingTestResultsFile )
pingping-linc1c696e2015-01-27 13:46:44 -08001407 main.log.info( pingTestResults )
pingping-lin3d87a132014-12-04 14:22:49 -08001408 # ping test
1409
1410 #============================= Deleting Routes ==================
kelvin-onlab8a832582015-01-16 17:06:11 -08001411 main.step( "Check deleting routes installed" )
1412 main.log.info( "Delete routes to Quagga on host3" )
pingping-linc1c696e2015-01-27 13:46:44 -08001413 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001414 main.log.info( "Delete routes to Quagga on host4" )
pingping-linc1c696e2015-01-27 13:46:44 -08001415 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
pingping-lin3d87a132014-12-04 14:22:49 -08001416
pingping-linc1c696e2015-01-27 13:46:44 -08001417 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
pingping-lin79011132015-01-27 15:27:27 -08001418 allRoutesActual = \
1419 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001420 main.log.info( "allRoutes_actual = " )
pingping-linc1c696e2015-01-27 13:46:44 -08001421 main.log.info( allRoutesActual )
pingping-lin3d87a132014-12-04 14:22:49 -08001422
pingping-lin79011132015-01-27 15:27:27 -08001423 utilities.assertEquals(
1424 expect="[]", actual=str( allRoutesActual ),
1425 onpass="***Route number in SDN-IP is 0, correct!***",
1426 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001427
pingping-linc1c696e2015-01-27 13:46:44 -08001428 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -08001429 main.log.report(
1430 "***Routes in SDN-IP after deleting correct!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001431 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001432 main.log.report(
1433 "***Routes in SDN-IP after deleting wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001434
kelvin-onlab8a832582015-01-16 17:06:11 -08001435 main.step( "Check intents after deleting routes" )
pingping-linc1c696e2015-01-27 13:46:44 -08001436 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
pingping-lin79011132015-01-27 15:27:27 -08001437 routeIntentsActual = \
pingping-lin00e4f7f2015-01-27 16:30:06 -08001438 main.QuaggaCliHost3.extractActualRouteIntents(
1439 getIntentsResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001440 main.log.info( "main.ONOScli.intents()= " )
pingping-linc1c696e2015-01-27 13:46:44 -08001441 main.log.info( routeIntentsActual )
1442 utilities.assertEquals(
1443 expect="[]", actual=str( routeIntentsActual ),
pingping-lin00e4f7f2015-01-27 16:30:06 -08001444 onpass=
1445 "***MultiPointToSinglePoint Intents number in SDN-IP \
1446 is 0, correct!***",
1447 onfail="***MultiPointToSinglePoint Intents number in SDN-IP \
1448 is 0, wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001449
pingping-linc1c696e2015-01-27 13:46:44 -08001450 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -08001451 main.log.report(
pingping-lin00e4f7f2015-01-27 16:30:06 -08001452 "***MultiPointToSinglePoint Intents after deleting \
1453 routes correct!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001454 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001455 main.log.report(
pingping-lin00e4f7f2015-01-27 16:30:06 -08001456 "***MultiPointToSinglePoint Intents after deleting \
1457 routes wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001458
kelvin-onlab8a832582015-01-16 17:06:11 -08001459 time.sleep( 20 )
pingping-linc1c696e2015-01-27 13:46:44 -08001460 # pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
pingping-lin00e4f7f2015-01-27 16:30:06 -08001461 pingTestResultsFile = \
1462 "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" \
pingping-lin79011132015-01-27 15:27:27 -08001463 + str( roundNum ) + "-ping-results-after-delete-routes-" \
1464 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
pingping-linc1c696e2015-01-27 13:46:44 -08001465 pingTestResults = main.QuaggaCliHost.pingTest(
pingping-lin79011132015-01-27 15:27:27 -08001466 "1.168.30.100", pingTestScript, pingTestResultsFile )
pingping-linc1c696e2015-01-27 13:46:44 -08001467 main.log.info( pingTestResults )
kelvin-onlab8a832582015-01-16 17:06:11 -08001468 time.sleep( 30 )
pingping-linc1c696e2015-01-27 13:46:44 -08001469