blob: 85ac21ea9c27b9b0edd2e6bc7e9cf542edb2708f [file] [log] [blame]
pingping-lin3d87a132014-12-04 14:22:49 -08001# from cupshelpers.config import prefix
pingping-lin8b306ac2014-11-17 18:13:51 -08002
pingping-linc6b86fa2014-12-01 16:18:10 -08003# Testing the basic functionality of SDN-IP
pingping-lin8b306ac2014-11-17 18:13:51 -08004
kelvin-onlab8a832582015-01-16 17:06:11 -08005
pingping-lin8b306ac2014-11-17 18:13:51 -08006class SdnIpTest:
kelvin-onlab8a832582015-01-16 17:06:11 -08007
8 def __init__( self ):
pingping-lin8b306ac2014-11-17 18:13:51 -08009 self.default = ''
10
kelvin-onlab2c4342a2015-01-28 15:59:53 -080011# from cupshelpers.config import prefix
12
13# Testing the basic functionality of SDN-IP
14
15
16class SdnIpTest:
17
18 def __init__( self ):
19 self.default = ''
20
21 def CASE4( self, main ):
kelvin-onlab8a832582015-01-16 17:06:11 -080022 """
pingping-lin8b306ac2014-11-17 18:13:51 -080023 Test the SDN-IP functionality
kelvin-onlab7bbb5612015-01-26 10:54:50 -080024 allRoutesExpected: all expected routes for all BGP peers
kelvin-onlab2c4342a2015-01-28 15:59:53 -080025 routeIntentsExpected: all expected MultiPointToSinglePointIntent \
26 intents
kelvin-onlab7bbb5612015-01-26 10:54:50 -080027 bgpIntentsExpected: expected PointToPointIntent intents
28 allRoutesActual: all routes from ONOS LCI
kelvin-onlab2c4342a2015-01-28 15:59:53 -080029 routeIntentsActual: actual MultiPointToSinglePointIntent intents from \
30 ONOS CLI
kelvin-onlab7bbb5612015-01-26 10:54:50 -080031 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
kelvin-onlab8a832582015-01-16 17:06:11 -080032 """
pingping-lin8b306ac2014-11-17 18:13:51 -080033 import time
34 import json
35 from operator import eq
pingping-linc6b86fa2014-12-01 16:18:10 -080036 # from datetime import datetime
pingping-lin01355a62014-12-02 20:58:14 -080037 from time import localtime, strftime
pingping-linc6b86fa2014-12-01 16:18:10 -080038
kelvin-onlab2c4342a2015-01-28 15:59:53 -080039 main.case("The test case is to help to setup the TestON environment \
40 and test new drivers" )
41 # SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
42 SDNIPJSONFILEPATH = \
43 "/home/admin/workspace/onos/tools/package/config/sdnip.json"
44 # all expected routes for all BGP peers
45 allRoutesExpected = []
46 main.step( "Start to generate routes for all BGP peers" )
47 main.log.info( "Generate prefixes for host3" )
48 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
49 main.log.info( prefixesHost3 )
50 # generate route with next hop
51 for prefix in prefixesHost3:
52 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
53 routeIntentsExpectedHost3 = \
54 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
55 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
56 SDNIPJSONFILEPATH )
57
58 main.log.info( "Generate prefixes for host4" )
59 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
60 main.log.info( prefixesHost4 )
61 # generate route with next hop
62 for prefix in prefixesHost4:
63 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
64 routeIntentsExpectedHost4 = \
65 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
66 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
67 SDNIPJSONFILEPATH )
68
69 main.log.info( "Generate prefixes for host5" )
70 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
71 main.log.info( prefixesHost5 )
72 for prefix in prefixesHost5:
73 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
74 routeIntentsExpectedHost5 = \
75 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
76 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
77 SDNIPJSONFILEPATH )
78
79 routeIntentsExpected = routeIntentsExpectedHost3 + \
80 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
81
82 cellName = main.params[ 'ENV' ][ 'cellName' ]
83 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
84 main.step( "Set cell for ONOS-cli environment" )
85 main.ONOScli.setCell( cellName )
86 verifyResult = main.ONOSbench.verifyCell()
87
88 main.log.report( "Removing raft logs" )
89 main.ONOSbench.onosRemoveRaftLogs()
90 main.log.report( "Uninstalling ONOS" )
91 main.ONOSbench.onosUninstall( ONOS1Ip )
92
93 main.step( "Installing ONOS package" )
94 onos1InstallResult = main.ONOSbench.onosInstall(
95 options="-f", node=ONOS1Ip )
96
97 main.step( "Checking if ONOS is up yet" )
98 time.sleep( 150 )
99 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
100 if not onos1Isup:
101 main.log.report( "ONOS1 didn't start!" )
102
103 main.step( "Start ONOS-cli" )
104
105 main.ONOScli.startOnosCli( ONOS1Ip )
106
107 main.step( "Get devices in the network" )
108 listResult = main.ONOScli.devices( jsonFormat=False )
109 main.log.info( listResult )
110 time.sleep( 10 )
111 main.log.info( "Installing sdn-ip feature" )
112 main.ONOScli.featureInstall( "onos-app-sdnip" )
113 time.sleep( 10 )
114 main.step( "Login all BGP peers and add routes into peers" )
115
116 main.log.info( "Login Quagga CLI on host3" )
117 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
118 main.log.info( "Enter configuration model of Quagga CLI on host3" )
119 main.QuaggaCliHost3.enterConfig( 64514 )
120 main.log.info( "Add routes to Quagga on host3" )
121 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
122
123 main.log.info( "Login Quagga CLI on host4" )
124 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
125 main.log.info( "Enter configuration model of Quagga CLI on host4" )
126 main.QuaggaCliHost4.enterConfig( 64516 )
127 main.log.info( "Add routes to Quagga on host4" )
128 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
129
130 main.log.info( "Login Quagga CLI on host5" )
131 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
132 main.log.info( "Enter configuration model of Quagga CLI on host5" )
133 main.QuaggaCliHost5.enterConfig( 64521 )
134 main.log.info( "Add routes to Quagga on host5" )
135 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
136
137 for i in range( 101, 201 ):
138 prefixesHostX = main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
139 main.log.info( prefixesHostX )
140 for prefix in prefixesHostX:
141 allRoutesExpected.append(
142 prefix + "/" + "192.168.40." + str( i - 100 ) )
143
144 routeIntentsExpectedHostX = \
145 main.QuaggaCliHost.generateExpectedOnePeerRouteIntents(
146 prefixesHostX, "192.168.40." + str( i - 100 ),
147 "00:00:%02d:00:00:90" % ( i - 101 ), SDNIPJSONFILEPATH )
148 routeIntentsExpected = routeIntentsExpected + \
149 routeIntentsExpectedHostX
150
151 main.log.info( "Login Quagga CLI on host" + str( i ) )
152 QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
153 QuaggaCliHostX.loginQuagga( "1.168.30." + str( i ) )
154 main.log.info(
155 "Enter configuration model of Quagga CLI on host" + str( i ) )
156 QuaggaCliHostX.enterConfig( 65000 + i - 100 )
157 main.log.info( "Add routes to Quagga on host" + str( i ) )
158 QuaggaCliHostX.addRoutes( prefixesHostX, 1 )
159
160 time.sleep( 60 )
161
162 # get routes inside SDN-IP
163 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
164
165 # parse routes from ONOS CLI
166 allRoutesActual = \
167 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
168
169 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
170 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
171 main.step( "Check routes installed" )
172 main.log.info( "Routes expected:" )
173 main.log.info( allRoutesStrExpected )
174 main.log.info( "Routes get from ONOS CLI:" )
175 main.log.info( allRoutesStrActual )
176 utilities.assertEquals(
177 expect=allRoutesStrExpected, actual=allRoutesStrActual,
178 onpass="***Routes in SDN-IP are correct!***",
179 onfail="***Routes in SDN-IP are wrong!***" )
180 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
181 main.log.report(
182 "***Routes in SDN-IP after adding routes are correct!***" )
183 else:
184 main.log.report(
185 "***Routes in SDN-IP after adding routes are wrong!***" )
186
187 time.sleep( 20 )
188 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
189
190 main.step( "Check MultiPointToSinglePointIntent intents installed" )
191 # routeIntentsExpected are generated when generating routes
192 # get rpoute intents from ONOS CLI
193 routeIntentsActual = \
194 main.QuaggaCliHost3.extractActualRouteIntents(
195 getIntentsResult )
196 routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
197 routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" )
198 main.log.info( "MultiPointToSinglePoint intents expected:" )
199 main.log.info( routeIntentsStrExpected )
200 main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" )
201 main.log.info( routeIntentsStrActual )
202 utilities.assertEquals(
203 expect=True,
204 actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
205 onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
206 correct!***",
207 onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
208 wrong!***" )
209
210 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
211 main.log.report( "***MultiPointToSinglePoint Intents before \
212 deleting routes correct!***" )
213 else:
214 main.log.report( "***MultiPointToSinglePoint Intents before \
215 deleting routes wrong!***" )
216
217 main.step( "Check BGP PointToPointIntent intents installed" )
218 # bgp intents expected
219 bgpIntentsExpected = \
220 main.QuaggaCliHost3.generateExpectedBgpIntents( SDNIPJSONFILEPATH )
221 # get BGP intents from ONOS CLI
222 bgpIntentsActual = \
223 main.QuaggaCliHost3.extractActualBgpIntents( getIntentsResult )
224
225 bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
226 bgpIntentsStrActual = str( bgpIntentsActual )
227 main.log.info( "PointToPointIntent intents expected:" )
228 main.log.info( bgpIntentsStrExpected )
229 main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
230 main.log.info( bgpIntentsStrActual )
231
232 utilities.assertEquals(
233 expect=True,
234 actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
235 onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
236 onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
237
238 if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
239 main.log.report(
240 "***PointToPointIntent Intents in SDN-IP are correct!***" )
241 else:
242 main.log.report(
243 "***PointToPointIntent Intents in SDN-IP are wrong!***" )
244
245 #============================= Ping Test ========================
246 # wait until all MultiPointToSinglePoint
247 time.sleep( 20 )
248 pingTestScript = "~/SDNIP/test-tools/CASE4-ping-as2host.sh"
249 pingTestResultsFile = \
250 "~/SDNIP/SdnIpIntentDemo/log/CASE4-ping-results-before-delete-routes-" \
251 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
252 pingTestResults = main.QuaggaCliHost.pingTest(
253 "1.168.30.100", pingTestScript, pingTestResultsFile )
254 main.log.info( pingTestResults )
255 time.sleep( 20 )
256
257 #============================= Deleting Routes ==================
258 main.step( "Check deleting routes installed" )
259 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
260 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
261 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
262
263 for i in range( 101, 201 ):
264 prefixesHostX = main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
265 main.log.info( prefixesHostX )
266 QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
267 QuaggaCliHostX.deleteRoutes( prefixesHostX, 1 )
268
269 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
270 allRoutesActual = \
271 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
272 main.log.info( "allRoutes_actual = " )
273 main.log.info( allRoutesActual )
274
275 utilities.assertEquals(
276 expect="[]", actual=str( allRoutesActual ),
277 onpass="***Route number in SDN-IP is 0, correct!***",
278 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
279
280 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
281 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
282 else:
283 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
284
285 main.step( "Check intents after deleting routes" )
286 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
287 routeIntentsActual = \
288 main.QuaggaCliHost3.extractActualRouteIntents(
289 getIntentsResult )
290 main.log.info( "main.ONOScli.intents()= " )
291 main.log.info( routeIntentsActual )
292 utilities.assertEquals(
293 expect="[]", actual=str( routeIntentsActual ),
294 onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, \
295 correct!***",
296 onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, \
297 wrong!***" )
298
299 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
300 main.log.report( "***MultiPointToSinglePoint Intents after \
301 deleting routes correct!***" )
302 else:
303 main.log.report( "***MultiPointToSinglePoint Intents after \
304 deleting routes wrong!***" )
305
306 time.sleep( 20 )
307 pingTestScript = "~/SDNIP/test-tools/CASE4-ping-as2host.sh"
308 pingTestResultsFile = \
309 "~/SDNIP/SdnIpIntentDemo/log/CASE4-ping-results-after-delete-routes-" \
310 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
311 pingTestResults = main.QuaggaCliHost.pingTest(
312 "1.168.30.100", pingTestScript, pingTestResultsFile )
313 main.log.info( pingTestResults )
314 time.sleep( 100 )
315
316 # main.step( "Test whether Mininet is started" )
317 # main.Mininet2.handle.sendline( "xterm host1" )
318 # main.Mininet2.handle.expect( "mininet>" )
319
320 def CASE3( self, main ):
321 """
322 Test the SDN-IP functionality
323 allRoutesExpected: all expected routes for all BGP peers
324 routeIntentsExpected: all expected MultiPointToSinglePointIntent intents
325 bgpIntentsExpected: expected PointToPointIntent intents
326 allRoutesActual: all routes from ONOS LCI
327 routeIntentsActual: actual MultiPointToSinglePointIntent intents from \
328 ONOS CLI
329 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
330 """
331 import time
332 import json
333 from operator import eq
334 # from datetime import datetime
335 from time import localtime, strftime
336
337 main.case( "The test case is to help to setup the TestON \
338 environment and test new drivers" )
339 # SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
340 SDNIPJSONFILEPATH = \
341 "/home/admin/workspace/onos/tools/package/config/sdnip.json"
342 # all expected routes for all BGP peers
343 allRoutesExpected = []
344 main.step( "Start to generate routes for all BGP peers" )
345 main.log.info( "Generate prefixes for host3" )
346 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
347 main.log.info( prefixesHost3 )
348 # generate route with next hop
349 for prefix in prefixesHost3:
350 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
351 routeIntentsExpectedHost3 = \
352 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
353 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
354 SDNIPJSONFILEPATH )
355
356 main.log.info( "Generate prefixes for host4" )
357 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
358 main.log.info( prefixesHost4 )
359 # generate route with next hop
360 for prefix in prefixesHost4:
361 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
362 routeIntentsExpectedHost4 = \
363 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
364 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
365 SDNIPJSONFILEPATH )
366
367 routeIntentsExpected = routeIntentsExpectedHost3 + \
368 routeIntentsExpectedHost4
369
370 cellName = main.params[ 'ENV' ][ 'cellName' ]
371 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
372 main.step( "Set cell for ONOS-cli environment" )
373 main.ONOScli.setCell( cellName )
374 verifyResult = main.ONOSbench.verifyCell()
375
376 main.log.report( "Removing raft logs" )
377 main.ONOSbench.onosRemoveRaftLogs()
378 main.log.report( "Uninstalling ONOS" )
379 main.ONOSbench.onosUninstall( ONOS1Ip )
380
381 main.step( "Installing ONOS package" )
382 onos1InstallResult = main.ONOSbench.onosInstall(
383 options="-f", node=ONOS1Ip )
384
385 main.step( "Checking if ONOS is up yet" )
386 time.sleep( 60 )
387 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
388 if not onos1Isup:
389 main.log.report( "ONOS1 didn't start!" )
390
391 main.step( "Start ONOS-cli" )
392
393 main.ONOScli.startOnosCli( ONOS1Ip )
394
395 main.step( "Get devices in the network" )
396 listResult = main.ONOScli.devices( jsonFormat=False )
397 main.log.info( listResult )
398 time.sleep( 10 )
399 main.log.info( "Installing sdn-ip feature" )
400 main.ONOScli.featureInstall( "onos-app-sdnip" )
401 time.sleep( 10 )
402 main.step( "Login all BGP peers and add routes into peers" )
403
404 main.log.info( "Login Quagga CLI on host3" )
405 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
406 main.log.info( "Enter configuration model of Quagga CLI on host3" )
407 main.QuaggaCliHost3.enterConfig( 64514 )
408 main.log.info( "Add routes to Quagga on host3" )
409 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
410
411 main.log.info( "Login Quagga CLI on host4" )
412 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
413 main.log.info( "Enter configuration model of Quagga CLI on host4" )
414 main.QuaggaCliHost4.enterConfig( 64516 )
415 main.log.info( "Add routes to Quagga on host4" )
416 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
417
418 for i in range( 101, 201 ):
419 prefixesHostX = \
420 main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
421 main.log.info( prefixesHostX )
422 for prefix in prefixesHostX:
423 allRoutesExpected.append(
424 prefix + "/" + "192.168.40." + str( i - 100 ) )
425
426 routeIntentsExpectedHostX = \
427 main.QuaggaCliHost.generateExpectedOnePeerRouteIntents(
428 prefixesHostX, "192.168.40." + str( i - 100 ),
429 "00:00:%02d:00:00:90" % ( i - 101 ), SDNIPJSONFILEPATH )
430 routeIntentsExpected = routeIntentsExpected + \
431 routeIntentsExpectedHostX
432
433 main.log.info( "Login Quagga CLI on host" + str( i ) )
434 QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
435 QuaggaCliHostX.loginQuagga( "1.168.30." + str( i ) )
436 main.log.info(
437 "Enter configuration model of Quagga CLI on host" + str( i ) )
438 QuaggaCliHostX.enterConfig( 65000 + i - 100 )
439 main.log.info( "Add routes to Quagga on host" + str( i ) )
440 QuaggaCliHostX.addRoutes( prefixesHostX, 1 )
441
442 time.sleep( 60 )
443
444 # get routes inside SDN-IP
445 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
446
447 # parse routes from ONOS CLI
448 allRoutesActual = \
449 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
450
451 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
452 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
453 main.step( "Check routes installed" )
454 main.log.info( "Routes expected:" )
455 main.log.info( allRoutesStrExpected )
456 main.log.info( "Routes get from ONOS CLI:" )
457 main.log.info( allRoutesStrActual )
458 utilities.assertEquals(
459 expect=allRoutesStrExpected, actual=allRoutesStrActual,
460 onpass="***Routes in SDN-IP are correct!***",
461 onfail="***Routes in SDN-IP are wrong!***" )
462 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
463 main.log.report(
464 "***Routes in SDN-IP after adding routes are correct!***" )
465 else:
466 main.log.report(
467 "***Routes in SDN-IP after adding routes are wrong!***" )
468
469 time.sleep( 20 )
470 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
471
472 main.step( "Check MultiPointToSinglePointIntent intents installed" )
473 # routeIntentsExpected are generated when generating routes
474 # get rpoute intents from ONOS CLI
475 routeIntentsActual = \
476 main.QuaggaCliHost3.extractActualRouteIntents(
477 getIntentsResult )
478 routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
479 routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" )
480 main.log.info( "MultiPointToSinglePoint intents expected:" )
481 main.log.info( routeIntentsStrExpected )
482 main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" )
483 main.log.info( routeIntentsStrActual )
484 utilities.assertEquals(
485 expect=True,
486 actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
487 onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
488 correct!***",
489 onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
490 wrong!***" )
491
492 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
493 main.log.report(
494 "***MultiPointToSinglePoint Intents before deleting routes \
495 correct!***" )
496 else:
497 main.log.report(
498 "***MultiPointToSinglePoint Intents before deleting routes \
499 wrong!***" )
500
501 main.step( "Check BGP PointToPointIntent intents installed" )
502 # bgp intents expected
503 bgpIntentsExpected = main.QuaggaCliHost3.generateExpectedBgpIntents(
504 SDNIPJSONFILEPATH )
505 # get BGP intents from ONOS CLI
506 bgpIntentsActual = main.QuaggaCliHost3.extractActualBgpIntents(
507 getIntentsResult )
508
509 bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
510 bgpIntentsStrActual = str( bgpIntentsActual )
511 main.log.info( "PointToPointIntent intents expected:" )
512 main.log.info( bgpIntentsStrExpected )
513 main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
514 main.log.info( bgpIntentsStrActual )
515
516 utilities.assertEquals(
517 expect=True,
518 actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
519 onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
520 onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
521
522 if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
523 main.log.report(
524 "***PointToPointIntent Intents in SDN-IP are correct!***" )
525 else:
526 main.log.report(
527 "***PointToPointIntent Intents in SDN-IP are wrong!***" )
528
529 #============================= Ping Test ========================
530 # wait until all MultiPointToSinglePoint
531 time.sleep( 20 )
532 pingTestScript = "~/SDNIP/test-tools/CASE3-ping-as2host.sh"
533 pingTestResultsFile = \
534 "~/SDNIP/SdnIpIntentDemo/log/CASE3-ping-results-before-delete-routes-" \
535 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
536 pingTestResults = main.QuaggaCliHost.pingTest(
537 "1.168.30.100", pingTestScript, pingTestResultsFile )
538 main.log.info( pingTestResults )
539 time.sleep( 20 )
540
541 #============================= Deleting Routes ==================
542 main.step( "Check deleting routes installed" )
543 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
544 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
545 for i in range( 101, 201 ):
546 prefixesHostX = \
547 main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
548 main.log.info( prefixesHostX )
549 QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
550 QuaggaCliHostX.deleteRoutes( prefixesHostX, 1 )
551
552 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
553 allRoutesActual = main.QuaggaCliHost3.extractActualRoutes(
554 getRoutesResult )
555 main.log.info( "allRoutes_actual = " )
556 main.log.info( allRoutesActual )
557
558 utilities.assertEquals(
559 expect="[]", actual=str( allRoutesActual ),
560 onpass="***Route number in SDN-IP is 0, correct!***",
561 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
562
563 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
564 main.log.report(
565 "***Routes in SDN-IP after deleting correct!***" )
566 else:
567 main.log.report(
568 "***Routes in SDN-IP after deleting wrong!***" )
569
570 main.step( "Check intents after deleting routes" )
571 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
572 routeIntentsActual = \
573 main.QuaggaCliHost3.extractActualRouteIntents(
574 getIntentsResult )
575 main.log.info( "main.ONOScli.intents()= " )
576 main.log.info( routeIntentsActual )
577 utilities.assertEquals(
578 expect="[]", actual=str( routeIntentsActual ),
579 onpass="***MultiPointToSinglePoint Intents number in SDN-IP is \
580 0, correct!***",
581 onfail="***MultiPointToSinglePoint Intents number in SDN-IP is \
582 0, wrong!***" )
583
584 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
585 main.log.report(
586 "***MultiPointToSinglePoint Intents after deleting routes \
587 correct!***" )
588 else:
589 main.log.report(
590 "***MultiPointToSinglePoint Intents after deleting routes \
591 wrong!***" )
592
593 time.sleep( 20 )
594 pingTestScript = "~/SDNIP/test-tools/CASE3-ping-as2host.sh"
595 pingTestResultsFile = \
596 "~/SDNIP/SdnIpIntentDemo/log/CASE3-ping-results-after-delete-routes-" \
597 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
598 pingTestResults = main.QuaggaCliHost.pingTest(
599 "1.168.30.100", pingTestScript, pingTestResultsFile )
600 main.log.info( pingTestResults )
601 time.sleep( 100 )
602
603 # main.step( "Test whether Mininet is started" )
604 # main.Mininet2.handle.sendline( "xterm host1" )
605 # main.Mininet2.handle.expect( "mininet>" )
606
607 def CASE1( self, main ):
608 """
609 Test the SDN-IP functionality
610 allRoutesExpected: all expected routes for all BGP peers
611 routeIntentsExpected: all expected MultiPointToSinglePointIntent \
612 intents
613 bgpIntentsExpected: expected PointToPointIntent intents
614 allRoutesActual: all routes from ONOS LCI
615 routeIntentsActual: actual MultiPointToSinglePointIntent intents \
616 from ONOS CLI
617 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
618 """
619 import time
620 import json
621 from operator import eq
622 # from datetime import datetime
623 from time import localtime, strftime
624
625 main.case("The test case is to help to setup the TestON environment \
626 and test new drivers" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800627 SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
pingping-lin6f6332e2014-11-19 19:13:58 -0800628 # all expected routes for all BGP peers
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800629 allRoutesExpected = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800630 main.step( "Start to generate routes for all BGP peers" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800631 # bgpPeerHosts = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800632 # for i in range( 3, 5 ):
633 # bgpPeerHosts.append( "host" + str( i ) )
634 # main.log.info( "BGP Peer Hosts are:" + bgpPeerHosts )
pingping-lin6f6332e2014-11-19 19:13:58 -0800635
kelvin-onlab8a832582015-01-16 17:06:11 -0800636 # for i in range( 3, 5 ):
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800637 # QuaggaCliHost = "QuaggaCliHost" + str( i )
638 # prefixes = main.QuaggaCliHost.generatePrefixes( 3, 10 )
pingping-lin6f6332e2014-11-19 19:13:58 -0800639
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800640 # main.log.info( prefixes )
641 # allRoutesExpected.append( prefixes )
kelvin-onlab8a832582015-01-16 17:06:11 -0800642 main.log.info( "Generate prefixes for host3" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800643 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
644 main.log.info( prefixesHost3 )
pingping-lin36fbe802014-11-25 16:01:14 -0800645 # generate route with next hop
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800646 for prefix in prefixesHost3:
647 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800648 routeIntentsExpectedHost3 = \
649 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
650 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
651 SDNIPJSONFILEPATH )
pingping-lin6f6332e2014-11-19 19:13:58 -0800652
kelvin-onlab8a832582015-01-16 17:06:11 -0800653 main.log.info( "Generate prefixes for host4" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800654 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
655 main.log.info( prefixesHost4 )
pingping-lin36fbe802014-11-25 16:01:14 -0800656 # generate route with next hop
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800657 for prefix in prefixesHost4:
658 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800659 routeIntentsExpectedHost4 = \
660 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
661 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
662 SDNIPJSONFILEPATH )
pingping-lin6f6332e2014-11-19 19:13:58 -0800663
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800664 routeIntentsExpected = routeIntentsExpectedHost3 + \
665 routeIntentsExpectedHost4
pingping-lin8b306ac2014-11-17 18:13:51 -0800666
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800667 cellName = main.params[ 'ENV' ][ 'cellName' ]
668 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
kelvin-onlab8a832582015-01-16 17:06:11 -0800669 main.step( "Set cell for ONOS-cli environment" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800670 main.ONOScli.setCell( cellName )
671 verifyResult = main.ONOSbench.verifyCell()
kelvin-onlab8a832582015-01-16 17:06:11 -0800672 main.log.report( "Removing raft logs" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800673 main.ONOSbench.onosRemoveRaftLogs()
kelvin-onlab8a832582015-01-16 17:06:11 -0800674 main.log.report( "Uninstalling ONOS" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800675 main.ONOSbench.onosUninstall( ONOS1Ip )
kelvin-onlab8a832582015-01-16 17:06:11 -0800676 main.step( "Creating ONOS package" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800677 packageResult = main.ONOSbench.onosPackage()
pingping-lin8b306ac2014-11-17 18:13:51 -0800678
kelvin-onlab8a832582015-01-16 17:06:11 -0800679 main.step( "Starting ONOS service" )
pingping-lin8b306ac2014-11-17 18:13:51 -0800680 # TODO: start ONOS from Mininet Script
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800681 # startResult = main.ONOSbench.onosStart( "127.0.0.1" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800682 main.step( "Installing ONOS package" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800683 onos1InstallResult = main.ONOSbench.onosInstall(
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800684 options="-f", node=ONOS1Ip )
pingping-lin3d87a132014-12-04 14:22:49 -0800685
kelvin-onlab8a832582015-01-16 17:06:11 -0800686 main.step( "Checking if ONOS is up yet" )
687 time.sleep( 60 )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800688 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
689 if not onos1Isup:
kelvin-onlab8a832582015-01-16 17:06:11 -0800690 main.log.report( "ONOS1 didn't start!" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800691
kelvin-onlab8a832582015-01-16 17:06:11 -0800692 main.step( "Start ONOS-cli" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800693 # TODO: change the hardcode in startOnosCli method in ONOS CLI driver
pingping-linc6b86fa2014-12-01 16:18:10 -0800694
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800695 main.ONOScli.startOnosCli( ONOS1Ip )
pingping-lin8b306ac2014-11-17 18:13:51 -0800696
kelvin-onlab8a832582015-01-16 17:06:11 -0800697 main.step( "Get devices in the network" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800698 listResult = main.ONOScli.devices( jsonFormat=False )
699 main.log.info( listResult )
kelvin-onlab8a832582015-01-16 17:06:11 -0800700 time.sleep( 10 )
701 main.log.info( "Installing sdn-ip feature" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800702 main.ONOScli.featureInstall( "onos-app-sdnip" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800703 time.sleep( 10 )
704 main.step( "Login all BGP peers and add routes into peers" )
705 main.log.info( "Login Quagga CLI on host3" )
706 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
707 main.log.info( "Enter configuration model of Quagga CLI on host3" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800708 main.QuaggaCliHost3.enterConfig( 64514 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800709 main.log.info( "Add routes to Quagga on host3" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800710 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
pingping-linbc230942014-12-03 18:36:27 -0800711
kelvin-onlab8a832582015-01-16 17:06:11 -0800712 main.log.info( "Login Quagga CLI on host4" )
713 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
714 main.log.info( "Enter configuration model of Quagga CLI on host4" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800715 main.QuaggaCliHost4.enterConfig( 64516 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800716 main.log.info( "Add routes to Quagga on host4" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800717 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
kelvin-onlab8a832582015-01-16 17:06:11 -0800718 time.sleep( 60 )
pingping-lin8b306ac2014-11-17 18:13:51 -0800719
pingping-linc6b86fa2014-12-01 16:18:10 -0800720 # get all routes inside SDN-IP
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800721 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
pingping-linc6b86fa2014-12-01 16:18:10 -0800722
pingping-lin8b306ac2014-11-17 18:13:51 -0800723 # parse routes from ONOS CLI
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800724 allRoutesActual = \
725 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
pingping-linc6b86fa2014-12-01 16:18:10 -0800726
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800727 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
728 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800729 main.step( "Check routes installed" )
730 main.log.info( "Routes expected:" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800731 main.log.info( allRoutesStrExpected )
kelvin-onlab8a832582015-01-16 17:06:11 -0800732 main.log.info( "Routes get from ONOS CLI:" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800733 main.log.info( allRoutesStrActual )
734 utilities.assertEquals(
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800735 expect=allRoutesStrExpected, actual=allRoutesStrActual,
kelvin-onlab8a832582015-01-16 17:06:11 -0800736 onpass="***Routes in SDN-IP are correct!***",
737 onfail="***Routes in SDN-IP are wrong!***" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800738 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800739 main.log.report(
740 "***Routes in SDN-IP after adding routes are correct!***" )
pingping-lin3d87a132014-12-04 14:22:49 -0800741 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800742 main.log.report(
743 "***Routes in SDN-IP after adding routes are wrong!***" )
pingping-lin8b306ac2014-11-17 18:13:51 -0800744
kelvin-onlab8a832582015-01-16 17:06:11 -0800745 time.sleep( 20 )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800746 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
pingping-lin6f6332e2014-11-19 19:13:58 -0800747
kelvin-onlab8a832582015-01-16 17:06:11 -0800748 main.step( "Check MultiPointToSinglePointIntent intents installed" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800749 # routeIntentsExpected are generated when generating routes
pingping-lin6f6332e2014-11-19 19:13:58 -0800750 # get rpoute intents from ONOS CLI
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800751 routeIntentsActual = \
752 main.QuaggaCliHost3.extractActualRouteIntents(
753 getIntentsResult )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800754 routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
755 routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800756 main.log.info( "MultiPointToSinglePoint intents expected:" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800757 main.log.info( routeIntentsStrExpected )
kelvin-onlab8a832582015-01-16 17:06:11 -0800758 main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800759 main.log.info( routeIntentsStrActual )
760 utilities.assertEquals(
kelvin-onlab8a832582015-01-16 17:06:11 -0800761 expect=True,
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800762 actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
763 onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
764 correct!***",
765 onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
766 wrong!***" )
pingping-lin6f6332e2014-11-19 19:13:58 -0800767
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800768 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800769 main.log.report(
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800770 "***MultiPointToSinglePoint Intents before deleting routes \
771 correct!***" )
pingping-lin3d87a132014-12-04 14:22:49 -0800772 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800773 main.log.report(
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800774 "***MultiPointToSinglePoint Intents before deleting routes \
775 wrong!***" )
pingping-lin6f6332e2014-11-19 19:13:58 -0800776
kelvin-onlab8a832582015-01-16 17:06:11 -0800777 main.step( "Check BGP PointToPointIntent intents installed" )
pingping-lin6f6332e2014-11-19 19:13:58 -0800778 # bgp intents expected
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800779 bgpIntentsExpected = \
780 main.QuaggaCliHost3.generateExpectedBgpIntents( SDNIPJSONFILEPATH )
pingping-lin6f6332e2014-11-19 19:13:58 -0800781 # get BGP intents from ONOS CLI
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800782 bgpIntentsActual = main.QuaggaCliHost3.extractActualBgpIntents(
783 getIntentsResult )
pingping-lin3228e132014-11-20 17:49:02 -0800784
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800785 bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
786 bgpIntentsStrActual = str( bgpIntentsActual )
kelvin-onlab8a832582015-01-16 17:06:11 -0800787 main.log.info( "PointToPointIntent intents expected:" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800788 main.log.info( bgpIntentsStrExpected )
kelvin-onlab8a832582015-01-16 17:06:11 -0800789 main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800790 main.log.info( bgpIntentsStrActual )
pingping-lin3228e132014-11-20 17:49:02 -0800791
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800792 utilities.assertEquals(
kelvin-onlab8a832582015-01-16 17:06:11 -0800793 expect=True,
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800794 actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
kelvin-onlab8a832582015-01-16 17:06:11 -0800795 onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
796 onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
pingping-lin8b306ac2014-11-17 18:13:51 -0800797
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800798 if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800799 main.log.report(
800 "***PointToPointIntent Intents in SDN-IP are correct!***" )
pingping-lin3d87a132014-12-04 14:22:49 -0800801 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800802 main.log.report(
803 "***PointToPointIntent Intents in SDN-IP are wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -0800804
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800805 #============================= Ping Test ========================
pingping-linc6b86fa2014-12-01 16:18:10 -0800806 # wait until all MultiPointToSinglePoint
kelvin-onlab8a832582015-01-16 17:06:11 -0800807 time.sleep( 20 )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800808 pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800809 pingTestResultsFile = \
810 "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-before-delete-routes-" \
811 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800812 pingTestResults = main.QuaggaCliHost.pingTest(
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800813 "1.168.30.100", pingTestScript, pingTestResultsFile )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800814 main.log.info( pingTestResults )
pingping-linc6b86fa2014-12-01 16:18:10 -0800815
816 # ping test
817
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800818 #============================= Deleting Routes ==================
kelvin-onlab8a832582015-01-16 17:06:11 -0800819 main.step( "Check deleting routes installed" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800820 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
821 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
pingping-linc6b86fa2014-12-01 16:18:10 -0800822
kelvin-onlab8a832582015-01-16 17:06:11 -0800823 # main.log.info( "main.ONOScli.get_routes_num() = " )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800824 # main.log.info( main.ONOScli.getRoutesNum() )
825 # utilities.assertEquals( expect="Total SDN-IP routes = 1", actual=
826 # main.ONOScli.getRoutesNum(),
827 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800828 allRoutesActual = \
829 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
kelvin-onlab8a832582015-01-16 17:06:11 -0800830 main.log.info( "allRoutes_actual = " )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800831 main.log.info( allRoutesActual )
pingping-linc6b86fa2014-12-01 16:18:10 -0800832
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800833 utilities.assertEquals(
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800834 expect="[]", actual=str( allRoutesActual ),
kelvin-onlab8a832582015-01-16 17:06:11 -0800835 onpass="***Route number in SDN-IP is 0, correct!***",
836 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800837
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800838 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800839 main.log.report(
840 "***Routes in SDN-IP after deleting correct!***" )
pingping-lin3d87a132014-12-04 14:22:49 -0800841 else:
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800842 main.log.report(
843 "***Routes in SDN-IP after deleting wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -0800844
kelvin-onlab8a832582015-01-16 17:06:11 -0800845 main.step( "Check intents after deleting routes" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800846 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800847 routeIntentsActual = \
848 main.QuaggaCliHost3.extractActualRouteIntents(
849 getIntentsResult )
kelvin-onlab8a832582015-01-16 17:06:11 -0800850 main.log.info( "main.ONOScli.intents()= " )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800851 main.log.info( routeIntentsActual )
852 utilities.assertEquals(
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800853 expect="[]", actual=str( routeIntentsActual ),
854 onpass="***MultiPointToSinglePoint Intents number in SDN-IP is \
855 0, correct!***",
856 onfail="***MultiPointToSinglePoint Intents number in SDN-IP is \
857 0, wrong!***" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800858
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800859 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800860 main.log.report(
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800861 "***MultiPointToSinglePoint Intents after deleting routes \
862 correct!***" )
pingping-lin3d87a132014-12-04 14:22:49 -0800863 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800864 main.log.report(
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800865 "***MultiPointToSinglePoint Intents after deleting routes \
866 wrong!***" )
pingping-linc6b86fa2014-12-01 16:18:10 -0800867
kelvin-onlab8a832582015-01-16 17:06:11 -0800868 time.sleep( 20 )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800869 pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800870 pingTestResultsFile = \
871 "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-after-delete-routes-" \
872 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800873 pingTestResults = main.QuaggaCliHost.pingTest(
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800874 "1.168.30.100", pingTestScript, pingTestResultsFile )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800875 main.log.info( pingTestResults )
kelvin-onlab8a832582015-01-16 17:06:11 -0800876 time.sleep( 30 )
pingping-linc6b86fa2014-12-01 16:18:10 -0800877
kelvin-onlab8a832582015-01-16 17:06:11 -0800878 # main.step( "Test whether Mininet is started" )
879 # main.Mininet2.handle.sendline( "xterm host1" )
880 # main.Mininet2.handle.expect( "mininet>" )
pingping-lin8b306ac2014-11-17 18:13:51 -0800881
kelvin-onlab8a832582015-01-16 17:06:11 -0800882 def CASE2( self, main ):
883 """
pingping-lin3d87a132014-12-04 14:22:49 -0800884 Test the SDN-IP functionality
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800885 allRoutesExpected: all expected routes for all BGP peers
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800886 routeIntentsExpected: all expected MultiPointToSinglePointIntent \
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800887 intents
888 bgpIntentsExpected: expected PointToPointIntent intents
889 allRoutesActual: all routes from ONOS LCI
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800890 routeIntentsActual: actual MultiPointToSinglePointIntent intents \
891 from ONOS CLI
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800892 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
kelvin-onlab8a832582015-01-16 17:06:11 -0800893 """
pingping-lin3d87a132014-12-04 14:22:49 -0800894 import time
895 import json
896 from operator import eq
897 from time import localtime, strftime
898
kelvin-onlab8a832582015-01-16 17:06:11 -0800899 main.case(
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800900 "The test case is to help to setup the TestON environment and \
901 test new drivers" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800902 SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
pingping-lin3d87a132014-12-04 14:22:49 -0800903 # all expected routes for all BGP peers
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800904 allRoutesExpected = []
kelvin-onlab8a832582015-01-16 17:06:11 -0800905 main.step( "Start to generate routes for all BGP peers" )
pingping-lin3d87a132014-12-04 14:22:49 -0800906
kelvin-onlab8a832582015-01-16 17:06:11 -0800907 main.log.info( "Generate prefixes for host3" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800908 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
909 main.log.info( prefixesHost3 )
pingping-lin3d87a132014-12-04 14:22:49 -0800910 # generate route with next hop
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800911 for prefix in prefixesHost3:
912 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800913 routeIntentsExpectedHost3 = \
914 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
915 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
916 SDNIPJSONFILEPATH )
pingping-lin3d87a132014-12-04 14:22:49 -0800917
kelvin-onlab8a832582015-01-16 17:06:11 -0800918 main.log.info( "Generate prefixes for host4" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800919 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
920 main.log.info( prefixesHost4 )
pingping-lin3d87a132014-12-04 14:22:49 -0800921 # generate route with next hop
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800922 for prefix in prefixesHost4:
923 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800924 routeIntentsExpectedHost4 = \
925 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
926 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
927 SDNIPJSONFILEPATH )
pingping-lin3d87a132014-12-04 14:22:49 -0800928
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800929 routeIntentsExpected = routeIntentsExpectedHost3 + \
930 routeIntentsExpectedHost4
pingping-lin3d87a132014-12-04 14:22:49 -0800931
kelvin-onlab8a832582015-01-16 17:06:11 -0800932 main.log.report( "Removing raft logs" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800933 main.ONOSbench.onosRemoveRaftLogs()
kelvin-onlab8a832582015-01-16 17:06:11 -0800934 main.log.report( "Uninstalling ONOS" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800935 main.ONOSbench.onosUninstall( ONOS1Ip )
pingping-lin3d87a132014-12-04 14:22:49 -0800936
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800937 cellName = main.params[ 'ENV' ][ 'cellName' ]
938 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
kelvin-onlab8a832582015-01-16 17:06:11 -0800939 main.step( "Set cell for ONOS-cli environment" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800940 main.ONOScli.setCell( cellName )
941 verifyResult = main.ONOSbench.verifyCell()
942 # main.log.report( "Removing raft logs" )
943 # main.ONOSbench.onosRemoveRaftLogs()
944 # main.log.report( "Uninstalling ONOS" )
945 # main.ONOSbench.onosUninstall( ONOS1Ip )
kelvin-onlab8a832582015-01-16 17:06:11 -0800946 main.step( "Creating ONOS package" )
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800947 # packageResult = main.ONOSbench.onosPackage()
pingping-lin3d87a132014-12-04 14:22:49 -0800948
kelvin-onlab8a832582015-01-16 17:06:11 -0800949 main.step( "Installing ONOS package" )
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800950 # onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
951 # node=ONOS1Ip )
pingping-lin3d87a132014-12-04 14:22:49 -0800952
kelvin-onlab8a832582015-01-16 17:06:11 -0800953 main.step( "Checking if ONOS is up yet" )
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800954 # time.sleep( 60 )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800955 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
956 if not onos1Isup:
kelvin-onlab8a832582015-01-16 17:06:11 -0800957 main.log.report( "ONOS1 didn't start!" )
pingping-lin3d87a132014-12-04 14:22:49 -0800958
kelvin-onlab8a832582015-01-16 17:06:11 -0800959 main.step( "Start ONOS-cli" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800960 main.ONOScli.startOnosCli( ONOS1Ip )
pingping-lin3d87a132014-12-04 14:22:49 -0800961
kelvin-onlab8a832582015-01-16 17:06:11 -0800962 main.step( "Get devices in the network" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800963 listResult = main.ONOScli.devices( jsonFormat=False )
964 main.log.info( listResult )
kelvin-onlab8a832582015-01-16 17:06:11 -0800965 time.sleep( 10 )
966 main.log.info( "Installing sdn-ip feature" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800967 main.ONOScli.featureInstall( "onos-app-sdnip" )
kelvin-onlab8a832582015-01-16 17:06:11 -0800968 time.sleep( 10 )
pingping-lin3d87a132014-12-04 14:22:49 -0800969
kelvin-onlab8a832582015-01-16 17:06:11 -0800970 main.step( "Check BGP PointToPointIntent intents installed" )
pingping-lin3d87a132014-12-04 14:22:49 -0800971 # bgp intents expected
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800972 bgpIntentsExpected = main.QuaggaCliHost3.generateExpectedBgpIntents(
973 SDNIPJSONFILEPATH )
pingping-lin3d87a132014-12-04 14:22:49 -0800974 # get BGP intents from ONOS CLI
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800975 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
976 bgpIntentsActual = main.QuaggaCliHost3.extractActualBgpIntents(
977 getIntentsResult )
pingping-lin3d87a132014-12-04 14:22:49 -0800978
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800979 bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
980 bgpIntentsStrActual = str( bgpIntentsActual )
kelvin-onlab8a832582015-01-16 17:06:11 -0800981 main.log.info( "PointToPointIntent intents expected:" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800982 main.log.info( bgpIntentsStrExpected )
kelvin-onlab8a832582015-01-16 17:06:11 -0800983 main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800984 main.log.info( bgpIntentsStrActual )
pingping-lin3d87a132014-12-04 14:22:49 -0800985
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800986 utilities.assertEquals(
kelvin-onlab8a832582015-01-16 17:06:11 -0800987 expect=True,
kelvin-onlab2c4342a2015-01-28 15:59:53 -0800988 actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
kelvin-onlab8a832582015-01-16 17:06:11 -0800989 onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
990 onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -0800991
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800992 if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -0800993 main.log.report(
994 "***PointToPointIntent Intents in SDN-IP are correct!***" )
pingping-lin3d87a132014-12-04 14:22:49 -0800995 else:
kelvin-onlab8a832582015-01-16 17:06:11 -0800996 main.log.report(
997 "***PointToPointIntent Intents in SDN-IP are wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -0800998
kelvin-onlab7bbb5612015-01-26 10:54:50 -0800999 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
1000 routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
1001 pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
1002 # roundNum = 0;
kelvin-onlab8a832582015-01-16 17:06:11 -08001003 # while( True ):
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001004 for roundNum in range( 1, 6 ):
pingping-lin3d87a132014-12-04 14:22:49 -08001005 # round = round + 1;
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001006 main.log.report( "The Round " + str( roundNum ) +
1007 " test starts................................" )
pingping-lin3d87a132014-12-04 14:22:49 -08001008
kelvin-onlab8a832582015-01-16 17:06:11 -08001009 main.step( "Login all BGP peers and add routes into peers" )
1010 main.log.info( "Login Quagga CLI on host3" )
1011 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001012 main.log.info(
1013 "Enter configuration model of Quagga CLI on host3" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001014 main.QuaggaCliHost3.enterConfig( 64514 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001015 main.log.info( "Add routes to Quagga on host3" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001016 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
pingping-lin3d87a132014-12-04 14:22:49 -08001017
kelvin-onlab8a832582015-01-16 17:06:11 -08001018 main.log.info( "Login Quagga CLI on host4" )
1019 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001020 main.log.info(
1021 "Enter configuration model of Quagga CLI on host4" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001022 main.QuaggaCliHost4.enterConfig( 64516 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001023 main.log.info( "Add routes to Quagga on host4" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001024 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001025 time.sleep( 60 )
pingping-lin3d87a132014-12-04 14:22:49 -08001026
1027 # get all routes inside SDN-IP
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001028 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
pingping-lin3d87a132014-12-04 14:22:49 -08001029
1030 # parse routes from ONOS CLI
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001031 allRoutesActual = \
1032 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
pingping-lin3d87a132014-12-04 14:22:49 -08001033
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001034 # allRoutesStrExpected = str( sorted( allRoutesExpected ) )
1035 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001036 main.step( "Check routes installed" )
1037 main.log.info( "Routes expected:" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001038 main.log.info( allRoutesStrExpected )
kelvin-onlab8a832582015-01-16 17:06:11 -08001039 main.log.info( "Routes get from ONOS CLI:" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001040 main.log.info( allRoutesStrActual )
1041 utilities.assertEquals(
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001042 expect=allRoutesStrExpected, actual=allRoutesStrActual,
kelvin-onlab8a832582015-01-16 17:06:11 -08001043 onpass="***Routes in SDN-IP are correct!***",
1044 onfail="***Routes in SDN-IP are wrong!***" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001045 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -08001046 main.log.report(
1047 "***Routes in SDN-IP after adding correct!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001048 else:
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001049 main.log.report(
1050 "***Routes in SDN-IP after adding wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001051
kelvin-onlab8a832582015-01-16 17:06:11 -08001052 time.sleep( 20 )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001053 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
pingping-lin3d87a132014-12-04 14:22:49 -08001054
kelvin-onlab8a832582015-01-16 17:06:11 -08001055 main.step(
1056 "Check MultiPointToSinglePointIntent intents installed" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001057 # routeIntentsExpected are generated when generating routes
pingping-lin3d87a132014-12-04 14:22:49 -08001058 # get route intents from ONOS CLI
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001059 routeIntentsActual = \
1060 main.QuaggaCliHost3.extractActualRouteIntents(
1061 getIntentsResult )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001062 # routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
1063 routeIntentsStrActual = str(
1064 routeIntentsActual ).replace( 'u', "" )
kelvin-onlab8a832582015-01-16 17:06:11 -08001065 main.log.info( "MultiPointToSinglePoint intents expected:" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001066 main.log.info( routeIntentsStrExpected )
kelvin-onlab8a832582015-01-16 17:06:11 -08001067 main.log.info(
1068 "MultiPointToSinglePoint intents get from ONOS CLI:" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001069 main.log.info( routeIntentsStrActual )
1070 utilities.assertEquals(
kelvin-onlab8a832582015-01-16 17:06:11 -08001071 expect=True,
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001072 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-lin3d87a132014-12-04 14:22:49 -08001077
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001078 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -08001079 main.log.report(
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001080 "***MultiPointToSinglePoint Intents after adding routes \
1081 correct!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001082 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001083 main.log.report(
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001084 "***MultiPointToSinglePoint Intents after adding routes \
1085 wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001086
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001087 #============================= Ping Test ========================
pingping-lin3d87a132014-12-04 14:22:49 -08001088 # wait until all MultiPointToSinglePoint
kelvin-onlab8a832582015-01-16 17:06:11 -08001089 time.sleep( 20 )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001090 # pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001091 pingTestResultsFile = \
1092 "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" \
1093 + str( roundNum ) + "-ping-results-before-delete-routes-" \
1094 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001095 pingTestResults = main.QuaggaCliHost.pingTest(
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001096 "1.168.30.100", pingTestScript, pingTestResultsFile )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001097 main.log.info( pingTestResults )
pingping-lin3d87a132014-12-04 14:22:49 -08001098 # ping test
1099
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001100 #============================= Deleting Routes ==================
kelvin-onlab8a832582015-01-16 17:06:11 -08001101 main.step( "Check deleting routes installed" )
1102 main.log.info( "Delete routes to Quagga on host3" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001103 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
kelvin-onlab8a832582015-01-16 17:06:11 -08001104 main.log.info( "Delete routes to Quagga on host4" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001105 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
pingping-lin3d87a132014-12-04 14:22:49 -08001106
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001107 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001108 allRoutesActual = \
1109 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001110 main.log.info( "allRoutes_actual = " )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001111 main.log.info( allRoutesActual )
pingping-lin3d87a132014-12-04 14:22:49 -08001112
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001113 utilities.assertEquals(
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001114 expect="[]", actual=str( allRoutesActual ),
kelvin-onlab8a832582015-01-16 17:06:11 -08001115 onpass="***Route number in SDN-IP is 0, correct!***",
1116 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001117
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001118 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -08001119 main.log.report(
1120 "***Routes in SDN-IP after deleting correct!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001121 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001122 main.log.report(
1123 "***Routes in SDN-IP after deleting wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001124
kelvin-onlab8a832582015-01-16 17:06:11 -08001125 main.step( "Check intents after deleting routes" )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001126 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001127 routeIntentsActual = \
1128 main.QuaggaCliHost3.extractActualRouteIntents(
1129 getIntentsResult )
kelvin-onlab8a832582015-01-16 17:06:11 -08001130 main.log.info( "main.ONOScli.intents()= " )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001131 main.log.info( routeIntentsActual )
1132 utilities.assertEquals(
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001133 expect="[]", actual=str( routeIntentsActual ),
1134 onpass=
1135 "***MultiPointToSinglePoint Intents number in SDN-IP \
1136 is 0, correct!***",
1137 onfail="***MultiPointToSinglePoint Intents number in SDN-IP \
1138 is 0, wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001139
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001140 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
kelvin-onlab8a832582015-01-16 17:06:11 -08001141 main.log.report(
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001142 "***MultiPointToSinglePoint Intents after deleting \
1143 routes correct!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001144 else:
kelvin-onlab8a832582015-01-16 17:06:11 -08001145 main.log.report(
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001146 "***MultiPointToSinglePoint Intents after deleting \
1147 routes wrong!***" )
pingping-lin3d87a132014-12-04 14:22:49 -08001148
kelvin-onlab8a832582015-01-16 17:06:11 -08001149 time.sleep( 20 )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001150 # pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001151 pingTestResultsFile = \
1152 "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" \
1153 + str( roundNum ) + "-ping-results-after-delete-routes-" \
1154 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001155 pingTestResults = main.QuaggaCliHost.pingTest(
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001156 "1.168.30.100", pingTestScript, pingTestResultsFile )
kelvin-onlab7bbb5612015-01-26 10:54:50 -08001157 main.log.info( pingTestResults )
kelvin-onlab8a832582015-01-16 17:06:11 -08001158 time.sleep( 30 )
kelvin-onlab2c4342a2015-01-28 15:59:53 -08001159