blob: 79230f3842ce2f3af5e07bfd4a77a6443d322001 [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
sanghoshinc59d6c52015-03-03 10:01:07 -0800236 main.ONOScli.logout()
Srikanth Vavilapallicf1cd5b2015-02-27 17:19:12 -0800237 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 import time
243 import json
244 from operator import eq
245 # from datetime import datetime
246 from time import localtime, strftime
247
248 main.case("The test case is to help to setup the TestON environment \
249 and test new drivers" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800250 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
sanghoshin5f3e7cb2015-03-04 18:07:21 -0800251 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/mininet"
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800252 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json"
253 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
sanghoshin3de90272015-03-03 16:10:04 -0800254
255 # Copy the json files to config dir
256 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/addresses.json ~/onos/tools/package/config/")
257 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/sdnip.json ~/onos/tools/package/config/")
258
259 # Launch mininet topology for this case
260 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininetVlan.py"
261 main.step( "Launch mininet" )
262 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
263 main.step("waiting 20 secs for all switches and quagga instances to comeup")
264 time.sleep(20)
265 main.step( "Test whether Mininet is started" )
266 main.log.info( "Login Quagga CLI on host3" )
267 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800268 # all expected routes for all BGP peers
269 allRoutesExpected = []
270 main.step( "Start to generate routes for all BGP peers" )
sanghoshin3de90272015-03-03 16:10:04 -0800271
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800272 main.log.info( "Generate prefixes for host3" )
273 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
274 main.log.info( prefixesHost3 )
275 # generate route with next hop
276 for prefix in prefixesHost3:
277 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
278 routeIntentsExpectedHost3 = \
279 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
280 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
281 SDNIPJSONFILEPATH )
282
283 main.log.info( "Generate prefixes for host4" )
284 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
285 main.log.info( prefixesHost4 )
286 # generate route with next hop
287 for prefix in prefixesHost4:
288 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
289 routeIntentsExpectedHost4 = \
290 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
291 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
292 SDNIPJSONFILEPATH )
293
294 main.log.info( "Generate prefixes for host5" )
295 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
296 main.log.info( prefixesHost5 )
297 for prefix in prefixesHost5:
298 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
299 routeIntentsExpectedHost5 = \
300 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
301 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
302 SDNIPJSONFILEPATH )
303
304 routeIntentsExpected = routeIntentsExpectedHost3 + \
305 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
306
307 cellName = main.params[ 'ENV' ][ 'cellName' ]
308 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
309 main.step( "Set cell for ONOS-cli environment" )
310 main.ONOScli.setCell( cellName )
311 verifyResult = main.ONOSbench.verifyCell()
312
313 main.log.report( "Removing raft logs" )
314 main.ONOSbench.onosRemoveRaftLogs()
315 main.log.report( "Uninstalling ONOS" )
316 main.ONOSbench.onosUninstall( ONOS1Ip )
317
318 main.step( "Installing ONOS package" )
319 onos1InstallResult = main.ONOSbench.onosInstall(
320 options="-f", node=ONOS1Ip )
321
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800322 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
323 if not onos1Isup:
324 main.log.report( "ONOS1 didn't start!" )
325
326 main.step( "Start ONOS-cli" )
327
328 main.ONOScli.startOnosCli( ONOS1Ip )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800329 main.step( "Get devices in the network" )
330 listResult = main.ONOScli.devices( jsonFormat=False )
331 main.log.info( listResult )
332 time.sleep( 10 )
sanghoshin3de90272015-03-03 16:10:04 -0800333 main.log.info( "Installing bgprouter feature" )
sanghoshina96f1e72015-02-27 09:30:56 -0800334 main.ONOScli.featureInstall( "onos-app-bgprouter" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800335 time.sleep( 10 )
336 main.step( "Login all BGP peers and add routes into peers" )
337
338 main.log.info( "Login Quagga CLI on host3" )
339 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
340 main.log.info( "Enter configuration model of Quagga CLI on host3" )
341 main.QuaggaCliHost3.enterConfig( 64514 )
342 main.log.info( "Add routes to Quagga on host3" )
343 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
344
345 main.log.info( "Login Quagga CLI on host4" )
346 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
347 main.log.info( "Enter configuration model of Quagga CLI on host4" )
348 main.QuaggaCliHost4.enterConfig( 64516 )
349 main.log.info( "Add routes to Quagga on host4" )
350 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
351
352 main.log.info( "Login Quagga CLI on host5" )
353 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
354 main.log.info( "Enter configuration model of Quagga CLI on host5" )
355 main.QuaggaCliHost5.enterConfig( 64521 )
356 main.log.info( "Add routes to Quagga on host5" )
357 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
358
sanghoshin3de90272015-03-03 16:10:04 -0800359 time.sleep( 30 )
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
sanghoshin3de90272015-03-03 16:10:04 -0800365 allRoutesActual = \
366 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800367
368 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
369 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
370 main.step( "Check routes installed" )
371 main.log.info( "Routes expected:" )
372 main.log.info( allRoutesStrExpected )
373 main.log.info( "Routes get from ONOS CLI:" )
374 main.log.info( allRoutesStrActual )
375 utilities.assertEquals(
376 expect=allRoutesStrExpected, actual=allRoutesStrActual,
377 onpass="***Routes in SDN-IP are correct!***",
378 onfail="***Routes in SDN-IP are wrong!***" )
379 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
380 main.log.report(
381 "***Routes in SDN-IP after adding routes are correct!***" )
382 else:
383 main.log.report(
384 "***Routes in SDN-IP after adding routes are wrong!***" )
385
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800386 #============================= Ping Test ========================
sanghoshin3de90272015-03-03 16:10:04 -0800387 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
sanghoshin29e6a472015-02-27 12:55:06 -0800388 main.log.info("Ping test result")
sanghoshin3de90272015-03-03 16:10:04 -0800389 if pingTestResults:
390 main.log.info("Test succeeded")
391 else:
392 main.log.info("Test failed")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800393
sanghoshin3de90272015-03-03 16:10:04 -0800394 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
395 onpass="Default connectivity check PASS",
396 onfail="Default connectivity check FAIL")
397
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800398 #============================= Deleting Routes ==================
399 main.step( "Check deleting routes installed" )
400 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
401 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
402 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
403
404 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
sanghoshin3de90272015-03-03 16:10:04 -0800405 allRoutesActual = \
406 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
sanghoshin29e6a472015-02-27 12:55:06 -0800407
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800408 main.log.info( "allRoutes_actual = " )
409 main.log.info( allRoutesActual )
410
411 utilities.assertEquals(
412 expect="[]", actual=str( allRoutesActual ),
413 onpass="***Route number in SDN-IP is 0, correct!***",
414 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
415
416 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
417 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
418 else:
419 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
420
sanghoshin3de90272015-03-03 16:10:04 -0800421 #============================= Ping Test ========================
422 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
423 main.log.info("Ping test result")
424 if pingTestResults:
425 main.log.info("Test succeeded")
426 else:
427 main.log.info("Test failed")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800428
sanghoshin3de90272015-03-03 16:10:04 -0800429 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
430 onpass="disconnect check PASS",
431 onfail="disconnect check FAIL")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800432
sanghoshin3de90272015-03-03 16:10:04 -0800433 main.ONOScli.logout()
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800434 main.ONOSbench.onosStop(ONOS1Ip);
sanghoshin3de90272015-03-03 16:10:04 -0800435 main.Mininet.stopNet()
436 time.sleep(10)
437
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800438
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800439 # Route convergence and connectivity test
440 def CASE21( self, main):
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800441 import time
442 import json
443 from operator import eq
444 # from datetime import datetime
445 from time import localtime, strftime
446
447 main.case("The test case is to help to setup the TestON environment \
448 and test new drivers" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800449 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
450 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/routeconvergence/mininet"
451 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json"
452 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
sanghoshin43dbcfb2015-03-02 12:02:40 -0800453
454 # Copy the json files to config dir
455 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/addresses.json ~/onos/tools/package/config/")
456 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/sdnip.json ~/onos/tools/package/config/")
457
458 # Launch mininet topology for this case
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800459 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterConvergenceMininet.py"
460 main.step( "Launch mininet" )
461 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
462 main.step("waiting 20 secs for all switches and quagga instances to comeup")
463 time.sleep(20)
464 main.step( "Test whether Mininet is started" )
465 main.log.info( "Login Quagga CLI on host3" )
466 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800467 # all expected routes for all BGP peers
468 allRoutesExpected = []
469 main.step( "Start to generate routes for all BGP peers" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800470 main.log.info( "Generate prefixes for host3" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800471
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800472 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
473 main.log.info( prefixesHost3 )
474 # generate route with next hop
475 for prefix in prefixesHost3:
476 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
477 routeIntentsExpectedHost3 = \
478 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
479 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
480 SDNIPJSONFILEPATH )
481
482 main.log.info( "Generate prefixes for host4" )
483 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
484 main.log.info( prefixesHost4 )
485 # generate route with next hop
486 for prefix in prefixesHost4:
487 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
488 routeIntentsExpectedHost4 = \
489 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
490 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
491 SDNIPJSONFILEPATH )
492
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800493 main.log.info( "Generate prefixes for host5" )
494 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
495 main.log.info( prefixesHost5 )
496 for prefix in prefixesHost5:
497 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
498 routeIntentsExpectedHost5 = \
499 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
500 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
501 SDNIPJSONFILEPATH )
502
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800503 routeIntentsExpected = routeIntentsExpectedHost3 + \
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800504 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800505
506 cellName = main.params[ 'ENV' ][ 'cellName' ]
507 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
508 main.step( "Set cell for ONOS-cli environment" )
509 main.ONOScli.setCell( cellName )
510 verifyResult = main.ONOSbench.verifyCell()
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800511
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800512 main.log.report( "Removing raft logs" )
513 main.ONOSbench.onosRemoveRaftLogs()
514 main.log.report( "Uninstalling ONOS" )
515 main.ONOSbench.onosUninstall( ONOS1Ip )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800516
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800517 main.step( "Installing ONOS package" )
518 onos1InstallResult = main.ONOSbench.onosInstall(
519 options="-f", node=ONOS1Ip )
520
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800521 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
522 if not onos1Isup:
523 main.log.report( "ONOS1 didn't start!" )
524
525 main.step( "Start ONOS-cli" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800526
527 main.ONOScli.startOnosCli( ONOS1Ip )
528
529 main.step( "Get devices in the network" )
530 listResult = main.ONOScli.devices( jsonFormat=False )
531 main.log.info( listResult )
532 time.sleep( 10 )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800533 main.log.info( "Installing gbprouter feature" )
534 main.ONOScli.featureInstall( "onos-app-bgprouter" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800535 time.sleep( 10 )
536 main.step( "Login all BGP peers and add routes into peers" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800537
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800538 main.log.info( "Login Quagga CLI on host3" )
539 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
540 main.log.info( "Enter configuration model of Quagga CLI on host3" )
541 main.QuaggaCliHost3.enterConfig( 64514 )
542 main.log.info( "Add routes to Quagga on host3" )
543 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
544
545 main.log.info( "Login Quagga CLI on host4" )
546 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
547 main.log.info( "Enter configuration model of Quagga CLI on host4" )
548 main.QuaggaCliHost4.enterConfig( 64516 )
549 main.log.info( "Add routes to Quagga on host4" )
550 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800551
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800552 main.log.info( "Login Quagga CLI on host5" )
553 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
554 main.log.info( "Enter configuration model of Quagga CLI on host5" )
555 main.QuaggaCliHost5.enterConfig( 64521 )
556 main.log.info( "Add routes to Quagga on host5" )
557 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
558
sanghoshin43dbcfb2015-03-02 12:02:40 -0800559 time.sleep( 30 )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800560
561 # get routes inside SDN-IP
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800562 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
563
564 # parse routes from ONOS CLI
565 allRoutesActual = \
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800566 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800567
568 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
569 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
570 main.step( "Check routes installed" )
571 main.log.info( "Routes expected:" )
572 main.log.info( allRoutesStrExpected )
573 main.log.info( "Routes get from ONOS CLI:" )
574 main.log.info( allRoutesStrActual )
575 utilities.assertEquals(
576 expect=allRoutesStrExpected, actual=allRoutesStrActual,
577 onpass="***Routes in SDN-IP are correct!***",
578 onfail="***Routes in SDN-IP are wrong!***" )
579 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
580 main.log.report(
581 "***Routes in SDN-IP after adding routes are correct!***" )
582 else:
583 main.log.report(
584 "***Routes in SDN-IP after adding routes are wrong!***" )
585
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800586 #============================= Ping Test ========================
587 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
588 main.log.info("Ping test result")
589 if pingTestResults:
590 main.log.info("Test succeeded")
591 else:
592 main.log.info("Test failed")
593
594 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
595 onpass="Default connectivity check PASS",
596 onfail="Default connectivity check FAIL")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800597
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800598 #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ==================
599 main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
600 main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" )
601 main.log.info( "Sleeping for 150 seconds for network to converge" )
602 time.sleep(150)
603 # get routes inside SDN-IP
604 main.log.info( "Getting Routes from ONOS CLI" )
605 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
606
607 # parse routes from ONOS CLI
608 newAllRoutesActual = \
609 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
610 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
611
612 # Expected routes with changed next hop
613 newAllRoutesExpected = []
614 for prefix in prefixesHost3:
615 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
616 for prefix in prefixesHost4:
617 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
618 for prefix in prefixesHost5:
619 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
620 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
621 main.step( "Check routes installed after convergence-1" )
622 main.log.info( "Routes expected:" )
623 main.log.info( newAllRoutesStrExpected )
624 main.log.info( "Routes got from ONOS CLI after convergence-1:" )
625 main.log.info( newAllRoutesStrActual )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800626 utilities.assertEquals(
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800627 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
628 onpass="***Routes in SDN-IP are correct after convergence!***",
629 onfail="***Routes in SDN-IP are wrong after convergence!***" )
630 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800631 main.log.report(
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800632 "***Routes in SDN-IP after convergence are correct!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800633 else:
634 main.log.report(
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800635 "***Routes in SDN-IP after convergence are wrong!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800636
637 #============================= Ping Test ========================
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800638 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
639 main.log.info("Ping test result")
640 if pingTestResults:
641 main.log.info("Test succeeded")
642 else:
643 main.log.info("Test failed")
644
645 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
646 onpass="Default connectivity check PASS",
647 onfail="Default connectivity check FAIL")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800648
Srikanth Vavilapalli43f3a1d2015-03-04 11:09:44 -0800649 #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ==================
650 main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
651 main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
652 main.log.info( "Sleeping for 150 seconds for network to converge" )
653 time.sleep(150)
654 # get routes inside SDN-IP
655 main.log.info( "Getting Routes from ONOS CLI" )
656 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
657
658 # parse routes from ONOS CLI
659 newAllRoutesActual = \
660 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
661 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
662
663 # Expected routes with changed next hop
664 newAllRoutesExpected = []
665 for prefix in prefixesHost3:
666 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
667 for prefix in prefixesHost4:
668 newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" )
669 for prefix in prefixesHost5:
670 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
671 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
672 main.step( "Check routes installed after convergence-2" )
673 main.log.info( "Routes expected:" )
674 main.log.info( newAllRoutesStrExpected )
675 main.log.info( "Routes got from ONOS CLI after convergence-2:" )
676 main.log.info( newAllRoutesStrActual )
677 utilities.assertEquals(
678 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
679 onpass="***Routes in SDN-IP are correct after convergence!***",
680 onfail="***Routes in SDN-IP are wrong after convergence!***" )
681 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
682 main.log.report(
683 "***Routes in SDN-IP after convergence are correct!***" )
684 else:
685 main.log.report(
686 "***Routes in SDN-IP after convergence are wrong!***" )
687
688 #============================= Ping Test ========================
689 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
690 main.log.info("Ping test result")
691 if pingTestResults:
692 main.log.info("Test succeeded")
693 else:
694 main.log.info("Test failed")
695
696 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
697 onpass="Default connectivity check PASS",
698 onfail="Default connectivity check FAIL")
699
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800700 #============================= Deleting Routes ==================
701 main.step( "Check deleting routes installed" )
702 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
703 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800704 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800705
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800706 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
707 allRoutesActual = \
708 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800709
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800710 main.log.info( "allRoutes_actual = " )
711 main.log.info( allRoutesActual )
712
713 utilities.assertEquals(
714 expect="[]", actual=str( allRoutesActual ),
715 onpass="***Route number in SDN-IP is 0, correct!***",
716 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
717
718 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800719 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800720 else:
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800721 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800722
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800723 #============================= Ping Test ========================
724 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
725 main.log.info("Ping test result")
726 if pingTestResults:
727 main.log.info("Test succeeded")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800728 else:
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800729 main.log.info("Test failed")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800730
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800731 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
732 onpass="disconnect check PASS",
733 onfail="disconnect check FAIL")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800734
sanghoshinc59d6c52015-03-03 10:01:07 -0800735 main.ONOScli.logout()
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800736 main.ONOSbench.onosStop(ONOS1Ip);
sanghoshin43dbcfb2015-03-02 12:02:40 -0800737 main.Mininet.stopNet()
738 time.sleep(10)
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800739
Srikanth Vavilapallie5388212015-03-05 13:55:53 -0800740 # Route convergence and connectivity test with Route Server
741 def CASE22( self, main):
742 import time
743 import json
744 from operator import eq
745 # from datetime import datetime
746 from time import localtime, strftime
747
748 main.case("The test case is to help to setup the TestON environment \
749 and test new drivers" )
750 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
751 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/routeserver/mininet"
752 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/routeserver/sdnip.json"
753 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
754
755 # Copy the json files to config dir
756 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/routeserver/addresses.json ~/onos/tools/package/config/")
757 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/routeserver/sdnip.json ~/onos/tools/package/config/")
758
759 # Launch mininet topology for this case
760 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouteServerMininet.py"
761 main.step( "Launch mininet" )
762 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
763 main.step("waiting 20 secs for all switches and quagga instances to comeup")
764 time.sleep(20)
765 main.step( "Test whether Mininet is started" )
766 main.log.info( "Login Quagga CLI on host3" )
767 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
768 # all expected routes for all BGP peers
769 allRoutesExpected = []
770 main.step( "Start to generate routes for all BGP peers" )
771 main.log.info( "Generate prefixes for host3" )
772
773 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
774 main.log.info( prefixesHost3 )
775 # generate route with next hop
776 for prefix in prefixesHost3:
777 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
778 routeIntentsExpectedHost3 = \
779 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
780 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
781 SDNIPJSONFILEPATH )
782
783 main.log.info( "Generate prefixes for host4" )
784 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
785 main.log.info( prefixesHost4 )
786 # generate route with next hop
787 for prefix in prefixesHost4:
788 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
789 routeIntentsExpectedHost4 = \
790 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
791 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
792 SDNIPJSONFILEPATH )
793
794 main.log.info( "Generate prefixes for host5" )
795 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
796 main.log.info( prefixesHost5 )
797 for prefix in prefixesHost5:
798 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
799 routeIntentsExpectedHost5 = \
800 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
801 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
802 SDNIPJSONFILEPATH )
803
804 routeIntentsExpected = routeIntentsExpectedHost3 + \
805 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
806
807 cellName = main.params[ 'ENV' ][ 'cellName' ]
808 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
809 main.step( "Set cell for ONOS-cli environment" )
810 main.ONOScli.setCell( cellName )
811 verifyResult = main.ONOSbench.verifyCell()
812
813 main.log.report( "Removing raft logs" )
814 main.ONOSbench.onosRemoveRaftLogs()
815 main.log.report( "Uninstalling ONOS" )
816 main.ONOSbench.onosUninstall( ONOS1Ip )
817
818 main.step( "Installing ONOS package" )
819 onos1InstallResult = main.ONOSbench.onosInstall(
820 options="-f", node=ONOS1Ip )
821
822 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
823 if not onos1Isup:
824 main.log.report( "ONOS1 didn't start!" )
825
826 main.step( "Start ONOS-cli" )
827
828 main.ONOScli.startOnosCli( ONOS1Ip )
829
830 main.step( "Get devices in the network" )
831 listResult = main.ONOScli.devices( jsonFormat=False )
832 main.log.info( listResult )
833 time.sleep( 10 )
834 main.log.info( "Installing gbprouter feature" )
835 main.ONOScli.featureInstall( "onos-app-bgprouter" )
836 time.sleep( 10 )
837 main.step( "Login all BGP peers and add routes into peers" )
838
839 main.log.info( "Login Quagga CLI on host3" )
840 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
841 main.log.info( "Enter configuration model of Quagga CLI on host3" )
842 main.QuaggaCliHost3.enterConfig( 64514 )
843 main.log.info( "Add routes to Quagga on host3" )
844 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
845
846 main.log.info( "Login Quagga CLI on host4" )
847 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
848 main.log.info( "Enter configuration model of Quagga CLI on host4" )
849 main.QuaggaCliHost4.enterConfig( 64516 )
850 main.log.info( "Add routes to Quagga on host4" )
851 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
852
853 main.log.info( "Login Quagga CLI on host5" )
854 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
855 main.log.info( "Enter configuration model of Quagga CLI on host5" )
856 main.QuaggaCliHost5.enterConfig( 64521 )
857 main.log.info( "Add routes to Quagga on host5" )
858 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
859
860 time.sleep( 60 )
861
862 # get routes inside SDN-IP
863 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
864
865 # parse routes from ONOS CLI
866 allRoutesActual = \
867 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
868
869 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
870 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
871 main.step( "Check routes installed" )
872 main.log.info( "Routes expected:" )
873 main.log.info( allRoutesStrExpected )
874 main.log.info( "Routes get from ONOS CLI:" )
875 main.log.info( allRoutesStrActual )
876 utilities.assertEquals(
877 expect=allRoutesStrExpected, actual=allRoutesStrActual,
878 onpass="***Routes in SDN-IP are correct!***",
879 onfail="***Routes in SDN-IP are wrong!***" )
880 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
881 main.log.report(
882 "***Routes in SDN-IP after adding routes are correct!***" )
883 else:
884 main.log.report(
885 "***Routes in SDN-IP after adding routes are wrong!***" )
886
887 #============================= Ping Test ========================
888 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
889 main.log.info("Ping test result")
890 if pingTestResults:
891 main.log.info("Test succeeded")
892 else:
893 main.log.info("Test failed")
894
895 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
896 onpass="Default connectivity check PASS",
897 onfail="Default connectivity check FAIL")
898
899 #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ==================
900 main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
901 main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" )
902 main.log.info( "Sleeping for 150 seconds for network to converge" )
903 time.sleep(150)
904 # get routes inside SDN-IP
905 main.log.info( "Getting Routes from ONOS CLI" )
906 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
907
908 # parse routes from ONOS CLI
909 newAllRoutesActual = \
910 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
911 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
912
913 # Expected routes with changed next hop
914 newAllRoutesExpected = []
915 for prefix in prefixesHost3:
916 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
917 for prefix in prefixesHost4:
918 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
919 for prefix in prefixesHost5:
920 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
921 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
922 main.step( "Check routes installed after convergence-1" )
923 main.log.info( "Routes expected:" )
924 main.log.info( newAllRoutesStrExpected )
925 main.log.info( "Routes got from ONOS CLI after convergence-1:" )
926 main.log.info( newAllRoutesStrActual )
927 utilities.assertEquals(
928 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
929 onpass="***Routes in SDN-IP are correct after convergence!***",
930 onfail="***Routes in SDN-IP are wrong after convergence!***" )
931 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
932 main.log.report(
933 "***Routes in SDN-IP after convergence are correct!***" )
934 else:
935 main.log.report(
936 "***Routes in SDN-IP after convergence are wrong!***" )
937
938 #============================= Ping Test ========================
939 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
940 main.log.info("Ping test result")
941 if pingTestResults:
942 main.log.info("Test succeeded")
943 else:
944 main.log.info("Test failed")
945
946 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
947 onpass="Default connectivity check PASS",
948 onfail="Default connectivity check FAIL")
949
950 #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ==================
951 main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
952 main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
953 main.log.info( "Sleeping for 150 seconds for network to converge" )
954 time.sleep(150)
955 # get routes inside SDN-IP
956 main.log.info( "Getting Routes from ONOS CLI" )
957 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
958
959 # parse routes from ONOS CLI
960 newAllRoutesActual = \
961 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
962 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
963
964 # Expected routes with changed next hop
965 newAllRoutesExpected = []
966 for prefix in prefixesHost3:
967 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
968 for prefix in prefixesHost4:
969 newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" )
970 for prefix in prefixesHost5:
971 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
972 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
973 main.step( "Check routes installed after convergence-2" )
974 main.log.info( "Routes expected:" )
975 main.log.info( newAllRoutesStrExpected )
976 main.log.info( "Routes got from ONOS CLI after convergence-2:" )
977 main.log.info( newAllRoutesStrActual )
978 utilities.assertEquals(
979 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
980 onpass="***Routes in SDN-IP are correct after convergence!***",
981 onfail="***Routes in SDN-IP are wrong after convergence!***" )
982 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
983 main.log.report(
984 "***Routes in SDN-IP after convergence are correct!***" )
985 else:
986 main.log.report(
987 "***Routes in SDN-IP after convergence are wrong!***" )
988
989 #============================= Ping Test ========================
990 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
991 main.log.info("Ping test result")
992 if pingTestResults:
993 main.log.info("Test succeeded")
994 else:
995 main.log.info("Test failed")
996
997 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
998 onpass="Default connectivity check PASS",
999 onfail="Default connectivity check FAIL")
1000
1001 #============================= Deleting Routes ==================
1002 main.step( "Check deleting routes installed" )
1003 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
1004 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
1005 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
1006
1007 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1008 allRoutesActual = \
1009 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1010
1011 main.log.info( "allRoutes_actual = " )
1012 main.log.info( allRoutesActual )
1013
1014 utilities.assertEquals(
1015 expect="[]", actual=str( allRoutesActual ),
1016 onpass="***Route number in SDN-IP is 0, correct!***",
1017 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
1018
1019 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1020 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
1021 else:
1022 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
1023
1024 #============================= Ping Test ========================
1025 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
1026 main.log.info("Ping test result")
1027 if pingTestResults:
1028 main.log.info("Test succeeded")
1029 else:
1030 main.log.info("Test failed")
1031
1032 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1033 onpass="disconnect check PASS",
1034 onfail="disconnect check FAIL")
1035
1036 main.ONOScli.logout()
1037 main.ONOSbench.onosStop(ONOS1Ip);
1038 main.Mininet.stopNet()
1039 time.sleep(10)
1040