Fix bgpcep-1node-userfeatures tests
[integration/test.git] / csit / suites / bgpcep / bgpfunct / bgp_ipv6_basic.robot
index aab5e569c12374fcce1fb835e5bb2070aebe550e..d523f5bf6fce2009fb02e05e9cb2543d43e328f0 100644 (file)
@@ -1,12 +1,12 @@
 *** Settings ***
 Documentation     Functional test for ipv6 connection with bgp.
-...           
+...
 ...               Copyright (c) 2018 AT&T 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 (exabgp) and Odl.
 ...               Peer is configured with ipv6, and exabgp connectes to odl via ipv6.
 ...               Exabgp sends one ipv6 unicast route, which presence is verified in
@@ -28,6 +28,7 @@ Resource          ../../../libraries/SSHKeywords.robot
 Resource          ../../../libraries/TemplatedRequests.robot
 Resource          ../../../libraries/Utils.robot
 Resource          ../../../variables/Variables.robot
+Resource          ../../../libraries/KarafKeywords.robot
 
 *** Variables ***
 ${BGP_VAR_FOLDER}    ${CURDIR}/../../../variables/bgpfunctional/ipv6
@@ -39,12 +40,17 @@ ${EXABGP_CFG}     exaipv6.cfg
 ${EXABGP_LOG}     exaipv6.log
 ${EXABGP2_CFG}    exaipv4.cfg
 ${EXABGP2_LOG}    exaipv4.log
+${EXABGP3_CFG}    exabgp_graceful_restart.cfg
+${EXABGP3_LOG}    exabgp_graceful_restart.log
+${EXABGP4_CFG}    exa4.cfg
+${EXABGP4_LOG}    exa4.log
 ${IPV4_IP}        127.0.0.1
 ${CONTROLLER_IPV4}    ${ODL_SYSTEM_IP}
 ${IPV6_IP}        2607:f0d0:1002:0011:0000:0000:0000:0002
 ${IPV6_IP_2}      2607:f0d0:1002:11:0:0:0:2
 ${IPV6_IP_3}      2607:f0d0:1002:11::2
 ${IPV6_IP_GW}     2607:f0d0:1002:0011:0000:0000:0000:0001
+${IPV6_PREFIX_LENGTH}    64
 ${HOLDTIME}       180
 ${RIB_INSTANCE}    example-bgp-rib
 
@@ -226,6 +232,68 @@ Stop_All_Exabgps_2
     ${Log_Content}    OperatingSystem.Get File    ${EXABGP2_LOG}
     Log    ${Log_Content}
 
