blob: 4b0b589ed86b34b03749c3dde7f86a1f519dbe1d [file] [log] [blame]
AntonySilvestera1080f22016-04-26 13:05:57 +05301"""
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07002
3Copyright 2016 Open Networking Foundation (ONF)
4
5Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
6the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
7or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
8
9 TestON is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 2 of the License, or
12 (at your option) any later version.
13
14 TestON is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with TestON. If not, see <http://www.gnu.org/licenses/>.
21
AntonySilvestera1080f22016-04-26 13:05:57 +053022**** Scripted by Antony Silvester - antony.silvester@huawei.com ******
23
24
25This Test check the bgp_ls functionality
26
27List of test cases:
28CASE1: Compile ONOS and push it to the test machines
29CASE2: Discovery the topology using BGPLS
30CASE3: Addition of new Node to existing topology
AntonySilvester02652382016-07-13 16:44:45 +053031CASE4: Verification of Links thats is discovered"
32CASE5: Deletion of Links
33Case6: Uninstalling the app
AntonySilvestera1080f22016-04-26 13:05:57 +053034
35
36"""
AntonySilvestera1080f22016-04-26 13:05:57 +053037class FUNCbgpls:
38
39 def __init__( self ):
40 self.default = ''
41
42 def CASE1( self, main ):
43 """
44 CASE1 is to compile ONOS and push it to the test machines
45
46 Startup sequence:
47 cell <name>
48 onos-verify-cell
49 NOTE: temporary - onos-remove-raft-logs
50 onos-uninstall
51 git pull
AntonySilvestera1080f22016-04-26 13:05:57 +053052 onos-package
53 onos-install -f
54 onos-wait-for-start
55 start cli sessions
56 start BGPLS apps
57
58 """
AntonySilvestera1080f22016-04-26 13:05:57 +053059 import os
Pratik Parab3b2ab5a2017-02-14 13:15:14 -080060
AntonySilvestera1080f22016-04-26 13:05:57 +053061 main.log.info( "ONOS Single node start " +
62 "Scapy Tool - initialization" )
Devin Lim142b5342017-07-20 15:22:39 -070063 try:
64 from tests.dependencies.ONOSSetup import ONOSSetup
65 main.testSetUp = ONOSSetup()
66 except ImportError:
67 main.log.error( "ONOSSetup not found. exiting the test" )
68 main.exit()
69 main.testSetUp.envSetupDescription()
70 try:
71 main.cellName = main.params['ENV']['cellName']
72 main.ipList = os.getenv(main.params['CTRL']['ip1'])
73 main.scapy_ip = os.getenv(main.params['SCAPY']['HOSTNAMES'])
AntonySilvestera1080f22016-04-26 13:05:57 +053074
Devin Lim142b5342017-07-20 15:22:39 -070075 main.apps = main.params['ENV']['cellApps']
76 stepResult = main.testSetUp.envSetup()
77 except Exception as e:
78 main.testSetUp.envSetupException( e )
AntonySilvestera1080f22016-04-26 13:05:57 +053079
Devin Lim142b5342017-07-20 15:22:39 -070080 cliResults = main.testSetUp.ONOSSetUp( main.scapy_ip, main.Cluster,
81 cellName=main.cellName, removeLog=True )
AntonySilvestera1080f22016-04-26 13:05:57 +053082 main.step( "App Ids check" )
Devin Lim142b5342017-07-20 15:22:39 -070083 appCheck = main.Cluster.active( 0 ).CLI.appToIDCheck()
AntonySilvestera1080f22016-04-26 13:05:57 +053084
Jon Hall46fdea12017-05-24 15:48:57 -070085 if appCheck != main.TRUE:
Devin Lim142b5342017-07-20 15:22:39 -070086 main.log.warn( main.Cluster.active( 0 ).CLI.apps() )
87 main.log.warn( main.Cluster.active( 0 ).CLI.appIDs() )
AntonySilvestera1080f22016-04-26 13:05:57 +053088 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
Jon Hall46fdea12017-05-24 15:48:57 -070089 onpass="App Ids seem to be correct",
90 onfail="Something is wrong with app Ids" )
AntonySilvestera1080f22016-04-26 13:05:57 +053091 if cliResults == main.FALSE:
92 main.log.error( "Failed to start ONOS,stopping test" )
93 main.cleanup()
94 main.exit()
95
AntonySilvestera1080f22016-04-26 13:05:57 +053096 def CASE2( self, main ):
97 """
98 Discovery the topology using BGPLS
99 """
Jon Hall46fdea12017-05-24 15:48:57 -0700100 import os
101 import sys
AntonySilvestera1080f22016-04-26 13:05:57 +0530102 import re
103 import time
104
105 main.case( "Testcase 2 : Discovery the Network Topology using BGPLS" )
Devin Lim142b5342017-07-20 15:22:39 -0700106 main.Cluster.active( 0 ).CLI.log( "\"testcase2 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530107
108 try:
109 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
110 except ImportError:
111 main.log.exception( "Something wrong with import file or code error." )
112 main.log.info( "Import Error, please check!" )
113 main.cleanup()
114 main.exit()
115
116 bgplsConfig = BgpLs()
117 Ne_id = bgplsConfig.Constants()
118 app = bgplsConfig.apps()
Jon Hall46fdea12017-05-24 15:48:57 -0700119 httpport = main.params[ 'HTTP' ][ 'port' ]
120 path = main.params[ 'HTTP' ][ 'path' ]
Devin Lim142b5342017-07-20 15:22:39 -0700121 bgplsConfig.ipValue( main.ipList, main.scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530122
123 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800124 main.log.info( "Sending BGPLS information" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530125 bgplsConfig.Comments()
126
AntonySilvestera1080f22016-04-26 13:05:57 +0530127 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\
128 dependencies/Scapyfiles/Topo_discovery.py" )
129 bgplsConfig.Comments()
130 main.log.info( "Enable BGPlS plugin in ONOS" )
131 bgplsConfig.Comments()
132
Devin Lim142b5342017-07-20 15:22:39 -0700133 main.testSetUp.startOnosClis( main.Cluster )
AntonySilvestera1080f22016-04-26 13:05:57 +0530134
Devin Lim142b5342017-07-20 15:22:39 -0700135 installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530136 main.step( "Install onos-app-bgp" )
137 utilities.assert_equals( expect=main.TRUE, actual=installResults,
138 onpass="Install onos-app-bgp successful",
139 onfail="Install onos-app-bgp failed" )
140
141 bgpls_post = bgplsConfig.DictoJson()
142
143 bgplsConfig.Comments()
144 main.log.info( "BGPLS RestConf input" )
145 bgplsConfig.Comments()
146
Jon Hall46fdea12017-05-24 15:48:57 -0700147 print ( bgpls_post )
Devin Lim142b5342017-07-20 15:22:39 -0700148 Poststatus, result = main.Cluster.active( 0 ).REST.send( '/network/configuration/', method="POST", data=bgpls_post )
AntonySilvestera1080f22016-04-26 13:05:57 +0530149 main.step( "Configure BGP through RESTCONF" )
150
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800151 utilities.assert_equals( expect='200',
152 actual=Poststatus,
153 onpass="Post Port Success",
154 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
AntonySilvestera1080f22016-04-26 13:05:57 +0530155
AntonySilvestera1080f22016-04-26 13:05:57 +0530156 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800157 main.step( "Check Network devices are Updated in ONOS " )
AntonySilvestera1080f22016-04-26 13:05:57 +0530158 bgplsConfig.Comments()
Jon Hall46fdea12017-05-24 15:48:57 -0700159 time.sleep( 15 )
Devin Lim142b5342017-07-20 15:22:39 -0700160 response = main.Cluster.active( 0 ).CLI.devices()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800161 responseCheck = main.FALSE
162 if response:
163 responseCheck = main.TRUE
164 utilities.assert_equals( expect=main.TRUE,
165 actual=responseCheck,
166 onpass="Network Devices update in ONOS successful",
167 onfail="Network Devices update in ONOS failed" )
168
AntonySilvestera1080f22016-04-26 13:05:57 +0530169 main.step( "Check the nodes are discovered" )
Jon Hall46fdea12017-05-24 15:48:57 -0700170 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 +0530171 stepResult = main.TRUE
172 else:
173 stepResult = main.FALSE
174 utilities.assert_equals( expect=main.TRUE,
175 actual=stepResult,
Jon Hall46fdea12017-05-24 15:48:57 -0700176 onpass="Node " + str( Ne_id[ 1 ][ 0 ] ) + ( Ne_id[ 1 ][ 1 ] ) + ( Ne_id[ 1 ][ 2 ] ) + " sucess",
177 onfail="Node " + str( Ne_id[ 1 ][ 0 ] ) + ( Ne_id[ 1 ][ 1 ] ) + ( Ne_id[ 1 ][ 2 ] ) + " failed" )
Devin Lim142b5342017-07-20 15:22:39 -0700178 main.Cluster.active( 0 ).CLI.log( "\"testcase2 end\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530179
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800180 main.step( "Check for Errors or Exception in testcase2" )
181 startStr = "testcase2 start"
182 endStr = "testcase2 end"
Devin Lim142b5342017-07-20 15:22:39 -0700183 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700184 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800185 startStr, endStr )
186 utilities.assert_equals( expect=0, actual=errorLog,
187 onpass="No Exception or Error occured in testcase2",
188 onfail="Exception or Error occured in testcase2" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530189 bgplsConfig.Comments()
190 main.log.info( "Kill Scapy process" )
191 bgplsConfig.Comments()
192
193 main.Scapy1.handle.sendline( "\x03" )
Jon Hall46fdea12017-05-24 15:48:57 -0700194 time.sleep( 90 ) # This Sleep time gives time for the socket to close.
AntonySilvestera1080f22016-04-26 13:05:57 +0530195
AntonySilvestera1080f22016-04-26 13:05:57 +0530196 def CASE3( self, main ):
197 """
198 Addition of new Node to existing topology
199 """
Jon Hall46fdea12017-05-24 15:48:57 -0700200 import os
201 import sys
AntonySilvestera1080f22016-04-26 13:05:57 +0530202 import re
203 import time
204
205 main.case( "Testcase 3: Addition of New Node to existing topology" )
Devin Lim142b5342017-07-20 15:22:39 -0700206 main.Cluster.active( 0 ).CLI.log( "\"testcase3 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530207 try:
208 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
209 except ImportError:
210 main.log.exception( "Something wrong with import file or code error." )
211 main.log.info( "Import Error, please check!" )
212 main.cleanup()
213 main.exit()
214
215 bgplsConfig = BgpLs()
216 Ne_id = bgplsConfig.Constants()
217 app = bgplsConfig.apps()
AntonySilvestera1080f22016-04-26 13:05:57 +0530218
Jon Hall46fdea12017-05-24 15:48:57 -0700219 httpport = main.params[ 'HTTP' ][ 'port' ]
220 path = main.params[ 'HTTP' ][ 'path' ]
AntonySilvestera1080f22016-04-26 13:05:57 +0530221
Devin Lim142b5342017-07-20 15:22:39 -0700222 bgplsConfig.ipValue( main.ipList, main.scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530223
224 bgplsConfig.Comments()
225 main.log.info( "Sending BGPLS Packet " )
226 bgplsConfig.Comments()
227
228 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\
229 dependencies/Scapyfiles/Update_Node.py" )
230 bgplsConfig.Comments()
231 main.log.info( "Enable BGPlS plugin in ONOS" )
232 bgplsConfig.Comments()
233
234 main.step( "UnInstall onos-app-bgp" )
Devin Lim142b5342017-07-20 15:22:39 -0700235 installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530236 utilities.assert_equals( expect=main.TRUE, actual=installResults,
237 onpass="Uninstall onos-app-bgp successful",
238 onfail="Uninstall onos-app-bgp failed" )
239
Devin Lim142b5342017-07-20 15:22:39 -0700240 installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530241 main.step( "Install onos-app-bgp" )
242 utilities.assert_equals( expect=main.TRUE, actual=installResults,
243 onpass="Install onos-app-bgp successful",
244 onfail="Install onos-app-bgp failed" )
245
AntonySilvestera1080f22016-04-26 13:05:57 +0530246 bgpls_post = bgplsConfig.DictoJson()
247
248 bgplsConfig.Comments()
249 main.log.info( "BGPLS RestConf input" )
250 bgplsConfig.Comments()
251
252 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800253 main.step( "Check Network devices are Updated in ONOS" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530254 bgplsConfig.Comments()
Jon Hall46fdea12017-05-24 15:48:57 -0700255 time.sleep( 120 )
Devin Lim142b5342017-07-20 15:22:39 -0700256 response = main.Cluster.active( 0 ).CLI.devices()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800257 responseCheck = main.FALSE
258 if response:
259 responseCheck = main.TRUE
260 utilities.assert_equals( expect=main.TRUE,
261 actual=responseCheck,
262 onpass="Network Devices update in ONOS successful",
263 onfail="Network Devices update in ONOS failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530264 main.step( "Check Newly added Node is getting updated" )
265
Jon Hall46fdea12017-05-24 15:48:57 -0700266 if response.find( Ne_id[ 1 ][ 3 ] ) != -1:
AntonySilvestera1080f22016-04-26 13:05:57 +0530267 stepResult = main.TRUE
268 else:
269 stepResult = main.FALSE
270 utilities.assert_equals( expect=main.TRUE,
271 actual=stepResult,
AntonySilvester02652382016-07-13 16:44:45 +0530272 onpass="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update sucess",
273 onfail="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update failed" )
Devin Lim142b5342017-07-20 15:22:39 -0700274 main.Cluster.active( 0 ).CLI.log( "\"testcase3 end\"" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800275
276 main.step( "Check for Errors or Exception in testcase3" )
277 startStr = "testcase3 start"
278 endStr = "testcase3 end"
Devin Lim142b5342017-07-20 15:22:39 -0700279 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700280 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800281 startStr, endStr )
282 utilities.assert_equals( expect=0, actual=errorLog,
283 onpass="No Exception or Error occured in testcase3",
284 onfail="Exception or Error occured in testcase3" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530285 bgplsConfig.Comments()
286 main.log.info( "Kill Scapy process" )
287 bgplsConfig.Comments()
288 main.Scapy1.handle.sendline( "\x03" )
Jon Hall46fdea12017-05-24 15:48:57 -0700289 time.sleep( 90 ) # This Sleep time gives time for the socket to close.
AntonySilvestera1080f22016-04-26 13:05:57 +0530290
AntonySilvestera1080f22016-04-26 13:05:57 +0530291 def CASE4( self, main ):
292 """
AntonySilvester02652382016-07-13 16:44:45 +0530293 Verification of Links in existing topology
AntonySilvestera1080f22016-04-26 13:05:57 +0530294 """
AntonySilvester02652382016-07-13 16:44:45 +0530295 import json
AntonySilvestera1080f22016-04-26 13:05:57 +0530296 import time
AntonySilvester02652382016-07-13 16:44:45 +0530297 import os
298 main.case( "Testcase 4: Verification of Links thats is discovered" )
Devin Lim142b5342017-07-20 15:22:39 -0700299 main.Cluster.active( 0 ).CLI.log( "\"testcase4 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530300 try:
301 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
302 except ImportError:
303 main.log.exception( "Something wrong with import file or code error." )
304 main.log.info( "Import Error, please check!" )
305 main.cleanup()
306 main.exit()
307
308 bgplsConfig = BgpLs()
AntonySilvestera1080f22016-04-26 13:05:57 +0530309 app = bgplsConfig.apps()
Devin Lim142b5342017-07-20 15:22:39 -0700310 bgplsConfig.ipValue( main.ipList, main.scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530311
AntonySilvestera1080f22016-04-26 13:05:57 +0530312 bgplsConfig.Comments()
AntonySilvester02652382016-07-13 16:44:45 +0530313 main.log.info( "Sending BGPLS Link information Packet " )
AntonySilvestera1080f22016-04-26 13:05:57 +0530314 bgplsConfig.Comments()
315
AntonySilvester02652382016-07-13 16:44:45 +0530316 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Link_Update_Node.py" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530317 bgplsConfig.Comments()
318 main.log.info( "Enable BGPlS plugin in ONOS" )
319 bgplsConfig.Comments()
320
AntonySilvester02652382016-07-13 16:44:45 +0530321 main.step( "UnInstall onos-app-bgp" )
Devin Lim142b5342017-07-20 15:22:39 -0700322 installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] )
AntonySilvester02652382016-07-13 16:44:45 +0530323 utilities.assert_equals( expect=main.TRUE, actual=installResults,
324 onpass="Uninstall onos-app-bgp successful",
325 onfail="Uninstall onos-app-bgp failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530326
Devin Lim142b5342017-07-20 15:22:39 -0700327 installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530328 main.step( "Install onos-app-bgp" )
329 utilities.assert_equals( expect=main.TRUE, actual=installResults,
330 onpass="Install onos-app-bgp successful",
331 onfail="Install onos-app-bgp failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530332 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800333 main.step( "Checking the Link Discovery Status" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530334 bgplsConfig.Comments()
AntonySilvester02652382016-07-13 16:44:45 +0530335 time.sleep( 120 ) # Time taken to discovery the links
Devin Lim142b5342017-07-20 15:22:39 -0700336 response = main.Cluster.active( 0 ).CLI.links()
AntonySilvester02652382016-07-13 16:44:45 +0530337 linksResp = json.loads( response )
338 check_link = bgplsConfig.checkLinks( linksResp )
AntonySilvestera1080f22016-04-26 13:05:57 +0530339
Jon Hall46fdea12017-05-24 15:48:57 -0700340 if check_link:
AntonySilvester02652382016-07-13 16:44:45 +0530341 reply_Check_Link = main.TRUE
Jon Hall46fdea12017-05-24 15:48:57 -0700342 utilities.assert_equals( expect=main.TRUE, actual=reply_Check_Link,
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800343 onpass="Link Discovery Success.",
344 onfail="Link Discovery Failed." )
Devin Lim142b5342017-07-20 15:22:39 -0700345 main.Cluster.active( 0 ).CLI.log( "\"testcase4 end\"" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800346
347 main.step( "Check for Errors or Exception in testcase4 " )
348 startStr = "testcase4 start"
349 endStr = "testcase4 end"
Devin Lim142b5342017-07-20 15:22:39 -0700350 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700351 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800352 startStr, endStr )
Jon Hall46fdea12017-05-24 15:48:57 -0700353 utilities.assert_equals( expect=0, actual=errorLog,
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800354 onpass="No Exception or Error occured in testcase4",
355 onfail="Exception or Error occured in testcase4" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530356 bgplsConfig.Comments()
357 main.log.info( "Kill Scapy process" )
358 bgplsConfig.Comments()
AntonySilvestera1080f22016-04-26 13:05:57 +0530359 main.Scapy1.handle.sendline( "\x03" )
AntonySilvester02652382016-07-13 16:44:45 +0530360 time.sleep( 90 )
AntonySilvestera1080f22016-04-26 13:05:57 +0530361
362 def CASE5( self, main ):
363 """
AntonySilvester02652382016-07-13 16:44:45 +0530364 Deletion of links
365 """
366 import json
367 import time
368 import os
369 main.case( "Testcase 5: Deletion of Link in existing topology" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800370
Devin Lim142b5342017-07-20 15:22:39 -0700371 main.Cluster.active( 0 ).CLI.log( "\"testcase5 start\"" )
AntonySilvester02652382016-07-13 16:44:45 +0530372 try:
373 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
374 except ImportError:
375 main.log.exception( "Something wrong with import file or code error." )
376 main.log.info( "Import Error, please check!" )
377 main.cleanup()
378 main.exit()
379
380 bgplsConfig = BgpLs()
381 app = bgplsConfig.apps()
Devin Lim142b5342017-07-20 15:22:39 -0700382 bgplsConfig.ipValue( main.ipList, main.scapy_ip )
AntonySilvester02652382016-07-13 16:44:45 +0530383
384 bgplsConfig.Comments()
385 main.log.info( "Sending BGPLS Delete Link Packet " )
386 bgplsConfig.Comments()
387
388 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py" )
389 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800390 main.log.info( "Enable BGPlS plugin in ONOS " )
AntonySilvester02652382016-07-13 16:44:45 +0530391 bgplsConfig.Comments()
392
393 main.step( "UnInstall onos-app-bgp" )
Devin Lim142b5342017-07-20 15:22:39 -0700394 installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] )
AntonySilvester02652382016-07-13 16:44:45 +0530395 utilities.assert_equals( expect=main.TRUE, actual=installResults,
396 onpass="Uninstall onos-app-bgp successful",
397 onfail="Uninstall onos-app-bgp failed" )
398
Devin Lim142b5342017-07-20 15:22:39 -0700399 installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] )
AntonySilvester02652382016-07-13 16:44:45 +0530400 main.step( "Install onos-app-bgp" )
401 utilities.assert_equals( expect=main.TRUE, actual=installResults,
402 onpass="Install onos-app-bgp successful",
403 onfail="Install onos-app-bgp failed" )
404 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800405 main.step( "Checking whether the links is deleted" )
AntonySilvester02652382016-07-13 16:44:45 +0530406 bgplsConfig.Comments()
407 time.sleep( 120 ) # Time taken to discovery the links
Devin Lim142b5342017-07-20 15:22:39 -0700408 response = main.Cluster.active( 0 ).CLI.links()
AntonySilvester02652382016-07-13 16:44:45 +0530409 linksResp = json.loads( response )
410 check_link = bgplsConfig.checkLinks( linksResp )
Jon Hall46fdea12017-05-24 15:48:57 -0700411 if not check_link:
AntonySilvester02652382016-07-13 16:44:45 +0530412 reply_Check_Link = main.TRUE
Jon Hall46fdea12017-05-24 15:48:57 -0700413 utilities.assert_equals( expect=main.TRUE, actual=reply_Check_Link,
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800414 onpass="Link is Deleted Successfully.",
415 onfail="Link is Deletion Failed." )
Devin Lim142b5342017-07-20 15:22:39 -0700416 main.Cluster.active( 0 ).CLI.log( "\"testcase5 end\"" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800417
418 main.step( "Check for Errors or Exception in testcase5" )
419 startStr = "testcase5 start"
420 endStr = "testcase5 end"
Devin Lim142b5342017-07-20 15:22:39 -0700421 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700422 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800423 startStr, endStr )
424 utilities.assert_equals( expect=0, actual=errorLog,
425 onpass="No Exception or Error occured in testcase5",
426 onfail="Exception or Error occured in testcase5" )
AntonySilvester02652382016-07-13 16:44:45 +0530427 bgplsConfig.Comments()
428 main.log.info( "Kill Scapy process" )
429 bgplsConfig.Comments()
430 main.Scapy1.handle.sendline( "\x03" )
431 time.sleep( 90 )
432
433 def CASE6( self, main ):
434 """
AntonySilvestera1080f22016-04-26 13:05:57 +0530435 Uninstalling the app
436 """
Jon Hall46fdea12017-05-24 15:48:57 -0700437 import os
438 import sys
AntonySilvestera1080f22016-04-26 13:05:57 +0530439 import re
440 import time
441
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800442 main.case( "TestCase 6: UnInstalling of app" )
Devin Lim142b5342017-07-20 15:22:39 -0700443 main.Cluster.active( 0 ).CLI.log( "\"testcase6 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530444 try:
445 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
446 except ImportError:
447 main.log.exception( "Something wrong with import file or code error." )
448 main.log.info( "Import Error, please check!" )
449 main.cleanup()
450 main.exit()
451
452 bgplsConfig = BgpLs()
453 app = bgplsConfig.apps()
AntonySilvestera1080f22016-04-26 13:05:57 +0530454
455 bgplsConfig = BgpLs()
Devin Lim142b5342017-07-20 15:22:39 -0700456 bgplsConfig.ipValue( main.ipList, main.scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530457
Devin Lim142b5342017-07-20 15:22:39 -0700458 main.testSetUp.createApplyCell( main.Cluster, True, main.cellName, main.scapy_ip, True, main.ipList )
AntonySilvestera1080f22016-04-26 13:05:57 +0530459 bgplsConfig.Comments()
Devin Lim142b5342017-07-20 15:22:39 -0700460 main.testSetUp.startOnosClis( main.Cluster )
AntonySilvestera1080f22016-04-26 13:05:57 +0530461 bgplsConfig.Comments()
462
AntonySilvestera1080f22016-04-26 13:05:57 +0530463 main.log.info( "Uninstall onos-app-bgp" )
464 bgplsConfig.Comments()
465 main.step( "UnInstall onos-app-bgp" )
Devin Lim142b5342017-07-20 15:22:39 -0700466 installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530467 utilities.assert_equals( expect=main.TRUE, actual=installResults,
468 onpass="Uninstall onos-app-bgp successful",
469 onfail="Uninstall onos-app-bgp failed" )
470
Devin Lim142b5342017-07-20 15:22:39 -0700471 main.Cluster.active( 0 ).CLI.log( "\"testcase6 end\"" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800472 main.step( "Check for Errors or Exception in testcase6" )
473 startStr = "testcase6 start"
474 endStr = "testcase6 end"
Devin Lim142b5342017-07-20 15:22:39 -0700475 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700476 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800477 startStr, endStr )
478 utilities.assert_equals( expect=0, actual=errorLog,
479 onpass="No Exception or Error occured in testcase6",
480 onfail="Exception or Error occured in testcase6" )
481
482 main.step( "Check for Errors or Exception End of the Script" )
Devin Lim142b5342017-07-20 15:22:39 -0700483 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700484 [ "ERROR", "EXCEPT" ] )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800485 utilities.assert_equals( expect=0, actual=errorLog,
AntonySilvester02652382016-07-13 16:44:45 +0530486 onpass="No Exception or Error occured",
Chiyu Chengef109502016-11-21 15:51:38 -0800487 onfail="Exception or Error occured" )