blob: a3ea9c328da808836716463a34e89a1875f5299e [file] [log] [blame]
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001# from cupshelpers.config import prefix
2
sanghoshina96f1e72015-02-27 09:30:56 -08003# Testing the basic functionality of SDN-IP
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08004
5
6class PeeringRouterTest:
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 PeeringRouterTest:
17
18 def __init__( self ):
19 self.default = ''
20
sanghoshin29e6a472015-02-27 12:55:06 -080021 def CASE6 (self, main):
22 import time
23 import json
24 from operator import eq
25 # from datetime import datetime
26 from time import localtime, strftime
27
28 #============================= Ping Test ========================
29 main.log.info("Start ping test")
30 pingTestResults = main.QuaggaCliHost.pingTestAndCheck(
31 "1.168.30.100" )
32 main.log.info("Ping test result")
33 if pingTestResults:
34 main.log.info("Test succeeded")
35 else:
36 main.log.info("Test failed")
37
38 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
39 onpass="Default connectivity check PASS",
40 onfail="Default connectivity check FAIL")
41
42
43 def CASE4( self, main):
44 import time
45 import json
46 from operator import eq
47 # from datetime import datetime
48 from time import localtime, strftime
49
50 main.case("The test case is to help to setup the TestON environment \
51 and test new drivers" )
Srikanth Vavilapallicf1cd5b2015-02-27 17:19:12 -080052 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
53 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/mininet"
54 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json"
55 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
sanghoshin43dbcfb2015-03-02 12:02:40 -080056
57 # Copy the json files to config dir
58 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/addresses.json ~/onos/tools/package/config/")
59 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/sdnip.json ~/onos/tools/package/config/")
60
Srikanth Vavilapallicf1cd5b2015-02-27 17:19:12 -080061 # Launch mininet topology for this case
62 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininet.py"
63 main.step( "Launch mininet" )
64 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
65 main.step("waiting 20 secs for all switches and quagga instances to comeup")
66 time.sleep(20)
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -080067 main.step( "Test whether Mininet is started" )
Srikanth Vavilapallicf1cd5b2015-02-27 17:19:12 -080068 main.log.info( "Login Quagga CLI on host3" )
69 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
sanghoshin29e6a472015-02-27 12:55:06 -080070 # all expected routes for all BGP peers
71 allRoutesExpected = []
72 main.step( "Start to generate routes for all BGP peers" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -080073
sanghoshin29e6a472015-02-27 12:55:06 -080074 main.log.info( "Generate prefixes for host3" )
75 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
76 main.log.info( prefixesHost3 )
77 # generate route with next hop
78 for prefix in prefixesHost3:
79 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
80 routeIntentsExpectedHost3 = \
81 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
82 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
83 SDNIPJSONFILEPATH )
84
85 main.log.info( "Generate prefixes for host4" )
86 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
87 main.log.info( prefixesHost4 )
sanghoshin29e6a472015-02-27 12:55:06 -080088 # generate route with next hop
89 for prefix in prefixesHost4:
90 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
91 routeIntentsExpectedHost4 = \
92 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
93 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
94 SDNIPJSONFILEPATH )
95
96 main.log.info( "Generate prefixes for host5" )
97 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
98 main.log.info( prefixesHost5 )
99 for prefix in prefixesHost5:
100 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
101 routeIntentsExpectedHost5 = \
102 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
103 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
104 SDNIPJSONFILEPATH )
105
106 routeIntentsExpected = routeIntentsExpectedHost3 + \
107 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
108
109 cellName = main.params[ 'ENV' ][ 'cellName' ]
110 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
111 main.step( "Set cell for ONOS-cli environment" )
112 main.ONOScli.setCell( cellName )
113 verifyResult = main.ONOSbench.verifyCell()
114
115 main.log.report( "Removing raft logs" )
116 main.ONOSbench.onosRemoveRaftLogs()
117 main.log.report( "Uninstalling ONOS" )
118 main.ONOSbench.onosUninstall( ONOS1Ip )
119
120 main.step( "Installing ONOS package" )
121 onos1InstallResult = main.ONOSbench.onosInstall(
122 options="-f", node=ONOS1Ip )
123
124 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
125 if not onos1Isup:
126 main.log.report( "ONOS1 didn't start!" )
127
128 main.step( "Start ONOS-cli" )
129
130 main.ONOScli.startOnosCli( ONOS1Ip )
131
132 main.step( "Get devices in the network" )
133 listResult = main.ONOScli.devices( jsonFormat=False )
134 main.log.info( listResult )
135 time.sleep( 10 )
sanghoshin43dbcfb2015-03-02 12:02:40 -0800136 main.log.info( "Installing bgprouter feature" )
sanghoshin29e6a472015-02-27 12:55:06 -0800137 main.ONOScli.featureInstall( "onos-app-bgprouter" )
138 time.sleep( 10 )
139 main.step( "Login all BGP peers and add routes into peers" )
140
141 main.log.info( "Login Quagga CLI on host3" )
142 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
143 main.log.info( "Enter configuration model of Quagga CLI on host3" )
144 main.QuaggaCliHost3.enterConfig( 64514 )
145 main.log.info( "Add routes to Quagga on host3" )
146 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
147
148 main.log.info( "Login Quagga CLI on host4" )
149 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
150 main.log.info( "Enter configuration model of Quagga CLI on host4" )
151 main.QuaggaCliHost4.enterConfig( 64516 )
152 main.log.info( "Add routes to Quagga on host4" )
153 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
154
155 main.log.info( "Login Quagga CLI on host5" )
156 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
157 main.log.info( "Enter configuration model of Quagga CLI on host5" )
158 main.QuaggaCliHost5.enterConfig( 64521 )
159 main.log.info( "Add routes to Quagga on host5" )
160 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
161
sanghoshin43dbcfb2015-03-02 12:02:40 -0800162 time.sleep( 30 )
sanghoshin29e6a472015-02-27 12:55:06 -0800163
164 # get routes inside SDN-IP
165 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
166
167 # parse routes from ONOS CLI
sanghoshine35a8a52015-02-27 20:47:26 -0800168 allRoutesActual = \
169 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
sanghoshin29e6a472015-02-27 12:55:06 -0800170
171 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
172 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
173 main.step( "Check routes installed" )
174 main.log.info( "Routes expected:" )
175 main.log.info( allRoutesStrExpected )
176 main.log.info( "Routes get from ONOS CLI:" )
177 main.log.info( allRoutesStrActual )
178 utilities.assertEquals(
179 expect=allRoutesStrExpected, actual=allRoutesStrActual,
180 onpass="***Routes in SDN-IP are correct!***",
181 onfail="***Routes in SDN-IP are wrong!***" )
182 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
183 main.log.report(
184 "***Routes in SDN-IP after adding routes are correct!***" )
185 else:
186 main.log.report(
187 "***Routes in SDN-IP after adding routes are wrong!***" )
188
189 #============================= Ping Test ========================
190 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
191 main.log.info("Ping test result")
192 if pingTestResults:
193 main.log.info("Test succeeded")
194 else:
195 main.log.info("Test failed")
196
197 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
198 onpass="Default connectivity check PASS",
199 onfail="Default connectivity check FAIL")
200
201 #============================= Deleting Routes ==================
202 main.step( "Check deleting routes installed" )
203 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
204 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
205 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
206
207 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
sanghoshine35a8a52015-02-27 20:47:26 -0800208 allRoutesActual = \
209 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
sanghoshin29e6a472015-02-27 12:55:06 -0800210
211 main.log.info( "allRoutes_actual = " )
212 main.log.info( allRoutesActual )
213
214 utilities.assertEquals(
215 expect="[]", actual=str( allRoutesActual ),
216 onpass="***Route number in SDN-IP is 0, correct!***",
217 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
218
219 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
220 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
221 else:
222 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
223
224 #============================= Ping Test ========================
225 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
226 main.log.info("Ping test result")
227 if pingTestResults:
228 main.log.info("Test succeeded")
229 else:
230 main.log.info("Test failed")
231
232 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
233 onpass="disconnect check PASS",
234 onfail="disconnect check FAIL")
235
Srikanth Vavilapallicf1cd5b2015-02-27 17:19:12 -0800236 main.ONOScli.disconnect()
237 main.ONOSbench.onosStop(ONOS1Ip);
sanghoshin43dbcfb2015-03-02 12:02:40 -0800238 main.Mininet.stopNet()
239 time.sleep(10)
Srikanth Vavilapallicf1cd5b2015-02-27 17:19:12 -0800240
sanghoshin29e6a472015-02-27 12:55:06 -0800241 def CASE5( self, main ):
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800242 """
243 Test the SDN-IP functionality
244 allRoutesExpected: all expected routes for all BGP peers
245 routeIntentsExpected: all expected MultiPointToSinglePointIntent \
246 intents
247 bgpIntentsExpected: expected PointToPointIntent intents
248 allRoutesActual: all routes from ONOS LCI
249 routeIntentsActual: actual MultiPointToSinglePointIntent intents from \
250 ONOS CLI
251 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
252 """
253 import time
254 import json
255 from operator import eq
256 # from datetime import datetime
257 from time import localtime, strftime
258
259 main.case("The test case is to help to setup the TestON environment \
260 and test new drivers" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800261 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
262 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/mininet"
263 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json"
264 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800265 # all expected routes for all BGP peers
266 allRoutesExpected = []
267 main.step( "Start to generate routes for all BGP peers" )
268 main.log.info( "Generate prefixes for host3" )
269 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
270 main.log.info( prefixesHost3 )
271 # generate route with next hop
272 for prefix in prefixesHost3:
273 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
274 routeIntentsExpectedHost3 = \
275 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
276 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
277 SDNIPJSONFILEPATH )
278
279 main.log.info( "Generate prefixes for host4" )
280 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
281 main.log.info( prefixesHost4 )
282 # generate route with next hop
283 for prefix in prefixesHost4:
284 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
285 routeIntentsExpectedHost4 = \
286 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
287 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
288 SDNIPJSONFILEPATH )
289
290 main.log.info( "Generate prefixes for host5" )
291 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
292 main.log.info( prefixesHost5 )
293 for prefix in prefixesHost5:
294 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
295 routeIntentsExpectedHost5 = \
296 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
297 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
298 SDNIPJSONFILEPATH )
299
300 routeIntentsExpected = routeIntentsExpectedHost3 + \
301 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
302
303 cellName = main.params[ 'ENV' ][ 'cellName' ]
304 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
305 main.step( "Set cell for ONOS-cli environment" )
306 main.ONOScli.setCell( cellName )
307 verifyResult = main.ONOSbench.verifyCell()
308
309 main.log.report( "Removing raft logs" )
310 main.ONOSbench.onosRemoveRaftLogs()
311 main.log.report( "Uninstalling ONOS" )
312 main.ONOSbench.onosUninstall( ONOS1Ip )
313
314 main.step( "Installing ONOS package" )
315 onos1InstallResult = main.ONOSbench.onosInstall(
316 options="-f", node=ONOS1Ip )
317
318 main.step( "Checking if ONOS is up yet" )
sanghoshina96f1e72015-02-27 09:30:56 -0800319 time.sleep( 20 )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800320 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
321 if not onos1Isup:
322 main.log.report( "ONOS1 didn't start!" )
323
324 main.step( "Start ONOS-cli" )
325
326 main.ONOScli.startOnosCli( ONOS1Ip )
327
328 main.step( "Get devices in the network" )
329 listResult = main.ONOScli.devices( jsonFormat=False )
330 main.log.info( listResult )
331 time.sleep( 10 )
sanghoshina96f1e72015-02-27 09:30:56 -0800332 main.log.info( "Installing gbprouter feature" )
333 main.ONOScli.featureInstall( "onos-app-bgprouter" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800334 time.sleep( 10 )
335 main.step( "Login all BGP peers and add routes into peers" )
336
337 main.log.info( "Login Quagga CLI on host3" )
338 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
339 main.log.info( "Enter configuration model of Quagga CLI on host3" )
340 main.QuaggaCliHost3.enterConfig( 64514 )
341 main.log.info( "Add routes to Quagga on host3" )
342 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
343
344 main.log.info( "Login Quagga CLI on host4" )
345 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
346 main.log.info( "Enter configuration model of Quagga CLI on host4" )
347 main.QuaggaCliHost4.enterConfig( 64516 )
348 main.log.info( "Add routes to Quagga on host4" )
349 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
350
351 main.log.info( "Login Quagga CLI on host5" )
352 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
353 main.log.info( "Enter configuration model of Quagga CLI on host5" )
354 main.QuaggaCliHost5.enterConfig( 64521 )
355 main.log.info( "Add routes to Quagga on host5" )
356 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
357
sanghoshin29e6a472015-02-27 12:55:06 -0800358 #time.sleep( 30 )
359 time.sleep(10)
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800360
361 # get routes inside SDN-IP
362 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
363
364 # parse routes from ONOS CLI
sanghoshin29e6a472015-02-27 12:55:06 -0800365 # allRoutesActual = \
366 # main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
367 allRoutesActual = []
368 main.log.info("allRoutesExpected")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800369
370 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
371 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
372 main.step( "Check routes installed" )
373 main.log.info( "Routes expected:" )
374 main.log.info( allRoutesStrExpected )
375 main.log.info( "Routes get from ONOS CLI:" )
376 main.log.info( allRoutesStrActual )
377 utilities.assertEquals(
378 expect=allRoutesStrExpected, actual=allRoutesStrActual,
379 onpass="***Routes in SDN-IP are correct!***",
380 onfail="***Routes in SDN-IP are wrong!***" )
381 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
382 main.log.report(
383 "***Routes in SDN-IP after adding routes are correct!***" )
384 else:
385 main.log.report(
386 "***Routes in SDN-IP after adding routes are wrong!***" )
387
sanghoshin29e6a472015-02-27 12:55:06 -0800388 #time.sleep( 20 )
389 #getIntentsResult = main.ONOScli.intents( jsonFormat=True )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800390
sanghoshin29e6a472015-02-27 12:55:06 -0800391 #main.step( "Check MultiPointToSinglePointIntent intents installed" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800392 # routeIntentsExpected are generated when generating routes
393 # get rpoute intents from ONOS CLI
sanghoshin29e6a472015-02-27 12:55:06 -0800394 #routeIntentsActual = \
395 # main.QuaggaCliHost3.extractActualRouteIntents(
396 # getIntentsResult )
397 #routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
398 #routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" )
399 #main.log.info( "MultiPointToSinglePoint intents expected:" )
400 #main.log.info( routeIntentsStrExpected )
401 #main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" )
402 #main.log.info( routeIntentsStrActual )
403 #utilities.assertEquals(
404 # expect=True,
405 # actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
406 # onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
407 # correct!***",
408 # onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
409 # wrong!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800410
sanghoshin29e6a472015-02-27 12:55:06 -0800411 #if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
412 # main.log.report( "***MultiPointToSinglePoint Intents before \
413 # deleting routes correct!***" )
414 #else:
415 # main.log.report( "***MultiPointToSinglePoint Intents before \
416 # deleting routes wrong!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800417
sanghoshin29e6a472015-02-27 12:55:06 -0800418 #main.step( "Check BGP PointToPointIntent intents installed" )
419 ## bgp intents expected
420 #bgpIntentsExpected = \
421 # main.QuaggaCliHost3.generateExpectedBgpIntents( SDNIPJSONFILEPATH )
422 ## get BGP intents from ONOS CLI
423 #bgpIntentsActual = \
424 # main.QuaggaCliHost3.extractActualBgpIntents( getIntentsResult )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800425
sanghoshin29e6a472015-02-27 12:55:06 -0800426 #bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
427 #bgpIntentsStrActual = str( bgpIntentsActual )
428 #main.log.info( "PointToPointIntent intents expected:" )
429 #main.log.info( bgpIntentsStrExpected )
430 #main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
431 #main.log.info( bgpIntentsStrActual )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800432
sanghoshin29e6a472015-02-27 12:55:06 -0800433 #utilities.assertEquals(
434 # expect=True,
435 # actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
436 # onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
437 # onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800438
sanghoshin29e6a472015-02-27 12:55:06 -0800439 #if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
440 # main.log.report(
441 # "***PointToPointIntent Intents in SDN-IP are correct!***" )
442 #else:
443 # main.log.report(
444 # "***PointToPointIntent Intents in SDN-IP are wrong!***" )
sanghoshina96f1e72015-02-27 09:30:56 -0800445
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800446 #============================= Ping Test ========================
447 # wait until all MultiPointToSinglePoint
sanghoshin29e6a472015-02-27 12:55:06 -0800448 time.sleep( 10 )
449 main.log.info("Start ping test")
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800450 pingTestScript = TESTCASE_ROOT_PATH + "CASE4-ping-as2host.sh"
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800451 pingTestResultsFile = \
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800452 TESTCASE_ROOT_PATH + "CASE4-ping-results-before-delete-routes-" \
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800453 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
454 pingTestResults = main.QuaggaCliHost.pingTest(
455 "1.168.30.100", pingTestScript, pingTestResultsFile )
sanghoshin29e6a472015-02-27 12:55:06 -0800456 main.log.info("Ping test result")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800457 main.log.info( pingTestResults )
sanghoshin29e6a472015-02-27 12:55:06 -0800458 time.sleep( 10 )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800459
460 #============================= Deleting Routes ==================
461 main.step( "Check deleting routes installed" )
462 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
463 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
464 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
465
466 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
sanghoshin29e6a472015-02-27 12:55:06 -0800467 # FIX ME
468 #allRoutesActual = \
469 # main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
470 allRoutesActual = []
471
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800472 main.log.info( "allRoutes_actual = " )
473 main.log.info( allRoutesActual )
474
475 utilities.assertEquals(
476 expect="[]", actual=str( allRoutesActual ),
477 onpass="***Route number in SDN-IP is 0, correct!***",
478 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
479
480 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
481 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
482 else:
483 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
484
sanghoshin29e6a472015-02-27 12:55:06 -0800485 #main.step( "Check intents after deleting routes" )
486 #getIntentsResult = main.ONOScli.intents( jsonFormat=True )
487 #routeIntentsActual = \
488 # main.QuaggaCliHost3.extractActualRouteIntents(
489 # getIntentsResult )
490 #main.log.info( "main.ONOScli.intents()= " )
491 #main.log.info( routeIntentsActual )
492 #utilities.assertEquals(
493 # expect="[]", actual=str( routeIntentsActual ),
494 # onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, \
495 # correct!***",
496 # onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, \
497 # wrong!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800498
sanghoshin29e6a472015-02-27 12:55:06 -0800499 #if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
500 # main.log.report( "***MultiPointToSinglePoint Intents after \
501 # deleting routes correct!***" )
502 #else:
503 # main.log.report( "***MultiPointToSinglePoint Intents after \
504 # deleting routes wrong!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800505
sanghoshin29e6a472015-02-27 12:55:06 -0800506 time.sleep( 10 )
507 main.log.info("Ping test after removing routs")
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800508 pingTestScript = TESTCASE_ROOT_PATH + "CASE4-ping-as2host.sh"
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800509 pingTestResultsFile = \
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800510 TESTCASE_ROOT_PATH + "CASE4-ping-results-after-delete-routes-" \
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800511 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
512 pingTestResults = main.QuaggaCliHost.pingTest(
513 "1.168.30.100", pingTestScript, pingTestResultsFile )
sanghoshin29e6a472015-02-27 12:55:06 -0800514 main.log.info("Ping test results")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800515 main.log.info( pingTestResults )
sanghoshin29e6a472015-02-27 12:55:06 -0800516 time.sleep( 10 )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800517
518 # main.step( "Test whether Mininet is started" )
519 # main.Mininet2.handle.sendline( "xterm host1" )
520 # main.Mininet2.handle.expect( "mininet>" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800521 main.ONOScli.disconnect()
522 main.ONOSbench.onosStop(ONOS1Ip);
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800523
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800524 # Route convergence and connectivity test
525 def CASE21( self, main):
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800526 import time
527 import json
528 from operator import eq
529 # from datetime import datetime
530 from time import localtime, strftime
531
532 main.case("The test case is to help to setup the TestON environment \
533 and test new drivers" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800534 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
535 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/routeconvergence/mininet"
536 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json"
537 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
sanghoshin43dbcfb2015-03-02 12:02:40 -0800538
539 # Copy the json files to config dir
540 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/addresses.json ~/onos/tools/package/config/")
541 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/sdnip.json ~/onos/tools/package/config/")
542
543 # Launch mininet topology for this case
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800544 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterConvergenceMininet.py"
545 main.step( "Launch mininet" )
546 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
547 main.step("waiting 20 secs for all switches and quagga instances to comeup")
548 time.sleep(20)
549 main.step( "Test whether Mininet is started" )
550 main.log.info( "Login Quagga CLI on host3" )
551 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800552 # all expected routes for all BGP peers
553 allRoutesExpected = []
554 main.step( "Start to generate routes for all BGP peers" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800555 main.log.info( "Generate prefixes for host3" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800556
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800557 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
558 main.log.info( prefixesHost3 )
559 # generate route with next hop
560 for prefix in prefixesHost3:
561 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
562 routeIntentsExpectedHost3 = \
563 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
564 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
565 SDNIPJSONFILEPATH )
566
567 main.log.info( "Generate prefixes for host4" )
568 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
569 main.log.info( prefixesHost4 )
570 # generate route with next hop
571 for prefix in prefixesHost4:
572 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
573 routeIntentsExpectedHost4 = \
574 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
575 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
576 SDNIPJSONFILEPATH )
577
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800578 main.log.info( "Generate prefixes for host5" )
579 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
580 main.log.info( prefixesHost5 )
581 for prefix in prefixesHost5:
582 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
583 routeIntentsExpectedHost5 = \
584 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
585 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
586 SDNIPJSONFILEPATH )
587
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800588 routeIntentsExpected = routeIntentsExpectedHost3 + \
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800589 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800590
591 cellName = main.params[ 'ENV' ][ 'cellName' ]
592 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
593 main.step( "Set cell for ONOS-cli environment" )
594 main.ONOScli.setCell( cellName )
595 verifyResult = main.ONOSbench.verifyCell()
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800596
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800597 main.log.report( "Removing raft logs" )
598 main.ONOSbench.onosRemoveRaftLogs()
599 main.log.report( "Uninstalling ONOS" )
600 main.ONOSbench.onosUninstall( ONOS1Ip )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800601
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800602 main.step( "Installing ONOS package" )
603 onos1InstallResult = main.ONOSbench.onosInstall(
604 options="-f", node=ONOS1Ip )
605
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800606 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
607 if not onos1Isup:
608 main.log.report( "ONOS1 didn't start!" )
609
610 main.step( "Start ONOS-cli" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800611
612 main.ONOScli.startOnosCli( ONOS1Ip )
613
614 main.step( "Get devices in the network" )
615 listResult = main.ONOScli.devices( jsonFormat=False )
616 main.log.info( listResult )
617 time.sleep( 10 )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800618 main.log.info( "Installing gbprouter feature" )
619 main.ONOScli.featureInstall( "onos-app-bgprouter" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800620 time.sleep( 10 )
621 main.step( "Login all BGP peers and add routes into peers" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800622
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800623 main.log.info( "Login Quagga CLI on host3" )
624 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
625 main.log.info( "Enter configuration model of Quagga CLI on host3" )
626 main.QuaggaCliHost3.enterConfig( 64514 )
627 main.log.info( "Add routes to Quagga on host3" )
628 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
629
630 main.log.info( "Login Quagga CLI on host4" )
631 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
632 main.log.info( "Enter configuration model of Quagga CLI on host4" )
633 main.QuaggaCliHost4.enterConfig( 64516 )
634 main.log.info( "Add routes to Quagga on host4" )
635 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800636
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800637 main.log.info( "Login Quagga CLI on host5" )
638 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
639 main.log.info( "Enter configuration model of Quagga CLI on host5" )
640 main.QuaggaCliHost5.enterConfig( 64521 )
641 main.log.info( "Add routes to Quagga on host5" )
642 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
643
sanghoshin43dbcfb2015-03-02 12:02:40 -0800644 time.sleep( 30 )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800645
646 # get routes inside SDN-IP
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800647 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
648
649 # parse routes from ONOS CLI
650 allRoutesActual = \
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800651 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800652
653 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
654 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
655 main.step( "Check routes installed" )
656 main.log.info( "Routes expected:" )
657 main.log.info( allRoutesStrExpected )
658 main.log.info( "Routes get from ONOS CLI:" )
659 main.log.info( allRoutesStrActual )
660 utilities.assertEquals(
661 expect=allRoutesStrExpected, actual=allRoutesStrActual,
662 onpass="***Routes in SDN-IP are correct!***",
663 onfail="***Routes in SDN-IP are wrong!***" )
664 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
665 main.log.report(
666 "***Routes in SDN-IP after adding routes are correct!***" )
667 else:
668 main.log.report(
669 "***Routes in SDN-IP after adding routes are wrong!***" )
670
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800671 #============================= Ping Test ========================
672 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
673 main.log.info("Ping test result")
674 if pingTestResults:
675 main.log.info("Test succeeded")
676 else:
677 main.log.info("Test failed")
678
679 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
680 onpass="Default connectivity check PASS",
681 onfail="Default connectivity check FAIL")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800682
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800683 #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ==================
684 main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
685 main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" )
686 main.log.info( "Sleeping for 150 seconds for network to converge" )
687 time.sleep(150)
688 # get routes inside SDN-IP
689 main.log.info( "Getting Routes from ONOS CLI" )
690 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
691
692 # parse routes from ONOS CLI
693 newAllRoutesActual = \
694 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
695 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
696
697 # Expected routes with changed next hop
698 newAllRoutesExpected = []
699 for prefix in prefixesHost3:
700 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
701 for prefix in prefixesHost4:
702 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
703 for prefix in prefixesHost5:
704 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
705 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
706 main.step( "Check routes installed after convergence-1" )
707 main.log.info( "Routes expected:" )
708 main.log.info( newAllRoutesStrExpected )
709 main.log.info( "Routes got from ONOS CLI after convergence-1:" )
710 main.log.info( newAllRoutesStrActual )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800711 utilities.assertEquals(
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800712 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
713 onpass="***Routes in SDN-IP are correct after convergence!***",
714 onfail="***Routes in SDN-IP are wrong after convergence!***" )
715 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800716 main.log.report(
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800717 "***Routes in SDN-IP after convergence are correct!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800718 else:
719 main.log.report(
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800720 "***Routes in SDN-IP after convergence are wrong!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800721
722 #============================= Ping Test ========================
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800723 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
724 main.log.info("Ping test result")
725 if pingTestResults:
726 main.log.info("Test succeeded")
727 else:
728 main.log.info("Test failed")
729
730 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
731 onpass="Default connectivity check PASS",
732 onfail="Default connectivity check FAIL")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800733
734 #============================= Deleting Routes ==================
735 main.step( "Check deleting routes installed" )
736 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
737 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800738 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800739
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800740 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
741 allRoutesActual = \
742 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800743
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800744 main.log.info( "allRoutes_actual = " )
745 main.log.info( allRoutesActual )
746
747 utilities.assertEquals(
748 expect="[]", actual=str( allRoutesActual ),
749 onpass="***Route number in SDN-IP is 0, correct!***",
750 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
751
752 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800753 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800754 else:
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800755 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800756
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800757 #============================= Ping Test ========================
758 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
759 main.log.info("Ping test result")
760 if pingTestResults:
761 main.log.info("Test succeeded")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800762 else:
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800763 main.log.info("Test failed")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800764
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800765 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
766 onpass="disconnect check PASS",
767 onfail="disconnect check FAIL")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800768
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800769 main.ONOScli.disconnect()
770 main.ONOSbench.onosStop(ONOS1Ip);
sanghoshin43dbcfb2015-03-02 12:02:40 -0800771 main.Mininet.stopNet()
772 time.sleep(10)
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800773