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