blob: 10d9617c35c4168e37eef02d7aecce6484a1185e [file] [log] [blame]
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08001# from cupshelpers.config import prefix
2
sanghoshina96f1e72015-02-27 09:30:56 -08003# Testing the basic functionality of SDN-IP
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -08004
5
6class PeeringRouterTest:
7
8 def __init__( self ):
9 self.default = ''
10
11# from cupshelpers.config import prefix
12
13# Testing the basic functionality of SDN-IP
14
15
16class PeeringRouterTest:
17
18 def __init__( self ):
19 self.default = ''
20
sanghoshin29e6a472015-02-27 12:55:06 -080021 def CASE6 (self, main):
22 import time
23 import json
24 from operator import eq
25 # from datetime import datetime
26 from time import localtime, strftime
27
28 #============================= Ping Test ========================
29 main.log.info("Start ping test")
30 pingTestResults = main.QuaggaCliHost.pingTestAndCheck(
31 "1.168.30.100" )
32 main.log.info("Ping test result")
33 if pingTestResults:
34 main.log.info("Test succeeded")
35 else:
36 main.log.info("Test failed")
37
38 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
39 onpass="Default connectivity check PASS",
40 onfail="Default connectivity check FAIL")
41
42
43 def CASE4( self, main):
44 import time
45 import json
46 from operator import eq
47 # from datetime import datetime
48 from time import localtime, strftime
49
50 main.case("The test case is to help to setup the TestON environment \
51 and test new drivers" )
Srikanth Vavilapallicf1cd5b2015-02-27 17:19:12 -080052 TESTCASE_ROOT_PATH = main.params[ 'ENV' ][ 'home' ]
53 TESTCASE_MININET_ROOT_PATH = TESTCASE_ROOT_PATH + "/mininet"
54 SDNIPJSONFILEPATH = TESTCASE_ROOT_PATH + "/sdnip.json"
55 main.log.info("sdnip.json file path: "+ SDNIPJSONFILEPATH)
56 # Launch mininet topology for this case
57 MININET_TOPO_FILE = TESTCASE_MININET_ROOT_PATH + "/PeeringRouterMininet.py"
58 main.step( "Launch mininet" )
59 main.Mininet.handle.sendline("sudo python " + MININET_TOPO_FILE + " " + TESTCASE_MININET_ROOT_PATH)
60 main.step("waiting 20 secs for all switches and quagga instances to comeup")
61 time.sleep(20)
62 main.step("verifying mininet launch")
63 main.log.info( "Login Quagga CLI on host3" )
64 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
sanghoshin29e6a472015-02-27 12:55:06 -080065 # all expected routes for all BGP peers
66 allRoutesExpected = []
67 main.step( "Start to generate routes for all BGP peers" )
68 main.log.info( "Generate prefixes for host3" )
69 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
70 main.log.info( prefixesHost3 )
71 # generate route with next hop
72 for prefix in prefixesHost3:
73 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
74 routeIntentsExpectedHost3 = \
75 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
76 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
77 SDNIPJSONFILEPATH )
78
79 main.log.info( "Generate prefixes for host4" )
80 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
81 main.log.info( prefixesHost4 )
82
83 # generate route with next hop
84 for prefix in prefixesHost3:
85 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
86 routeIntentsExpectedHost3 = \
87 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
88 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
89 SDNIPJSONFILEPATH )
90
91 main.log.info( "Generate prefixes for host4" )
92 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
93 main.log.info( prefixesHost4 )
94 # generate route with next hop
95 for prefix in prefixesHost4:
96 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
97 routeIntentsExpectedHost4 = \
98 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
99 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
100 SDNIPJSONFILEPATH )
101
102 main.log.info( "Generate prefixes for host5" )
103 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
104 main.log.info( prefixesHost5 )
105 for prefix in prefixesHost5:
106 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
107 routeIntentsExpectedHost5 = \
108 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
109 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
110 SDNIPJSONFILEPATH )
111
112 routeIntentsExpected = routeIntentsExpectedHost3 + \
113 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
114
115 cellName = main.params[ 'ENV' ][ 'cellName' ]
116 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
117 main.step( "Set cell for ONOS-cli environment" )
118 main.ONOScli.setCell( cellName )
119 verifyResult = main.ONOSbench.verifyCell()
120
121 main.log.report( "Removing raft logs" )
122 main.ONOSbench.onosRemoveRaftLogs()
123 main.log.report( "Uninstalling ONOS" )
124 main.ONOSbench.onosUninstall( ONOS1Ip )
125
126 main.step( "Installing ONOS package" )
127 onos1InstallResult = main.ONOSbench.onosInstall(
128 options="-f", node=ONOS1Ip )
129
130 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
131 if not onos1Isup:
132 main.log.report( "ONOS1 didn't start!" )
133
134 main.step( "Start ONOS-cli" )
135
136 main.ONOScli.startOnosCli( ONOS1Ip )
137
138 main.step( "Get devices in the network" )
139 listResult = main.ONOScli.devices( jsonFormat=False )
140 main.log.info( listResult )
141 time.sleep( 10 )
142 main.log.info( "Installing gbprouter feature" )
143 main.ONOScli.featureInstall( "onos-app-bgprouter" )
144 time.sleep( 10 )
145 main.step( "Login all BGP peers and add routes into peers" )
146
147 main.log.info( "Login Quagga CLI on host3" )
148 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
149 main.log.info( "Enter configuration model of Quagga CLI on host3" )
150 main.QuaggaCliHost3.enterConfig( 64514 )
151 main.log.info( "Add routes to Quagga on host3" )
152 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
153
154 main.log.info( "Login Quagga CLI on host4" )
155 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
156 main.log.info( "Enter configuration model of Quagga CLI on host4" )
157 main.QuaggaCliHost4.enterConfig( 64516 )
158 main.log.info( "Add routes to Quagga on host4" )
159 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
160
161 main.log.info( "Login Quagga CLI on host5" )
162 main.QuaggaCliHost5.loginQuagga( "1.168.30.5" )
163 main.log.info( "Enter configuration model of Quagga CLI on host5" )
164 main.QuaggaCliHost5.enterConfig( 64521 )
165 main.log.info( "Add routes to Quagga on host5" )
166 main.QuaggaCliHost5.addRoutes( prefixesHost5, 1 )
167
168 #time.sleep( 30 )
169 time.sleep(10)
170
171 # get routes inside SDN-IP
172 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
173
174 # parse routes from ONOS CLI
sanghoshine35a8a52015-02-27 20:47:26 -0800175 allRoutesActual = \
176 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
sanghoshin29e6a472015-02-27 12:55:06 -0800177
178 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
179 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
180 main.step( "Check routes installed" )
181 main.log.info( "Routes expected:" )
182 main.log.info( allRoutesStrExpected )
183 main.log.info( "Routes get from ONOS CLI:" )
184 main.log.info( allRoutesStrActual )
185 utilities.assertEquals(
186 expect=allRoutesStrExpected, actual=allRoutesStrActual,
187 onpass="***Routes in SDN-IP are correct!***",
188 onfail="***Routes in SDN-IP are wrong!***" )
189 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
190 main.log.report(
191 "***Routes in SDN-IP after adding routes are correct!***" )
192 else:
193 main.log.report(
194 "***Routes in SDN-IP after adding routes are wrong!***" )
195
196 #============================= Ping Test ========================
197 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllPass( "1.168.30.100" )
198 main.log.info("Ping test result")
199 if pingTestResults:
200 main.log.info("Test succeeded")
201 else:
202 main.log.info("Test failed")
203
204 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
205 onpass="Default connectivity check PASS",
206 onfail="Default connectivity check FAIL")
207
208 #============================= Deleting Routes ==================
209 main.step( "Check deleting routes installed" )
210 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
211 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
212 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
213
214 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
sanghoshine35a8a52015-02-27 20:47:26 -0800215 allRoutesActual = \
216 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
sanghoshin29e6a472015-02-27 12:55:06 -0800217
218 main.log.info( "allRoutes_actual = " )
219 main.log.info( allRoutesActual )
220
221 utilities.assertEquals(
222 expect="[]", actual=str( allRoutesActual ),
223 onpass="***Route number in SDN-IP is 0, correct!***",
224 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
225
226 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
227 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
228 else:
229 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
230
231 #============================= Ping Test ========================
232 pingTestResults = main.QuaggaCliHost.pingTestAndCheckAllFail( "1.168.30.100" )
233 main.log.info("Ping test result")
234 if pingTestResults:
235 main.log.info("Test succeeded")
236 else:
237 main.log.info("Test failed")
238
239 utilities.assert_equals(expect=main.TRUE,actual=pingTestResults,
240 onpass="disconnect check PASS",
241 onfail="disconnect check FAIL")
242
Srikanth Vavilapallicf1cd5b2015-02-27 17:19:12 -0800243 main.ONOScli.disconnect()
244 main.ONOSbench.onosStop(ONOS1Ip);
245 main.Mininet.disconnect()
246
sanghoshin29e6a472015-02-27 12:55:06 -0800247 def CASE5( self, main ):
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800248 """
249 Test the SDN-IP functionality
250 allRoutesExpected: all expected routes for all BGP peers
251 routeIntentsExpected: all expected MultiPointToSinglePointIntent \
252 intents
253 bgpIntentsExpected: expected PointToPointIntent intents
254 allRoutesActual: all routes from ONOS LCI
255 routeIntentsActual: actual MultiPointToSinglePointIntent intents from \
256 ONOS CLI
257 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
258 """
259 import time
260 import json
261 from operator import eq
262 # from datetime import datetime
263 from time import localtime, strftime
264
265 main.case("The test case is to help to setup the TestON environment \
266 and test new drivers" )
sanghoshin29e6a472015-02-27 12:55:06 -0800267 CURRENT_PATH = "/home/sdnip/TestON/tests/PeeringRouterTest/"
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800268 SDNIPJSONFILEPATH = \
sanghoshin29e6a472015-02-27 12:55:06 -0800269 "/home/sdnip/TestON/tests/PeeringRouterTest/sdnip.json"
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800270 # all expected routes for all BGP peers
271 allRoutesExpected = []
272 main.step( "Start to generate routes for all BGP peers" )
273 main.log.info( "Generate prefixes for host3" )
274 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
275 main.log.info( prefixesHost3 )
276 # generate route with next hop
277 for prefix in prefixesHost3:
278 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
279 routeIntentsExpectedHost3 = \
280 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
281 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
282 SDNIPJSONFILEPATH )
283
284 main.log.info( "Generate prefixes for host4" )
285 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
286 main.log.info( prefixesHost4 )
287 # generate route with next hop
288 for prefix in prefixesHost4:
289 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
290 routeIntentsExpectedHost4 = \
291 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
292 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
293 SDNIPJSONFILEPATH )
294
295 main.log.info( "Generate prefixes for host5" )
296 prefixesHost5 = main.QuaggaCliHost5.generatePrefixes( 5, 10 )
297 main.log.info( prefixesHost5 )
298 for prefix in prefixesHost5:
299 allRoutesExpected.append( prefix + "/" + "192.168.60.2" )
300 routeIntentsExpectedHost5 = \
301 main.QuaggaCliHost5.generateExpectedOnePeerRouteIntents(
302 prefixesHost5, "192.168.60.1", "00:00:00:00:06:02",
303 SDNIPJSONFILEPATH )
304
305 routeIntentsExpected = routeIntentsExpectedHost3 + \
306 routeIntentsExpectedHost4 + routeIntentsExpectedHost5
307
308 cellName = main.params[ 'ENV' ][ 'cellName' ]
309 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
310 main.step( "Set cell for ONOS-cli environment" )
311 main.ONOScli.setCell( cellName )
312 verifyResult = main.ONOSbench.verifyCell()
313
314 main.log.report( "Removing raft logs" )
315 main.ONOSbench.onosRemoveRaftLogs()
316 main.log.report( "Uninstalling ONOS" )
317 main.ONOSbench.onosUninstall( ONOS1Ip )
318
319 main.step( "Installing ONOS package" )
320 onos1InstallResult = main.ONOSbench.onosInstall(
321 options="-f", node=ONOS1Ip )
322
323 main.step( "Checking if ONOS is up yet" )
sanghoshina96f1e72015-02-27 09:30:56 -0800324 time.sleep( 20 )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800325 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
326 if not onos1Isup:
327 main.log.report( "ONOS1 didn't start!" )
328
329 main.step( "Start ONOS-cli" )
330
331 main.ONOScli.startOnosCli( ONOS1Ip )
332
333 main.step( "Get devices in the network" )
334 listResult = main.ONOScli.devices( jsonFormat=False )
335 main.log.info( listResult )
336 time.sleep( 10 )
sanghoshina96f1e72015-02-27 09:30:56 -0800337 main.log.info( "Installing gbprouter feature" )
338 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
sanghoshin29e6a472015-02-27 12:55:06 -0800363 #time.sleep( 30 )
364 time.sleep(10)
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800365
366 # get routes inside SDN-IP
367 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
368
369 # parse routes from ONOS CLI
sanghoshin29e6a472015-02-27 12:55:06 -0800370 # allRoutesActual = \
371 # main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
372 allRoutesActual = []
373 main.log.info("allRoutesExpected")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800374
375 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
376 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
377 main.step( "Check routes installed" )
378 main.log.info( "Routes expected:" )
379 main.log.info( allRoutesStrExpected )
380 main.log.info( "Routes get from ONOS CLI:" )
381 main.log.info( allRoutesStrActual )
382 utilities.assertEquals(
383 expect=allRoutesStrExpected, actual=allRoutesStrActual,
384 onpass="***Routes in SDN-IP are correct!***",
385 onfail="***Routes in SDN-IP are wrong!***" )
386 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
387 main.log.report(
388 "***Routes in SDN-IP after adding routes are correct!***" )
389 else:
390 main.log.report(
391 "***Routes in SDN-IP after adding routes are wrong!***" )
392
sanghoshin29e6a472015-02-27 12:55:06 -0800393 #time.sleep( 20 )
394 #getIntentsResult = main.ONOScli.intents( jsonFormat=True )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800395
sanghoshin29e6a472015-02-27 12:55:06 -0800396 #main.step( "Check MultiPointToSinglePointIntent intents installed" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800397 # routeIntentsExpected are generated when generating routes
398 # get rpoute intents from ONOS CLI
sanghoshin29e6a472015-02-27 12:55:06 -0800399 #routeIntentsActual = \
400 # main.QuaggaCliHost3.extractActualRouteIntents(
401 # getIntentsResult )
402 #routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
403 #routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" )
404 #main.log.info( "MultiPointToSinglePoint intents expected:" )
405 #main.log.info( routeIntentsStrExpected )
406 #main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" )
407 #main.log.info( routeIntentsStrActual )
408 #utilities.assertEquals(
409 # expect=True,
410 # actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
411 # onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
412 # correct!***",
413 # onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
414 # wrong!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800415
sanghoshin29e6a472015-02-27 12:55:06 -0800416 #if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
417 # main.log.report( "***MultiPointToSinglePoint Intents before \
418 # deleting routes correct!***" )
419 #else:
420 # main.log.report( "***MultiPointToSinglePoint Intents before \
421 # deleting routes wrong!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800422
sanghoshin29e6a472015-02-27 12:55:06 -0800423 #main.step( "Check BGP PointToPointIntent intents installed" )
424 ## bgp intents expected
425 #bgpIntentsExpected = \
426 # main.QuaggaCliHost3.generateExpectedBgpIntents( SDNIPJSONFILEPATH )
427 ## get BGP intents from ONOS CLI
428 #bgpIntentsActual = \
429 # main.QuaggaCliHost3.extractActualBgpIntents( getIntentsResult )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800430
sanghoshin29e6a472015-02-27 12:55:06 -0800431 #bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
432 #bgpIntentsStrActual = str( bgpIntentsActual )
433 #main.log.info( "PointToPointIntent intents expected:" )
434 #main.log.info( bgpIntentsStrExpected )
435 #main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
436 #main.log.info( bgpIntentsStrActual )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800437
sanghoshin29e6a472015-02-27 12:55:06 -0800438 #utilities.assertEquals(
439 # expect=True,
440 # actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
441 # onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
442 # onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800443
sanghoshin29e6a472015-02-27 12:55:06 -0800444 #if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
445 # main.log.report(
446 # "***PointToPointIntent Intents in SDN-IP are correct!***" )
447 #else:
448 # main.log.report(
449 # "***PointToPointIntent Intents in SDN-IP are wrong!***" )
sanghoshina96f1e72015-02-27 09:30:56 -0800450
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800451 #============================= Ping Test ========================
452 # wait until all MultiPointToSinglePoint
sanghoshin29e6a472015-02-27 12:55:06 -0800453 time.sleep( 10 )
454 main.log.info("Start ping test")
455 pingTestScript = CURRENT_PATH + "CASE4-ping-as2host.sh"
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800456 pingTestResultsFile = \
sanghoshin29e6a472015-02-27 12:55:06 -0800457 CURRENT_PATH + "CASE4-ping-results-before-delete-routes-" \
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800458 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
459 pingTestResults = main.QuaggaCliHost.pingTest(
460 "1.168.30.100", pingTestScript, pingTestResultsFile )
sanghoshin29e6a472015-02-27 12:55:06 -0800461 main.log.info("Ping test result")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800462 main.log.info( pingTestResults )
sanghoshin29e6a472015-02-27 12:55:06 -0800463 time.sleep( 10 )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800464
465 #============================= Deleting Routes ==================
466 main.step( "Check deleting routes installed" )
467 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
468 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
469 main.QuaggaCliHost5.deleteRoutes( prefixesHost5, 1 )
470
471 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
sanghoshin29e6a472015-02-27 12:55:06 -0800472 # FIX ME
473 #allRoutesActual = \
474 # main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
475 allRoutesActual = []
476
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800477 main.log.info( "allRoutes_actual = " )
478 main.log.info( allRoutesActual )
479
480 utilities.assertEquals(
481 expect="[]", actual=str( allRoutesActual ),
482 onpass="***Route number in SDN-IP is 0, correct!***",
483 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
484
485 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
486 main.log.report( "***Routes in SDN-IP after deleting correct!***" )
487 else:
488 main.log.report( "***Routes in SDN-IP after deleting wrong!***" )
489
sanghoshin29e6a472015-02-27 12:55:06 -0800490 #main.step( "Check intents after deleting routes" )
491 #getIntentsResult = main.ONOScli.intents( jsonFormat=True )
492 #routeIntentsActual = \
493 # main.QuaggaCliHost3.extractActualRouteIntents(
494 # getIntentsResult )
495 #main.log.info( "main.ONOScli.intents()= " )
496 #main.log.info( routeIntentsActual )
497 #utilities.assertEquals(
498 # expect="[]", actual=str( routeIntentsActual ),
499 # onpass="***MultiPointToSinglePoint Intents number in SDN-IP is 0, \
500 # correct!***",
501 # onfail="***MultiPointToSinglePoint Intents number in SDN-IP is 0, \
502 # wrong!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800503
sanghoshin29e6a472015-02-27 12:55:06 -0800504 #if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
505 # main.log.report( "***MultiPointToSinglePoint Intents after \
506 # deleting routes correct!***" )
507 #else:
508 # main.log.report( "***MultiPointToSinglePoint Intents after \
509 # deleting routes wrong!***" )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800510
sanghoshin29e6a472015-02-27 12:55:06 -0800511 time.sleep( 10 )
512 main.log.info("Ping test after removing routs")
513 pingTestScript = CURRENT_PATH + "CASE4-ping-as2host.sh"
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800514 pingTestResultsFile = \
sanghoshin29e6a472015-02-27 12:55:06 -0800515 CURRENT_PATH + "CASE4-ping-results-after-delete-routes-" \
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800516 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
517 pingTestResults = main.QuaggaCliHost.pingTest(
518 "1.168.30.100", pingTestScript, pingTestResultsFile )
sanghoshin29e6a472015-02-27 12:55:06 -0800519 main.log.info("Ping test results")
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800520 main.log.info( pingTestResults )
sanghoshin29e6a472015-02-27 12:55:06 -0800521 time.sleep( 10 )
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800522
523 # main.step( "Test whether Mininet is started" )
524 # main.Mininet2.handle.sendline( "xterm host1" )
525 # main.Mininet2.handle.expect( "mininet>" )
526
527 def CASE3( self, main ):
528 """
529 Test the SDN-IP functionality
530 allRoutesExpected: all expected routes for all BGP peers
531 routeIntentsExpected: all expected MultiPointToSinglePointIntent intents
532 bgpIntentsExpected: expected PointToPointIntent intents
533 allRoutesActual: all routes from ONOS LCI
534 routeIntentsActual: actual MultiPointToSinglePointIntent intents from \
535 ONOS CLI
536 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
537 """
538 import time
539 import json
540 from operator import eq
541 # from datetime import datetime
542 from time import localtime, strftime
543
544 main.case( "The test case is to help to setup the TestON \
545 environment and test new drivers" )
546 # SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
sanghoshin29e6a472015-02-27 12:55:06 -0800547 TESTPATH = "/home/adnip/TestOn/tests/PeeringRouterTest/"
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800548 SDNIPJSONFILEPATH = \
sanghoshin29e6a472015-02-27 12:55:06 -0800549 "/home/sdnip/onos/tools/package/config/sdnip.json"
Srikanth Vavilapalli0abf3f62015-02-24 21:27:43 -0800550 # all expected routes for all BGP peers
551 allRoutesExpected = []
552 main.step( "Start to generate routes for all BGP peers" )
553 main.log.info( "Generate prefixes for host3" )
554 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
555 main.log.info( prefixesHost3 )
556 # generate route with next hop
557 for prefix in prefixesHost3:
558 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
559 routeIntentsExpectedHost3 = \
560 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
561 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
562 SDNIPJSONFILEPATH )
563
564 main.log.info( "Generate prefixes for host4" )
565 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
566 main.log.info( prefixesHost4 )
567 # generate route with next hop
568 for prefix in prefixesHost4:
569 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
570 routeIntentsExpectedHost4 = \
571 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
572 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
573 SDNIPJSONFILEPATH )
574
575 routeIntentsExpected = routeIntentsExpectedHost3 + \
576 routeIntentsExpectedHost4
577
578 cellName = main.params[ 'ENV' ][ 'cellName' ]
579 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
580 main.step( "Set cell for ONOS-cli environment" )
581 main.ONOScli.setCell( cellName )
582 verifyResult = main.ONOSbench.verifyCell()
583
584 main.log.report( "Removing raft logs" )
585 main.ONOSbench.onosRemoveRaftLogs()
586 main.log.report( "Uninstalling ONOS" )
587 main.ONOSbench.onosUninstall( ONOS1Ip )
588
589 main.step( "Installing ONOS package" )
590 onos1InstallResult = main.ONOSbench.onosInstall(
591 options="-f", node=ONOS1Ip )
592
593 main.step( "Checking if ONOS is up yet" )
594 time.sleep( 60 )
595 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
596 if not onos1Isup:
597 main.log.report( "ONOS1 didn't start!" )
598
599 main.step( "Start ONOS-cli" )
600
601 main.ONOScli.startOnosCli( ONOS1Ip )
602
603 main.step( "Get devices in the network" )
604 listResult = main.ONOScli.devices( jsonFormat=False )
605 main.log.info( listResult )
606 time.sleep( 10 )
607 main.log.info( "Installing sdn-ip feature" )
608 main.ONOScli.featureInstall( "onos-app-sdnip" )
609 time.sleep( 10 )
610 main.step( "Login all BGP peers and add routes into peers" )
611
612 main.log.info( "Login Quagga CLI on host3" )
613 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
614 main.log.info( "Enter configuration model of Quagga CLI on host3" )
615 main.QuaggaCliHost3.enterConfig( 64514 )
616 main.log.info( "Add routes to Quagga on host3" )
617 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
618
619 main.log.info( "Login Quagga CLI on host4" )
620 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
621 main.log.info( "Enter configuration model of Quagga CLI on host4" )
622 main.QuaggaCliHost4.enterConfig( 64516 )
623 main.log.info( "Add routes to Quagga on host4" )
624 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
625
626 for i in range( 101, 201 ):
627 prefixesHostX = \
628 main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
629 main.log.info( prefixesHostX )
630 for prefix in prefixesHostX:
631 allRoutesExpected.append(
632 prefix + "/" + "192.168.40." + str( i - 100 ) )
633
634 routeIntentsExpectedHostX = \
635 main.QuaggaCliHost.generateExpectedOnePeerRouteIntents(
636 prefixesHostX, "192.168.40." + str( i - 100 ),
637 "00:00:%02d:00:00:90" % ( i - 101 ), SDNIPJSONFILEPATH )
638 routeIntentsExpected = routeIntentsExpected + \
639 routeIntentsExpectedHostX
640
641 main.log.info( "Login Quagga CLI on host" + str( i ) )
642 QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
643 QuaggaCliHostX.loginQuagga( "1.168.30." + str( i ) )
644 main.log.info(
645 "Enter configuration model of Quagga CLI on host" + str( i ) )
646 QuaggaCliHostX.enterConfig( 65000 + i - 100 )
647 main.log.info( "Add routes to Quagga on host" + str( i ) )
648 QuaggaCliHostX.addRoutes( prefixesHostX, 1 )
649
650 time.sleep( 60 )
651
652 # get routes inside SDN-IP
653 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
654
655 # parse routes from ONOS CLI
656 allRoutesActual = \
657 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
658
659 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
660 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
661 main.step( "Check routes installed" )
662 main.log.info( "Routes expected:" )
663 main.log.info( allRoutesStrExpected )
664 main.log.info( "Routes get from ONOS CLI:" )
665 main.log.info( allRoutesStrActual )
666 utilities.assertEquals(
667 expect=allRoutesStrExpected, actual=allRoutesStrActual,
668 onpass="***Routes in SDN-IP are correct!***",
669 onfail="***Routes in SDN-IP are wrong!***" )
670 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
671 main.log.report(
672 "***Routes in SDN-IP after adding routes are correct!***" )
673 else:
674 main.log.report(
675 "***Routes in SDN-IP after adding routes are wrong!***" )
676
677 time.sleep( 20 )
678 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
679
680 main.step( "Check MultiPointToSinglePointIntent intents installed" )
681 # routeIntentsExpected are generated when generating routes
682 # get rpoute intents from ONOS CLI
683 routeIntentsActual = \
684 main.QuaggaCliHost3.extractActualRouteIntents(
685 getIntentsResult )
686 routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
687 routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" )
688 main.log.info( "MultiPointToSinglePoint intents expected:" )
689 main.log.info( routeIntentsStrExpected )
690 main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" )
691 main.log.info( routeIntentsStrActual )
692 utilities.assertEquals(
693 expect=True,
694 actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
695 onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
696 correct!***",
697 onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
698 wrong!***" )
699
700 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
701 main.log.report(
702 "***MultiPointToSinglePoint Intents before deleting routes \
703 correct!***" )
704 else:
705 main.log.report(
706 "***MultiPointToSinglePoint Intents before deleting routes \
707 wrong!***" )
708
709 main.step( "Check BGP PointToPointIntent intents installed" )
710 # bgp intents expected
711 bgpIntentsExpected = main.QuaggaCliHost3.generateExpectedBgpIntents(
712 SDNIPJSONFILEPATH )
713 # get BGP intents from ONOS CLI
714 bgpIntentsActual = main.QuaggaCliHost3.extractActualBgpIntents(
715 getIntentsResult )
716
717 bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
718 bgpIntentsStrActual = str( bgpIntentsActual )
719 main.log.info( "PointToPointIntent intents expected:" )
720 main.log.info( bgpIntentsStrExpected )
721 main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
722 main.log.info( bgpIntentsStrActual )
723
724 utilities.assertEquals(
725 expect=True,
726 actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
727 onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
728 onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
729
730 if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
731 main.log.report(
732 "***PointToPointIntent Intents in SDN-IP are correct!***" )
733 else:
734 main.log.report(
735 "***PointToPointIntent Intents in SDN-IP are wrong!***" )
736
737 #============================= Ping Test ========================
738 # wait until all MultiPointToSinglePoint
739 time.sleep( 20 )
740 pingTestScript = "~/SDNIP/test-tools/CASE3-ping-as2host.sh"
741 pingTestResultsFile = \
742 "~/SDNIP/SdnIpIntentDemo/log/CASE3-ping-results-before-delete-routes-" \
743 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
744 pingTestResults = main.QuaggaCliHost.pingTest(
745 "1.168.30.100", pingTestScript, pingTestResultsFile )
746 main.log.info( pingTestResults )
747 time.sleep( 20 )
748
749 #============================= Deleting Routes ==================
750 main.step( "Check deleting routes installed" )
751 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
752 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
753 for i in range( 101, 201 ):
754 prefixesHostX = \
755 main.QuaggaCliHost.generatePrefixes( str( i ), 10 )
756 main.log.info( prefixesHostX )
757 QuaggaCliHostX = getattr( main, ( 'QuaggaCliHost' + str( i ) ) )
758 QuaggaCliHostX.deleteRoutes( prefixesHostX, 1 )
759
760 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
761 allRoutesActual = main.QuaggaCliHost3.extractActualRoutes(
762 getRoutesResult )
763 main.log.info( "allRoutes_actual = " )
764 main.log.info( allRoutesActual )
765
766 utilities.assertEquals(
767 expect="[]", actual=str( allRoutesActual ),
768 onpass="***Route number in SDN-IP is 0, correct!***",
769 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
770
771 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
772 main.log.report(
773 "***Routes in SDN-IP after deleting correct!***" )
774 else:
775 main.log.report(
776 "***Routes in SDN-IP after deleting wrong!***" )
777
778 main.step( "Check intents after deleting routes" )
779 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
780 routeIntentsActual = \
781 main.QuaggaCliHost3.extractActualRouteIntents(
782 getIntentsResult )
783 main.log.info( "main.ONOScli.intents()= " )
784 main.log.info( routeIntentsActual )
785 utilities.assertEquals(
786 expect="[]", actual=str( routeIntentsActual ),
787 onpass="***MultiPointToSinglePoint Intents number in SDN-IP is \
788 0, correct!***",
789 onfail="***MultiPointToSinglePoint Intents number in SDN-IP is \
790 0, wrong!***" )
791
792 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
793 main.log.report(
794 "***MultiPointToSinglePoint Intents after deleting routes \
795 correct!***" )
796 else:
797 main.log.report(
798 "***MultiPointToSinglePoint Intents after deleting routes \
799 wrong!***" )
800
801 time.sleep( 20 )
802 pingTestScript = "~/SDNIP/test-tools/CASE3-ping-as2host.sh"
803 pingTestResultsFile = \
804 "~/SDNIP/SdnIpIntentDemo/log/CASE3-ping-results-after-delete-routes-" \
805 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
806 pingTestResults = main.QuaggaCliHost.pingTest(
807 "1.168.30.100", pingTestScript, pingTestResultsFile )
808 main.log.info( pingTestResults )
809 time.sleep( 100 )
810
811 # main.step( "Test whether Mininet is started" )
812 # main.Mininet2.handle.sendline( "xterm host1" )
813 # main.Mininet2.handle.expect( "mininet>" )
814
815 def CASE1( self, main ):
816 """
817 Test the SDN-IP functionality
818 allRoutesExpected: all expected routes for all BGP peers
819 routeIntentsExpected: all expected MultiPointToSinglePointIntent \
820 intents
821 bgpIntentsExpected: expected PointToPointIntent intents
822 allRoutesActual: all routes from ONOS LCI
823 routeIntentsActual: actual MultiPointToSinglePointIntent intents \
824 from ONOS CLI
825 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
826 """
827 import time
828 import json
829 from operator import eq
830 # from datetime import datetime
831 from time import localtime, strftime
832
833 main.case("The test case is to help to setup the TestON environment \
834 and test new drivers" )
835 SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
836 # all expected routes for all BGP peers
837 allRoutesExpected = []
838 main.step( "Start to generate routes for all BGP peers" )
839 # bgpPeerHosts = []
840 # for i in range( 3, 5 ):
841 # bgpPeerHosts.append( "host" + str( i ) )
842 # main.log.info( "BGP Peer Hosts are:" + bgpPeerHosts )
843
844 # for i in range( 3, 5 ):
845 # QuaggaCliHost = "QuaggaCliHost" + str( i )
846 # prefixes = main.QuaggaCliHost.generatePrefixes( 3, 10 )
847
848 # main.log.info( prefixes )
849 # allRoutesExpected.append( prefixes )
850 main.log.info( "Generate prefixes for host3" )
851 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
852 main.log.info( prefixesHost3 )
853 # generate route with next hop
854 for prefix in prefixesHost3:
855 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
856 routeIntentsExpectedHost3 = \
857 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
858 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
859 SDNIPJSONFILEPATH )
860
861 main.log.info( "Generate prefixes for host4" )
862 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
863 main.log.info( prefixesHost4 )
864 # generate route with next hop
865 for prefix in prefixesHost4:
866 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
867 routeIntentsExpectedHost4 = \
868 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
869 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
870 SDNIPJSONFILEPATH )
871
872 routeIntentsExpected = routeIntentsExpectedHost3 + \
873 routeIntentsExpectedHost4
874
875 cellName = main.params[ 'ENV' ][ 'cellName' ]
876 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
877 main.step( "Set cell for ONOS-cli environment" )
878 main.ONOScli.setCell( cellName )
879 verifyResult = main.ONOSbench.verifyCell()
880 main.log.report( "Removing raft logs" )
881 main.ONOSbench.onosRemoveRaftLogs()
882 main.log.report( "Uninstalling ONOS" )
883 main.ONOSbench.onosUninstall( ONOS1Ip )
884 main.step( "Creating ONOS package" )
885 packageResult = main.ONOSbench.onosPackage()
886
887 main.step( "Starting ONOS service" )
888 # TODO: start ONOS from Mininet Script
889 # startResult = main.ONOSbench.onosStart( "127.0.0.1" )
890 main.step( "Installing ONOS package" )
891 onos1InstallResult = main.ONOSbench.onosInstall(
892 options="-f", node=ONOS1Ip )
893
894 main.step( "Checking if ONOS is up yet" )
895 time.sleep( 60 )
896 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
897 if not onos1Isup:
898 main.log.report( "ONOS1 didn't start!" )
899
900 main.step( "Start ONOS-cli" )
901 # TODO: change the hardcode in startOnosCli method in ONOS CLI driver
902
903 main.ONOScli.startOnosCli( ONOS1Ip )
904
905 main.step( "Get devices in the network" )
906 listResult = main.ONOScli.devices( jsonFormat=False )
907 main.log.info( listResult )
908 time.sleep( 10 )
909 main.log.info( "Installing sdn-ip feature" )
910 main.ONOScli.featureInstall( "onos-app-sdnip" )
911 time.sleep( 10 )
912 main.step( "Login all BGP peers and add routes into peers" )
913 main.log.info( "Login Quagga CLI on host3" )
914 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
915 main.log.info( "Enter configuration model of Quagga CLI on host3" )
916 main.QuaggaCliHost3.enterConfig( 64514 )
917 main.log.info( "Add routes to Quagga on host3" )
918 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
919
920 main.log.info( "Login Quagga CLI on host4" )
921 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
922 main.log.info( "Enter configuration model of Quagga CLI on host4" )
923 main.QuaggaCliHost4.enterConfig( 64516 )
924 main.log.info( "Add routes to Quagga on host4" )
925 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
926 time.sleep( 60 )
927
928 # get all routes inside SDN-IP
929 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
930
931 # parse routes from ONOS CLI
932 allRoutesActual = \
933 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
934
935 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
936 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
937 main.step( "Check routes installed" )
938 main.log.info( "Routes expected:" )
939 main.log.info( allRoutesStrExpected )
940 main.log.info( "Routes get from ONOS CLI:" )
941 main.log.info( allRoutesStrActual )
942 utilities.assertEquals(
943 expect=allRoutesStrExpected, actual=allRoutesStrActual,
944 onpass="***Routes in SDN-IP are correct!***",
945 onfail="***Routes in SDN-IP are wrong!***" )
946 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
947 main.log.report(
948 "***Routes in SDN-IP after adding routes are correct!***" )
949 else:
950 main.log.report(
951 "***Routes in SDN-IP after adding routes are wrong!***" )
952
953 time.sleep( 20 )
954 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
955
956 main.step( "Check MultiPointToSinglePointIntent intents installed" )
957 # routeIntentsExpected are generated when generating routes
958 # get rpoute intents from ONOS CLI
959 routeIntentsActual = \
960 main.QuaggaCliHost3.extractActualRouteIntents(
961 getIntentsResult )
962 routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
963 routeIntentsStrActual = str( routeIntentsActual ).replace( 'u', "" )
964 main.log.info( "MultiPointToSinglePoint intents expected:" )
965 main.log.info( routeIntentsStrExpected )
966 main.log.info( "MultiPointToSinglePoint intents get from ONOS CLI:" )
967 main.log.info( routeIntentsStrActual )
968 utilities.assertEquals(
969 expect=True,
970 actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
971 onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
972 correct!***",
973 onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
974 wrong!***" )
975
976 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
977 main.log.report(
978 "***MultiPointToSinglePoint Intents before deleting routes \
979 correct!***" )
980 else:
981 main.log.report(
982 "***MultiPointToSinglePoint Intents before deleting routes \
983 wrong!***" )
984
985 main.step( "Check BGP PointToPointIntent intents installed" )
986 # bgp intents expected
987 bgpIntentsExpected = \
988 main.QuaggaCliHost3.generateExpectedBgpIntents( SDNIPJSONFILEPATH )
989 # get BGP intents from ONOS CLI
990 bgpIntentsActual = main.QuaggaCliHost3.extractActualBgpIntents(
991 getIntentsResult )
992
993 bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
994 bgpIntentsStrActual = str( bgpIntentsActual )
995 main.log.info( "PointToPointIntent intents expected:" )
996 main.log.info( bgpIntentsStrExpected )
997 main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
998 main.log.info( bgpIntentsStrActual )
999
1000 utilities.assertEquals(
1001 expect=True,
1002 actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
1003 onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
1004 onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
1005
1006 if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
1007 main.log.report(
1008 "***PointToPointIntent Intents in SDN-IP are correct!***" )
1009 else:
1010 main.log.report(
1011 "***PointToPointIntent Intents in SDN-IP are wrong!***" )
1012
1013 #============================= Ping Test ========================
1014 # wait until all MultiPointToSinglePoint
1015 time.sleep( 20 )
1016 pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
1017 pingTestResultsFile = \
1018 "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-before-delete-routes-" \
1019 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
1020 pingTestResults = main.QuaggaCliHost.pingTest(
1021 "1.168.30.100", pingTestScript, pingTestResultsFile )
1022 main.log.info( pingTestResults )
1023
1024 # ping test
1025
1026 #============================= Deleting Routes ==================
1027 main.step( "Check deleting routes installed" )
1028 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
1029 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
1030
1031 # main.log.info( "main.ONOScli.get_routes_num() = " )
1032 # main.log.info( main.ONOScli.getRoutesNum() )
1033 # utilities.assertEquals( expect="Total SDN-IP routes = 1", actual=
1034 # main.ONOScli.getRoutesNum(),
1035 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1036 allRoutesActual = \
1037 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1038 main.log.info( "allRoutes_actual = " )
1039 main.log.info( allRoutesActual )
1040
1041 utilities.assertEquals(
1042 expect="[]", actual=str( allRoutesActual ),
1043 onpass="***Route number in SDN-IP is 0, correct!***",
1044 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
1045
1046 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1047 main.log.report(
1048 "***Routes in SDN-IP after deleting correct!***" )
1049 else:
1050 main.log.report(
1051 "***Routes in SDN-IP after deleting wrong!***" )
1052
1053 main.step( "Check intents after deleting routes" )
1054 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
1055 routeIntentsActual = \
1056 main.QuaggaCliHost3.extractActualRouteIntents(
1057 getIntentsResult )
1058 main.log.info( "main.ONOScli.intents()= " )
1059 main.log.info( routeIntentsActual )
1060 utilities.assertEquals(
1061 expect="[]", actual=str( routeIntentsActual ),
1062 onpass="***MultiPointToSinglePoint Intents number in SDN-IP is \
1063 0, correct!***",
1064 onfail="***MultiPointToSinglePoint Intents number in SDN-IP is \
1065 0, wrong!***" )
1066
1067 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
1068 main.log.report(
1069 "***MultiPointToSinglePoint Intents after deleting routes \
1070 correct!***" )
1071 else:
1072 main.log.report(
1073 "***MultiPointToSinglePoint Intents after deleting routes \
1074 wrong!***" )
1075
1076 time.sleep( 20 )
1077 pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
1078 pingTestResultsFile = \
1079 "~/SDNIP/SdnIpIntentDemo/log/CASE1-ping-results-after-delete-routes-" \
1080 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
1081 pingTestResults = main.QuaggaCliHost.pingTest(
1082 "1.168.30.100", pingTestScript, pingTestResultsFile )
1083 main.log.info( pingTestResults )
1084 time.sleep( 30 )
1085
1086 # main.step( "Test whether Mininet is started" )
1087 # main.Mininet2.handle.sendline( "xterm host1" )
1088 # main.Mininet2.handle.expect( "mininet>" )
1089
1090 def CASE2( self, main ):
1091 """
1092 Test the SDN-IP functionality
1093 allRoutesExpected: all expected routes for all BGP peers
1094 routeIntentsExpected: all expected MultiPointToSinglePointIntent \
1095 intents
1096 bgpIntentsExpected: expected PointToPointIntent intents
1097 allRoutesActual: all routes from ONOS LCI
1098 routeIntentsActual: actual MultiPointToSinglePointIntent intents \
1099 from ONOS CLI
1100 bgpIntentsActual: actual PointToPointIntent intents from ONOS CLI
1101 """
1102 import time
1103 import json
1104 from operator import eq
1105 from time import localtime, strftime
1106
1107 main.case(
1108 "The test case is to help to setup the TestON environment and \
1109 test new drivers" )
1110 SDNIPJSONFILEPATH = "../tests/SdnIpTest/sdnip.json"
1111 # all expected routes for all BGP peers
1112 allRoutesExpected = []
1113 main.step( "Start to generate routes for all BGP peers" )
1114
1115 main.log.info( "Generate prefixes for host3" )
1116 prefixesHost3 = main.QuaggaCliHost3.generatePrefixes( 3, 10 )
1117 main.log.info( prefixesHost3 )
1118 # generate route with next hop
1119 for prefix in prefixesHost3:
1120 allRoutesExpected.append( prefix + "/" + "192.168.20.1" )
1121 routeIntentsExpectedHost3 = \
1122 main.QuaggaCliHost3.generateExpectedOnePeerRouteIntents(
1123 prefixesHost3, "192.168.20.1", "00:00:00:00:02:02",
1124 SDNIPJSONFILEPATH )
1125
1126 main.log.info( "Generate prefixes for host4" )
1127 prefixesHost4 = main.QuaggaCliHost4.generatePrefixes( 4, 10 )
1128 main.log.info( prefixesHost4 )
1129 # generate route with next hop
1130 for prefix in prefixesHost4:
1131 allRoutesExpected.append( prefix + "/" + "192.168.30.1" )
1132 routeIntentsExpectedHost4 = \
1133 main.QuaggaCliHost4.generateExpectedOnePeerRouteIntents(
1134 prefixesHost4, "192.168.30.1", "00:00:00:00:03:01",
1135 SDNIPJSONFILEPATH )
1136
1137 routeIntentsExpected = routeIntentsExpectedHost3 + \
1138 routeIntentsExpectedHost4
1139
1140 main.log.report( "Removing raft logs" )
1141 main.ONOSbench.onosRemoveRaftLogs()
1142 main.log.report( "Uninstalling ONOS" )
1143 main.ONOSbench.onosUninstall( ONOS1Ip )
1144
1145 cellName = main.params[ 'ENV' ][ 'cellName' ]
1146 ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
1147 main.step( "Set cell for ONOS-cli environment" )
1148 main.ONOScli.setCell( cellName )
1149 verifyResult = main.ONOSbench.verifyCell()
1150 # main.log.report( "Removing raft logs" )
1151 # main.ONOSbench.onosRemoveRaftLogs()
1152 # main.log.report( "Uninstalling ONOS" )
1153 # main.ONOSbench.onosUninstall( ONOS1Ip )
1154 main.step( "Creating ONOS package" )
1155 # packageResult = main.ONOSbench.onosPackage()
1156
1157 main.step( "Installing ONOS package" )
1158 # onos1InstallResult = main.ONOSbench.onosInstall( options="-f",
1159 # node=ONOS1Ip )
1160
1161 main.step( "Checking if ONOS is up yet" )
1162 # time.sleep( 60 )
1163 onos1Isup = main.ONOSbench.isup( ONOS1Ip )
1164 if not onos1Isup:
1165 main.log.report( "ONOS1 didn't start!" )
1166
1167 main.step( "Start ONOS-cli" )
1168 main.ONOScli.startOnosCli( ONOS1Ip )
1169
1170 main.step( "Get devices in the network" )
1171 listResult = main.ONOScli.devices( jsonFormat=False )
1172 main.log.info( listResult )
1173 time.sleep( 10 )
1174 main.log.info( "Installing sdn-ip feature" )
1175 main.ONOScli.featureInstall( "onos-app-sdnip" )
1176 time.sleep( 10 )
1177
1178 main.step( "Check BGP PointToPointIntent intents installed" )
1179 # bgp intents expected
1180 bgpIntentsExpected = main.QuaggaCliHost3.generateExpectedBgpIntents(
1181 SDNIPJSONFILEPATH )
1182 # get BGP intents from ONOS CLI
1183 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
1184 bgpIntentsActual = main.QuaggaCliHost3.extractActualBgpIntents(
1185 getIntentsResult )
1186
1187 bgpIntentsStrExpected = str( bgpIntentsExpected ).replace( 'u', "" )
1188 bgpIntentsStrActual = str( bgpIntentsActual )
1189 main.log.info( "PointToPointIntent intents expected:" )
1190 main.log.info( bgpIntentsStrExpected )
1191 main.log.info( "PointToPointIntent intents get from ONOS CLI:" )
1192 main.log.info( bgpIntentsStrActual )
1193
1194 utilities.assertEquals(
1195 expect=True,
1196 actual=eq( bgpIntentsStrExpected, bgpIntentsStrActual ),
1197 onpass="***PointToPointIntent Intents in SDN-IP are correct!***",
1198 onfail="***PointToPointIntent Intents in SDN-IP are wrong!***" )
1199
1200 if ( eq( bgpIntentsStrExpected, bgpIntentsStrActual ) ):
1201 main.log.report(
1202 "***PointToPointIntent Intents in SDN-IP are correct!***" )
1203 else:
1204 main.log.report(
1205 "***PointToPointIntent Intents in SDN-IP are wrong!***" )
1206
1207 allRoutesStrExpected = str( sorted( allRoutesExpected ) )
1208 routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
1209 pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
1210 # roundNum = 0;
1211 # while( True ):
1212 for roundNum in range( 1, 6 ):
1213 # round = round + 1;
1214 main.log.report( "The Round " + str( roundNum ) +
1215 " test starts................................" )
1216
1217 main.step( "Login all BGP peers and add routes into peers" )
1218 main.log.info( "Login Quagga CLI on host3" )
1219 main.QuaggaCliHost3.loginQuagga( "1.168.30.2" )
1220 main.log.info(
1221 "Enter configuration model of Quagga CLI on host3" )
1222 main.QuaggaCliHost3.enterConfig( 64514 )
1223 main.log.info( "Add routes to Quagga on host3" )
1224 main.QuaggaCliHost3.addRoutes( prefixesHost3, 1 )
1225
1226 main.log.info( "Login Quagga CLI on host4" )
1227 main.QuaggaCliHost4.loginQuagga( "1.168.30.3" )
1228 main.log.info(
1229 "Enter configuration model of Quagga CLI on host4" )
1230 main.QuaggaCliHost4.enterConfig( 64516 )
1231 main.log.info( "Add routes to Quagga on host4" )
1232 main.QuaggaCliHost4.addRoutes( prefixesHost4, 1 )
1233 time.sleep( 60 )
1234
1235 # get all routes inside SDN-IP
1236 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1237
1238 # parse routes from ONOS CLI
1239 allRoutesActual = \
1240 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1241
1242 # allRoutesStrExpected = str( sorted( allRoutesExpected ) )
1243 allRoutesStrActual = str( allRoutesActual ).replace( 'u', "" )
1244 main.step( "Check routes installed" )
1245 main.log.info( "Routes expected:" )
1246 main.log.info( allRoutesStrExpected )
1247 main.log.info( "Routes get from ONOS CLI:" )
1248 main.log.info( allRoutesStrActual )
1249 utilities.assertEquals(
1250 expect=allRoutesStrExpected, actual=allRoutesStrActual,
1251 onpass="***Routes in SDN-IP are correct!***",
1252 onfail="***Routes in SDN-IP are wrong!***" )
1253 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1254 main.log.report(
1255 "***Routes in SDN-IP after adding correct!***" )
1256 else:
1257 main.log.report(
1258 "***Routes in SDN-IP after adding wrong!***" )
1259
1260 time.sleep( 20 )
1261 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
1262
1263 main.step(
1264 "Check MultiPointToSinglePointIntent intents installed" )
1265 # routeIntentsExpected are generated when generating routes
1266 # get route intents from ONOS CLI
1267 routeIntentsActual = \
1268 main.QuaggaCliHost3.extractActualRouteIntents(
1269 getIntentsResult )
1270 # routeIntentsStrExpected = str( sorted( routeIntentsExpected ) )
1271 routeIntentsStrActual = str(
1272 routeIntentsActual ).replace( 'u', "" )
1273 main.log.info( "MultiPointToSinglePoint intents expected:" )
1274 main.log.info( routeIntentsStrExpected )
1275 main.log.info(
1276 "MultiPointToSinglePoint intents get from ONOS CLI:" )
1277 main.log.info( routeIntentsStrActual )
1278 utilities.assertEquals(
1279 expect=True,
1280 actual=eq( routeIntentsStrExpected, routeIntentsStrActual ),
1281 onpass="***MultiPointToSinglePoint Intents in SDN-IP are \
1282 correct!***",
1283 onfail="***MultiPointToSinglePoint Intents in SDN-IP are \
1284 wrong!***" )
1285
1286 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
1287 main.log.report(
1288 "***MultiPointToSinglePoint Intents after adding routes \
1289 correct!***" )
1290 else:
1291 main.log.report(
1292 "***MultiPointToSinglePoint Intents after adding routes \
1293 wrong!***" )
1294
1295 #============================= Ping Test ========================
1296 # wait until all MultiPointToSinglePoint
1297 time.sleep( 20 )
1298 # pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
1299 pingTestResultsFile = \
1300 "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" \
1301 + str( roundNum ) + "-ping-results-before-delete-routes-" \
1302 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
1303 pingTestResults = main.QuaggaCliHost.pingTest(
1304 "1.168.30.100", pingTestScript, pingTestResultsFile )
1305 main.log.info( pingTestResults )
1306 # ping test
1307
1308 #============================= Deleting Routes ==================
1309 main.step( "Check deleting routes installed" )
1310 main.log.info( "Delete routes to Quagga on host3" )
1311 main.QuaggaCliHost3.deleteRoutes( prefixesHost3, 1 )
1312 main.log.info( "Delete routes to Quagga on host4" )
1313 main.QuaggaCliHost4.deleteRoutes( prefixesHost4, 1 )
1314
1315 getRoutesResult = main.ONOScli.routes( jsonFormat=True )
1316 allRoutesActual = \
1317 main.QuaggaCliHost3.extractActualRoutes( getRoutesResult )
1318 main.log.info( "allRoutes_actual = " )
1319 main.log.info( allRoutesActual )
1320
1321 utilities.assertEquals(
1322 expect="[]", actual=str( allRoutesActual ),
1323 onpass="***Route number in SDN-IP is 0, correct!***",
1324 onfail="***Routes number in SDN-IP is not 0, wrong!***" )
1325
1326 if( eq( allRoutesStrExpected, allRoutesStrActual ) ):
1327 main.log.report(
1328 "***Routes in SDN-IP after deleting correct!***" )
1329 else:
1330 main.log.report(
1331 "***Routes in SDN-IP after deleting wrong!***" )
1332
1333 main.step( "Check intents after deleting routes" )
1334 getIntentsResult = main.ONOScli.intents( jsonFormat=True )
1335 routeIntentsActual = \
1336 main.QuaggaCliHost3.extractActualRouteIntents(
1337 getIntentsResult )
1338 main.log.info( "main.ONOScli.intents()= " )
1339 main.log.info( routeIntentsActual )
1340 utilities.assertEquals(
1341 expect="[]", actual=str( routeIntentsActual ),
1342 onpass=
1343 "***MultiPointToSinglePoint Intents number in SDN-IP \
1344 is 0, correct!***",
1345 onfail="***MultiPointToSinglePoint Intents number in SDN-IP \
1346 is 0, wrong!***" )
1347
1348 if( eq( routeIntentsStrExpected, routeIntentsStrActual ) ):
1349 main.log.report(
1350 "***MultiPointToSinglePoint Intents after deleting \
1351 routes correct!***" )
1352 else:
1353 main.log.report(
1354 "***MultiPointToSinglePoint Intents after deleting \
1355 routes wrong!***" )
1356
1357 time.sleep( 20 )
1358 # pingTestScript = "~/SDNIP/SdnIpIntentDemo/CASE1-ping-as2host.sh"
1359 pingTestResultsFile = \
1360 "~/SDNIP/SdnIpIntentDemo/log/CASE2-Round" \
1361 + str( roundNum ) + "-ping-results-after-delete-routes-" \
1362 + strftime( "%Y-%m-%d_%H:%M:%S", localtime() ) + ".txt"
1363 pingTestResults = main.QuaggaCliHost.pingTest(
1364 "1.168.30.100", pingTestScript, pingTestResultsFile )
1365 main.log.info( pingTestResults )
1366 time.sleep( 30 )
1367