Local as peer test 41/70841/13
authorTomas Markovic <tomas.markovic@pantheon.tech>
Thu, 12 Apr 2018 11:27:47 +0000 (13:27 +0200)
committerLuis Gomez <ecelgp@gmail.com>
Wed, 18 Apr 2018 16:14:21 +0000 (16:14 +0000)
Testing local-as configuration.
Configures external peer with local-as,
and internal peer without local-as.

We connect play.py python tool to both
peers, and we wait for them to exchange
routes.

Local-as from external peer is expected
on outputs of both peers, and each peer
should contain the others peer-as.

Change-Id: I741b251b6618432b713b65d4aa9ab81a7290eb90
Signed-off-by: Tomas Markovic <tomas.markovic@pantheon.tech>
csit/libraries/BGPSpeaker.robot
csit/suites/bgpcep/bgpuser/ebgp_peers_basic.robot
csit/variables/bgpuser/local_as/adj_rib_out/data.json [new file with mode: 0644]
csit/variables/bgpuser/local_as/adj_rib_out/location.uri [new file with mode: 0644]
csit/variables/bgpuser/local_as/ebgp_peer/data.xml [new file with mode: 0644]
csit/variables/bgpuser/local_as/ebgp_peer/location.uri [new file with mode: 0644]

index e5c5f7195930916e78cfff74e8fcd7ca02016419..053debd06aea0929313a86a45e07ced470d44640 100644 (file)
@@ -24,10 +24,12 @@ Documentation     Robot keyword library (Resource) for handling the BGP speaker
 ...               want to make the assumption that an SSH connection was already open.
 ...               alternative TODO: Explain that it is not worth to perform separate SSH logins.
 Library           SSHLibrary
 ...               want to make the assumption that an SSH connection was already open.
 ...               alternative TODO: Explain that it is not worth to perform separate SSH logins.
 Library           SSHLibrary
-Resource          ${CURDIR}/RemoteBash.robot
+Library           RequestsLibrary
+Resource          RemoteBash.robot
 
 *** Variables ***
 ${BGPSpeaker__OUTPUT_LOG}    play.py.out
 
 *** Variables ***
 ${BGPSpeaker__OUTPUT_LOG}    play.py.out
+${PEER_URL}       /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/peer/bgp:%2F%2F
 
 *** Keywords ***
 Start_BGP_Speaker
 
 *** Keywords ***
 Start_BGP_Speaker
@@ -40,6 +42,24 @@ Start_BGP_Speaker
     BuiltIn.Log    ${command}
     ${output} =    SSHLibrary.Write    ${command}
 
     BuiltIn.Log    ${command}
     ${output} =    SSHLibrary.Write    ${command}
 
+Start_BGP_Speaker_And_Verify_Connected
+    [Arguments]    ${arguments}    ${session}    ${speaker_ip}=${TOOLS_SYSTEM_IP}    ${connected}=${True}
+    [Documentation]    Start the BGP speaker python utility, and verifies it's connection.
+    ...    We can change connected variable to false to verify Speaker did not connect.
+    Start_BGP_Speaker    ${arguments}
+    ${message}    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    Verify_BGP_Speaker_Connection    ${session}    ${speaker_ip}
+    ...    ${connected}
+    [Return]    ${message}
+
+Verify_BGP_Speaker_Connection
+    [Arguments]    ${session}    ${ip}    ${connected}=${True}
+    [Documentation]    Verifies peer's presence in bgp rib.
+    ${exp_status_code}    BuiltIn.Set_Variable_If    ${connected}    ${200}    ${404}
+    ${url}    BuiltIn.Set_Variable    ${PEER_URL}${ip}
+    ${response}    RequestsLibrary.Get_Request    ${session}    ${url}
+    BuiltIn.Should_Be_Equal_As_Numbers    ${exp_status_code}    ${response.status_code}
+    [Return]    ${response.content}
+
 Start_BGP_Manager
     [Arguments]    ${arguments}
     [Documentation]    Start the BGP manager python utility. Redirect its error output to a log file.
 Start_BGP_Manager
     [Arguments]    ${arguments}
     [Documentation]    Start the BGP manager python utility. Redirect its error output to a log file.
