blob: 9d049fc29821d2131f79ad05d6a6042b7de4835f [file] [log] [blame]
AntonySilvestera1080f22016-04-26 13:05:57 +05301"""
2**** Scripted by Antony Silvester - antony.silvester@huawei.com ******
3
4
5This Test check the bgp_ls functionality
6
7List of test cases:
8CASE1: Compile ONOS and push it to the test machines
9CASE2: Discovery the topology using BGPLS
10CASE3: Addition of new Node to existing topology
AntonySilvester02652382016-07-13 16:44:45 +053011CASE4: Verification of Links thats is discovered"
12CASE5: Deletion of Links
13Case6: Uninstalling the app
AntonySilvestera1080f22016-04-26 13:05:57 +053014
15
16"""
17
18
19class FUNCbgpls:
20
21 def __init__( self ):
22 self.default = ''
23
24 def CASE1( self, main ):
25 """
26 CASE1 is to compile ONOS and push it to the test machines
27
28 Startup sequence:
29 cell <name>
30 onos-verify-cell
31 NOTE: temporary - onos-remove-raft-logs
32 onos-uninstall
33 git pull
34 mvn clean install
35 onos-package
36 onos-install -f
37 onos-wait-for-start
38 start cli sessions
39 start BGPLS apps
40
41 """
42
43 import os
Pratik Parab3b2ab5a2017-02-14 13:15:14 -080044
AntonySilvestera1080f22016-04-26 13:05:57 +053045 main.log.info( "ONOS Single node start " +
46 "Scapy Tool - initialization" )
47 main.case( "Setting up test environment" )
48 main.caseExplanation = "Setup the test environment including " +\
49 "installing ONOS, start ONOS."
50
51
52 PULLCODE = False
53 if main.params[ 'GIT' ][ 'pull' ] == 'True':
54 PULLCODE = True
55 gitBranch = main.params[ 'GIT' ][ 'branch' ]
56 cellName = main.params[ 'ENV' ][ 'cellName' ]
57 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
58 scapy_ip = os.getenv(main.params ['SCAPY'] ['HOSTNAMES'] )
59
60 main.log.info( "Removing raft logs" )
61 main.ONOSbench.onosRemoveRaftLogs()
62
63 main.CLIs = []
64 main.nodes = []
65 main.numCtrls= 1
66
67 for i in range( 1, main.numCtrls + 1 ):
68 try:
69 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
70 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
71 ipList.append( main.nodes[ -1 ].ip_address )
72 except AttributeError:
73 break
74
75 main.log.info( "Uninstalling ONOS" )
76 for node in main.nodes:
77 main.ONOSbench.onosUninstall( node.ip_address )
78
79 main.step( "Create cell file" )
80 cellAppString = main.params[ 'ENV' ][ 'cellApps' ]
81
82 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
83 scapy_ip,
84 cellAppString, ipList )
85
86 main.step( "Applying cell variable to environment" )
87 cellResult = main.ONOSbench.setCell( cellName )
88
89 verifyResult = main.ONOSbench.verifyCell()
90
91 # Make sure ONOS process is not running
92 main.log.info( "Killing any ONOS processes" )
93 killResults = main.TRUE
94 for node in main.nodes:
95 killed = main.ONOSbench.onosKill( node.ip_address )
96 killResults = killResults and killed
97
98 cleanInstallResult = main.TRUE
99 gitPullResult = main.FALSE
100 main.step( "Git checkout and pull" + gitBranch )
101 if PULLCODE:
102 main.ONOSbench.gitCheckout( gitBranch )
103 gitPullResult = main.ONOSbench.gitPull()
104 # values of 1 or 3 are good
105 utilities.assert_lesser( expect=0, actual=gitPullResult,
106 onpass="Git pull successful",
107 onfail="Git pull failed" )
108
109 #main.ONOSbench.getVersion( report=True )
110
111 main.step( "Using mvn clean install" )
112 cleanInstallResult = main.TRUE
113 if PULLCODE and gitPullResult == main.TRUE:
114 cleanInstallResult = main.ONOSbench.cleanInstall()
115 else:
116 main.log.warn( "Did not pull new code so skipping mvn" +
117 "clean install" )
118 utilities.assert_equals( expect=main.TRUE,
119 actual=cleanInstallResult,
120 onpass="MCI successful",
121 onfail="MCI failed" )
122
123 main.step( "Creating ONOS package" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700124 packageResult = main.ONOSbench.buckBuild()
AntonySilvestera1080f22016-04-26 13:05:57 +0530125 utilities.assert_equals( expect=main.TRUE,
126 actual=packageResult,
127 onpass="Successfully created ONOS package",
128 onfail="Failed to create ONOS package" )
129
130 main.step( "Installing ONOS package" )
131 onosInstallResult = main.ONOSbench.onosInstall(
alisonb1a26522016-11-22 17:27:17 -0800132 options="-f", node=main.nodes[ 0 ].ip_address )
AntonySilvestera1080f22016-04-26 13:05:57 +0530133 utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
134 onpass="ONOS install successful",
135 onfail="ONOS install failed" )
136
You Wangf5de25b2017-01-06 15:13:01 -0800137 main.step( "Set up ONOS secure SSH" )
138 secureSshResult = main.ONOSbench.onosSecureSSH( node=main.nodes[ 0 ].ip_address )
139 utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
140 onpass="Test step PASS",
141 onfail="Test step FAIL" )
142
AntonySilvestera1080f22016-04-26 13:05:57 +0530143 main.step( "Checking if ONOS is up yet" )
144 print main.nodes[0].ip_address
145 for i in range( 2 ):
alisonb1a26522016-11-22 17:27:17 -0800146 onos1Isup = main.ONOSbench.isup( main.nodes[ 0 ].ip_address )
AntonySilvestera1080f22016-04-26 13:05:57 +0530147 if onos1Isup:
148 break
149 utilities.assert_equals( expect=main.TRUE, actual=onos1Isup,
150 onpass="ONOS startup successful",
151 onfail="ONOS startup failed" )
Chiyu Chengef109502016-11-21 15:51:38 -0800152
Jon Hall6509dbf2016-06-21 17:01:17 -0700153 main.step( "Starting ONOS CLI sessions" )
alisonb1a26522016-11-22 17:27:17 -0800154 print main.nodes[ 0 ].ip_address
155 cliResults = main.ONOScli1.startOnosCli( main.nodes[ 0 ].ip_address )
AntonySilvestera1080f22016-04-26 13:05:57 +0530156 utilities.assert_equals( expect=main.TRUE, actual=cliResults,
157 onpass="ONOS cli startup successful",
158 onfail="ONOS cli startup failed" )
159
160 main.step( "App Ids check" )
161 appCheck = main.ONOScli1.appToIDCheck()
162
163 if appCheck !=main.TRUE:
alisonb1a26522016-11-22 17:27:17 -0800164 main.log.warn( main.CLIs[ 0 ].apps() )
165 main.log.warn( main.CLIs[ 0 ].appIDs() )
AntonySilvestera1080f22016-04-26 13:05:57 +0530166 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
167 onpass="App Ids seem to be correct",
168 onfail="Something is wrong with app Ids" )
169 if cliResults == main.FALSE:
170 main.log.error( "Failed to start ONOS,stopping test" )
171 main.cleanup()
172 main.exit()
173
AntonySilvestera1080f22016-04-26 13:05:57 +0530174 def CASE2( self, main ):
175 """
176 Discovery the topology using BGPLS
177 """
178 import os , sys
179 import re
180 import time
181
182 main.case( "Testcase 2 : Discovery the Network Topology using BGPLS" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800183 main.ONOScli1.log( "\"testcase2 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530184
185 try:
186 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
187 except ImportError:
188 main.log.exception( "Something wrong with import file or code error." )
189 main.log.info( "Import Error, please check!" )
190 main.cleanup()
191 main.exit()
192
193 bgplsConfig = BgpLs()
194 Ne_id = bgplsConfig.Constants()
195 app = bgplsConfig.apps()
196 main.CLIs = []
197 main.nodes = []
198 main.numCtrls= 1
199
200
201 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
202 scapy_ip = os.getenv(main.params ['SCAPY'] ['HOSTNAMES'] )
203 httpport = main.params['HTTP']['port']
204 path = main.params['HTTP']['path']
205 bgplsConfig.ipValue(ipList,scapy_ip)
206
207 for i in range( 1, main.numCtrls + 1 ):
208 try:
209 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
210 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
211 ipList.append( main.nodes[ -1 ].ip_address )
212 except AttributeError:
213 break
214
215 main.step( "Apply cell to environment" )
216 bgplsConfig.Comments()
217
218 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800219 main.log.info( "Sending BGPLS information" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530220 bgplsConfig.Comments()
221
222
223 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\
224 dependencies/Scapyfiles/Topo_discovery.py" )
225 bgplsConfig.Comments()
226 main.log.info( "Enable BGPlS plugin in ONOS" )
227 bgplsConfig.Comments()
228
229
230 cliResults = main.ONOScli1.startOnosCli( main.nodes[0].ip_address)
231
232 main.step( "Getting connected to ONOS" )
233 utilities.assert_equals( expect=main.TRUE, actual=cliResults,
234 onpass="ONOS cli startup successful",
235 onfail="ONOS cli startup failed" )
236 installResults = main.ONOScli1.activateApp( app[0])
237
238 main.step( "Install onos-app-bgp" )
239 utilities.assert_equals( expect=main.TRUE, actual=installResults,
240 onpass="Install onos-app-bgp successful",
241 onfail="Install onos-app-bgp failed" )
242
243 bgpls_post = bgplsConfig.DictoJson()
244
245 bgplsConfig.Comments()
246 main.log.info( "BGPLS RestConf input" )
247 bgplsConfig.Comments()
248
249 print (bgpls_post)
alisonb1a26522016-11-22 17:27:17 -0800250 main.ONOSrest.user_name = "onos"
251 main.ONOSrest.pwd = "rocks"
Jon Hall1f5e65f2016-06-15 10:06:05 -0700252 Poststatus, result = main.ONOSrest.send( '/network/configuration/', method="POST", data=bgpls_post)
AntonySilvestera1080f22016-04-26 13:05:57 +0530253 main.step( "Configure BGP through RESTCONF" )
254
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800255 utilities.assert_equals( expect='200',
256 actual=Poststatus,
257 onpass="Post Port Success",
258 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
AntonySilvestera1080f22016-04-26 13:05:57 +0530259
260
261 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800262 main.step( "Check Network devices are Updated in ONOS " )
AntonySilvestera1080f22016-04-26 13:05:57 +0530263 bgplsConfig.Comments()
264 time.sleep(15)
AntonySilvestera1080f22016-04-26 13:05:57 +0530265 response = main.ONOScli1.devices()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800266 responseCheck = main.FALSE
267 if response:
268 responseCheck = main.TRUE
269 utilities.assert_equals( expect=main.TRUE,
270 actual=responseCheck,
271 onpass="Network Devices update in ONOS successful",
272 onfail="Network Devices update in ONOS failed" )
273
AntonySilvestera1080f22016-04-26 13:05:57 +0530274 main.step( "Check the nodes are discovered" )
275 if response.find( Ne_id[1][0]) and response.find(Ne_id[1][1]) and response.find(Ne_id[1][2]) != -1:
276 stepResult = main.TRUE
277 else:
278 stepResult = main.FALSE
279 utilities.assert_equals( expect=main.TRUE,
280 actual=stepResult,
281 onpass="Node " + str( Ne_id[1][0]) + ( Ne_id[1][1]) + ( Ne_id[1][2]) + " sucess",
282 onfail="Node " + str( Ne_id[1][0]) + ( Ne_id[1][1]) + ( Ne_id[1][2]) + " failed" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800283 main.ONOScli1.log( "\"testcase2 end\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530284
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800285 main.step( "Check for Errors or Exception in testcase2" )
286 startStr = "testcase2 start"
287 endStr = "testcase2 end"
288 errorLog = main.ONOSbench.logReport( main.nodes[0].ip_address,
289 ["ERROR","EXCEPT"], "s",
290 startStr, endStr )
291 utilities.assert_equals( expect=0, actual=errorLog,
292 onpass="No Exception or Error occured in testcase2",
293 onfail="Exception or Error occured in testcase2" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530294 bgplsConfig.Comments()
295 main.log.info( "Kill Scapy process" )
296 bgplsConfig.Comments()
297
298 main.Scapy1.handle.sendline( "\x03" )
AntonySilvester02652382016-07-13 16:44:45 +0530299 time.sleep( 90 ) #This Sleep time gives time for the socket to close.
AntonySilvestera1080f22016-04-26 13:05:57 +0530300
AntonySilvestera1080f22016-04-26 13:05:57 +0530301 def CASE3( self, main ):
302 """
303 Addition of new Node to existing topology
304 """
305 import os , sys
306 import re
307 import time
308
309 main.case( "Testcase 3: Addition of New Node to existing topology" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800310 main.ONOScli1.log( "\"testcase3 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530311 try:
312 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
313 except ImportError:
314 main.log.exception( "Something wrong with import file or code error." )
315 main.log.info( "Import Error, please check!" )
316 main.cleanup()
317 main.exit()
318
319 bgplsConfig = BgpLs()
320 Ne_id = bgplsConfig.Constants()
321 app = bgplsConfig.apps()
322 main.CLIs = []
323 main.nodes = []
324 main.numCtrls= 1
325
326
327 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
328 scapy_ip = os.getenv( main.params ['SCAPY'] ['HOSTNAMES'] )
329 cellName = main.params[ 'ENV' ][ 'cellName' ]
330 cellAppString= main.params[ 'ENV' ][ 'cellApps' ]
331 httpport = main.params['HTTP']['port']
332 path = main.params['HTTP']['path']
333
334 bgplsConfig.ipValue(ipList,scapy_ip)
335
336 for i in range( 1, main.numCtrls + 1 ):
337 try:
338 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
339 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
340 ipList.append( main.nodes[ -1 ].ip_address )
341 except AttributeError:
342 break
343
344 bgplsConfig.Comments()
345 main.log.info( "Sending BGPLS Packet " )
346 bgplsConfig.Comments()
347
348 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\
349 dependencies/Scapyfiles/Update_Node.py" )
350 bgplsConfig.Comments()
351 main.log.info( "Enable BGPlS plugin in ONOS" )
352 bgplsConfig.Comments()
353
354 main.step( "UnInstall onos-app-bgp" )
355 installResults = main.ONOScli1.deactivateApp( app[0] )
356 utilities.assert_equals( expect=main.TRUE, actual=installResults,
357 onpass="Uninstall onos-app-bgp successful",
358 onfail="Uninstall onos-app-bgp failed" )
359
360 installResults = main.ONOScli1.activateApp( app[0])
361 main.step( "Install onos-app-bgp" )
362 utilities.assert_equals( expect=main.TRUE, actual=installResults,
363 onpass="Install onos-app-bgp successful",
364 onfail="Install onos-app-bgp failed" )
365
366
367 bgpls_post = bgplsConfig.DictoJson()
368
369 bgplsConfig.Comments()
370 main.log.info( "BGPLS RestConf input" )
371 bgplsConfig.Comments()
372
373 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800374 main.step( "Check Network devices are Updated in ONOS" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530375 bgplsConfig.Comments()
376 time.sleep(120)
AntonySilvestera1080f22016-04-26 13:05:57 +0530377 response = main.ONOScli1.devices()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800378 responseCheck = main.FALSE
379 if response:
380 responseCheck = main.TRUE
381 utilities.assert_equals( expect=main.TRUE,
382 actual=responseCheck,
383 onpass="Network Devices update in ONOS successful",
384 onfail="Network Devices update in ONOS failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530385 main.step( "Check Newly added Node is getting updated" )
386
387 if response.find( Ne_id[1][3]) != -1:
388 stepResult = main.TRUE
389 else:
390 stepResult = main.FALSE
391 utilities.assert_equals( expect=main.TRUE,
392 actual=stepResult,
AntonySilvester02652382016-07-13 16:44:45 +0530393 onpass="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update sucess",
394 onfail="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update failed" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800395 main.ONOScli1.log( "\"testcase3 end\"" )
396
397 main.step( "Check for Errors or Exception in testcase3" )
398 startStr = "testcase3 start"
399 endStr = "testcase3 end"
400 errorLog = main.ONOSbench.logReport( main.nodes[0].ip_address,
401 ["ERROR","EXCEPT"], "s",
402 startStr, endStr )
403 utilities.assert_equals( expect=0, actual=errorLog,
404 onpass="No Exception or Error occured in testcase3",
405 onfail="Exception or Error occured in testcase3" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530406 bgplsConfig.Comments()
407 main.log.info( "Kill Scapy process" )
408 bgplsConfig.Comments()
409 main.Scapy1.handle.sendline( "\x03" )
AntonySilvester02652382016-07-13 16:44:45 +0530410 time.sleep( 90 ) #This Sleep time gives time for the socket to close.
AntonySilvestera1080f22016-04-26 13:05:57 +0530411
AntonySilvestera1080f22016-04-26 13:05:57 +0530412 def CASE4( self, main ):
413 """
AntonySilvester02652382016-07-13 16:44:45 +0530414 Verification of Links in existing topology
AntonySilvestera1080f22016-04-26 13:05:57 +0530415 """
AntonySilvester02652382016-07-13 16:44:45 +0530416 import json
AntonySilvestera1080f22016-04-26 13:05:57 +0530417 import time
AntonySilvester02652382016-07-13 16:44:45 +0530418 import os
419 main.case( "Testcase 4: Verification of Links thats is discovered" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800420 main.ONOScli1.log( "\"testcase4 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530421 try:
422 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
423 except ImportError:
424 main.log.exception( "Something wrong with import file or code error." )
425 main.log.info( "Import Error, please check!" )
426 main.cleanup()
427 main.exit()
428
429 bgplsConfig = BgpLs()
AntonySilvestera1080f22016-04-26 13:05:57 +0530430 app = bgplsConfig.apps()
431 main.CLIs = []
432 main.nodes = []
433 main.numCtrls= 1
AntonySilvestera1080f22016-04-26 13:05:57 +0530434 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
435 scapy_ip = os.getenv(main.params ['SCAPY'] ['HOSTNAMES'] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530436 bgplsConfig.ipValue(ipList,scapy_ip)
437
AntonySilvestera1080f22016-04-26 13:05:57 +0530438 for i in range( 1, main.numCtrls + 1 ):
439 try:
440 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
441 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
442 ipList.append( main.nodes[ -1 ].ip_address )
443 except AttributeError:
444 break
445
AntonySilvestera1080f22016-04-26 13:05:57 +0530446 bgplsConfig.Comments()
AntonySilvester02652382016-07-13 16:44:45 +0530447 main.log.info( "Sending BGPLS Link information Packet " )
AntonySilvestera1080f22016-04-26 13:05:57 +0530448 bgplsConfig.Comments()
449
AntonySilvester02652382016-07-13 16:44:45 +0530450 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Link_Update_Node.py" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530451 bgplsConfig.Comments()
452 main.log.info( "Enable BGPlS plugin in ONOS" )
453 bgplsConfig.Comments()
454
AntonySilvester02652382016-07-13 16:44:45 +0530455 main.step( "UnInstall onos-app-bgp" )
456 installResults = main.ONOScli1.deactivateApp( app[ 0 ] )
457 utilities.assert_equals( expect=main.TRUE, actual=installResults,
458 onpass="Uninstall onos-app-bgp successful",
459 onfail="Uninstall onos-app-bgp failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530460
AntonySilvester02652382016-07-13 16:44:45 +0530461 installResults = main.ONOScli1.activateApp( app[ 0 ])
AntonySilvestera1080f22016-04-26 13:05:57 +0530462 main.step( "Install onos-app-bgp" )
463 utilities.assert_equals( expect=main.TRUE, actual=installResults,
464 onpass="Install onos-app-bgp successful",
465 onfail="Install onos-app-bgp failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530466 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800467 main.step( "Checking the Link Discovery Status" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530468 bgplsConfig.Comments()
AntonySilvester02652382016-07-13 16:44:45 +0530469 time.sleep( 120 ) # Time taken to discovery the links
470 response = main.ONOScli1.links()
471 linksResp = json.loads( response )
472 check_link = bgplsConfig.checkLinks( linksResp )
AntonySilvestera1080f22016-04-26 13:05:57 +0530473
AntonySilvester02652382016-07-13 16:44:45 +0530474 if check_link == True:
475 reply_Check_Link = main.TRUE
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800476 utilities.assert_equals( expect= main.TRUE, actual=reply_Check_Link,
477 onpass="Link Discovery Success.",
478 onfail="Link Discovery Failed." )
479 main.ONOScli1.log( "\"testcase4 end\"" )
480
481 main.step( "Check for Errors or Exception in testcase4 " )
482 startStr = "testcase4 start"
483 endStr = "testcase4 end"
484 errorLog = main.ONOSbench.logReport( main.nodes[0].ip_address,
485 ["ERROR","EXCEPT"], "s",
486 startStr, endStr )
487 utilities.assert_equals( expect= 0, actual=errorLog,
488 onpass="No Exception or Error occured in testcase4",
489 onfail="Exception or Error occured in testcase4" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530490 bgplsConfig.Comments()
491 main.log.info( "Kill Scapy process" )
492 bgplsConfig.Comments()
AntonySilvestera1080f22016-04-26 13:05:57 +0530493 main.Scapy1.handle.sendline( "\x03" )
AntonySilvester02652382016-07-13 16:44:45 +0530494 time.sleep( 90 )
AntonySilvestera1080f22016-04-26 13:05:57 +0530495
496 def CASE5( self, main ):
497 """
AntonySilvester02652382016-07-13 16:44:45 +0530498 Deletion of links
499 """
500 import json
501 import time
502 import os
503 main.case( "Testcase 5: Deletion of Link in existing topology" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800504
505 main.ONOScli1.log( "\"testcase5 start\"" )
AntonySilvester02652382016-07-13 16:44:45 +0530506 try:
507 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
508 except ImportError:
509 main.log.exception( "Something wrong with import file or code error." )
510 main.log.info( "Import Error, please check!" )
511 main.cleanup()
512 main.exit()
513
514 bgplsConfig = BgpLs()
515 app = bgplsConfig.apps()
516 main.CLIs = []
517 main.nodes = []
518 main.numCtrls= 1
519 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
520 scapy_ip = os.getenv(main.params [ 'SCAPY' ] [ 'HOSTNAMES' ] )
521 bgplsConfig.ipValue(ipList,scapy_ip)
522
523 for i in range( 1, main.numCtrls + 1 ):
524 try:
525 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
526 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
527 ipList.append( main.nodes[ -1 ].ip_address )
528 except AttributeError:
529 break
530
531 bgplsConfig.Comments()
532 main.log.info( "Sending BGPLS Delete Link Packet " )
533 bgplsConfig.Comments()
534
535 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py" )
536 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800537 main.log.info( "Enable BGPlS plugin in ONOS " )
AntonySilvester02652382016-07-13 16:44:45 +0530538 bgplsConfig.Comments()
539
540 main.step( "UnInstall onos-app-bgp" )
541 installResults = main.ONOScli1.deactivateApp( app[ 0 ] )
542 utilities.assert_equals( expect=main.TRUE, actual=installResults,
543 onpass="Uninstall onos-app-bgp successful",
544 onfail="Uninstall onos-app-bgp failed" )
545
546 installResults = main.ONOScli1.activateApp( app[ 0 ])
547 main.step( "Install onos-app-bgp" )
548 utilities.assert_equals( expect=main.TRUE, actual=installResults,
549 onpass="Install onos-app-bgp successful",
550 onfail="Install onos-app-bgp failed" )
551 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800552 main.step( "Checking whether the links is deleted" )
AntonySilvester02652382016-07-13 16:44:45 +0530553 bgplsConfig.Comments()
554 time.sleep( 120 ) # Time taken to discovery the links
555 response = main.ONOScli1.links()
556 linksResp = json.loads( response )
557 check_link = bgplsConfig.checkLinks( linksResp )
558 if check_link == False:
559 reply_Check_Link = main.TRUE
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800560 utilities.assert_equals( expect= main.TRUE, actual=reply_Check_Link,
561 onpass="Link is Deleted Successfully.",
562 onfail="Link is Deletion Failed." )
563 main.ONOScli1.log( "\"testcase5 end\"" )
564
565 main.step( "Check for Errors or Exception in testcase5" )
566 startStr = "testcase5 start"
567 endStr = "testcase5 end"
568 errorLog = main.ONOSbench.logReport( main.nodes[0].ip_address,
569 ["ERROR","EXCEPT"], "s",
570 startStr, endStr )
571 utilities.assert_equals( expect=0, actual=errorLog,
572 onpass="No Exception or Error occured in testcase5",
573 onfail="Exception or Error occured in testcase5" )
AntonySilvester02652382016-07-13 16:44:45 +0530574 bgplsConfig.Comments()
575 main.log.info( "Kill Scapy process" )
576 bgplsConfig.Comments()
577 main.Scapy1.handle.sendline( "\x03" )
578 time.sleep( 90 )
579
580 def CASE6( self, main ):
581 """
AntonySilvestera1080f22016-04-26 13:05:57 +0530582 Uninstalling the app
583 """
584 import os,sys
585 import re
586 import time
587
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800588 main.case( "TestCase 6: UnInstalling of app" )
589 main.ONOScli1.log( "\"testcase6 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530590 try:
591 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
592 except ImportError:
593 main.log.exception( "Something wrong with import file or code error." )
594 main.log.info( "Import Error, please check!" )
595 main.cleanup()
596 main.exit()
597
598 bgplsConfig = BgpLs()
599 app = bgplsConfig.apps()
600 main.CLIs = []
601 main.nodes = []
602 main.numCtrls= 1
603
604
605 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
606 scapy_ip = os.getenv(main.params ['SCAPY'] ['HOSTNAMES'] )
607 cellName = main.params[ 'ENV' ][ 'cellName' ]
608 cellAppString= main.params[ 'ENV' ][ 'cellApps' ]
609
610 bgplsConfig = BgpLs()
611 bgplsConfig.ipValue(ipList,scapy_ip)
612 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
613 scapy_ip,
AntonySilvester02652382016-07-13 16:44:45 +0530614 cellAppString, ipList )
AntonySilvestera1080f22016-04-26 13:05:57 +0530615
616 for i in range( 1, main.numCtrls + 1 ):
617 try:
618 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
619 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
620 ipList.append( main.nodes[ -1 ].ip_address )
621 except AttributeError:
622 break
623
624 main.step( "Apply cell to environment" )
625 bgplsConfig.Comments()
626 cellResult = main.ONOSbench.setCell( cellName )
627
628 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800629 main.step( "Logging into ONOS CLI " )
AntonySilvestera1080f22016-04-26 13:05:57 +0530630 bgplsConfig.Comments()
631
632 cliResults = main.ONOScli1.startOnosCli( main.nodes[0].ip_address )
633 utilities.assert_equals( expect=main.TRUE, actual=cliResults,
634 onpass="ONOS cli startup successful",
635 onfail="ONOS cli startup failed" )
636
637 bgplsConfig.Comments()
638 main.log.info( "Uninstall onos-app-bgp" )
639 bgplsConfig.Comments()
640 main.step( "UnInstall onos-app-bgp" )
641 installResults = main.ONOScli1.deactivateApp( app[0] )
642 utilities.assert_equals( expect=main.TRUE, actual=installResults,
643 onpass="Uninstall onos-app-bgp successful",
644 onfail="Uninstall onos-app-bgp failed" )
645
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800646 main.ONOScli1.log( "\"testcase6 end\"" )
647 main.step( "Check for Errors or Exception in testcase6" )
648 startStr = "testcase6 start"
649 endStr = "testcase6 end"
650 errorLog = main.ONOSbench.logReport( main.nodes[0].ip_address,
651 ["ERROR","EXCEPT"], "s",
652 startStr, endStr )
653 utilities.assert_equals( expect=0, actual=errorLog,
654 onpass="No Exception or Error occured in testcase6",
655 onfail="Exception or Error occured in testcase6" )
656
657 main.step( "Check for Errors or Exception End of the Script" )
658 errorLog = main.ONOSbench.logReport( main.nodes[0].ip_address,
659 ["ERROR","EXCEPT"] )
660 utilities.assert_equals( expect=0, actual=errorLog,
AntonySilvester02652382016-07-13 16:44:45 +0530661 onpass="No Exception or Error occured",
Chiyu Chengef109502016-11-21 15:51:38 -0800662 onfail="Exception or Error occured" )