blob: d13bdb3d52477d677b905249e92221be1d4fcc8c [file] [log] [blame]
sanghoshina0934b72015-02-26 11:25:07 -08001# from cupshelpers.config import prefix
2
3# Testing the basic functionality of SDN-IP
4
5
6class SdnIpSingleSwitch:
7
8 def __init__( self ):
9 self.default = ''
10
11# from cupshelpers.config import prefix
12
13# Testing the basic functionality of SDN-IP
14
15
16class SdnIpSingleSwitch:
17
18 def __init__( self ):
19 self.default = ''
20
21 def CASE4( self, main ):
22 """
23 Test the SDN-IP functionality
24 allRoutesExpected: all expected routes for all BGP peers
25 routeIntentsExpected: all expected MultiPointToSinglePointIntent \
26 intents
27 bgpIntentsExpected: expected PointToPointIntent intents
28 allRoutesActual: all routes from ONOS LCI
29 routeIntentsActual: actual MultiPointToSinglePointIntent intents from \
30 ONOS CLI
31 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
32 """
33 import time
34 import json
35 from operator import eq
36 # from datetime import datetime
37 from time import localtime, strftime
38
39 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/sdnip/TestON/tests/SdnIpSingleSwitch/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( 20 )
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 time.sleep( 60 )
138
139 # get routes inside SDN-IP
140 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
141
142 # parse routes from ONOS CLI
143 allRoutesActual = \
144 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
145
146 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
147 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
148 main.step( "Check routes installed" )
149 main.log.info( "Routes expected:" )
150 main.log.info( allRoutesStrExpected )
151 main.log.info( "Routes get from ONOS CLI:" )
152 main.log.info( allRoutesStrActual )
153 utilities.assertEquals(
154 expect=allRoutesStrExpected, actual=allRoutesStrActual,
155 onpass="***Routes in SDN-IP are correct!***",
156 onfail="***Routes in SDN-IP are wrong!***" )
157 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
158 main.log.report(
159 "***Routes in SDN-IP after adding routes are correct!***" )
160 else:
161 main.log.report(
162 "***Routes in SDN-IP after adding routes are wrong!***" )
163
164 time.sleep( 20 )
165 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
166
167 main.step( "Check MultiPointToSinglePointIntent intents installed" )
168 # routeIntentsExpected are generated when generating routes
169 # get rpoute intents from ONOS CLI
170 routeIntentsActual = \
171 main.QuaggaCliHost3.extractActualRouteIntents(
172 getIntentsResult )
173 routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
174 routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" )
175 main.log.info( "MultiPointToSinglePoint intents expected:" )
176 main.log.info( routeIntentsStrExpected )
177 main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" )
178 main.log.info( routeIntentsStrActual )
179 utilities.assertEquals(
180 expect=True,
181 actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
182 onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
183 correct!***",
184 onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
185 wrong!***" )
186
187 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
188 main.log.report( "***MultiPointToSinglePoint Intents before \
189 deleting routes correct!***" )
190 else:
191 main.log.report( "***MultiPointToSinglePoint Intents before \
192 deleting routes wrong!***" )
193
194 main.step( "Check BGP PointToPointIntent intents installed" )
195 # bgp intents expected
196 bgpIntentsExpected = \
197 main.QuaggaCliHost3.generateExpectedBgpIntents( SDNIPJSONFILEPATH )
198 # get BGP intents from ONOS CLI
199 bgpIntentsActual = \
200 main.QuaggaCliHost3.extractActualBgpIntents( getIntentsResult )
201
202 bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
203 bgpIntentsStrActual = str( bgpIntentsActual )
204 main.log.info( "PointToPointIntent intents expected:" )
205 main.log.info( bgpIntentsStrExpected )
206 main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
207 main.log.info( bgpIntentsStrActual )
208
209 utilities.assertEquals(
210 expect=True,
211 actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
212 onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
213 onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
214
215 if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
216 main.log.report(
217 "***PointToPointIntent Intents in SDN-IP are correct!***" )
218 else:
219 main.log.report(
220 "***PointToPointIntent Intents in SDN-IP are wrong!***" )
221
222 main.log.info( "Ping Test Start" )
223 time.sleep(1000000)
224
225 #============================= Ping Test ========================
226 # wait until all MultiPointToSinglePoint
227 time.sleep( 20 )
228 pingTestScript = "CASE4-ping-as2host.sh"
229 pingTestResultsFile = \
230 "~/CASE4-ping-results-before-delete-routes-" \
231 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
232 pingTestResults = main.QuaggaCliHost.pingTest(
233 "1.168.30.100", pingTestScript, pingTestResultsFile )
234 main.log.info( pingTestResults )
235 time.sleep( 20 )
236
237 #============================= Deleting Routes ==================
238 main.step( "Check deleting routes installed" )
239 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
240 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
241 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
242
243 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
244 allRoutesActual = \
245 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
246 main.log.info( "allRoutes_actual = " )
247 main.log.info( allRoutesActual )
248
249 utilities.assertEquals(
250 expect="[]", actual=str( allRoutesActual ),
251 onpass="***Route number in SDN-IP is 0, correct!***",
252 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
253
254 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
255 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
256 else:
257 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
258
259 main.step( "Check intents after deleting routes" )
260 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
261 routeIntentsActual = \
262 main.QuaggaCliHost3.extractActualRouteIntents(
263 getIntentsResult )
264 main.log.info( "main.ONOScli.intents()= " )
265 main.log.info( routeIntentsActual )
266 utilities.assertEquals(
267 expect="[]", actual=str( routeIntentsActual ),
268 onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, \
269 correct!***",
270 onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, \
271 wrong!***" )
272
273 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
274 main.log.report( "***MultiPointToSinglePoint Intents after \
275 deleting routes correct!***" )
276 else:
277 main.log.report( "***MultiPointToSinglePoint Intents after \
278 deleting routes wrong!***" )
279
280 time.sleep( 20 )
281 pingTestScript = "CASE4-ping-as2host.sh"
282 pingTestResultsFile = \
283 "~/CASE4-ping-results-after-delete-routes-" \
284 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
285 pingTestResults = main.QuaggaCliHost.pingTest(
286 "1.168.30.100", pingTestScript, pingTestResultsFile )
287 main.log.info( pingTestResults )
288 time.sleep( 100 )
289
290 # main.step( "Test whether Mininet is started" )
291 # main.Mininet2.handle.sendline( "xterm host1" )
292 # main.Mininet2.handle.expect( "mininet>" )
293
294 def CASE3( self, main ):
295 """
296 Test the SDN-IP functionality
297 allRoutesExpected: all expected routes for all BGP peers
298 routeIntentsExpected: all expected MultiPointToSinglePointIntent intents
299 bgpIntentsExpected: expected PointToPointIntent intents
300 allRoutesActual: all routes from ONOS LCI
301 routeIntentsActual: actual MultiPointToSinglePointIntent intents from \
302 ONOS CLI
303 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
304 """
305 import time
306 import json
307 from operator import eq
308 # from datetime import datetime
309 from time import localtime, strftime
310
311 main.case( "The test case is to help to setup the TestON \
312 environment and test new drivers" )
313 # SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
314 SDNIPJSONFILEPATH = \
315 "/home/admin/workspace/onos/tools/package/config/sdnip.json"
316 # all expected routes for all BGP peers
317 allRoutesExpected = []
318 main.step( "Start to generate routes for all BGP peers" )
319 main.log.info( "Generate prefixes for host3" )
320 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
321 main.log.info( prefixesHost3 )
322 # generate route with next hop
323 for prefix in prefixesHost3:
324 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
325 routeIntentsExpectedHost3 = \
326 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
327 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
328 SDNIPJSONFILEPATH )
329
330 main.log.info( "Generate prefixes for host4" )
331 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
332 main.log.info( prefixesHost4 )
333 # generate route with next hop
334 for prefix in prefixesHost4:
335 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
336 routeIntentsExpectedHost4 = \
337 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
338 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
339 SDNIPJSONFILEPATH )
340
341 routeIntentsExpected = routeIntentsExpectedHost3 + \
342 routeIntentsExpectedHost4
343
344 cellName = main.params[ 'ENV' ][ 'cellName' ]
345 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
346 main.step( "Set cell for ONOS-cli environment" )
347 main.ONOScli.setCell( cellName )
348 verifyResult = main.ONOSbench.verifyCell()
349
350 main.log.report( "Removing raft logs" )
351 main.ONOSbench.onosRemoveRaftLogs()
352 main.log.report( "Uninstalling ONOS" )
353 main.ONOSbench.onosUninstall( ONOS1Ip )
354
355 main.step( "Installing ONOS package" )
356 onos1InstallResult = main.ONOSbench.onosInstall(
357 options="-f", node=ONOS1Ip )
358
359 main.step( "Checking if ONOS is up yet" )
360 time.sleep( 60 )
361 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
362 if not onos1Isup:
363 main.log.report( "ONOS1 didn't start!" )
364
365 main.step( "Start ONOS-cli" )
366
367 main.ONOScli.startOnosCli( ONOS1Ip )
368
369 main.step( "Get devices in the network" )
370 listResult = main.ONOScli.devices( jsonFormat=False )
371 main.log.info( listResult )
372 time.sleep( 10 )
373 main.log.info( "Installing sdn-ip feature" )
374 main.ONOScli.featureInstall( "onos-app-sdnip" )
375 time.sleep( 10 )
376 main.step( "Login all BGP peers and add routes into peers" )
377
378 main.log.info( "Login Quagga CLI on host3" )
379 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
380 main.log.info( "Enter configuration model of Quagga CLI on host3" )
381 main.QuaggaCliHost3.enterConfig( 64514 )
382 main.log.info( "Add routes to Quagga on host3" )
383 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
384
385 main.log.info( "Login Quagga CLI on host4" )
386 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
387 main.log.info( "Enter configuration model of Quagga CLI on host4" )
388 main.QuaggaCliHost4.enterConfig( 64516 )
389 main.log.info( "Add routes to Quagga on host4" )
390 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
391
392 for i in range( 101, 201 ):
393 prefixesHostX = \
394 main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
395 main.log.info( prefixesHostX )
396 for prefix in prefixesHostX:
397 allRoutesExpected.append(
398 prefix + "/" + "192.168.40." + str( i - 100 ) )
399
400 routeIntentsExpectedHostX = \
401 main.QuaggaCliHost.generateExpectedOnePeerRouteIntents(
402 prefixesHostX, "192.168.40." + str( i - 100 ),
403 "00:00:%02d:00:00:90" % ( i - 101 ), SDNIPJSONFILEPATH )
404 routeIntentsExpected = routeIntentsExpected + \
405 routeIntentsExpectedHostX
406
407 main.log.info( "Login Quagga CLI on host" + str( i ) )
408 QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
409 QuaggaCliHostX.loginQuagga( "1.168.30." + str( i ) )
410 main.log.info(
411 "Enter configuration model of Quagga CLI on host" + str( i ) )
412 QuaggaCliHostX.enterConfig( 65000 + i - 100 )
413 main.log.info( "Add routes to Quagga on host" + str( i ) )
414 QuaggaCliHostX.addRoutes( prefixesHostX, 1 )
415
416 time.sleep( 60 )
417
418 # get routes inside SDN-IP
419 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
420
421 # parse routes from ONOS CLI
422 allRoutesActual = \
423 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
424
425 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
426 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
427 main.step( "Check routes installed" )
428 main.log.info( "Routes expected:" )
429 main.log.info( allRoutesStrExpected )
430 main.log.info( "Routes get from ONOS CLI:" )
431 main.log.info( allRoutesStrActual )
432 utilities.assertEquals(
433 expect=allRoutesStrExpected, actual=allRoutesStrActual,
434 onpass="***Routes in SDN-IP are correct!***",
435 onfail="***Routes in SDN-IP are wrong!***" )
436 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
437 main.log.report(
438 "***Routes in SDN-IP after adding routes are correct!***" )
439 else:
440 main.log.report(
441 "***Routes in SDN-IP after adding routes are wrong!***" )
442
443 time.sleep( 20 )
444 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
445
446 main.step( "Check MultiPointToSinglePointIntent intents installed" )
447 # routeIntentsExpected are generated when generating routes
448 # get rpoute intents from ONOS CLI
449 routeIntentsActual = \
450 main.QuaggaCliHost3.extractActualRouteIntents(
451 getIntentsResult )
452 routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
453 routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" )
454 main.log.info( "MultiPointToSinglePoint intents expected:" )
455 main.log.info( routeIntentsStrExpected )
456 main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" )
457 main.log.info( routeIntentsStrActual )
458 utilities.assertEquals(
459 expect=True,
460 actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
461 onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
462 correct!***",
463 onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
464 wrong!***" )
465
466 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
467 main.log.report(
468 "***MultiPointToSinglePoint Intents before deleting routes \
469 correct!***" )
470 else:
471 main.log.report(
472 "***MultiPointToSinglePoint Intents before deleting routes \
473 wrong!***" )
474
475 main.step( "Check BGP PointToPointIntent intents installed" )
476 # bgp intents expected
477 bgpIntentsExpected = main.QuaggaCliHost3.generateExpectedBgpIntents(
478 SDNIPJSONFILEPATH )
479 # get BGP intents from ONOS CLI
480 bgpIntentsActual = main.QuaggaCliHost3.extractActualBgpIntents(
481 getIntentsResult )
482
483 bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
484 bgpIntentsStrActual = str( bgpIntentsActual )
485 main.log.info( "PointToPointIntent intents expected:" )
486 main.log.info( bgpIntentsStrExpected )
487 main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
488 main.log.info( bgpIntentsStrActual )
489
490 utilities.assertEquals(
491 expect=True,
492 actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
493 onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
494 onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
495
496 if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
497 main.log.report(
498 "***PointToPointIntent Intents in SDN-IP are correct!***" )
499 else:
500 main.log.report(
501 "***PointToPointIntent Intents in SDN-IP are wrong!***" )
502
503 #============================= Ping Test ========================
504 # wait until all MultiPointToSinglePoint
505 time.sleep( 20 )
506 pingTestScript = "~/SDNIP/test-tools/CASE3-ping-as2host.sh"
507 pingTestResultsFile = \
508 "~/SDNIP/SdnIpIntentDemo/log/CASE3-ping-results-before-delete-routes-" \
509 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
510 pingTestResults = main.QuaggaCliHost.pingTest(
511 "1.168.30.100", pingTestScript, pingTestResultsFile )
512 main.log.info( pingTestResults )
513 time.sleep( 20 )
514
515 #============================= Deleting Routes ==================
516 main.step( "Check deleting routes installed" )
517 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
518 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
519 for i in range( 101, 201 ):
520 prefixesHostX = \
521 main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
522 main.log.info( prefixesHostX )
523 QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
524 QuaggaCliHostX.deleteRoutes( prefixesHostX, 1 )
525
526 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
527 allRoutesActual = main.QuaggaCliHost3.extractActualRoutes(
528 getRoutesResult )
529 main.log.info( "allRoutes_actual = " )
530 main.log.info( allRoutesActual )
531
532 utilities.assertEquals(
533 expect="[]", actual=str( allRoutesActual ),
534 onpass="***Route number in SDN-IP is 0, correct!***",
535 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
536
537 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
538 main.log.report(
539 "***Routes in SDN-IP after deleting correct!***" )
540 else:
541 main.log.report(
542 "***Routes in SDN-IP after deleting wrong!***" )
543
544 main.step( "Check intents after deleting routes" )
545 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
546 routeIntentsActual = \
547 main.QuaggaCliHost3.extractActualRouteIntents(
548 getIntentsResult )
549 main.log.info( "main.ONOScli.intents()= " )
550 main.log.info( routeIntentsActual )
551 utilities.assertEquals(
552 expect="[]", actual=str( routeIntentsActual ),
553 onpass="***MultiPointToSinglePoint Intents number in SDN-IP is \
554 0, correct!***",
555 onfail="***MultiPointToSinglePoint Intents number in SDN-IP is \
556 0, wrong!***" )
557
558 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
559 main.log.report(
560 "***MultiPointToSinglePoint Intents after deleting routes \
561 correct!***" )
562 else:
563 main.log.report(
564 "***MultiPointToSinglePoint Intents after deleting routes \
565 wrong!***" )
566
567 time.sleep( 20 )
568 pingTestScript = "~/SDNIP/test-tools/CASE3-ping-as2host.sh"
569 pingTestResultsFile = \
570 "~/SDNIP/SdnIpIntentDemo/log/CASE3-ping-results-after-delete-routes-" \
571 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
572 pingTestResults = main.QuaggaCliHost.pingTest(
573 "1.168.30.100", pingTestScript, pingTestResultsFile )
574 main.log.info( pingTestResults )
575 time.sleep( 100 )
576
577 # main.step( "Test whether Mininet is started" )
578 # main.Mininet2.handle.sendline( "xterm host1" )
579 # main.Mininet2.handle.expect( "mininet>" )
580
581 def CASE1( self, main ):
582 """
583 Test the SDN-IP functionality
584 allRoutesExpected: all expected routes for all BGP peers
585 routeIntentsExpected: all expected MultiPointToSinglePointIntent \
586 intents
587 bgpIntentsExpected: expected PointToPointIntent intents
588 allRoutesActual: all routes from ONOS LCI
589 routeIntentsActual: actual MultiPointToSinglePointIntent intents \
590 from ONOS CLI
591 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
592 """
593 import time
594 import json
595 from operator import eq
596 # from datetime import datetime
597 from time import localtime, strftime
598
599 main.case("The test case is to help to setup the TestON environment \
600 and test new drivers" )
601 SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
602 # all expected routes for all BGP peers
603 allRoutesExpected = []
604 main.step( "Start to generate routes for all BGP peers" )
605 # bgpPeerHosts = []
606 # for i in range( 3, 5 ):
607 # bgpPeerHosts.append( "host" + str( i ) )
608 # main.log.info( "BGP Peer Hosts are:" + bgpPeerHosts )
609
610 # for i in range( 3, 5 ):
611 # QuaggaCliHost = "QuaggaCliHost" + str( i )
612 # prefixes = main.QuaggaCliHost.generatePrefixes( 3, 10 )
613
614 # main.log.info( prefixes )
615 # allRoutesExpected.append( prefixes )
616 main.log.info( "Generate prefixes for host3" )
617 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
618 main.log.info( prefixesHost3 )
619 # generate route with next hop
620 for prefix in prefixesHost3:
621 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
622 routeIntentsExpectedHost3 = \
623 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
624 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
625 SDNIPJSONFILEPATH )
626
627 main.log.info( "Generate prefixes for host4" )
628 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
629 main.log.info( prefixesHost4 )
630 # generate route with next hop
631 for prefix in prefixesHost4:
632 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
633 routeIntentsExpectedHost4 = \
634 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
635 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
636 SDNIPJSONFILEPATH )
637
638 routeIntentsExpected = routeIntentsExpectedHost3 + \
639 routeIntentsExpectedHost4
640
641 cellName = main.params[ 'ENV' ][ 'cellName' ]
642 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
643 main.step( "Set cell for ONOS-cli environment" )
644 main.ONOScli.setCell( cellName )
645 verifyResult = main.ONOSbench.verifyCell()
646 main.log.report( "Removing raft logs" )
647 main.ONOSbench.onosRemoveRaftLogs()
648 main.log.report( "Uninstalling ONOS" )
649 main.ONOSbench.onosUninstall( ONOS1Ip )
650 main.step( "Creating ONOS package" )
651 packageResult = main.ONOSbench.onosPackage()
652
653 main.step( "Starting ONOS service" )
654 # TODO: start ONOS from Mininet Script
655 # startResult = main.ONOSbench.onosStart( "127.0.0.1" )
656 main.step( "Installing ONOS package" )
657 onos1InstallResult = main.ONOSbench.onosInstall(
658 options="-f", node=ONOS1Ip )
659
660 main.step( "Checking if ONOS is up yet" )
661 time.sleep( 60 )
662 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
663 if not onos1Isup:
664 main.log.report( "ONOS1 didn't start!" )
665
666 main.step( "Start ONOS-cli" )
667 # TODO: change the hardcode in startOnosCli method in ONOS CLI driver
668
669 main.ONOScli.startOnosCli( ONOS1Ip )
670
671 main.step( "Get devices in the network" )
672 listResult = main.ONOScli.devices( jsonFormat=False )
673 main.log.info( listResult )
674 time.sleep( 10 )
675 main.log.info( "Installing sdn-ip feature" )
676 main.ONOScli.featureInstall( "onos-app-sdnip" )
677 time.sleep( 10 )
678 main.step( "Login all BGP peers and add routes into peers" )
679 main.log.info( "Login Quagga CLI on host3" )
680 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
681 main.log.info( "Enter configuration model of Quagga CLI on host3" )
682 main.QuaggaCliHost3.enterConfig( 64514 )
683 main.log.info( "Add routes to Quagga on host3" )
684 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
685
686 main.log.info( "Login Quagga CLI on host4" )
687 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
688 main.log.info( "Enter configuration model of Quagga CLI on host4" )
689 main.QuaggaCliHost4.enterConfig( 64516 )
690 main.log.info( "Add routes to Quagga on host4" )
691 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
692 time.sleep( 60 )
693
694 # get all routes inside SDN-IP
695 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
696
697 # parse routes from ONOS CLI
698 allRoutesActual = \
699 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
700
701 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
702 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
703 main.step( "Check routes installed" )
704 main.log.info( "Routes expected:" )
705 main.log.info( allRoutesStrExpected )
706 main.log.info( "Routes get from ONOS CLI:" )
707 main.log.info( allRoutesStrActual )
708 utilities.assertEquals(
709 expect=allRoutesStrExpected, actual=allRoutesStrActual,
710 onpass="***Routes in SDN-IP are correct!***",
711 onfail="***Routes in SDN-IP are wrong!***" )
712 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
713 main.log.report(
714 "***Routes in SDN-IP after adding routes are correct!***" )
715 else:
716 main.log.report(
717 "***Routes in SDN-IP after adding routes are wrong!***" )
718
719 time.sleep( 20 )
720 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
721
722 main.step( "Check MultiPointToSinglePointIntent intents installed" )
723 # routeIntentsExpected are generated when generating routes
724 # get rpoute intents from ONOS CLI
725 routeIntentsActual = \
726 main.QuaggaCliHost3.extractActualRouteIntents(
727 getIntentsResult )
728 routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
729 routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" )
730 main.log.info( "MultiPointToSinglePoint intents expected:" )
731 main.log.info( routeIntentsStrExpected )
732 main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" )
733 main.log.info( routeIntentsStrActual )
734 utilities.assertEquals(
735 expect=True,
736 actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
737 onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
738 correct!***",
739 onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
740 wrong!***" )
741
742 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
743 main.log.report(
744 "***MultiPointToSinglePoint Intents before deleting routes \
745 correct!***" )
746 else:
747 main.log.report(
748 "***MultiPointToSinglePoint Intents before deleting routes \
749 wrong!***" )
750
751 main.step( "Check BGP PointToPointIntent intents installed" )
752 # bgp intents expected
753 bgpIntentsExpected = \
754 main.QuaggaCliHost3.generateExpectedBgpIntents( SDNIPJSONFILEPATH )
755 # get BGP intents from ONOS CLI
756 bgpIntentsActual = main.QuaggaCliHost3.extractActualBgpIntents(
757 getIntentsResult )
758
759 bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
760 bgpIntentsStrActual = str( bgpIntentsActual )
761 main.log.info( "PointToPointIntent intents expected:" )
762 main.log.info( bgpIntentsStrExpected )
763 main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
764 main.log.info( bgpIntentsStrActual )
765
766 utilities.assertEquals(
767 expect=True,
768 actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
769 onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
770 onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
771
772 if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
773 main.log.report(
774 "***PointToPointIntent Intents in SDN-IP are correct!***" )
775 else:
776 main.log.report(
777 "***PointToPointIntent Intents in SDN-IP are wrong!***" )
778
779 #============================= Ping Test ========================
780 # wait until all MultiPointToSinglePoint
781 time.sleep( 20 )
782 pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
783 pingTestResultsFile = \
784 "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-before-delete-routes-" \
785 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
786 pingTestResults = main.QuaggaCliHost.pingTest(
787 "1.168.30.100", pingTestScript, pingTestResultsFile )
788 main.log.info( pingTestResults )
789
790 # ping test
791
792 #============================= Deleting Routes ==================
793 main.step( "Check deleting routes installed" )
794 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
795 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
796
797 # main.log.info( "main.ONOScli.get_routes_num() = " )
798 # main.log.info( main.ONOScli.getRoutesNum() )
799 # utilities.assertEquals( expect="Total SDN-IP routes = 1", actual=
800 # main.ONOScli.getRoutesNum(),
801 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
802 allRoutesActual = \
803 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
804 main.log.info( "allRoutes_actual = " )
805 main.log.info( allRoutesActual )
806
807 utilities.assertEquals(
808 expect="[]", actual=str( allRoutesActual ),
809 onpass="***Route number in SDN-IP is 0, correct!***",
810 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
811
812 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
813 main.log.report(
814 "***Routes in SDN-IP after deleting correct!***" )
815 else:
816 main.log.report(
817 "***Routes in SDN-IP after deleting wrong!***" )
818
819 main.step( "Check intents after deleting routes" )
820 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
821 routeIntentsActual = \
822 main.QuaggaCliHost3.extractActualRouteIntents(
823 getIntentsResult )
824 main.log.info( "main.ONOScli.intents()= " )
825 main.log.info( routeIntentsActual )
826 utilities.assertEquals(
827 expect="[]", actual=str( routeIntentsActual ),
828 onpass="***MultiPointToSinglePoint Intents number in SDN-IP is \
829 0, correct!***",
830 onfail="***MultiPointToSinglePoint Intents number in SDN-IP is \
831 0, wrong!***" )
832
833 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
834 main.log.report(
835 "***MultiPointToSinglePoint Intents after deleting routes \
836 correct!***" )
837 else:
838 main.log.report(
839 "***MultiPointToSinglePoint Intents after deleting routes \
840 wrong!***" )
841
842 time.sleep( 20 )
843 pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
844 pingTestResultsFile = \
845 "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-after-delete-routes-" \
846 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
847 pingTestResults = main.QuaggaCliHost.pingTest(
848 "1.168.30.100", pingTestScript, pingTestResultsFile )
849 main.log.info( pingTestResults )
850 time.sleep( 30 )
851
852 # main.step( "Test whether Mininet is started" )
853 # main.Mininet2.handle.sendline( "xterm host1" )
854 # main.Mininet2.handle.expect( "mininet>" )
855
856 def CASE2( self, main ):
857 """
858 Test the SDN-IP functionality
859 allRoutesExpected: all expected routes for all BGP peers
860 routeIntentsExpected: all expected MultiPointToSinglePointIntent \
861 intents
862 bgpIntentsExpected: expected PointToPointIntent intents
863 allRoutesActual: all routes from ONOS LCI
864 routeIntentsActual: actual MultiPointToSinglePointIntent intents \
865 from ONOS CLI
866 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
867 """
868 import time
869 import json
870 from operator import eq
871 from time import localtime, strftime
872
873 main.case(
874 "The test case is to help to setup the TestON environment and \
875 test new drivers" )
876 SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
877 # all expected routes for all BGP peers
878 allRoutesExpected = []
879 main.step( "Start to generate routes for all BGP peers" )
880
881 main.log.info( "Generate prefixes for host3" )
882 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
883 main.log.info( prefixesHost3 )
884 # generate route with next hop
885 for prefix in prefixesHost3:
886 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
887 routeIntentsExpectedHost3 = \
888 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
889 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
890 SDNIPJSONFILEPATH )
891
892 main.log.info( "Generate prefixes for host4" )
893 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
894 main.log.info( prefixesHost4 )
895 # generate route with next hop
896 for prefix in prefixesHost4:
897 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
898 routeIntentsExpectedHost4 = \
899 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
900 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
901 SDNIPJSONFILEPATH )
902
903 routeIntentsExpected = routeIntentsExpectedHost3 + \
904 routeIntentsExpectedHost4
905
906 main.log.report( "Removing raft logs" )
907 main.ONOSbench.onosRemoveRaftLogs()
908 main.log.report( "Uninstalling ONOS" )
909 main.ONOSbench.onosUninstall( ONOS1Ip )
910
911 cellName = main.params[ 'ENV' ][ 'cellName' ]
912 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
913 main.step( "Set cell for ONOS-cli environment" )
914 main.ONOScli.setCell( cellName )
915 verifyResult = main.ONOSbench.verifyCell()
916 # main.log.report( "Removing raft logs" )
917 # main.ONOSbench.onosRemoveRaftLogs()
918 # main.log.report( "Uninstalling ONOS" )
919 # main.ONOSbench.onosUninstall( ONOS1Ip )
920 main.step( "Creating ONOS package" )
921 # packageResult = main.ONOSbench.onosPackage()
922
923 main.step( "Installing ONOS package" )
924 # onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
925 # node=ONOS1Ip )
926
927 main.step( "Checking if ONOS is up yet" )
928 # time.sleep( 60 )
929 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
930 if not onos1Isup:
931 main.log.report( "ONOS1 didn't start!" )
932
933 main.step( "Start ONOS-cli" )
934 main.ONOScli.startOnosCli( ONOS1Ip )
935
936 main.step( "Get devices in the network" )
937 listResult = main.ONOScli.devices( jsonFormat=False )
938 main.log.info( listResult )
939 time.sleep( 10 )
940 main.log.info( "Installing sdn-ip feature" )
941 main.ONOScli.featureInstall( "onos-app-sdnip" )
942 time.sleep( 10 )
943
944 main.step( "Check BGP PointToPointIntent intents installed" )
945 # bgp intents expected
946 bgpIntentsExpected = main.QuaggaCliHost3.generateExpectedBgpIntents(
947 SDNIPJSONFILEPATH )
948 # get BGP intents from ONOS CLI
949 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
950 bgpIntentsActual = main.QuaggaCliHost3.extractActualBgpIntents(
951 getIntentsResult )
952
953 bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
954 bgpIntentsStrActual = str( bgpIntentsActual )
955 main.log.info( "PointToPointIntent intents expected:" )
956 main.log.info( bgpIntentsStrExpected )
957 main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
958 main.log.info( bgpIntentsStrActual )
959
960 utilities.assertEquals(
961 expect=True,
962 actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
963 onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
964 onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
965
966 if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
967 main.log.report(
968 "***PointToPointIntent Intents in SDN-IP are correct!***" )
969 else:
970 main.log.report(
971 "***PointToPointIntent Intents in SDN-IP are wrong!***" )
972
973 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
974 routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
975 pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
976 # roundNum = 0;
977 # while( True ):
978 for roundNum in range( 1, 6 ):
979 # round = round + 1;
980 main.log.report( "The Round " + str( roundNum ) +
981 " test starts................................" )
982
983 main.step( "Login all BGP peers and add routes into peers" )
984 main.log.info( "Login Quagga CLI on host3" )
985 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
986 main.log.info(
987 "Enter configuration model of Quagga CLI on host3" )
988 main.QuaggaCliHost3.enterConfig( 64514 )
989 main.log.info( "Add routes to Quagga on host3" )
990 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
991
992 main.log.info( "Login Quagga CLI on host4" )
993 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
994 main.log.info(
995 "Enter configuration model of Quagga CLI on host4" )
996 main.QuaggaCliHost4.enterConfig( 64516 )
997 main.log.info( "Add routes to Quagga on host4" )
998 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
999 time.sleep( 60 )
1000
1001 # get all routes inside SDN-IP
1002 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1003
1004 # parse routes from ONOS CLI
1005 allRoutesActual = \
1006 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1007
1008 # allRoutesStrExpected = str( sorted( allRoutesExpected ) )
1009 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
1010 main.step( "Check routes installed" )
1011 main.log.info( "Routes expected:" )
1012 main.log.info( allRoutesStrExpected )
1013 main.log.info( "Routes get from ONOS CLI:" )
1014 main.log.info( allRoutesStrActual )
1015 utilities.assertEquals(
1016 expect=allRoutesStrExpected, actual=allRoutesStrActual,
1017 onpass="***Routes in SDN-IP are correct!***",
1018 onfail="***Routes in SDN-IP are wrong!***" )
1019 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1020 main.log.report(
1021 "***Routes in SDN-IP after adding correct!***" )
1022 else:
1023 main.log.report(
1024 "***Routes in SDN-IP after adding wrong!***" )
1025
1026 time.sleep( 20 )
1027 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
1028
1029 main.step(
1030 "Check MultiPointToSinglePointIntent intents installed" )
1031 # routeIntentsExpected are generated when generating routes
1032 # get route intents from ONOS CLI
1033 routeIntentsActual = \
1034 main.QuaggaCliHost3.extractActualRouteIntents(
1035 getIntentsResult )
1036 # routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
1037 routeIntentsStrActual = str(
1038 routeIntentsActual ).replace( 'u', "" )
1039 main.log.info( "MultiPointToSinglePoint intents expected:" )
1040 main.log.info( routeIntentsStrExpected )
1041 main.log.info(
1042 "MultiPointToSinglePoint intents get from ONOS CLI:" )
1043 main.log.info( routeIntentsStrActual )
1044 utilities.assertEquals(
1045 expect=True,
1046 actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
1047 onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
1048 correct!***",
1049 onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
1050 wrong!***" )
1051
1052 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
1053 main.log.report(
1054 "***MultiPointToSinglePoint Intents after adding routes \
1055 correct!***" )
1056 else:
1057 main.log.report(
1058 "***MultiPointToSinglePoint Intents after adding routes \
1059 wrong!***" )
1060
1061 #============================= Ping Test ========================
1062 # wait until all MultiPointToSinglePoint
1063 time.sleep( 20 )
1064 # pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
1065 pingTestResultsFile = \
1066 "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" \
1067 + str( roundNum ) + "-ping-results-before-delete-routes-" \
1068 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
1069 pingTestResults = main.QuaggaCliHost.pingTest(
1070 "1.168.30.100", pingTestScript, pingTestResultsFile )
1071 main.log.info( pingTestResults )
1072 # ping test
1073
1074 #============================= Deleting Routes ==================
1075 main.step( "Check deleting routes installed" )
1076 main.log.info( "Delete routes to Quagga on host3" )
1077 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
1078 main.log.info( "Delete routes to Quagga on host4" )
1079 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
1080
1081 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1082 allRoutesActual = \
1083 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1084 main.log.info( "allRoutes_actual = " )
1085 main.log.info( allRoutesActual )
1086
1087 utilities.assertEquals(
1088 expect="[]", actual=str( allRoutesActual ),
1089 onpass="***Route number in SDN-IP is 0, correct!***",
1090 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
1091
1092 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1093 main.log.report(
1094 "***Routes in SDN-IP after deleting correct!***" )
1095 else:
1096 main.log.report(
1097 "***Routes in SDN-IP after deleting wrong!***" )
1098
1099 main.step( "Check intents after deleting routes" )
1100 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
1101 routeIntentsActual = \
1102 main.QuaggaCliHost3.extractActualRouteIntents(
1103 getIntentsResult )
1104 main.log.info( "main.ONOScli.intents()= " )
1105 main.log.info( routeIntentsActual )
1106 utilities.assertEquals(
1107 expect="[]", actual=str( routeIntentsActual ),
1108 onpass=
1109 "***MultiPointToSinglePoint Intents number in SDN-IP \
1110 is 0, correct!***",
1111 onfail="***MultiPointToSinglePoint Intents number in SDN-IP \
1112 is 0, wrong!***" )
1113
1114 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
1115 main.log.report(
1116 "***MultiPointToSinglePoint Intents after deleting \
1117 routes correct!***" )
1118 else:
1119 main.log.report(
1120 "***MultiPointToSinglePoint Intents after deleting \
1121 routes wrong!***" )
1122
1123 time.sleep( 20 )
1124 # pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
1125 pingTestResultsFile = \
1126 "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" \
1127 + str( roundNum ) + "-ping-results-after-delete-routes-" \
1128 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
1129 pingTestResults = main.QuaggaCliHost.pingTest(
1130 "1.168.30.100", pingTestScript, pingTestResultsFile )
1131 main.log.info( pingTestResults )
1132 time.sleep( 30 )
1133