blob: dd2d2cc18f1c9907686e4a8bb9f35e5a26549ecb [file] [log] [blame]
AntonySilvestera1080f22016-04-26 13:05:57 +05301"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07002Copyright 2016 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07003
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
7
8 TestON is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070011 ( at your option ) any later version.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070012
13 TestON is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with TestON. If not, see <http://www.gnu.org/licenses/>.
20
AntonySilvestera1080f22016-04-26 13:05:57 +053021**** Scripted by Antony Silvester - antony.silvester@huawei.com ******
22
23
24This Test check the bgp_ls functionality
25
26List of test cases:
27CASE1: Compile ONOS and push it to the test machines
28CASE2: Discovery the topology using BGPLS
29CASE3: Addition of new Node to existing topology
AntonySilvester02652382016-07-13 16:44:45 +053030CASE4: Verification of Links thats is discovered"
31CASE5: Deletion of Links
32Case6: Uninstalling the app
AntonySilvestera1080f22016-04-26 13:05:57 +053033
34
35"""
AntonySilvestera1080f22016-04-26 13:05:57 +053036class FUNCbgpls:
37
38 def __init__( self ):
39 self.default = ''
40
41 def CASE1( self, main ):
42 """
43 CASE1 is to compile ONOS and push it to the test machines
44
45 Startup sequence:
46 cell <name>
47 onos-verify-cell
48 NOTE: temporary - onos-remove-raft-logs
49 onos-uninstall
50 git pull
AntonySilvestera1080f22016-04-26 13:05:57 +053051 onos-package
52 onos-install -f
53 onos-wait-for-start
54 start cli sessions
55 start BGPLS apps
56
57 """
AntonySilvestera1080f22016-04-26 13:05:57 +053058 import os
Pratik Parab3b2ab5a2017-02-14 13:15:14 -080059
AntonySilvestera1080f22016-04-26 13:05:57 +053060 main.log.info( "ONOS Single node start " +
61 "Scapy Tool - initialization" )
Devin Lim142b5342017-07-20 15:22:39 -070062 try:
63 from tests.dependencies.ONOSSetup import ONOSSetup
64 main.testSetUp = ONOSSetup()
65 except ImportError:
66 main.log.error( "ONOSSetup not found. exiting the test" )
Devin Lim44075962017-08-11 10:56:37 -070067 main.cleanAndExit()
Devin Lim142b5342017-07-20 15:22:39 -070068 main.testSetUp.envSetupDescription()
69 try:
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070070 main.cellName = main.params[ 'ENV' ][ 'cellName' ]
71 main.ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
72 main.scapy_ip = os.getenv( main.params[ 'SCAPY' ][ 'HOSTNAMES' ] )
AntonySilvestera1080f22016-04-26 13:05:57 +053073
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070074 main.apps = main.params[ 'ENV' ][ 'cellApps' ]
Devin Lim142b5342017-07-20 15:22:39 -070075 stepResult = main.testSetUp.envSetup()
76 except Exception as e:
77 main.testSetUp.envSetupException( e )
AntonySilvestera1080f22016-04-26 13:05:57 +053078
You Wanga0f6ff62018-01-11 15:46:30 -080079 cliResults = main.testSetUp.ONOSSetUp( main.Cluster, cellName=main.cellName,
80 mininetIp=main.scapy_ip, removeLog=True )
AntonySilvestera1080f22016-04-26 13:05:57 +053081 main.step( "App Ids check" )
Devin Lim142b5342017-07-20 15:22:39 -070082 appCheck = main.Cluster.active( 0 ).CLI.appToIDCheck()
AntonySilvestera1080f22016-04-26 13:05:57 +053083
Jon Hall46fdea12017-05-24 15:48:57 -070084 if appCheck != main.TRUE:
Devin Lim142b5342017-07-20 15:22:39 -070085 main.log.warn( main.Cluster.active( 0 ).CLI.apps() )
86 main.log.warn( main.Cluster.active( 0 ).CLI.appIDs() )
AntonySilvestera1080f22016-04-26 13:05:57 +053087 utilities.assert_equals( expect=main.TRUE, actual=appCheck,
Jon Hall46fdea12017-05-24 15:48:57 -070088 onpass="App Ids seem to be correct",
89 onfail="Something is wrong with app Ids" )
AntonySilvestera1080f22016-04-26 13:05:57 +053090 if cliResults == main.FALSE:
91 main.log.error( "Failed to start ONOS,stopping test" )
Devin Lim44075962017-08-11 10:56:37 -070092 main.cleanAndExit()
AntonySilvestera1080f22016-04-26 13:05:57 +053093
AntonySilvestera1080f22016-04-26 13:05:57 +053094 def CASE2( self, main ):
95 """
96 Discovery the topology using BGPLS
97 """
Jon Hall46fdea12017-05-24 15:48:57 -070098 import os
99 import sys
AntonySilvestera1080f22016-04-26 13:05:57 +0530100 import re
101 import time
102
103 main.case( "Testcase 2 : Discovery the Network Topology using BGPLS" )
Devin Lim142b5342017-07-20 15:22:39 -0700104 main.Cluster.active( 0 ).CLI.log( "\"testcase2 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530105
106 try:
107 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
108 except ImportError:
109 main.log.exception( "Something wrong with import file or code error." )
110 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700111 main.cleanAndExit()
AntonySilvestera1080f22016-04-26 13:05:57 +0530112
113 bgplsConfig = BgpLs()
114 Ne_id = bgplsConfig.Constants()
115 app = bgplsConfig.apps()
Jon Hall46fdea12017-05-24 15:48:57 -0700116 httpport = main.params[ 'HTTP' ][ 'port' ]
117 path = main.params[ 'HTTP' ][ 'path' ]
Devin Lim142b5342017-07-20 15:22:39 -0700118 bgplsConfig.ipValue( main.ipList, main.scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530119
120 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800121 main.log.info( "Sending BGPLS information" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530122 bgplsConfig.Comments()
123
AntonySilvestera1080f22016-04-26 13:05:57 +0530124 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\
125 dependencies/Scapyfiles/Topo_discovery.py" )
126 bgplsConfig.Comments()
127 main.log.info( "Enable BGPlS plugin in ONOS" )
128 bgplsConfig.Comments()
129
Devin Lim142b5342017-07-20 15:22:39 -0700130 main.testSetUp.startOnosClis( main.Cluster )
AntonySilvestera1080f22016-04-26 13:05:57 +0530131
Devin Lim142b5342017-07-20 15:22:39 -0700132 installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530133 main.step( "Install onos-app-bgp" )
134 utilities.assert_equals( expect=main.TRUE, actual=installResults,
135 onpass="Install onos-app-bgp successful",
136 onfail="Install onos-app-bgp failed" )
137
138 bgpls_post = bgplsConfig.DictoJson()
139
140 bgplsConfig.Comments()
141 main.log.info( "BGPLS RestConf input" )
142 bgplsConfig.Comments()
143
Jon Hall46fdea12017-05-24 15:48:57 -0700144 print ( bgpls_post )
Devin Lim142b5342017-07-20 15:22:39 -0700145 Poststatus, result = main.Cluster.active( 0 ).REST.send( '/network/configuration/', method="POST", data=bgpls_post )
AntonySilvestera1080f22016-04-26 13:05:57 +0530146 main.step( "Configure BGP through RESTCONF" )
147
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800148 utilities.assert_equals( expect='200',
149 actual=Poststatus,
150 onpass="Post Port Success",
151 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
AntonySilvestera1080f22016-04-26 13:05:57 +0530152
AntonySilvestera1080f22016-04-26 13:05:57 +0530153 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800154 main.step( "Check Network devices are Updated in ONOS " )
AntonySilvestera1080f22016-04-26 13:05:57 +0530155 bgplsConfig.Comments()
Jon Hall46fdea12017-05-24 15:48:57 -0700156 time.sleep( 15 )
Devin Lim142b5342017-07-20 15:22:39 -0700157 response = main.Cluster.active( 0 ).CLI.devices()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800158 responseCheck = main.FALSE
159 if response:
160 responseCheck = main.TRUE
161 utilities.assert_equals( expect=main.TRUE,
162 actual=responseCheck,
163 onpass="Network Devices update in ONOS successful",
164 onfail="Network Devices update in ONOS failed" )
165
AntonySilvestera1080f22016-04-26 13:05:57 +0530166 main.step( "Check the nodes are discovered" )
Jon Hall46fdea12017-05-24 15:48:57 -0700167 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 +0530168 stepResult = main.TRUE
169 else:
170 stepResult = main.FALSE
171 utilities.assert_equals( expect=main.TRUE,
172 actual=stepResult,
Jon Hall46fdea12017-05-24 15:48:57 -0700173 onpass="Node " + str( Ne_id[ 1 ][ 0 ] ) + ( Ne_id[ 1 ][ 1 ] ) + ( Ne_id[ 1 ][ 2 ] ) + " sucess",
174 onfail="Node " + str( Ne_id[ 1 ][ 0 ] ) + ( Ne_id[ 1 ][ 1 ] ) + ( Ne_id[ 1 ][ 2 ] ) + " failed" )
Devin Lim142b5342017-07-20 15:22:39 -0700175 main.Cluster.active( 0 ).CLI.log( "\"testcase2 end\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530176
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800177 main.step( "Check for Errors or Exception in testcase2" )
178 startStr = "testcase2 start"
179 endStr = "testcase2 end"
Devin Lim142b5342017-07-20 15:22:39 -0700180 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700181 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800182 startStr, endStr )
183 utilities.assert_equals( expect=0, actual=errorLog,
184 onpass="No Exception or Error occured in testcase2",
185 onfail="Exception or Error occured in testcase2" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530186 bgplsConfig.Comments()
187 main.log.info( "Kill Scapy process" )
188 bgplsConfig.Comments()
189
190 main.Scapy1.handle.sendline( "\x03" )
Jon Hall46fdea12017-05-24 15:48:57 -0700191 time.sleep( 90 ) # This Sleep time gives time for the socket to close.
AntonySilvestera1080f22016-04-26 13:05:57 +0530192
AntonySilvestera1080f22016-04-26 13:05:57 +0530193 def CASE3( self, main ):
194 """
195 Addition of new Node to existing topology
196 """
Jon Hall46fdea12017-05-24 15:48:57 -0700197 import os
198 import sys
AntonySilvestera1080f22016-04-26 13:05:57 +0530199 import re
200 import time
201
202 main.case( "Testcase 3: Addition of New Node to existing topology" )
Devin Lim142b5342017-07-20 15:22:39 -0700203 main.Cluster.active( 0 ).CLI.log( "\"testcase3 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530204 try:
205 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
206 except ImportError:
207 main.log.exception( "Something wrong with import file or code error." )
208 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700209 main.cleanAndExit()
AntonySilvestera1080f22016-04-26 13:05:57 +0530210
211 bgplsConfig = BgpLs()
212 Ne_id = bgplsConfig.Constants()
213 app = bgplsConfig.apps()
AntonySilvestera1080f22016-04-26 13:05:57 +0530214
Jon Hall46fdea12017-05-24 15:48:57 -0700215 httpport = main.params[ 'HTTP' ][ 'port' ]
216 path = main.params[ 'HTTP' ][ 'path' ]
AntonySilvestera1080f22016-04-26 13:05:57 +0530217
Devin Lim142b5342017-07-20 15:22:39 -0700218 bgplsConfig.ipValue( main.ipList, main.scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530219
220 bgplsConfig.Comments()
221 main.log.info( "Sending BGPLS Packet " )
222 bgplsConfig.Comments()
223
224 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\
225 dependencies/Scapyfiles/Update_Node.py" )
226 bgplsConfig.Comments()
227 main.log.info( "Enable BGPlS plugin in ONOS" )
228 bgplsConfig.Comments()
229
230 main.step( "UnInstall onos-app-bgp" )
Devin Lim142b5342017-07-20 15:22:39 -0700231 installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530232 utilities.assert_equals( expect=main.TRUE, actual=installResults,
233 onpass="Uninstall onos-app-bgp successful",
234 onfail="Uninstall onos-app-bgp failed" )
235
Devin Lim142b5342017-07-20 15:22:39 -0700236 installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530237 main.step( "Install onos-app-bgp" )
238 utilities.assert_equals( expect=main.TRUE, actual=installResults,
239 onpass="Install onos-app-bgp successful",
240 onfail="Install onos-app-bgp failed" )
241
AntonySilvestera1080f22016-04-26 13:05:57 +0530242 bgpls_post = bgplsConfig.DictoJson()
243
244 bgplsConfig.Comments()
245 main.log.info( "BGPLS RestConf input" )
246 bgplsConfig.Comments()
247
248 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800249 main.step( "Check Network devices are Updated in ONOS" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530250 bgplsConfig.Comments()
Jon Hall46fdea12017-05-24 15:48:57 -0700251 time.sleep( 120 )
Devin Lim142b5342017-07-20 15:22:39 -0700252 response = main.Cluster.active( 0 ).CLI.devices()
Devin Lim3d60b442017-08-03 17:59:56 -0700253
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800254 responseCheck = main.FALSE
255 if response:
256 responseCheck = main.TRUE
257 utilities.assert_equals( expect=main.TRUE,
258 actual=responseCheck,
259 onpass="Network Devices update in ONOS successful",
260 onfail="Network Devices update in ONOS failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530261 main.step( "Check Newly added Node is getting updated" )
262
Jon Hall46fdea12017-05-24 15:48:57 -0700263 if response.find( Ne_id[ 1 ][ 3 ] ) != -1:
AntonySilvestera1080f22016-04-26 13:05:57 +0530264 stepResult = main.TRUE
265 else:
266 stepResult = main.FALSE
267 utilities.assert_equals( expect=main.TRUE,
268 actual=stepResult,
AntonySilvester02652382016-07-13 16:44:45 +0530269 onpass="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update sucess",
270 onfail="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update failed" )
Devin Lim142b5342017-07-20 15:22:39 -0700271 main.Cluster.active( 0 ).CLI.log( "\"testcase3 end\"" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800272
273 main.step( "Check for Errors or Exception in testcase3" )
274 startStr = "testcase3 start"
275 endStr = "testcase3 end"
Devin Lim142b5342017-07-20 15:22:39 -0700276 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700277 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800278 startStr, endStr )
279 utilities.assert_equals( expect=0, actual=errorLog,
280 onpass="No Exception or Error occured in testcase3",
281 onfail="Exception or Error occured in testcase3" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530282 bgplsConfig.Comments()
283 main.log.info( "Kill Scapy process" )
284 bgplsConfig.Comments()
285 main.Scapy1.handle.sendline( "\x03" )
Jon Hall46fdea12017-05-24 15:48:57 -0700286 time.sleep( 90 ) # This Sleep time gives time for the socket to close.
AntonySilvestera1080f22016-04-26 13:05:57 +0530287
AntonySilvestera1080f22016-04-26 13:05:57 +0530288 def CASE4( self, main ):
289 """
AntonySilvester02652382016-07-13 16:44:45 +0530290 Verification of Links in existing topology
AntonySilvestera1080f22016-04-26 13:05:57 +0530291 """
AntonySilvester02652382016-07-13 16:44:45 +0530292 import json
AntonySilvestera1080f22016-04-26 13:05:57 +0530293 import time
AntonySilvester02652382016-07-13 16:44:45 +0530294 import os
295 main.case( "Testcase 4: Verification of Links thats is discovered" )
Devin Lim142b5342017-07-20 15:22:39 -0700296 main.Cluster.active( 0 ).CLI.log( "\"testcase4 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530297 try:
298 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
299 except ImportError:
300 main.log.exception( "Something wrong with import file or code error." )
301 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700302 main.cleanAndExit()
AntonySilvestera1080f22016-04-26 13:05:57 +0530303
304 bgplsConfig = BgpLs()
AntonySilvestera1080f22016-04-26 13:05:57 +0530305 app = bgplsConfig.apps()
Devin Lim142b5342017-07-20 15:22:39 -0700306 bgplsConfig.ipValue( main.ipList, main.scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530307
AntonySilvestera1080f22016-04-26 13:05:57 +0530308 bgplsConfig.Comments()
AntonySilvester02652382016-07-13 16:44:45 +0530309 main.log.info( "Sending BGPLS Link information Packet " )
AntonySilvestera1080f22016-04-26 13:05:57 +0530310 bgplsConfig.Comments()
311
AntonySilvester02652382016-07-13 16:44:45 +0530312 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Link_Update_Node.py" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530313 bgplsConfig.Comments()
314 main.log.info( "Enable BGPlS plugin in ONOS" )
315 bgplsConfig.Comments()
316
AntonySilvester02652382016-07-13 16:44:45 +0530317 main.step( "UnInstall onos-app-bgp" )
Devin Lim142b5342017-07-20 15:22:39 -0700318 installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] )
AntonySilvester02652382016-07-13 16:44:45 +0530319 utilities.assert_equals( expect=main.TRUE, actual=installResults,
320 onpass="Uninstall onos-app-bgp successful",
321 onfail="Uninstall onos-app-bgp failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530322
Devin Lim142b5342017-07-20 15:22:39 -0700323 installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530324 main.step( "Install onos-app-bgp" )
325 utilities.assert_equals( expect=main.TRUE, actual=installResults,
326 onpass="Install onos-app-bgp successful",
327 onfail="Install onos-app-bgp failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530328 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800329 main.step( "Checking the Link Discovery Status" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530330 bgplsConfig.Comments()
AntonySilvester02652382016-07-13 16:44:45 +0530331 time.sleep( 120 ) # Time taken to discovery the links
Devin Lim142b5342017-07-20 15:22:39 -0700332 response = main.Cluster.active( 0 ).CLI.links()
AntonySilvester02652382016-07-13 16:44:45 +0530333 linksResp = json.loads( response )
334 check_link = bgplsConfig.checkLinks( linksResp )
Devin Lim3d60b442017-08-03 17:59:56 -0700335 reply_Check_Link = main.FALSE
Jon Hall46fdea12017-05-24 15:48:57 -0700336 if check_link:
AntonySilvester02652382016-07-13 16:44:45 +0530337 reply_Check_Link = main.TRUE
Jon Hall46fdea12017-05-24 15:48:57 -0700338 utilities.assert_equals( expect=main.TRUE, actual=reply_Check_Link,
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800339 onpass="Link Discovery Success.",
340 onfail="Link Discovery Failed." )
Devin Lim142b5342017-07-20 15:22:39 -0700341 main.Cluster.active( 0 ).CLI.log( "\"testcase4 end\"" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800342
343 main.step( "Check for Errors or Exception in testcase4 " )
344 startStr = "testcase4 start"
345 endStr = "testcase4 end"
Devin Lim142b5342017-07-20 15:22:39 -0700346 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700347 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800348 startStr, endStr )
Jon Hall46fdea12017-05-24 15:48:57 -0700349 utilities.assert_equals( expect=0, actual=errorLog,
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800350 onpass="No Exception or Error occured in testcase4",
351 onfail="Exception or Error occured in testcase4" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530352 bgplsConfig.Comments()
353 main.log.info( "Kill Scapy process" )
354 bgplsConfig.Comments()
AntonySilvestera1080f22016-04-26 13:05:57 +0530355 main.Scapy1.handle.sendline( "\x03" )
AntonySilvester02652382016-07-13 16:44:45 +0530356 time.sleep( 90 )
AntonySilvestera1080f22016-04-26 13:05:57 +0530357
358 def CASE5( self, main ):
359 """
AntonySilvester02652382016-07-13 16:44:45 +0530360 Deletion of links
361 """
362 import json
363 import time
364 import os
365 main.case( "Testcase 5: Deletion of Link in existing topology" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800366
Devin Lim142b5342017-07-20 15:22:39 -0700367 main.Cluster.active( 0 ).CLI.log( "\"testcase5 start\"" )
AntonySilvester02652382016-07-13 16:44:45 +0530368 try:
369 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
370 except ImportError:
371 main.log.exception( "Something wrong with import file or code error." )
372 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700373 main.cleanAndExit()
AntonySilvester02652382016-07-13 16:44:45 +0530374
375 bgplsConfig = BgpLs()
376 app = bgplsConfig.apps()
Devin Lim142b5342017-07-20 15:22:39 -0700377 bgplsConfig.ipValue( main.ipList, main.scapy_ip )
AntonySilvester02652382016-07-13 16:44:45 +0530378
379 bgplsConfig.Comments()
380 main.log.info( "Sending BGPLS Delete Link Packet " )
381 bgplsConfig.Comments()
382
383 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py" )
384 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800385 main.log.info( "Enable BGPlS plugin in ONOS " )
AntonySilvester02652382016-07-13 16:44:45 +0530386 bgplsConfig.Comments()
387
388 main.step( "UnInstall onos-app-bgp" )
Devin Lim142b5342017-07-20 15:22:39 -0700389 installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] )
AntonySilvester02652382016-07-13 16:44:45 +0530390 utilities.assert_equals( expect=main.TRUE, actual=installResults,
391 onpass="Uninstall onos-app-bgp successful",
392 onfail="Uninstall onos-app-bgp failed" )
393
Devin Lim142b5342017-07-20 15:22:39 -0700394 installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] )
AntonySilvester02652382016-07-13 16:44:45 +0530395 main.step( "Install onos-app-bgp" )
396 utilities.assert_equals( expect=main.TRUE, actual=installResults,
397 onpass="Install onos-app-bgp successful",
398 onfail="Install onos-app-bgp failed" )
399 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800400 main.step( "Checking whether the links is deleted" )
AntonySilvester02652382016-07-13 16:44:45 +0530401 bgplsConfig.Comments()
402 time.sleep( 120 ) # Time taken to discovery the links
Devin Lim142b5342017-07-20 15:22:39 -0700403 response = main.Cluster.active( 0 ).CLI.links()
AntonySilvester02652382016-07-13 16:44:45 +0530404 linksResp = json.loads( response )
405 check_link = bgplsConfig.checkLinks( linksResp )
Devin Lim3d60b442017-08-03 17:59:56 -0700406 reply_Check_Link = main.FALSE
Jon Hall46fdea12017-05-24 15:48:57 -0700407 if not check_link:
AntonySilvester02652382016-07-13 16:44:45 +0530408 reply_Check_Link = main.TRUE
Jon Hall46fdea12017-05-24 15:48:57 -0700409 utilities.assert_equals( expect=main.TRUE, actual=reply_Check_Link,
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800410 onpass="Link is Deleted Successfully.",
411 onfail="Link is Deletion Failed." )
Devin Lim142b5342017-07-20 15:22:39 -0700412 main.Cluster.active( 0 ).CLI.log( "\"testcase5 end\"" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800413
414 main.step( "Check for Errors or Exception in testcase5" )
415 startStr = "testcase5 start"
416 endStr = "testcase5 end"
Devin Lim142b5342017-07-20 15:22:39 -0700417 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700418 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800419 startStr, endStr )
420 utilities.assert_equals( expect=0, actual=errorLog,
421 onpass="No Exception or Error occured in testcase5",
422 onfail="Exception or Error occured in testcase5" )
AntonySilvester02652382016-07-13 16:44:45 +0530423 bgplsConfig.Comments()
424 main.log.info( "Kill Scapy process" )
425 bgplsConfig.Comments()
426 main.Scapy1.handle.sendline( "\x03" )
427 time.sleep( 90 )
428
429 def CASE6( self, main ):
430 """
AntonySilvestera1080f22016-04-26 13:05:57 +0530431 Uninstalling the app
432 """
Jon Hall46fdea12017-05-24 15:48:57 -0700433 import os
434 import sys
AntonySilvestera1080f22016-04-26 13:05:57 +0530435 import re
436 import time
437
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800438 main.case( "TestCase 6: UnInstalling of app" )
Devin Lim142b5342017-07-20 15:22:39 -0700439 main.Cluster.active( 0 ).CLI.log( "\"testcase6 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530440 try:
441 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
442 except ImportError:
443 main.log.exception( "Something wrong with import file or code error." )
444 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700445 main.cleanAndExit()
AntonySilvestera1080f22016-04-26 13:05:57 +0530446
447 bgplsConfig = BgpLs()
448 app = bgplsConfig.apps()
AntonySilvestera1080f22016-04-26 13:05:57 +0530449
450 bgplsConfig = BgpLs()
Devin Lim142b5342017-07-20 15:22:39 -0700451 bgplsConfig.ipValue( main.ipList, main.scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530452
You Wang09b596b2018-01-10 10:42:38 -0800453 main.testSetUp.createApplyCell( main.Cluster, True, main.cellName, main.apps, main.scapy_ip, True, main.ipList )
AntonySilvestera1080f22016-04-26 13:05:57 +0530454 bgplsConfig.Comments()
Devin Lim142b5342017-07-20 15:22:39 -0700455 main.testSetUp.startOnosClis( main.Cluster )
AntonySilvestera1080f22016-04-26 13:05:57 +0530456 bgplsConfig.Comments()
457
AntonySilvestera1080f22016-04-26 13:05:57 +0530458 main.log.info( "Uninstall onos-app-bgp" )
459 bgplsConfig.Comments()
460 main.step( "UnInstall onos-app-bgp" )
Devin Lim142b5342017-07-20 15:22:39 -0700461 installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530462 utilities.assert_equals( expect=main.TRUE, actual=installResults,
463 onpass="Uninstall onos-app-bgp successful",
464 onfail="Uninstall onos-app-bgp failed" )
465
Devin Lim142b5342017-07-20 15:22:39 -0700466 main.Cluster.active( 0 ).CLI.log( "\"testcase6 end\"" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800467 main.step( "Check for Errors or Exception in testcase6" )
468 startStr = "testcase6 start"
469 endStr = "testcase6 end"
Devin Lim142b5342017-07-20 15:22:39 -0700470 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700471 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800472 startStr, endStr )
473 utilities.assert_equals( expect=0, actual=errorLog,
474 onpass="No Exception or Error occured in testcase6",
475 onfail="Exception or Error occured in testcase6" )
476
477 main.step( "Check for Errors or Exception End of the Script" )
Devin Lim142b5342017-07-20 15:22:39 -0700478 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700479 [ "ERROR", "EXCEPT" ] )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800480 utilities.assert_equals( expect=0, actual=errorLog,
AntonySilvester02652382016-07-13 16:44:45 +0530481 onpass="No Exception or Error occured",
Chiyu Chengef109502016-11-21 15:51:38 -0800482 onfail="Exception or Error occured" )