BGP session with LLGR capability for unsupported safi 03/91503/52
authorpdathathraya <pdathathraya@luminanetworks.com>
Tue, 21 Jul 2020 12:10:05 +0000 (17:40 +0530)
committerJamo Luhrsen <jluhrsen@gmail.com>
Wed, 19 Aug 2020 16:48:40 +0000 (16:48 +0000)
   - A library for gobgp tool is added
   - Test case for validating BGP Session with LLGR
   - For an unsupported safi

JIRA : BGPCEP-893

Signed-off-by: pdathathraya <pdathathraya@luminanetworks.com>
Change-Id: I57cfc0ade08f37f85f5bbdb0ca7093012ac0f500

csit/libraries/GoBgpLib.robot [new file with mode: 0644]
csit/suites/bgpcep/bgpfunct/bgp_llgr_basic.robot [new file with mode: 0644]
csit/testplans/bgpcep-userfeatures.txt
csit/variables/bgpfunctional/gobgp/gobgp.cfg [new file with mode: 0644]

diff --git a/csit/libraries/GoBgpLib.robot b/csit/libraries/GoBgpLib.robot
new file mode 100644 (file)
index 0000000..aadf9aa
--- /dev/null
@@ -0,0 +1,66 @@
+*** Settings ***
+Documentation     Robot keyword library (Resource) for handling the GoBgp tool.
+...           
+...               Copyright (c) 2020 Lumina Networks and others. All rights reserved.
+...           
+...               This program and the accompanying materials are made available under the
+...               terms of the Eclipse Public License v1.0 which accompanies this distribution,
+...               and is available at http://www.eclipse.org/legal/epl-v10.html
+...           
+...           
+...               This library assumes that a SSH connection exists (and is switched to)
+...               to a Linux machine (usualy TOOLS_SYSTEM) where the GoBgp should be run.
+...           
+Library           Process
+Library           SSHLibrary
+Resource          ${CURDIR}/BGPcliKeywords.robot
+Resource          ${CURDIR}/RemoteBash.robot
+Resource          ${CURDIR}/SSHKeywords.robot
+
+*** Variables ***
+${GOBGP_KILL_COMMAND}    ps axf | grep gobgp | grep -v grep | awk '{print \"kill -9 \" $1}' | sh
+${GOBGP_EXECUTION_COMMAND}    /home/jenkins/gobgpd -l debug -f
+${PEER_CHECK_URL}    /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/peer/bgp:%2F%2F
+
+*** Keywords ***
+Start_GoBgp
+    [Arguments]    ${cfg_file}
+    [Documentation]    Dump the start command into prompt. It assumes that no gobgp is running. For verified
+    ...    start use Start_GoBgp_And_Verify_Connected keyword.
+    ${start_cmd}=    ${GOBGP_EXECUTION_COMMAND} /home/jenkins/${cfg_file}
+    BuiltIn.Log    ${start_cmd}
+    ${output}=    SSHLibrary.Write    ${start_cmd}
+    BuiltIn.Log    ${output}
+
+Stop_GoBgp
+    [Documentation]    Stops the GoBgp by sending ctrl+c
+    ${output}=    SSHLibrary.Read
+    BuiltIn.Log    ${output}
+    RemoteBash.Write_Bare_Ctrl_C
+    ${output}=    SSHLibrary.Read_Until_Prompt
+    BuiltIn.Log    ${output}
+
+Stop_All_GoBgps
+    [Documentation]    Sends kill command to stop all Gobgps running
+    ${output}    SSHLibrary.Read
+    BuiltIn.Log    ${output}
+    ${output}    SSHLibrary.Write    ${GOBGP_KILL_COMMAND}
+    BuiltIn.Log    ${output}
+
+Start_GoBgp_And_Verify_Connected
+    [Arguments]    ${cfg_file}    ${session}    ${gobgp_ip}    ${connection_retries}=${3}
+    [Documentation]    Starts the GoBgp and verifies its connection. The verification is done by checking the presence
+    ...    of the peer in the bgp rib. [Gobgp at times might take more time, hence the loop]
+    Start_GoBgp    ${cfg_file}
+    ${status}    ${value}=    BuiltIn.Run_Keyword_And_Ignore_Error    BuiltIn.Wait_Until_Keyword_Succeeds    ${connection_retries}x    15s
+    ...    Verify_GoBgps_Connection    ${session}    ${gobgp_ip}    connected=${True}
+    BuiltIn.Run_Keyword_Unless    "${status}" == "PASS"    Stop_GoBgp
+    BuiltIn.Return_From_Keyword_If    "${status}" == "PASS"
+
+Verify_GoBgps_Connection
+    [Arguments]    ${session}    ${gobgp_ip}=${TOOLS_SYSTEM_IP}    ${connected}=${True}
+    [Documentation]    Checks peer presence in operational datastore
+    ${exp_status_code}=    BuiltIn.Set_Variable_If    ${connected}    ${ALLOWED_STATUS_CODES}    ${DELETED_STATUS_CODES}
+    ${rsp}=    RequestsLibrary.Get Request    ${session}    ${PEER_CHECK_URL}${gobgp_ip}
+    BuiltIn.Log    ${rsp.content}
+    BuiltIn.Should_Be_Equal_As_Numbers    ${exp_status_code}    ${rsp.status_code}
diff --git a/csit/suites/bgpcep/bgpfunct/bgp_llgr_basic.robot b/csit/suites/bgpcep/bgpfunct/bgp_llgr_basic.robot
new file mode 100644 (file)
index 0000000..61c40ec
--- /dev/null
@@ -0,0 +1,94 @@
+*** Settings ***
+Documentation     Functional test for ipv6 connection with bgp.
+...           
+...               Copyright (c) 2020 Lumina Networks Intellectual Property. All rights reserved.
+...           
+...               This program and the accompanying materials are made available under the
+...               terms of the Eclipse Public License v1.0 which accompanies this distribution,
+...               and is available at http://www.eclipse.org/legal/epl-v10.html
+...           
+...               This suite tests simple connection between one ibgp peer (goabgp) and Odl.
+...               Peer is configured with ipv6, and gobgp connectes to odl via ipv6.
+Suite Setup       Start_Suite
+Suite Teardown    Stop_Suite
+Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
+Library           RequestsLibrary
+Library           SSHLibrary
+Resource          ../../../variables/Variables.robot
+Resource          ../../../libraries/BGPcliKeywords.robot
+Resource          ../../../libraries/GoBgpLib.robot
+Resource          ../../../libraries/SetupUtils.robot
+Resource          ../../../libraries/SSHKeywords.robot
+Resource          ../../../libraries/TemplatedRequests.robot
+
+*** Variables ***
+${BGP_VAR_FOLDER}    ${CURDIR}/../../../variables/bgpfunctional/ipv6
+${GOBGP_FOLDER}    ${CURDIR}/../../../variables/bgpfunctional/gobgp
+${CONFIG_SESSION}    config-session
+${GOBGP_CFG}      gobgp.cfg
+${GOBGP_LOG}      gobgp.log
+${HOLDTIME}       180
+${RIB_INSTANCE}    example-bgp-rib
+${GOBGP_BINARY_URL}    https://github.com/osrg/gobgp/releases/download/v2.18.0/gobgp_2.18.0_linux_386.tar.gz
+${FILE_NAME}      gobgp_2.18.0_linux_386.tar.gz
+
+*** Test Cases ***
+Reconfigure_ODL_To_Accept_Connections
+    [Documentation]    Configure BGP peer modules with initiate-connection set to false with short ipv6 address.
+    &{mapping}    Create Dictionary    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    INITIATE=false    BGP_RIB=${RIB_INSTANCE}
+    ...    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${RIB_INSTANCE}    RIB_INSTANCE_NAME=${RIB_INSTANCE}
+    TemplatedRequests.Put_As_Xml_Templated    ${BGP_VAR_FOLDER}/bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
+
+Start_Gobgp
+    [Tags]    critical
+    ${cmd}=    ${GOBGP_CFG} > ${GOBGP_LOG}
+    GoBgpLib.Start_GoBgp_And_Verify_Connected    ${cmd}    ${CONFIG_SESSION}    ${TOOLS_SYSTEM_IP}
+
+Delete_Bgp_Peer_Configuration
+    [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
+    &{mapping}    Create Dictionary    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    INITIATE=false    BGP_RIB=${RIB_INSTANCE}
+    ...    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${RIB_INSTANCE}    RIB_INSTANCE_NAME=${RIB_INSTANCE}
+    TemplatedRequests.Delete_Templated    ${BGP_VAR_FOLDER}/bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
+
+Stop_All_Gobgps
+    [Documentation]    Save exabgp logs as exaipv6.log, and stop exabgp with ctrl-c bash signal
+    BGPcliKeywords.Store_File_To_Workspace    ${GOBGP_LOG}    ${GOBGP_LOG}
+    GoBgpLib.Stop_GoBgp
+
+*** Keywords ***
+Start_Suite
+    [Documentation]    Suite setup keyword.
+    SetupUtils.Setup_Utils_For_Setup_And_Teardown
+    ${tools_system_conn_id}=    SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=6s
+    Builtin.Set_Suite_Variable    ${tools_system_conn_id}
+    SSHKeywords.Flexible_Mininet_Login    ${TOOLS_SYSTEM_USER}
+    RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
+    Upload_Config_Files
+    Download_Gobgp_Binary
+
+Stop_Suite
+    [Documentation]    Suite teardown keyword
+    SSHLibrary.Close_All_Connections
+    RequestsLibrary.Delete_All_Sessions
+    BuiltIn.Run Keyword And Ignore Error    GoBgpLib.Stop_GoBgp
+
+Upload_Config_Files
+    [Documentation]    Uploads gobgp config files
+    SSHLibrary.Put_File    ${GOBGP_FOLDER}/${GOBGP_CFG}    .
+    @{cfgfiles}=    SSHLibrary.List_Files_In_Directory    .    *.cfg
+    FOR    ${cfgfile}    IN    @{cfgfiles}
+        SSHLibrary.Execute_Command    sed -i -e 's/GOBGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
+        SSHLibrary.Execute_Command    sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
+        SSHLibrary.Execute_Command    sed -i -e 's/ROUTERID/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
+        SSHLibrary.Execute_Command    sed -i -e 's/ROUTEREFRESH/disable/g' ${cfgfile}
+        SSHLibrary.Execute_Command    sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
+        ${stdout}=    SSHLibrary.Execute_Command    cat ${cfgfile}
+        Log    ${stdout}
+    END
+
+Download_Gobgp_Binary
+    [Documentation]    Downloads gobgp binary and untar the binary zip file
+    SSHKeywords.Open_Connection_To_Tools_System    ${TOOLS_SYSTEM_IP}
+    SSHLibrary.Execute Command    wget ${GOBGP_BINARY_URL}
+    SSHLibrary.File Should Exist    ./${FILE_NAME}
+    SSHLibrary.Execute Command    tar -xzf ${FILE_NAME}
index a45fffd95ef9dcf9fb8f110a3493c1d7d4a6c8f2..0d23f3761c142959e4876aef34149e9c75bedbc0 100644 (file)
@@ -10,6 +10,7 @@ integration/test/csit/suites/bgpcep/pcepuser/pcepuser.robot
 integration/test/csit/suites/bgpcep/bgpfunct/bgp_functional_md5.robot
 integration/test/csit/suites/bgpcep/bgpuser/basic.robot
 integration/test/csit/suites/bgpcep/bgpfunct/bgp_ipv6_basic.robot
+integration/test/csit/suites/bgpcep/bgpfunct/bgp_llgr_basic.robot
 integration/test/csit/suites/bgpcep/bgpuser/bgp_app_peer_basic.robot
 integration/test/csit/suites/bgpcep/bgpuser/ibgp_peers_basic.robot
 integration/test/csit/suites/bgpcep/bgpuser/ebgp_peers_basic.robot
diff --git a/csit/variables/bgpfunctional/gobgp/gobgp.cfg b/csit/variables/bgpfunctional/gobgp/gobgp.cfg
new file mode 100644 (file)
index 0000000..8ef6afd
--- /dev/null
@@ -0,0 +1,18 @@
+[global.config]
+    as = 64496
+    router-id = "ROUTERID"
+    port = 17900
+[[neighbors]]
+    [neighbors.config]
+        peer-as = 64496
+        neighbor-address = "ODLIP"
+        local-as = 64496
+    [neighbors.transport.config]
+        local-address = "GOBGPIP"
+        remote-port = 1790
+    [[neighbors.afi-safis]]
+        [neighbors.afi-safis.config]
+           afi-safi-name = "ipv4-flowspec"
+        [neighbors.afi-safis.long-lived-graceful-restart.config]
+           enabled = true
+           restart-time = 86400