AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 1 | """ |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 2 | |
| 3 | Copyright 2016 Open Networking Foundation (ONF) |
| 4 | |
| 5 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 6 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 7 | or 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 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 22 | **** Scripted by Antony Silvester - antony.silvester@huawei.com ****** |
| 23 | |
| 24 | |
| 25 | This Test check the bgp_ls functionality |
| 26 | |
| 27 | List of test cases: |
| 28 | CASE1: Compile ONOS and push it to the test machines |
| 29 | CASE2: Discovery the topology using BGPLS |
| 30 | CASE3: Addition of new Node to existing topology |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 31 | CASE4: Verification of Links thats is discovered" |
| 32 | CASE5: Deletion of Links |
| 33 | Case6: Uninstalling the app |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 34 | |
| 35 | |
| 36 | """ |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 37 | class 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 |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 52 | onos-package |
| 53 | onos-install -f |
| 54 | onos-wait-for-start |
| 55 | start cli sessions |
| 56 | start BGPLS apps |
| 57 | |
| 58 | """ |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 59 | import os |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 60 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 61 | main.log.info( "ONOS Single node start " + |
| 62 | "Scapy Tool - initialization" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 63 | 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']) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 74 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 75 | main.apps = main.params['ENV']['cellApps'] |
| 76 | stepResult = main.testSetUp.envSetup() |
| 77 | except Exception as e: |
| 78 | main.testSetUp.envSetupException( e ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 79 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 80 | cliResults = main.testSetUp.ONOSSetUp( main.scapy_ip, main.Cluster, |
| 81 | cellName=main.cellName, removeLog=True ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 82 | main.step( "App Ids check" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 83 | appCheck = main.Cluster.active( 0 ).CLI.appToIDCheck() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 84 | |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 85 | if appCheck != main.TRUE: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 86 | main.log.warn( main.Cluster.active( 0 ).CLI.apps() ) |
| 87 | main.log.warn( main.Cluster.active( 0 ).CLI.appIDs() ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 88 | utilities.assert_equals( expect=main.TRUE, actual=appCheck, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 89 | onpass="App Ids seem to be correct", |
| 90 | onfail="Something is wrong with app Ids" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 91 | if cliResults == main.FALSE: |
| 92 | main.log.error( "Failed to start ONOS,stopping test" ) |
| 93 | main.cleanup() |
| 94 | main.exit() |
| 95 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 96 | def CASE2( self, main ): |
| 97 | """ |
| 98 | Discovery the topology using BGPLS |
| 99 | """ |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 100 | import os |
| 101 | import sys |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 102 | import re |
| 103 | import time |
| 104 | |
| 105 | main.case( "Testcase 2 : Discovery the Network Topology using BGPLS" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 106 | main.Cluster.active( 0 ).CLI.log( "\"testcase2 start\"" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 107 | |
| 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 Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 119 | httpport = main.params[ 'HTTP' ][ 'port' ] |
| 120 | path = main.params[ 'HTTP' ][ 'path' ] |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 121 | bgplsConfig.ipValue( main.ipList, main.scapy_ip ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 122 | |
| 123 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 124 | main.log.info( "Sending BGPLS information" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 125 | bgplsConfig.Comments() |
| 126 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 127 | 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 Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 133 | main.testSetUp.startOnosClis( main.Cluster ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 134 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 135 | installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 136 | 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 Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 147 | print ( bgpls_post ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 148 | Poststatus, result = main.Cluster.active( 0 ).REST.send( '/network/configuration/', method="POST", data=bgpls_post ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 149 | main.step( "Configure BGP through RESTCONF" ) |
| 150 | |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 151 | utilities.assert_equals( expect='200', |
| 152 | actual=Poststatus, |
| 153 | onpass="Post Port Success", |
| 154 | onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 155 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 156 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 157 | main.step( "Check Network devices are Updated in ONOS " ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 158 | bgplsConfig.Comments() |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 159 | time.sleep( 15 ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 160 | response = main.Cluster.active( 0 ).CLI.devices() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 161 | 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 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 169 | main.step( "Check the nodes are discovered" ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 170 | if response.find( Ne_id[ 1 ][ 0 ] ) and response.find( Ne_id[ 1 ][ 1 ] ) and response.find( Ne_id[ 1 ][ 2 ] ) != -1: |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 171 | stepResult = main.TRUE |
| 172 | else: |
| 173 | stepResult = main.FALSE |
| 174 | utilities.assert_equals( expect=main.TRUE, |
| 175 | actual=stepResult, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 176 | 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 Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 178 | main.Cluster.active( 0 ).CLI.log( "\"testcase2 end\"" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 179 | |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 180 | main.step( "Check for Errors or Exception in testcase2" ) |
| 181 | startStr = "testcase2 start" |
| 182 | endStr = "testcase2 end" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 183 | errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 184 | [ "ERROR", "EXCEPT" ], "s", |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 185 | 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" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 189 | bgplsConfig.Comments() |
| 190 | main.log.info( "Kill Scapy process" ) |
| 191 | bgplsConfig.Comments() |
| 192 | |
| 193 | main.Scapy1.handle.sendline( "\x03" ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 194 | time.sleep( 90 ) # This Sleep time gives time for the socket to close. |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 195 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 196 | def CASE3( self, main ): |
| 197 | """ |
| 198 | Addition of new Node to existing topology |
| 199 | """ |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 200 | import os |
| 201 | import sys |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 202 | import re |
| 203 | import time |
| 204 | |
| 205 | main.case( "Testcase 3: Addition of New Node to existing topology" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 206 | main.Cluster.active( 0 ).CLI.log( "\"testcase3 start\"" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 207 | 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() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 218 | |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 219 | httpport = main.params[ 'HTTP' ][ 'port' ] |
| 220 | path = main.params[ 'HTTP' ][ 'path' ] |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 221 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 222 | bgplsConfig.ipValue( main.ipList, main.scapy_ip ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 223 | |
| 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 Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 235 | installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 236 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 237 | onpass="Uninstall onos-app-bgp successful", |
| 238 | onfail="Uninstall onos-app-bgp failed" ) |
| 239 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 240 | installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 241 | 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 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 246 | bgpls_post = bgplsConfig.DictoJson() |
| 247 | |
| 248 | bgplsConfig.Comments() |
| 249 | main.log.info( "BGPLS RestConf input" ) |
| 250 | bgplsConfig.Comments() |
| 251 | |
| 252 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 253 | main.step( "Check Network devices are Updated in ONOS" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 254 | bgplsConfig.Comments() |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 255 | time.sleep( 120 ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 256 | response = main.Cluster.active( 0 ).CLI.devices() |
Devin Lim | 3d60b44 | 2017-08-03 17:59:56 -0700 | [diff] [blame] | 257 | |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 258 | 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" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 265 | main.step( "Check Newly added Node is getting updated" ) |
| 266 | |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 267 | if response.find( Ne_id[ 1 ][ 3 ] ) != -1: |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 268 | stepResult = main.TRUE |
| 269 | else: |
| 270 | stepResult = main.FALSE |
| 271 | utilities.assert_equals( expect=main.TRUE, |
| 272 | actual=stepResult, |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 273 | onpass="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update sucess", |
| 274 | onfail="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update failed" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 275 | main.Cluster.active( 0 ).CLI.log( "\"testcase3 end\"" ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 276 | |
| 277 | main.step( "Check for Errors or Exception in testcase3" ) |
| 278 | startStr = "testcase3 start" |
| 279 | endStr = "testcase3 end" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 280 | errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 281 | [ "ERROR", "EXCEPT" ], "s", |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 282 | 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" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 286 | bgplsConfig.Comments() |
| 287 | main.log.info( "Kill Scapy process" ) |
| 288 | bgplsConfig.Comments() |
| 289 | main.Scapy1.handle.sendline( "\x03" ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 290 | time.sleep( 90 ) # This Sleep time gives time for the socket to close. |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 291 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 292 | def CASE4( self, main ): |
| 293 | """ |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 294 | Verification of Links in existing topology |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 295 | """ |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 296 | import json |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 297 | import time |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 298 | import os |
| 299 | main.case( "Testcase 4: Verification of Links thats is discovered" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 300 | main.Cluster.active( 0 ).CLI.log( "\"testcase4 start\"" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 301 | 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() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 310 | app = bgplsConfig.apps() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 311 | bgplsConfig.ipValue( main.ipList, main.scapy_ip ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 312 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 313 | bgplsConfig.Comments() |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 314 | main.log.info( "Sending BGPLS Link information Packet " ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 315 | bgplsConfig.Comments() |
| 316 | |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 317 | main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Link_Update_Node.py" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 318 | bgplsConfig.Comments() |
| 319 | main.log.info( "Enable BGPlS plugin in ONOS" ) |
| 320 | bgplsConfig.Comments() |
| 321 | |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 322 | main.step( "UnInstall onos-app-bgp" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 323 | installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 324 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 325 | onpass="Uninstall onos-app-bgp successful", |
| 326 | onfail="Uninstall onos-app-bgp failed" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 327 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 328 | installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 329 | 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" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 333 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 334 | main.step( "Checking the Link Discovery Status" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 335 | bgplsConfig.Comments() |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 336 | time.sleep( 120 ) # Time taken to discovery the links |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 337 | response = main.Cluster.active( 0 ).CLI.links() |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 338 | linksResp = json.loads( response ) |
| 339 | check_link = bgplsConfig.checkLinks( linksResp ) |
Devin Lim | 3d60b44 | 2017-08-03 17:59:56 -0700 | [diff] [blame] | 340 | reply_Check_Link = main.FALSE |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 341 | if check_link: |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 342 | reply_Check_Link = main.TRUE |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 343 | utilities.assert_equals( expect=main.TRUE, actual=reply_Check_Link, |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 344 | onpass="Link Discovery Success.", |
| 345 | onfail="Link Discovery Failed." ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 346 | main.Cluster.active( 0 ).CLI.log( "\"testcase4 end\"" ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 347 | |
| 348 | main.step( "Check for Errors or Exception in testcase4 " ) |
| 349 | startStr = "testcase4 start" |
| 350 | endStr = "testcase4 end" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 351 | errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 352 | [ "ERROR", "EXCEPT" ], "s", |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 353 | startStr, endStr ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 354 | utilities.assert_equals( expect=0, actual=errorLog, |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 355 | onpass="No Exception or Error occured in testcase4", |
| 356 | onfail="Exception or Error occured in testcase4" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 357 | bgplsConfig.Comments() |
| 358 | main.log.info( "Kill Scapy process" ) |
| 359 | bgplsConfig.Comments() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 360 | main.Scapy1.handle.sendline( "\x03" ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 361 | time.sleep( 90 ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 362 | |
| 363 | def CASE5( self, main ): |
| 364 | """ |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 365 | 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 Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 371 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 372 | main.Cluster.active( 0 ).CLI.log( "\"testcase5 start\"" ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 373 | 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 Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 383 | bgplsConfig.ipValue( main.ipList, main.scapy_ip ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 384 | |
| 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 Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 391 | main.log.info( "Enable BGPlS plugin in ONOS " ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 392 | bgplsConfig.Comments() |
| 393 | |
| 394 | main.step( "UnInstall onos-app-bgp" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 395 | installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 396 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 397 | onpass="Uninstall onos-app-bgp successful", |
| 398 | onfail="Uninstall onos-app-bgp failed" ) |
| 399 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 400 | installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 401 | 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 Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 406 | main.step( "Checking whether the links is deleted" ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 407 | bgplsConfig.Comments() |
| 408 | time.sleep( 120 ) # Time taken to discovery the links |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 409 | response = main.Cluster.active( 0 ).CLI.links() |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 410 | linksResp = json.loads( response ) |
| 411 | check_link = bgplsConfig.checkLinks( linksResp ) |
Devin Lim | 3d60b44 | 2017-08-03 17:59:56 -0700 | [diff] [blame] | 412 | reply_Check_Link = main.FALSE |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 413 | if not check_link: |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 414 | reply_Check_Link = main.TRUE |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 415 | utilities.assert_equals( expect=main.TRUE, actual=reply_Check_Link, |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 416 | onpass="Link is Deleted Successfully.", |
| 417 | onfail="Link is Deletion Failed." ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 418 | main.Cluster.active( 0 ).CLI.log( "\"testcase5 end\"" ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 419 | |
| 420 | main.step( "Check for Errors or Exception in testcase5" ) |
| 421 | startStr = "testcase5 start" |
| 422 | endStr = "testcase5 end" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 423 | errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 424 | [ "ERROR", "EXCEPT" ], "s", |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 425 | 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" ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 429 | 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 | """ |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 437 | Uninstalling the app |
| 438 | """ |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 439 | import os |
| 440 | import sys |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 441 | import re |
| 442 | import time |
| 443 | |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 444 | main.case( "TestCase 6: UnInstalling of app" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 445 | main.Cluster.active( 0 ).CLI.log( "\"testcase6 start\"" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 446 | 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() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 456 | |
| 457 | bgplsConfig = BgpLs() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 458 | bgplsConfig.ipValue( main.ipList, main.scapy_ip ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 459 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 460 | main.testSetUp.createApplyCell( main.Cluster, True, main.cellName, main.scapy_ip, True, main.ipList ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 461 | bgplsConfig.Comments() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 462 | main.testSetUp.startOnosClis( main.Cluster ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 463 | bgplsConfig.Comments() |
| 464 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 465 | main.log.info( "Uninstall onos-app-bgp" ) |
| 466 | bgplsConfig.Comments() |
| 467 | main.step( "UnInstall onos-app-bgp" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 468 | installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 469 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 470 | onpass="Uninstall onos-app-bgp successful", |
| 471 | onfail="Uninstall onos-app-bgp failed" ) |
| 472 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 473 | main.Cluster.active( 0 ).CLI.log( "\"testcase6 end\"" ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 474 | main.step( "Check for Errors or Exception in testcase6" ) |
| 475 | startStr = "testcase6 start" |
| 476 | endStr = "testcase6 end" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 477 | errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 478 | [ "ERROR", "EXCEPT" ], "s", |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 479 | 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 Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 485 | errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 486 | [ "ERROR", "EXCEPT" ] ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 487 | utilities.assert_equals( expect=0, actual=errorLog, |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 488 | onpass="No Exception or Error occured", |
Chiyu Cheng | ef10950 | 2016-11-21 15:51:38 -0800 | [diff] [blame] | 489 | onfail="Exception or Error occured" ) |