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