8173b6b5583f678aac6a30297ea2cf180d328244
[integration/test.git] / csit / suites / bgpcep / bgpfunct / bgp_llgr_basic.robot
1 *** Settings ***
2 Documentation     Functional test for ipv6 connection with bgp.
3 ...
4 ...               Copyright (c) 2020 Lumina Networks Intellectual Property. All rights reserved.
5 ...
6 ...               This program and the accompanying materials are made available under the
7 ...               terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 ...               and is available at http://www.eclipse.org/legal/epl-v10.html
9 ...
10 ...               This suite tests simple connection between one ibgp peer (goabgp) and Odl.
11 ...               Peer is configured with ipv6, and gobgp connectes to odl via ipv6.
12 Suite Setup       Start_Suite
13 Suite Teardown    Stop_Suite
14 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
15 Library           RequestsLibrary
16 Library           SSHLibrary
17 Resource          ../../../variables/Variables.robot
18 Resource          ../../../libraries/BGPcliKeywords.robot
19 Resource          ../../../libraries/GoBgpLib.robot
20 Resource          ../../../libraries/SetupUtils.robot
21 Resource          ../../../libraries/SSHKeywords.robot
22 Resource          ../../../libraries/TemplatedRequests.robot
23
24 *** Variables ***
25 ${BGP_VAR_FOLDER}    ${CURDIR}/../../../variables/bgpfunctional/ipv6
26 ${GOBGP_FOLDER}    ${CURDIR}/../../../variables/bgpfunctional/gobgp
27 ${CONFIG_SESSION}    config-session
28 ${GOBGP_CFG}      gobgp.cfg
29 ${GOBGP_LOG}      gobgp.log
30 ${HOLDTIME}       180
31 ${RIB_INSTANCE}    example-bgp-rib
32 ${GOBGP_BINARY_URL}    https://github.com/osrg/gobgp/releases/download/v2.18.0/gobgp_2.18.0_linux_386.tar.gz
33 ${FILE_NAME}      gobgp_2.18.0_linux_386.tar.gz
34
35 *** Test Cases ***
36 Reconfigure_ODL_To_Accept_Connections
37     [Documentation]    Configure BGP peer modules with initiate-connection set to false with short ipv6 address.
38     &{mapping}    Create Dictionary    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    INITIATE=false    BGP_RIB=${RIB_INSTANCE}
39     ...    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${RIB_INSTANCE}    RIB_INSTANCE_NAME=${RIB_INSTANCE}
40     TemplatedRequests.Put_As_Xml_Templated    ${BGP_VAR_FOLDER}/bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
41
42 Start_Gobgp
43     [Tags]    critical
44     ${cmd}    BuiltIn.Set Variable    ${GOBGP_CFG} > ${GOBGP_LOG}
45     GoBgpLib.Start_GoBgp_And_Verify_Connected    ${cmd}    ${CONFIG_SESSION}    ${TOOLS_SYSTEM_IP}
46
47 Delete_Bgp_Peer_Configuration
48     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
49     &{mapping}    Create Dictionary    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    INITIATE=false    BGP_RIB=${RIB_INSTANCE}
50     ...    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${RIB_INSTANCE}    RIB_INSTANCE_NAME=${RIB_INSTANCE}
51     TemplatedRequests.Delete_Templated    ${BGP_VAR_FOLDER}/bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
52
53 Stop_All_Gobgps
54     [Documentation]    Save exabgp logs as exaipv6.log, and stop exabgp with ctrl-c bash signal
55     BGPcliKeywords.Store_File_To_Workspace    ${GOBGP_LOG}    ${GOBGP_LOG}
56     GoBgpLib.Stop_GoBgp
57
58 *** Keywords ***
59 Start_Suite
60     [Documentation]    Suite setup keyword.
61     SetupUtils.Setup_Utils_For_Setup_And_Teardown
62     ${tools_system_conn_id}=    SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=6s
63     Builtin.Set_Suite_Variable    ${tools_system_conn_id}
64     SSHKeywords.Flexible_Mininet_Login    ${TOOLS_SYSTEM_USER}
65     RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
66     Upload_Config_Files
67     Download_Gobgp_Binary
68
69 Stop_Suite
70     [Documentation]    Suite teardown keyword
71     SSHLibrary.Close_All_Connections
72     RequestsLibrary.Delete_All_Sessions
73     BuiltIn.Run Keyword And Ignore Error    GoBgpLib.Stop_GoBgp
74
75 Upload_Config_Files
76     [Documentation]    Uploads gobgp config files
77     SSHLibrary.Put_File    ${GOBGP_FOLDER}/${GOBGP_CFG}    .
78     @{cfgfiles}=    SSHLibrary.List_Files_In_Directory    .    *.cfg
79     FOR    ${cfgfile}    IN    @{cfgfiles}
80         SSHLibrary.Execute_Command    sed -i -e 's/GOBGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
81         SSHLibrary.Execute_Command    sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
82         SSHLibrary.Execute_Command    sed -i -e 's/ROUTERID/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
83         SSHLibrary.Execute_Command    sed -i -e 's/ROUTEREFRESH/disable/g' ${cfgfile}
84         SSHLibrary.Execute_Command    sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
85         ${stdout}=    SSHLibrary.Execute_Command    cat ${cfgfile}
86         Log    ${stdout}
87     END
88
89 Download_Gobgp_Binary
90     [Documentation]    Downloads gobgp binary and untar the binary zip file
91     SSHKeywords.Open_Connection_To_Tools_System    ${TOOLS_SYSTEM_IP}
92     SSHLibrary.Execute Command    wget ${GOBGP_BINARY_URL}
93     SSHLibrary.File Should Exist    ./${FILE_NAME}
94     SSHLibrary.Execute Command    tar -xzf ${FILE_NAME}