+Reconfigure_ODL_To_Accept_Connections_6
+    [Documentation]    Configure BGP peer modules with initiate-connection set to false with short ipv6 address.
+    &{mapping}    Create Dictionary    IP=${IPV6_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}/graceful_restart    mapping=${mapping}    session=${CONFIG_SESSION}
+
+Start_Exabgp_3
+    [Documentation]    Start exabgp with
+    [Tags]    critical
+    ${cmd}    BuiltIn.Set_Variable    ${EXABGP3_CFG} > ${EXABGP3_LOG}
+    ExaBgpLib.Start_ExaBgp_And_Verify_Connected    ${cmd}    ${CONFIG_SESSION}    ${EXABGP_ID}
+
+Stop_All_Exabgps_3
+    [Documentation]    Save exabgp logs as exabgp_graceful_restart.log, and stop exabgp with ctrl-c bash signal
+    BGPcliKeywords.Store_File_To_Workspace    ${EXABGP3_LOG}    ${EXABGP3_LOG}
+    ExaBgpLib.Stop_ExaBgp
+    Sleep    40s
+    KarafKeywords.Fail If Exceptions Found During Test    ${SUITE_NAME}.${TEST_NAME}    fail=${True}
+
+Start_Exabgp_4
+    [Documentation]    Start exabgp with
+    [Tags]    critical
+    ${cmd}    BuiltIn.Set_Variable    ${EXABGP3_CFG} > ${EXABGP3_LOG}
+    ExaBgpLib.Start_ExaBgp_And_Verify_Connected    ${cmd}    ${CONFIG_SESSION}    ${EXABGP_ID}
+
+Delete_Bgp_Peer_Configuration_6
+    [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
+    &{mapping}    Create Dictionary    IP=${IPV6_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}/graceful_restart    mapping=${mapping}    session=${CONFIG_SESSION}
+
+Stop_All_Exabgps_4
+    [Documentation]    Save exabgp logs as exabgp_graceful_restart.log, and stop exabgp with ctrl-c bash signal
+    BGPcliKeywords.Store_File_To_Workspace    ${EXABGP3_LOG}    ${EXABGP3_LOG}
+    ExaBgpLib.Stop_ExaBgp
+
+Reconfigure_ODL_To_Accept_Connections_7
+    [Documentation]    Configure BGP peer modules with initiate-connection set to false with short ipv6 address.
+    [Tags]    exclude
+    &{mapping}    Create Dictionary    IP=${IPV6_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_Exabgp_5
+    [Documentation]    Start exabgp with
+    [Tags]    exclude
+    ${cmd}    BuiltIn.Set_Variable    ${EXABGP4_CFG} > ${EXABGP4_LOG}
+    ExaBgpLib.Start_ExaBgp_And_Verify_Connected    ${cmd}    ${CONFIG_SESSION}    ${EXABGP_ID}
+
+Delete_Bgp_Peer_Configuration_7
+    [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
+    [Tags]    exclude
+    &{mapping}    Create Dictionary    IP=${IPV6_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_Exabgps_5
+    [Documentation]    Save exabgp logs as exabgp_graceful_restart.log, and stop exabgp with ctrl-c bash signal
+    [Tags]    exclude
+    BGPcliKeywords.Store_File_To_Workspace    ${EXABGP4_LOG}    ${EXABGP4_LOG}
+    ExaBgpLib.Stop_ExaBgp
+
 *** Keywords ***
 Start_Suite
     [Documentation]    Suite setup keyword.
@@ -240,6 +308,8 @@ Start_Suite
     RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
     Upload_Config_Files
     Upload_Config_Files_exabgp_ipv4
+    Upload_Config_Files_exabgp_graceful_restart
+    Upload_Config_Files_Exabgp_AS_Value_Reconfigured
 
 Stop_Suite
     [Documentation]    Suite teardown keyword
@@ -250,11 +320,12 @@ Stop_Suite
 
 Configure_Ipv6_Network
     [Documentation]    Reconfigures basic network settings on controller
-    SSHLibrary.Execute_Command    sudo sh -c 'echo "NETWORKING_IPV6=yes" >> /etc/sysconfig/network'
-    SSHLibrary.Execute_Command    sudo sh -c 'echo "IPV6INIT=yes" >> /etc/sysconfig/network-scripts/ifcfg-eth0'
-    SSHLibrary.Execute_Command    sudo sh -c 'echo "IPV6ADDR=${IPV6_IP}" >> /etc/sysconfig/network-scripts/ifcfg-eth0'
-    SSHLibrary.Execute_Command    sudo sh -c 'echo "IPV6_DEFAULTGW=${IPV6_IP_GW}" >> /etc/sysconfig/network-scripts/ifcfg-eth0'
-    SSHLibrary.Execute_Command    sudo /etc/init.d/network restart
+    SSHLibrary.Execute_Command    sudo ip -6 addr add ${IPV6_IP}/${IPV6_PREFIX_LENGTH} dev eth0
+    SSHLibrary.Execute_Command    sudo ip -6 route add default via ${IPV6_IP_GW}
+    ${stdout}=    SSHLibrary.Execute_Command    sudo ip -6 addr show
+    Log    ${stdout}
+    ${stdout}=    SSHLibrary.Execute_Command    sudo ip -6 route show
+    Log    ${stdout}
 
 Verify_Rib_Status_Empty
     [Documentation]    Verifies that example-ipv6-topology is empty
@@ -291,3 +362,31 @@ Upload_Config_Files_exabgp_ipv4
         ${stdout}=    SSHLibrary.Execute_Command    cat ${cfgfile}
         Log    ${stdout}
     END
+
+Upload_Config_Files_exabgp_graceful_restart
+    [Documentation]    Uploads exabgp config files
+    SSHLibrary.Put_File    ${BGP_VAR_FOLDER}/${EXABGP3_CFG}    .
+    @{cfgfiles}=    SSHLibrary.List_Files_In_Directory    .    *restart.cfg
+    FOR    ${cfgfile}    IN    @{cfgfiles}
+        SSHLibrary.Execute_Command    sed -i -e 's/EXABGPIP/${IPV6_IP}/g' ${cfgfile}
+        SSHLibrary.Execute_Command    sed -i -e 's/ODLIP/${CONTROLLER_IPV6}/g' ${cfgfile}
+        SSHLibrary.Execute_Command    sed -i -e 's/ROUTERID/${EXABGP_ID}/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
+
+Upload_Config_Files_Exabgp_AS_Value_Reconfigured
+    [Documentation]    Uploads exabgp config files
+    SSHLibrary.Put_File    ${BGP_VAR_FOLDER}/${EXABGP4_CFG}    .
+    @{cfgfiles}=    SSHLibrary.List_Files_In_Directory    .    *exa4.cfg
+    FOR    ${cfgfile}    IN    @{cfgfiles}
+        SSHLibrary.Execute_Command    sed -i -e 's/EXABGPIP/${IPV6_IP}/g' ${cfgfile}
+        SSHLibrary.Execute_Command    sed -i -e 's/ODLIP/${CONTROLLER_IPV6}/g' ${cfgfile}
+        SSHLibrary.Execute_Command    sed -i -e 's/ROUTERID/${EXABGP_ID}/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