blob: f89e57d256e87bfc61cb7bbe4e3becdc68da1a41 [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" )
Devin Lim44075962017-08-11 10:56:37 -070068 main.cleanAndExit()
Devin Lim142b5342017-07-20 15:22:39 -070069 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" )
Devin Lim44075962017-08-11 10:56:37 -070093 main.cleanAndExit()
AntonySilvestera1080f22016-04-26 13:05:57 +053094
AntonySilvestera1080f22016-04-26 13:05:57 +053095 def CASE2( self, main ):
96 """
97 Discovery the topology using BGPLS
98 """
Jon Hall46fdea12017-05-24 15:48:57 -070099 import os
100 import sys
AntonySilvestera1080f22016-04-26 13:05:57 +0530101 import re
102 import time
103
104 main.case( "Testcase 2 : Discovery the Network Topology using BGPLS" )
Devin Lim142b5342017-07-20 15:22:39 -0700105 main.Cluster.active( 0 ).CLI.log( "\"testcase2 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530106
107 try:
108 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
109 except ImportError:
110 main.log.exception( "Something wrong with import file or code error." )
111 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700112 main.cleanAndExit()
AntonySilvestera1080f22016-04-26 13:05:57 +0530113
114 bgplsConfig = BgpLs()
115 Ne_id = bgplsConfig.Constants()
116 app = bgplsConfig.apps()
Jon Hall46fdea12017-05-24 15:48:57 -0700117 httpport = main.params[ 'HTTP' ][ 'port' ]
118 path = main.params[ 'HTTP' ][ 'path' ]
Devin Lim142b5342017-07-20 15:22:39 -0700119 bgplsConfig.ipValue( main.ipList, main.scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530120
121 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800122 main.log.info( "Sending BGPLS information" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530123 bgplsConfig.Comments()
124
AntonySilvestera1080f22016-04-26 13:05:57 +0530125 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\
126 dependencies/Scapyfiles/Topo_discovery.py" )
127 bgplsConfig.Comments()
128 main.log.info( "Enable BGPlS plugin in ONOS" )
129 bgplsConfig.Comments()
130
Devin Lim142b5342017-07-20 15:22:39 -0700131 main.testSetUp.startOnosClis( main.Cluster )
AntonySilvestera1080f22016-04-26 13:05:57 +0530132
Devin Lim142b5342017-07-20 15:22:39 -0700133 installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530134 main.step( "Install onos-app-bgp" )
135 utilities.assert_equals( expect=main.TRUE, actual=installResults,
136 onpass="Install onos-app-bgp successful",
137 onfail="Install onos-app-bgp failed" )
138
139 bgpls_post = bgplsConfig.DictoJson()
140
141 bgplsConfig.Comments()
142 main.log.info( "BGPLS RestConf input" )
143 bgplsConfig.Comments()
144
Jon Hall46fdea12017-05-24 15:48:57 -0700145 print ( bgpls_post )
Devin Lim142b5342017-07-20 15:22:39 -0700146 Poststatus, result = main.Cluster.active( 0 ).REST.send( '/network/configuration/', method="POST", data=bgpls_post )
AntonySilvestera1080f22016-04-26 13:05:57 +0530147 main.step( "Configure BGP through RESTCONF" )
148
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800149 utilities.assert_equals( expect='200',
150 actual=Poststatus,
151 onpass="Post Port Success",
152 onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
AntonySilvestera1080f22016-04-26 13:05:57 +0530153
AntonySilvestera1080f22016-04-26 13:05:57 +0530154 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800155 main.step( "Check Network devices are Updated in ONOS " )
AntonySilvestera1080f22016-04-26 13:05:57 +0530156 bgplsConfig.Comments()
Jon Hall46fdea12017-05-24 15:48:57 -0700157 time.sleep( 15 )
Devin Lim142b5342017-07-20 15:22:39 -0700158 response = main.Cluster.active( 0 ).CLI.devices()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800159 responseCheck = main.FALSE
160 if response:
161 responseCheck = main.TRUE
162 utilities.assert_equals( expect=main.TRUE,
163 actual=responseCheck,
164 onpass="Network Devices update in ONOS successful",
165 onfail="Network Devices update in ONOS failed" )
166
AntonySilvestera1080f22016-04-26 13:05:57 +0530167 main.step( "Check the nodes are discovered" )
Jon Hall46fdea12017-05-24 15:48:57 -0700168 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 +0530169 stepResult = main.TRUE
170 else:
171 stepResult = main.FALSE
172 utilities.assert_equals( expect=main.TRUE,
173 actual=stepResult,
Jon Hall46fdea12017-05-24 15:48:57 -0700174 onpass="Node " + str( Ne_id[ 1 ][ 0 ] ) + ( Ne_id[ 1 ][ 1 ] ) + ( Ne_id[ 1 ][ 2 ] ) + " sucess",
175 onfail="Node " + str( Ne_id[ 1 ][ 0 ] ) + ( Ne_id[ 1 ][ 1 ] ) + ( Ne_id[ 1 ][ 2 ] ) + " failed" )
Devin Lim142b5342017-07-20 15:22:39 -0700176 main.Cluster.active( 0 ).CLI.log( "\"testcase2 end\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530177
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800178 main.step( "Check for Errors or Exception in testcase2" )
179 startStr = "testcase2 start"
180 endStr = "testcase2 end"
Devin Lim142b5342017-07-20 15:22:39 -0700181 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700182 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800183 startStr, endStr )
184 utilities.assert_equals( expect=0, actual=errorLog,
185 onpass="No Exception or Error occured in testcase2",
186 onfail="Exception or Error occured in testcase2" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530187 bgplsConfig.Comments()
188 main.log.info( "Kill Scapy process" )
189 bgplsConfig.Comments()
190
191 main.Scapy1.handle.sendline( "\x03" )
Jon Hall46fdea12017-05-24 15:48:57 -0700192 time.sleep( 90 ) # This Sleep time gives time for the socket to close.
AntonySilvestera1080f22016-04-26 13:05:57 +0530193
AntonySilvestera1080f22016-04-26 13:05:57 +0530194 def CASE3( self, main ):
195 """
196 Addition of new Node to existing topology
197 """
Jon Hall46fdea12017-05-24 15:48:57 -0700198 import os
199 import sys
AntonySilvestera1080f22016-04-26 13:05:57 +0530200 import re
201 import time
202
203 main.case( "Testcase 3: Addition of New Node to existing topology" )
Devin Lim142b5342017-07-20 15:22:39 -0700204 main.Cluster.active( 0 ).CLI.log( "\"testcase3 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530205 try:
206 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
207 except ImportError:
208 main.log.exception( "Something wrong with import file or code error." )
209 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700210 main.cleanAndExit()
AntonySilvestera1080f22016-04-26 13:05:57 +0530211
212 bgplsConfig = BgpLs()
213 Ne_id = bgplsConfig.Constants()
214 app = bgplsConfig.apps()
AntonySilvestera1080f22016-04-26 13:05:57 +0530215
Jon Hall46fdea12017-05-24 15:48:57 -0700216 httpport = main.params[ 'HTTP' ][ 'port' ]
217 path = main.params[ 'HTTP' ][ 'path' ]
AntonySilvestera1080f22016-04-26 13:05:57 +0530218
Devin Lim142b5342017-07-20 15:22:39 -0700219 bgplsConfig.ipValue( main.ipList, main.scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530220
221 bgplsConfig.Comments()
222 main.log.info( "Sending BGPLS Packet " )
223 bgplsConfig.Comments()
224
225 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\
226 dependencies/Scapyfiles/Update_Node.py" )
227 bgplsConfig.Comments()
228 main.log.info( "Enable BGPlS plugin in ONOS" )
229 bgplsConfig.Comments()
230
231 main.step( "UnInstall onos-app-bgp" )
Devin Lim142b5342017-07-20 15:22:39 -0700232 installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530233 utilities.assert_equals( expect=main.TRUE, actual=installResults,
234 onpass="Uninstall onos-app-bgp successful",
235 onfail="Uninstall onos-app-bgp failed" )
236
Devin Lim142b5342017-07-20 15:22:39 -0700237 installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530238 main.step( "Install onos-app-bgp" )
239 utilities.assert_equals( expect=main.TRUE, actual=installResults,
240 onpass="Install onos-app-bgp successful",
241 onfail="Install onos-app-bgp failed" )
242
AntonySilvestera1080f22016-04-26 13:05:57 +0530243 bgpls_post = bgplsConfig.DictoJson()
244
245 bgplsConfig.Comments()
246 main.log.info( "BGPLS RestConf input" )
247 bgplsConfig.Comments()
248
249 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800250 main.step( "Check Network devices are Updated in ONOS" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530251 bgplsConfig.Comments()
Jon Hall46fdea12017-05-24 15:48:57 -0700252 time.sleep( 120 )
Devin Lim142b5342017-07-20 15:22:39 -0700253 response = main.Cluster.active( 0 ).CLI.devices()
Devin Lim3d60b442017-08-03 17:59:56 -0700254
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800255 responseCheck = main.FALSE
256 if response:
257 responseCheck = main.TRUE
258 utilities.assert_equals( expect=main.TRUE,
259 actual=responseCheck,
260 onpass="Network Devices update in ONOS successful",
261 onfail="Network Devices update in ONOS failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530262 main.step( "Check Newly added Node is getting updated" )
263
Jon Hall46fdea12017-05-24 15:48:57 -0700264 if response.find( Ne_id[ 1 ][ 3 ] ) != -1:
AntonySilvestera1080f22016-04-26 13:05:57 +0530265 stepResult = main.TRUE
266 else:
267 stepResult = main.FALSE
268 utilities.assert_equals( expect=main.TRUE,
269 actual=stepResult,
AntonySilvester02652382016-07-13 16:44:45 +0530270 onpass="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update sucess",
271 onfail="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update failed" )
Devin Lim142b5342017-07-20 15:22:39 -0700272 main.Cluster.active( 0 ).CLI.log( "\"testcase3 end\"" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800273
274 main.step( "Check for Errors or Exception in testcase3" )
275 startStr = "testcase3 start"
276 endStr = "testcase3 end"
Devin Lim142b5342017-07-20 15:22:39 -0700277 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700278 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800279 startStr, endStr )
280 utilities.assert_equals( expect=0, actual=errorLog,
281 onpass="No Exception or Error occured in testcase3",
282 onfail="Exception or Error occured in testcase3" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530283 bgplsConfig.Comments()
284 main.log.info( "Kill Scapy process" )
285 bgplsConfig.Comments()
286 main.Scapy1.handle.sendline( "\x03" )
Jon Hall46fdea12017-05-24 15:48:57 -0700287 time.sleep( 90 ) # This Sleep time gives time for the socket to close.
AntonySilvestera1080f22016-04-26 13:05:57 +0530288
AntonySilvestera1080f22016-04-26 13:05:57 +0530289 def CASE4( self, main ):
290 """
AntonySilvester02652382016-07-13 16:44:45 +0530291 Verification of Links in existing topology
AntonySilvestera1080f22016-04-26 13:05:57 +0530292 """
AntonySilvester02652382016-07-13 16:44:45 +0530293 import json
AntonySilvestera1080f22016-04-26 13:05:57 +0530294 import time
AntonySilvester02652382016-07-13 16:44:45 +0530295 import os
296 main.case( "Testcase 4: Verification of Links thats is discovered" )
Devin Lim142b5342017-07-20 15:22:39 -0700297 main.Cluster.active( 0 ).CLI.log( "\"testcase4 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530298 try:
299 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
300 except ImportError:
301 main.log.exception( "Something wrong with import file or code error." )
302 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700303 main.cleanAndExit()
AntonySilvestera1080f22016-04-26 13:05:57 +0530304
305 bgplsConfig = BgpLs()
AntonySilvestera1080f22016-04-26 13:05:57 +0530306 app = bgplsConfig.apps()
Devin Lim142b5342017-07-20 15:22:39 -0700307 bgplsConfig.ipValue( main.ipList, main.scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530308
AntonySilvestera1080f22016-04-26 13:05:57 +0530309 bgplsConfig.Comments()
AntonySilvester02652382016-07-13 16:44:45 +0530310 main.log.info( "Sending BGPLS Link information Packet " )
AntonySilvestera1080f22016-04-26 13:05:57 +0530311 bgplsConfig.Comments()
312
AntonySilvester02652382016-07-13 16:44:45 +0530313 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Link_Update_Node.py" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530314 bgplsConfig.Comments()
315 main.log.info( "Enable BGPlS plugin in ONOS" )
316 bgplsConfig.Comments()
317
AntonySilvester02652382016-07-13 16:44:45 +0530318 main.step( "UnInstall onos-app-bgp" )
Devin Lim142b5342017-07-20 15:22:39 -0700319 installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] )
AntonySilvester02652382016-07-13 16:44:45 +0530320 utilities.assert_equals( expect=main.TRUE, actual=installResults,
321 onpass="Uninstall onos-app-bgp successful",
322 onfail="Uninstall onos-app-bgp failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530323
Devin Lim142b5342017-07-20 15:22:39 -0700324 installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530325 main.step( "Install onos-app-bgp" )
326 utilities.assert_equals( expect=main.TRUE, actual=installResults,
327 onpass="Install onos-app-bgp successful",
328 onfail="Install onos-app-bgp failed" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530329 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800330 main.step( "Checking the Link Discovery Status" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530331 bgplsConfig.Comments()
AntonySilvester02652382016-07-13 16:44:45 +0530332 time.sleep( 120 ) # Time taken to discovery the links
Devin Lim142b5342017-07-20 15:22:39 -0700333 response = main.Cluster.active( 0 ).CLI.links()
AntonySilvester02652382016-07-13 16:44:45 +0530334 linksResp = json.loads( response )
335 check_link = bgplsConfig.checkLinks( linksResp )
Devin Lim3d60b442017-08-03 17:59:56 -0700336 reply_Check_Link = main.FALSE
Jon Hall46fdea12017-05-24 15:48:57 -0700337 if check_link:
AntonySilvester02652382016-07-13 16:44:45 +0530338 reply_Check_Link = main.TRUE
Jon Hall46fdea12017-05-24 15:48:57 -0700339 utilities.assert_equals( expect=main.TRUE, actual=reply_Check_Link,
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800340 onpass="Link Discovery Success.",
341 onfail="Link Discovery Failed." )
Devin Lim142b5342017-07-20 15:22:39 -0700342 main.Cluster.active( 0 ).CLI.log( "\"testcase4 end\"" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800343
344 main.step( "Check for Errors or Exception in testcase4 " )
345 startStr = "testcase4 start"
346 endStr = "testcase4 end"
Devin Lim142b5342017-07-20 15:22:39 -0700347 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700348 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800349 startStr, endStr )
Jon Hall46fdea12017-05-24 15:48:57 -0700350 utilities.assert_equals( expect=0, actual=errorLog,
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800351 onpass="No Exception or Error occured in testcase4",
352 onfail="Exception or Error occured in testcase4" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530353 bgplsConfig.Comments()
354 main.log.info( "Kill Scapy process" )
355 bgplsConfig.Comments()
AntonySilvestera1080f22016-04-26 13:05:57 +0530356 main.Scapy1.handle.sendline( "\x03" )
AntonySilvester02652382016-07-13 16:44:45 +0530357 time.sleep( 90 )
AntonySilvestera1080f22016-04-26 13:05:57 +0530358
359 def CASE5( self, main ):
360 """
AntonySilvester02652382016-07-13 16:44:45 +0530361 Deletion of links
362 """
363 import json
364 import time
365 import os
366 main.case( "Testcase 5: Deletion of Link in existing topology" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800367
Devin Lim142b5342017-07-20 15:22:39 -0700368 main.Cluster.active( 0 ).CLI.log( "\"testcase5 start\"" )
AntonySilvester02652382016-07-13 16:44:45 +0530369 try:
370 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
371 except ImportError:
372 main.log.exception( "Something wrong with import file or code error." )
373 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700374 main.cleanAndExit()
AntonySilvester02652382016-07-13 16:44:45 +0530375
376 bgplsConfig = BgpLs()
377 app = bgplsConfig.apps()
Devin Lim142b5342017-07-20 15:22:39 -0700378 bgplsConfig.ipValue( main.ipList, main.scapy_ip )
AntonySilvester02652382016-07-13 16:44:45 +0530379
380 bgplsConfig.Comments()
381 main.log.info( "Sending BGPLS Delete Link Packet " )
382 bgplsConfig.Comments()
383
384 main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py" )
385 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800386 main.log.info( "Enable BGPlS plugin in ONOS " )
AntonySilvester02652382016-07-13 16:44:45 +0530387 bgplsConfig.Comments()
388
389 main.step( "UnInstall onos-app-bgp" )
Devin Lim142b5342017-07-20 15:22:39 -0700390 installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] )
AntonySilvester02652382016-07-13 16:44:45 +0530391 utilities.assert_equals( expect=main.TRUE, actual=installResults,
392 onpass="Uninstall onos-app-bgp successful",
393 onfail="Uninstall onos-app-bgp failed" )
394
Devin Lim142b5342017-07-20 15:22:39 -0700395 installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] )
AntonySilvester02652382016-07-13 16:44:45 +0530396 main.step( "Install onos-app-bgp" )
397 utilities.assert_equals( expect=main.TRUE, actual=installResults,
398 onpass="Install onos-app-bgp successful",
399 onfail="Install onos-app-bgp failed" )
400 bgplsConfig.Comments()
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800401 main.step( "Checking whether the links is deleted" )
AntonySilvester02652382016-07-13 16:44:45 +0530402 bgplsConfig.Comments()
403 time.sleep( 120 ) # Time taken to discovery the links
Devin Lim142b5342017-07-20 15:22:39 -0700404 response = main.Cluster.active( 0 ).CLI.links()
AntonySilvester02652382016-07-13 16:44:45 +0530405 linksResp = json.loads( response )
406 check_link = bgplsConfig.checkLinks( linksResp )
Devin Lim3d60b442017-08-03 17:59:56 -0700407 reply_Check_Link = main.FALSE
Jon Hall46fdea12017-05-24 15:48:57 -0700408 if not check_link:
AntonySilvester02652382016-07-13 16:44:45 +0530409 reply_Check_Link = main.TRUE
Jon Hall46fdea12017-05-24 15:48:57 -0700410 utilities.assert_equals( expect=main.TRUE, actual=reply_Check_Link,
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800411 onpass="Link is Deleted Successfully.",
412 onfail="Link is Deletion Failed." )
Devin Lim142b5342017-07-20 15:22:39 -0700413 main.Cluster.active( 0 ).CLI.log( "\"testcase5 end\"" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800414
415 main.step( "Check for Errors or Exception in testcase5" )
416 startStr = "testcase5 start"
417 endStr = "testcase5 end"
Devin Lim142b5342017-07-20 15:22:39 -0700418 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700419 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800420 startStr, endStr )
421 utilities.assert_equals( expect=0, actual=errorLog,
422 onpass="No Exception or Error occured in testcase5",
423 onfail="Exception or Error occured in testcase5" )
AntonySilvester02652382016-07-13 16:44:45 +0530424 bgplsConfig.Comments()
425 main.log.info( "Kill Scapy process" )
426 bgplsConfig.Comments()
427 main.Scapy1.handle.sendline( "\x03" )
428 time.sleep( 90 )
429
430 def CASE6( self, main ):
431 """
AntonySilvestera1080f22016-04-26 13:05:57 +0530432 Uninstalling the app
433 """
Jon Hall46fdea12017-05-24 15:48:57 -0700434 import os
435 import sys
AntonySilvestera1080f22016-04-26 13:05:57 +0530436 import re
437 import time
438
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800439 main.case( "TestCase 6: UnInstalling of app" )
Devin Lim142b5342017-07-20 15:22:39 -0700440 main.Cluster.active( 0 ).CLI.log( "\"testcase6 start\"" )
AntonySilvestera1080f22016-04-26 13:05:57 +0530441 try:
442 from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
443 except ImportError:
444 main.log.exception( "Something wrong with import file or code error." )
445 main.log.info( "Import Error, please check!" )
Devin Lim44075962017-08-11 10:56:37 -0700446 main.cleanAndExit()
AntonySilvestera1080f22016-04-26 13:05:57 +0530447
448 bgplsConfig = BgpLs()
449 app = bgplsConfig.apps()
AntonySilvestera1080f22016-04-26 13:05:57 +0530450
451 bgplsConfig = BgpLs()
Devin Lim142b5342017-07-20 15:22:39 -0700452 bgplsConfig.ipValue( main.ipList, main.scapy_ip )
AntonySilvestera1080f22016-04-26 13:05:57 +0530453
Devin Lim142b5342017-07-20 15:22:39 -0700454 main.testSetUp.createApplyCell( main.Cluster, True, main.cellName, main.scapy_ip, True, main.ipList )
AntonySilvestera1080f22016-04-26 13:05:57 +0530455 bgplsConfig.Comments()
Devin Lim142b5342017-07-20 15:22:39 -0700456 main.testSetUp.startOnosClis( main.Cluster )
AntonySilvestera1080f22016-04-26 13:05:57 +0530457 bgplsConfig.Comments()
458
AntonySilvestera1080f22016-04-26 13:05:57 +0530459 main.log.info( "Uninstall onos-app-bgp" )
460 bgplsConfig.Comments()
461 main.step( "UnInstall onos-app-bgp" )
Devin Lim142b5342017-07-20 15:22:39 -0700462 installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] )
AntonySilvestera1080f22016-04-26 13:05:57 +0530463 utilities.assert_equals( expect=main.TRUE, actual=installResults,
464 onpass="Uninstall onos-app-bgp successful",
465 onfail="Uninstall onos-app-bgp failed" )
466
Devin Lim142b5342017-07-20 15:22:39 -0700467 main.Cluster.active( 0 ).CLI.log( "\"testcase6 end\"" )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800468 main.step( "Check for Errors or Exception in testcase6" )
469 startStr = "testcase6 start"
470 endStr = "testcase6 end"
Devin Lim142b5342017-07-20 15:22:39 -0700471 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700472 [ "ERROR", "EXCEPT" ], "s",
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800473 startStr, endStr )
474 utilities.assert_equals( expect=0, actual=errorLog,
475 onpass="No Exception or Error occured in testcase6",
476 onfail="Exception or Error occured in testcase6" )
477
478 main.step( "Check for Errors or Exception End of the Script" )
Devin Lim142b5342017-07-20 15:22:39 -0700479 errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress,
Jon Hall46fdea12017-05-24 15:48:57 -0700480 [ "ERROR", "EXCEPT" ] )
Pratik Parab3b2ab5a2017-02-14 13:15:14 -0800481 utilities.assert_equals( expect=0, actual=errorLog,
AntonySilvester02652382016-07-13 16:44:45 +0530482 onpass="No Exception or Error occured",
Chiyu Chengef109502016-11-21 15:51:38 -0800483 onfail="Exception or Error occured" )