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" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 68 | main.cleanAndExit() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 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" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 93 | main.cleanAndExit() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 94 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 95 | def CASE2( self, main ): |
| 96 | """ |
| 97 | Discovery the topology using BGPLS |
| 98 | """ |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 99 | import os |
| 100 | import sys |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 101 | import re |
| 102 | import time |
| 103 | |
| 104 | main.case( "Testcase 2 : Discovery the Network Topology using BGPLS" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 105 | main.Cluster.active( 0 ).CLI.log( "\"testcase2 start\"" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 106 | |
| 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 Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 112 | main.cleanAndExit() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 113 | |
| 114 | bgplsConfig = BgpLs() |
| 115 | Ne_id = bgplsConfig.Constants() |
| 116 | app = bgplsConfig.apps() |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 117 | httpport = main.params[ 'HTTP' ][ 'port' ] |
| 118 | path = main.params[ 'HTTP' ][ 'path' ] |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 119 | bgplsConfig.ipValue( main.ipList, main.scapy_ip ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 120 | |
| 121 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 122 | main.log.info( "Sending BGPLS information" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 123 | bgplsConfig.Comments() |
| 124 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 125 | 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 Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 131 | main.testSetUp.startOnosClis( main.Cluster ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 132 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 133 | installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 134 | 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 Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 145 | print ( bgpls_post ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 146 | 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] | 147 | main.step( "Configure BGP through RESTCONF" ) |
| 148 | |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 149 | utilities.assert_equals( expect='200', |
| 150 | actual=Poststatus, |
| 151 | onpass="Post Port Success", |
| 152 | onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 153 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 154 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 155 | main.step( "Check Network devices are Updated in ONOS " ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 156 | bgplsConfig.Comments() |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 157 | time.sleep( 15 ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 158 | response = main.Cluster.active( 0 ).CLI.devices() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 159 | 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 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 167 | main.step( "Check the nodes are discovered" ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 168 | 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] | 169 | stepResult = main.TRUE |
| 170 | else: |
| 171 | stepResult = main.FALSE |
| 172 | utilities.assert_equals( expect=main.TRUE, |
| 173 | actual=stepResult, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 174 | 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 Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 176 | main.Cluster.active( 0 ).CLI.log( "\"testcase2 end\"" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 177 | |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 178 | main.step( "Check for Errors or Exception in testcase2" ) |
| 179 | startStr = "testcase2 start" |
| 180 | endStr = "testcase2 end" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 181 | errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 182 | [ "ERROR", "EXCEPT" ], "s", |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 183 | 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" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 187 | bgplsConfig.Comments() |
| 188 | main.log.info( "Kill Scapy process" ) |
| 189 | bgplsConfig.Comments() |
| 190 | |
| 191 | main.Scapy1.handle.sendline( "\x03" ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 192 | time.sleep( 90 ) # This Sleep time gives time for the socket to close. |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 193 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 194 | def CASE3( self, main ): |
| 195 | """ |
| 196 | Addition of new Node to existing topology |
| 197 | """ |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 198 | import os |
| 199 | import sys |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 200 | import re |
| 201 | import time |
| 202 | |
| 203 | main.case( "Testcase 3: Addition of New Node to existing topology" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 204 | main.Cluster.active( 0 ).CLI.log( "\"testcase3 start\"" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 205 | 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 Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 210 | main.cleanAndExit() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 211 | |
| 212 | bgplsConfig = BgpLs() |
| 213 | Ne_id = bgplsConfig.Constants() |
| 214 | app = bgplsConfig.apps() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 215 | |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 216 | httpport = main.params[ 'HTTP' ][ 'port' ] |
| 217 | path = main.params[ 'HTTP' ][ 'path' ] |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 218 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 219 | bgplsConfig.ipValue( main.ipList, main.scapy_ip ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 220 | |
| 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 Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 232 | installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 233 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 234 | onpass="Uninstall onos-app-bgp successful", |
| 235 | onfail="Uninstall onos-app-bgp failed" ) |
| 236 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 237 | installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 238 | 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 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 243 | bgpls_post = bgplsConfig.DictoJson() |
| 244 | |
| 245 | bgplsConfig.Comments() |
| 246 | main.log.info( "BGPLS RestConf input" ) |
| 247 | bgplsConfig.Comments() |
| 248 | |
| 249 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 250 | main.step( "Check Network devices are Updated in ONOS" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 251 | bgplsConfig.Comments() |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 252 | time.sleep( 120 ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 253 | response = main.Cluster.active( 0 ).CLI.devices() |
Devin Lim | 3d60b44 | 2017-08-03 17:59:56 -0700 | [diff] [blame] | 254 | |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 255 | 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" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 262 | main.step( "Check Newly added Node is getting updated" ) |
| 263 | |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 264 | if response.find( Ne_id[ 1 ][ 3 ] ) != -1: |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 265 | stepResult = main.TRUE |
| 266 | else: |
| 267 | stepResult = main.FALSE |
| 268 | utilities.assert_equals( expect=main.TRUE, |
| 269 | actual=stepResult, |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 270 | onpass="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update sucess", |
| 271 | onfail="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update failed" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 272 | main.Cluster.active( 0 ).CLI.log( "\"testcase3 end\"" ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 273 | |
| 274 | main.step( "Check for Errors or Exception in testcase3" ) |
| 275 | startStr = "testcase3 start" |
| 276 | endStr = "testcase3 end" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 277 | errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 278 | [ "ERROR", "EXCEPT" ], "s", |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 279 | 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" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 283 | bgplsConfig.Comments() |
| 284 | main.log.info( "Kill Scapy process" ) |
| 285 | bgplsConfig.Comments() |
| 286 | main.Scapy1.handle.sendline( "\x03" ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 287 | time.sleep( 90 ) # This Sleep time gives time for the socket to close. |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 288 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 289 | def CASE4( self, main ): |
| 290 | """ |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 291 | Verification of Links in existing topology |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 292 | """ |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 293 | import json |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 294 | import time |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 295 | import os |
| 296 | main.case( "Testcase 4: Verification of Links thats is discovered" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 297 | main.Cluster.active( 0 ).CLI.log( "\"testcase4 start\"" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 298 | 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 Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 303 | main.cleanAndExit() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 304 | |
| 305 | bgplsConfig = BgpLs() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 306 | app = bgplsConfig.apps() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 307 | bgplsConfig.ipValue( main.ipList, main.scapy_ip ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 308 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 309 | bgplsConfig.Comments() |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 310 | main.log.info( "Sending BGPLS Link information Packet " ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 311 | bgplsConfig.Comments() |
| 312 | |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 313 | 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] | 314 | bgplsConfig.Comments() |
| 315 | main.log.info( "Enable BGPlS plugin in ONOS" ) |
| 316 | bgplsConfig.Comments() |
| 317 | |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 318 | main.step( "UnInstall onos-app-bgp" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 319 | installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 320 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 321 | onpass="Uninstall onos-app-bgp successful", |
| 322 | onfail="Uninstall onos-app-bgp failed" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 323 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 324 | installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 325 | 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" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 329 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 330 | main.step( "Checking the Link Discovery Status" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 331 | bgplsConfig.Comments() |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 332 | time.sleep( 120 ) # Time taken to discovery the links |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 333 | response = main.Cluster.active( 0 ).CLI.links() |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 334 | linksResp = json.loads( response ) |
| 335 | check_link = bgplsConfig.checkLinks( linksResp ) |
Devin Lim | 3d60b44 | 2017-08-03 17:59:56 -0700 | [diff] [blame] | 336 | reply_Check_Link = main.FALSE |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 337 | if check_link: |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 338 | reply_Check_Link = main.TRUE |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 339 | utilities.assert_equals( expect=main.TRUE, actual=reply_Check_Link, |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 340 | onpass="Link Discovery Success.", |
| 341 | onfail="Link Discovery Failed." ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 342 | main.Cluster.active( 0 ).CLI.log( "\"testcase4 end\"" ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 343 | |
| 344 | main.step( "Check for Errors or Exception in testcase4 " ) |
| 345 | startStr = "testcase4 start" |
| 346 | endStr = "testcase4 end" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 347 | errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 348 | [ "ERROR", "EXCEPT" ], "s", |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 349 | startStr, endStr ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 350 | utilities.assert_equals( expect=0, actual=errorLog, |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 351 | onpass="No Exception or Error occured in testcase4", |
| 352 | onfail="Exception or Error occured in testcase4" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 353 | bgplsConfig.Comments() |
| 354 | main.log.info( "Kill Scapy process" ) |
| 355 | bgplsConfig.Comments() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 356 | main.Scapy1.handle.sendline( "\x03" ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 357 | time.sleep( 90 ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 358 | |
| 359 | def CASE5( self, main ): |
| 360 | """ |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 361 | 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 Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 367 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 368 | main.Cluster.active( 0 ).CLI.log( "\"testcase5 start\"" ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 369 | 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 Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 374 | main.cleanAndExit() |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 375 | |
| 376 | bgplsConfig = BgpLs() |
| 377 | app = bgplsConfig.apps() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 378 | bgplsConfig.ipValue( main.ipList, main.scapy_ip ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 379 | |
| 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 Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 386 | main.log.info( "Enable BGPlS plugin in ONOS " ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 387 | bgplsConfig.Comments() |
| 388 | |
| 389 | main.step( "UnInstall onos-app-bgp" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 390 | installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 391 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 392 | onpass="Uninstall onos-app-bgp successful", |
| 393 | onfail="Uninstall onos-app-bgp failed" ) |
| 394 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 395 | installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 396 | 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 Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 401 | main.step( "Checking whether the links is deleted" ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 402 | bgplsConfig.Comments() |
| 403 | time.sleep( 120 ) # Time taken to discovery the links |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 404 | response = main.Cluster.active( 0 ).CLI.links() |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 405 | linksResp = json.loads( response ) |
| 406 | check_link = bgplsConfig.checkLinks( linksResp ) |
Devin Lim | 3d60b44 | 2017-08-03 17:59:56 -0700 | [diff] [blame] | 407 | reply_Check_Link = main.FALSE |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 408 | if not check_link: |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 409 | reply_Check_Link = main.TRUE |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 410 | utilities.assert_equals( expect=main.TRUE, actual=reply_Check_Link, |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 411 | onpass="Link is Deleted Successfully.", |
| 412 | onfail="Link is Deletion Failed." ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 413 | main.Cluster.active( 0 ).CLI.log( "\"testcase5 end\"" ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 414 | |
| 415 | main.step( "Check for Errors or Exception in testcase5" ) |
| 416 | startStr = "testcase5 start" |
| 417 | endStr = "testcase5 end" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 418 | errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 419 | [ "ERROR", "EXCEPT" ], "s", |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 420 | 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" ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 424 | 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 | """ |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 432 | Uninstalling the app |
| 433 | """ |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 434 | import os |
| 435 | import sys |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 436 | import re |
| 437 | import time |
| 438 | |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 439 | main.case( "TestCase 6: UnInstalling of app" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 440 | main.Cluster.active( 0 ).CLI.log( "\"testcase6 start\"" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 441 | 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 Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 446 | main.cleanAndExit() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 447 | |
| 448 | bgplsConfig = BgpLs() |
| 449 | app = bgplsConfig.apps() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 450 | |
| 451 | bgplsConfig = BgpLs() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 452 | bgplsConfig.ipValue( main.ipList, main.scapy_ip ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 453 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 454 | 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] | 455 | bgplsConfig.Comments() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 456 | main.testSetUp.startOnosClis( main.Cluster ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 457 | bgplsConfig.Comments() |
| 458 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 459 | main.log.info( "Uninstall onos-app-bgp" ) |
| 460 | bgplsConfig.Comments() |
| 461 | main.step( "UnInstall onos-app-bgp" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 462 | installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 463 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 464 | onpass="Uninstall onos-app-bgp successful", |
| 465 | onfail="Uninstall onos-app-bgp failed" ) |
| 466 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 467 | main.Cluster.active( 0 ).CLI.log( "\"testcase6 end\"" ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 468 | main.step( "Check for Errors or Exception in testcase6" ) |
| 469 | startStr = "testcase6 start" |
| 470 | endStr = "testcase6 end" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 471 | errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 472 | [ "ERROR", "EXCEPT" ], "s", |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 473 | 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 Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 479 | errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 480 | [ "ERROR", "EXCEPT" ] ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 481 | utilities.assert_equals( expect=0, actual=errorLog, |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 482 | onpass="No Exception or Error occured", |
Chiyu Cheng | ef10950 | 2016-11-21 15:51:38 -0800 | [diff] [blame] | 483 | onfail="Exception or Error occured" ) |