blob: 9de5845dfd72a0039ac1f6fc62d6ca805dd36087 [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
sanghoshin37e27622015-03-17 10:11:04 -0700646 main.ONOScli.logout()
647 main.log.info("ONOS cli logout")
648 time.sleep(20);
649 main.ONOSbench.onosStop(ONOS1Ip);
650 main.log.info("onos stop")
651 time.sleep(20);
652 main.Mininet.stopNet()
653 main.log.info("mininet stop")
654 time.sleep(20)
655
656 # Route flap test (Add a route and detele it very fast 20 times) in VLAN configuration
657 def CASE8( self, main ):
658 import time
659 import json
660 from operator import eq
661 # from datetime import datetime
662 from time import localtime, strftime
663
664 main.case("The test case is to help to setup the TestON environment \
665 and test new drivers" )
666 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
667 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/mininet"
668 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/sdnip.json"
669 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
670
671 # Copy the json files to config dir
672 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/addresses.json ~/onos/tools/package/config/")
673 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/sdnip.json ~/onos/tools/package/config/")
674
675 # Launch mininet topology for this case
676 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininetVlan.py"
677 main.step( "Launch mininet" )
678 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
679 main.step("waiting 20 secs for all switches and quagga instances to comeup")
680 time.sleep(20)
681 main.step( "Test whether Mininet is started" )
682 main.log.info( "Login Quagga CLI on host3" )
683 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
684 # all expected routes for all BGP peers
685 allRoutesExpected = []
686 main.step( "Start to generate routes for all BGP peers" )
687
688 main.log.info( "Generate prefixes for host3" )
689 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 1 )
690 main.log.info( prefixesHost3 )
691 # generate route with next hop
692 for prefix in prefixesHost3:
693 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
694 routeIntentsExpectedHost3 = \
695 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
696 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
697 SDNIPJSONFILEPATH )
698
699 main.log.info( "Generate prefixes for host5" )
700 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 1 )
701 main.log.info( prefixesHost5 )
702 for prefix in prefixesHost5:
703 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
704 routeIntentsExpectedHost5 = \
705 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
706 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
707 SDNIPJSONFILEPATH )
708
709 routeIntentsExpected = routeIntentsExpectedHost3 + \
710 routeIntentsExpectedHost5
711
712 cellName = main.params[ 'ENV' ][ 'cellName' ]
713 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
714 main.step( "Set cell for ONOS-cli environment" )
715 main.ONOScli.setCell( cellName )
716 verifyResult = main.ONOSbench.verifyCell()
717
718 main.log.report( "Removing raft logs" )
719 main.ONOSbench.onosRemoveRaftLogs()
720 main.log.report( "Uninstalling ONOS" )
721 main.ONOSbench.onosUninstall( ONOS1Ip )
722
723 main.step( "Installing ONOS package" )
724 onos1InstallResult = main.ONOSbench.onosInstall(
725 options="-f", node=ONOS1Ip )
726
727 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
728 if not onos1Isup:
729 main.log.report( "ONOS1 didn't start!" )
730
731 main.step( "Start ONOS-cli" )
732
733 main.ONOScli.startOnosCli( ONOS1Ip )
734 main.step( "Get devices in the network" )
735 listResult = main.ONOScli.devices( jsonFormat=False )
736 main.log.info( listResult )
737 time.sleep( 10 )
738 main.log.info( "Installing bgprouter feature" )
739 main.ONOScli.featureInstall( "onos-app-bgprouter" )
740 time.sleep( 10 )
741 main.step( "Login all BGP peers and add routes into peers" )
742
743 main.log.info( "Login Quagga CLI on host5" )
744 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
745 main.log.info( "Enter configuration model of Quagga CLI on host5" )
746 main.QuaggaCliHost5.enterConfig( 64521 )
747 main.log.info( "Add routes to Quagga on host5" )
748 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
749
750 main.log.info( "Login Quagga CLI on host3" )
751 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
752 main.log.info( "Enter configuration model of Quagga CLI on host3" )
753 main.QuaggaCliHost3.enterConfig( 64514 )
754 main.log.info( "Add and delete a route to Quagga on host3 20 times" )
755 for i in range(0, 20):
756 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
757 main.log.info("Add a route %s times", i)
758 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
759 main.log.info("Delete the route")
760 time.sleep(0.1)
761
762 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
763 main.log.info("Add the route finally and wait for 10 sec")
764
765 for j in range(0, 30):
766 r = main.Mininet.pingHost(SRC="as6host", TARGET="3.0.0.1")
767
768 utilities.assert_equals(expect=main.TRUE,actual=r,
769 onpass="Default connectivity check PASS",
770 onfail="Default connectivity check FAIL")
771
772 #time.sleep(20)
773
774 # get routes inside SDN-IP
775 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
776
777 # parse routes from ONOS CLI
778 allRoutesActual = \
779 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
780
781 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
782 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
783
784 # get routes inside SDN-IP
785 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
786
787 # parse routes from ONOS CLI
788 allRoutesActual = \
789 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
790
791 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
792 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
793 main.step( "Check routes installed" )
794 main.log.info( "Routes expected:" )
795 main.log.info( allRoutesStrExpected )
796 main.log.info( "Routes get from ONOS CLI:" )
797 main.log.info( allRoutesStrActual )
798 utilities.assertEquals(
799 expect=allRoutesStrExpected, actual=allRoutesStrActual,
800 onpass="***Routes in SDN-IP are correct!***",
801 onfail="***Routes in SDN-IP are wrong!***" )
802 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
803 main.log.report(
804 "***Routes in SDN-IP after adding routes are correct!***" )
805 else:
806 main.log.report(
807 "***Routes in SDN-IP after adding routes are wrong!***" )
808
809 main.log.info( "Login Quagga CLI on host3" )
810 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
811 main.log.info( "Enter configuration model of Quagga CLI on host3" )
812 main.QuaggaCliHost3.enterConfig( 64514 )
813 main.log.info( "Add and delete a route to Quagga on host3 20 times" )
814 for i in range(0, 20):
815 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
816 main.log.info("Add a route %s times", i)
817 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
818 main.log.info("Delete the route")
819 time.sleep(0.1)
820
821 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
822
823 # get routes inside SDN-IP
824 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
825
826 # parse routes from ONOS CLI
827 allRoutesActual = \
828 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
829
830 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
831
832 # get routes inside SDN-IP
833 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
834
835 # parse routes from ONOS CLI
836 allRoutesActual = \
837 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
838
839 allRoutesStrExpected = []
840 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
841 main.step( "Check routes installed" )
842 main.log.info( "Routes expected:" )
843 main.log.info( allRoutesStrExpected )
844 main.log.info( "Routes get from ONOS CLI:" )
845 main.log.info( allRoutesStrActual )
846 utilities.assertEquals(
847 expect=allRoutesStrExpected, actual=allRoutesStrActual,
848 onpass="***Routes in SDN-IP are correct!***",
849 onfail="***Routes in SDN-IP are wrong!***" )
850
851 for j in range(0, 5):
852 r = main.Mininet.pingHost(SRC="as6host", TARGET="3.0.0.1")
853
854 utilities.assert_equals(expect=main.FALSE,actual=r,
855 onpass="disconnectivity check PASS",
856 onfail="disconnectivity check FAIL")
857
858 main.ONOScli.logout()
859 main.log.info("ONOS cli logout")
860 time.sleep(20);
861 main.ONOSbench.onosStop(ONOS1Ip);
862 main.log.info("onos stop")
863 time.sleep(20);
864 main.Mininet.stopNet()
865 main.log.info("mininet stop")
866 time.sleep(20)
867
868 # Route flap test (change the next-hop very fast 20 times) in VLAN configuration
869 def CASE9( self, main):
870 import time
871 import json
872 from operator import eq
873 # from datetime import datetime
874 from time import localtime, strftime
875
876 main.case("The test case is to help to setup the TestON environment \
877 and test new drivers" )
878 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
879 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/routeconvergence/mininet"
880 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/sdnip.json"
881 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
882
883 # Copy the json files to config dir
884 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/addresses.json ~/onos/tools/package/config/")
885 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/sdnip.json ~/onos/tools/package/config/")
886
887 # Launch mininet topology for this case
888 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterConvergenceVlanMininet.py"
889 main.step( "Launch mininet" )
890 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
891 main.step("waiting 20 secs for all switches and quagga instances to comeup")
892 time.sleep(20)
893 main.step( "Test whether Mininet is started" )
894 main.log.info( "Login Quagga CLI on host3" )
895 result = main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
896 #if result is not main.TRUE:
897 # main.log.report("Mininet is not started...Aborting")
898 # main.Mininet.stopNet()
899 # main.cleanup()
900 # main.exit()
901 # all expected routes for all BGP peers
902 allRoutesExpected = []
903 main.step( "Start to generate routes for all BGP peers" )
904 main.log.info( "Generate prefixes for host3" )
905
906 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
907 main.log.info( prefixesHost3 )
908 # generate route with next hop
909 for prefix in prefixesHost3:
910 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
911 routeIntentsExpectedHost3 = \
912 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
913 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
914 SDNIPJSONFILEPATH )
915
916 main.log.info( "Generate prefixes for host4" )
917 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
918 main.log.info( prefixesHost4 )
919 # generate route with next hop
920 for prefix in prefixesHost4:
921 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
922 routeIntentsExpectedHost4 = \
923 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
924 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
925 SDNIPJSONFILEPATH )
926
927 main.log.info( "Generate prefixes for host5" )
928 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
929 main.log.info( prefixesHost5 )
930 for prefix in prefixesHost5:
931 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
932 routeIntentsExpectedHost5 = \
933 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
934 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
935 SDNIPJSONFILEPATH )
936
937 routeIntentsExpected = routeIntentsExpectedHost3 + \
938 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
939
940 cellName = main.params[ 'ENV' ][ 'cellName' ]
941 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
942 main.step( "Set cell for ONOS-cli environment" )
943 main.ONOScli.setCell( cellName )
944 verifyResult = main.ONOSbench.verifyCell()
945 utilities.assert_equals(expect=main.TRUE,actual=verifyResult,onpass="Verify cell pass!",onfail="Verify cell failed...")
946
947 main.log.report( "Removing raft logs" )
948 main.ONOSbench.onosRemoveRaftLogs()
949 main.log.report( "Uninstalling ONOS" )
950 main.ONOSbench.onosUninstall( ONOS1Ip )
951
952 main.step( "Installing ONOS package" )
953 onos1InstallResult = main.ONOSbench.onosInstall(
954 options="-f", node=ONOS1Ip )
955 if onos1InstallResult is not main.TRUE:
956 main.log.report("ONOS is not installed...Aborting")
957 main.Mininet.stopNet()
958 main.cleanup()
959 main.exit()
960
961 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
962 if onos1Isup is not main.TRUE:
963 main.log.report("ONOS1 didn't start!...Aborting" )
964 main.Mininet.stopNet()
965 main.ONOSbench.onosStop(ONOS1Ip);
966 main.cleanup()
967 main.exit()
968
969 main.step( "Start ONOS-cli" )
970
971 result = main.ONOScli.startOnosCli( ONOS1Ip )
972 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="ONOS CLI is up!",onfail="ONOS CLI is not up...")
973 if result is not main.TRUE:
974 main.log.report("ONOS1 didn't start!...Aborting" )
975 main.Mininet.stopNet()
976 main.ONOScli.logout()
977 main.ONOSbench.onosStop(ONOS1Ip);
978 main.cleanup()
979 main.exit()
980
981
982 main.step( "Get devices in the network" )
983 listResult = main.ONOScli.devices( jsonFormat=False )
984 main.log.info( listResult )
985 time.sleep( 10 )
986 main.log.info( "Installing bgprouter feature" )
987 main.ONOScli.featureInstall( "onos-app-bgprouter" )
988 time.sleep( 10 )
989 main.step( "Login all BGP peers and add routes into peers" )
990
991 main.log.info( "Login Quagga CLI on host3" )
992 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
993 main.log.info( "Enter configuration model of Quagga CLI on host3" )
994 main.QuaggaCliHost3.enterConfig( 64514 )
995 main.log.info( "Add routes to Quagga on host3" )
996 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
997
998 main.log.info( "Login Quagga CLI on host4" )
999 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
1000 main.log.info( "Enter configuration model of Quagga CLI on host4" )
1001 main.QuaggaCliHost4.enterConfig( 64516 )
1002 main.log.info( "Add routes to Quagga on host4" )
1003 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
1004
1005 main.log.info( "Login Quagga CLI on host5" )
1006 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
1007 main.log.info( "Enter configuration model of Quagga CLI on host5" )
1008 main.QuaggaCliHost5.enterConfig( 64521 )
1009 main.log.info( "Add routes to Quagga on host5" )
1010 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
1011
1012 time.sleep( 30 )
1013
1014 # get routes inside SDN-IP
1015 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1016
1017 # parse routes from ONOS CLI
1018 allRoutesActual = \
1019 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1020
1021 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
1022 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
1023 main.step( "Check routes installed" )
1024 main.log.info( "Routes expected:" )
1025 main.log.info( allRoutesStrExpected )
1026 main.log.info( "Routes get from ONOS CLI:" )
1027 main.log.info( allRoutesStrActual )
1028 utilities.assertEquals(
1029 expect=allRoutesStrExpected, actual=allRoutesStrActual,
1030 onpass="***Routes in SDN-IP are correct!***",
1031 onfail="***Routes in SDN-IP are wrong!***" )
1032 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1033 main.log.report(
1034 "***Routes in SDN-IP after adding routes are correct!***" )
1035 else:
1036 main.log.report(
1037 "***Routes in SDN-IP after adding routes are wrong!***" )
1038
1039 #============= Flap the BGP session between QuaggaCliHost4 and ONOS ==================
1040 main.log.info( "Disabling bgp session and enable it 20 times very fast between QuaggaCliHost4 and 192.168.30.101:" )
1041 for i in range(0, 20):
1042 main.log.info("Disable it %s times", i)
1043 main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513")
1044 main.log.info("Enable it again")
1045 main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
1046 time.sleep(0.1)
1047 main.log.info("Disable it finally")
1048 main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513")
1049
1050 main.log.info( "Sleeping for 30 seconds for network to converge" )
1051 time.sleep(30)
1052 # get routes inside SDN-IP
1053 main.log.info( "Getting Routes from ONOS CLI" )
1054 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1055
1056 # parse routes from ONOS CLI
1057 newAllRoutesActual = \
1058 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1059 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
1060
1061 # Expected routes with changed next hop
1062 newAllRoutesExpected = []
1063 for prefix in prefixesHost3:
1064 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1065 for prefix in prefixesHost4:
1066 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1067 for prefix in prefixesHost5:
1068 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1069 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
1070 main.step( "Check routes installed after convergence-1" )
1071 main.log.info( "Routes expected:" )
1072 main.log.info( newAllRoutesStrExpected )
1073 main.log.info( "Routes got from ONOS CLI after convergence-1:" )
1074 main.log.info( newAllRoutesStrActual )
1075 utilities.assertEquals(
1076 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
1077 onpass="***Routes in SDN-IP are correct after convergence!***",
1078 onfail="***Routes in SDN-IP are wrong after convergence!***" )
1079 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
1080 main.log.report(
1081 "***Routes in SDN-IP after convergence are correct!***" )
1082 else:
1083 main.log.report(
1084 "***Routes in SDN-IP after convergence are wrong!***" )
1085
1086 #============= Flap the BGP session between QuaggaCliHost4 and ONOS ==================
1087 main.log.info( "Disabling bgp session and enable it 20 times very fast between QuaggaCliHost4 and 192.168.30.101:" )
1088 for i in range(0, 20):
1089 main.log.info("Disable it %s times", i)
1090 main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513")
1091 main.log.info("Enable it again")
1092 main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
1093 time.sleep(0.1)
1094
1095 main.log.info( "Sleeping for 30 seconds for network to converge" )
1096 time.sleep(30)
1097
1098 # get routes inside SDN-IP
1099 main.log.info( "Getting Routes from ONOS CLI" )
1100 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1101
1102 # parse routes from ONOS CLI
1103 newAllRoutesActual = \
1104 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1105 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
1106
1107 # Expected routes with changed next hop
1108 newAllRoutesExpected = []
1109 for prefix in prefixesHost3:
1110 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1111 for prefix in prefixesHost4:
1112 newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" )
1113 for prefix in prefixesHost5:
1114 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1115 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
1116 main.step( "Check routes installed after convergence-2" )
1117 main.log.info( "Routes expected:" )
1118 main.log.info( newAllRoutesStrExpected )
1119 main.log.info( "Routes got from ONOS CLI after convergence-2:" )
1120 main.log.info( newAllRoutesStrActual )
1121 utilities.assertEquals(
1122 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
1123 onpass="***Routes in SDN-IP are correct after convergence!***",
1124 onfail="***Routes in SDN-IP are wrong after convergence!***" )
1125 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
1126 main.log.report(
1127 "***Routes in SDN-IP after convergence are correct!***" )
1128 else:
1129 main.log.report(
1130 "***Routes in SDN-IP after convergence are wrong!***" )
1131
1132 main.ONOScli.logout()
1133 main.log.info("ONOS cli logout")
1134 time.sleep(20);
1135 main.ONOSbench.onosStop(ONOS1Ip);
1136 main.log.info("onos stop")
1137 time.sleep(20);
1138 main.Mininet.stopNet()
1139 main.log.info("mininet stop")
1140 time.sleep(20)
1141
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001142 # Route convergence and connectivity test
1143 def CASE21( self, main):
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001144 import time
1145 import json
1146 from operator import eq
1147 # from datetime import datetime
1148 from time import localtime, strftime
1149
1150 main.case("The test case is to help to setup the TestON environment \
1151 and test new drivers" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001152 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
1153 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/routeconvergence/mininet"
1154 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json"
1155 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
sanghoshin43dbcfb2015-03-02 12:02:40 -08001156
1157 # Copy the json files to config dir
1158 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/addresses.json ~/onos/tools/package/config/")
1159 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/sdnip.json ~/onos/tools/package/config/")
1160
1161 # Launch mininet topology for this case
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001162 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterConvergenceMininet.py"
1163 main.step( "Launch mininet" )
1164 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
1165 main.step("waiting 20 secs for all switches and quagga instances to comeup")
1166 time.sleep(20)
1167 main.step( "Test whether Mininet is started" )
1168 main.log.info( "Login Quagga CLI on host3" )
1169 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001170 # all expected routes for all BGP peers
1171 allRoutesExpected = []
1172 main.step( "Start to generate routes for all BGP peers" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001173 main.log.info( "Generate prefixes for host3" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001174
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001175 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
1176 main.log.info( prefixesHost3 )
1177 # generate route with next hop
1178 for prefix in prefixesHost3:
1179 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1180 routeIntentsExpectedHost3 = \
1181 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
1182 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
1183 SDNIPJSONFILEPATH )
1184
1185 main.log.info( "Generate prefixes for host4" )
1186 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
1187 main.log.info( prefixesHost4 )
1188 # generate route with next hop
1189 for prefix in prefixesHost4:
1190 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
1191 routeIntentsExpectedHost4 = \
1192 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
1193 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
1194 SDNIPJSONFILEPATH )
1195
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001196 main.log.info( "Generate prefixes for host5" )
1197 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
1198 main.log.info( prefixesHost5 )
1199 for prefix in prefixesHost5:
1200 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1201 routeIntentsExpectedHost5 = \
1202 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
1203 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
1204 SDNIPJSONFILEPATH )
1205
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001206 routeIntentsExpected = routeIntentsExpectedHost3 + \
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001207 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001208
1209 cellName = main.params[ 'ENV' ][ 'cellName' ]
1210 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
1211 main.step( "Set cell for ONOS-cli environment" )
1212 main.ONOScli.setCell( cellName )
1213 verifyResult = main.ONOSbench.verifyCell()
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001214
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001215 main.log.report( "Removing raft logs" )
1216 main.ONOSbench.onosRemoveRaftLogs()
1217 main.log.report( "Uninstalling ONOS" )
1218 main.ONOSbench.onosUninstall( ONOS1Ip )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001219
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001220 main.step( "Installing ONOS package" )
1221 onos1InstallResult = main.ONOSbench.onosInstall(
1222 options="-f", node=ONOS1Ip )
1223
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001224 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
1225 if not onos1Isup:
1226 main.log.report( "ONOS1 didn't start!" )
1227
1228 main.step( "Start ONOS-cli" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001229
1230 main.ONOScli.startOnosCli( ONOS1Ip )
1231
1232 main.step( "Get devices in the network" )
1233 listResult = main.ONOScli.devices( jsonFormat=False )
1234 main.log.info( listResult )
1235 time.sleep( 10 )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001236 main.log.info( "Installing gbprouter feature" )
1237 main.ONOScli.featureInstall( "onos-app-bgprouter" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001238 time.sleep( 10 )
1239 main.step( "Login all BGP peers and add routes into peers" )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001240
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001241 main.log.info( "Login Quagga CLI on host3" )
1242 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
1243 main.log.info( "Enter configuration model of Quagga CLI on host3" )
1244 main.QuaggaCliHost3.enterConfig( 64514 )
1245 main.log.info( "Add routes to Quagga on host3" )
1246 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
1247
1248 main.log.info( "Login Quagga CLI on host4" )
1249 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
1250 main.log.info( "Enter configuration model of Quagga CLI on host4" )
1251 main.QuaggaCliHost4.enterConfig( 64516 )
1252 main.log.info( "Add routes to Quagga on host4" )
1253 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001254
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001255 main.log.info( "Login Quagga CLI on host5" )
1256 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
1257 main.log.info( "Enter configuration model of Quagga CLI on host5" )
1258 main.QuaggaCliHost5.enterConfig( 64521 )
1259 main.log.info( "Add routes to Quagga on host5" )
1260 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
1261
sanghoshin43dbcfb2015-03-02 12:02:40 -08001262 time.sleep( 30 )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001263
1264 # get routes inside SDN-IP
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001265 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1266
1267 # parse routes from ONOS CLI
1268 allRoutesActual = \
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001269 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001270
1271 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
1272 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
1273 main.step( "Check routes installed" )
1274 main.log.info( "Routes expected:" )
1275 main.log.info( allRoutesStrExpected )
1276 main.log.info( "Routes get from ONOS CLI:" )
1277 main.log.info( allRoutesStrActual )
1278 utilities.assertEquals(
1279 expect=allRoutesStrExpected, actual=allRoutesStrActual,
1280 onpass="***Routes in SDN-IP are correct!***",
1281 onfail="***Routes in SDN-IP are wrong!***" )
1282 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1283 main.log.report(
1284 "***Routes in SDN-IP after adding routes are correct!***" )
1285 else:
1286 main.log.report(
1287 "***Routes in SDN-IP after adding routes are wrong!***" )
1288
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001289 #============================= Ping Test ========================
1290 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1291 main.log.info("Ping test result")
1292 if pingTestResults:
1293 main.log.info("Test succeeded")
1294 else:
1295 main.log.info("Test failed")
1296
1297 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1298 onpass="Default connectivity check PASS",
1299 onfail="Default connectivity check FAIL")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001300
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001301 #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ==================
1302 main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
1303 main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" )
1304 main.log.info( "Sleeping for 150 seconds for network to converge" )
1305 time.sleep(150)
1306 # get routes inside SDN-IP
1307 main.log.info( "Getting Routes from ONOS CLI" )
1308 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1309
1310 # parse routes from ONOS CLI
1311 newAllRoutesActual = \
1312 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1313 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
1314
1315 # Expected routes with changed next hop
1316 newAllRoutesExpected = []
1317 for prefix in prefixesHost3:
1318 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1319 for prefix in prefixesHost4:
1320 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1321 for prefix in prefixesHost5:
1322 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1323 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
1324 main.step( "Check routes installed after convergence-1" )
1325 main.log.info( "Routes expected:" )
1326 main.log.info( newAllRoutesStrExpected )
1327 main.log.info( "Routes got from ONOS CLI after convergence-1:" )
1328 main.log.info( newAllRoutesStrActual )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001329 utilities.assertEquals(
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001330 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
1331 onpass="***Routes in SDN-IP are correct after convergence!***",
1332 onfail="***Routes in SDN-IP are wrong after convergence!***" )
1333 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001334 main.log.report(
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001335 "***Routes in SDN-IP after convergence are correct!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001336 else:
1337 main.log.report(
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001338 "***Routes in SDN-IP after convergence are wrong!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001339
1340 #============================= Ping Test ========================
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001341 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1342 main.log.info("Ping test result")
1343 if pingTestResults:
1344 main.log.info("Test succeeded")
1345 else:
1346 main.log.info("Test failed")
1347
1348 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1349 onpass="Default connectivity check PASS",
1350 onfail="Default connectivity check FAIL")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001351
Srikanth Vavilapalli43f3a1d2015-03-04 11:09:44 -08001352 #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ==================
1353 main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
1354 main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
1355 main.log.info( "Sleeping for 150 seconds for network to converge" )
1356 time.sleep(150)
1357 # get routes inside SDN-IP
1358 main.log.info( "Getting Routes from ONOS CLI" )
1359 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1360
1361 # parse routes from ONOS CLI
1362 newAllRoutesActual = \
1363 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1364 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
1365
1366 # Expected routes with changed next hop
1367 newAllRoutesExpected = []
1368 for prefix in prefixesHost3:
1369 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1370 for prefix in prefixesHost4:
1371 newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" )
1372 for prefix in prefixesHost5:
1373 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1374 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
1375 main.step( "Check routes installed after convergence-2" )
1376 main.log.info( "Routes expected:" )
1377 main.log.info( newAllRoutesStrExpected )
1378 main.log.info( "Routes got from ONOS CLI after convergence-2:" )
1379 main.log.info( newAllRoutesStrActual )
1380 utilities.assertEquals(
1381 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
1382 onpass="***Routes in SDN-IP are correct after convergence!***",
1383 onfail="***Routes in SDN-IP are wrong after convergence!***" )
1384 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
1385 main.log.report(
1386 "***Routes in SDN-IP after convergence are correct!***" )
1387 else:
1388 main.log.report(
1389 "***Routes in SDN-IP after convergence are wrong!***" )
1390
1391 #============================= Ping Test ========================
1392 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1393 main.log.info("Ping test result")
1394 if pingTestResults:
1395 main.log.info("Test succeeded")
1396 else:
1397 main.log.info("Test failed")
1398
1399 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1400 onpass="Default connectivity check PASS",
1401 onfail="Default connectivity check FAIL")
1402
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001403 #============================= Deleting Routes ==================
1404 main.step( "Check deleting routes installed" )
1405 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
1406 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001407 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001408
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001409 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1410 allRoutesActual = \
1411 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001412
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001413 main.log.info( "allRoutes_actual = " )
1414 main.log.info( allRoutesActual )
1415
1416 utilities.assertEquals(
1417 expect="[]", actual=str( allRoutesActual ),
1418 onpass="***Route number in SDN-IP is 0, correct!***",
1419 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
1420
1421 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001422 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001423 else:
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001424 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001425
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001426 #============================= Ping Test ========================
1427 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
1428 main.log.info("Ping test result")
1429 if pingTestResults:
1430 main.log.info("Test succeeded")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001431 else:
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001432 main.log.info("Test failed")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001433
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001434 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1435 onpass="disconnect check PASS",
1436 onfail="disconnect check FAIL")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001437
sanghoshinc59d6c52015-03-03 10:01:07 -08001438 main.ONOScli.logout()
Srikanth Vavilapallicf584ff2015-03-01 14:12:44 -08001439 main.ONOSbench.onosStop(ONOS1Ip);
sanghoshin43dbcfb2015-03-02 12:02:40 -08001440 main.Mininet.stopNet()
1441 time.sleep(10)
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001442
Srikanth Vavilapallie5388212015-03-05 13:55:53 -08001443 # Route convergence and connectivity test with Route Server
1444 def CASE22( self, main):
1445 import time
1446 import json
1447 from operator import eq
1448 # from datetime import datetime
1449 from time import localtime, strftime
1450
1451 main.case("The test case is to help to setup the TestON environment \
1452 and test new drivers" )
1453 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
1454 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/routeserver/mininet"
1455 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/routeserver/sdnip.json"
1456 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
1457
1458 # Copy the json files to config dir
1459 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/routeserver/addresses.json ~/onos/tools/package/config/")
1460 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/routeserver/sdnip.json ~/onos/tools/package/config/")
1461
1462 # Launch mininet topology for this case
1463 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouteServerMininet.py"
1464 main.step( "Launch mininet" )
1465 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
1466 main.step("waiting 20 secs for all switches and quagga instances to comeup")
1467 time.sleep(20)
1468 main.step( "Test whether Mininet is started" )
1469 main.log.info( "Login Quagga CLI on host3" )
1470 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
1471 # all expected routes for all BGP peers
1472 allRoutesExpected = []
1473 main.step( "Start to generate routes for all BGP peers" )
1474 main.log.info( "Generate prefixes for host3" )
1475
1476 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
1477 main.log.info( prefixesHost3 )
1478 # generate route with next hop
1479 for prefix in prefixesHost3:
1480 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1481 routeIntentsExpectedHost3 = \
1482 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
1483 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
1484 SDNIPJSONFILEPATH )
1485
1486 main.log.info( "Generate prefixes for host4" )
1487 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
1488 main.log.info( prefixesHost4 )
1489 # generate route with next hop
1490 for prefix in prefixesHost4:
1491 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
1492 routeIntentsExpectedHost4 = \
1493 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
1494 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
1495 SDNIPJSONFILEPATH )
1496
1497 main.log.info( "Generate prefixes for host5" )
1498 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
1499 main.log.info( prefixesHost5 )
1500 for prefix in prefixesHost5:
1501 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1502 routeIntentsExpectedHost5 = \
1503 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
1504 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
1505 SDNIPJSONFILEPATH )
1506
1507 routeIntentsExpected = routeIntentsExpectedHost3 + \
1508 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
1509
1510 cellName = main.params[ 'ENV' ][ 'cellName' ]
1511 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
1512 main.step( "Set cell for ONOS-cli environment" )
1513 main.ONOScli.setCell( cellName )
1514 verifyResult = main.ONOSbench.verifyCell()
1515
1516 main.log.report( "Removing raft logs" )
1517 main.ONOSbench.onosRemoveRaftLogs()
1518 main.log.report( "Uninstalling ONOS" )
1519 main.ONOSbench.onosUninstall( ONOS1Ip )
1520
1521 main.step( "Installing ONOS package" )
1522 onos1InstallResult = main.ONOSbench.onosInstall(
1523 options="-f", node=ONOS1Ip )
1524
1525 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
1526 if not onos1Isup:
1527 main.log.report( "ONOS1 didn't start!" )
1528
1529 main.step( "Start ONOS-cli" )
1530
1531 main.ONOScli.startOnosCli( ONOS1Ip )
1532
1533 main.step( "Get devices in the network" )
1534 listResult = main.ONOScli.devices( jsonFormat=False )
1535 main.log.info( listResult )
1536 time.sleep( 10 )
1537 main.log.info( "Installing gbprouter feature" )
1538 main.ONOScli.featureInstall( "onos-app-bgprouter" )
1539 time.sleep( 10 )
1540 main.step( "Login all BGP peers and add routes into peers" )
1541
1542 main.log.info( "Login Quagga CLI on host3" )
1543 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
1544 main.log.info( "Enter configuration model of Quagga CLI on host3" )
1545 main.QuaggaCliHost3.enterConfig( 64514 )
1546 main.log.info( "Add routes to Quagga on host3" )
1547 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
1548
1549 main.log.info( "Login Quagga CLI on host4" )
1550 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
1551 main.log.info( "Enter configuration model of Quagga CLI on host4" )
1552 main.QuaggaCliHost4.enterConfig( 64516 )
1553 main.log.info( "Add routes to Quagga on host4" )
1554 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
1555
1556 main.log.info( "Login Quagga CLI on host5" )
1557 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
1558 main.log.info( "Enter configuration model of Quagga CLI on host5" )
1559 main.QuaggaCliHost5.enterConfig( 64521 )
1560 main.log.info( "Add routes to Quagga on host5" )
1561 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
1562
1563 time.sleep( 60 )
1564
1565 # get routes inside SDN-IP
1566 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1567
1568 # parse routes from ONOS CLI
1569 allRoutesActual = \
1570 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1571
1572 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
1573 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
1574 main.step( "Check routes installed" )
1575 main.log.info( "Routes expected:" )
1576 main.log.info( allRoutesStrExpected )
1577 main.log.info( "Routes get from ONOS CLI:" )
1578 main.log.info( allRoutesStrActual )
1579 utilities.assertEquals(
1580 expect=allRoutesStrExpected, actual=allRoutesStrActual,
1581 onpass="***Routes in SDN-IP are correct!***",
1582 onfail="***Routes in SDN-IP are wrong!***" )
1583 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1584 main.log.report(
1585 "***Routes in SDN-IP after adding routes are correct!***" )
1586 else:
1587 main.log.report(
1588 "***Routes in SDN-IP after adding routes are wrong!***" )
1589
1590 #============================= Ping Test ========================
1591 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1592 main.log.info("Ping test result")
1593 if pingTestResults:
1594 main.log.info("Test succeeded")
1595 else:
1596 main.log.info("Test failed")
1597
1598 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1599 onpass="Default connectivity check PASS",
1600 onfail="Default connectivity check FAIL")
1601
1602 #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ==================
1603 main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
1604 main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" )
1605 main.log.info( "Sleeping for 150 seconds for network to converge" )
1606 time.sleep(150)
1607 # get routes inside SDN-IP
1608 main.log.info( "Getting Routes from ONOS CLI" )
1609 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1610
1611 # parse routes from ONOS CLI
1612 newAllRoutesActual = \
1613 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1614 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
1615
1616 # Expected routes with changed next hop
1617 newAllRoutesExpected = []
1618 for prefix in prefixesHost3:
1619 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1620 for prefix in prefixesHost4:
1621 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1622 for prefix in prefixesHost5:
1623 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1624 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
1625 main.step( "Check routes installed after convergence-1" )
1626 main.log.info( "Routes expected:" )
1627 main.log.info( newAllRoutesStrExpected )
1628 main.log.info( "Routes got from ONOS CLI after convergence-1:" )
1629 main.log.info( newAllRoutesStrActual )
1630 utilities.assertEquals(
1631 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
1632 onpass="***Routes in SDN-IP are correct after convergence!***",
1633 onfail="***Routes in SDN-IP are wrong after convergence!***" )
1634 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
1635 main.log.report(
1636 "***Routes in SDN-IP after convergence are correct!***" )
1637 else:
1638 main.log.report(
1639 "***Routes in SDN-IP after convergence are wrong!***" )
1640
1641 #============================= Ping Test ========================
1642 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1643 main.log.info("Ping test result")
1644 if pingTestResults:
1645 main.log.info("Test succeeded")
1646 else:
1647 main.log.info("Test failed")
1648
1649 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1650 onpass="Default connectivity check PASS",
1651 onfail="Default connectivity check FAIL")
1652
1653 #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ==================
1654 main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
1655 main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
1656 main.log.info( "Sleeping for 150 seconds for network to converge" )
1657 time.sleep(150)
1658 # get routes inside SDN-IP
1659 main.log.info( "Getting Routes from ONOS CLI" )
1660 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1661
1662 # parse routes from ONOS CLI
1663 newAllRoutesActual = \
1664 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1665 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
1666
1667 # Expected routes with changed next hop
1668 newAllRoutesExpected = []
1669 for prefix in prefixesHost3:
1670 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1671 for prefix in prefixesHost4:
1672 newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" )
1673 for prefix in prefixesHost5:
1674 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1675 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
1676 main.step( "Check routes installed after convergence-2" )
1677 main.log.info( "Routes expected:" )
1678 main.log.info( newAllRoutesStrExpected )
1679 main.log.info( "Routes got from ONOS CLI after convergence-2:" )
1680 main.log.info( newAllRoutesStrActual )
1681 utilities.assertEquals(
1682 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
1683 onpass="***Routes in SDN-IP are correct after convergence!***",
1684 onfail="***Routes in SDN-IP are wrong after convergence!***" )
1685 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
1686 main.log.report(
1687 "***Routes in SDN-IP after convergence are correct!***" )
1688 else:
1689 main.log.report(
1690 "***Routes in SDN-IP after convergence are wrong!***" )
1691
1692 #============================= Ping Test ========================
1693 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1694 main.log.info("Ping test result")
1695 if pingTestResults:
1696 main.log.info("Test succeeded")
1697 else:
1698 main.log.info("Test failed")
1699
1700 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1701 onpass="Default connectivity check PASS",
1702 onfail="Default connectivity check FAIL")
1703
1704 #============================= Deleting Routes ==================
1705 main.step( "Check deleting routes installed" )
1706 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
1707 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
1708 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
1709
1710 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1711 allRoutesActual = \
1712 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1713
1714 main.log.info( "allRoutes_actual = " )
1715 main.log.info( allRoutesActual )
1716
1717 utilities.assertEquals(
1718 expect="[]", actual=str( allRoutesActual ),
1719 onpass="***Route number in SDN-IP is 0, correct!***",
1720 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
1721
1722 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1723 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
1724 else:
1725 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
1726
1727 #============================= Ping Test ========================
1728 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
1729 main.log.info("Ping test result")
1730 if pingTestResults:
1731 main.log.info("Test succeeded")
1732 else:
1733 main.log.info("Test failed")
1734
1735 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1736 onpass="disconnect check PASS",
1737 onfail="disconnect check FAIL")
1738
1739 main.ONOScli.logout()
1740 main.ONOSbench.onosStop(ONOS1Ip);
1741 main.Mininet.stopNet()
1742 time.sleep(10)
1743
Srikanth Vavilapallida0b4e52015-03-09 16:09:15 -07001744 # Route convergence and connectivity test in VLAN configuration
1745 def CASE31( self, main):
1746 import time
1747 import json
1748 from operator import eq
1749 # from datetime import datetime
1750 from time import localtime, strftime
1751
1752 main.case("The test case is to help to setup the TestON environment \
1753 and test new drivers" )
1754 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
1755 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/routeconvergence/mininet"
1756 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/sdnip.json"
1757 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
1758
1759 # Copy the json files to config dir
1760 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/addresses.json ~/onos/tools/package/config/")
1761 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/sdnip.json ~/onos/tools/package/config/")
1762
1763 # Launch mininet topology for this case
1764 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterConvergenceVlanMininet.py"
1765 main.step( "Launch mininet" )
1766 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
1767 main.step("waiting 20 secs for all switches and quagga instances to comeup")
1768 time.sleep(20)
1769 main.step( "Test whether Mininet is started" )
1770 main.log.info( "Login Quagga CLI on host3" )
1771 result = main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
1772 #if result is not main.TRUE:
1773 # main.log.report("Mininet is not started...Aborting")
1774 # main.Mininet.stopNet()
1775 # main.cleanup()
1776 # main.exit()
1777 # all expected routes for all BGP peers
1778 allRoutesExpected = []
1779 main.step( "Start to generate routes for all BGP peers" )
1780 main.log.info( "Generate prefixes for host3" )
1781
1782 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
1783 main.log.info( prefixesHost3 )
1784 # generate route with next hop
1785 for prefix in prefixesHost3:
1786 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1787 routeIntentsExpectedHost3 = \
1788 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
1789 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
1790 SDNIPJSONFILEPATH )
1791
1792 main.log.info( "Generate prefixes for host4" )
1793 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
1794 main.log.info( prefixesHost4 )
1795 # generate route with next hop
1796 for prefix in prefixesHost4:
1797 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
1798 routeIntentsExpectedHost4 = \
1799 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
1800 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
1801 SDNIPJSONFILEPATH )
1802
1803 main.log.info( "Generate prefixes for host5" )
1804 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
1805 main.log.info( prefixesHost5 )
1806 for prefix in prefixesHost5:
1807 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1808 routeIntentsExpectedHost5 = \
1809 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
1810 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
1811 SDNIPJSONFILEPATH )
1812
1813 routeIntentsExpected = routeIntentsExpectedHost3 + \
1814 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
1815
1816 cellName = main.params[ 'ENV' ][ 'cellName' ]
1817 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
1818 main.step( "Set cell for ONOS-cli environment" )
1819 main.ONOScli.setCell( cellName )
1820 verifyResult = main.ONOSbench.verifyCell()
1821 utilities.assert_equals(expect=main.TRUE,actual=verifyResult,onpass="Verify cell pass!",onfail="Verify cell failed...")
1822
1823 main.log.report( "Removing raft logs" )
1824 main.ONOSbench.onosRemoveRaftLogs()
1825 main.log.report( "Uninstalling ONOS" )
1826 main.ONOSbench.onosUninstall( ONOS1Ip )
1827
1828 main.step( "Installing ONOS package" )
1829 onos1InstallResult = main.ONOSbench.onosInstall(
1830 options="-f", node=ONOS1Ip )
1831 if onos1InstallResult is not main.TRUE:
1832 main.log.report("ONOS is not installed...Aborting")
1833 main.Mininet.stopNet()
1834 main.cleanup()
1835 main.exit()
1836
1837 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
1838 if onos1Isup is not main.TRUE:
1839 main.log.report("ONOS1 didn't start!...Aborting" )
1840 main.Mininet.stopNet()
1841 main.ONOSbench.onosStop(ONOS1Ip);
1842 main.cleanup()
1843 main.exit()
1844
1845 main.step( "Start ONOS-cli" )
1846
1847 result = main.ONOScli.startOnosCli( ONOS1Ip )
1848 utilities.assert_equals(expect=main.TRUE,actual=result,onpass="ONOS CLI is up!",onfail="ONOS CLI is not up...")
1849 if result is not main.TRUE:
1850 main.log.report("ONOS1 didn't start!...Aborting" )
1851 main.Mininet.stopNet()
1852 main.ONOScli.logout()
1853 main.ONOSbench.onosStop(ONOS1Ip);
1854 main.cleanup()
1855 main.exit()
1856
1857
1858 main.step( "Get devices in the network" )
1859 listResult = main.ONOScli.devices( jsonFormat=False )
1860 main.log.info( listResult )
1861 time.sleep( 10 )
1862 main.log.info( "Installing bgprouter feature" )
1863 main.ONOScli.featureInstall( "onos-app-bgprouter" )
1864 time.sleep( 10 )
1865 main.step( "Login all BGP peers and add routes into peers" )
1866
1867 main.log.info( "Login Quagga CLI on host3" )
1868 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
1869 main.log.info( "Enter configuration model of Quagga CLI on host3" )
1870 main.QuaggaCliHost3.enterConfig( 64514 )
1871 main.log.info( "Add routes to Quagga on host3" )
1872 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
1873
1874 main.log.info( "Login Quagga CLI on host4" )
1875 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
1876 main.log.info( "Enter configuration model of Quagga CLI on host4" )
1877 main.QuaggaCliHost4.enterConfig( 64516 )
1878 main.log.info( "Add routes to Quagga on host4" )
1879 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
1880
1881 main.log.info( "Login Quagga CLI on host5" )
1882 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
1883 main.log.info( "Enter configuration model of Quagga CLI on host5" )
1884 main.QuaggaCliHost5.enterConfig( 64521 )
1885 main.log.info( "Add routes to Quagga on host5" )
1886 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
1887
1888 time.sleep( 30 )
1889
1890 # get routes inside SDN-IP
1891 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1892
1893 # parse routes from ONOS CLI
1894 allRoutesActual = \
1895 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1896
1897 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
1898 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
1899 main.step( "Check routes installed" )
1900 main.log.info( "Routes expected:" )
1901 main.log.info( allRoutesStrExpected )
1902 main.log.info( "Routes get from ONOS CLI:" )
1903 main.log.info( allRoutesStrActual )
1904 utilities.assertEquals(
1905 expect=allRoutesStrExpected, actual=allRoutesStrActual,
1906 onpass="***Routes in SDN-IP are correct!***",
1907 onfail="***Routes in SDN-IP are wrong!***" )
1908 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1909 main.log.report(
1910 "***Routes in SDN-IP after adding routes are correct!***" )
1911 else:
1912 main.log.report(
1913 "***Routes in SDN-IP after adding routes are wrong!***" )
1914
1915 #============================= Ping Test ========================
1916 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1917 main.log.info("Ping test result")
1918 if pingTestResults:
1919 main.log.info("Test succeeded")
1920 else:
1921 main.log.info("Test failed")
1922
1923 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1924 onpass="Default connectivity check PASS",
1925 onfail="Default connectivity check FAIL")
1926
1927 #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ==================
1928 main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
1929 main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" )
1930 main.log.info( "Sleeping for 150 seconds for network to converge" )
1931 time.sleep(150)
1932 # get routes inside SDN-IP
1933 main.log.info( "Getting Routes from ONOS CLI" )
1934 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1935
1936 # parse routes from ONOS CLI
1937 newAllRoutesActual = \
1938 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1939 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
1940
1941 # Expected routes with changed next hop
1942 newAllRoutesExpected = []
1943 for prefix in prefixesHost3:
1944 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1945 for prefix in prefixesHost4:
1946 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1947 for prefix in prefixesHost5:
1948 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
1949 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
1950 main.step( "Check routes installed after convergence-1" )
1951 main.log.info( "Routes expected:" )
1952 main.log.info( newAllRoutesStrExpected )
1953 main.log.info( "Routes got from ONOS CLI after convergence-1:" )
1954 main.log.info( newAllRoutesStrActual )
1955 utilities.assertEquals(
1956 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
1957 onpass="***Routes in SDN-IP are correct after convergence!***",
1958 onfail="***Routes in SDN-IP are wrong after convergence!***" )
1959 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
1960 main.log.report(
1961 "***Routes in SDN-IP after convergence are correct!***" )
1962 else:
1963 main.log.report(
1964 "***Routes in SDN-IP after convergence are wrong!***" )
1965
1966 #============================= Ping Test ========================
1967 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
1968 main.log.info("Ping test result")
1969 if pingTestResults:
1970 main.log.info("Test succeeded")
1971 else:
1972 main.log.info("Test failed")
1973
1974 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
1975 onpass="Default connectivity check PASS",
1976 onfail="Default connectivity check FAIL")
1977
1978 #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ==================
1979 main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
1980 main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
1981 main.log.info( "Sleeping for 150 seconds for network to converge" )
1982 time.sleep(150)
1983 # get routes inside SDN-IP
1984 main.log.info( "Getting Routes from ONOS CLI" )
1985 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1986
1987 # parse routes from ONOS CLI
1988 newAllRoutesActual = \
1989 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1990 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
1991
1992 # Expected routes with changed next hop
1993 newAllRoutesExpected = []
1994 for prefix in prefixesHost3:
1995 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1996 for prefix in prefixesHost4:
1997 newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" )
1998 for prefix in prefixesHost5:
1999 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
2000 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
2001 main.step( "Check routes installed after convergence-2" )
2002 main.log.info( "Routes expected:" )
2003 main.log.info( newAllRoutesStrExpected )
2004 main.log.info( "Routes got from ONOS CLI after convergence-2:" )
2005 main.log.info( newAllRoutesStrActual )
2006 utilities.assertEquals(
2007 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
2008 onpass="***Routes in SDN-IP are correct after convergence!***",
2009 onfail="***Routes in SDN-IP are wrong after convergence!***" )
2010 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
2011 main.log.report(
2012 "***Routes in SDN-IP after convergence are correct!***" )
2013 else:
2014 main.log.report(
2015 "***Routes in SDN-IP after convergence are wrong!***" )
2016
2017 #============================= Ping Test ========================
2018 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
2019 main.log.info("Ping test result")
2020 if pingTestResults:
2021 main.log.info("Test succeeded")
2022 else:
2023 main.log.info("Test failed")
2024
2025 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
2026 onpass="Default connectivity check PASS",
2027 onfail="Default connectivity check FAIL")
2028
2029 #============================= Deleting Routes ==================
2030 main.step( "Check deleting routes installed" )
2031 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
2032 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
2033 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
2034
2035 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
2036 allRoutesActual = \
2037 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
2038
2039 main.log.info( "allRoutes_actual = " )
2040 main.log.info( allRoutesActual )
2041
2042 utilities.assertEquals(
2043 expect="[]", actual=str( allRoutesActual ),
2044 onpass="***Route number in SDN-IP is 0, correct!***",
2045 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
2046
2047 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
2048 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
2049 else:
2050 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
2051
2052 #============================= Ping Test ========================
2053 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
2054 main.log.info("Ping test result")
2055 if pingTestResults:
2056 main.log.info("Test succeeded")
2057 else:
2058 main.log.info("Test failed")
2059
2060 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
2061 onpass="disconnect check PASS",
2062 onfail="disconnect check FAIL")
2063
2064 main.ONOScli.logout()
2065 main.ONOSbench.onosStop(ONOS1Ip);
2066 main.Mininet.stopNet()
2067 time.sleep(10)
2068
2069 # Route convergence and connectivity test with Route Server in VLAN tagged network
2070 def CASE32( self, main):
2071 import time
2072 import json
2073 from operator import eq
2074 # from datetime import datetime
2075 from time import localtime, strftime
2076
2077 main.case("The test case is to help to setup the TestON environment \
2078 and test new drivers" )
2079 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
2080 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/vlan/routeserver/mininet"
2081 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/vlan/routeserver/sdnip.json"
2082 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
2083
2084 # Copy the json files to config dir
2085 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/routeserver/addresses.json ~/onos/tools/package/config/")
2086 main.ONOSbench.handle.sendline("cp " + TESTCASE_ROOT_PATH + "/vlan/routeserver/sdnip.json ~/onos/tools/package/config/")
2087
2088 # Launch mininet topology for this case
2089 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouteServerVlanMininet.py"
2090 main.step( "Launch mininet" )
2091 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
2092 main.step("waiting 20 secs for all switches and quagga instances to comeup")
2093 time.sleep(20)
2094 main.step( "Test whether Mininet is started" )
2095 main.log.info( "Login Quagga CLI on host3" )
2096 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
2097 # all expected routes for all BGP peers
2098 allRoutesExpected = []
2099 main.step( "Start to generate routes for all BGP peers" )
2100 main.log.info( "Generate prefixes for host3" )
2101
2102 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
2103 main.log.info( prefixesHost3 )
2104 # generate route with next hop
2105 for prefix in prefixesHost3:
2106 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
2107 routeIntentsExpectedHost3 = \
2108 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
2109 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
2110 SDNIPJSONFILEPATH )
2111
2112 main.log.info( "Generate prefixes for host4" )
2113 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
2114 main.log.info( prefixesHost4 )
2115 # generate route with next hop
2116 for prefix in prefixesHost4:
2117 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
2118 routeIntentsExpectedHost4 = \
2119 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
2120 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
2121 SDNIPJSONFILEPATH )
2122
2123 main.log.info( "Generate prefixes for host5" )
2124 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
2125 main.log.info( prefixesHost5 )
2126 for prefix in prefixesHost5:
2127 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
2128 routeIntentsExpectedHost5 = \
2129 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
2130 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
2131 SDNIPJSONFILEPATH )
2132
2133 routeIntentsExpected = routeIntentsExpectedHost3 + \
2134 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
2135
2136 cellName = main.params[ 'ENV' ][ 'cellName' ]
2137 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
2138 main.step( "Set cell for ONOS-cli environment" )
2139 main.ONOScli.setCell( cellName )
2140 verifyResult = main.ONOSbench.verifyCell()
2141
2142 main.log.report( "Removing raft logs" )
2143 main.ONOSbench.onosRemoveRaftLogs()
2144 main.log.report( "Uninstalling ONOS" )
2145 main.ONOSbench.onosUninstall( ONOS1Ip )
2146
2147 main.step( "Installing ONOS package" )
2148 onos1InstallResult = main.ONOSbench.onosInstall(
2149 options="-f", node=ONOS1Ip )
2150
2151 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
2152 if not onos1Isup:
2153 main.log.report( "ONOS1 didn't start!" )
2154
2155 main.step( "Start ONOS-cli" )
2156
2157 main.ONOScli.startOnosCli( ONOS1Ip )
2158
2159 main.step( "Get devices in the network" )
2160 listResult = main.ONOScli.devices( jsonFormat=False )
2161 main.log.info( listResult )
2162 time.sleep( 10 )
2163 main.log.info( "Installing gbprouter feature" )
2164 main.ONOScli.featureInstall( "onos-app-bgprouter" )
2165 time.sleep( 10 )
2166 main.step( "Login all BGP peers and add routes into peers" )
2167
2168 main.log.info( "Login Quagga CLI on host3" )
2169 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
2170 main.log.info( "Enter configuration model of Quagga CLI on host3" )
2171 main.QuaggaCliHost3.enterConfig( 64514 )
2172 main.log.info( "Add routes to Quagga on host3" )
2173 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
2174
2175 main.log.info( "Login Quagga CLI on host4" )
2176 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
2177 main.log.info( "Enter configuration model of Quagga CLI on host4" )
2178 main.QuaggaCliHost4.enterConfig( 64516 )
2179 main.log.info( "Add routes to Quagga on host4" )
2180 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
2181
2182 main.log.info( "Login Quagga CLI on host5" )
2183 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
2184 main.log.info( "Enter configuration model of Quagga CLI on host5" )
2185 main.QuaggaCliHost5.enterConfig( 64521 )
2186 main.log.info( "Add routes to Quagga on host5" )
2187 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
2188
2189 time.sleep( 60 )
2190
2191 # get routes inside SDN-IP
2192 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
2193
2194 # parse routes from ONOS CLI
2195 allRoutesActual = \
2196 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
2197
2198 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
2199 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
2200 main.step( "Check routes installed" )
2201 main.log.info( "Routes expected:" )
2202 main.log.info( allRoutesStrExpected )
2203 main.log.info( "Routes get from ONOS CLI:" )
2204 main.log.info( allRoutesStrActual )
2205 utilities.assertEquals(
2206 expect=allRoutesStrExpected, actual=allRoutesStrActual,
2207 onpass="***Routes in SDN-IP are correct!***",
2208 onfail="***Routes in SDN-IP are wrong!***" )
2209 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
2210 main.log.report(
2211 "***Routes in SDN-IP after adding routes are correct!***" )
2212 else:
2213 main.log.report(
2214 "***Routes in SDN-IP after adding routes are wrong!***" )
2215
2216 #============================= Ping Test ========================
2217 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
2218 main.log.info("Ping test result")
2219 if pingTestResults:
2220 main.log.info("Test succeeded")
2221 else:
2222 main.log.info("Test failed")
2223
2224 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
2225 onpass="Default connectivity check PASS",
2226 onfail="Default connectivity check FAIL")
2227
2228 #============= Disconnect the BGP session between QuaggaCliHost4 and ONOS ==================
2229 main.log.info( "Disabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
2230 main.QuaggaCliHost4.disable_bgp_peer( "192.168.30.101", "64513" )
2231 main.log.info( "Sleeping for 150 seconds for network to converge" )
2232 time.sleep(150)
2233 # get routes inside SDN-IP
2234 main.log.info( "Getting Routes from ONOS CLI" )
2235 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
2236
2237 # parse routes from ONOS CLI
2238 newAllRoutesActual = \
2239 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
2240 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
2241
2242 # Expected routes with changed next hop
2243 newAllRoutesExpected = []
2244 for prefix in prefixesHost3:
2245 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
2246 for prefix in prefixesHost4:
2247 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
2248 for prefix in prefixesHost5:
2249 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
2250 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
2251 main.step( "Check routes installed after convergence-1" )
2252 main.log.info( "Routes expected:" )
2253 main.log.info( newAllRoutesStrExpected )
2254 main.log.info( "Routes got from ONOS CLI after convergence-1:" )
2255 main.log.info( newAllRoutesStrActual )
2256 utilities.assertEquals(
2257 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
2258 onpass="***Routes in SDN-IP are correct after convergence!***",
2259 onfail="***Routes in SDN-IP are wrong after convergence!***" )
2260 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
2261 main.log.report(
2262 "***Routes in SDN-IP after convergence are correct!***" )
2263 else:
2264 main.log.report(
2265 "***Routes in SDN-IP after convergence are wrong!***" )
2266
2267 #============================= Ping Test ========================
2268 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
2269 main.log.info("Ping test result")
2270 if pingTestResults:
2271 main.log.info("Test succeeded")
2272 else:
2273 main.log.info("Test failed")
2274
2275 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
2276 onpass="Default connectivity check PASS",
2277 onfail="Default connectivity check FAIL")
2278
2279 #============= Enabling the BGP session between QuaggaCliHost4 and ONOS ==================
2280 main.log.info( "Enabling bgp session between QuaggaCliHost4 and 192.168.30.101:" )
2281 main.QuaggaCliHost4.enable_bgp_peer( "192.168.30.101", "64513" )
2282 main.log.info( "Sleeping for 150 seconds for network to converge" )
2283 time.sleep(150)
2284 # get routes inside SDN-IP
2285 main.log.info( "Getting Routes from ONOS CLI" )
2286 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
2287
2288 # parse routes from ONOS CLI
2289 newAllRoutesActual = \
2290 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
2291 newAllRoutesStrActual = str( newAllRoutesActual ).replace( 'u', "" )
2292
2293 # Expected routes with changed next hop
2294 newAllRoutesExpected = []
2295 for prefix in prefixesHost3:
2296 newAllRoutesExpected.append( prefix + "/" + "192.168.20.1" )
2297 for prefix in prefixesHost4:
2298 newAllRoutesExpected.append( prefix + "/" + "192.168.30.1" )
2299 for prefix in prefixesHost5:
2300 newAllRoutesExpected.append( prefix + "/" + "192.168.60.2" )
2301 newAllRoutesStrExpected = str( sorted( newAllRoutesExpected ) )
2302 main.step( "Check routes installed after convergence-2" )
2303 main.log.info( "Routes expected:" )
2304 main.log.info( newAllRoutesStrExpected )
2305 main.log.info( "Routes got from ONOS CLI after convergence-2:" )
2306 main.log.info( newAllRoutesStrActual )
2307 utilities.assertEquals(
2308 expect=newAllRoutesStrExpected, actual=newAllRoutesStrActual,
2309 onpass="***Routes in SDN-IP are correct after convergence!***",
2310 onfail="***Routes in SDN-IP are wrong after convergence!***" )
2311 if( eq( newAllRoutesStrExpected, newAllRoutesStrActual ) ):
2312 main.log.report(
2313 "***Routes in SDN-IP after convergence are correct!***" )
2314 else:
2315 main.log.report(
2316 "***Routes in SDN-IP after convergence are wrong!***" )
2317
2318 #============================= Ping Test ========================
2319 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
2320 main.log.info("Ping test result")
2321 if pingTestResults:
2322 main.log.info("Test succeeded")
2323 else:
2324 main.log.info("Test failed")
2325
2326 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
2327 onpass="Default connectivity check PASS",
2328 onfail="Default connectivity check FAIL")
2329
2330 #============================= Deleting Routes ==================
2331 main.step( "Check deleting routes installed" )
2332 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
2333 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
2334 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
2335
2336 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
2337 allRoutesActual = \
2338 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
2339
2340 main.log.info( "allRoutes_actual = " )
2341 main.log.info( allRoutesActual )
2342
2343 utilities.assertEquals(
2344 expect="[]", actual=str( allRoutesActual ),
2345 onpass="***Route number in SDN-IP is 0, correct!***",
2346 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
2347
2348 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
2349 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
2350 else:
2351 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
2352
2353 #============================= Ping Test ========================
2354 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
2355 main.log.info("Ping test result")
2356 if pingTestResults:
2357 main.log.info("Test succeeded")
2358 else:
2359 main.log.info("Test failed")
2360
2361 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
2362 onpass="disconnect check PASS",
2363 onfail="disconnect check FAIL")
2364
2365 main.ONOScli.logout()
2366 main.ONOSbench.onosStop(ONOS1Ip);
2367 main.Mininet.stopNet()
2368 time.sleep(10)
2369