index a5dfe409b44bc069f8f736feee8841fb6b41e2d2..e66d6b18c9ca410ab97c4f50a6dcb0bff74cd84f 100644 (file)
@@ -14,6 +14,12 @@ Documentation     Basic tests for eBGP application peers.
 ...               Bug 4834 - ODL controller announces the same route twice (two eBGP scenario aka HA)
 ...               Bug 4835 - Routes not withdrawn when eBGP peers are disconnected (the same prefixes announced)
 ...
 ...               Bug 4834 - ODL controller announces the same route twice (two eBGP scenario aka HA)
 ...               Bug 4835 - Routes not withdrawn when eBGP peers are disconnected (the same prefixes announced)
 ...
+...               For versions Fluorine and above, there are test cases:
+...               TC_LAS (test case local AS)
+...               - configuration of ebgp with local-as and ibgp without local-as
+...               - connect bgp speakers (play.py) to both peers and check their connection
+...               - check adj-rib-out on both peers, expecting local-as in as-sequence on both peers.
+...
 ...               TODO: Extend testsuite by tests dedicated to path selection algorithm
 ...               TODO: Choose keywords used by more than one test suite to be placed in a common place.
 Suite Setup       Setup_Everything
 ...               TODO: Extend testsuite by tests dedicated to path selection algorithm
 ...               TODO: Choose keywords used by more than one test suite to be placed in a common place.
 Suite Setup       Setup_Everything
@@ -23,17 +29,18 @@ Test Teardown     FailFast.Start_Failing_Fast_If_This_Failed
 Library           Collections
 Library           OperatingSystem
 Library           RequestsLibrary
 Library           Collections
 Library           OperatingSystem
 Library           RequestsLibrary
-Variables         ${CURDIR}/../../../variables/Variables.py
-Variables         ${CURDIR}/../../../variables/bgpuser/variables.py    ${TOOLS_SYSTEM_IP}    ${ODL_STREAM}
-Resource          ${CURDIR}/../../../libraries/BGPcliKeywords.robot
-Resource          ${CURDIR}/../../../libraries/BgpOperations.robot
-Resource          ${CURDIR}/../../../libraries/BGPSpeaker.robot
-Resource          ${CURDIR}/../../../libraries/FailFast.robot
-Resource          ${CURDIR}/../../../libraries/KillPythonTool.robot
-Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
-Resource          ${CURDIR}/../../../libraries/SSHKeywords.robot
-Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
-Resource          ${CURDIR}/../../../libraries/WaitForFailure.robot
+Resource          ../../../libraries/BGPcliKeywords.robot
+Resource          ../../../libraries/BgpOperations.robot
+Resource          ../../../libraries/BGPSpeaker.robot
+Resource          ../../../libraries/CompareStream.robot
+Resource          ../../../libraries/FailFast.robot
+Resource          ../../../libraries/KillPythonTool.robot
+Resource          ../../../libraries/SetupUtils.robot
+Resource          ../../../libraries/SSHKeywords.robot
+Resource          ../../../libraries/TemplatedRequests.robot
+Resource          ../../../variables/Variables.robot
+Resource          ../../../libraries/WaitForFailure.robot
+Variables         ../../../variables/bgpuser/variables.py    ${TOOLS_SYSTEM_IP}    ${ODL_STREAM}
 
 *** Variables ***
 ${BGP_VARIABLES_FOLDER}    ${CURDIR}/../../../variables/bgpuser/
 
 *** Variables ***
 ${BGP_VARIABLES_FOLDER}    ${CURDIR}/../../../variables/bgpuser/
