blob: a58ca2454b13fbe70d6faa0c9b3a0bebea6c2b54 [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"
sanghoshin70502002015-03-11 10:21:14 -0700481 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/sdnip.json"
sanghoshinb3500fa2015-03-06 12:51:29 -0800482 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
483
484 # Copy the json files to config dir
sanghoshin70502002015-03-11 10:21:14 -0700485 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/addresses.json ~/onos/tools/package/config/")
486 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/sdnip.json ~/onos/tools/package/config/")
sanghoshinb3500fa2015-03-06 12:51:29 -0800487
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" )
sanghoshin70502002015-03-11 10:21:14 -0700502 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 3500 )
sanghoshinb3500fa2015-03-06 12:51:29 -0800503 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" )
sanghoshin70502002015-03-11 10:21:14 -0700512 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 3500 )
sanghoshinb3500fa2015-03-06 12:51:29 -0800513 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" )
sanghoshin70502002015-03-11 10:21:14 -0700523 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 3500 )
sanghoshinb3500fa2015-03-06 12:51:29 -0800524 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
sanghoshin70502002015-03-11 10:21:14 -0700573 time.sleep(20)
574
sanghoshinb3500fa2015-03-06 12:51:29 -0800575 main.log.info( "Login Quagga CLI on host4" )
576 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
577 main.log.info( "Enter configuration model of Quagga CLI on host4" )
578 main.QuaggaCliHost4.enterConfig( 64516 )
579 main.log.info( "Add routes to Quagga on host4" )
580 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
581
sanghoshin70502002015-03-11 10:21:14 -0700582 time.sleep(20)
583
sanghoshinb3500fa2015-03-06 12:51:29 -0800584 main.log.info( "Login Quagga CLI on host5" )
585 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
586 main.log.info( "Enter configuration model of Quagga CLI on host5" )
587 main.QuaggaCliHost5.enterConfig( 64521 )
588 main.log.info( "Add routes to Quagga on host5" )
589 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
590
sanghoshin70502002015-03-11 10:21:14 -0700591 time.sleep(60)
592
593 # get routes inside SDN-IP
594 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
595
596 # parse routes from ONOS CLI
597 allRoutesActual = \
598 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
599
600 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
601 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
sanghoshinb3500fa2015-03-06 12:51:29 -0800602
603 # get routes inside SDN-IP
604 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
605
606 # parse routes from ONOS CLI
607 allRoutesActual = \
608 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
609
610 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
611 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
612 main.step( "Check routes installed" )
613 main.log.info( "Routes expected:" )
614 main.log.info( allRoutesStrExpected )
615 main.log.info( "Routes get from ONOS CLI:" )
616 main.log.info( allRoutesStrActual )
617 utilities.assertEquals(
618 expect=allRoutesStrExpected, actual=allRoutesStrActual,
619 onpass="***Routes in SDN-IP are correct!***",
620 onfail="***Routes in SDN-IP are wrong!***" )
621 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
622 main.log.report(
623 "***Routes in SDN-IP after adding routes are correct!***" )
624 else:
625 main.log.report(
626 "***Routes in SDN-IP after adding routes are wrong!***" )
627
sanghoshin70502002015-03-11 10:21:14 -0700628 time.sleep(20)
629
630
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800631 #============================= Ping Test ========================
sanghoshin70502002015-03-11 10:21:14 -0700632 pingTestResults = main.TRUE
633 for m in range( 3, 6 ):
634 for n in range( 1, 10 ):
635 hostIp = str( m ) + ".0." + str( n ) + ".1"
636 r = main.Mininet.pingHost(SRC="as2host", TARGET=hostIp)
637 if r == main.FALSE:
638 pingTestResults = main.FALSE
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800639
sanghoshin3de90272015-03-03 16:10:04 -0800640 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
641 onpass="Default connectivity check PASS",
642 onfail="Default connectivity check FAIL")
sanghoshinb3500fa2015-03-06 12:51:29 -0800643
sanghoshin3de90272015-03-03 16:10:04 -0800644 time.sleep(10)
645
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800646 # Route convergence and connectivity test
647 def CASE21( self, main):
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800648 import time
649 import json
650 from operator import eq
651 # from datetime import datetime
652 from time import localtime, strftime
653
654 main.case("The test case is to help to setup the TestON environment \
655 and test new drivers" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800656 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
657 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/routeconvergence/mininet"
658 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json"
659 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
sanghoshin43dbcfb2015-03-02 12:02:40 -0800660
661 # Copy the json files to config dir
662 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/addresses.json ~/onos/tools/package/config/")
663 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/sdnip.json ~/onos/tools/package/config/")
664
665 # Launch mininet topology for this case
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800666 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterConvergenceMininet.py"
667 main.step( "Launch mininet" )
668 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
669 main.step("waiting 20 secs for all switches and quagga instances to comeup")
670 time.sleep(20)
671 main.step( "Test whether Mininet is started" )
672 main.log.info( "Login Quagga CLI on host3" )
673 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800674 # all expected routes for all BGP peers
675 allRoutesExpected = []
676 main.step( "Start to generate routes for all BGP peers" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800677 main.log.info( "Generate prefixes for host3" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800678
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800679 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
680 main.log.info( prefixesHost3 )
681 # generate route with next hop
682 for prefix in prefixesHost3:
683 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
684 routeIntentsExpectedHost3 = \
685 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
686 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
687 SDNIPJSONFILEPATH )
688
689 main.log.info( "Generate prefixes for host4" )
690 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
691 main.log.info( prefixesHost4 )
692 # generate route with next hop
693 for prefix in prefixesHost4:
694 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
695 routeIntentsExpectedHost4 = \
696 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
697 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
698 SDNIPJSONFILEPATH )
699
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800700 main.log.info( "Generate prefixes for host5" )
701 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
702 main.log.info( prefixesHost5 )
703 for prefix in prefixesHost5:
704 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
705 routeIntentsExpectedHost5 = \
706 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
707 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
708 SDNIPJSONFILEPATH )
709
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800710 routeIntentsExpected = routeIntentsExpectedHost3 + \
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800711 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800712
713 cellName = main.params[ 'ENV' ][ 'cellName' ]
714 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
715 main.step( "Set cell for ONOS-cli environment" )
716 main.ONOScli.setCell( cellName )
717 verifyResult = main.ONOSbench.verifyCell()
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800718
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800719 main.log.report( "Removing raft logs" )
720 main.ONOSbench.onosRemoveRaftLogs()
721 main.log.report( "Uninstalling ONOS" )
722 main.ONOSbench.onosUninstall( ONOS1Ip )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800723
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800724 main.step( "Installing ONOS package" )
725 onos1InstallResult = main.ONOSbench.onosInstall(
726 options="-f", node=ONOS1Ip )
727
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800728 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
729 if not onos1Isup:
730 main.log.report( "ONOS1 didn't start!" )
731
732 main.step( "Start ONOS-cli" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800733
734 main.ONOScli.startOnosCli( ONOS1Ip )
735
736 main.step( "Get devices in the network" )
737 listResult = main.ONOScli.devices( jsonFormat=False )
738 main.log.info( listResult )
739 time.sleep( 10 )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800740 main.log.info( "Installing gbprouter feature" )
741 main.ONOScli.featureInstall( "onos-app-bgprouter" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800742 time.sleep( 10 )
743 main.step( "Login all BGP peers and add routes into peers" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800744
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800745 main.log.info( "Login Quagga CLI on host3" )
746 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
747 main.log.info( "Enter configuration model of Quagga CLI on host3" )
748 main.QuaggaCliHost3.enterConfig( 64514 )
749 main.log.info( "Add routes to Quagga on host3" )
750 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
751
752 main.log.info( "Login Quagga CLI on host4" )
753 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
754 main.log.info( "Enter configuration model of Quagga CLI on host4" )
755 main.QuaggaCliHost4.enterConfig( 64516 )
756 main.log.info( "Add routes to Quagga on host4" )
757 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800758
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800759 main.log.info( "Login Quagga CLI on host5" )
760 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
761 main.log.info( "Enter configuration model of Quagga CLI on host5" )
762 main.QuaggaCliHost5.enterConfig( 64521 )
763 main.log.info( "Add routes to Quagga on host5" )
764 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
765
sanghoshin43dbcfb2015-03-02 12:02:40 -0800766 time.sleep( 30 )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800767
768 # get routes inside SDN-IP
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800769 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
770
771 # parse routes from ONOS CLI
772 allRoutesActual = \
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800773 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800774
775 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
776 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
777 main.step( "Check routes installed" )
778 main.log.info( "Routes expected:" )
779 main.log.info( allRoutesStrExpected )
780 main.log.info( "Routes get from ONOS CLI:" )
781 main.log.info( allRoutesStrActual )
782 utilities.assertEquals(
783 expect=allRoutesStrExpected, actual=allRoutesStrActual,
784 onpass="***Routes in SDN-IP are correct!***",
785 onfail="***Routes in SDN-IP are wrong!***" )
786 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
787 main.log.report(
788 "***Routes in SDN-IP after adding routes are correct!***" )
789 else:
790 main.log.report(
791 "***Routes in SDN-IP after adding routes are wrong!***" )
792
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800793 #============================= Ping Test ========================
794 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
795 main.log.info("Ping test result")
796 if pingTestResults:
797 main.log.info("Test succeeded")
798 else:
799 main.log.info("Test failed")
800
801 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
802 onpass="Default connectivity check PASS",
803 onfail="Default connectivity check FAIL")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800804
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800805 #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ==================
806 main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
807 main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" )
808 main.log.info( "Sleeping for 150 seconds for network to converge" )
809 time.sleep(150)
810 # get routes inside SDN-IP
811 main.log.info( "Getting Routes from ONOS CLI" )
812 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
813
814 # parse routes from ONOS CLI
815 newAllRoutesActual = \
816 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
817 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
818
819 # Expected routes with changed next hop
820 newAllRoutesExpected = []
821 for prefix in prefixesHost3:
822 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
823 for prefix in prefixesHost4:
824 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
825 for prefix in prefixesHost5:
826 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
827 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
828 main.step( "Check routes installed after convergence-1" )
829 main.log.info( "Routes expected:" )
830 main.log.info( newAllRoutesStrExpected )
831 main.log.info( "Routes got from ONOS CLI after convergence-1:" )
832 main.log.info( newAllRoutesStrActual )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800833 utilities.assertEquals(
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800834 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
835 onpass="***Routes in SDN-IP are correct after convergence!***",
836 onfail="***Routes in SDN-IP are wrong after convergence!***" )
837 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800838 main.log.report(
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800839 "***Routes in SDN-IP after convergence are correct!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800840 else:
841 main.log.report(
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800842 "***Routes in SDN-IP after convergence are wrong!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800843
844 #============================= Ping Test ========================
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800845 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
846 main.log.info("Ping test result")
847 if pingTestResults:
848 main.log.info("Test succeeded")
849 else:
850 main.log.info("Test failed")
851
852 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
853 onpass="Default connectivity check PASS",
854 onfail="Default connectivity check FAIL")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800855
Srikanth Vavilapalli43f3a1d2015-03-04 11:09:44 -0800856 #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ==================
857 main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
858 main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
859 main.log.info( "Sleeping for 150 seconds for network to converge" )
860 time.sleep(150)
861 # get routes inside SDN-IP
862 main.log.info( "Getting Routes from ONOS CLI" )
863 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
864
865 # parse routes from ONOS CLI
866 newAllRoutesActual = \
867 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
868 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
869
870 # Expected routes with changed next hop
871 newAllRoutesExpected = []
872 for prefix in prefixesHost3:
873 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
874 for prefix in prefixesHost4:
875 newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" )
876 for prefix in prefixesHost5:
877 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
878 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
879 main.step( "Check routes installed after convergence-2" )
880 main.log.info( "Routes expected:" )
881 main.log.info( newAllRoutesStrExpected )
882 main.log.info( "Routes got from ONOS CLI after convergence-2:" )
883 main.log.info( newAllRoutesStrActual )
884 utilities.assertEquals(
885 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
886 onpass="***Routes in SDN-IP are correct after convergence!***",
887 onfail="***Routes in SDN-IP are wrong after convergence!***" )
888 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
889 main.log.report(
890 "***Routes in SDN-IP after convergence are correct!***" )
891 else:
892 main.log.report(
893 "***Routes in SDN-IP after convergence are wrong!***" )
894
895 #============================= Ping Test ========================
896 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
897 main.log.info("Ping test result")
898 if pingTestResults:
899 main.log.info("Test succeeded")
900 else:
901 main.log.info("Test failed")
902
903 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
904 onpass="Default connectivity check PASS",
905 onfail="Default connectivity check FAIL")
906
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800907 #============================= Deleting Routes ==================
908 main.step( "Check deleting routes installed" )
909 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
910 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800911 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800912
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800913 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
914 allRoutesActual = \
915 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800916
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800917 main.log.info( "allRoutes_actual = " )
918 main.log.info( allRoutesActual )
919
920 utilities.assertEquals(
921 expect="[]", actual=str( allRoutesActual ),
922 onpass="***Route number in SDN-IP is 0, correct!***",
923 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
924
925 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800926 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800927 else:
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800928 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800929
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800930 #============================= Ping Test ========================
931 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
932 main.log.info("Ping test result")
933 if pingTestResults:
934 main.log.info("Test succeeded")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800935 else:
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800936 main.log.info("Test failed")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800937
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800938 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
939 onpass="disconnect check PASS",
940 onfail="disconnect check FAIL")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800941
sanghoshinc59d6c52015-03-03 10:01:07 -0800942 main.ONOScli.logout()
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -0800943 main.ONOSbench.onosStop(ONOS1Ip);
sanghoshin43dbcfb2015-03-02 12:02:40 -0800944 main.Mininet.stopNet()
945 time.sleep(10)
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800946
Srikanth Vavilapallie5388212015-03-05 13:55:53 -0800947 # Route convergence and connectivity test with Route Server
948 def CASE22( self, main):
949 import time
950 import json
951 from operator import eq
952 # from datetime import datetime
953 from time import localtime, strftime
954
955 main.case("The test case is to help to setup the TestON environment \
956 and test new drivers" )
957 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
958 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/routeserver/mininet"
959 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/routeserver/sdnip.json"
960 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
961
962 # Copy the json files to config dir
963 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/routeserver/addresses.json ~/onos/tools/package/config/")
964 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/routeserver/sdnip.json ~/onos/tools/package/config/")
965
966 # Launch mininet topology for this case
967 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouteServerMininet.py"
968 main.step( "Launch mininet" )
969 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
970 main.step("waiting 20 secs for all switches and quagga instances to comeup")
971 time.sleep(20)
972 main.step( "Test whether Mininet is started" )
973 main.log.info( "Login Quagga CLI on host3" )
974 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
975 # all expected routes for all BGP peers
976 allRoutesExpected = []
977 main.step( "Start to generate routes for all BGP peers" )
978 main.log.info( "Generate prefixes for host3" )
979
980 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
981 main.log.info( prefixesHost3 )
982 # generate route with next hop
983 for prefix in prefixesHost3:
984 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
985 routeIntentsExpectedHost3 = \
986 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
987 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
988 SDNIPJSONFILEPATH )
989
990 main.log.info( "Generate prefixes for host4" )
991 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
992 main.log.info( prefixesHost4 )
993 # generate route with next hop
994 for prefix in prefixesHost4:
995 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
996 routeIntentsExpectedHost4 = \
997 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
998 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
999 SDNIPJSONFILEPATH )
1000
1001 main.log.info( "Generate prefixes for host5" )
1002 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
1003 main.log.info( prefixesHost5 )
1004 for prefix in prefixesHost5:
1005 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1006 routeIntentsExpectedHost5 = \
1007 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
1008 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
1009 SDNIPJSONFILEPATH )
1010
1011 routeIntentsExpected = routeIntentsExpectedHost3 + \
1012 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
1013
1014 cellName = main.params[ 'ENV' ][ 'cellName' ]
1015 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
1016 main.step( "Set cell for ONOS-cli environment" )
1017 main.ONOScli.setCell( cellName )
1018 verifyResult = main.ONOSbench.verifyCell()
1019
1020 main.log.report( "Removing raft logs" )
1021 main.ONOSbench.onosRemoveRaftLogs()
1022 main.log.report( "Uninstalling ONOS" )
1023 main.ONOSbench.onosUninstall( ONOS1Ip )
1024
1025 main.step( "Installing ONOS package" )
1026 onos1InstallResult = main.ONOSbench.onosInstall(
1027 options="-f", node=ONOS1Ip )
1028
1029 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
1030 if not onos1Isup:
1031 main.log.report( "ONOS1 didn't start!" )
1032
1033 main.step( "Start ONOS-cli" )
1034
1035 main.ONOScli.startOnosCli( ONOS1Ip )
1036
1037 main.step( "Get devices in the network" )
1038 listResult = main.ONOScli.devices( jsonFormat=False )
1039 main.log.info( listResult )
1040 time.sleep( 10 )
1041 main.log.info( "Installing gbprouter feature" )
1042 main.ONOScli.featureInstall( "onos-app-bgprouter" )
1043 time.sleep( 10 )
1044 main.step( "Login all BGP peers and add routes into peers" )
1045
1046 main.log.info( "Login Quagga CLI on host3" )
1047 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
1048 main.log.info( "Enter configuration model of Quagga CLI on host3" )
1049 main.QuaggaCliHost3.enterConfig( 64514 )
1050 main.log.info( "Add routes to Quagga on host3" )
1051 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
1052
1053 main.log.info( "Login Quagga CLI on host4" )
1054 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
1055 main.log.info( "Enter configuration model of Quagga CLI on host4" )
1056 main.QuaggaCliHost4.enterConfig( 64516 )
1057 main.log.info( "Add routes to Quagga on host4" )
1058 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
1059
1060 main.log.info( "Login Quagga CLI on host5" )
1061 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
1062 main.log.info( "Enter configuration model of Quagga CLI on host5" )
1063 main.QuaggaCliHost5.enterConfig( 64521 )
1064 main.log.info( "Add routes to Quagga on host5" )
1065 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
1066
1067 time.sleep( 60 )
1068
1069 # get routes inside SDN-IP
1070 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1071
1072 # parse routes from ONOS CLI
1073 allRoutesActual = \
1074 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1075
1076 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
1077 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
1078 main.step( "Check routes installed" )
1079 main.log.info( "Routes expected:" )
1080 main.log.info( allRoutesStrExpected )
1081 main.log.info( "Routes get from ONOS CLI:" )
1082 main.log.info( allRoutesStrActual )
1083 utilities.assertEquals(
1084 expect=allRoutesStrExpected, actual=allRoutesStrActual,
1085 onpass="***Routes in SDN-IP are correct!***",
1086 onfail="***Routes in SDN-IP are wrong!***" )
1087 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1088 main.log.report(
1089 "***Routes in SDN-IP after adding routes are correct!***" )
1090 else:
1091 main.log.report(
1092 "***Routes in SDN-IP after adding routes are wrong!***" )
1093
1094 #============================= Ping Test ========================
1095 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1096 main.log.info("Ping test result")
1097 if pingTestResults:
1098 main.log.info("Test succeeded")
1099 else:
1100 main.log.info("Test failed")
1101
1102 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1103 onpass="Default connectivity check PASS",
1104 onfail="Default connectivity check FAIL")
1105
1106 #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ==================
1107 main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
1108 main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" )
1109 main.log.info( "Sleeping for 150 seconds for network to converge" )
1110 time.sleep(150)
1111 # get routes inside SDN-IP
1112 main.log.info( "Getting Routes from ONOS CLI" )
1113 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1114
1115 # parse routes from ONOS CLI
1116 newAllRoutesActual = \
1117 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1118 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
1119
1120 # Expected routes with changed next hop
1121 newAllRoutesExpected = []
1122 for prefix in prefixesHost3:
1123 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1124 for prefix in prefixesHost4:
1125 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1126 for prefix in prefixesHost5:
1127 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1128 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
1129 main.step( "Check routes installed after convergence-1" )
1130 main.log.info( "Routes expected:" )
1131 main.log.info( newAllRoutesStrExpected )
1132 main.log.info( "Routes got from ONOS CLI after convergence-1:" )
1133 main.log.info( newAllRoutesStrActual )
1134 utilities.assertEquals(
1135 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
1136 onpass="***Routes in SDN-IP are correct after convergence!***",
1137 onfail="***Routes in SDN-IP are wrong after convergence!***" )
1138 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
1139 main.log.report(
1140 "***Routes in SDN-IP after convergence are correct!***" )
1141 else:
1142 main.log.report(
1143 "***Routes in SDN-IP after convergence are wrong!***" )
1144
1145 #============================= Ping Test ========================
1146 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1147 main.log.info("Ping test result")
1148 if pingTestResults:
1149 main.log.info("Test succeeded")
1150 else:
1151 main.log.info("Test failed")
1152
1153 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1154 onpass="Default connectivity check PASS",
1155 onfail="Default connectivity check FAIL")
1156
1157 #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ==================
1158 main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
1159 main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
1160 main.log.info( "Sleeping for 150 seconds for network to converge" )
1161 time.sleep(150)
1162 # get routes inside SDN-IP
1163 main.log.info( "Getting Routes from ONOS CLI" )
1164 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1165
1166 # parse routes from ONOS CLI
1167 newAllRoutesActual = \
1168 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1169 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
1170
1171 # Expected routes with changed next hop
1172 newAllRoutesExpected = []
1173 for prefix in prefixesHost3:
1174 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1175 for prefix in prefixesHost4:
1176 newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" )
1177 for prefix in prefixesHost5:
1178 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1179 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
1180 main.step( "Check routes installed after convergence-2" )
1181 main.log.info( "Routes expected:" )
1182 main.log.info( newAllRoutesStrExpected )
1183 main.log.info( "Routes got from ONOS CLI after convergence-2:" )
1184 main.log.info( newAllRoutesStrActual )
1185 utilities.assertEquals(
1186 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
1187 onpass="***Routes in SDN-IP are correct after convergence!***",
1188 onfail="***Routes in SDN-IP are wrong after convergence!***" )
1189 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
1190 main.log.report(
1191 "***Routes in SDN-IP after convergence are correct!***" )
1192 else:
1193 main.log.report(
1194 "***Routes in SDN-IP after convergence are wrong!***" )
1195
1196 #============================= Ping Test ========================
1197 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1198 main.log.info("Ping test result")
1199 if pingTestResults:
1200 main.log.info("Test succeeded")
1201 else:
1202 main.log.info("Test failed")
1203
1204 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1205 onpass="Default connectivity check PASS",
1206 onfail="Default connectivity check FAIL")
1207
1208 #============================= Deleting Routes ==================
1209 main.step( "Check deleting routes installed" )
1210 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
1211 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
1212 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
1213
1214 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1215 allRoutesActual = \
1216 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1217
1218 main.log.info( "allRoutes_actual = " )
1219 main.log.info( allRoutesActual )
1220
1221 utilities.assertEquals(
1222 expect="[]", actual=str( allRoutesActual ),
1223 onpass="***Route number in SDN-IP is 0, correct!***",
1224 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
1225
1226 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1227 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
1228 else:
1229 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
1230
1231 #============================= Ping Test ========================
1232 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
1233 main.log.info("Ping test result")
1234 if pingTestResults:
1235 main.log.info("Test succeeded")
1236 else:
1237 main.log.info("Test failed")
1238
1239 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1240 onpass="disconnect check PASS",
1241 onfail="disconnect check FAIL")
1242
1243 main.ONOScli.logout()
1244 main.ONOSbench.onosStop(ONOS1Ip);
1245 main.Mininet.stopNet()
1246 time.sleep(10)
1247
Srikanth Vavilapallida0b4e52015-03-09 16:09:15 -07001248 # Route convergence and connectivity test in VLAN configuration
1249 def CASE31( self, main):
1250 import time
1251 import json
1252 from operator import eq
1253 # from datetime import datetime
1254 from time import localtime, strftime
1255
1256 main.case("The test case is to help to setup the TestON environment \
1257 and test new drivers" )
1258 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
1259 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/routeconvergence/mininet"
1260 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/sdnip.json"
1261 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
1262
1263 # Copy the json files to config dir
1264 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/addresses.json ~/onos/tools/package/config/")
1265 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/sdnip.json ~/onos/tools/package/config/")
1266
1267 # Launch mininet topology for this case
1268 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterConvergenceVlanMininet.py"
1269 main.step( "Launch mininet" )
1270 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
1271 main.step("waiting 20 secs for all switches and quagga instances to comeup")
1272 time.sleep(20)
1273 main.step( "Test whether Mininet is started" )
1274 main.log.info( "Login Quagga CLI on host3" )
1275 result = main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
1276 #if result is not main.TRUE:
1277 # main.log.report("Mininet is not started...Aborting")
1278 # main.Mininet.stopNet()
1279 # main.cleanup()
1280 # main.exit()
1281 # all expected routes for all BGP peers
1282 allRoutesExpected = []
1283 main.step( "Start to generate routes for all BGP peers" )
1284 main.log.info( "Generate prefixes for host3" )
1285
1286 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
1287 main.log.info( prefixesHost3 )
1288 # generate route with next hop
1289 for prefix in prefixesHost3:
1290 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1291 routeIntentsExpectedHost3 = \
1292 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
1293 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
1294 SDNIPJSONFILEPATH )
1295
1296 main.log.info( "Generate prefixes for host4" )
1297 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
1298 main.log.info( prefixesHost4 )
1299 # generate route with next hop
1300 for prefix in prefixesHost4:
1301 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
1302 routeIntentsExpectedHost4 = \
1303 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
1304 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
1305 SDNIPJSONFILEPATH )
1306
1307 main.log.info( "Generate prefixes for host5" )
1308 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
1309 main.log.info( prefixesHost5 )
1310 for prefix in prefixesHost5:
1311 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1312 routeIntentsExpectedHost5 = \
1313 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
1314 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
1315 SDNIPJSONFILEPATH )
1316
1317 routeIntentsExpected = routeIntentsExpectedHost3 + \
1318 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
1319
1320 cellName = main.params[ 'ENV' ][ 'cellName' ]
1321 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
1322 main.step( "Set cell for ONOS-cli environment" )
1323 main.ONOScli.setCell( cellName )
1324 verifyResult = main.ONOSbench.verifyCell()
1325 utilities.assert_equals(expect=main.TRUE,actual=verifyResult,onpass="Verify cell pass!",onfail="Verify cell failed...")
1326
1327 main.log.report( "Removing raft logs" )
1328 main.ONOSbench.onosRemoveRaftLogs()
1329 main.log.report( "Uninstalling ONOS" )
1330 main.ONOSbench.onosUninstall( ONOS1Ip )
1331
1332 main.step( "Installing ONOS package" )
1333 onos1InstallResult = main.ONOSbench.onosInstall(
1334 options="-f", node=ONOS1Ip )
1335 if onos1InstallResult is not main.TRUE:
1336 main.log.report("ONOS is not installed...Aborting")
1337 main.Mininet.stopNet()
1338 main.cleanup()
1339 main.exit()
1340
1341 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
1342 if onos1Isup is not main.TRUE:
1343 main.log.report("ONOS1 didn't start!...Aborting" )
1344 main.Mininet.stopNet()
1345 main.ONOSbench.onosStop(ONOS1Ip);
1346 main.cleanup()
1347 main.exit()
1348
1349 main.step( "Start ONOS-cli" )
1350
1351 result = main.ONOScli.startOnosCli( ONOS1Ip )
1352 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="ONOS CLI is up!",onfail="ONOS CLI is not up...")
1353 if result is not main.TRUE:
1354 main.log.report("ONOS1 didn't start!...Aborting" )
1355 main.Mininet.stopNet()
1356 main.ONOScli.logout()
1357 main.ONOSbench.onosStop(ONOS1Ip);
1358 main.cleanup()
1359 main.exit()
1360
1361
1362 main.step( "Get devices in the network" )
1363 listResult = main.ONOScli.devices( jsonFormat=False )
1364 main.log.info( listResult )
1365 time.sleep( 10 )
1366 main.log.info( "Installing bgprouter feature" )
1367 main.ONOScli.featureInstall( "onos-app-bgprouter" )
1368 time.sleep( 10 )
1369 main.step( "Login all BGP peers and add routes into peers" )
1370
1371 main.log.info( "Login Quagga CLI on host3" )
1372 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
1373 main.log.info( "Enter configuration model of Quagga CLI on host3" )
1374 main.QuaggaCliHost3.enterConfig( 64514 )
1375 main.log.info( "Add routes to Quagga on host3" )
1376 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
1377
1378 main.log.info( "Login Quagga CLI on host4" )
1379 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
1380 main.log.info( "Enter configuration model of Quagga CLI on host4" )
1381 main.QuaggaCliHost4.enterConfig( 64516 )
1382 main.log.info( "Add routes to Quagga on host4" )
1383 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
1384
1385 main.log.info( "Login Quagga CLI on host5" )
1386 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
1387 main.log.info( "Enter configuration model of Quagga CLI on host5" )
1388 main.QuaggaCliHost5.enterConfig( 64521 )
1389 main.log.info( "Add routes to Quagga on host5" )
1390 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
1391
1392 time.sleep( 30 )
1393
1394 # get routes inside SDN-IP
1395 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1396
1397 # parse routes from ONOS CLI
1398 allRoutesActual = \
1399 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1400
1401 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
1402 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
1403 main.step( "Check routes installed" )
1404 main.log.info( "Routes expected:" )
1405 main.log.info( allRoutesStrExpected )
1406 main.log.info( "Routes get from ONOS CLI:" )
1407 main.log.info( allRoutesStrActual )
1408 utilities.assertEquals(
1409 expect=allRoutesStrExpected, actual=allRoutesStrActual,
1410 onpass="***Routes in SDN-IP are correct!***",
1411 onfail="***Routes in SDN-IP are wrong!***" )
1412 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1413 main.log.report(
1414 "***Routes in SDN-IP after adding routes are correct!***" )
1415 else:
1416 main.log.report(
1417 "***Routes in SDN-IP after adding routes are wrong!***" )
1418
1419 #============================= Ping Test ========================
1420 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1421 main.log.info("Ping test result")
1422 if pingTestResults:
1423 main.log.info("Test succeeded")
1424 else:
1425 main.log.info("Test failed")
1426
1427 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1428 onpass="Default connectivity check PASS",
1429 onfail="Default connectivity check FAIL")
1430
1431 #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ==================
1432 main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
1433 main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" )
1434 main.log.info( "Sleeping for 150 seconds for network to converge" )
1435 time.sleep(150)
1436 # get routes inside SDN-IP
1437 main.log.info( "Getting Routes from ONOS CLI" )
1438 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1439
1440 # parse routes from ONOS CLI
1441 newAllRoutesActual = \
1442 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1443 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
1444
1445 # Expected routes with changed next hop
1446 newAllRoutesExpected = []
1447 for prefix in prefixesHost3:
1448 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1449 for prefix in prefixesHost4:
1450 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1451 for prefix in prefixesHost5:
1452 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1453 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
1454 main.step( "Check routes installed after convergence-1" )
1455 main.log.info( "Routes expected:" )
1456 main.log.info( newAllRoutesStrExpected )
1457 main.log.info( "Routes got from ONOS CLI after convergence-1:" )
1458 main.log.info( newAllRoutesStrActual )
1459 utilities.assertEquals(
1460 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
1461 onpass="***Routes in SDN-IP are correct after convergence!***",
1462 onfail="***Routes in SDN-IP are wrong after convergence!***" )
1463 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
1464 main.log.report(
1465 "***Routes in SDN-IP after convergence are correct!***" )
1466 else:
1467 main.log.report(
1468 "***Routes in SDN-IP after convergence are wrong!***" )
1469
1470 #============================= Ping Test ========================
1471 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1472 main.log.info("Ping test result")
1473 if pingTestResults:
1474 main.log.info("Test succeeded")
1475 else:
1476 main.log.info("Test failed")
1477
1478 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1479 onpass="Default connectivity check PASS",
1480 onfail="Default connectivity check FAIL")
1481
1482 #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ==================
1483 main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
1484 main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
1485 main.log.info( "Sleeping for 150 seconds for network to converge" )
1486 time.sleep(150)
1487 # get routes inside SDN-IP
1488 main.log.info( "Getting Routes from ONOS CLI" )
1489 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1490
1491 # parse routes from ONOS CLI
1492 newAllRoutesActual = \
1493 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1494 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
1495
1496 # Expected routes with changed next hop
1497 newAllRoutesExpected = []
1498 for prefix in prefixesHost3:
1499 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1500 for prefix in prefixesHost4:
1501 newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" )
1502 for prefix in prefixesHost5:
1503 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1504 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
1505 main.step( "Check routes installed after convergence-2" )
1506 main.log.info( "Routes expected:" )
1507 main.log.info( newAllRoutesStrExpected )
1508 main.log.info( "Routes got from ONOS CLI after convergence-2:" )
1509 main.log.info( newAllRoutesStrActual )
1510 utilities.assertEquals(
1511 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
1512 onpass="***Routes in SDN-IP are correct after convergence!***",
1513 onfail="***Routes in SDN-IP are wrong after convergence!***" )
1514 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
1515 main.log.report(
1516 "***Routes in SDN-IP after convergence are correct!***" )
1517 else:
1518 main.log.report(
1519 "***Routes in SDN-IP after convergence are wrong!***" )
1520
1521 #============================= Ping Test ========================
1522 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1523 main.log.info("Ping test result")
1524 if pingTestResults:
1525 main.log.info("Test succeeded")
1526 else:
1527 main.log.info("Test failed")
1528
1529 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1530 onpass="Default connectivity check PASS",
1531 onfail="Default connectivity check FAIL")
1532
1533 #============================= Deleting Routes ==================
1534 main.step( "Check deleting routes installed" )
1535 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
1536 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
1537 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
1538
1539 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1540 allRoutesActual = \
1541 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1542
1543 main.log.info( "allRoutes_actual = " )
1544 main.log.info( allRoutesActual )
1545
1546 utilities.assertEquals(
1547 expect="[]", actual=str( allRoutesActual ),
1548 onpass="***Route number in SDN-IP is 0, correct!***",
1549 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
1550
1551 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1552 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
1553 else:
1554 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
1555
1556 #============================= Ping Test ========================
1557 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
1558 main.log.info("Ping test result")
1559 if pingTestResults:
1560 main.log.info("Test succeeded")
1561 else:
1562 main.log.info("Test failed")
1563
1564 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1565 onpass="disconnect check PASS",
1566 onfail="disconnect check FAIL")
1567
1568 main.ONOScli.logout()
1569 main.ONOSbench.onosStop(ONOS1Ip);
1570 main.Mininet.stopNet()
1571 time.sleep(10)
1572
1573 # Route convergence and connectivity test with Route Server in VLAN tagged network
1574 def CASE32( self, main):
1575 import time
1576 import json
1577 from operator import eq
1578 # from datetime import datetime
1579 from time import localtime, strftime
1580
1581 main.case("The test case is to help to setup the TestON environment \
1582 and test new drivers" )
1583 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
1584 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/routeserver/mininet"
1585 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/routeserver/sdnip.json"
1586 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
1587
1588 # Copy the json files to config dir
1589 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/routeserver/addresses.json ~/onos/tools/package/config/")
1590 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/routeserver/sdnip.json ~/onos/tools/package/config/")
1591
1592 # Launch mininet topology for this case
1593 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouteServerVlanMininet.py"
1594 main.step( "Launch mininet" )
1595 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
1596 main.step("waiting 20 secs for all switches and quagga instances to comeup")
1597 time.sleep(20)
1598 main.step( "Test whether Mininet is started" )
1599 main.log.info( "Login Quagga CLI on host3" )
1600 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
1601 # all expected routes for all BGP peers
1602 allRoutesExpected = []
1603 main.step( "Start to generate routes for all BGP peers" )
1604 main.log.info( "Generate prefixes for host3" )
1605
1606 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
1607 main.log.info( prefixesHost3 )
1608 # generate route with next hop
1609 for prefix in prefixesHost3:
1610 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1611 routeIntentsExpectedHost3 = \
1612 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
1613 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
1614 SDNIPJSONFILEPATH )
1615
1616 main.log.info( "Generate prefixes for host4" )
1617 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
1618 main.log.info( prefixesHost4 )
1619 # generate route with next hop
1620 for prefix in prefixesHost4:
1621 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
1622 routeIntentsExpectedHost4 = \
1623 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
1624 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
1625 SDNIPJSONFILEPATH )
1626
1627 main.log.info( "Generate prefixes for host5" )
1628 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
1629 main.log.info( prefixesHost5 )
1630 for prefix in prefixesHost5:
1631 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1632 routeIntentsExpectedHost5 = \
1633 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
1634 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
1635 SDNIPJSONFILEPATH )
1636
1637 routeIntentsExpected = routeIntentsExpectedHost3 + \
1638 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
1639
1640 cellName = main.params[ 'ENV' ][ 'cellName' ]
1641 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
1642 main.step( "Set cell for ONOS-cli environment" )
1643 main.ONOScli.setCell( cellName )
1644 verifyResult = main.ONOSbench.verifyCell()
1645
1646 main.log.report( "Removing raft logs" )
1647 main.ONOSbench.onosRemoveRaftLogs()
1648 main.log.report( "Uninstalling ONOS" )
1649 main.ONOSbench.onosUninstall( ONOS1Ip )
1650
1651 main.step( "Installing ONOS package" )
1652 onos1InstallResult = main.ONOSbench.onosInstall(
1653 options="-f", node=ONOS1Ip )
1654
1655 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
1656 if not onos1Isup:
1657 main.log.report( "ONOS1 didn't start!" )
1658
1659 main.step( "Start ONOS-cli" )
1660
1661 main.ONOScli.startOnosCli( ONOS1Ip )
1662
1663 main.step( "Get devices in the network" )
1664 listResult = main.ONOScli.devices( jsonFormat=False )
1665 main.log.info( listResult )
1666 time.sleep( 10 )
1667 main.log.info( "Installing gbprouter feature" )
1668 main.ONOScli.featureInstall( "onos-app-bgprouter" )
1669 time.sleep( 10 )
1670 main.step( "Login all BGP peers and add routes into peers" )
1671
1672 main.log.info( "Login Quagga CLI on host3" )
1673 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
1674 main.log.info( "Enter configuration model of Quagga CLI on host3" )
1675 main.QuaggaCliHost3.enterConfig( 64514 )
1676 main.log.info( "Add routes to Quagga on host3" )
1677 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
1678
1679 main.log.info( "Login Quagga CLI on host4" )
1680 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
1681 main.log.info( "Enter configuration model of Quagga CLI on host4" )
1682 main.QuaggaCliHost4.enterConfig( 64516 )
1683 main.log.info( "Add routes to Quagga on host4" )
1684 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
1685
1686 main.log.info( "Login Quagga CLI on host5" )
1687 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
1688 main.log.info( "Enter configuration model of Quagga CLI on host5" )
1689 main.QuaggaCliHost5.enterConfig( 64521 )
1690 main.log.info( "Add routes to Quagga on host5" )
1691 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
1692
1693 time.sleep( 60 )
1694
1695 # get routes inside SDN-IP
1696 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1697
1698 # parse routes from ONOS CLI
1699 allRoutesActual = \
1700 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1701
1702 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
1703 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
1704 main.step( "Check routes installed" )
1705 main.log.info( "Routes expected:" )
1706 main.log.info( allRoutesStrExpected )
1707 main.log.info( "Routes get from ONOS CLI:" )
1708 main.log.info( allRoutesStrActual )
1709 utilities.assertEquals(
1710 expect=allRoutesStrExpected, actual=allRoutesStrActual,
1711 onpass="***Routes in SDN-IP are correct!***",
1712 onfail="***Routes in SDN-IP are wrong!***" )
1713 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1714 main.log.report(
1715 "***Routes in SDN-IP after adding routes are correct!***" )
1716 else:
1717 main.log.report(
1718 "***Routes in SDN-IP after adding routes are wrong!***" )
1719
1720 #============================= Ping Test ========================
1721 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1722 main.log.info("Ping test result")
1723 if pingTestResults:
1724 main.log.info("Test succeeded")
1725 else:
1726 main.log.info("Test failed")
1727
1728 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1729 onpass="Default connectivity check PASS",
1730 onfail="Default connectivity check FAIL")
1731
1732 #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ==================
1733 main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
1734 main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" )
1735 main.log.info( "Sleeping for 150 seconds for network to converge" )
1736 time.sleep(150)
1737 # get routes inside SDN-IP
1738 main.log.info( "Getting Routes from ONOS CLI" )
1739 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1740
1741 # parse routes from ONOS CLI
1742 newAllRoutesActual = \
1743 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1744 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
1745
1746 # Expected routes with changed next hop
1747 newAllRoutesExpected = []
1748 for prefix in prefixesHost3:
1749 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1750 for prefix in prefixesHost4:
1751 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1752 for prefix in prefixesHost5:
1753 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1754 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
1755 main.step( "Check routes installed after convergence-1" )
1756 main.log.info( "Routes expected:" )
1757 main.log.info( newAllRoutesStrExpected )
1758 main.log.info( "Routes got from ONOS CLI after convergence-1:" )
1759 main.log.info( newAllRoutesStrActual )
1760 utilities.assertEquals(
1761 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
1762 onpass="***Routes in SDN-IP are correct after convergence!***",
1763 onfail="***Routes in SDN-IP are wrong after convergence!***" )
1764 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
1765 main.log.report(
1766 "***Routes in SDN-IP after convergence are correct!***" )
1767 else:
1768 main.log.report(
1769 "***Routes in SDN-IP after convergence are wrong!***" )
1770
1771 #============================= Ping Test ========================
1772 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1773 main.log.info("Ping test result")
1774 if pingTestResults:
1775 main.log.info("Test succeeded")
1776 else:
1777 main.log.info("Test failed")
1778
1779 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1780 onpass="Default connectivity check PASS",
1781 onfail="Default connectivity check FAIL")
1782
1783 #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ==================
1784 main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
1785 main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
1786 main.log.info( "Sleeping for 150 seconds for network to converge" )
1787 time.sleep(150)
1788 # get routes inside SDN-IP
1789 main.log.info( "Getting Routes from ONOS CLI" )
1790 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1791
1792 # parse routes from ONOS CLI
1793 newAllRoutesActual = \
1794 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1795 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
1796
1797 # Expected routes with changed next hop
1798 newAllRoutesExpected = []
1799 for prefix in prefixesHost3:
1800 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1801 for prefix in prefixesHost4:
1802 newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" )
1803 for prefix in prefixesHost5:
1804 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1805 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
1806 main.step( "Check routes installed after convergence-2" )
1807 main.log.info( "Routes expected:" )
1808 main.log.info( newAllRoutesStrExpected )
1809 main.log.info( "Routes got from ONOS CLI after convergence-2:" )
1810 main.log.info( newAllRoutesStrActual )
1811 utilities.assertEquals(
1812 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
1813 onpass="***Routes in SDN-IP are correct after convergence!***",
1814 onfail="***Routes in SDN-IP are wrong after convergence!***" )
1815 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
1816 main.log.report(
1817 "***Routes in SDN-IP after convergence are correct!***" )
1818 else:
1819 main.log.report(
1820 "***Routes in SDN-IP after convergence are wrong!***" )
1821
1822 #============================= Ping Test ========================
1823 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1824 main.log.info("Ping test result")
1825 if pingTestResults:
1826 main.log.info("Test succeeded")
1827 else:
1828 main.log.info("Test failed")
1829
1830 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1831 onpass="Default connectivity check PASS",
1832 onfail="Default connectivity check FAIL")
1833
1834 #============================= Deleting Routes ==================
1835 main.step( "Check deleting routes installed" )
1836 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
1837 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
1838 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
1839
1840 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1841 allRoutesActual = \
1842 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1843
1844 main.log.info( "allRoutes_actual = " )
1845 main.log.info( allRoutesActual )
1846
1847 utilities.assertEquals(
1848 expect="[]", actual=str( allRoutesActual ),
1849 onpass="***Route number in SDN-IP is 0, correct!***",
1850 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
1851
1852 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1853 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
1854 else:
1855 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
1856
1857 #============================= Ping Test ========================
1858 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
1859 main.log.info("Ping test result")
1860 if pingTestResults:
1861 main.log.info("Test succeeded")
1862 else:
1863 main.log.info("Test failed")
1864
1865 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1866 onpass="disconnect check PASS",
1867 onfail="disconnect check FAIL")
1868
1869 main.ONOScli.logout()
1870 main.ONOSbench.onosStop(ONOS1Ip);
1871 main.Mininet.stopNet()
1872 time.sleep(10)
1873