blob: 81be490293f08cca1d2f1d92a3ae317086d43c5d [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
AntonySilvestera1080f22016-04-26 13:05:57 +053032 onos-package
33 onos-install -f
34 onos-wait-for-start
35 start cli sessions
36 start BGPLS apps
37
38 """
AntonySilvestera1080f22016-04-26 13:05:57 +053039 import os
Pratik Parab3b2ab5a2017-02-14 13:15:14 -080040
AntonySilvestera1080f22016-04-26 13:05:57 +053041 main.log.info( "ONOS Single node start " +
42 "Scapy Tool - initialization" )
43 main.case( "Setting up test environment" )
44 main.caseExplanation = "Setup the test environment including " +\
45 "installing ONOS, start ONOS."
46
AntonySilvestera1080f22016-04-26 13:05:57 +053047 PULLCODE = False
48 if main.params[ 'GIT' ][ 'pull' ] == 'True':
49 PULLCODE = True
50 gitBranch = main.params[ 'GIT' ][ 'branch' ]
51 cellName = main.params[ 'ENV' ][ 'cellName' ]
52 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
Jon Hall46fdea12017-05-24 15:48:57 -070053 scapy_ip = os.getenv( main.params[ 'SCAPY' ][ 'HOSTNAMES' ] )
AntonySilvestera1080f22016-04-26 13:05:57 +053054
55 main.log.info( "Removing raft logs" )
56 main.ONOSbench.onosRemoveRaftLogs()
57
58 main.CLIs = []
59 main.nodes = []
Jon Hall46fdea12017-05-24 15:48:57 -070060 main.numCtrls = 1
AntonySilvestera1080f22016-04-26 13:05:57 +053061
62 for i in range( 1, main.numCtrls + 1 ):
63 try:
64 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
65 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
66 ipList.append( main.nodes[ -1 ].ip_address )
67 except AttributeError:
68 break
69
70 main.log.info( "Uninstalling ONOS" )
71 for node in main.nodes:
72 main.ONOSbench.onosUninstall( node.ip_address )
73
74 main.step( "Create cell file" )
75 cellAppString = main.params[ 'ENV' ][ 'cellApps' ]
76
77 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
78 scapy_ip,
Devin Limdc78e202017-06-09 18:30:07 -070079 cellAppString, ipList, main.ONOScli1.karafUser )
AntonySilvestera1080f22016-04-26 13:05:57 +053080
81 main.step( "Applying cell variable to environment" )
82 cellResult = main.ONOSbench.setCell( cellName )
83
84 verifyResult = main.ONOSbench.verifyCell()
85
86 # Make sure ONOS process is not running
87 main.log.info( "Killing any ONOS processes" )
88 killResults = main.TRUE
89 for node in main.nodes:
90 killed = main.ONOSbench.onosKill( node.ip_address )
91 killResults = killResults and killed
92
AntonySilvestera1080f22016-04-26 13:05:57 +053093 gitPullResult = main.FALSE
94 main.step( "Git checkout and pull" + gitBranch )
95 if PULLCODE:
96 main.ONOSbench.gitCheckout( gitBranch )
97 gitPullResult = main.ONOSbench.gitPull()
98 # values of 1 or 3 are good
99 utilities.assert_lesser( expect=0, actual=gitPullResult,
100 onpass="Git pull successful",
101 onfail="Git pull failed" )
102
Devin Lim8d7c7782017-06-07 16:21:20 -0700103 main.ONOSbench.getVersion( report=True )
AntonySilvestera1080f22016-04-26 13:05:57 +0530104
105 main.step( "Creating ONOS package" )
Jon Hallbd60ea02016-08-23 10:03:59 -0700106 packageResult = main.ONOSbench.buckBuild()
AntonySilvestera1080f22016-04-26 13:05:57 +0530107 utilities.assert_equals( expect=main.TRUE,
108 actual=packageResult,
109 onpass="Successfully created ONOS package",
110 onfail="Failed to create ONOS package" )
111
112 main.step( "Installing ONOS package" )
113 onosInstallResult = main.ONOSbench.onosInstall(
alisonb1a26522016-11-22 17:27:17 -0800114 options="-f", node=main.nodes[ 0 ].ip_address )
AntonySilvestera1080f22016-04-26 13:05:57 +0530115 utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
116 onpass="ONOS install successful",
117 onfail="ONOS install failed" )
118
You Wangf5de25b2017-01-06 15:13:01 -0800119 main.step( "Set up ONOS secure SSH" )
120 secureSshResult = main.ONOSbench.onosSecureSSH( node=main.nodes[ 0 ].ip_address )
121 utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
122 onpass="Test step PASS",
123 onfail="Test step FAIL" )
124
AntonySilvestera1080f22016-04-26 13:05:57 +0530125 main.step( "Checking if ONOS is up yet" )
Jon Hall46fdea12017-05-24 15:48:57 -0700126 print main.nodes[ 0 ].ip_address
AntonySilvestera1080f22016-04-26 13:05:57 +0530127 for i in range( 2 ):
alisonb1a26522016-11-22 17:27:17 -0800128 onos1Isup = main.ONOSbench.isup( main.nodes[ 0 ].ip_address )
AntonySilvestera1080f22016-04-26 13:05:57 +0530129 if onos1Isup:
130 break
131 utilities.assert_equals( expect=main.TRUE, actual=onos1Isup,
132 onpass="ONOS startup successful",
133 onfail="ONOS startup failed" )
Chiyu Chengef109502016-11-21 15:51:38 -0800134
Jon Hall6509dbf2016-06-21 17:01:17 -0700135 main.step( "Starting ONOS CLI sessions" )
alisonb1a26522016-11-22 17:27:17 -0800136 print main.nodes[ 0 ].ip_address
137 cliResults = main.ONOScli1.startOnosCli( main.nodes[ 0 ].ip_address )
AntonySilvestera1080f22016-04-26 13:05:57 +0530138 utilities.assert_equals( expect=main.TRUE, actual=cliResults,
139 onpass="ONOS cli startup successful",
140 onfail="ONOS cli startup failed" )
141
142 main.step( "App Ids check" )
143 appCheck = main.ONOScli1.appToIDCheck()
144
Jon Hall46fdea12017-05-24 15:48:57 -0700145 if appCheck != main.TRUE:
alisonb1a26522016-11-22 17:27:17 -0800146 main.log.warn( main.CLIs[ 0 ].apps() )
147 main.log.warn( main.CLIs[ 0 ].appIDs() )
AntonySilvestera1080f22016-04-26 13:05:57 +0530148 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
Jon Hall46fdea12017-05-24 15:48:57 -0700149 onpass="App Ids seem to be correct",
150 onfail="Something is wrong with app Ids" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530151 if cliResults == main.FALSE:
152 main.log.error( "Failed to start ONOS,stopping test" )
153 main.cleanup()
154 main.exit()
155
AntonySilvestera1080f22016-04-26 13:05:57 +0530156 def CASE2( self, main ):
157 """
158 Discovery the topology using BGPLS
159 """
Jon Hall46fdea12017-05-24 15:48:57 -0700160 import os
161 import sys
AntonySilvestera1080f22016-04-26 13:05:57 +0530162 import re
163 import time
164
165 main.case( "Testcase 2 : Discovery the Network Topology using BGPLS" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800166 main.ONOScli1.log( "\"testcase2 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530167
168 try:
169 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
170 except ImportError:
171 main.log.exception( "Something wrong with import file or code error." )
172 main.log.info( "Import Error, please check!" )
173 main.cleanup()
174 main.exit()
175
176 bgplsConfig = BgpLs()
177 Ne_id = bgplsConfig.Constants()
178 app = bgplsConfig.apps()
179 main.CLIs = []
180 main.nodes = []
Jon Hall46fdea12017-05-24 15:48:57 -0700181 main.numCtrls = 1
AntonySilvestera1080f22016-04-26 13:05:57 +0530182
183 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
Jon Hall46fdea12017-05-24 15:48:57 -0700184 scapy_ip = os.getenv( main.params[ 'SCAPY' ][ 'HOSTNAMES' ] )
185 httpport = main.params[ 'HTTP' ][ 'port' ]
186 path = main.params[ 'HTTP' ][ 'path' ]
187 bgplsConfig.ipValue( ipList, scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530188
189 for i in range( 1, main.numCtrls + 1 ):
190 try:
191 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
192 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
193 ipList.append( main.nodes[ -1 ].ip_address )
194 except AttributeError:
195 break
196
197 main.step( "Apply cell to environment" )
198 bgplsConfig.Comments()
199
200 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800201 main.log.info( "Sending BGPLS information" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530202 bgplsConfig.Comments()
203
AntonySilvestera1080f22016-04-26 13:05:57 +0530204 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\
205 dependencies/Scapyfiles/Topo_discovery.py" )
206 bgplsConfig.Comments()
207 main.log.info( "Enable BGPlS plugin in ONOS" )
208 bgplsConfig.Comments()
209
Jon Hall46fdea12017-05-24 15:48:57 -0700210 cliResults = main.ONOScli1.startOnosCli( main.nodes[ 0 ].ip_address )
AntonySilvestera1080f22016-04-26 13:05:57 +0530211
212 main.step( "Getting connected to ONOS" )
213 utilities.assert_equals( expect=main.TRUE, actual=cliResults,
214 onpass="ONOS cli startup successful",
215 onfail="ONOS cli startup failed" )
Jon Hall46fdea12017-05-24 15:48:57 -0700216 installResults = main.ONOScli1.activateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530217
218 main.step( "Install onos-app-bgp" )
219 utilities.assert_equals( expect=main.TRUE, actual=installResults,
220 onpass="Install onos-app-bgp successful",
221 onfail="Install onos-app-bgp failed" )
222
223 bgpls_post = bgplsConfig.DictoJson()
224
225 bgplsConfig.Comments()
226 main.log.info( "BGPLS RestConf input" )
227 bgplsConfig.Comments()
228
Jon Hall46fdea12017-05-24 15:48:57 -0700229 print ( bgpls_post )
alisonb1a26522016-11-22 17:27:17 -0800230 main.ONOSrest.user_name = "onos"
231 main.ONOSrest.pwd = "rocks"
Jon Hall46fdea12017-05-24 15:48:57 -0700232 Poststatus, result = main.ONOSrest.send( '/network/configuration/', method="POST", data=bgpls_post )
AntonySilvestera1080f22016-04-26 13:05:57 +0530233 main.step( "Configure BGP through RESTCONF" )
234
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800235 utilities.assert_equals( expect='200',
236 actual=Poststatus,
237 onpass="Post Port Success",
238 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
AntonySilvestera1080f22016-04-26 13:05:57 +0530239
AntonySilvestera1080f22016-04-26 13:05:57 +0530240 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800241 main.step( "Check Network devices are Updated in ONOS " )
AntonySilvestera1080f22016-04-26 13:05:57 +0530242 bgplsConfig.Comments()
Jon Hall46fdea12017-05-24 15:48:57 -0700243 time.sleep( 15 )
AntonySilvestera1080f22016-04-26 13:05:57 +0530244 response = main.ONOScli1.devices()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800245 responseCheck = main.FALSE
246 if response:
247 responseCheck = main.TRUE
248 utilities.assert_equals( expect=main.TRUE,
249 actual=responseCheck,
250 onpass="Network Devices update in ONOS successful",
251 onfail="Network Devices update in ONOS failed" )
252
AntonySilvestera1080f22016-04-26 13:05:57 +0530253 main.step( "Check the nodes are discovered" )
Jon Hall46fdea12017-05-24 15:48:57 -0700254 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 +0530255 stepResult = main.TRUE
256 else:
257 stepResult = main.FALSE
258 utilities.assert_equals( expect=main.TRUE,
259 actual=stepResult,
Jon Hall46fdea12017-05-24 15:48:57 -0700260 onpass="Node " + str( Ne_id[ 1 ][ 0 ] ) + ( Ne_id[ 1 ][ 1 ] ) + ( Ne_id[ 1 ][ 2 ] ) + " sucess",
261 onfail="Node " + str( Ne_id[ 1 ][ 0 ] ) + ( Ne_id[ 1 ][ 1 ] ) + ( Ne_id[ 1 ][ 2 ] ) + " failed" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800262 main.ONOScli1.log( "\"testcase2 end\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530263
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800264 main.step( "Check for Errors or Exception in testcase2" )
265 startStr = "testcase2 start"
266 endStr = "testcase2 end"
Jon Hall46fdea12017-05-24 15:48:57 -0700267 errorLog = main.ONOSbench.logReport( main.nodes[ 0 ].ip_address,
268 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800269 startStr, endStr )
270 utilities.assert_equals( expect=0, actual=errorLog,
271 onpass="No Exception or Error occured in testcase2",
272 onfail="Exception or Error occured in testcase2" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530273 bgplsConfig.Comments()
274 main.log.info( "Kill Scapy process" )
275 bgplsConfig.Comments()
276
277 main.Scapy1.handle.sendline( "\x03" )
Jon Hall46fdea12017-05-24 15:48:57 -0700278 time.sleep( 90 ) # This Sleep time gives time for the socket to close.
AntonySilvestera1080f22016-04-26 13:05:57 +0530279
AntonySilvestera1080f22016-04-26 13:05:57 +0530280 def CASE3( self, main ):
281 """
282 Addition of new Node to existing topology
283 """
Jon Hall46fdea12017-05-24 15:48:57 -0700284 import os
285 import sys
AntonySilvestera1080f22016-04-26 13:05:57 +0530286 import re
287 import time
288
289 main.case( "Testcase 3: Addition of New Node to existing topology" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800290 main.ONOScli1.log( "\"testcase3 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530291 try:
292 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
293 except ImportError:
294 main.log.exception( "Something wrong with import file or code error." )
295 main.log.info( "Import Error, please check!" )
296 main.cleanup()
297 main.exit()
298
299 bgplsConfig = BgpLs()
300 Ne_id = bgplsConfig.Constants()
301 app = bgplsConfig.apps()
302 main.CLIs = []
303 main.nodes = []
Jon Hall46fdea12017-05-24 15:48:57 -0700304 main.numCtrls = 1
AntonySilvestera1080f22016-04-26 13:05:57 +0530305
306 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
Jon Hall46fdea12017-05-24 15:48:57 -0700307 scapy_ip = os.getenv( main.params[ 'SCAPY' ][ 'HOSTNAMES' ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530308 cellName = main.params[ 'ENV' ][ 'cellName' ]
Jon Hall46fdea12017-05-24 15:48:57 -0700309 cellAppString = main.params[ 'ENV' ][ 'cellApps' ]
310 httpport = main.params[ 'HTTP' ][ 'port' ]
311 path = main.params[ 'HTTP' ][ 'path' ]
AntonySilvestera1080f22016-04-26 13:05:57 +0530312
Jon Hall46fdea12017-05-24 15:48:57 -0700313 bgplsConfig.ipValue( ipList, scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530314
315 for i in range( 1, main.numCtrls + 1 ):
316 try:
317 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
318 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
319 ipList.append( main.nodes[ -1 ].ip_address )
320 except AttributeError:
321 break
322
323 bgplsConfig.Comments()
324 main.log.info( "Sending BGPLS Packet " )
325 bgplsConfig.Comments()
326
327 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\
328 dependencies/Scapyfiles/Update_Node.py" )
329 bgplsConfig.Comments()
330 main.log.info( "Enable BGPlS plugin in ONOS" )
331 bgplsConfig.Comments()
332
333 main.step( "UnInstall onos-app-bgp" )
Jon Hall46fdea12017-05-24 15:48:57 -0700334 installResults = main.ONOScli1.deactivateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530335 utilities.assert_equals( expect=main.TRUE, actual=installResults,
336 onpass="Uninstall onos-app-bgp successful",
337 onfail="Uninstall onos-app-bgp failed" )
338
Jon Hall46fdea12017-05-24 15:48:57 -0700339 installResults = main.ONOScli1.activateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530340 main.step( "Install onos-app-bgp" )
341 utilities.assert_equals( expect=main.TRUE, actual=installResults,
342 onpass="Install onos-app-bgp successful",
343 onfail="Install onos-app-bgp failed" )
344
AntonySilvestera1080f22016-04-26 13:05:57 +0530345 bgpls_post = bgplsConfig.DictoJson()
346
347 bgplsConfig.Comments()
348 main.log.info( "BGPLS RestConf input" )
349 bgplsConfig.Comments()
350
351 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800352 main.step( "Check Network devices are Updated in ONOS" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530353 bgplsConfig.Comments()
Jon Hall46fdea12017-05-24 15:48:57 -0700354 time.sleep( 120 )
AntonySilvestera1080f22016-04-26 13:05:57 +0530355 response = main.ONOScli1.devices()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800356 responseCheck = main.FALSE
357 if response:
358 responseCheck = main.TRUE
359 utilities.assert_equals( expect=main.TRUE,
360 actual=responseCheck,
361 onpass="Network Devices update in ONOS successful",
362 onfail="Network Devices update in ONOS failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530363 main.step( "Check Newly added Node is getting updated" )
364
Jon Hall46fdea12017-05-24 15:48:57 -0700365 if response.find( Ne_id[ 1 ][ 3 ] ) != -1:
AntonySilvestera1080f22016-04-26 13:05:57 +0530366 stepResult = main.TRUE
367 else:
368 stepResult = main.FALSE
369 utilities.assert_equals( expect=main.TRUE,
370 actual=stepResult,
AntonySilvester02652382016-07-13 16:44:45 +0530371 onpass="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update sucess",
372 onfail="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update failed" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800373 main.ONOScli1.log( "\"testcase3 end\"" )
374
375 main.step( "Check for Errors or Exception in testcase3" )
376 startStr = "testcase3 start"
377 endStr = "testcase3 end"
Jon Hall46fdea12017-05-24 15:48:57 -0700378 errorLog = main.ONOSbench.logReport( main.nodes[ 0 ].ip_address,
379 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800380 startStr, endStr )
381 utilities.assert_equals( expect=0, actual=errorLog,
382 onpass="No Exception or Error occured in testcase3",
383 onfail="Exception or Error occured in testcase3" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530384 bgplsConfig.Comments()
385 main.log.info( "Kill Scapy process" )
386 bgplsConfig.Comments()
387 main.Scapy1.handle.sendline( "\x03" )
Jon Hall46fdea12017-05-24 15:48:57 -0700388 time.sleep( 90 ) # This Sleep time gives time for the socket to close.
AntonySilvestera1080f22016-04-26 13:05:57 +0530389
AntonySilvestera1080f22016-04-26 13:05:57 +0530390 def CASE4( self, main ):
391 """
AntonySilvester02652382016-07-13 16:44:45 +0530392 Verification of Links in existing topology
AntonySilvestera1080f22016-04-26 13:05:57 +0530393 """
AntonySilvester02652382016-07-13 16:44:45 +0530394 import json
AntonySilvestera1080f22016-04-26 13:05:57 +0530395 import time
AntonySilvester02652382016-07-13 16:44:45 +0530396 import os
397 main.case( "Testcase 4: Verification of Links thats is discovered" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800398 main.ONOScli1.log( "\"testcase4 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530399 try:
400 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
401 except ImportError:
402 main.log.exception( "Something wrong with import file or code error." )
403 main.log.info( "Import Error, please check!" )
404 main.cleanup()
405 main.exit()
406
407 bgplsConfig = BgpLs()
AntonySilvestera1080f22016-04-26 13:05:57 +0530408 app = bgplsConfig.apps()
409 main.CLIs = []
410 main.nodes = []
Jon Hall46fdea12017-05-24 15:48:57 -0700411 main.numCtrls = 1
AntonySilvestera1080f22016-04-26 13:05:57 +0530412 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
Jon Hall46fdea12017-05-24 15:48:57 -0700413 scapy_ip = os.getenv( main.params[ 'SCAPY' ][ 'HOSTNAMES' ] )
414 bgplsConfig.ipValue( ipList, scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530415
AntonySilvestera1080f22016-04-26 13:05:57 +0530416 for i in range( 1, main.numCtrls + 1 ):
417 try:
418 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
419 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
420 ipList.append( main.nodes[ -1 ].ip_address )
421 except AttributeError:
422 break
423
AntonySilvestera1080f22016-04-26 13:05:57 +0530424 bgplsConfig.Comments()
AntonySilvester02652382016-07-13 16:44:45 +0530425 main.log.info( "Sending BGPLS Link information Packet " )
AntonySilvestera1080f22016-04-26 13:05:57 +0530426 bgplsConfig.Comments()
427
AntonySilvester02652382016-07-13 16:44:45 +0530428 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Link_Update_Node.py" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530429 bgplsConfig.Comments()
430 main.log.info( "Enable BGPlS plugin in ONOS" )
431 bgplsConfig.Comments()
432
AntonySilvester02652382016-07-13 16:44:45 +0530433 main.step( "UnInstall onos-app-bgp" )
434 installResults = main.ONOScli1.deactivateApp( app[ 0 ] )
435 utilities.assert_equals( expect=main.TRUE, actual=installResults,
436 onpass="Uninstall onos-app-bgp successful",
437 onfail="Uninstall onos-app-bgp failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530438
Jon Hall46fdea12017-05-24 15:48:57 -0700439 installResults = main.ONOScli1.activateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530440 main.step( "Install onos-app-bgp" )
441 utilities.assert_equals( expect=main.TRUE, actual=installResults,
442 onpass="Install onos-app-bgp successful",
443 onfail="Install onos-app-bgp failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530444 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800445 main.step( "Checking the Link Discovery Status" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530446 bgplsConfig.Comments()
AntonySilvester02652382016-07-13 16:44:45 +0530447 time.sleep( 120 ) # Time taken to discovery the links
448 response = main.ONOScli1.links()
449 linksResp = json.loads( response )
450 check_link = bgplsConfig.checkLinks( linksResp )
AntonySilvestera1080f22016-04-26 13:05:57 +0530451
Jon Hall46fdea12017-05-24 15:48:57 -0700452 if check_link:
AntonySilvester02652382016-07-13 16:44:45 +0530453 reply_Check_Link = main.TRUE
Jon Hall46fdea12017-05-24 15:48:57 -0700454 utilities.assert_equals( expect=main.TRUE, actual=reply_Check_Link,
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800455 onpass="Link Discovery Success.",
456 onfail="Link Discovery Failed." )
457 main.ONOScli1.log( "\"testcase4 end\"" )
458
459 main.step( "Check for Errors or Exception in testcase4 " )
460 startStr = "testcase4 start"
461 endStr = "testcase4 end"
Jon Hall46fdea12017-05-24 15:48:57 -0700462 errorLog = main.ONOSbench.logReport( main.nodes[ 0 ].ip_address,
463 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800464 startStr, endStr )
Jon Hall46fdea12017-05-24 15:48:57 -0700465 utilities.assert_equals( expect=0, actual=errorLog,
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800466 onpass="No Exception or Error occured in testcase4",
467 onfail="Exception or Error occured in testcase4" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530468 bgplsConfig.Comments()
469 main.log.info( "Kill Scapy process" )
470 bgplsConfig.Comments()
AntonySilvestera1080f22016-04-26 13:05:57 +0530471 main.Scapy1.handle.sendline( "\x03" )
AntonySilvester02652382016-07-13 16:44:45 +0530472 time.sleep( 90 )
AntonySilvestera1080f22016-04-26 13:05:57 +0530473
474 def CASE5( self, main ):
475 """
AntonySilvester02652382016-07-13 16:44:45 +0530476 Deletion of links
477 """
478 import json
479 import time
480 import os
481 main.case( "Testcase 5: Deletion of Link in existing topology" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800482
483 main.ONOScli1.log( "\"testcase5 start\"" )
AntonySilvester02652382016-07-13 16:44:45 +0530484 try:
485 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
486 except ImportError:
487 main.log.exception( "Something wrong with import file or code error." )
488 main.log.info( "Import Error, please check!" )
489 main.cleanup()
490 main.exit()
491
492 bgplsConfig = BgpLs()
493 app = bgplsConfig.apps()
494 main.CLIs = []
495 main.nodes = []
Jon Hall46fdea12017-05-24 15:48:57 -0700496 main.numCtrls = 1
AntonySilvester02652382016-07-13 16:44:45 +0530497 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
Jon Hall46fdea12017-05-24 15:48:57 -0700498 scapy_ip = os.getenv( main.params[ 'SCAPY' ][ 'HOSTNAMES' ] )
499 bgplsConfig.ipValue( ipList, scapy_ip )
AntonySilvester02652382016-07-13 16:44:45 +0530500
501 for i in range( 1, main.numCtrls + 1 ):
502 try:
503 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
504 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
505 ipList.append( main.nodes[ -1 ].ip_address )
506 except AttributeError:
507 break
508
509 bgplsConfig.Comments()
510 main.log.info( "Sending BGPLS Delete Link Packet " )
511 bgplsConfig.Comments()
512
513 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py" )
514 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800515 main.log.info( "Enable BGPlS plugin in ONOS " )
AntonySilvester02652382016-07-13 16:44:45 +0530516 bgplsConfig.Comments()
517
518 main.step( "UnInstall onos-app-bgp" )
519 installResults = main.ONOScli1.deactivateApp( app[ 0 ] )
520 utilities.assert_equals( expect=main.TRUE, actual=installResults,
521 onpass="Uninstall onos-app-bgp successful",
522 onfail="Uninstall onos-app-bgp failed" )
523
Jon Hall46fdea12017-05-24 15:48:57 -0700524 installResults = main.ONOScli1.activateApp( app[ 0 ] )
AntonySilvester02652382016-07-13 16:44:45 +0530525 main.step( "Install onos-app-bgp" )
526 utilities.assert_equals( expect=main.TRUE, actual=installResults,
527 onpass="Install onos-app-bgp successful",
528 onfail="Install onos-app-bgp failed" )
529 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800530 main.step( "Checking whether the links is deleted" )
AntonySilvester02652382016-07-13 16:44:45 +0530531 bgplsConfig.Comments()
532 time.sleep( 120 ) # Time taken to discovery the links
533 response = main.ONOScli1.links()
534 linksResp = json.loads( response )
535 check_link = bgplsConfig.checkLinks( linksResp )
Jon Hall46fdea12017-05-24 15:48:57 -0700536 if not check_link:
AntonySilvester02652382016-07-13 16:44:45 +0530537 reply_Check_Link = main.TRUE
Jon Hall46fdea12017-05-24 15:48:57 -0700538 utilities.assert_equals( expect=main.TRUE, actual=reply_Check_Link,
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800539 onpass="Link is Deleted Successfully.",
540 onfail="Link is Deletion Failed." )
541 main.ONOScli1.log( "\"testcase5 end\"" )
542
543 main.step( "Check for Errors or Exception in testcase5" )
544 startStr = "testcase5 start"
545 endStr = "testcase5 end"
Jon Hall46fdea12017-05-24 15:48:57 -0700546 errorLog = main.ONOSbench.logReport( main.nodes[ 0 ].ip_address,
547 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800548 startStr, endStr )
549 utilities.assert_equals( expect=0, actual=errorLog,
550 onpass="No Exception or Error occured in testcase5",
551 onfail="Exception or Error occured in testcase5" )
AntonySilvester02652382016-07-13 16:44:45 +0530552 bgplsConfig.Comments()
553 main.log.info( "Kill Scapy process" )
554 bgplsConfig.Comments()
555 main.Scapy1.handle.sendline( "\x03" )
556 time.sleep( 90 )
557
558 def CASE6( self, main ):
559 """
AntonySilvestera1080f22016-04-26 13:05:57 +0530560 Uninstalling the app
561 """
Jon Hall46fdea12017-05-24 15:48:57 -0700562 import os
563 import sys
AntonySilvestera1080f22016-04-26 13:05:57 +0530564 import re
565 import time
566
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800567 main.case( "TestCase 6: UnInstalling of app" )
568 main.ONOScli1.log( "\"testcase6 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530569 try:
570 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
571 except ImportError:
572 main.log.exception( "Something wrong with import file or code error." )
573 main.log.info( "Import Error, please check!" )
574 main.cleanup()
575 main.exit()
576
577 bgplsConfig = BgpLs()
578 app = bgplsConfig.apps()
579 main.CLIs = []
580 main.nodes = []
Jon Hall46fdea12017-05-24 15:48:57 -0700581 main.numCtrls = 1
AntonySilvestera1080f22016-04-26 13:05:57 +0530582
583 ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
Jon Hall46fdea12017-05-24 15:48:57 -0700584 scapy_ip = os.getenv( main.params[ 'SCAPY' ][ 'HOSTNAMES' ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530585 cellName = main.params[ 'ENV' ][ 'cellName' ]
Jon Hall46fdea12017-05-24 15:48:57 -0700586 cellAppString = main.params[ 'ENV' ][ 'cellApps' ]
AntonySilvestera1080f22016-04-26 13:05:57 +0530587
588 bgplsConfig = BgpLs()
Jon Hall46fdea12017-05-24 15:48:57 -0700589 bgplsConfig.ipValue( ipList, scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530590 main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
591 scapy_ip,
Devin Limdc78e202017-06-09 18:30:07 -0700592 cellAppString, ipList, main.ONOScli1.karafUser )
AntonySilvestera1080f22016-04-26 13:05:57 +0530593
594 for i in range( 1, main.numCtrls + 1 ):
595 try:
596 main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
597 main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
598 ipList.append( main.nodes[ -1 ].ip_address )
599 except AttributeError:
600 break
601
602 main.step( "Apply cell to environment" )
603 bgplsConfig.Comments()
604 cellResult = main.ONOSbench.setCell( cellName )
605
606 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800607 main.step( "Logging into ONOS CLI " )
AntonySilvestera1080f22016-04-26 13:05:57 +0530608 bgplsConfig.Comments()
609
Jon Hall46fdea12017-05-24 15:48:57 -0700610 cliResults = main.ONOScli1.startOnosCli( main.nodes[ 0 ].ip_address )
AntonySilvestera1080f22016-04-26 13:05:57 +0530611 utilities.assert_equals( expect=main.TRUE, actual=cliResults,
612 onpass="ONOS cli startup successful",
613 onfail="ONOS cli startup failed" )
614
615 bgplsConfig.Comments()
616 main.log.info( "Uninstall onos-app-bgp" )
617 bgplsConfig.Comments()
618 main.step( "UnInstall onos-app-bgp" )
Jon Hall46fdea12017-05-24 15:48:57 -0700619 installResults = main.ONOScli1.deactivateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530620 utilities.assert_equals( expect=main.TRUE, actual=installResults,
621 onpass="Uninstall onos-app-bgp successful",
622 onfail="Uninstall onos-app-bgp failed" )
623
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800624 main.ONOScli1.log( "\"testcase6 end\"" )
625 main.step( "Check for Errors or Exception in testcase6" )
626 startStr = "testcase6 start"
627 endStr = "testcase6 end"
Jon Hall46fdea12017-05-24 15:48:57 -0700628 errorLog = main.ONOSbench.logReport( main.nodes[ 0 ].ip_address,
629 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800630 startStr, endStr )
631 utilities.assert_equals( expect=0, actual=errorLog,
632 onpass="No Exception or Error occured in testcase6",
633 onfail="Exception or Error occured in testcase6" )
634
635 main.step( "Check for Errors or Exception End of the Script" )
Jon Hall46fdea12017-05-24 15:48:57 -0700636 errorLog = main.ONOSbench.logReport( main.nodes[ 0 ].ip_address,
637 [ "ERROR", "EXCEPT" ] )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800638 utilities.assert_equals( expect=0, actual=errorLog,
AntonySilvester02652382016-07-13 16:44:45 +0530639 onpass="No Exception or Error occured",
Chiyu Chengef109502016-11-21 15:51:38 -0800640 onfail="Exception or Error occured" )