@@ -77,6 +84,9 @@ ${DEFAULT_TOPOLOGY_CHECK_PERIOD}    1s
 ${RIB_INSTANCE}    example-bgp-rib
 ${PROTOCOL_OPENCONFIG}    ${RIB_INSTANCE}
 ${DEVICE_NAME}    controller-config
 ${RIB_INSTANCE}    example-bgp-rib
 ${PROTOCOL_OPENCONFIG}    ${RIB_INSTANCE}
 ${DEVICE_NAME}    controller-config
+${DEFAULT_AS}     64496
+${LOCAL_AS}       65432
+${eBGP_AS}        64497
 
 *** Test Cases ***
 Configure_BGP_Peers
 
 *** Test Cases ***
 Configure_BGP_Peers
@@ -194,6 +204,81 @@ Delete_BGP_Peers_Configuration
     Collections.Set To Dictionary    ${mapping}    NAME=example-ebgp-peer2    IP=${eBGP_PEER2_IP}
     TemplatedRequests.Delete_Templated    ${BGP_VARIABLES_FOLDER}${/}ebgp_peers    mapping=${mapping}
 
     Collections.Set To Dictionary    ${mapping}    NAME=example-ebgp-peer2    IP=${eBGP_PEER2_IP}
     TemplatedRequests.Delete_Templated    ${BGP_VARIABLES_FOLDER}${/}ebgp_peers    mapping=${mapping}
 
