blob: e199d742c88203409674726846dd2c5d908c9689 [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
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08005class PeeringRouterTest:
6
7 def __init__( self ):
8 self.default = ''
9
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -080010
sanghoshinb3500fa2015-03-06 12:51:29 -080011 def CASE6 ( self, main):
12
sanghoshin29e6a472015-02-27 12:55:06 -080013 import time
14 import json
15 from operator import eq
16 # from datetime import datetime
17 from time import localtime, strftime
sanghoshinb3500fa2015-03-06 12:51:29 -080018
19 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
20 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/mininet"
21 # Launch mininet topology for this case
22 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininetVlan.py"
23 main.step( "Launch mininet" )
24 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
25 main.step("waiting 20 secs for all switches and quagga instances to comeup")
26 time.sleep(20)
27 main.step( "Test whether Mininet is started" )
sanghoshin29e6a472015-02-27 12:55:06 -080028
29 #============================= Ping Test ========================
30 main.log.info("Start ping test")
sanghoshinb3500fa2015-03-06 12:51:29 -080031
32 for m in range( 3, 6 ):
33 for n in range( 1, 11 ):
34 hostIp = str( m ) + ".0." + str( n ) + ".1"
35 pingTestResults = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp)
36
sanghoshin29e6a472015-02-27 12:55:06 -080037 if pingTestResults:
38 main.log.info("Test succeeded")
39 else:
40 main.log.info("Test failed")
41
sanghoshinb3500fa2015-03-06 12:51:29 -080042 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
sanghoshin29e6a472015-02-27 12:55:06 -080043 onpass="Default connectivity check PASS",
44 onfail="Default connectivity check FAIL")
45
46
47 def CASE4( self, main):
48 import time
49 import json
50 from operator import eq
51 # from datetime import datetime
52 from time import localtime, strftime
53
54 main.case("The test case is to help to setup the TestON environment \
55 and test new drivers" )
Srikanth Vavilapallicf1cd5b2015-02-27 17:19:12 -080056 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
57 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/mininet"
58 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json"
59 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
sanghoshin43dbcfb2015-03-02 12:02:40 -080060
61 # Copy the json files to config dir
62 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/addresses.json ~/onos/tools/package/config/")
63 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/sdnip.json ~/onos/tools/package/config/")
64
Srikanth Vavilapallicf1cd5b2015-02-27 17:19:12 -080065 # Launch mininet topology for this case
66 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininet.py"
67 main.step( "Launch mininet" )
68 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
69 main.step("waiting 20 secs for all switches and quagga instances to comeup")
70 time.sleep(20)
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -080071 main.step( "Test whether Mininet is started" )
Srikanth Vavilapallicf1cd5b2015-02-27 17:19:12 -080072 main.log.info( "Login Quagga CLI on host3" )
73 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
sanghoshin29e6a472015-02-27 12:55:06 -080074 # all expected routes for all BGP peers
75 allRoutesExpected = []
76 main.step( "Start to generate routes for all BGP peers" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -080077
sanghoshin29e6a472015-02-27 12:55:06 -080078 main.log.info( "Generate prefixes for host3" )
79 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
80 main.log.info( prefixesHost3 )
81 # generate route with next hop
82 for prefix in prefixesHost3:
83 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
84 routeIntentsExpectedHost3 = \
85 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
86 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
87 SDNIPJSONFILEPATH )
88
89 main.log.info( "Generate prefixes for host4" )
90 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
91 main.log.info( prefixesHost4 )
sanghoshin29e6a472015-02-27 12:55:06 -080092 # generate route with next hop
93 for prefix in prefixesHost4:
94 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
95 routeIntentsExpectedHost4 = \
96 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
97 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
98 SDNIPJSONFILEPATH )
99
100 main.log.info( "Generate prefixes for host5" )
101 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
102 main.log.info( prefixesHost5 )
103 for prefix in prefixesHost5:
104 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
105 routeIntentsExpectedHost5 = \
106 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
107 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
108 SDNIPJSONFILEPATH )
109
110 routeIntentsExpected = routeIntentsExpectedHost3 + \
111 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
112
113 cellName = main.params[ 'ENV' ][ 'cellName' ]
114 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
115 main.step( "Set cell for ONOS-cli environment" )
116 main.ONOScli.setCell( cellName )
117 verifyResult = main.ONOSbench.verifyCell()
118
119 main.log.report( "Removing raft logs" )
120 main.ONOSbench.onosRemoveRaftLogs()
121 main.log.report( "Uninstalling ONOS" )
122 main.ONOSbench.onosUninstall( ONOS1Ip )
123
124 main.step( "Installing ONOS package" )
125 onos1InstallResult = main.ONOSbench.onosInstall(
126 options="-f", node=ONOS1Ip )
127
128 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
129 if not onos1Isup:
130 main.log.report( "ONOS1 didn't start!" )
131
132 main.step( "Start ONOS-cli" )
133
134 main.ONOScli.startOnosCli( ONOS1Ip )
135
136 main.step( "Get devices in the network" )
137 listResult = main.ONOScli.devices( jsonFormat=False )
138 main.log.info( listResult )
139 time.sleep( 10 )
sanghoshin43dbcfb2015-03-02 12:02:40 -0800140 main.log.info( "Installing bgprouter feature" )
sanghoshin29e6a472015-02-27 12:55:06 -0800141 main.ONOScli.featureInstall( "onos-app-bgprouter" )
142 time.sleep( 10 )
143 main.step( "Login all BGP peers and add routes into peers" )
144
145 main.log.info( "Login Quagga CLI on host3" )
146 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
147 main.log.info( "Enter configuration model of Quagga CLI on host3" )
148 main.QuaggaCliHost3.enterConfig( 64514 )
149 main.log.info( "Add routes to Quagga on host3" )
150 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
151
152 main.log.info( "Login Quagga CLI on host4" )
153 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
154 main.log.info( "Enter configuration model of Quagga CLI on host4" )
155 main.QuaggaCliHost4.enterConfig( 64516 )
156 main.log.info( "Add routes to Quagga on host4" )
157 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
158
159 main.log.info( "Login Quagga CLI on host5" )
160 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
161 main.log.info( "Enter configuration model of Quagga CLI on host5" )
162 main.QuaggaCliHost5.enterConfig( 64521 )
163 main.log.info( "Add routes to Quagga on host5" )
164 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
165
sanghoshin43dbcfb2015-03-02 12:02:40 -0800166 time.sleep( 30 )
sanghoshin29e6a472015-02-27 12:55:06 -0800167
168 # get routes inside SDN-IP
169 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
170
171 # parse routes from ONOS CLI
sanghoshine35a8a52015-02-27 20:47:26 -0800172 allRoutesActual = \
173 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
sanghoshin29e6a472015-02-27 12:55:06 -0800174
175 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
176 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
177 main.step( "Check routes installed" )
178 main.log.info( "Routes expected:" )
179 main.log.info( allRoutesStrExpected )
180 main.log.info( "Routes get from ONOS CLI:" )
181 main.log.info( allRoutesStrActual )
182 utilities.assertEquals(
183 expect=allRoutesStrExpected, actual=allRoutesStrActual,
184 onpass="***Routes in SDN-IP are correct!***",
185 onfail="***Routes in SDN-IP are wrong!***" )
186 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
187 main.log.report(
188 "***Routes in SDN-IP after adding routes are correct!***" )
189 else:
190 main.log.report(
191 "***Routes in SDN-IP after adding routes are wrong!***" )
192
193 #============================= Ping Test ========================
194 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
195 main.log.info("Ping test result")
196 if pingTestResults:
197 main.log.info("Test succeeded")
198 else:
199 main.log.info("Test failed")
200
201 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
202 onpass="Default connectivity check PASS",
203 onfail="Default connectivity check FAIL")
204
205 #============================= Deleting Routes ==================
206 main.step( "Check deleting routes installed" )
207 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
208 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
209 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
210
211 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
sanghoshine35a8a52015-02-27 20:47:26 -0800212 allRoutesActual = \
213 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
sanghoshin29e6a472015-02-27 12:55:06 -0800214
215 main.log.info( "allRoutes_actual = " )
216 main.log.info( allRoutesActual )
217
218 utilities.assertEquals(
219 expect="[]", actual=str( allRoutesActual ),
220 onpass="***Route number in SDN-IP is 0, correct!***",
221 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
222
223 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
224 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
225 else:
226 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
227
228 #============================= Ping Test ========================
229 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
230 main.log.info("Ping test result")
231 if pingTestResults:
232 main.log.info("Test succeeded")
233 else:
234 main.log.info("Test failed")
235
236 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
237 onpass="disconnect check PASS",
238 onfail="disconnect check FAIL")
239
sanghoshinc59d6c52015-03-03 10:01:07 -0800240 main.ONOScli.logout()
Srikanth Vavilapallicf1cd5b2015-02-27 17:19:12 -0800241 main.ONOSbench.onosStop(ONOS1Ip);
sanghoshin43dbcfb2015-03-02 12:02:40 -0800242 main.Mininet.stopNet()
243 time.sleep(10)
Srikanth Vavilapallicf1cd5b2015-02-27 17:19:12 -0800244
sanghoshin29e6a472015-02-27 12:55:06 -0800245 def CASE5( self, main ):
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800246 import time
247 import json
248 from operator import eq
249 # from datetime import datetime
250 from time import localtime, strftime
251
252 main.case("The test case is to help to setup the TestON environment \
253 and test new drivers" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800254 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
sanghoshin5f3e7cb2015-03-04 18:07:21 -0800255 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/mininet"
sanghoshin017a9602015-03-06 13:11:10 -0800256 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/sdnip.json"
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800257 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
sanghoshin3de90272015-03-03 16:10:04 -0800258
259 # Copy the json files to config dir
sanghoshinb3500fa2015-03-06 12:51:29 -0800260 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/addresses.json ~/onos/tools/package/config/")
261 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/sdnip.json ~/onos/tools/package/config/")
sanghoshin3de90272015-03-03 16:10:04 -0800262
263 # Launch mininet topology for this case
264 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininetVlan.py"
265 main.step( "Launch mininet" )
266 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
267 main.step("waiting 20 secs for all switches and quagga instances to comeup")
268 time.sleep(20)
269 main.step( "Test whether Mininet is started" )
270 main.log.info( "Login Quagga CLI on host3" )
271 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800272 # all expected routes for all BGP peers
273 allRoutesExpected = []
274 main.step( "Start to generate routes for all BGP peers" )
sanghoshin3de90272015-03-03 16:10:04 -0800275
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800276 main.log.info( "Generate prefixes for host3" )
277 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
278 main.log.info( prefixesHost3 )
279 # generate route with next hop
280 for prefix in prefixesHost3:
281 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
282 routeIntentsExpectedHost3 = \
283 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
284 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
285 SDNIPJSONFILEPATH )
286
287 main.log.info( "Generate prefixes for host4" )
288 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
289 main.log.info( prefixesHost4 )
290 # generate route with next hop
291 for prefix in prefixesHost4:
292 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
293 routeIntentsExpectedHost4 = \
294 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
295 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
296 SDNIPJSONFILEPATH )
297
298 main.log.info( "Generate prefixes for host5" )
299 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
300 main.log.info( prefixesHost5 )
301 for prefix in prefixesHost5:
302 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
303 routeIntentsExpectedHost5 = \
304 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
305 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
306 SDNIPJSONFILEPATH )
307
308 routeIntentsExpected = routeIntentsExpectedHost3 + \
309 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
310
311 cellName = main.params[ 'ENV' ][ 'cellName' ]
312 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
313 main.step( "Set cell for ONOS-cli environment" )
314 main.ONOScli.setCell( cellName )
315 verifyResult = main.ONOSbench.verifyCell()
316
317 main.log.report( "Removing raft logs" )
318 main.ONOSbench.onosRemoveRaftLogs()
319 main.log.report( "Uninstalling ONOS" )
320 main.ONOSbench.onosUninstall( ONOS1Ip )
321
322 main.step( "Installing ONOS package" )
323 onos1InstallResult = main.ONOSbench.onosInstall(
324 options="-f", node=ONOS1Ip )
325
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800326 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
327 if not onos1Isup:
328 main.log.report( "ONOS1 didn't start!" )
329
330 main.step( "Start ONOS-cli" )
331
332 main.ONOScli.startOnosCli( ONOS1Ip )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800333 main.step( "Get devices in the network" )
334 listResult = main.ONOScli.devices( jsonFormat=False )
335 main.log.info( listResult )
336 time.sleep( 10 )
sanghoshin3de90272015-03-03 16:10:04 -0800337 main.log.info( "Installing bgprouter feature" )
sanghoshina96f1e72015-02-27 09:30:56 -0800338 main.ONOScli.featureInstall( "onos-app-bgprouter" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800339 time.sleep( 10 )
340 main.step( "Login all BGP peers and add routes into peers" )
341
342 main.log.info( "Login Quagga CLI on host3" )
343 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
344 main.log.info( "Enter configuration model of Quagga CLI on host3" )
345 main.QuaggaCliHost3.enterConfig( 64514 )
346 main.log.info( "Add routes to Quagga on host3" )
347 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
348
349 main.log.info( "Login Quagga CLI on host4" )
350 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
351 main.log.info( "Enter configuration model of Quagga CLI on host4" )
352 main.QuaggaCliHost4.enterConfig( 64516 )
353 main.log.info( "Add routes to Quagga on host4" )
354 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
355
356 main.log.info( "Login Quagga CLI on host5" )
357 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
358 main.log.info( "Enter configuration model of Quagga CLI on host5" )
359 main.QuaggaCliHost5.enterConfig( 64521 )
360 main.log.info( "Add routes to Quagga on host5" )
361 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
362
sanghoshin3de90272015-03-03 16:10:04 -0800363 time.sleep( 30 )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800364
365 # get routes inside SDN-IP
366 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
367
368 # parse routes from ONOS CLI
sanghoshin3de90272015-03-03 16:10:04 -0800369 allRoutesActual = \
370 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800371
372 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
373 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
374 main.step( "Check routes installed" )
375 main.log.info( "Routes expected:" )
376 main.log.info( allRoutesStrExpected )
377 main.log.info( "Routes get from ONOS CLI:" )
378 main.log.info( allRoutesStrActual )
379 utilities.assertEquals(
380 expect=allRoutesStrExpected, actual=allRoutesStrActual,
381 onpass="***Routes in SDN-IP are correct!***",
382 onfail="***Routes in SDN-IP are wrong!***" )
383 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
384 main.log.report(
385 "***Routes in SDN-IP after adding routes are correct!***" )
386 else:
387 main.log.report(
388 "***Routes in SDN-IP after adding routes are wrong!***" )
389
sanghoshinb3500fa2015-03-06 12:51:29 -0800390 time.sleep(20)
391
392 #============================= Ping Test ========================
393 pingTestResults = main.TRUE
sanghoshin51f08192015-03-09 15:24:21 -0700394 sources = ["as2host", "as3host", "as6host"]
395 targets = ["192.168.10.101", "192.168.20.101", "192.168.30.101", "192.168.60.101"]
396 for source in sources:
397 for target in targets:
398 r = main.Mininet.pingHost(SRC=source, TARGET=target)
399 if r == main.FALSE:
400 pingTestResults = main.FALSE
401
402 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
403 onpass="Router connectivity check PASS",
404 onfail="Router connectivity check FAIL")
405
406 pingTestResults = main.TRUE
sanghoshinb3500fa2015-03-06 12:51:29 -0800407 for m in range( 3, 6 ):
408 for n in range( 1, 10 ):
409 hostIp = str( m ) + ".0." + str( n ) + ".1"
410 r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp)
411 if r == main.FALSE:
412 pingTestResults = main.FALSE
413
414 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
415 onpass="Default connectivity check PASS",
416 onfail="Default connectivity check FAIL")
417
418 time.sleep(20)
419 #============================= Deleting Routes ==================
420 main.step( "Check deleting routes installed" )
421 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
422 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
423 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
424
425 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
426 allRoutesActual = \
427 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
428
429 main.log.info( "allRoutes_actual = " )
430 main.log.info( allRoutesActual )
431
432 utilities.assertEquals(
433 expect="[]", actual=str( allRoutesActual ),
434 onpass="***Route number in SDN-IP is 0, correct!***",
435 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
436
437 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
438 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
439 else:
440 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
441
442 time.sleep(10)
443 #============================= Ping Test ========================
444 pingTestResults = main.TRUE
445 for m in range( 4, 6 ):
446 for n in range( 1, 10 ):
447 hostIp = str( m ) + ".0." + str( n ) + ".1"
448 r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp)
449 if r == main.TRUE:
450 pingTestResults = main.FALSE
451
452 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
453 onpass="disconnect check PASS",
454 onfail="disconnect check FAIL")
455
sanghoshin51f08192015-03-09 15:24:21 -0700456
457 time.sleep(20);
458
sanghoshinb3500fa2015-03-06 12:51:29 -0800459 main.ONOScli.logout()
sanghoshin51f08192015-03-09 15:24:21 -0700460 main.log.info("ONOS cli logout")
461 time.sleep(20);
sanghoshinb3500fa2015-03-06 12:51:29 -0800462 main.ONOSbench.onosStop(ONOS1Ip);
sanghoshin51f08192015-03-09 15:24:21 -0700463 main.log.info("onos stop")
464 time.sleep(20);
sanghoshinb3500fa2015-03-06 12:51:29 -0800465 main.Mininet.stopNet()
sanghoshin51f08192015-03-09 15:24:21 -0700466 main.log.info("mininet stop")
467 time.sleep(20)
sanghoshinb3500fa2015-03-06 12:51:29 -0800468
469
470 def CASE7( self, main ):
471 import time
472 import json
473 from operator import eq
474 # from datetime import datetime
475 from time import localtime, strftime
476
477 main.case("The test case is to help to setup the TestON environment \
478 and test new drivers" )
479 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
480 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/mininet"
481 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json"
482 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
483
484 # Copy the json files to config dir
485 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/addresses.json ~/onos/tools/package/config/")
486 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/sdnip.json ~/onos/tools/package/config/")
487
488 # Launch mininet topology for this case
489 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininetVlan.py"
490 main.step( "Launch mininet" )
491 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
492 main.step("waiting 20 secs for all switches and quagga instances to comeup")
493 time.sleep(20)
494 main.step( "Test whether Mininet is started" )
495 main.log.info( "Login Quagga CLI on host3" )
496 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
497 # all expected routes for all BGP peers
498 allRoutesExpected = []
499 main.step( "Start to generate routes for all BGP peers" )
500
501 main.log.info( "Generate prefixes for host3" )
502 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 255 )
503 main.log.info( prefixesHost3 )
504 # generate route with next hop
505 for prefix in prefixesHost3:
506 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
507 routeIntentsExpectedHost3 = \
508 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
509 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
510 SDNIPJSONFILEPATH )
511 main.log.info( "Generate prefixes for host4" )
512 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 255 )
513 main.log.info( prefixesHost4 )
514 # generate route with next hop
515 for prefix in prefixesHost4:
516 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
517 routeIntentsExpectedHost4 = \
518 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
519 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
520 SDNIPJSONFILEPATH )
521
522 main.log.info( "Generate prefixes for host5" )
523 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 255 )
524 main.log.info( prefixesHost5 )
525 for prefix in prefixesHost5:
526 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
527 routeIntentsExpectedHost5 = \
528 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
529 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
530 SDNIPJSONFILEPATH )
531
532 routeIntentsExpected = routeIntentsExpectedHost3 + \
533 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
534
535 cellName = main.params[ 'ENV' ][ 'cellName' ]
536 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
537 main.step( "Set cell for ONOS-cli environment" )
538 main.ONOScli.setCell( cellName )
539 verifyResult = main.ONOSbench.verifyCell()
540
541 main.log.report( "Removing raft logs" )
542 main.ONOSbench.onosRemoveRaftLogs()
543 main.log.report( "Uninstalling ONOS" )
544 main.ONOSbench.onosUninstall( ONOS1Ip )
545
546 main.step( "Installing ONOS package" )
547 onos1InstallResult = main.ONOSbench.onosInstall(
548 options="-f", node=ONOS1Ip )
549
550 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
551 if not onos1Isup:
552 main.log.report( "ONOS1 didn't start!" )
553
554 main.step( "Start ONOS-cli" )
555
556 main.ONOScli.startOnosCli( ONOS1Ip )
557 main.step( "Get devices in the network" )
558 listResult = main.ONOScli.devices( jsonFormat=False )
559 main.log.info( listResult )
560 time.sleep( 10 )
561 main.log.info( "Installing bgprouter feature" )
562 main.ONOScli.featureInstall( "onos-app-bgprouter" )
563 time.sleep( 10 )
564 main.step( "Login all BGP peers and add routes into peers" )
565
566 main.log.info( "Login Quagga CLI on host3" )
567 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
568 main.log.info( "Enter configuration model of Quagga CLI on host3" )
569 main.QuaggaCliHost3.enterConfig( 64514 )
570 main.log.info( "Add routes to Quagga on host3" )
571 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
572
573 main.log.info( "Login Quagga CLI on host4" )
574 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
575 main.log.info( "Enter configuration model of Quagga CLI on host4" )
576 main.QuaggaCliHost4.enterConfig( 64516 )
577 main.log.info( "Add routes to Quagga on host4" )
578 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
579
580 main.log.info( "Login Quagga CLI on host5" )
581 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
582 main.log.info( "Enter configuration model of Quagga CLI on host5" )
583 main.QuaggaCliHost5.enterConfig( 64521 )
584 main.log.info( "Add routes to Quagga on host5" )
585 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
586
587 time.sleep( 30 )
588
589 # get routes inside SDN-IP
590 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
591
592 # parse routes from ONOS CLI
593 allRoutesActual = \
594 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
595
596 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
597 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
598 main.step( "Check routes installed" )
599 main.log.info( "Routes expected:" )
600 main.log.info( allRoutesStrExpected )
601 main.log.info( "Routes get from ONOS CLI:" )
602 main.log.info( allRoutesStrActual )
603 utilities.assertEquals(
604 expect=allRoutesStrExpected, actual=allRoutesStrActual,
605 onpass="***Routes in SDN-IP are correct!***",
606 onfail="***Routes in SDN-IP are wrong!***" )
607 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
608 main.log.report(
609 "***Routes in SDN-IP after adding routes are correct!***" )
610 else:
611 main.log.report(
612 "***Routes in SDN-IP after adding routes are wrong!***" )
613
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800614 #============================= Ping Test ========================
sanghoshin3de90272015-03-03 16:10:04 -0800615 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
sanghoshin29e6a472015-02-27 12:55:06 -0800616 main.log.info("Ping test result")
sanghoshin3de90272015-03-03 16:10:04 -0800617 if pingTestResults:
618 main.log.info("Test succeeded")
619 else:
620 main.log.info("Test failed")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800621
sanghoshin3de90272015-03-03 16:10:04 -0800622 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
623 onpass="Default connectivity check PASS",
624 onfail="Default connectivity check FAIL")
sanghoshinb3500fa2015-03-06 12:51:29 -0800625
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800626 #============================= Deleting Routes ==================
627 main.step( "Check deleting routes installed" )
628 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
629 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
630 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
631
632 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
sanghoshin3de90272015-03-03 16:10:04 -0800633 allRoutesActual = \
634 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
sanghoshin29e6a472015-02-27 12:55:06 -0800635
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800636 main.log.info( "allRoutes_actual = " )
637 main.log.info( allRoutesActual )
638
639 utilities.assertEquals(
640 expect="[]", actual=str( allRoutesActual ),
641 onpass="***Route number in SDN-IP is 0, correct!***",
642 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
643
644 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
645 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
646 else:
647 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
648
sanghoshin3de90272015-03-03 16:10:04 -0800649 #============================= Ping Test ========================
650 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
651 main.log.info("Ping test result")
652 if pingTestResults:
653 main.log.info("Test succeeded")
654 else:
655 main.log.info("Test failed")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800656
sanghoshin3de90272015-03-03 16:10:04 -0800657 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
658 onpass="disconnect check PASS",
659 onfail="disconnect check FAIL")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800660
sanghoshin3de90272015-03-03 16:10:04 -0800661 main.ONOScli.logout()
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800662 main.ONOSbench.onosStop(ONOS1Ip);
sanghoshin3de90272015-03-03 16:10:04 -0800663 main.Mininet.stopNet()
664 time.sleep(10)
665
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800666
sanghoshinb3500fa2015-03-06 12:51:29 -0800667
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800668 # Route convergence and connectivity test
669 def CASE21( self, main):
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800670 import time
671 import json
672 from operator import eq
673 # from datetime import datetime
674 from time import localtime, strftime
675
676 main.case("The test case is to help to setup the TestON environment \
677 and test new drivers" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800678 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
679 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/routeconvergence/mininet"
680 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json"
681 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
sanghoshin43dbcfb2015-03-02 12:02:40 -0800682
683 # Copy the json files to config dir
684 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/addresses.json ~/onos/tools/package/config/")
685 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/sdnip.json ~/onos/tools/package/config/")
686
687 # Launch mininet topology for this case
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800688 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterConvergenceMininet.py"
689 main.step( "Launch mininet" )
690 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
691 main.step("waiting 20 secs for all switches and quagga instances to comeup")
692 time.sleep(20)
693 main.step( "Test whether Mininet is started" )
694 main.log.info( "Login Quagga CLI on host3" )
695 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800696 # all expected routes for all BGP peers
697 allRoutesExpected = []
698 main.step( "Start to generate routes for all BGP peers" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800699 main.log.info( "Generate prefixes for host3" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800700
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800701 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
702 main.log.info( prefixesHost3 )
703 # generate route with next hop
704 for prefix in prefixesHost3:
705 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
706 routeIntentsExpectedHost3 = \
707 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
708 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
709 SDNIPJSONFILEPATH )
710
711 main.log.info( "Generate prefixes for host4" )
712 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
713 main.log.info( prefixesHost4 )
714 # generate route with next hop
715 for prefix in prefixesHost4:
716 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
717 routeIntentsExpectedHost4 = \
718 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
719 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
720 SDNIPJSONFILEPATH )
721
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800722 main.log.info( "Generate prefixes for host5" )
723 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
724 main.log.info( prefixesHost5 )
725 for prefix in prefixesHost5:
726 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
727 routeIntentsExpectedHost5 = \
728 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
729 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
730 SDNIPJSONFILEPATH )
731
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800732 routeIntentsExpected = routeIntentsExpectedHost3 + \
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800733 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800734
735 cellName = main.params[ 'ENV' ][ 'cellName' ]
736 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
737 main.step( "Set cell for ONOS-cli environment" )
738 main.ONOScli.setCell( cellName )
739 verifyResult = main.ONOSbench.verifyCell()
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800740
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800741 main.log.report( "Removing raft logs" )
742 main.ONOSbench.onosRemoveRaftLogs()
743 main.log.report( "Uninstalling ONOS" )
744 main.ONOSbench.onosUninstall( ONOS1Ip )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800745
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800746 main.step( "Installing ONOS package" )
747 onos1InstallResult = main.ONOSbench.onosInstall(
748 options="-f", node=ONOS1Ip )
749
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800750 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
751 if not onos1Isup:
752 main.log.report( "ONOS1 didn't start!" )
753
754 main.step( "Start ONOS-cli" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800755
756 main.ONOScli.startOnosCli( ONOS1Ip )
757
758 main.step( "Get devices in the network" )
759 listResult = main.ONOScli.devices( jsonFormat=False )
760 main.log.info( listResult )
761 time.sleep( 10 )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800762 main.log.info( "Installing gbprouter feature" )
763 main.ONOScli.featureInstall( "onos-app-bgprouter" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800764 time.sleep( 10 )
765 main.step( "Login all BGP peers and add routes into peers" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800766
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800767 main.log.info( "Login Quagga CLI on host3" )
768 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
769 main.log.info( "Enter configuration model of Quagga CLI on host3" )
770 main.QuaggaCliHost3.enterConfig( 64514 )
771 main.log.info( "Add routes to Quagga on host3" )
772 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
773
774 main.log.info( "Login Quagga CLI on host4" )
775 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
776 main.log.info( "Enter configuration model of Quagga CLI on host4" )
777 main.QuaggaCliHost4.enterConfig( 64516 )
778 main.log.info( "Add routes to Quagga on host4" )
779 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800780
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800781 main.log.info( "Login Quagga CLI on host5" )
782 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
783 main.log.info( "Enter configuration model of Quagga CLI on host5" )
784 main.QuaggaCliHost5.enterConfig( 64521 )
785 main.log.info( "Add routes to Quagga on host5" )
786 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
787
sanghoshin43dbcfb2015-03-02 12:02:40 -0800788 time.sleep( 30 )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800789
790 # get routes inside SDN-IP
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800791 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
792
793 # parse routes from ONOS CLI
794 allRoutesActual = \
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800795 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800796
797 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
798 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
799 main.step( "Check routes installed" )
800 main.log.info( "Routes expected:" )
801 main.log.info( allRoutesStrExpected )
802 main.log.info( "Routes get from ONOS CLI:" )
803 main.log.info( allRoutesStrActual )
804 utilities.assertEquals(
805 expect=allRoutesStrExpected, actual=allRoutesStrActual,
806 onpass="***Routes in SDN-IP are correct!***",
807 onfail="***Routes in SDN-IP are wrong!***" )
808 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
809 main.log.report(
810 "***Routes in SDN-IP after adding routes are correct!***" )
811 else:
812 main.log.report(
813 "***Routes in SDN-IP after adding routes are wrong!***" )
814
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800815 #============================= Ping Test ========================
816 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
817 main.log.info("Ping test result")
818 if pingTestResults:
819 main.log.info("Test succeeded")
820 else:
821 main.log.info("Test failed")
822
823 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
824 onpass="Default connectivity check PASS",
825 onfail="Default connectivity check FAIL")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800826
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800827 #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ==================
828 main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
829 main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" )
830 main.log.info( "Sleeping for 150 seconds for network to converge" )
831 time.sleep(150)
832 # get routes inside SDN-IP
833 main.log.info( "Getting Routes from ONOS CLI" )
834 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
835
836 # parse routes from ONOS CLI
837 newAllRoutesActual = \
838 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
839 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
840
841 # Expected routes with changed next hop
842 newAllRoutesExpected = []
843 for prefix in prefixesHost3:
844 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
845 for prefix in prefixesHost4:
846 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
847 for prefix in prefixesHost5:
848 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
849 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
850 main.step( "Check routes installed after convergence-1" )
851 main.log.info( "Routes expected:" )
852 main.log.info( newAllRoutesStrExpected )
853 main.log.info( "Routes got from ONOS CLI after convergence-1:" )
854 main.log.info( newAllRoutesStrActual )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800855 utilities.assertEquals(
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800856 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
857 onpass="***Routes in SDN-IP are correct after convergence!***",
858 onfail="***Routes in SDN-IP are wrong after convergence!***" )
859 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800860 main.log.report(
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800861 "***Routes in SDN-IP after convergence are correct!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800862 else:
863 main.log.report(
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800864 "***Routes in SDN-IP after convergence are wrong!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800865
866 #============================= Ping Test ========================
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800867 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
868 main.log.info("Ping test result")
869 if pingTestResults:
870 main.log.info("Test succeeded")
871 else:
872 main.log.info("Test failed")
873
874 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
875 onpass="Default connectivity check PASS",
876 onfail="Default connectivity check FAIL")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800877
Srikanth Vavilapalli43f3a1d2015-03-04 11:09:44 -0800878 #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ==================
879 main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
880 main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
881 main.log.info( "Sleeping for 150 seconds for network to converge" )
882 time.sleep(150)
883 # get routes inside SDN-IP
884 main.log.info( "Getting Routes from ONOS CLI" )
885 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
886
887 # parse routes from ONOS CLI
888 newAllRoutesActual = \
889 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
890 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
891
892 # Expected routes with changed next hop
893 newAllRoutesExpected = []
894 for prefix in prefixesHost3:
895 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
896 for prefix in prefixesHost4:
897 newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" )
898 for prefix in prefixesHost5:
899 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
900 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
901 main.step( "Check routes installed after convergence-2" )
902 main.log.info( "Routes expected:" )
903 main.log.info( newAllRoutesStrExpected )
904 main.log.info( "Routes got from ONOS CLI after convergence-2:" )
905 main.log.info( newAllRoutesStrActual )
906 utilities.assertEquals(
907 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
908 onpass="***Routes in SDN-IP are correct after convergence!***",
909 onfail="***Routes in SDN-IP are wrong after convergence!***" )
910 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
911 main.log.report(
912 "***Routes in SDN-IP after convergence are correct!***" )
913 else:
914 main.log.report(
915 "***Routes in SDN-IP after convergence are wrong!***" )
916
917 #============================= Ping Test ========================
918 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
919 main.log.info("Ping test result")
920 if pingTestResults:
921 main.log.info("Test succeeded")
922 else:
923 main.log.info("Test failed")
924
925 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
926 onpass="Default connectivity check PASS",
927 onfail="Default connectivity check FAIL")
928
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800929 #============================= Deleting Routes ==================
930 main.step( "Check deleting routes installed" )
931 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
932 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800933 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800934
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800935 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
936 allRoutesActual = \
937 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800938
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800939 main.log.info( "allRoutes_actual = " )
940 main.log.info( allRoutesActual )
941
942 utilities.assertEquals(
943 expect="[]", actual=str( allRoutesActual ),
944 onpass="***Route number in SDN-IP is 0, correct!***",
945 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
946
947 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800948 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800949 else:
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800950 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800951
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800952 #============================= Ping Test ========================
953 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
954 main.log.info("Ping test result")
955 if pingTestResults:
956 main.log.info("Test succeeded")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800957 else:
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800958 main.log.info("Test failed")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800959
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800960 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
961 onpass="disconnect check PASS",
962 onfail="disconnect check FAIL")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800963
sanghoshinc59d6c52015-03-03 10:01:07 -0800964 main.ONOScli.logout()
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800965 main.ONOSbench.onosStop(ONOS1Ip);
sanghoshin43dbcfb2015-03-02 12:02:40 -0800966 main.Mininet.stopNet()
967 time.sleep(10)
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800968
Srikanth Vavilapallie5388212015-03-05 13:55:53 -0800969 # Route convergence and connectivity test with Route Server
970 def CASE22( self, main):
971 import time
972 import json
973 from operator import eq
974 # from datetime import datetime
975 from time import localtime, strftime
976
977 main.case("The test case is to help to setup the TestON environment \
978 and test new drivers" )
979 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
980 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/routeserver/mininet"
981 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/routeserver/sdnip.json"
982 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
983
984 # Copy the json files to config dir
985 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/routeserver/addresses.json ~/onos/tools/package/config/")
986 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/routeserver/sdnip.json ~/onos/tools/package/config/")
987
988 # Launch mininet topology for this case
989 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouteServerMininet.py"
990 main.step( "Launch mininet" )
991 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
992 main.step("waiting 20 secs for all switches and quagga instances to comeup")
993 time.sleep(20)
994 main.step( "Test whether Mininet is started" )
995 main.log.info( "Login Quagga CLI on host3" )
996 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
997 # all expected routes for all BGP peers
998 allRoutesExpected = []
999 main.step( "Start to generate routes for all BGP peers" )
1000 main.log.info( "Generate prefixes for host3" )
1001
1002 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
1003 main.log.info( prefixesHost3 )
1004 # generate route with next hop
1005 for prefix in prefixesHost3:
1006 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1007 routeIntentsExpectedHost3 = \
1008 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
1009 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
1010 SDNIPJSONFILEPATH )
1011
1012 main.log.info( "Generate prefixes for host4" )
1013 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
1014 main.log.info( prefixesHost4 )
1015 # generate route with next hop
1016 for prefix in prefixesHost4:
1017 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
1018 routeIntentsExpectedHost4 = \
1019 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
1020 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
1021 SDNIPJSONFILEPATH )
1022
1023 main.log.info( "Generate prefixes for host5" )
1024 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
1025 main.log.info( prefixesHost5 )
1026 for prefix in prefixesHost5:
1027 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1028 routeIntentsExpectedHost5 = \
1029 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
1030 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
1031 SDNIPJSONFILEPATH )
1032
1033 routeIntentsExpected = routeIntentsExpectedHost3 + \
1034 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
1035
1036 cellName = main.params[ 'ENV' ][ 'cellName' ]
1037 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
1038 main.step( "Set cell for ONOS-cli environment" )
1039 main.ONOScli.setCell( cellName )
1040 verifyResult = main.ONOSbench.verifyCell()
1041
1042 main.log.report( "Removing raft logs" )
1043 main.ONOSbench.onosRemoveRaftLogs()
1044 main.log.report( "Uninstalling ONOS" )
1045 main.ONOSbench.onosUninstall( ONOS1Ip )
1046
1047 main.step( "Installing ONOS package" )
1048 onos1InstallResult = main.ONOSbench.onosInstall(
1049 options="-f", node=ONOS1Ip )
1050
1051 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
1052 if not onos1Isup:
1053 main.log.report( "ONOS1 didn't start!" )
1054
1055 main.step( "Start ONOS-cli" )
1056
1057 main.ONOScli.startOnosCli( ONOS1Ip )
1058
1059 main.step( "Get devices in the network" )
1060 listResult = main.ONOScli.devices( jsonFormat=False )
1061 main.log.info( listResult )
1062 time.sleep( 10 )
1063 main.log.info( "Installing gbprouter feature" )
1064 main.ONOScli.featureInstall( "onos-app-bgprouter" )
1065 time.sleep( 10 )
1066 main.step( "Login all BGP peers and add routes into peers" )
1067
1068 main.log.info( "Login Quagga CLI on host3" )
1069 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
1070 main.log.info( "Enter configuration model of Quagga CLI on host3" )
1071 main.QuaggaCliHost3.enterConfig( 64514 )
1072 main.log.info( "Add routes to Quagga on host3" )
1073 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
1074
1075 main.log.info( "Login Quagga CLI on host4" )
1076 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
1077 main.log.info( "Enter configuration model of Quagga CLI on host4" )
1078 main.QuaggaCliHost4.enterConfig( 64516 )
1079 main.log.info( "Add routes to Quagga on host4" )
1080 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
1081
1082 main.log.info( "Login Quagga CLI on host5" )
1083 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
1084 main.log.info( "Enter configuration model of Quagga CLI on host5" )
1085 main.QuaggaCliHost5.enterConfig( 64521 )
1086 main.log.info( "Add routes to Quagga on host5" )
1087 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
1088
1089 time.sleep( 60 )
1090
1091 # get routes inside SDN-IP
1092 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1093
1094 # parse routes from ONOS CLI
1095 allRoutesActual = \
1096 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1097
1098 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
1099 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
1100 main.step( "Check routes installed" )
1101 main.log.info( "Routes expected:" )
1102 main.log.info( allRoutesStrExpected )
1103 main.log.info( "Routes get from ONOS CLI:" )
1104 main.log.info( allRoutesStrActual )
1105 utilities.assertEquals(
1106 expect=allRoutesStrExpected, actual=allRoutesStrActual,
1107 onpass="***Routes in SDN-IP are correct!***",
1108 onfail="***Routes in SDN-IP are wrong!***" )
1109 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1110 main.log.report(
1111 "***Routes in SDN-IP after adding routes are correct!***" )
1112 else:
1113 main.log.report(
1114 "***Routes in SDN-IP after adding routes are wrong!***" )
1115
1116 #============================= Ping Test ========================
1117 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1118 main.log.info("Ping test result")
1119 if pingTestResults:
1120 main.log.info("Test succeeded")
1121 else:
1122 main.log.info("Test failed")
1123
1124 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1125 onpass="Default connectivity check PASS",
1126 onfail="Default connectivity check FAIL")
1127
1128 #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ==================
1129 main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
1130 main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" )
1131 main.log.info( "Sleeping for 150 seconds for network to converge" )
1132 time.sleep(150)
1133 # get routes inside SDN-IP
1134 main.log.info( "Getting Routes from ONOS CLI" )
1135 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1136
1137 # parse routes from ONOS CLI
1138 newAllRoutesActual = \
1139 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1140 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
1141
1142 # Expected routes with changed next hop
1143 newAllRoutesExpected = []
1144 for prefix in prefixesHost3:
1145 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1146 for prefix in prefixesHost4:
1147 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1148 for prefix in prefixesHost5:
1149 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1150 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
1151 main.step( "Check routes installed after convergence-1" )
1152 main.log.info( "Routes expected:" )
1153 main.log.info( newAllRoutesStrExpected )
1154 main.log.info( "Routes got from ONOS CLI after convergence-1:" )
1155 main.log.info( newAllRoutesStrActual )
1156 utilities.assertEquals(
1157 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
1158 onpass="***Routes in SDN-IP are correct after convergence!***",
1159 onfail="***Routes in SDN-IP are wrong after convergence!***" )
1160 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
1161 main.log.report(
1162 "***Routes in SDN-IP after convergence are correct!***" )
1163 else:
1164 main.log.report(
1165 "***Routes in SDN-IP after convergence are wrong!***" )
1166
1167 #============================= Ping Test ========================
1168 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1169 main.log.info("Ping test result")
1170 if pingTestResults:
1171 main.log.info("Test succeeded")
1172 else:
1173 main.log.info("Test failed")
1174
1175 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1176 onpass="Default connectivity check PASS",
1177 onfail="Default connectivity check FAIL")
1178
1179 #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ==================
1180 main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
1181 main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
1182 main.log.info( "Sleeping for 150 seconds for network to converge" )
1183 time.sleep(150)
1184 # get routes inside SDN-IP
1185 main.log.info( "Getting Routes from ONOS CLI" )
1186 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1187
1188 # parse routes from ONOS CLI
1189 newAllRoutesActual = \
1190 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1191 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
1192
1193 # Expected routes with changed next hop
1194 newAllRoutesExpected = []
1195 for prefix in prefixesHost3:
1196 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1197 for prefix in prefixesHost4:
1198 newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" )
1199 for prefix in prefixesHost5:
1200 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1201 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
1202 main.step( "Check routes installed after convergence-2" )
1203 main.log.info( "Routes expected:" )
1204 main.log.info( newAllRoutesStrExpected )
1205 main.log.info( "Routes got from ONOS CLI after convergence-2:" )
1206 main.log.info( newAllRoutesStrActual )
1207 utilities.assertEquals(
1208 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
1209 onpass="***Routes in SDN-IP are correct after convergence!***",
1210 onfail="***Routes in SDN-IP are wrong after convergence!***" )
1211 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
1212 main.log.report(
1213 "***Routes in SDN-IP after convergence are correct!***" )
1214 else:
1215 main.log.report(
1216 "***Routes in SDN-IP after convergence are wrong!***" )
1217
1218 #============================= Ping Test ========================
1219 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1220 main.log.info("Ping test result")
1221 if pingTestResults:
1222 main.log.info("Test succeeded")
1223 else:
1224 main.log.info("Test failed")
1225
1226 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1227 onpass="Default connectivity check PASS",
1228 onfail="Default connectivity check FAIL")
1229
1230 #============================= Deleting Routes ==================
1231 main.step( "Check deleting routes installed" )
1232 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
1233 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
1234 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
1235
1236 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1237 allRoutesActual = \
1238 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1239
1240 main.log.info( "allRoutes_actual = " )
1241 main.log.info( allRoutesActual )
1242
1243 utilities.assertEquals(
1244 expect="[]", actual=str( allRoutesActual ),
1245 onpass="***Route number in SDN-IP is 0, correct!***",
1246 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
1247
1248 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1249 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
1250 else:
1251 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
1252
1253 #============================= Ping Test ========================
1254 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
1255 main.log.info("Ping test result")
1256 if pingTestResults:
1257 main.log.info("Test succeeded")
1258 else:
1259 main.log.info("Test failed")
1260
1261 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1262 onpass="disconnect check PASS",
1263 onfail="disconnect check FAIL")
1264
1265 main.ONOScli.logout()
1266 main.ONOSbench.onosStop(ONOS1Ip);
1267 main.Mininet.stopNet()
1268 time.sleep(10)
1269
Srikanth Vavilapallida0b4e52015-03-09 16:09:15 -07001270 # Route convergence and connectivity test in VLAN configuration
1271 def CASE31( self, main):
1272 import time
1273 import json
1274 from operator import eq
1275 # from datetime import datetime
1276 from time import localtime, strftime
1277
1278 main.case("The test case is to help to setup the TestON environment \
1279 and test new drivers" )
1280 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
1281 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/routeconvergence/mininet"
1282 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/sdnip.json"
1283 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
1284
1285 # Copy the json files to config dir
1286 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/addresses.json ~/onos/tools/package/config/")
1287 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/sdnip.json ~/onos/tools/package/config/")
1288
1289 # Launch mininet topology for this case
1290 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterConvergenceVlanMininet.py"
1291 main.step( "Launch mininet" )
1292 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
1293 main.step("waiting 20 secs for all switches and quagga instances to comeup")
1294 time.sleep(20)
1295 main.step( "Test whether Mininet is started" )
1296 main.log.info( "Login Quagga CLI on host3" )
1297 result = main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
1298 #if result is not main.TRUE:
1299 # main.log.report("Mininet is not started...Aborting")
1300 # main.Mininet.stopNet()
1301 # main.cleanup()
1302 # main.exit()
1303 # all expected routes for all BGP peers
1304 allRoutesExpected = []
1305 main.step( "Start to generate routes for all BGP peers" )
1306 main.log.info( "Generate prefixes for host3" )
1307
1308 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
1309 main.log.info( prefixesHost3 )
1310 # generate route with next hop
1311 for prefix in prefixesHost3:
1312 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1313 routeIntentsExpectedHost3 = \
1314 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
1315 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
1316 SDNIPJSONFILEPATH )
1317
1318 main.log.info( "Generate prefixes for host4" )
1319 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
1320 main.log.info( prefixesHost4 )
1321 # generate route with next hop
1322 for prefix in prefixesHost4:
1323 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
1324 routeIntentsExpectedHost4 = \
1325 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
1326 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
1327 SDNIPJSONFILEPATH )
1328
1329 main.log.info( "Generate prefixes for host5" )
1330 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
1331 main.log.info( prefixesHost5 )
1332 for prefix in prefixesHost5:
1333 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1334 routeIntentsExpectedHost5 = \
1335 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
1336 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
1337 SDNIPJSONFILEPATH )
1338
1339 routeIntentsExpected = routeIntentsExpectedHost3 + \
1340 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
1341
1342 cellName = main.params[ 'ENV' ][ 'cellName' ]
1343 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
1344 main.step( "Set cell for ONOS-cli environment" )
1345 main.ONOScli.setCell( cellName )
1346 verifyResult = main.ONOSbench.verifyCell()
1347 utilities.assert_equals(expect=main.TRUE,actual=verifyResult,onpass="Verify cell pass!",onfail="Verify cell failed...")
1348
1349 main.log.report( "Removing raft logs" )
1350 main.ONOSbench.onosRemoveRaftLogs()
1351 main.log.report( "Uninstalling ONOS" )
1352 main.ONOSbench.onosUninstall( ONOS1Ip )
1353
1354 main.step( "Installing ONOS package" )
1355 onos1InstallResult = main.ONOSbench.onosInstall(
1356 options="-f", node=ONOS1Ip )
1357 if onos1InstallResult is not main.TRUE:
1358 main.log.report("ONOS is not installed...Aborting")
1359 main.Mininet.stopNet()
1360 main.cleanup()
1361 main.exit()
1362
1363 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
1364 if onos1Isup is not main.TRUE:
1365 main.log.report("ONOS1 didn't start!...Aborting" )
1366 main.Mininet.stopNet()
1367 main.ONOSbench.onosStop(ONOS1Ip);
1368 main.cleanup()
1369 main.exit()
1370
1371 main.step( "Start ONOS-cli" )
1372
1373 result = main.ONOScli.startOnosCli( ONOS1Ip )
1374 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="ONOS CLI is up!",onfail="ONOS CLI is not up...")
1375 if result is not main.TRUE:
1376 main.log.report("ONOS1 didn't start!...Aborting" )
1377 main.Mininet.stopNet()
1378 main.ONOScli.logout()
1379 main.ONOSbench.onosStop(ONOS1Ip);
1380 main.cleanup()
1381 main.exit()
1382
1383
1384 main.step( "Get devices in the network" )
1385 listResult = main.ONOScli.devices( jsonFormat=False )
1386 main.log.info( listResult )
1387 time.sleep( 10 )
1388 main.log.info( "Installing bgprouter feature" )
1389 main.ONOScli.featureInstall( "onos-app-bgprouter" )
1390 time.sleep( 10 )
1391 main.step( "Login all BGP peers and add routes into peers" )
1392
1393 main.log.info( "Login Quagga CLI on host3" )
1394 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
1395 main.log.info( "Enter configuration model of Quagga CLI on host3" )
1396 main.QuaggaCliHost3.enterConfig( 64514 )
1397 main.log.info( "Add routes to Quagga on host3" )
1398 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
1399
1400 main.log.info( "Login Quagga CLI on host4" )
1401 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
1402 main.log.info( "Enter configuration model of Quagga CLI on host4" )
1403 main.QuaggaCliHost4.enterConfig( 64516 )
1404 main.log.info( "Add routes to Quagga on host4" )
1405 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
1406
1407 main.log.info( "Login Quagga CLI on host5" )
1408 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
1409 main.log.info( "Enter configuration model of Quagga CLI on host5" )
1410 main.QuaggaCliHost5.enterConfig( 64521 )
1411 main.log.info( "Add routes to Quagga on host5" )
1412 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
1413
1414 time.sleep( 30 )
1415
1416 # get routes inside SDN-IP
1417 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1418
1419 # parse routes from ONOS CLI
1420 allRoutesActual = \
1421 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1422
1423 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
1424 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
1425 main.step( "Check routes installed" )
1426 main.log.info( "Routes expected:" )
1427 main.log.info( allRoutesStrExpected )
1428 main.log.info( "Routes get from ONOS CLI:" )
1429 main.log.info( allRoutesStrActual )
1430 utilities.assertEquals(
1431 expect=allRoutesStrExpected, actual=allRoutesStrActual,
1432 onpass="***Routes in SDN-IP are correct!***",
1433 onfail="***Routes in SDN-IP are wrong!***" )
1434 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1435 main.log.report(
1436 "***Routes in SDN-IP after adding routes are correct!***" )
1437 else:
1438 main.log.report(
1439 "***Routes in SDN-IP after adding routes are wrong!***" )
1440
1441 #============================= Ping Test ========================
1442 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1443 main.log.info("Ping test result")
1444 if pingTestResults:
1445 main.log.info("Test succeeded")
1446 else:
1447 main.log.info("Test failed")
1448
1449 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1450 onpass="Default connectivity check PASS",
1451 onfail="Default connectivity check FAIL")
1452
1453 #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ==================
1454 main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
1455 main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" )
1456 main.log.info( "Sleeping for 150 seconds for network to converge" )
1457 time.sleep(150)
1458 # get routes inside SDN-IP
1459 main.log.info( "Getting Routes from ONOS CLI" )
1460 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1461
1462 # parse routes from ONOS CLI
1463 newAllRoutesActual = \
1464 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1465 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
1466
1467 # Expected routes with changed next hop
1468 newAllRoutesExpected = []
1469 for prefix in prefixesHost3:
1470 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1471 for prefix in prefixesHost4:
1472 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1473 for prefix in prefixesHost5:
1474 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1475 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
1476 main.step( "Check routes installed after convergence-1" )
1477 main.log.info( "Routes expected:" )
1478 main.log.info( newAllRoutesStrExpected )
1479 main.log.info( "Routes got from ONOS CLI after convergence-1:" )
1480 main.log.info( newAllRoutesStrActual )
1481 utilities.assertEquals(
1482 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
1483 onpass="***Routes in SDN-IP are correct after convergence!***",
1484 onfail="***Routes in SDN-IP are wrong after convergence!***" )
1485 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
1486 main.log.report(
1487 "***Routes in SDN-IP after convergence are correct!***" )
1488 else:
1489 main.log.report(
1490 "***Routes in SDN-IP after convergence are wrong!***" )
1491
1492 #============================= Ping Test ========================
1493 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1494 main.log.info("Ping test result")
1495 if pingTestResults:
1496 main.log.info("Test succeeded")
1497 else:
1498 main.log.info("Test failed")
1499
1500 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1501 onpass="Default connectivity check PASS",
1502 onfail="Default connectivity check FAIL")
1503
1504 #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ==================
1505 main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
1506 main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
1507 main.log.info( "Sleeping for 150 seconds for network to converge" )
1508 time.sleep(150)
1509 # get routes inside SDN-IP
1510 main.log.info( "Getting Routes from ONOS CLI" )
1511 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1512
1513 # parse routes from ONOS CLI
1514 newAllRoutesActual = \
1515 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1516 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
1517
1518 # Expected routes with changed next hop
1519 newAllRoutesExpected = []
1520 for prefix in prefixesHost3:
1521 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1522 for prefix in prefixesHost4:
1523 newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" )
1524 for prefix in prefixesHost5:
1525 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1526 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
1527 main.step( "Check routes installed after convergence-2" )
1528 main.log.info( "Routes expected:" )
1529 main.log.info( newAllRoutesStrExpected )
1530 main.log.info( "Routes got from ONOS CLI after convergence-2:" )
1531 main.log.info( newAllRoutesStrActual )
1532 utilities.assertEquals(
1533 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
1534 onpass="***Routes in SDN-IP are correct after convergence!***",
1535 onfail="***Routes in SDN-IP are wrong after convergence!***" )
1536 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
1537 main.log.report(
1538 "***Routes in SDN-IP after convergence are correct!***" )
1539 else:
1540 main.log.report(
1541 "***Routes in SDN-IP after convergence are wrong!***" )
1542
1543 #============================= Ping Test ========================
1544 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1545 main.log.info("Ping test result")
1546 if pingTestResults:
1547 main.log.info("Test succeeded")
1548 else:
1549 main.log.info("Test failed")
1550
1551 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1552 onpass="Default connectivity check PASS",
1553 onfail="Default connectivity check FAIL")
1554
1555 #============================= Deleting Routes ==================
1556 main.step( "Check deleting routes installed" )
1557 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
1558 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
1559 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
1560
1561 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1562 allRoutesActual = \
1563 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1564
1565 main.log.info( "allRoutes_actual = " )
1566 main.log.info( allRoutesActual )
1567
1568 utilities.assertEquals(
1569 expect="[]", actual=str( allRoutesActual ),
1570 onpass="***Route number in SDN-IP is 0, correct!***",
1571 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
1572
1573 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1574 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
1575 else:
1576 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
1577
1578 #============================= Ping Test ========================
1579 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
1580 main.log.info("Ping test result")
1581 if pingTestResults:
1582 main.log.info("Test succeeded")
1583 else:
1584 main.log.info("Test failed")
1585
1586 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1587 onpass="disconnect check PASS",
1588 onfail="disconnect check FAIL")
1589
1590 main.ONOScli.logout()
1591 main.ONOSbench.onosStop(ONOS1Ip);
1592 main.Mininet.stopNet()
1593 time.sleep(10)
1594
1595 # Route convergence and connectivity test with Route Server in VLAN tagged network
1596 def CASE32( self, main):
1597 import time
1598 import json
1599 from operator import eq
1600 # from datetime import datetime
1601 from time import localtime, strftime
1602
1603 main.case("The test case is to help to setup the TestON environment \
1604 and test new drivers" )
1605 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
1606 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/routeserver/mininet"
1607 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/routeserver/sdnip.json"
1608 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
1609
1610 # Copy the json files to config dir
1611 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/routeserver/addresses.json ~/onos/tools/package/config/")
1612 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/routeserver/sdnip.json ~/onos/tools/package/config/")
1613
1614 # Launch mininet topology for this case
1615 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouteServerVlanMininet.py"
1616 main.step( "Launch mininet" )
1617 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
1618 main.step("waiting 20 secs for all switches and quagga instances to comeup")
1619 time.sleep(20)
1620 main.step( "Test whether Mininet is started" )
1621 main.log.info( "Login Quagga CLI on host3" )
1622 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
1623 # all expected routes for all BGP peers
1624 allRoutesExpected = []
1625 main.step( "Start to generate routes for all BGP peers" )
1626 main.log.info( "Generate prefixes for host3" )
1627
1628 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
1629 main.log.info( prefixesHost3 )
1630 # generate route with next hop
1631 for prefix in prefixesHost3:
1632 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1633 routeIntentsExpectedHost3 = \
1634 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
1635 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
1636 SDNIPJSONFILEPATH )
1637
1638 main.log.info( "Generate prefixes for host4" )
1639 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
1640 main.log.info( prefixesHost4 )
1641 # generate route with next hop
1642 for prefix in prefixesHost4:
1643 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
1644 routeIntentsExpectedHost4 = \
1645 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
1646 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
1647 SDNIPJSONFILEPATH )
1648
1649 main.log.info( "Generate prefixes for host5" )
1650 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
1651 main.log.info( prefixesHost5 )
1652 for prefix in prefixesHost5:
1653 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1654 routeIntentsExpectedHost5 = \
1655 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
1656 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
1657 SDNIPJSONFILEPATH )
1658
1659 routeIntentsExpected = routeIntentsExpectedHost3 + \
1660 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
1661
1662 cellName = main.params[ 'ENV' ][ 'cellName' ]
1663 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
1664 main.step( "Set cell for ONOS-cli environment" )
1665 main.ONOScli.setCell( cellName )
1666 verifyResult = main.ONOSbench.verifyCell()
1667
1668 main.log.report( "Removing raft logs" )
1669 main.ONOSbench.onosRemoveRaftLogs()
1670 main.log.report( "Uninstalling ONOS" )
1671 main.ONOSbench.onosUninstall( ONOS1Ip )
1672
1673 main.step( "Installing ONOS package" )
1674 onos1InstallResult = main.ONOSbench.onosInstall(
1675 options="-f", node=ONOS1Ip )
1676
1677 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
1678 if not onos1Isup:
1679 main.log.report( "ONOS1 didn't start!" )
1680
1681 main.step( "Start ONOS-cli" )
1682
1683 main.ONOScli.startOnosCli( ONOS1Ip )
1684
1685 main.step( "Get devices in the network" )
1686 listResult = main.ONOScli.devices( jsonFormat=False )
1687 main.log.info( listResult )
1688 time.sleep( 10 )
1689 main.log.info( "Installing gbprouter feature" )
1690 main.ONOScli.featureInstall( "onos-app-bgprouter" )
1691 time.sleep( 10 )
1692 main.step( "Login all BGP peers and add routes into peers" )
1693
1694 main.log.info( "Login Quagga CLI on host3" )
1695 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
1696 main.log.info( "Enter configuration model of Quagga CLI on host3" )
1697 main.QuaggaCliHost3.enterConfig( 64514 )
1698 main.log.info( "Add routes to Quagga on host3" )
1699 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
1700
1701 main.log.info( "Login Quagga CLI on host4" )
1702 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
1703 main.log.info( "Enter configuration model of Quagga CLI on host4" )
1704 main.QuaggaCliHost4.enterConfig( 64516 )
1705 main.log.info( "Add routes to Quagga on host4" )
1706 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
1707
1708 main.log.info( "Login Quagga CLI on host5" )
1709 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
1710 main.log.info( "Enter configuration model of Quagga CLI on host5" )
1711 main.QuaggaCliHost5.enterConfig( 64521 )
1712 main.log.info( "Add routes to Quagga on host5" )
1713 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
1714
1715 time.sleep( 60 )
1716
1717 # get routes inside SDN-IP
1718 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1719
1720 # parse routes from ONOS CLI
1721 allRoutesActual = \
1722 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1723
1724 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
1725 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
1726 main.step( "Check routes installed" )
1727 main.log.info( "Routes expected:" )
1728 main.log.info( allRoutesStrExpected )
1729 main.log.info( "Routes get from ONOS CLI:" )
1730 main.log.info( allRoutesStrActual )
1731 utilities.assertEquals(
1732 expect=allRoutesStrExpected, actual=allRoutesStrActual,
1733 onpass="***Routes in SDN-IP are correct!***",
1734 onfail="***Routes in SDN-IP are wrong!***" )
1735 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1736 main.log.report(
1737 "***Routes in SDN-IP after adding routes are correct!***" )
1738 else:
1739 main.log.report(
1740 "***Routes in SDN-IP after adding routes are wrong!***" )
1741
1742 #============================= Ping Test ========================
1743 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1744 main.log.info("Ping test result")
1745 if pingTestResults:
1746 main.log.info("Test succeeded")
1747 else:
1748 main.log.info("Test failed")
1749
1750 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1751 onpass="Default connectivity check PASS",
1752 onfail="Default connectivity check FAIL")
1753
1754 #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ==================
1755 main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
1756 main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" )
1757 main.log.info( "Sleeping for 150 seconds for network to converge" )
1758 time.sleep(150)
1759 # get routes inside SDN-IP
1760 main.log.info( "Getting Routes from ONOS CLI" )
1761 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1762
1763 # parse routes from ONOS CLI
1764 newAllRoutesActual = \
1765 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1766 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
1767
1768 # Expected routes with changed next hop
1769 newAllRoutesExpected = []
1770 for prefix in prefixesHost3:
1771 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1772 for prefix in prefixesHost4:
1773 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1774 for prefix in prefixesHost5:
1775 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1776 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
1777 main.step( "Check routes installed after convergence-1" )
1778 main.log.info( "Routes expected:" )
1779 main.log.info( newAllRoutesStrExpected )
1780 main.log.info( "Routes got from ONOS CLI after convergence-1:" )
1781 main.log.info( newAllRoutesStrActual )
1782 utilities.assertEquals(
1783 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
1784 onpass="***Routes in SDN-IP are correct after convergence!***",
1785 onfail="***Routes in SDN-IP are wrong after convergence!***" )
1786 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
1787 main.log.report(
1788 "***Routes in SDN-IP after convergence are correct!***" )
1789 else:
1790 main.log.report(
1791 "***Routes in SDN-IP after convergence are wrong!***" )
1792
1793 #============================= Ping Test ========================
1794 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1795 main.log.info("Ping test result")
1796 if pingTestResults:
1797 main.log.info("Test succeeded")
1798 else:
1799 main.log.info("Test failed")
1800
1801 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1802 onpass="Default connectivity check PASS",
1803 onfail="Default connectivity check FAIL")
1804
1805 #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ==================
1806 main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
1807 main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
1808 main.log.info( "Sleeping for 150 seconds for network to converge" )
1809 time.sleep(150)
1810 # get routes inside SDN-IP
1811 main.log.info( "Getting Routes from ONOS CLI" )
1812 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1813
1814 # parse routes from ONOS CLI
1815 newAllRoutesActual = \
1816 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1817 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
1818
1819 # Expected routes with changed next hop
1820 newAllRoutesExpected = []
1821 for prefix in prefixesHost3:
1822 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1823 for prefix in prefixesHost4:
1824 newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" )
1825 for prefix in prefixesHost5:
1826 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1827 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
1828 main.step( "Check routes installed after convergence-2" )
1829 main.log.info( "Routes expected:" )
1830 main.log.info( newAllRoutesStrExpected )
1831 main.log.info( "Routes got from ONOS CLI after convergence-2:" )
1832 main.log.info( newAllRoutesStrActual )
1833 utilities.assertEquals(
1834 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
1835 onpass="***Routes in SDN-IP are correct after convergence!***",
1836 onfail="***Routes in SDN-IP are wrong after convergence!***" )
1837 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
1838 main.log.report(
1839 "***Routes in SDN-IP after convergence are correct!***" )
1840 else:
1841 main.log.report(
1842 "***Routes in SDN-IP after convergence are wrong!***" )
1843
1844 #============================= Ping Test ========================
1845 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1846 main.log.info("Ping test result")
1847 if pingTestResults:
1848 main.log.info("Test succeeded")
1849 else:
1850 main.log.info("Test failed")
1851
1852 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1853 onpass="Default connectivity check PASS",
1854 onfail="Default connectivity check FAIL")
1855
1856 #============================= Deleting Routes ==================
1857 main.step( "Check deleting routes installed" )
1858 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
1859 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
1860 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
1861
1862 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1863 allRoutesActual = \
1864 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1865
1866 main.log.info( "allRoutes_actual = " )
1867 main.log.info( allRoutesActual )
1868
1869 utilities.assertEquals(
1870 expect="[]", actual=str( allRoutesActual ),
1871 onpass="***Route number in SDN-IP is 0, correct!***",
1872 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
1873
1874 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1875 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
1876 else:
1877 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
1878
1879 #============================= Ping Test ========================
1880 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
1881 main.log.info("Ping test result")
1882 if pingTestResults:
1883 main.log.info("Test succeeded")
1884 else:
1885 main.log.info("Test failed")
1886
1887 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1888 onpass="disconnect check PASS",
1889 onfail="disconnect check FAIL")
1890
1891 main.ONOScli.logout()
1892 main.ONOSbench.onosStop(ONOS1Ip);
1893 main.Mininet.stopNet()
1894 time.sleep(10)
1895