Bgpls scripts updated with Links
Change-Id: I000a72601d4e17a8323694310a5ed1053c0792b5
diff --git a/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.py b/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.py
index a56c5c4..db60aad 100755
--- a/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.py
+++ b/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.py
@@ -8,8 +8,9 @@
CASE1: Compile ONOS and push it to the test machines
CASE2: Discovery the topology using BGPLS
CASE3: Addition of new Node to existing topology
-CASE4: Deletion of Node
-Case5: Uninstalling the app
+CASE4: Verification of Links thats is discovered"
+CASE5: Deletion of Links
+Case6: Uninstalling the app
"""
@@ -275,7 +276,7 @@
bgplsConfig.Comments()
main.Scapy1.handle.sendline( "\x03" )
- time.sleep(90) #This Sleep time gives time for the socket to close.
+ time.sleep( 90 ) #This Sleep time gives time for the socket to close.
@@ -365,24 +366,23 @@
stepResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="Node " + str( Ne_id[1][3] ) + " update sucess",
- onfail="Node " + str( Ne_id[1][3]) + " update failed" )
+ onpass="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update sucess",
+ onfail="Node " + str( Ne_id[ 1 ][ 3 ] ) + " update failed" )
bgplsConfig.Comments()
main.log.info( "Kill Scapy process" )
bgplsConfig.Comments()
main.Scapy1.handle.sendline( "\x03" )
-
+ time.sleep( 90 ) #This Sleep time gives time for the socket to close.
def CASE4( self, main ):
"""
- Deletion of Node
+ Verification of Links in existing topology
"""
- import os , sys
- import re
+ import json
import time
- main.case( "TestCase 4: Deletion of Node from existing Topology" )
-
+ import os
+ main.case( "Testcase 4: Verification of Links thats is discovered" )
try:
from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
except ImportError:
@@ -392,30 +392,14 @@
main.exit()
bgplsConfig = BgpLs()
- Ne_id = bgplsConfig.Constants()
app = bgplsConfig.apps()
main.CLIs = []
main.nodes = []
main.numCtrls= 1
-
- bgplsConfig.Comments()
- main.log.info( "Blocked due to this defect : ONOS-3920 " )
- bgplsConfig.Comments()
-
- '''
ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
scapy_ip = os.getenv(main.params ['SCAPY'] ['HOSTNAMES'] )
- cellName = main.params[ 'ENV' ][ 'cellName' ]
- cellAppString= main.params[ 'ENV' ][ 'cellApps' ]
- httpport = main.params['HTTP']['port']
- path = main.params['HTTP']['path']
- bgplsConfig = BgpLs()
bgplsConfig.ipValue(ipList,scapy_ip)
- main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
- scapy_ip,
- cellAppString, ipList , onosUser="karaf" )
-
for i in range( 1, main.numCtrls + 1 ):
try:
main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
@@ -424,93 +408,120 @@
except AttributeError:
break
- main.step( "Apply cell to environment" )
bgplsConfig.Comments()
- cellResult = main.ONOSbench.setCell( cellName )
-
- bgplsConfig.Comments()
- main.log.info( "Sending BGPLS information " )
+ main.log.info( "Sending BGPLS Link information Packet " )
bgplsConfig.Comments()
-
- main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py" )
- #main.Scapy1.handle.expect( "sdn:" )
- #main.Scapy1.handle.sendline( "rocks" )
-
-
+ main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Link_Update_Node.py" )
bgplsConfig.Comments()
main.log.info( "Enable BGPlS plugin in ONOS" )
bgplsConfig.Comments()
+ main.step( "UnInstall onos-app-bgp" )
+ installResults = main.ONOScli1.deactivateApp( app[ 0 ] )
+ utilities.assert_equals( expect=main.TRUE, actual=installResults,
+ onpass="Uninstall onos-app-bgp successful",
+ onfail="Uninstall onos-app-bgp failed" )
- cliResults = main.ONOScli1.startOnosCli( main.nodes[0].ip_address)
-
- main.step( "Getting connected to ONOS" )
- utilities.assert_equals( expect=main.TRUE, actual=cliResults,
- onpass="ONOS cli startup successful",
- onfail="ONOS cli startup failed" )
- installResults = main.ONOScli1.activateApp( app[0])
-
+ installResults = main.ONOScli1.activateApp( app[ 0 ])
main.step( "Install onos-app-bgp" )
utilities.assert_equals( expect=main.TRUE, actual=installResults,
onpass="Install onos-app-bgp successful",
onfail="Install onos-app-bgp failed" )
-
- main.step( "Install onos-app-bgpflow" )
- installResults = main.ONOScli1.activateApp( app[1] )
- utilities.assert_equals( expect=main.TRUE, actual=installResults,
- onpass="Install onos-app-bgpflow successful",
- onfail="Install onos-app-bgpflow failed" )
-
-
- bgpls_post = bgplsConfig.DictoJson()
-
bgplsConfig.Comments()
- main.log.info( "BGPLS RestConf input" )
+ main.log.info( "Checking the Link Discovery Status" )
bgplsConfig.Comments()
+ time.sleep( 120 ) # Time taken to discovery the links
+ response = main.ONOScli1.links()
+ linksResp = json.loads( response )
+ check_link = bgplsConfig.checkLinks( linksResp )
- print (bgpls_post)
- main.ONOSrest.user_name = "karaf"
- main.ONOSrest.pwd = "karaf"
- Poststatus, result = main.ONOSrest.send( ipList,httpport,'', path + 'v1/network/configuration/',
- 'POST', None, bgpls_post, debug=True )
-
- main.step( "Configure BGP through RESTCONF" )
- utilities.assert_equals(
- expect='200',
- actual=Poststatus,
- onpass="Post Port Success",
- onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
-
-
- bgplsConfig.Comments()
- main.log.info( "Check Network devices is deleted from ONOS " )
- bgplsConfig.Comments()
- time.sleep(15)
-
- response = main.ONOScli1.devices()
-
- main.step( "Check whehther Node is deleted successfully" )
-
- if response.find(Ne_id[3]) != -1:
- stepResult = main.TRUE
- else:
- stepResult = main.FALSE
- utilities.assert_equals( expect=main.FALSE,
- actual=stepResult,
- onpass="Node " + str( Ne_id[3] ) + " Deletion sucess",
- onfail="Node " + str( Ne_id[3] ) + " Deletion failed" )
-
+ if check_link == True:
+ reply_Check_Link = main.TRUE
+ utilities.assert_equals( expect= main.TRUE,
+ actual=reply_Check_Link ,
+ onpass="Link Discovery Success.",
+ onfail="Link Discovery Failed." )
bgplsConfig.Comments()
main.log.info( "Kill Scapy process" )
bgplsConfig.Comments()
-
main.Scapy1.handle.sendline( "\x03" )
- '''
-
+ time.sleep( 90 )
def CASE5( self, main ):
"""
+ Deletion of links
+ """
+ import json
+ import time
+ import os
+ main.case( "Testcase 5: Deletion of Link in existing topology" )
+ try:
+ from tests.FUNC.FUNCbgpls.dependencies.Nbdata import BgpLs
+ except ImportError:
+ main.log.exception( "Something wrong with import file or code error." )
+ main.log.info( "Import Error, please check!" )
+ main.cleanup()
+ main.exit()
+
+ bgplsConfig = BgpLs()
+ app = bgplsConfig.apps()
+ main.CLIs = []
+ main.nodes = []
+ main.numCtrls= 1
+ ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
+ scapy_ip = os.getenv(main.params [ 'SCAPY' ] [ 'HOSTNAMES' ] )
+ bgplsConfig.ipValue(ipList,scapy_ip)
+
+ for i in range( 1, main.numCtrls + 1 ):
+ try:
+ main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) )
+ main.nodes.append( getattr( main, 'ONOS' + str( i ) ) )
+ ipList.append( main.nodes[ -1 ].ip_address )
+ except AttributeError:
+ break
+
+ bgplsConfig.Comments()
+ main.log.info( "Sending BGPLS Delete Link Packet " )
+ bgplsConfig.Comments()
+
+ main.Scapy1.handle.sendline( "sudo python OnosSystemTest/TestON/tests/FUNC/FUNCbgpls/dependencies/Scapyfiles/Deletion_Node.py" )
+ bgplsConfig.Comments()
+ main.log.info( "Enable BGPlS plugin in ONOS" )
+ bgplsConfig.Comments()
+
+ main.step( "UnInstall onos-app-bgp" )
+ installResults = main.ONOScli1.deactivateApp( app[ 0 ] )
+ utilities.assert_equals( expect=main.TRUE, actual=installResults,
+ onpass="Uninstall onos-app-bgp successful",
+ onfail="Uninstall onos-app-bgp failed" )
+
+ installResults = main.ONOScli1.activateApp( app[ 0 ])
+ main.step( "Install onos-app-bgp" )
+ utilities.assert_equals( expect=main.TRUE, actual=installResults,
+ onpass="Install onos-app-bgp successful",
+ onfail="Install onos-app-bgp failed" )
+ bgplsConfig.Comments()
+ main.log.info( "Checking whether the links is deleted" )
+ bgplsConfig.Comments()
+ time.sleep( 120 ) # Time taken to discovery the links
+ response = main.ONOScli1.links()
+ linksResp = json.loads( response )
+ check_link = bgplsConfig.checkLinks( linksResp )
+ if check_link == False:
+ reply_Check_Link = main.TRUE
+ utilities.assert_equals( expect= main.TRUE,
+ actual=reply_Check_Link ,
+ onpass="Link is Deleted Successfully.",
+ onfail="Link is Deletion Failed." )
+ bgplsConfig.Comments()
+ main.log.info( "Kill Scapy process" )
+ bgplsConfig.Comments()
+ main.Scapy1.handle.sendline( "\x03" )
+ time.sleep( 90 )
+
+ def CASE6( self, main ):
+ """
Uninstalling the app
"""
import os,sys
@@ -542,7 +553,7 @@
bgplsConfig.ipValue(ipList,scapy_ip)
main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName,
scapy_ip,
- cellAppString, ipList , onosUser="karaf" )
+ cellAppString, ipList )
for i in range( 1, main.numCtrls + 1 ):
try:
@@ -574,5 +585,9 @@
onpass="Uninstall onos-app-bgp successful",
onfail="Uninstall onos-app-bgp failed" )
-
-
+ main.log.info( "Check for Errors or Exception End of the Script" )
+ errorLog = main.ONOSbench.logReport( main.nodes[0].ip_address, ["ERROR",\
+ "EXCEPT"] )
+ utilities.assert_equals( expect= 0, actual=errorLog,
+ onpass="No Exception or Error occured",
+ onfail="Exception or Error occured" )
\ No newline at end of file