+TC_LAS_Reconfigure_Odl_To_Accept_Connection
+    [Documentation]    Configure neighbors. One ibgp and one ebgp neighbor with local-as configured.
+    CompareStream.Run_Keyword_If_Less_Than_Fluorine    BuiltIn.Pass_Execution    Test case valid only for versions fluorine and above.
+    &{mapping}    Create Dictionary    IP=${iBGP_PEER1_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
+    TemplatedRequests.Put_As_Xml_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    mapping=${mapping}
+    &{mapping}    Create Dictionary    IP=${eBGP_PEER1_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
+    ...    AS_NUMBER=${LOCAL_AS}    PEER_AS=${eBGP_AS}
+    TemplatedRequests.Put_As_Xml_Templated    ${BGP_VARIABLES_FOLDER}${/}local_as/ebgp_peer    mapping=${mapping}
+    [Teardown]    SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
+
+TC_LAS_Start_iBgp_Speaker_And_Verify_Connected
+    [Documentation]    Verify that peer is present in odl's rib. Peer is configured with local-as.
+    [Tags]    critical
+    CompareStream.Run_Keyword_If_Less_Than_Fluorine    BuiltIn.Pass_Execution    Test case valid only for versions fluorine and above.
+    SSHLibrary.Switch Connection    ibgp_peer1_console
+    ${speaker_args}    BuiltIn.Set_Variable    --firstprefix ${iBGP_PEER1_FIRST_PREFIX_IP} --prefixlen ${PREFIX_LEN} --amount 1 --myip=${iBGP_PEER1_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT} --debug
+    ${output}    BGPSpeaker.Start_BGP_Speaker_And_Verify_Connected    ${speaker_args}    session=default    speaker_ip=${iBGP_PEER1_IP}
+    BuiltIn.Log    ${output}
+
+TC_LAS_Start_eBgp_Speaker_And_Verify_Connected
+    [Documentation]    Verify that peer is present in odl's rib. Peer is configured with local-as.
+    [Tags]    critical
+    CompareStream.Run_Keyword_If_Less_Than_Fluorine    BuiltIn.Pass_Execution    Test case valid only for versions fluorine and above.
+    SSHLibrary.Switch Connection    ebgp_peer1_console
+    ${speaker_args}    BuiltIn.Set_Variable    --firstprefix ${eBGP_PEER1_FIRST_PREFIX_IP} --prefixlen ${PREFIX_LEN} --amount 1 --asnumber=${eBGP_AS} --myip=${eBGP_PEER1_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT} --debug
+    ${output}    BGPSpeaker.Start_BGP_Speaker_And_Verify_Connected    ${speaker_args}    session=default    speaker_ip=${eBGP_PEER1_IP}
+    BuiltIn.Log    ${output}
+
+TC_LAS_Verify_iBGP_Rib_Out
+    [Documentation]    Verifies iBGP's adj-rib-out output. Expects local-as, and ebgp peer-as presence.
+    [Tags]    critical
+    CompareStream.Run_Keyword_If_Less_Than_Fluorine    BuiltIn.Pass_Execution    Test case valid only for versions fluorine and above.
+    &{mapping}    Create Dictionary    IP=${iBGP_PEER1_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
+    ...    AS_NUMBER=${LOCAL_AS}    PEER_AS=${eBGP_AS}    PREFIXLEN=${eBGP_PEER1_FIRST_PREFIX_IP}/${PREFIX_LEN}
+    BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_TOPOLOGY_CHECK_TIMEOUT}    ${DEFAULT_TOPOLOGY_CHECK_PERIOD}    TemplatedRequests.Get_As_Json_Templated    ${BGP_VARIABLES_FOLDER}${/}local_as/adj_rib_out    mapping=${mapping}    verify=True
+
+TC_LAS_Verify_eBGP_Rib_Out
+    [Documentation]    Verifies eBGP's adj-rib-out output. Expects local-as, and ibgp peer-as presence.
+    [Tags]    critical
+    CompareStream.Run_Keyword_If_Less_Than_Fluorine    BuiltIn.Pass_Execution    Test case valid only for versions fluorine and above.
+    &{mapping}    Create Dictionary    IP=${eBGP_PEER1_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
+    ...    AS_NUMBER=${LOCAL_AS}    PEER_AS=${DEFAULT_AS}    PREFIXLEN=${iBGP_PEER1_FIRST_PREFIX_IP}/${PREFIX_LEN}
+    BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_TOPOLOGY_CHECK_TIMEOUT}    ${DEFAULT_TOPOLOGY_CHECK_PERIOD}    TemplatedRequests.Get_As_Json_Templated    ${BGP_VARIABLES_FOLDER}${/}local_as/adj_rib_out    mapping=${mapping}    verify=True
+
+TC_LAS_Kill_iBgp_Speaker_After_Talking
+    [Documentation]    Abort the Python speaker. Also, attempt to stop failing fast.
+    [Tags]    critical
+    [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
+    CompareStream.Run_Keyword_If_Less_Than_Fluorine    BuiltIn.Pass_Execution    Test case valid only for versions fluorine and above.
+    SSHLibrary.Switch Connection    ibgp_peer1_console
+    BGPSpeaker.Kill_BGP_Speaker
+    FailFast.Do_Not_Fail_Fast_From_Now_On
+    # NOTE: It is still possible to remain failing fast, if both previous and this test have failed.
+    [Teardown]    FailFast.Do_Not_Start_Failing_If_This_Failed
+
+TC_LAS_Kill_eBgp_Speaker_After_Talking
+    [Documentation]    Abort the Python speaker. Also, attempt to stop failing fast.
+    [Tags]    critical
+    [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
+    CompareStream.Run_Keyword_If_Less_Than_Fluorine    BuiltIn.Pass_Execution    Test case valid only for versions fluorine and above.
+    SSHLibrary.Switch Connection    ebgp_peer1_console
+    BGPSpeaker.Kill_BGP_Speaker
+    FailFast.Do_Not_Fail_Fast_From_Now_On
+    # NOTE: It is still possible to remain failing fast, if both previous and this test have failed.
+    [Teardown]    FailFast.Do_Not_Start_Failing_If_This_Failed
+
+TC_LAS_Delete_Bgp_Peer_Configurations
+    [Documentation]    Delete peer configuration.
+    CompareStream.Run_Keyword_If_Less_Than_Fluorine    BuiltIn.Pass_Execution    Test case valid only for versions fluorine and above.
+    &{mapping}    Create Dictionary    IP=${iBGP_PEER1_IP}    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
+    TemplatedRequests.Delete_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    mapping=${mapping}
+    &{mapping}    Create Dictionary    IP=${eBGP_PEER1_IP}    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
+    TemplatedRequests.Delete_Templated    ${BGP_VARIABLES_FOLDER}${/}local_as/ebgp_peer    mapping=${mapping}
+    [Teardown]    SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
+
 *** Keywords ***
 Setup_Everything
     [Documentation]    Initialize SetupUtils. SSH-login to mininet machine, create HTTP session,
 *** Keywords ***
 Setup_Everything
     [Documentation]    Initialize SetupUtils. SSH-login to mininet machine, create HTTP session,
diff --git a/csit/variables/bgpuser/local_as/adj_rib_out/data.json b/csit/variables/bgpuser/local_as/adj_rib_out/data.json
new file mode 100644 (file)
index 0000000..47d6306
--- /dev/null
@@ -0,0 +1,29 @@
+{
+    "bgp-inet:ipv4-routes": {
+        "ipv4-route": [
+            {
+                "attributes": {
+                    "as-path": {
+                        "segments": [
+                            {
+                                "as-sequence": [
+                                    $AS_NUMBER,
+                                    $PEER_AS
+                                ]
+                            }
+                        ]
+                    },
+                    "ipv4-next-hop": {
+                        "global": "192.0.2.1"
+                    },
+                    "origin": {
+                        "value": "igp"
+                    }
+                },
+                "path-id": 0,
+                "prefix": "$PREFIXLEN",
+                "route-key": "$PREFIXLEN"
+            }
+        ]
+    }
+}
diff --git a/csit/variables/bgpuser/local_as/adj_rib_out/location.uri b/csit/variables/bgpuser/local_as/adj_rib_out/location.uri
new file mode 100644 (file)
index 0000000..add56d0
--- /dev/null
@@ -0,0 +1 @@
+restconf/operational/bgp-rib:bgp-rib/rib/$BGP_RIB_OPENCONFIG/peer/bgp:%2F%2F$IP/adj-rib-out/tables/bgp-types:ipv4-address-family/bgp-types:unicast-subsequent-address-family/bgp-inet:ipv4-routes
diff --git a/csit/variables/bgpuser/local_as/ebgp_peer/data.xml b/csit/variables/bgpuser/local_as/ebgp_peer/data.xml
new file mode 100644 (file)
index 0000000..ff87dda
--- /dev/null
@@ -0,0 +1,31 @@
+<neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
+    <neighbor-address>$IP</neighbor-address>
+    <timers>
+        <config>
+            <hold-time>$HOLDTIME</hold-time>
+            <connect-retry>5</connect-retry>
+        </config>
+    </timers>
+    <transport>
+        <config>
+            <remote-port>$PEER_PORT</remote-port>
+            <passive-mode>$PASSIVE_MODE</passive-mode>
+        </config>
+    </transport>
+    <config>
+        <peer-type>EXTERNAL</peer-type>
+        <peer-as>$PEER_AS</peer-as>
+        <local-as>$AS_NUMBER</local-as>
+    </config>
+    <afi-safis>
+        <afi-safi>
+            <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV4-UNICAST</afi-safi-name>
+        </afi-safi>
+        <afi-safi>
+            <afi-safi-name xmlns:x="http://openconfig.net/yang/bgp-types">x:IPV6-UNICAST</afi-safi-name>
+        </afi-safi>
+        <afi-safi>
+            <afi-safi-name>LINKSTATE</afi-safi-name>
+        </afi-safi>
+    </afi-safis>
+</neighbor>
diff --git a/csit/variables/bgpuser/local_as/ebgp_peer/location.uri b/csit/variables/bgpuser/local_as/ebgp_peer/location.uri
new file mode 100644 (file)
index 0000000..d713ddf
--- /dev/null
@@ -0,0 +1 @@
+restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols/protocol/openconfig-policy-types:BGP/$BGP_RIB_OPENCONFIG/bgp/neighbors/neighbor/$IP