AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 1 | """ |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 2 | Copyright 2016 Open Networking Foundation ( ONF ) |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 3 | |
| 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| 7 | |
| 8 | TestON is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 2 of the License, or |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 11 | ( at your option ) any later version. |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 12 | |
| 13 | TestON is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 20 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 21 | **** Scripted by Antony Silvester - antony.silvester@huawei.com ****** |
| 22 | |
| 23 | |
| 24 | This Test check the bgp_ls functionality |
| 25 | |
| 26 | List of test cases: |
| 27 | CASE1: Compile ONOS and push it to the test machines |
| 28 | CASE2: Discovery the topology using BGPLS |
| 29 | CASE3: Addition of new Node to existing topology |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 30 | CASE4: Verification of Links thats is discovered" |
| 31 | CASE5: Deletion of Links |
| 32 | Case6: Uninstalling the app |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 33 | |
| 34 | |
| 35 | """ |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 36 | class FUNCbgpls: |
| 37 | |
| 38 | def __init__( self ): |
| 39 | self.default = '' |
| 40 | |
| 41 | def CASE1( self, main ): |
| 42 | """ |
| 43 | CASE1 is to compile ONOS and push it to the test machines |
| 44 | |
| 45 | Startup sequence: |
| 46 | cell <name> |
| 47 | onos-verify-cell |
| 48 | NOTE: temporary - onos-remove-raft-logs |
| 49 | onos-uninstall |
| 50 | git pull |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 51 | onos-package |
| 52 | onos-install -f |
| 53 | onos-wait-for-start |
| 54 | start cli sessions |
| 55 | start BGPLS apps |
| 56 | |
| 57 | """ |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 58 | import os |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 59 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 60 | main.log.info( "ONOS Single node start " + |
| 61 | "Scapy Tool - initialization" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 62 | try: |
| 63 | from tests.dependencies.ONOSSetup import ONOSSetup |
| 64 | main.testSetUp = ONOSSetup() |
| 65 | except ImportError: |
| 66 | main.log.error( "ONOSSetup not found. exiting the test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 67 | main.cleanAndExit() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 68 | main.testSetUp.envSetupDescription() |
| 69 | try: |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 70 | main.cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 71 | main.ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 72 | main.scapy_ip = os.getenv( main.params[ 'SCAPY' ][ 'HOSTNAMES' ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 73 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 74 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 75 | stepResult = main.testSetUp.envSetup() |
| 76 | except Exception as e: |
| 77 | main.testSetUp.envSetupException( e ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 78 | |
You Wang | a0f6ff6 | 2018-01-11 15:46:30 -0800 | [diff] [blame] | 79 | cliResults = main.testSetUp.ONOSSetUp( main.Cluster, cellName=main.cellName, |
| 80 | mininetIp=main.scapy_ip, removeLog=True ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 81 | main.step( "App Ids check" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 82 | appCheck = main.Cluster.active( 0 ).CLI.appToIDCheck() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 83 | |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 84 | if appCheck != main.TRUE: |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 85 | main.log.warn( main.Cluster.active( 0 ).CLI.apps() ) |
| 86 | main.log.warn( main.Cluster.active( 0 ).CLI.appIDs() ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 87 | utilities.assert_equals( expect=main.TRUE, actual=appCheck, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 88 | onpass="App Ids seem to be correct", |
| 89 | onfail="Something is wrong with app Ids" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 90 | if cliResults == main.FALSE: |
| 91 | main.log.error( "Failed to start ONOS,stopping test" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 92 | main.cleanAndExit() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 93 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 94 | def CASE2( self, main ): |
| 95 | """ |
| 96 | Discovery the topology using BGPLS |
| 97 | """ |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 98 | import os |
| 99 | import sys |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 100 | import re |
| 101 | import time |
| 102 | |
| 103 | main.case( "Testcase 2 : Discovery the Network Topology using BGPLS" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 104 | main.Cluster.active( 0 ).CLI.log( "\"testcase2 start\"" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 105 | |
| 106 | try: |
| 107 | from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs |
| 108 | except ImportError: |
| 109 | main.log.exception( "Something wrong with import file or code error." ) |
| 110 | main.log.info( "Import Error, please check!" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 111 | main.cleanAndExit() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 112 | |
| 113 | bgplsConfig = BgpLs() |
| 114 | Ne_id = bgplsConfig.Constants() |
| 115 | app = bgplsConfig.apps() |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 116 | httpport = main.params[ 'HTTP' ][ 'port' ] |
| 117 | path = main.params[ 'HTTP' ][ 'path' ] |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 118 | bgplsConfig.ipValue( main.ipList, main.scapy_ip ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 119 | |
| 120 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 121 | main.log.info( "Sending BGPLS information" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 122 | bgplsConfig.Comments() |
| 123 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 124 | main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\ |
| 125 | dependencies/Scapyfiles/Topo_discovery.py" ) |
| 126 | bgplsConfig.Comments() |
| 127 | main.log.info( "Enable BGPlS plugin in ONOS" ) |
| 128 | bgplsConfig.Comments() |
| 129 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 130 | main.testSetUp.startOnosClis( main.Cluster ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 131 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 132 | installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 133 | main.step( "Install onos-app-bgp" ) |
| 134 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 135 | onpass="Install onos-app-bgp successful", |
| 136 | onfail="Install onos-app-bgp failed" ) |
| 137 | |
| 138 | bgpls_post = bgplsConfig.DictoJson() |
| 139 | |
| 140 | bgplsConfig.Comments() |
| 141 | main.log.info( "BGPLS RestConf input" ) |
| 142 | bgplsConfig.Comments() |
| 143 | |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 144 | print ( bgpls_post ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 145 | 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] | 146 | main.step( "Configure BGP through RESTCONF" ) |
| 147 | |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 148 | utilities.assert_equals( expect='200', |
| 149 | actual=Poststatus, |
| 150 | onpass="Post Port Success", |
| 151 | onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 152 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 153 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 154 | main.step( "Check Network devices are Updated in ONOS " ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 155 | bgplsConfig.Comments() |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 156 | time.sleep( 15 ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 157 | response = main.Cluster.active( 0 ).CLI.devices() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 158 | responseCheck = main.FALSE |
| 159 | if response: |
| 160 | responseCheck = main.TRUE |
| 161 | utilities.assert_equals( expect=main.TRUE, |
| 162 | actual=responseCheck, |
| 163 | onpass="Network Devices update in ONOS successful", |
| 164 | onfail="Network Devices update in ONOS failed" ) |
| 165 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 166 | main.step( "Check the nodes are discovered" ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 167 | 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] | 168 | stepResult = main.TRUE |
| 169 | else: |
| 170 | stepResult = main.FALSE |
| 171 | utilities.assert_equals( expect=main.TRUE, |
| 172 | actual=stepResult, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 173 | onpass="Node " + str( Ne_id[ 1 ][ 0 ] ) + ( Ne_id[ 1 ][ 1 ] ) + ( Ne_id[ 1 ][ 2 ] ) + " sucess", |
| 174 | onfail="Node " + str( Ne_id[ 1 ][ 0 ] ) + ( Ne_id[ 1 ][ 1 ] ) + ( Ne_id[ 1 ][ 2 ] ) + " failed" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 175 | main.Cluster.active( 0 ).CLI.log( "\"testcase2 end\"" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 176 | |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 177 | main.step( "Check for Errors or Exception in testcase2" ) |
| 178 | startStr = "testcase2 start" |
| 179 | endStr = "testcase2 end" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 180 | errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 181 | [ "ERROR", "EXCEPT" ], "s", |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 182 | startStr, endStr ) |
| 183 | utilities.assert_equals( expect=0, actual=errorLog, |
| 184 | onpass="No Exception or Error occured in testcase2", |
| 185 | onfail="Exception or Error occured in testcase2" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 186 | bgplsConfig.Comments() |
| 187 | main.log.info( "Kill Scapy process" ) |
| 188 | bgplsConfig.Comments() |
| 189 | |
| 190 | main.Scapy1.handle.sendline( "\x03" ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 191 | time.sleep( 90 ) # This Sleep time gives time for the socket to close. |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 192 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 193 | def CASE3( self, main ): |
| 194 | """ |
| 195 | Addition of new Node to existing topology |
| 196 | """ |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 197 | import os |
| 198 | import sys |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 199 | import re |
| 200 | import time |
| 201 | |
| 202 | main.case( "Testcase 3: Addition of New Node to existing topology" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 203 | main.Cluster.active( 0 ).CLI.log( "\"testcase3 start\"" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 204 | try: |
| 205 | from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs |
| 206 | except ImportError: |
| 207 | main.log.exception( "Something wrong with import file or code error." ) |
| 208 | main.log.info( "Import Error, please check!" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 209 | main.cleanAndExit() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 210 | |
| 211 | bgplsConfig = BgpLs() |
| 212 | Ne_id = bgplsConfig.Constants() |
| 213 | app = bgplsConfig.apps() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 214 | |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 215 | httpport = main.params[ 'HTTP' ][ 'port' ] |
| 216 | path = main.params[ 'HTTP' ][ 'path' ] |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 217 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 218 | bgplsConfig.ipValue( main.ipList, main.scapy_ip ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 219 | |
| 220 | bgplsConfig.Comments() |
| 221 | main.log.info( "Sending BGPLS Packet " ) |
| 222 | bgplsConfig.Comments() |
| 223 | |
| 224 | main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\ |
| 225 | dependencies/Scapyfiles/Update_Node.py" ) |
| 226 | bgplsConfig.Comments() |
| 227 | main.log.info( "Enable BGPlS plugin in ONOS" ) |
| 228 | bgplsConfig.Comments() |
| 229 | |
| 230 | main.step( "UnInstall onos-app-bgp" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 231 | installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 232 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 233 | onpass="Uninstall onos-app-bgp successful", |
| 234 | onfail="Uninstall onos-app-bgp failed" ) |
| 235 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 236 | installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 237 | main.step( "Install onos-app-bgp" ) |
| 238 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 239 | onpass="Install onos-app-bgp successful", |
| 240 | onfail="Install onos-app-bgp failed" ) |
| 241 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 242 | bgpls_post = bgplsConfig.DictoJson() |
| 243 | |
| 244 | bgplsConfig.Comments() |
| 245 | main.log.info( "BGPLS RestConf input" ) |
| 246 | bgplsConfig.Comments() |
| 247 | |
| 248 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 249 | main.step( "Check Network devices are Updated in ONOS" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 250 | bgplsConfig.Comments() |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 251 | time.sleep( 120 ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 252 | response = main.Cluster.active( 0 ).CLI.devices() |
Devin Lim | 3d60b44 | 2017-08-03 17:59:56 -0700 | [diff] [blame] | 253 | |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 254 | responseCheck = main.FALSE |
| 255 | if response: |
| 256 | responseCheck = main.TRUE |
| 257 | utilities.assert_equals( expect=main.TRUE, |
| 258 | actual=responseCheck, |
| 259 | onpass="Network Devices update in ONOS successful", |
| 260 | onfail="Network Devices update in ONOS failed" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 261 | main.step( "Check Newly added Node is getting updated" ) |
| 262 | |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 263 | if response.find( Ne_id[ 1 ][ 3 ] ) != -1: |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 264 | stepResult = main.TRUE |
| 265 | else: |
| 266 | stepResult = main.FALSE |
| 267 | utilities.assert_equals( expect=main.TRUE, |
| 268 | actual=stepResult, |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 269 | onpass="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update sucess", |
| 270 | onfail="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update failed" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 271 | main.Cluster.active( 0 ).CLI.log( "\"testcase3 end\"" ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 272 | |
| 273 | main.step( "Check for Errors or Exception in testcase3" ) |
| 274 | startStr = "testcase3 start" |
| 275 | endStr = "testcase3 end" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 276 | errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 277 | [ "ERROR", "EXCEPT" ], "s", |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 278 | startStr, endStr ) |
| 279 | utilities.assert_equals( expect=0, actual=errorLog, |
| 280 | onpass="No Exception or Error occured in testcase3", |
| 281 | onfail="Exception or Error occured in testcase3" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 282 | bgplsConfig.Comments() |
| 283 | main.log.info( "Kill Scapy process" ) |
| 284 | bgplsConfig.Comments() |
| 285 | main.Scapy1.handle.sendline( "\x03" ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 286 | time.sleep( 90 ) # This Sleep time gives time for the socket to close. |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 287 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 288 | def CASE4( self, main ): |
| 289 | """ |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 290 | Verification of Links in existing topology |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 291 | """ |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 292 | import json |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 293 | import time |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 294 | import os |
| 295 | main.case( "Testcase 4: Verification of Links thats is discovered" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 296 | main.Cluster.active( 0 ).CLI.log( "\"testcase4 start\"" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 297 | try: |
| 298 | from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs |
| 299 | except ImportError: |
| 300 | main.log.exception( "Something wrong with import file or code error." ) |
| 301 | main.log.info( "Import Error, please check!" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 302 | main.cleanAndExit() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 303 | |
| 304 | bgplsConfig = BgpLs() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 305 | app = bgplsConfig.apps() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 306 | bgplsConfig.ipValue( main.ipList, main.scapy_ip ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 307 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 308 | bgplsConfig.Comments() |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 309 | main.log.info( "Sending BGPLS Link information Packet " ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 310 | bgplsConfig.Comments() |
| 311 | |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 312 | 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] | 313 | bgplsConfig.Comments() |
| 314 | main.log.info( "Enable BGPlS plugin in ONOS" ) |
| 315 | bgplsConfig.Comments() |
| 316 | |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 317 | main.step( "UnInstall onos-app-bgp" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 318 | installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 319 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 320 | onpass="Uninstall onos-app-bgp successful", |
| 321 | onfail="Uninstall onos-app-bgp failed" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 322 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 323 | installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 324 | main.step( "Install onos-app-bgp" ) |
| 325 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 326 | onpass="Install onos-app-bgp successful", |
| 327 | onfail="Install onos-app-bgp failed" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 328 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 329 | main.step( "Checking the Link Discovery Status" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 330 | bgplsConfig.Comments() |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 331 | time.sleep( 120 ) # Time taken to discovery the links |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 332 | response = main.Cluster.active( 0 ).CLI.links() |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 333 | linksResp = json.loads( response ) |
| 334 | check_link = bgplsConfig.checkLinks( linksResp ) |
Devin Lim | 3d60b44 | 2017-08-03 17:59:56 -0700 | [diff] [blame] | 335 | reply_Check_Link = main.FALSE |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 336 | if check_link: |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 337 | reply_Check_Link = main.TRUE |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 338 | utilities.assert_equals( expect=main.TRUE, actual=reply_Check_Link, |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 339 | onpass="Link Discovery Success.", |
| 340 | onfail="Link Discovery Failed." ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 341 | main.Cluster.active( 0 ).CLI.log( "\"testcase4 end\"" ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 342 | |
| 343 | main.step( "Check for Errors or Exception in testcase4 " ) |
| 344 | startStr = "testcase4 start" |
| 345 | endStr = "testcase4 end" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 346 | errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 347 | [ "ERROR", "EXCEPT" ], "s", |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 348 | startStr, endStr ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 349 | utilities.assert_equals( expect=0, actual=errorLog, |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 350 | onpass="No Exception or Error occured in testcase4", |
| 351 | onfail="Exception or Error occured in testcase4" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 352 | bgplsConfig.Comments() |
| 353 | main.log.info( "Kill Scapy process" ) |
| 354 | bgplsConfig.Comments() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 355 | main.Scapy1.handle.sendline( "\x03" ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 356 | time.sleep( 90 ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 357 | |
| 358 | def CASE5( self, main ): |
| 359 | """ |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 360 | Deletion of links |
| 361 | """ |
| 362 | import json |
| 363 | import time |
| 364 | import os |
| 365 | main.case( "Testcase 5: Deletion of Link in existing topology" ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 366 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 367 | main.Cluster.active( 0 ).CLI.log( "\"testcase5 start\"" ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 368 | try: |
| 369 | from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs |
| 370 | except ImportError: |
| 371 | main.log.exception( "Something wrong with import file or code error." ) |
| 372 | main.log.info( "Import Error, please check!" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 373 | main.cleanAndExit() |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 374 | |
| 375 | bgplsConfig = BgpLs() |
| 376 | app = bgplsConfig.apps() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 377 | bgplsConfig.ipValue( main.ipList, main.scapy_ip ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 378 | |
| 379 | bgplsConfig.Comments() |
| 380 | main.log.info( "Sending BGPLS Delete Link Packet " ) |
| 381 | bgplsConfig.Comments() |
| 382 | |
| 383 | main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py" ) |
| 384 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 385 | main.log.info( "Enable BGPlS plugin in ONOS " ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 386 | bgplsConfig.Comments() |
| 387 | |
| 388 | main.step( "UnInstall onos-app-bgp" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 389 | installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 390 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 391 | onpass="Uninstall onos-app-bgp successful", |
| 392 | onfail="Uninstall onos-app-bgp failed" ) |
| 393 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 394 | installResults = main.Cluster.active( 0 ).CLI.activateApp( app[ 0 ] ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 395 | main.step( "Install onos-app-bgp" ) |
| 396 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 397 | onpass="Install onos-app-bgp successful", |
| 398 | onfail="Install onos-app-bgp failed" ) |
| 399 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 400 | main.step( "Checking whether the links is deleted" ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 401 | bgplsConfig.Comments() |
| 402 | time.sleep( 120 ) # Time taken to discovery the links |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 403 | response = main.Cluster.active( 0 ).CLI.links() |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 404 | linksResp = json.loads( response ) |
| 405 | check_link = bgplsConfig.checkLinks( linksResp ) |
Devin Lim | 3d60b44 | 2017-08-03 17:59:56 -0700 | [diff] [blame] | 406 | reply_Check_Link = main.FALSE |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 407 | if not check_link: |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 408 | reply_Check_Link = main.TRUE |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 409 | utilities.assert_equals( expect=main.TRUE, actual=reply_Check_Link, |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 410 | onpass="Link is Deleted Successfully.", |
| 411 | onfail="Link is Deletion Failed." ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 412 | main.Cluster.active( 0 ).CLI.log( "\"testcase5 end\"" ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 413 | |
| 414 | main.step( "Check for Errors or Exception in testcase5" ) |
| 415 | startStr = "testcase5 start" |
| 416 | endStr = "testcase5 end" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 417 | errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 418 | [ "ERROR", "EXCEPT" ], "s", |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 419 | startStr, endStr ) |
| 420 | utilities.assert_equals( expect=0, actual=errorLog, |
| 421 | onpass="No Exception or Error occured in testcase5", |
| 422 | onfail="Exception or Error occured in testcase5" ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 423 | bgplsConfig.Comments() |
| 424 | main.log.info( "Kill Scapy process" ) |
| 425 | bgplsConfig.Comments() |
| 426 | main.Scapy1.handle.sendline( "\x03" ) |
| 427 | time.sleep( 90 ) |
| 428 | |
| 429 | def CASE6( self, main ): |
| 430 | """ |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 431 | Uninstalling the app |
| 432 | """ |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 433 | import os |
| 434 | import sys |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 435 | import re |
| 436 | import time |
| 437 | |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 438 | main.case( "TestCase 6: UnInstalling of app" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 439 | main.Cluster.active( 0 ).CLI.log( "\"testcase6 start\"" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 440 | try: |
| 441 | from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs |
| 442 | except ImportError: |
| 443 | main.log.exception( "Something wrong with import file or code error." ) |
| 444 | main.log.info( "Import Error, please check!" ) |
Devin Lim | 4407596 | 2017-08-11 10:56:37 -0700 | [diff] [blame] | 445 | main.cleanAndExit() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 446 | |
| 447 | bgplsConfig = BgpLs() |
| 448 | app = bgplsConfig.apps() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 449 | |
| 450 | bgplsConfig = BgpLs() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 451 | bgplsConfig.ipValue( main.ipList, main.scapy_ip ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 452 | |
You Wang | 09b596b | 2018-01-10 10:42:38 -0800 | [diff] [blame] | 453 | main.testSetUp.createApplyCell( main.Cluster, True, main.cellName, main.apps, main.scapy_ip, True, main.ipList ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 454 | bgplsConfig.Comments() |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 455 | main.testSetUp.startOnosClis( main.Cluster ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 456 | bgplsConfig.Comments() |
| 457 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 458 | main.log.info( "Uninstall onos-app-bgp" ) |
| 459 | bgplsConfig.Comments() |
| 460 | main.step( "UnInstall onos-app-bgp" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 461 | installResults = main.Cluster.active( 0 ).CLI.deactivateApp( app[ 0 ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 462 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 463 | onpass="Uninstall onos-app-bgp successful", |
| 464 | onfail="Uninstall onos-app-bgp failed" ) |
| 465 | |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 466 | main.Cluster.active( 0 ).CLI.log( "\"testcase6 end\"" ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 467 | main.step( "Check for Errors or Exception in testcase6" ) |
| 468 | startStr = "testcase6 start" |
| 469 | endStr = "testcase6 end" |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 470 | errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 471 | [ "ERROR", "EXCEPT" ], "s", |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 472 | startStr, endStr ) |
| 473 | utilities.assert_equals( expect=0, actual=errorLog, |
| 474 | onpass="No Exception or Error occured in testcase6", |
| 475 | onfail="Exception or Error occured in testcase6" ) |
| 476 | |
| 477 | main.step( "Check for Errors or Exception End of the Script" ) |
Devin Lim | 142b534 | 2017-07-20 15:22:39 -0700 | [diff] [blame] | 478 | errorLog = main.ONOSbench.logReport( main.Cluster.active( 0 ).ipAddress, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 479 | [ "ERROR", "EXCEPT" ] ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 480 | utilities.assert_equals( expect=0, actual=errorLog, |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 481 | onpass="No Exception or Error occured", |
Chiyu Cheng | ef10950 | 2016-11-21 15:51:38 -0800 | [diff] [blame] | 482 | onfail="Exception or Error occured" ) |