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" ) |
Jon Hall | 6509dbf | 2016-06-21 17:01:17 -0700 | [diff] [blame] | 145 | main.step( "Starting ONOS CLI sessions" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 146 | print main.nodes[0].ip_address |
| 147 | cliResults = main.ONOScli1.startOnosCli( main.nodes[0].ip_address ) |
| 148 | utilities.assert_equals( expect=main.TRUE, actual=cliResults, |
| 149 | onpass="ONOS cli startup successful", |
| 150 | onfail="ONOS cli startup failed" ) |
| 151 | |
| 152 | main.step( "App Ids check" ) |
| 153 | appCheck = main.ONOScli1.appToIDCheck() |
| 154 | |
| 155 | if appCheck !=main.TRUE: |
| 156 | main.log.warn( main.CLIs[0].apps() ) |
| 157 | main.log.warn( main.CLIs[0].appIDs() ) |
| 158 | utilities.assert_equals( expect=main.TRUE, actual=appCheck, |
| 159 | onpass="App Ids seem to be correct", |
| 160 | onfail="Something is wrong with app Ids" ) |
| 161 | if cliResults == main.FALSE: |
| 162 | main.log.error( "Failed to start ONOS,stopping test" ) |
| 163 | main.cleanup() |
| 164 | main.exit() |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | def CASE2( self, main ): |
| 171 | """ |
| 172 | Discovery the topology using BGPLS |
| 173 | """ |
| 174 | import os , sys |
| 175 | import re |
| 176 | import time |
| 177 | |
| 178 | main.case( "Testcase 2 : Discovery the Network Topology using BGPLS" ) |
| 179 | |
| 180 | try: |
| 181 | from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs |
| 182 | except ImportError: |
| 183 | main.log.exception( "Something wrong with import file or code error." ) |
| 184 | main.log.info( "Import Error, please check!" ) |
| 185 | main.cleanup() |
| 186 | main.exit() |
| 187 | |
| 188 | bgplsConfig = BgpLs() |
| 189 | Ne_id = bgplsConfig.Constants() |
| 190 | app = bgplsConfig.apps() |
| 191 | main.CLIs = [] |
| 192 | main.nodes = [] |
| 193 | main.numCtrls= 1 |
| 194 | |
| 195 | |
| 196 | ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 197 | scapy_ip = os.getenv(main.params ['SCAPY'] ['HOSTNAMES'] ) |
| 198 | httpport = main.params['HTTP']['port'] |
| 199 | path = main.params['HTTP']['path'] |
| 200 | bgplsConfig.ipValue(ipList,scapy_ip) |
| 201 | |
| 202 | for i in range( 1, main.numCtrls + 1 ): |
| 203 | try: |
| 204 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 205 | main.nodes.append( getattr( main, 'ONOS' + str( i ) ) ) |
| 206 | ipList.append( main.nodes[ -1 ].ip_address ) |
| 207 | except AttributeError: |
| 208 | break |
| 209 | |
| 210 | main.step( "Apply cell to environment" ) |
| 211 | bgplsConfig.Comments() |
| 212 | |
| 213 | bgplsConfig.Comments() |
| 214 | main.log.info( "Sending BGPLS information " ) |
| 215 | bgplsConfig.Comments() |
| 216 | |
| 217 | |
| 218 | main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\ |
| 219 | dependencies/Scapyfiles/Topo_discovery.py" ) |
| 220 | bgplsConfig.Comments() |
| 221 | main.log.info( "Enable BGPlS plugin in ONOS" ) |
| 222 | bgplsConfig.Comments() |
| 223 | |
| 224 | |
| 225 | cliResults = main.ONOScli1.startOnosCli( main.nodes[0].ip_address) |
| 226 | |
| 227 | main.step( "Getting connected to ONOS" ) |
| 228 | utilities.assert_equals( expect=main.TRUE, actual=cliResults, |
| 229 | onpass="ONOS cli startup successful", |
| 230 | onfail="ONOS cli startup failed" ) |
| 231 | installResults = main.ONOScli1.activateApp( app[0]) |
| 232 | |
| 233 | main.step( "Install onos-app-bgp" ) |
| 234 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 235 | onpass="Install onos-app-bgp successful", |
| 236 | onfail="Install onos-app-bgp failed" ) |
| 237 | |
| 238 | bgpls_post = bgplsConfig.DictoJson() |
| 239 | |
| 240 | bgplsConfig.Comments() |
| 241 | main.log.info( "BGPLS RestConf input" ) |
| 242 | bgplsConfig.Comments() |
| 243 | |
| 244 | print (bgpls_post) |
| 245 | main.ONOSrest.user_name = "karaf" |
| 246 | main.ONOSrest.pwd = "karaf" |
Jon Hall | 1f5e65f | 2016-06-15 10:06:05 -0700 | [diff] [blame] | 247 | Poststatus, result = main.ONOSrest.send( '/network/configuration/', method="POST", data=bgpls_post) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 248 | main.step( "Configure BGP through RESTCONF" ) |
| 249 | |
| 250 | utilities.assert_equals( |
| 251 | expect='200', |
| 252 | actual=Poststatus, |
| 253 | onpass="Post Port Success", |
| 254 | onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) ) |
| 255 | |
| 256 | |
| 257 | bgplsConfig.Comments() |
| 258 | main.log.info( "Check Network devices are Updated in ONOS " ) |
| 259 | bgplsConfig.Comments() |
| 260 | time.sleep(15) |
| 261 | |
| 262 | response = main.ONOScli1.devices() |
| 263 | main.step( "Check the nodes are discovered" ) |
| 264 | if response.find( Ne_id[1][0]) and response.find(Ne_id[1][1]) and response.find(Ne_id[1][2]) != -1: |
| 265 | stepResult = main.TRUE |
| 266 | else: |
| 267 | stepResult = main.FALSE |
| 268 | utilities.assert_equals( expect=main.TRUE, |
| 269 | actual=stepResult, |
| 270 | onpass="Node " + str( Ne_id[1][0]) + ( Ne_id[1][1]) + ( Ne_id[1][2]) + " sucess", |
| 271 | onfail="Node " + str( Ne_id[1][0]) + ( Ne_id[1][1]) + ( Ne_id[1][2]) + " failed" ) |
| 272 | |
| 273 | |
| 274 | bgplsConfig.Comments() |
| 275 | main.log.info( "Kill Scapy process" ) |
| 276 | bgplsConfig.Comments() |
| 277 | |
| 278 | main.Scapy1.handle.sendline( "\x03" ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 279 | time.sleep( 90 ) #This Sleep time gives time for the socket to close. |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | def CASE3( self, main ): |
| 285 | """ |
| 286 | Addition of new Node to existing topology |
| 287 | """ |
| 288 | import os , sys |
| 289 | import re |
| 290 | import time |
| 291 | |
| 292 | main.case( "Testcase 3: Addition of New Node to existing topology" ) |
| 293 | try: |
| 294 | from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs |
| 295 | except ImportError: |
| 296 | main.log.exception( "Something wrong with import file or code error." ) |
| 297 | main.log.info( "Import Error, please check!" ) |
| 298 | main.cleanup() |
| 299 | main.exit() |
| 300 | |
| 301 | bgplsConfig = BgpLs() |
| 302 | Ne_id = bgplsConfig.Constants() |
| 303 | app = bgplsConfig.apps() |
| 304 | main.CLIs = [] |
| 305 | main.nodes = [] |
| 306 | main.numCtrls= 1 |
| 307 | |
| 308 | |
| 309 | ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 310 | scapy_ip = os.getenv( main.params ['SCAPY'] ['HOSTNAMES'] ) |
| 311 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 312 | cellAppString= main.params[ 'ENV' ][ 'cellApps' ] |
| 313 | httpport = main.params['HTTP']['port'] |
| 314 | path = main.params['HTTP']['path'] |
| 315 | |
| 316 | bgplsConfig.ipValue(ipList,scapy_ip) |
| 317 | |
| 318 | for i in range( 1, main.numCtrls + 1 ): |
| 319 | try: |
| 320 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 321 | main.nodes.append( getattr( main, 'ONOS' + str( i ) ) ) |
| 322 | ipList.append( main.nodes[ -1 ].ip_address ) |
| 323 | except AttributeError: |
| 324 | break |
| 325 | |
| 326 | bgplsConfig.Comments() |
| 327 | main.log.info( "Sending BGPLS Packet " ) |
| 328 | bgplsConfig.Comments() |
| 329 | |
| 330 | main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/\ |
| 331 | dependencies/Scapyfiles/Update_Node.py" ) |
| 332 | bgplsConfig.Comments() |
| 333 | main.log.info( "Enable BGPlS plugin in ONOS" ) |
| 334 | bgplsConfig.Comments() |
| 335 | |
| 336 | main.step( "UnInstall onos-app-bgp" ) |
| 337 | installResults = main.ONOScli1.deactivateApp( app[0] ) |
| 338 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 339 | onpass="Uninstall onos-app-bgp successful", |
| 340 | onfail="Uninstall onos-app-bgp failed" ) |
| 341 | |
| 342 | installResults = main.ONOScli1.activateApp( app[0]) |
| 343 | main.step( "Install onos-app-bgp" ) |
| 344 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 345 | onpass="Install onos-app-bgp successful", |
| 346 | onfail="Install onos-app-bgp failed" ) |
| 347 | |
| 348 | |
| 349 | bgpls_post = bgplsConfig.DictoJson() |
| 350 | |
| 351 | bgplsConfig.Comments() |
| 352 | main.log.info( "BGPLS RestConf input" ) |
| 353 | bgplsConfig.Comments() |
| 354 | |
| 355 | bgplsConfig.Comments() |
| 356 | main.log.info( "Check Network devices are Updated in ONOS " ) |
| 357 | bgplsConfig.Comments() |
| 358 | time.sleep(120) |
| 359 | |
| 360 | response = main.ONOScli1.devices() |
| 361 | main.step( "Check Newly added Node is getting updated" ) |
| 362 | |
| 363 | if response.find( Ne_id[1][3]) != -1: |
| 364 | stepResult = main.TRUE |
| 365 | else: |
| 366 | stepResult = main.FALSE |
| 367 | utilities.assert_equals( expect=main.TRUE, |
| 368 | actual=stepResult, |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 369 | onpass="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update sucess", |
| 370 | onfail="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update failed" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 371 | bgplsConfig.Comments() |
| 372 | main.log.info( "Kill Scapy process" ) |
| 373 | bgplsConfig.Comments() |
| 374 | main.Scapy1.handle.sendline( "\x03" ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 375 | time.sleep( 90 ) #This Sleep time gives time for the socket to close. |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 376 | |
| 377 | |
| 378 | def CASE4( self, main ): |
| 379 | """ |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 380 | Verification of Links in existing topology |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 381 | """ |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 382 | import json |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 383 | import time |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 384 | import os |
| 385 | main.case( "Testcase 4: Verification of Links thats is discovered" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 386 | try: |
| 387 | from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs |
| 388 | except ImportError: |
| 389 | main.log.exception( "Something wrong with import file or code error." ) |
| 390 | main.log.info( "Import Error, please check!" ) |
| 391 | main.cleanup() |
| 392 | main.exit() |
| 393 | |
| 394 | bgplsConfig = BgpLs() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 395 | app = bgplsConfig.apps() |
| 396 | main.CLIs = [] |
| 397 | main.nodes = [] |
| 398 | main.numCtrls= 1 |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 399 | ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 400 | scapy_ip = os.getenv(main.params ['SCAPY'] ['HOSTNAMES'] ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 401 | bgplsConfig.ipValue(ipList,scapy_ip) |
| 402 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 403 | for i in range( 1, main.numCtrls + 1 ): |
| 404 | try: |
| 405 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 406 | main.nodes.append( getattr( main, 'ONOS' + str( i ) ) ) |
| 407 | ipList.append( main.nodes[ -1 ].ip_address ) |
| 408 | except AttributeError: |
| 409 | break |
| 410 | |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 411 | bgplsConfig.Comments() |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 412 | main.log.info( "Sending BGPLS Link information Packet " ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 413 | bgplsConfig.Comments() |
| 414 | |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 415 | 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] | 416 | bgplsConfig.Comments() |
| 417 | main.log.info( "Enable BGPlS plugin in ONOS" ) |
| 418 | bgplsConfig.Comments() |
| 419 | |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 420 | main.step( "UnInstall onos-app-bgp" ) |
| 421 | installResults = main.ONOScli1.deactivateApp( app[ 0 ] ) |
| 422 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 423 | onpass="Uninstall onos-app-bgp successful", |
| 424 | onfail="Uninstall onos-app-bgp failed" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 425 | |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 426 | installResults = main.ONOScli1.activateApp( app[ 0 ]) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 427 | main.step( "Install onos-app-bgp" ) |
| 428 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 429 | onpass="Install onos-app-bgp successful", |
| 430 | onfail="Install onos-app-bgp failed" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 431 | bgplsConfig.Comments() |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 432 | main.log.info( "Checking the Link Discovery Status" ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 433 | bgplsConfig.Comments() |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 434 | time.sleep( 120 ) # Time taken to discovery the links |
| 435 | response = main.ONOScli1.links() |
| 436 | linksResp = json.loads( response ) |
| 437 | check_link = bgplsConfig.checkLinks( linksResp ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 438 | |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 439 | if check_link == True: |
| 440 | reply_Check_Link = main.TRUE |
| 441 | utilities.assert_equals( expect= main.TRUE, |
| 442 | actual=reply_Check_Link , |
| 443 | onpass="Link Discovery Success.", |
| 444 | onfail="Link Discovery Failed." ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 445 | bgplsConfig.Comments() |
| 446 | main.log.info( "Kill Scapy process" ) |
| 447 | bgplsConfig.Comments() |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 448 | main.Scapy1.handle.sendline( "\x03" ) |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 449 | time.sleep( 90 ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 450 | |
| 451 | def CASE5( self, main ): |
| 452 | """ |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 453 | Deletion of links |
| 454 | """ |
| 455 | import json |
| 456 | import time |
| 457 | import os |
| 458 | main.case( "Testcase 5: Deletion of Link in existing topology" ) |
| 459 | try: |
| 460 | from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs |
| 461 | except ImportError: |
| 462 | main.log.exception( "Something wrong with import file or code error." ) |
| 463 | main.log.info( "Import Error, please check!" ) |
| 464 | main.cleanup() |
| 465 | main.exit() |
| 466 | |
| 467 | bgplsConfig = BgpLs() |
| 468 | app = bgplsConfig.apps() |
| 469 | main.CLIs = [] |
| 470 | main.nodes = [] |
| 471 | main.numCtrls= 1 |
| 472 | ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 473 | scapy_ip = os.getenv(main.params [ 'SCAPY' ] [ 'HOSTNAMES' ] ) |
| 474 | bgplsConfig.ipValue(ipList,scapy_ip) |
| 475 | |
| 476 | for i in range( 1, main.numCtrls + 1 ): |
| 477 | try: |
| 478 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 479 | main.nodes.append( getattr( main, 'ONOS' + str( i ) ) ) |
| 480 | ipList.append( main.nodes[ -1 ].ip_address ) |
| 481 | except AttributeError: |
| 482 | break |
| 483 | |
| 484 | bgplsConfig.Comments() |
| 485 | main.log.info( "Sending BGPLS Delete Link Packet " ) |
| 486 | bgplsConfig.Comments() |
| 487 | |
| 488 | main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py" ) |
| 489 | bgplsConfig.Comments() |
| 490 | main.log.info( "Enable BGPlS plugin in ONOS" ) |
| 491 | bgplsConfig.Comments() |
| 492 | |
| 493 | main.step( "UnInstall onos-app-bgp" ) |
| 494 | installResults = main.ONOScli1.deactivateApp( app[ 0 ] ) |
| 495 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 496 | onpass="Uninstall onos-app-bgp successful", |
| 497 | onfail="Uninstall onos-app-bgp failed" ) |
| 498 | |
| 499 | installResults = main.ONOScli1.activateApp( app[ 0 ]) |
| 500 | main.step( "Install onos-app-bgp" ) |
| 501 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 502 | onpass="Install onos-app-bgp successful", |
| 503 | onfail="Install onos-app-bgp failed" ) |
| 504 | bgplsConfig.Comments() |
| 505 | main.log.info( "Checking whether the links is deleted" ) |
| 506 | bgplsConfig.Comments() |
| 507 | time.sleep( 120 ) # Time taken to discovery the links |
| 508 | response = main.ONOScli1.links() |
| 509 | linksResp = json.loads( response ) |
| 510 | check_link = bgplsConfig.checkLinks( linksResp ) |
| 511 | if check_link == False: |
| 512 | reply_Check_Link = main.TRUE |
| 513 | utilities.assert_equals( expect= main.TRUE, |
| 514 | actual=reply_Check_Link , |
| 515 | onpass="Link is Deleted Successfully.", |
| 516 | onfail="Link is Deletion Failed." ) |
| 517 | bgplsConfig.Comments() |
| 518 | main.log.info( "Kill Scapy process" ) |
| 519 | bgplsConfig.Comments() |
| 520 | main.Scapy1.handle.sendline( "\x03" ) |
| 521 | time.sleep( 90 ) |
| 522 | |
| 523 | def CASE6( self, main ): |
| 524 | """ |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 525 | Uninstalling the app |
| 526 | """ |
| 527 | import os,sys |
| 528 | import re |
| 529 | import time |
| 530 | |
| 531 | main.case( "TestCase 5: UnInstalling of app" ) |
| 532 | try: |
| 533 | from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs |
| 534 | except ImportError: |
| 535 | main.log.exception( "Something wrong with import file or code error." ) |
| 536 | main.log.info( "Import Error, please check!" ) |
| 537 | main.cleanup() |
| 538 | main.exit() |
| 539 | |
| 540 | bgplsConfig = BgpLs() |
| 541 | app = bgplsConfig.apps() |
| 542 | main.CLIs = [] |
| 543 | main.nodes = [] |
| 544 | main.numCtrls= 1 |
| 545 | |
| 546 | |
| 547 | ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] ) |
| 548 | scapy_ip = os.getenv(main.params ['SCAPY'] ['HOSTNAMES'] ) |
| 549 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 550 | cellAppString= main.params[ 'ENV' ][ 'cellApps' ] |
| 551 | |
| 552 | bgplsConfig = BgpLs() |
| 553 | bgplsConfig.ipValue(ipList,scapy_ip) |
| 554 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName, |
| 555 | scapy_ip, |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 556 | cellAppString, ipList ) |
AntonySilvester | a1080f2 | 2016-04-26 13:05:57 +0530 | [diff] [blame] | 557 | |
| 558 | for i in range( 1, main.numCtrls + 1 ): |
| 559 | try: |
| 560 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 561 | main.nodes.append( getattr( main, 'ONOS' + str( i ) ) ) |
| 562 | ipList.append( main.nodes[ -1 ].ip_address ) |
| 563 | except AttributeError: |
| 564 | break |
| 565 | |
| 566 | main.step( "Apply cell to environment" ) |
| 567 | bgplsConfig.Comments() |
| 568 | cellResult = main.ONOSbench.setCell( cellName ) |
| 569 | |
| 570 | bgplsConfig.Comments() |
| 571 | main.log.info( "Logging into ONOS CLI " ) |
| 572 | bgplsConfig.Comments() |
| 573 | |
| 574 | cliResults = main.ONOScli1.startOnosCli( main.nodes[0].ip_address ) |
| 575 | utilities.assert_equals( expect=main.TRUE, actual=cliResults, |
| 576 | onpass="ONOS cli startup successful", |
| 577 | onfail="ONOS cli startup failed" ) |
| 578 | |
| 579 | bgplsConfig.Comments() |
| 580 | main.log.info( "Uninstall onos-app-bgp" ) |
| 581 | bgplsConfig.Comments() |
| 582 | main.step( "UnInstall onos-app-bgp" ) |
| 583 | installResults = main.ONOScli1.deactivateApp( app[0] ) |
| 584 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 585 | onpass="Uninstall onos-app-bgp successful", |
| 586 | onfail="Uninstall onos-app-bgp failed" ) |
| 587 | |
AntonySilvester | 0265238 | 2016-07-13 16:44:45 +0530 | [diff] [blame] | 588 | main.log.info( "Check for Errors or Exception End of the Script" ) |
| 589 | errorLog = main.ONOSbench.logReport( main.nodes[0].ip_address, ["ERROR",\ |
| 590 | "EXCEPT"] ) |
| 591 | utilities.assert_equals( expect= 0, actual=errorLog, |
| 592 | onpass="No Exception or Error occured", |
| 593 | onfail="Exception or Error occured" ) |