blob: a401bb296a8e2aec0d381636d60b511bb14710d4 [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()
Devin Lim3d60b442017-08-03 17:59:56 -0700257
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800258 responseCheck = main.FALSE
259 if response:
260 responseCheck = main.TRUE
261 utilities.assert_equals( expect=main.TRUE,
262 actual=responseCheck,
263 onpass="Network Devices update in ONOS successful",
264 onfail="Network Devices update in ONOS failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530265 main.step( "Check Newly added Node is getting updated" )
266
Jon Hall46fdea12017-05-24 15:48:57 -0700267 if response.find( Ne_id[ 1 ][ 3 ] ) != -1:
AntonySilvestera1080f22016-04-26 13:05:57 +0530268 stepResult = main.TRUE
269 else:
270 stepResult = main.FALSE
271 utilities.assert_equals( expect=main.TRUE,
272 actual=stepResult,
AntonySilvester02652382016-07-13 16:44:45 +0530273 onpass="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update sucess",
274 onfail="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update failed" )
Devin Lim142b5342017-07-20 15:22:39 -0700275 main.Cluster.active( 0 ).CLI.log( "\"testcase3 end\"" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800276
277 main.step( "Check for Errors or Exception in testcase3" )
278 startStr = "testcase3 start"
279 endStr = "testcase3 end"
Devin Lim142b5342017-07-20 15:22:39 -0700280 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700281 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800282 startStr, endStr )
283 utilities.assert_equals( expect=0, actual=errorLog,
284 onpass="No Exception or Error occured in testcase3",
285 onfail="Exception or Error occured in testcase3" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530286 bgplsConfig.Comments()
287 main.log.info( "Kill Scapy process" )
288 bgplsConfig.Comments()
289 main.Scapy1.handle.sendline( "\x03" )
Jon Hall46fdea12017-05-24 15:48:57 -0700290 time.sleep( 90 ) # This Sleep time gives time for the socket to close.
AntonySilvestera1080f22016-04-26 13:05:57 +0530291
AntonySilvestera1080f22016-04-26 13:05:57 +0530292 def CASE4( self, main ):
293 """
AntonySilvester02652382016-07-13 16:44:45 +0530294 Verification of Links in existing topology
AntonySilvestera1080f22016-04-26 13:05:57 +0530295 """
AntonySilvester02652382016-07-13 16:44:45 +0530296 import json
AntonySilvestera1080f22016-04-26 13:05:57 +0530297 import time
AntonySilvester02652382016-07-13 16:44:45 +0530298 import os
299 main.case( "Testcase 4: Verification of Links thats is discovered" )
Devin Lim142b5342017-07-20 15:22:39 -0700300 main.Cluster.active( 0 ).CLI.log( "\"testcase4 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530301 try:
302 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
303 except ImportError:
304 main.log.exception( "Something wrong with import file or code error." )
305 main.log.info( "Import Error, please check!" )
306 main.cleanup()
307 main.exit()
308
309 bgplsConfig = BgpLs()
AntonySilvestera1080f22016-04-26 13:05:57 +0530310 app = bgplsConfig.apps()
Devin Lim142b5342017-07-20 15:22:39 -0700311 bgplsConfig.ipValue( main.ipList, main.scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530312
AntonySilvestera1080f22016-04-26 13:05:57 +0530313 bgplsConfig.Comments()
AntonySilvester02652382016-07-13 16:44:45 +0530314 main.log.info( "Sending BGPLS Link information Packet " )
AntonySilvestera1080f22016-04-26 13:05:57 +0530315 bgplsConfig.Comments()
316
AntonySilvester02652382016-07-13 16:44:45 +0530317 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Link_Update_Node.py" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530318 bgplsConfig.Comments()
319 main.log.info( "Enable BGPlS plugin in ONOS" )
320 bgplsConfig.Comments()
321
AntonySilvester02652382016-07-13 16:44:45 +0530322 main.step( "UnInstall onos-app-bgp" )
Devin Lim142b5342017-07-20 15:22:39 -0700323 installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] )
AntonySilvester02652382016-07-13 16:44:45 +0530324 utilities.assert_equals( expect=main.TRUE, actual=installResults,
325 onpass="Uninstall onos-app-bgp successful",
326 onfail="Uninstall onos-app-bgp failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530327
Devin Lim142b5342017-07-20 15:22:39 -0700328 installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530329 main.step( "Install onos-app-bgp" )
330 utilities.assert_equals( expect=main.TRUE, actual=installResults,
331 onpass="Install onos-app-bgp successful",
332 onfail="Install onos-app-bgp failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530333 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800334 main.step( "Checking the Link Discovery Status" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530335 bgplsConfig.Comments()
AntonySilvester02652382016-07-13 16:44:45 +0530336 time.sleep( 120 ) # Time taken to discovery the links
Devin Lim142b5342017-07-20 15:22:39 -0700337 response = main.Cluster.active( 0 ).CLI.links()
AntonySilvester02652382016-07-13 16:44:45 +0530338 linksResp = json.loads( response )
339 check_link = bgplsConfig.checkLinks( linksResp )
Devin Lim3d60b442017-08-03 17:59:56 -0700340 reply_Check_Link = main.FALSE
Jon Hall46fdea12017-05-24 15:48:57 -0700341 if check_link:
AntonySilvester02652382016-07-13 16:44:45 +0530342 reply_Check_Link = main.TRUE
Jon Hall46fdea12017-05-24 15:48:57 -0700343 utilities.assert_equals( expect=main.TRUE, actual=reply_Check_Link,
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800344 onpass="Link Discovery Success.",
345 onfail="Link Discovery Failed." )
Devin Lim142b5342017-07-20 15:22:39 -0700346 main.Cluster.active( 0 ).CLI.log( "\"testcase4 end\"" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800347
348 main.step( "Check for Errors or Exception in testcase4 " )
349 startStr = "testcase4 start"
350 endStr = "testcase4 end"
Devin Lim142b5342017-07-20 15:22:39 -0700351 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700352 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800353 startStr, endStr )
Jon Hall46fdea12017-05-24 15:48:57 -0700354 utilities.assert_equals( expect=0, actual=errorLog,
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800355 onpass="No Exception or Error occured in testcase4",
356 onfail="Exception or Error occured in testcase4" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530357 bgplsConfig.Comments()
358 main.log.info( "Kill Scapy process" )
359 bgplsConfig.Comments()
AntonySilvestera1080f22016-04-26 13:05:57 +0530360 main.Scapy1.handle.sendline( "\x03" )
AntonySilvester02652382016-07-13 16:44:45 +0530361 time.sleep( 90 )
AntonySilvestera1080f22016-04-26 13:05:57 +0530362
363 def CASE5( self, main ):
364 """
AntonySilvester02652382016-07-13 16:44:45 +0530365 Deletion of links
366 """
367 import json
368 import time
369 import os
370 main.case( "Testcase 5: Deletion of Link in existing topology" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800371
Devin Lim142b5342017-07-20 15:22:39 -0700372 main.Cluster.active( 0 ).CLI.log( "\"testcase5 start\"" )
AntonySilvester02652382016-07-13 16:44:45 +0530373 try:
374 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
375 except ImportError:
376 main.log.exception( "Something wrong with import file or code error." )
377 main.log.info( "Import Error, please check!" )
378 main.cleanup()
379 main.exit()
380
381 bgplsConfig = BgpLs()
382 app = bgplsConfig.apps()
Devin Lim142b5342017-07-20 15:22:39 -0700383 bgplsConfig.ipValue( main.ipList, main.scapy_ip )
AntonySilvester02652382016-07-13 16:44:45 +0530384
385 bgplsConfig.Comments()
386 main.log.info( "Sending BGPLS Delete Link Packet " )
387 bgplsConfig.Comments()
388
389 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py" )
390 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800391 main.log.info( "Enable BGPlS plugin in ONOS " )
AntonySilvester02652382016-07-13 16:44:45 +0530392 bgplsConfig.Comments()
393
394 main.step( "UnInstall onos-app-bgp" )
Devin Lim142b5342017-07-20 15:22:39 -0700395 installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] )
AntonySilvester02652382016-07-13 16:44:45 +0530396 utilities.assert_equals( expect=main.TRUE, actual=installResults,
397 onpass="Uninstall onos-app-bgp successful",
398 onfail="Uninstall onos-app-bgp failed" )
399
Devin Lim142b5342017-07-20 15:22:39 -0700400 installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] )
AntonySilvester02652382016-07-13 16:44:45 +0530401 main.step( "Install onos-app-bgp" )
402 utilities.assert_equals( expect=main.TRUE, actual=installResults,
403 onpass="Install onos-app-bgp successful",
404 onfail="Install onos-app-bgp failed" )
405 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800406 main.step( "Checking whether the links is deleted" )
AntonySilvester02652382016-07-13 16:44:45 +0530407 bgplsConfig.Comments()
408 time.sleep( 120 ) # Time taken to discovery the links
Devin Lim142b5342017-07-20 15:22:39 -0700409 response = main.Cluster.active( 0 ).CLI.links()
AntonySilvester02652382016-07-13 16:44:45 +0530410 linksResp = json.loads( response )
411 check_link = bgplsConfig.checkLinks( linksResp )
Devin Lim3d60b442017-08-03 17:59:56 -0700412 reply_Check_Link = main.FALSE
Jon Hall46fdea12017-05-24 15:48:57 -0700413 if not check_link:
AntonySilvester02652382016-07-13 16:44:45 +0530414 reply_Check_Link = main.TRUE
Jon Hall46fdea12017-05-24 15:48:57 -0700415 utilities.assert_equals( expect=main.TRUE, actual=reply_Check_Link,
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800416 onpass="Link is Deleted Successfully.",
417 onfail="Link is Deletion Failed." )
Devin Lim142b5342017-07-20 15:22:39 -0700418 main.Cluster.active( 0 ).CLI.log( "\"testcase5 end\"" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800419
420 main.step( "Check for Errors or Exception in testcase5" )
421 startStr = "testcase5 start"
422 endStr = "testcase5 end"
Devin Lim142b5342017-07-20 15:22:39 -0700423 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700424 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800425 startStr, endStr )
426 utilities.assert_equals( expect=0, actual=errorLog,
427 onpass="No Exception or Error occured in testcase5",
428 onfail="Exception or Error occured in testcase5" )
AntonySilvester02652382016-07-13 16:44:45 +0530429 bgplsConfig.Comments()
430 main.log.info( "Kill Scapy process" )
431 bgplsConfig.Comments()
432 main.Scapy1.handle.sendline( "\x03" )
433 time.sleep( 90 )
434
435 def CASE6( self, main ):
436 """
AntonySilvestera1080f22016-04-26 13:05:57 +0530437 Uninstalling the app
438 """
Jon Hall46fdea12017-05-24 15:48:57 -0700439 import os
440 import sys
AntonySilvestera1080f22016-04-26 13:05:57 +0530441 import re
442 import time
443
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800444 main.case( "TestCase 6: UnInstalling of app" )
Devin Lim142b5342017-07-20 15:22:39 -0700445 main.Cluster.active( 0 ).CLI.log( "\"testcase6 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530446 try:
447 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
448 except ImportError:
449 main.log.exception( "Something wrong with import file or code error." )
450 main.log.info( "Import Error, please check!" )
451 main.cleanup()
452 main.exit()
453
454 bgplsConfig = BgpLs()
455 app = bgplsConfig.apps()
AntonySilvestera1080f22016-04-26 13:05:57 +0530456
457 bgplsConfig = BgpLs()
Devin Lim142b5342017-07-20 15:22:39 -0700458 bgplsConfig.ipValue( main.ipList, main.scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530459
Devin Lim142b5342017-07-20 15:22:39 -0700460 main.testSetUp.createApplyCell( main.Cluster, True, main.cellName, main.scapy_ip, True, main.ipList )
AntonySilvestera1080f22016-04-26 13:05:57 +0530461 bgplsConfig.Comments()
Devin Lim142b5342017-07-20 15:22:39 -0700462 main.testSetUp.startOnosClis( main.Cluster )
AntonySilvestera1080f22016-04-26 13:05:57 +0530463 bgplsConfig.Comments()
464
AntonySilvestera1080f22016-04-26 13:05:57 +0530465 main.log.info( "Uninstall onos-app-bgp" )
466 bgplsConfig.Comments()
467 main.step( "UnInstall onos-app-bgp" )
Devin Lim142b5342017-07-20 15:22:39 -0700468 installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530469 utilities.assert_equals( expect=main.TRUE, actual=installResults,
470 onpass="Uninstall onos-app-bgp successful",
471 onfail="Uninstall onos-app-bgp failed" )
472
Devin Lim142b5342017-07-20 15:22:39 -0700473 main.Cluster.active( 0 ).CLI.log( "\"testcase6 end\"" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800474 main.step( "Check for Errors or Exception in testcase6" )
475 startStr = "testcase6 start"
476 endStr = "testcase6 end"
Devin Lim142b5342017-07-20 15:22:39 -0700477 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700478 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800479 startStr, endStr )
480 utilities.assert_equals( expect=0, actual=errorLog,
481 onpass="No Exception or Error occured in testcase6",
482 onfail="Exception or Error occured in testcase6" )
483
484 main.step( "Check for Errors or Exception End of the Script" )
Devin Lim142b5342017-07-20 15:22:39 -0700485 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700486 [ "ERROR", "EXCEPT" ] )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800487 utilities.assert_equals( expect=0, actual=errorLog,
AntonySilvester02652382016-07-13 16:44:45 +0530488 onpass="No Exception or Error occured",
Chiyu Chengef109502016-11-21 15:51:38 -0800489 onfail="Exception or Error occured" )