blob: 571e457635c0ceaa797e63785f8cd192ddafbce3 [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"""
AntonySilvestera1080f22016-04-26 13:05:57 +053017class FUNCbgpls:
18
19 def __init__( self ):
20 self.default = ''
21
22 def CASE1( self, main ):
23 """
24 CASE1 is to compile ONOS and push it to the test machines
25
26 Startup sequence:
27 cell <name>
28 onos-verify-cell
29 NOTE: temporary - onos-remove-raft-logs
30 onos-uninstall
31 git pull
32 mvn clean install
33 onos-package
34 onos-install -f
35 onos-wait-for-start
36 start cli sessions
37 start BGPLS apps
38
39 """
AntonySilvestera1080f22016-04-26 13:05:57 +053040 import os
Pratik Parab3b2ab5a2017-02-14 13:15:14 -080041
AntonySilvestera1080f22016-04-26 13:05:57 +053042 main.log.info( "ONOS Single node start " +
43 "Scapy Tool - initialization" )
44 main.case( "Setting up test environment" )
45 main.caseExplanation = "Setup the test environment including " +\
46 "installing ONOS, start ONOS."
47
AntonySilvestera1080f22016-04-26 13:05:57 +053048 PULLCODE = False
49 if main.params[ 'GIT' ][ 'pull' ] == 'True':
50 PULLCODE = True
51 gitBranch = main.params[ 'GIT' ][ 'branch' ]
52 cellName = main.params[ 'ENV' ][ 'cellName' ]
53 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
Jon Hall46fdea12017-05-24 15:48:57 -070054 scapy_ip = os.getenv( main.params[ 'SCAPY' ][ 'HOSTNAMES' ] )
AntonySilvestera1080f22016-04-26 13:05:57 +053055
56 main.log.info( "Removing raft logs" )
57 main.ONOSbench.onosRemoveRaftLogs()
58
59 main.CLIs = []
60 main.nodes = []
Jon Hall46fdea12017-05-24 15:48:57 -070061 main.numCtrls = 1
AntonySilvestera1080f22016-04-26 13:05:57 +053062
63 for i in range( 1, main.numCtrls + 1 ):
64 try:
65 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
66 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
67 ipList.append( main.nodes[ -1 ].ip_address )
68 except AttributeError:
69 break
70
71 main.log.info( "Uninstalling ONOS" )
72 for node in main.nodes:
73 main.ONOSbench.onosUninstall( node.ip_address )
74
75 main.step( "Create cell file" )
76 cellAppString = main.params[ 'ENV' ][ 'cellApps' ]
77
78 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
79 scapy_ip,
80 cellAppString, ipList )
81
82 main.step( "Applying cell variable to environment" )
83 cellResult = main.ONOSbench.setCell( cellName )
84
85 verifyResult = main.ONOSbench.verifyCell()
86
87 # Make sure ONOS process is not running
88 main.log.info( "Killing any ONOS processes" )
89 killResults = main.TRUE
90 for node in main.nodes:
91 killed = main.ONOSbench.onosKill( node.ip_address )
92 killResults = killResults and killed
93
94 cleanInstallResult = main.TRUE
95 gitPullResult = main.FALSE
96 main.step( "Git checkout and pull" + gitBranch )
97 if PULLCODE:
98 main.ONOSbench.gitCheckout( gitBranch )
99 gitPullResult = main.ONOSbench.gitPull()
100 # values of 1 or 3 are good
101 utilities.assert_lesser( expect=0, actual=gitPullResult,
102 onpass="Git pull successful",
103 onfail="Git pull failed" )
104
105 #main.ONOSbench.getVersion( report=True )
106
107 main.step( "Using mvn clean install" )
108 cleanInstallResult = main.TRUE
109 if PULLCODE and gitPullResult == main.TRUE:
110 cleanInstallResult = main.ONOSbench.cleanInstall()
111 else:
112 main.log.warn( "Did not pull new code so skipping mvn" +
113 "clean install" )
114 utilities.assert_equals( expect=main.TRUE,
115 actual=cleanInstallResult,
116 onpass="MCI successful",
117 onfail="MCI failed" )
118
119 main.step( "Creating ONOS package" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700120 packageResult = main.ONOSbench.buckBuild()
AntonySilvestera1080f22016-04-26 13:05:57 +0530121 utilities.assert_equals( expect=main.TRUE,
122 actual=packageResult,
123 onpass="Successfully created ONOS package",
124 onfail="Failed to create ONOS package" )
125
126 main.step( "Installing ONOS package" )
127 onosInstallResult = main.ONOSbench.onosInstall(
alisonb1a26522016-11-22 17:27:17 -0800128 options="-f", node=main.nodes[ 0 ].ip_address )
AntonySilvestera1080f22016-04-26 13:05:57 +0530129 utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
130 onpass="ONOS install successful",
131 onfail="ONOS install failed" )
132
You Wangf5de25b2017-01-06 15:13:01 -0800133 main.step( "Set up ONOS secure SSH" )
134 secureSshResult = main.ONOSbench.onosSecureSSH( node=main.nodes[ 0 ].ip_address )
135 utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
136 onpass="Test step PASS",
137 onfail="Test step FAIL" )
138
AntonySilvestera1080f22016-04-26 13:05:57 +0530139 main.step( "Checking if ONOS is up yet" )
Jon Hall46fdea12017-05-24 15:48:57 -0700140 print main.nodes[ 0 ].ip_address
AntonySilvestera1080f22016-04-26 13:05:57 +0530141 for i in range( 2 ):
alisonb1a26522016-11-22 17:27:17 -0800142 onos1Isup = main.ONOSbench.isup( main.nodes[ 0 ].ip_address )
AntonySilvestera1080f22016-04-26 13:05:57 +0530143 if onos1Isup:
144 break
145 utilities.assert_equals( expect=main.TRUE, actual=onos1Isup,
146 onpass="ONOS startup successful",
147 onfail="ONOS startup failed" )
Chiyu Chengef109502016-11-21 15:51:38 -0800148
Jon Hall6509dbf2016-06-21 17:01:17 -0700149 main.step( "Starting ONOS CLI sessions" )
alisonb1a26522016-11-22 17:27:17 -0800150 print main.nodes[ 0 ].ip_address
151 cliResults = main.ONOScli1.startOnosCli( main.nodes[ 0 ].ip_address )
AntonySilvestera1080f22016-04-26 13:05:57 +0530152 utilities.assert_equals( expect=main.TRUE, actual=cliResults,
153 onpass="ONOS cli startup successful",
154 onfail="ONOS cli startup failed" )
155
156 main.step( "App Ids check" )
157 appCheck = main.ONOScli1.appToIDCheck()
158
Jon Hall46fdea12017-05-24 15:48:57 -0700159 if appCheck != main.TRUE:
alisonb1a26522016-11-22 17:27:17 -0800160 main.log.warn( main.CLIs[ 0 ].apps() )
161 main.log.warn( main.CLIs[ 0 ].appIDs() )
AntonySilvestera1080f22016-04-26 13:05:57 +0530162 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
Jon Hall46fdea12017-05-24 15:48:57 -0700163 onpass="App Ids seem to be correct",
164 onfail="Something is wrong with app Ids" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530165 if cliResults == main.FALSE:
166 main.log.error( "Failed to start ONOS,stopping test" )
167 main.cleanup()
168 main.exit()
169
AntonySilvestera1080f22016-04-26 13:05:57 +0530170 def CASE2( self, main ):
171 """
172 Discovery the topology using BGPLS
173 """
Jon Hall46fdea12017-05-24 15:48:57 -0700174 import os
175 import sys
AntonySilvestera1080f22016-04-26 13:05:57 +0530176 import re
177 import time
178
179 main.case( "Testcase 2 : Discovery the Network Topology using BGPLS" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800180 main.ONOScli1.log( "\"testcase2 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530181
182 try:
183 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
184 except ImportError:
185 main.log.exception( "Something wrong with import file or code error." )
186 main.log.info( "Import Error, please check!" )
187 main.cleanup()
188 main.exit()
189
190 bgplsConfig = BgpLs()
191 Ne_id = bgplsConfig.Constants()
192 app = bgplsConfig.apps()
193 main.CLIs = []
194 main.nodes = []
Jon Hall46fdea12017-05-24 15:48:57 -0700195 main.numCtrls = 1
AntonySilvestera1080f22016-04-26 13:05:57 +0530196
197 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
Jon Hall46fdea12017-05-24 15:48:57 -0700198 scapy_ip = os.getenv( main.params[ 'SCAPY' ][ 'HOSTNAMES' ] )
199 httpport = main.params[ 'HTTP' ][ 'port' ]
200 path = main.params[ 'HTTP' ][ 'path' ]
201 bgplsConfig.ipValue( ipList, scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530202
203 for i in range( 1, main.numCtrls + 1 ):
204 try:
205 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
206 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
207 ipList.append( main.nodes[ -1 ].ip_address )
208 except AttributeError:
209 break
210
211 main.step( "Apply cell to environment" )
212 bgplsConfig.Comments()
213
214 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800215 main.log.info( "Sending BGPLS information" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530216 bgplsConfig.Comments()
217
AntonySilvestera1080f22016-04-26 13:05:57 +0530218 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\
219 dependencies/Scapyfiles/Topo_discovery.py" )
220 bgplsConfig.Comments()
221 main.log.info( "Enable BGPlS plugin in ONOS" )
222 bgplsConfig.Comments()
223
Jon Hall46fdea12017-05-24 15:48:57 -0700224 cliResults = main.ONOScli1.startOnosCli( main.nodes[ 0 ].ip_address )
AntonySilvestera1080f22016-04-26 13:05:57 +0530225
226 main.step( "Getting connected to ONOS" )
227 utilities.assert_equals( expect=main.TRUE, actual=cliResults,
228 onpass="ONOS cli startup successful",
229 onfail="ONOS cli startup failed" )
Jon Hall46fdea12017-05-24 15:48:57 -0700230 installResults = main.ONOScli1.activateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530231
232 main.step( "Install onos-app-bgp" )
233 utilities.assert_equals( expect=main.TRUE, actual=installResults,
234 onpass="Install onos-app-bgp successful",
235 onfail="Install onos-app-bgp failed" )
236
237 bgpls_post = bgplsConfig.DictoJson()
238
239 bgplsConfig.Comments()
240 main.log.info( "BGPLS RestConf input" )
241 bgplsConfig.Comments()
242
Jon Hall46fdea12017-05-24 15:48:57 -0700243 print ( bgpls_post )
alisonb1a26522016-11-22 17:27:17 -0800244 main.ONOSrest.user_name = "onos"
245 main.ONOSrest.pwd = "rocks"
Jon Hall46fdea12017-05-24 15:48:57 -0700246 Poststatus, result = main.ONOSrest.send( '/network/configuration/', method="POST", data=bgpls_post )
AntonySilvestera1080f22016-04-26 13:05:57 +0530247 main.step( "Configure BGP through RESTCONF" )
248
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800249 utilities.assert_equals( expect='200',
250 actual=Poststatus,
251 onpass="Post Port Success",
252 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
AntonySilvestera1080f22016-04-26 13:05:57 +0530253
AntonySilvestera1080f22016-04-26 13:05:57 +0530254 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800255 main.step( "Check Network devices are Updated in ONOS " )
AntonySilvestera1080f22016-04-26 13:05:57 +0530256 bgplsConfig.Comments()
Jon Hall46fdea12017-05-24 15:48:57 -0700257 time.sleep( 15 )
AntonySilvestera1080f22016-04-26 13:05:57 +0530258 response = main.ONOScli1.devices()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800259 responseCheck = main.FALSE
260 if response:
261 responseCheck = main.TRUE
262 utilities.assert_equals( expect=main.TRUE,
263 actual=responseCheck,
264 onpass="Network Devices update in ONOS successful",
265 onfail="Network Devices update in ONOS failed" )
266
AntonySilvestera1080f22016-04-26 13:05:57 +0530267 main.step( "Check the nodes are discovered" )
Jon Hall46fdea12017-05-24 15:48:57 -0700268 if response.find( Ne_id[ 1 ][ 0 ] ) and response.find( Ne_id[ 1 ][ 1 ] ) and response.find( Ne_id[ 1 ][ 2 ] ) != -1:
AntonySilvestera1080f22016-04-26 13:05:57 +0530269 stepResult = main.TRUE
270 else:
271 stepResult = main.FALSE
272 utilities.assert_equals( expect=main.TRUE,
273 actual=stepResult,
Jon Hall46fdea12017-05-24 15:48:57 -0700274 onpass="Node " + str( Ne_id[ 1 ][ 0 ] ) + ( Ne_id[ 1 ][ 1 ] ) + ( Ne_id[ 1 ][ 2 ] ) + " sucess",
275 onfail="Node " + str( Ne_id[ 1 ][ 0 ] ) + ( Ne_id[ 1 ][ 1 ] ) + ( Ne_id[ 1 ][ 2 ] ) + " failed" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800276 main.ONOScli1.log( "\"testcase2 end\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530277
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800278 main.step( "Check for Errors or Exception in testcase2" )
279 startStr = "testcase2 start"
280 endStr = "testcase2 end"
Jon Hall46fdea12017-05-24 15:48:57 -0700281 errorLog = main.ONOSbench.logReport( main.nodes[ 0 ].ip_address,
282 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800283 startStr, endStr )
284 utilities.assert_equals( expect=0, actual=errorLog,
285 onpass="No Exception or Error occured in testcase2",
286 onfail="Exception or Error occured in testcase2" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530287 bgplsConfig.Comments()
288 main.log.info( "Kill Scapy process" )
289 bgplsConfig.Comments()
290
291 main.Scapy1.handle.sendline( "\x03" )
Jon Hall46fdea12017-05-24 15:48:57 -0700292 time.sleep( 90 ) # This Sleep time gives time for the socket to close.
AntonySilvestera1080f22016-04-26 13:05:57 +0530293
AntonySilvestera1080f22016-04-26 13:05:57 +0530294 def CASE3( self, main ):
295 """
296 Addition of new Node to existing topology
297 """
Jon Hall46fdea12017-05-24 15:48:57 -0700298 import os
299 import sys
AntonySilvestera1080f22016-04-26 13:05:57 +0530300 import re
301 import time
302
303 main.case( "Testcase 3: Addition of New Node to existing topology" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800304 main.ONOScli1.log( "\"testcase3 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530305 try:
306 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
307 except ImportError:
308 main.log.exception( "Something wrong with import file or code error." )
309 main.log.info( "Import Error, please check!" )
310 main.cleanup()
311 main.exit()
312
313 bgplsConfig = BgpLs()
314 Ne_id = bgplsConfig.Constants()
315 app = bgplsConfig.apps()
316 main.CLIs = []
317 main.nodes = []
Jon Hall46fdea12017-05-24 15:48:57 -0700318 main.numCtrls = 1
AntonySilvestera1080f22016-04-26 13:05:57 +0530319
320 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
Jon Hall46fdea12017-05-24 15:48:57 -0700321 scapy_ip = os.getenv( main.params[ 'SCAPY' ][ 'HOSTNAMES' ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530322 cellName = main.params[ 'ENV' ][ 'cellName' ]
Jon Hall46fdea12017-05-24 15:48:57 -0700323 cellAppString = main.params[ 'ENV' ][ 'cellApps' ]
324 httpport = main.params[ 'HTTP' ][ 'port' ]
325 path = main.params[ 'HTTP' ][ 'path' ]
AntonySilvestera1080f22016-04-26 13:05:57 +0530326
Jon Hall46fdea12017-05-24 15:48:57 -0700327 bgplsConfig.ipValue( ipList, scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530328
329 for i in range( 1, main.numCtrls + 1 ):
330 try:
331 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
332 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
333 ipList.append( main.nodes[ -1 ].ip_address )
334 except AttributeError:
335 break
336
337 bgplsConfig.Comments()
338 main.log.info( "Sending BGPLS Packet " )
339 bgplsConfig.Comments()
340
341 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\
342 dependencies/Scapyfiles/Update_Node.py" )
343 bgplsConfig.Comments()
344 main.log.info( "Enable BGPlS plugin in ONOS" )
345 bgplsConfig.Comments()
346
347 main.step( "UnInstall onos-app-bgp" )
Jon Hall46fdea12017-05-24 15:48:57 -0700348 installResults = main.ONOScli1.deactivateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530349 utilities.assert_equals( expect=main.TRUE, actual=installResults,
350 onpass="Uninstall onos-app-bgp successful",
351 onfail="Uninstall onos-app-bgp failed" )
352
Jon Hall46fdea12017-05-24 15:48:57 -0700353 installResults = main.ONOScli1.activateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530354 main.step( "Install onos-app-bgp" )
355 utilities.assert_equals( expect=main.TRUE, actual=installResults,
356 onpass="Install onos-app-bgp successful",
357 onfail="Install onos-app-bgp failed" )
358
AntonySilvestera1080f22016-04-26 13:05:57 +0530359 bgpls_post = bgplsConfig.DictoJson()
360
361 bgplsConfig.Comments()
362 main.log.info( "BGPLS RestConf input" )
363 bgplsConfig.Comments()
364
365 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800366 main.step( "Check Network devices are Updated in ONOS" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530367 bgplsConfig.Comments()
Jon Hall46fdea12017-05-24 15:48:57 -0700368 time.sleep( 120 )
AntonySilvestera1080f22016-04-26 13:05:57 +0530369 response = main.ONOScli1.devices()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800370 responseCheck = main.FALSE
371 if response:
372 responseCheck = main.TRUE
373 utilities.assert_equals( expect=main.TRUE,
374 actual=responseCheck,
375 onpass="Network Devices update in ONOS successful",
376 onfail="Network Devices update in ONOS failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530377 main.step( "Check Newly added Node is getting updated" )
378
Jon Hall46fdea12017-05-24 15:48:57 -0700379 if response.find( Ne_id[ 1 ][ 3 ] ) != -1:
AntonySilvestera1080f22016-04-26 13:05:57 +0530380 stepResult = main.TRUE
381 else:
382 stepResult = main.FALSE
383 utilities.assert_equals( expect=main.TRUE,
384 actual=stepResult,
AntonySilvester02652382016-07-13 16:44:45 +0530385 onpass="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update sucess",
386 onfail="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update failed" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800387 main.ONOScli1.log( "\"testcase3 end\"" )
388
389 main.step( "Check for Errors or Exception in testcase3" )
390 startStr = "testcase3 start"
391 endStr = "testcase3 end"
Jon Hall46fdea12017-05-24 15:48:57 -0700392 errorLog = main.ONOSbench.logReport( main.nodes[ 0 ].ip_address,
393 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800394 startStr, endStr )
395 utilities.assert_equals( expect=0, actual=errorLog,
396 onpass="No Exception or Error occured in testcase3",
397 onfail="Exception or Error occured in testcase3" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530398 bgplsConfig.Comments()
399 main.log.info( "Kill Scapy process" )
400 bgplsConfig.Comments()
401 main.Scapy1.handle.sendline( "\x03" )
Jon Hall46fdea12017-05-24 15:48:57 -0700402 time.sleep( 90 ) # This Sleep time gives time for the socket to close.
AntonySilvestera1080f22016-04-26 13:05:57 +0530403
AntonySilvestera1080f22016-04-26 13:05:57 +0530404 def CASE4( self, main ):
405 """
AntonySilvester02652382016-07-13 16:44:45 +0530406 Verification of Links in existing topology
AntonySilvestera1080f22016-04-26 13:05:57 +0530407 """
AntonySilvester02652382016-07-13 16:44:45 +0530408 import json
AntonySilvestera1080f22016-04-26 13:05:57 +0530409 import time
AntonySilvester02652382016-07-13 16:44:45 +0530410 import os
411 main.case( "Testcase 4: Verification of Links thats is discovered" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800412 main.ONOScli1.log( "\"testcase4 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530413 try:
414 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
415 except ImportError:
416 main.log.exception( "Something wrong with import file or code error." )
417 main.log.info( "Import Error, please check!" )
418 main.cleanup()
419 main.exit()
420
421 bgplsConfig = BgpLs()
AntonySilvestera1080f22016-04-26 13:05:57 +0530422 app = bgplsConfig.apps()
423 main.CLIs = []
424 main.nodes = []
Jon Hall46fdea12017-05-24 15:48:57 -0700425 main.numCtrls = 1
AntonySilvestera1080f22016-04-26 13:05:57 +0530426 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
Jon Hall46fdea12017-05-24 15:48:57 -0700427 scapy_ip = os.getenv( main.params[ 'SCAPY' ][ 'HOSTNAMES' ] )
428 bgplsConfig.ipValue( ipList, scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530429
AntonySilvestera1080f22016-04-26 13:05:57 +0530430 for i in range( 1, main.numCtrls + 1 ):
431 try:
432 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
433 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
434 ipList.append( main.nodes[ -1 ].ip_address )
435 except AttributeError:
436 break
437
AntonySilvestera1080f22016-04-26 13:05:57 +0530438 bgplsConfig.Comments()
AntonySilvester02652382016-07-13 16:44:45 +0530439 main.log.info( "Sending BGPLS Link information Packet " )
AntonySilvestera1080f22016-04-26 13:05:57 +0530440 bgplsConfig.Comments()
441
AntonySilvester02652382016-07-13 16:44:45 +0530442 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Link_Update_Node.py" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530443 bgplsConfig.Comments()
444 main.log.info( "Enable BGPlS plugin in ONOS" )
445 bgplsConfig.Comments()
446
AntonySilvester02652382016-07-13 16:44:45 +0530447 main.step( "UnInstall onos-app-bgp" )
448 installResults = main.ONOScli1.deactivateApp( app[ 0 ] )
449 utilities.assert_equals( expect=main.TRUE, actual=installResults,
450 onpass="Uninstall onos-app-bgp successful",
451 onfail="Uninstall onos-app-bgp failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530452
Jon Hall46fdea12017-05-24 15:48:57 -0700453 installResults = main.ONOScli1.activateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530454 main.step( "Install onos-app-bgp" )
455 utilities.assert_equals( expect=main.TRUE, actual=installResults,
456 onpass="Install onos-app-bgp successful",
457 onfail="Install onos-app-bgp failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530458 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800459 main.step( "Checking the Link Discovery Status" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530460 bgplsConfig.Comments()
AntonySilvester02652382016-07-13 16:44:45 +0530461 time.sleep( 120 ) # Time taken to discovery the links
462 response = main.ONOScli1.links()
463 linksResp = json.loads( response )
464 check_link = bgplsConfig.checkLinks( linksResp )
AntonySilvestera1080f22016-04-26 13:05:57 +0530465
Jon Hall46fdea12017-05-24 15:48:57 -0700466 if check_link:
AntonySilvester02652382016-07-13 16:44:45 +0530467 reply_Check_Link = main.TRUE
Jon Hall46fdea12017-05-24 15:48:57 -0700468 utilities.assert_equals( expect=main.TRUE, actual=reply_Check_Link,
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800469 onpass="Link Discovery Success.",
470 onfail="Link Discovery Failed." )
471 main.ONOScli1.log( "\"testcase4 end\"" )
472
473 main.step( "Check for Errors or Exception in testcase4 " )
474 startStr = "testcase4 start"
475 endStr = "testcase4 end"
Jon Hall46fdea12017-05-24 15:48:57 -0700476 errorLog = main.ONOSbench.logReport( main.nodes[ 0 ].ip_address,
477 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800478 startStr, endStr )
Jon Hall46fdea12017-05-24 15:48:57 -0700479 utilities.assert_equals( expect=0, actual=errorLog,
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800480 onpass="No Exception or Error occured in testcase4",
481 onfail="Exception or Error occured in testcase4" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530482 bgplsConfig.Comments()
483 main.log.info( "Kill Scapy process" )
484 bgplsConfig.Comments()
AntonySilvestera1080f22016-04-26 13:05:57 +0530485 main.Scapy1.handle.sendline( "\x03" )
AntonySilvester02652382016-07-13 16:44:45 +0530486 time.sleep( 90 )
AntonySilvestera1080f22016-04-26 13:05:57 +0530487
488 def CASE5( self, main ):
489 """
AntonySilvester02652382016-07-13 16:44:45 +0530490 Deletion of links
491 """
492 import json
493 import time
494 import os
495 main.case( "Testcase 5: Deletion of Link in existing topology" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800496
497 main.ONOScli1.log( "\"testcase5 start\"" )
AntonySilvester02652382016-07-13 16:44:45 +0530498 try:
499 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
500 except ImportError:
501 main.log.exception( "Something wrong with import file or code error." )
502 main.log.info( "Import Error, please check!" )
503 main.cleanup()
504 main.exit()
505
506 bgplsConfig = BgpLs()
507 app = bgplsConfig.apps()
508 main.CLIs = []
509 main.nodes = []
Jon Hall46fdea12017-05-24 15:48:57 -0700510 main.numCtrls = 1
AntonySilvester02652382016-07-13 16:44:45 +0530511 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
Jon Hall46fdea12017-05-24 15:48:57 -0700512 scapy_ip = os.getenv( main.params[ 'SCAPY' ][ 'HOSTNAMES' ] )
513 bgplsConfig.ipValue( ipList, scapy_ip )
AntonySilvester02652382016-07-13 16:44:45 +0530514
515 for i in range( 1, main.numCtrls + 1 ):
516 try:
517 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
518 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
519 ipList.append( main.nodes[ -1 ].ip_address )
520 except AttributeError:
521 break
522
523 bgplsConfig.Comments()
524 main.log.info( "Sending BGPLS Delete Link Packet " )
525 bgplsConfig.Comments()
526
527 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py" )
528 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800529 main.log.info( "Enable BGPlS plugin in ONOS " )
AntonySilvester02652382016-07-13 16:44:45 +0530530 bgplsConfig.Comments()
531
532 main.step( "UnInstall onos-app-bgp" )
533 installResults = main.ONOScli1.deactivateApp( app[ 0 ] )
534 utilities.assert_equals( expect=main.TRUE, actual=installResults,
535 onpass="Uninstall onos-app-bgp successful",
536 onfail="Uninstall onos-app-bgp failed" )
537
Jon Hall46fdea12017-05-24 15:48:57 -0700538 installResults = main.ONOScli1.activateApp( app[ 0 ] )
AntonySilvester02652382016-07-13 16:44:45 +0530539 main.step( "Install onos-app-bgp" )
540 utilities.assert_equals( expect=main.TRUE, actual=installResults,
541 onpass="Install onos-app-bgp successful",
542 onfail="Install onos-app-bgp failed" )
543 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800544 main.step( "Checking whether the links is deleted" )
AntonySilvester02652382016-07-13 16:44:45 +0530545 bgplsConfig.Comments()
546 time.sleep( 120 ) # Time taken to discovery the links
547 response = main.ONOScli1.links()
548 linksResp = json.loads( response )
549 check_link = bgplsConfig.checkLinks( linksResp )
Jon Hall46fdea12017-05-24 15:48:57 -0700550 if not check_link:
AntonySilvester02652382016-07-13 16:44:45 +0530551 reply_Check_Link = main.TRUE
Jon Hall46fdea12017-05-24 15:48:57 -0700552 utilities.assert_equals( expect=main.TRUE, actual=reply_Check_Link,
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800553 onpass="Link is Deleted Successfully.",
554 onfail="Link is Deletion Failed." )
555 main.ONOScli1.log( "\"testcase5 end\"" )
556
557 main.step( "Check for Errors or Exception in testcase5" )
558 startStr = "testcase5 start"
559 endStr = "testcase5 end"
Jon Hall46fdea12017-05-24 15:48:57 -0700560 errorLog = main.ONOSbench.logReport( main.nodes[ 0 ].ip_address,
561 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800562 startStr, endStr )
563 utilities.assert_equals( expect=0, actual=errorLog,
564 onpass="No Exception or Error occured in testcase5",
565 onfail="Exception or Error occured in testcase5" )
AntonySilvester02652382016-07-13 16:44:45 +0530566 bgplsConfig.Comments()
567 main.log.info( "Kill Scapy process" )
568 bgplsConfig.Comments()
569 main.Scapy1.handle.sendline( "\x03" )
570 time.sleep( 90 )
571
572 def CASE6( self, main ):
573 """
AntonySilvestera1080f22016-04-26 13:05:57 +0530574 Uninstalling the app
575 """
Jon Hall46fdea12017-05-24 15:48:57 -0700576 import os
577 import sys
AntonySilvestera1080f22016-04-26 13:05:57 +0530578 import re
579 import time
580
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800581 main.case( "TestCase 6: UnInstalling of app" )
582 main.ONOScli1.log( "\"testcase6 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530583 try:
584 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
585 except ImportError:
586 main.log.exception( "Something wrong with import file or code error." )
587 main.log.info( "Import Error, please check!" )
588 main.cleanup()
589 main.exit()
590
591 bgplsConfig = BgpLs()
592 app = bgplsConfig.apps()
593 main.CLIs = []
594 main.nodes = []
Jon Hall46fdea12017-05-24 15:48:57 -0700595 main.numCtrls = 1
AntonySilvestera1080f22016-04-26 13:05:57 +0530596
597 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
Jon Hall46fdea12017-05-24 15:48:57 -0700598 scapy_ip = os.getenv( main.params[ 'SCAPY' ][ 'HOSTNAMES' ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530599 cellName = main.params[ 'ENV' ][ 'cellName' ]
Jon Hall46fdea12017-05-24 15:48:57 -0700600 cellAppString = main.params[ 'ENV' ][ 'cellApps' ]
AntonySilvestera1080f22016-04-26 13:05:57 +0530601
602 bgplsConfig = BgpLs()
Jon Hall46fdea12017-05-24 15:48:57 -0700603 bgplsConfig.ipValue( ipList, scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530604 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
605 scapy_ip,
AntonySilvester02652382016-07-13 16:44:45 +0530606 cellAppString, ipList )
AntonySilvestera1080f22016-04-26 13:05:57 +0530607
608 for i in range( 1, main.numCtrls + 1 ):
609 try:
610 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
611 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
612 ipList.append( main.nodes[ -1 ].ip_address )
613 except AttributeError:
614 break
615
616 main.step( "Apply cell to environment" )
617 bgplsConfig.Comments()
618 cellResult = main.ONOSbench.setCell( cellName )
619
620 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800621 main.step( "Logging into ONOS CLI " )
AntonySilvestera1080f22016-04-26 13:05:57 +0530622 bgplsConfig.Comments()
623
Jon Hall46fdea12017-05-24 15:48:57 -0700624 cliResults = main.ONOScli1.startOnosCli( main.nodes[ 0 ].ip_address )
AntonySilvestera1080f22016-04-26 13:05:57 +0530625 utilities.assert_equals( expect=main.TRUE, actual=cliResults,
626 onpass="ONOS cli startup successful",
627 onfail="ONOS cli startup failed" )
628
629 bgplsConfig.Comments()
630 main.log.info( "Uninstall onos-app-bgp" )
631 bgplsConfig.Comments()
632 main.step( "UnInstall onos-app-bgp" )
Jon Hall46fdea12017-05-24 15:48:57 -0700633 installResults = main.ONOScli1.deactivateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530634 utilities.assert_equals( expect=main.TRUE, actual=installResults,
635 onpass="Uninstall onos-app-bgp successful",
636 onfail="Uninstall onos-app-bgp failed" )
637
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800638 main.ONOScli1.log( "\"testcase6 end\"" )
639 main.step( "Check for Errors or Exception in testcase6" )
640 startStr = "testcase6 start"
641 endStr = "testcase6 end"
Jon Hall46fdea12017-05-24 15:48:57 -0700642 errorLog = main.ONOSbench.logReport( main.nodes[ 0 ].ip_address,
643 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800644 startStr, endStr )
645 utilities.assert_equals( expect=0, actual=errorLog,
646 onpass="No Exception or Error occured in testcase6",
647 onfail="Exception or Error occured in testcase6" )
648
649 main.step( "Check for Errors or Exception End of the Script" )
Jon Hall46fdea12017-05-24 15:48:57 -0700650 errorLog = main.ONOSbench.logReport( main.nodes[ 0 ].ip_address,
651 [ "ERROR", "EXCEPT" ] )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800652 utilities.assert_equals( expect=0, actual=errorLog,
AntonySilvester02652382016-07-13 16:44:45 +0530653 onpass="No Exception or Error occured",
Chiyu Chengef109502016-11-21 15:51:38 -0800654 onfail="Exception or Error occured" )