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" ) |
| 63 | main.case( "Setting up test environment" ) |
| 64 | main.caseExplanation = "Setup the test environment including " +\ |
| 65 | "installing ONOS, start ONOS." |
| 66 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 67 | PULLCODE = False |
| 68 | if main.params[ 'GIT' ][ 'pull' ] == 'True': |
| 69 | PULLCODE = True |
| 70 | gitBranch = main.params[ 'GIT' ][ 'branch' ] |
| 71 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 72 | ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 73 | scapy_ip = os.getenv( main.params[ 'SCAPY' ][ 'HOSTNAMES' ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 74 | |
| 75 | main.log.info( "Removing raft logs" ) |
| 76 | main.ONOSbench.onosRemoveRaftLogs() |
| 77 | |
| 78 | main.CLIs = [] |
| 79 | main.nodes = [] |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 80 | main.numCtrls = 1 |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 81 | |
| 82 | for i in range( 1, main.numCtrls + 1 ): |
| 83 | try: |
| 84 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 85 | main.nodes.append( getattr( main, 'ONOS' + str( i ) ) ) |
| 86 | ipList.append( main.nodes[ -1 ].ip_address ) |
| 87 | except AttributeError: |
| 88 | break |
| 89 | |
| 90 | main.log.info( "Uninstalling ONOS" ) |
| 91 | for node in main.nodes: |
| 92 | main.ONOSbench.onosUninstall( node.ip_address ) |
| 93 | |
| 94 | main.step( "Create cell file" ) |
| 95 | cellAppString = main.params[ 'ENV' ][ 'cellApps' ] |
| 96 | |
| 97 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName, |
| 98 | scapy_ip, |
Devin Lim | dc78e20 | 2017-06-09 18:30:07 -0700 | [diff] [blame] | 99 | cellAppString, ipList, main.ONOScli1.karafUser ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 100 | |
| 101 | main.step( "Applying cell variable to environment" ) |
| 102 | cellResult = main.ONOSbench.setCell( cellName ) |
| 103 | |
| 104 | verifyResult = main.ONOSbench.verifyCell() |
| 105 | |
| 106 | # Make sure ONOS process is not running |
| 107 | main.log.info( "Killing any ONOS processes" ) |
| 108 | killResults = main.TRUE |
| 109 | for node in main.nodes: |
| 110 | killed = main.ONOSbench.onosKill( node.ip_address ) |
| 111 | killResults = killResults and killed |
| 112 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 113 | gitPullResult = main.FALSE |
| 114 | main.step( "Git checkout and pull" + gitBranch ) |
| 115 | if PULLCODE: |
| 116 | main.ONOSbench.gitCheckout( gitBranch ) |
| 117 | gitPullResult = main.ONOSbench.gitPull() |
| 118 | # values of 1 or 3 are good |
| 119 | utilities.assert_lesser( expect=0, actual=gitPullResult, |
| 120 | onpass="Git pull successful", |
| 121 | onfail="Git pull failed" ) |
| 122 | |
Devin Lim | 8d7c778 | 2017-06-07 16:21:20 -0700 | [diff] [blame] | 123 | main.ONOSbench.getVersion( report=True ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 124 | |
| 125 | main.step( "Creating ONOS package" ) |
Jon Hall | bd60ea0 | 2016-08-23 10:03:59 -0700 | [diff] [blame] | 126 | packageResult = main.ONOSbench.buckBuild() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 127 | utilities.assert_equals( expect=main.TRUE, |
| 128 | actual=packageResult, |
| 129 | onpass="Successfully created ONOS package", |
| 130 | onfail="Failed to create ONOS package" ) |
| 131 | |
| 132 | main.step( "Installing ONOS package" ) |
| 133 | onosInstallResult = main.ONOSbench.onosInstall( |
alison | b1a2652 | 2016-11-22 17:27:17 -0800 | [diff] [blame] | 134 | options="-f", node=main.nodes[ 0 ].ip_address ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 135 | utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult, |
| 136 | onpass="ONOS install successful", |
| 137 | onfail="ONOS install failed" ) |
| 138 | |
You Wang | f5de25b | 2017-01-06 15:13:01 -0800 | [diff] [blame] | 139 | main.step( "Set up ONOS secure SSH" ) |
| 140 | secureSshResult = main.ONOSbench.onosSecureSSH( node=main.nodes[ 0 ].ip_address ) |
| 141 | utilities.assert_equals( expect=main.TRUE, actual=secureSshResult, |
| 142 | onpass="Test step PASS", |
| 143 | onfail="Test step FAIL" ) |
| 144 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 145 | main.step( "Checking if ONOS is up yet" ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 146 | print main.nodes[ 0 ].ip_address |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 147 | for i in range( 2 ): |
alison | b1a2652 | 2016-11-22 17:27:17 -0800 | [diff] [blame] | 148 | onos1Isup = main.ONOSbench.isup( main.nodes[ 0 ].ip_address ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 149 | if onos1Isup: |
| 150 | break |
| 151 | utilities.assert_equals( expect=main.TRUE, actual=onos1Isup, |
| 152 | onpass="ONOS startup successful", |
| 153 | onfail="ONOS startup failed" ) |
Chiyu Cheng | ef10950 | 2016-11-21 15:51:38 -0800 | [diff] [blame] | 154 | |
Jon Hall | 6509dbf | 2016-06-21 17:01:17 -0700 | [diff] [blame] | 155 | main.step( "Starting ONOS CLI sessions" ) |
alison | b1a2652 | 2016-11-22 17:27:17 -0800 | [diff] [blame] | 156 | print main.nodes[ 0 ].ip_address |
| 157 | cliResults = main.ONOScli1.startOnosCli( main.nodes[ 0 ].ip_address ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 158 | utilities.assert_equals( expect=main.TRUE, actual=cliResults, |
| 159 | onpass="ONOS cli startup successful", |
| 160 | onfail="ONOS cli startup failed" ) |
| 161 | |
| 162 | main.step( "App Ids check" ) |
| 163 | appCheck = main.ONOScli1.appToIDCheck() |
| 164 | |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 165 | if appCheck != main.TRUE: |
alison | b1a2652 | 2016-11-22 17:27:17 -0800 | [diff] [blame] | 166 | main.log.warn( main.CLIs[ 0 ].apps() ) |
| 167 | main.log.warn( main.CLIs[ 0 ].appIDs() ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 168 | utilities.assert_equals( expect=main.TRUE, actual=appCheck, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 169 | onpass="App Ids seem to be correct", |
| 170 | onfail="Something is wrong with app Ids" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 171 | if cliResults == main.FALSE: |
| 172 | main.log.error( "Failed to start ONOS,stopping test" ) |
| 173 | main.cleanup() |
| 174 | main.exit() |
| 175 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 176 | def CASE2( self, main ): |
| 177 | """ |
| 178 | Discovery the topology using BGPLS |
| 179 | """ |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 180 | import os |
| 181 | import sys |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 182 | import re |
| 183 | import time |
| 184 | |
| 185 | main.case( "Testcase 2 : Discovery the Network Topology using BGPLS" ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 186 | main.ONOScli1.log( "\"testcase2 start\"" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 187 | |
| 188 | try: |
| 189 | from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs |
| 190 | except ImportError: |
| 191 | main.log.exception( "Something wrong with import file or code error." ) |
| 192 | main.log.info( "Import Error, please check!" ) |
| 193 | main.cleanup() |
| 194 | main.exit() |
| 195 | |
| 196 | bgplsConfig = BgpLs() |
| 197 | Ne_id = bgplsConfig.Constants() |
| 198 | app = bgplsConfig.apps() |
| 199 | main.CLIs = [] |
| 200 | main.nodes = [] |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 201 | main.numCtrls = 1 |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 202 | |
| 203 | ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 204 | scapy_ip = os.getenv( main.params[ 'SCAPY' ][ 'HOSTNAMES' ] ) |
| 205 | httpport = main.params[ 'HTTP' ][ 'port' ] |
| 206 | path = main.params[ 'HTTP' ][ 'path' ] |
| 207 | bgplsConfig.ipValue( ipList, scapy_ip ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 208 | |
| 209 | for i in range( 1, main.numCtrls + 1 ): |
| 210 | try: |
| 211 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 212 | main.nodes.append( getattr( main, 'ONOS' + str( i ) ) ) |
| 213 | ipList.append( main.nodes[ -1 ].ip_address ) |
| 214 | except AttributeError: |
| 215 | break |
| 216 | |
| 217 | main.step( "Apply cell to environment" ) |
| 218 | bgplsConfig.Comments() |
| 219 | |
| 220 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 221 | main.log.info( "Sending BGPLS information" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 222 | bgplsConfig.Comments() |
| 223 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 224 | main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\ |
| 225 | dependencies/Scapyfiles/Topo_discovery.py" ) |
| 226 | bgplsConfig.Comments() |
| 227 | main.log.info( "Enable BGPlS plugin in ONOS" ) |
| 228 | bgplsConfig.Comments() |
| 229 | |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 230 | cliResults = main.ONOScli1.startOnosCli( main.nodes[ 0 ].ip_address ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 231 | |
| 232 | main.step( "Getting connected to ONOS" ) |
| 233 | utilities.assert_equals( expect=main.TRUE, actual=cliResults, |
| 234 | onpass="ONOS cli startup successful", |
| 235 | onfail="ONOS cli startup failed" ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 236 | installResults = main.ONOScli1.activateApp( app[ 0 ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 237 | |
| 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 | |
| 243 | bgpls_post = bgplsConfig.DictoJson() |
| 244 | |
| 245 | bgplsConfig.Comments() |
| 246 | main.log.info( "BGPLS RestConf input" ) |
| 247 | bgplsConfig.Comments() |
| 248 | |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 249 | print ( bgpls_post ) |
alison | b1a2652 | 2016-11-22 17:27:17 -0800 | [diff] [blame] | 250 | main.ONOSrest.user_name = "onos" |
| 251 | main.ONOSrest.pwd = "rocks" |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 252 | Poststatus, result = main.ONOSrest.send( '/network/configuration/', method="POST", data=bgpls_post ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 253 | main.step( "Configure BGP through RESTCONF" ) |
| 254 | |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 255 | utilities.assert_equals( expect='200', |
| 256 | actual=Poststatus, |
| 257 | onpass="Post Port Success", |
| 258 | onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 259 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 260 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 261 | main.step( "Check Network devices are Updated in ONOS " ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 262 | bgplsConfig.Comments() |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 263 | time.sleep( 15 ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 264 | response = main.ONOScli1.devices() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 265 | responseCheck = main.FALSE |
| 266 | if response: |
| 267 | responseCheck = main.TRUE |
| 268 | utilities.assert_equals( expect=main.TRUE, |
| 269 | actual=responseCheck, |
| 270 | onpass="Network Devices update in ONOS successful", |
| 271 | onfail="Network Devices update in ONOS failed" ) |
| 272 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 273 | main.step( "Check the nodes are discovered" ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 274 | 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] | 275 | stepResult = main.TRUE |
| 276 | else: |
| 277 | stepResult = main.FALSE |
| 278 | utilities.assert_equals( expect=main.TRUE, |
| 279 | actual=stepResult, |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 280 | onpass="Node " + str( Ne_id[ 1 ][ 0 ] ) + ( Ne_id[ 1 ][ 1 ] ) + ( Ne_id[ 1 ][ 2 ] ) + " sucess", |
| 281 | onfail="Node " + str( Ne_id[ 1 ][ 0 ] ) + ( Ne_id[ 1 ][ 1 ] ) + ( Ne_id[ 1 ][ 2 ] ) + " failed" ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 282 | main.ONOScli1.log( "\"testcase2 end\"" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 283 | |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 284 | main.step( "Check for Errors or Exception in testcase2" ) |
| 285 | startStr = "testcase2 start" |
| 286 | endStr = "testcase2 end" |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 287 | errorLog = main.ONOSbench.logReport( main.nodes[ 0 ].ip_address, |
| 288 | [ "ERROR", "EXCEPT" ], "s", |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 289 | startStr, endStr ) |
| 290 | utilities.assert_equals( expect=0, actual=errorLog, |
| 291 | onpass="No Exception or Error occured in testcase2", |
| 292 | onfail="Exception or Error occured in testcase2" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 293 | bgplsConfig.Comments() |
| 294 | main.log.info( "Kill Scapy process" ) |
| 295 | bgplsConfig.Comments() |
| 296 | |
| 297 | main.Scapy1.handle.sendline( "\x03" ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 298 | time.sleep( 90 ) # This Sleep time gives time for the socket to close. |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 299 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 300 | def CASE3( self, main ): |
| 301 | """ |
| 302 | Addition of new Node to existing topology |
| 303 | """ |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 304 | import os |
| 305 | import sys |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 306 | import re |
| 307 | import time |
| 308 | |
| 309 | main.case( "Testcase 3: Addition of New Node to existing topology" ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 310 | main.ONOScli1.log( "\"testcase3 start\"" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 311 | try: |
| 312 | from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs |
| 313 | except ImportError: |
| 314 | main.log.exception( "Something wrong with import file or code error." ) |
| 315 | main.log.info( "Import Error, please check!" ) |
| 316 | main.cleanup() |
| 317 | main.exit() |
| 318 | |
| 319 | bgplsConfig = BgpLs() |
| 320 | Ne_id = bgplsConfig.Constants() |
| 321 | app = bgplsConfig.apps() |
| 322 | main.CLIs = [] |
| 323 | main.nodes = [] |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 324 | main.numCtrls = 1 |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 325 | |
| 326 | ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 327 | scapy_ip = os.getenv( main.params[ 'SCAPY' ][ 'HOSTNAMES' ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 328 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 329 | cellAppString = main.params[ 'ENV' ][ 'cellApps' ] |
| 330 | httpport = main.params[ 'HTTP' ][ 'port' ] |
| 331 | path = main.params[ 'HTTP' ][ 'path' ] |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 332 | |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 333 | bgplsConfig.ipValue( ipList, scapy_ip ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 334 | |
| 335 | for i in range( 1, main.numCtrls + 1 ): |
| 336 | try: |
| 337 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 338 | main.nodes.append( getattr( main, 'ONOS' + str( i ) ) ) |
| 339 | ipList.append( main.nodes[ -1 ].ip_address ) |
| 340 | except AttributeError: |
| 341 | break |
| 342 | |
| 343 | bgplsConfig.Comments() |
| 344 | main.log.info( "Sending BGPLS Packet " ) |
| 345 | bgplsConfig.Comments() |
| 346 | |
| 347 | main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\ |
| 348 | dependencies/Scapyfiles/Update_Node.py" ) |
| 349 | bgplsConfig.Comments() |
| 350 | main.log.info( "Enable BGPlS plugin in ONOS" ) |
| 351 | bgplsConfig.Comments() |
| 352 | |
| 353 | main.step( "UnInstall onos-app-bgp" ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 354 | installResults = main.ONOScli1.deactivateApp( app[ 0 ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 355 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 356 | onpass="Uninstall onos-app-bgp successful", |
| 357 | onfail="Uninstall onos-app-bgp failed" ) |
| 358 | |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 359 | installResults = main.ONOScli1.activateApp( app[ 0 ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 360 | main.step( "Install onos-app-bgp" ) |
| 361 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 362 | onpass="Install onos-app-bgp successful", |
| 363 | onfail="Install onos-app-bgp failed" ) |
| 364 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 365 | bgpls_post = bgplsConfig.DictoJson() |
| 366 | |
| 367 | bgplsConfig.Comments() |
| 368 | main.log.info( "BGPLS RestConf input" ) |
| 369 | bgplsConfig.Comments() |
| 370 | |
| 371 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 372 | main.step( "Check Network devices are Updated in ONOS" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 373 | bgplsConfig.Comments() |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 374 | time.sleep( 120 ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 375 | response = main.ONOScli1.devices() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 376 | responseCheck = main.FALSE |
| 377 | if response: |
| 378 | responseCheck = main.TRUE |
| 379 | utilities.assert_equals( expect=main.TRUE, |
| 380 | actual=responseCheck, |
| 381 | onpass="Network Devices update in ONOS successful", |
| 382 | onfail="Network Devices update in ONOS failed" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 383 | main.step( "Check Newly added Node is getting updated" ) |
| 384 | |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 385 | if response.find( Ne_id[ 1 ][ 3 ] ) != -1: |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 386 | stepResult = main.TRUE |
| 387 | else: |
| 388 | stepResult = main.FALSE |
| 389 | utilities.assert_equals( expect=main.TRUE, |
| 390 | actual=stepResult, |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 391 | onpass="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update sucess", |
| 392 | onfail="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update failed" ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 393 | main.ONOScli1.log( "\"testcase3 end\"" ) |
| 394 | |
| 395 | main.step( "Check for Errors or Exception in testcase3" ) |
| 396 | startStr = "testcase3 start" |
| 397 | endStr = "testcase3 end" |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 398 | errorLog = main.ONOSbench.logReport( main.nodes[ 0 ].ip_address, |
| 399 | [ "ERROR", "EXCEPT" ], "s", |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 400 | startStr, endStr ) |
| 401 | utilities.assert_equals( expect=0, actual=errorLog, |
| 402 | onpass="No Exception or Error occured in testcase3", |
| 403 | onfail="Exception or Error occured in testcase3" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 404 | bgplsConfig.Comments() |
| 405 | main.log.info( "Kill Scapy process" ) |
| 406 | bgplsConfig.Comments() |
| 407 | main.Scapy1.handle.sendline( "\x03" ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 408 | time.sleep( 90 ) # This Sleep time gives time for the socket to close. |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 409 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 410 | def CASE4( self, main ): |
| 411 | """ |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 412 | Verification of Links in existing topology |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 413 | """ |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 414 | import json |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 415 | import time |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 416 | import os |
| 417 | main.case( "Testcase 4: Verification of Links thats is discovered" ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 418 | main.ONOScli1.log( "\"testcase4 start\"" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 419 | try: |
| 420 | from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs |
| 421 | except ImportError: |
| 422 | main.log.exception( "Something wrong with import file or code error." ) |
| 423 | main.log.info( "Import Error, please check!" ) |
| 424 | main.cleanup() |
| 425 | main.exit() |
| 426 | |
| 427 | bgplsConfig = BgpLs() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 428 | app = bgplsConfig.apps() |
| 429 | main.CLIs = [] |
| 430 | main.nodes = [] |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 431 | main.numCtrls = 1 |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 432 | ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 433 | scapy_ip = os.getenv( main.params[ 'SCAPY' ][ 'HOSTNAMES' ] ) |
| 434 | bgplsConfig.ipValue( ipList, scapy_ip ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 435 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 436 | for i in range( 1, main.numCtrls + 1 ): |
| 437 | try: |
| 438 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 439 | main.nodes.append( getattr( main, 'ONOS' + str( i ) ) ) |
| 440 | ipList.append( main.nodes[ -1 ].ip_address ) |
| 441 | except AttributeError: |
| 442 | break |
| 443 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 444 | bgplsConfig.Comments() |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 445 | main.log.info( "Sending BGPLS Link information Packet " ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 446 | bgplsConfig.Comments() |
| 447 | |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 448 | 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] | 449 | bgplsConfig.Comments() |
| 450 | main.log.info( "Enable BGPlS plugin in ONOS" ) |
| 451 | bgplsConfig.Comments() |
| 452 | |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 453 | main.step( "UnInstall onos-app-bgp" ) |
| 454 | installResults = main.ONOScli1.deactivateApp( app[ 0 ] ) |
| 455 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 456 | onpass="Uninstall onos-app-bgp successful", |
| 457 | onfail="Uninstall onos-app-bgp failed" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 458 | |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 459 | installResults = main.ONOScli1.activateApp( app[ 0 ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 460 | main.step( "Install onos-app-bgp" ) |
| 461 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 462 | onpass="Install onos-app-bgp successful", |
| 463 | onfail="Install onos-app-bgp failed" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 464 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 465 | main.step( "Checking the Link Discovery Status" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 466 | bgplsConfig.Comments() |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 467 | time.sleep( 120 ) # Time taken to discovery the links |
| 468 | response = main.ONOScli1.links() |
| 469 | linksResp = json.loads( response ) |
| 470 | check_link = bgplsConfig.checkLinks( linksResp ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 471 | |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 472 | if check_link: |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 473 | reply_Check_Link = main.TRUE |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 474 | utilities.assert_equals( expect=main.TRUE, actual=reply_Check_Link, |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 475 | onpass="Link Discovery Success.", |
| 476 | onfail="Link Discovery Failed." ) |
| 477 | main.ONOScli1.log( "\"testcase4 end\"" ) |
| 478 | |
| 479 | main.step( "Check for Errors or Exception in testcase4 " ) |
| 480 | startStr = "testcase4 start" |
| 481 | endStr = "testcase4 end" |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 482 | errorLog = main.ONOSbench.logReport( main.nodes[ 0 ].ip_address, |
| 483 | [ "ERROR", "EXCEPT" ], "s", |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 484 | startStr, endStr ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 485 | utilities.assert_equals( expect=0, actual=errorLog, |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 486 | onpass="No Exception or Error occured in testcase4", |
| 487 | onfail="Exception or Error occured in testcase4" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 488 | bgplsConfig.Comments() |
| 489 | main.log.info( "Kill Scapy process" ) |
| 490 | bgplsConfig.Comments() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 491 | main.Scapy1.handle.sendline( "\x03" ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 492 | time.sleep( 90 ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 493 | |
| 494 | def CASE5( self, main ): |
| 495 | """ |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 496 | Deletion of links |
| 497 | """ |
| 498 | import json |
| 499 | import time |
| 500 | import os |
| 501 | main.case( "Testcase 5: Deletion of Link in existing topology" ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 502 | |
| 503 | main.ONOScli1.log( "\"testcase5 start\"" ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 504 | try: |
| 505 | from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs |
| 506 | except ImportError: |
| 507 | main.log.exception( "Something wrong with import file or code error." ) |
| 508 | main.log.info( "Import Error, please check!" ) |
| 509 | main.cleanup() |
| 510 | main.exit() |
| 511 | |
| 512 | bgplsConfig = BgpLs() |
| 513 | app = bgplsConfig.apps() |
| 514 | main.CLIs = [] |
| 515 | main.nodes = [] |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 516 | main.numCtrls = 1 |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 517 | ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 518 | scapy_ip = os.getenv( main.params[ 'SCAPY' ][ 'HOSTNAMES' ] ) |
| 519 | bgplsConfig.ipValue( ipList, scapy_ip ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 520 | |
| 521 | for i in range( 1, main.numCtrls + 1 ): |
| 522 | try: |
| 523 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 524 | main.nodes.append( getattr( main, 'ONOS' + str( i ) ) ) |
| 525 | ipList.append( main.nodes[ -1 ].ip_address ) |
| 526 | except AttributeError: |
| 527 | break |
| 528 | |
| 529 | bgplsConfig.Comments() |
| 530 | main.log.info( "Sending BGPLS Delete Link Packet " ) |
| 531 | bgplsConfig.Comments() |
| 532 | |
| 533 | main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py" ) |
| 534 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 535 | main.log.info( "Enable BGPlS plugin in ONOS " ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 536 | bgplsConfig.Comments() |
| 537 | |
| 538 | main.step( "UnInstall onos-app-bgp" ) |
| 539 | installResults = main.ONOScli1.deactivateApp( app[ 0 ] ) |
| 540 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 541 | onpass="Uninstall onos-app-bgp successful", |
| 542 | onfail="Uninstall onos-app-bgp failed" ) |
| 543 | |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 544 | installResults = main.ONOScli1.activateApp( app[ 0 ] ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 545 | main.step( "Install onos-app-bgp" ) |
| 546 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 547 | onpass="Install onos-app-bgp successful", |
| 548 | onfail="Install onos-app-bgp failed" ) |
| 549 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 550 | main.step( "Checking whether the links is deleted" ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 551 | bgplsConfig.Comments() |
| 552 | time.sleep( 120 ) # Time taken to discovery the links |
| 553 | response = main.ONOScli1.links() |
| 554 | linksResp = json.loads( response ) |
| 555 | check_link = bgplsConfig.checkLinks( linksResp ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 556 | if not check_link: |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 557 | reply_Check_Link = main.TRUE |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 558 | utilities.assert_equals( expect=main.TRUE, actual=reply_Check_Link, |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 559 | onpass="Link is Deleted Successfully.", |
| 560 | onfail="Link is Deletion Failed." ) |
| 561 | main.ONOScli1.log( "\"testcase5 end\"" ) |
| 562 | |
| 563 | main.step( "Check for Errors or Exception in testcase5" ) |
| 564 | startStr = "testcase5 start" |
| 565 | endStr = "testcase5 end" |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 566 | errorLog = main.ONOSbench.logReport( main.nodes[ 0 ].ip_address, |
| 567 | [ "ERROR", "EXCEPT" ], "s", |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 568 | startStr, endStr ) |
| 569 | utilities.assert_equals( expect=0, actual=errorLog, |
| 570 | onpass="No Exception or Error occured in testcase5", |
| 571 | onfail="Exception or Error occured in testcase5" ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 572 | bgplsConfig.Comments() |
| 573 | main.log.info( "Kill Scapy process" ) |
| 574 | bgplsConfig.Comments() |
| 575 | main.Scapy1.handle.sendline( "\x03" ) |
| 576 | time.sleep( 90 ) |
| 577 | |
| 578 | def CASE6( self, main ): |
| 579 | """ |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 580 | Uninstalling the app |
| 581 | """ |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 582 | import os |
| 583 | import sys |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 584 | import re |
| 585 | import time |
| 586 | |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 587 | main.case( "TestCase 6: UnInstalling of app" ) |
| 588 | main.ONOScli1.log( "\"testcase6 start\"" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 589 | try: |
| 590 | from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs |
| 591 | except ImportError: |
| 592 | main.log.exception( "Something wrong with import file or code error." ) |
| 593 | main.log.info( "Import Error, please check!" ) |
| 594 | main.cleanup() |
| 595 | main.exit() |
| 596 | |
| 597 | bgplsConfig = BgpLs() |
| 598 | app = bgplsConfig.apps() |
| 599 | main.CLIs = [] |
| 600 | main.nodes = [] |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 601 | main.numCtrls = 1 |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 602 | |
| 603 | ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 604 | scapy_ip = os.getenv( main.params[ 'SCAPY' ][ 'HOSTNAMES' ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 605 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 606 | cellAppString = main.params[ 'ENV' ][ 'cellApps' ] |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 607 | |
| 608 | bgplsConfig = BgpLs() |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 609 | bgplsConfig.ipValue( ipList, scapy_ip ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 610 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName, |
| 611 | scapy_ip, |
Devin Lim | dc78e20 | 2017-06-09 18:30:07 -0700 | [diff] [blame] | 612 | cellAppString, ipList, main.ONOScli1.karafUser ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 613 | |
| 614 | for i in range( 1, main.numCtrls + 1 ): |
| 615 | try: |
| 616 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 617 | main.nodes.append( getattr( main, 'ONOS' + str( i ) ) ) |
| 618 | ipList.append( main.nodes[ -1 ].ip_address ) |
| 619 | except AttributeError: |
| 620 | break |
| 621 | |
| 622 | main.step( "Apply cell to environment" ) |
| 623 | bgplsConfig.Comments() |
| 624 | cellResult = main.ONOSbench.setCell( cellName ) |
| 625 | |
| 626 | bgplsConfig.Comments() |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 627 | main.step( "Logging into ONOS CLI " ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 628 | bgplsConfig.Comments() |
| 629 | |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 630 | cliResults = main.ONOScli1.startOnosCli( main.nodes[ 0 ].ip_address ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 631 | utilities.assert_equals( expect=main.TRUE, actual=cliResults, |
| 632 | onpass="ONOS cli startup successful", |
| 633 | onfail="ONOS cli startup failed" ) |
| 634 | |
| 635 | bgplsConfig.Comments() |
| 636 | main.log.info( "Uninstall onos-app-bgp" ) |
| 637 | bgplsConfig.Comments() |
| 638 | main.step( "UnInstall onos-app-bgp" ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 639 | installResults = main.ONOScli1.deactivateApp( app[ 0 ] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 640 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 641 | onpass="Uninstall onos-app-bgp successful", |
| 642 | onfail="Uninstall onos-app-bgp failed" ) |
| 643 | |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 644 | main.ONOScli1.log( "\"testcase6 end\"" ) |
| 645 | main.step( "Check for Errors or Exception in testcase6" ) |
| 646 | startStr = "testcase6 start" |
| 647 | endStr = "testcase6 end" |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 648 | errorLog = main.ONOSbench.logReport( main.nodes[ 0 ].ip_address, |
| 649 | [ "ERROR", "EXCEPT" ], "s", |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 650 | startStr, endStr ) |
| 651 | utilities.assert_equals( expect=0, actual=errorLog, |
| 652 | onpass="No Exception or Error occured in testcase6", |
| 653 | onfail="Exception or Error occured in testcase6" ) |
| 654 | |
| 655 | main.step( "Check for Errors or Exception End of the Script" ) |
Jon Hall | 46fdea1 | 2017-05-24 15:48:57 -0700 | [diff] [blame] | 656 | errorLog = main.ONOSbench.logReport( main.nodes[ 0 ].ip_address, |
| 657 | [ "ERROR", "EXCEPT" ] ) |
Pratik Parab | 3b2ab5a | 2017-02-14 13:15:14 -0800 | [diff] [blame] | 658 | utilities.assert_equals( expect=0, actual=errorLog, |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 659 | onpass="No Exception or Error occured", |
Chiyu Cheng | ef10950 | 2016-11-21 15:51:38 -0800 | [diff] [blame] | 660 | onfail="Exception or Error occured" ) |