Migrate Get Requests invocations(libraries)
[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
13 Library             RequestsLibrary
14 Library             SSHLibrary
15 Resource            ../../../variables/Variables.robot
16 Resource            ../../../libraries/BGPcliKeywords.robot
17 Resource            ../../../libraries/GoBgpLib.robot
18 Resource            ../../../libraries/SetupUtils.robot
19 Resource            ../../../libraries/SSHKeywords.robot
20 Resource            ../../../libraries/TemplatedRequests.robot
21
22 Suite Setup         Start_Suite
23 Suite Teardown      Stop_Suite
24 Test Setup          SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
25
26
27 *** Variables ***
28 ${BGP_VAR_FOLDER}       ${CURDIR}/../../../variables/bgpfunctional/ipv6
29 ${GOBGP_FOLDER}         ${CURDIR}/../../../variables/bgpfunctional/gobgp
30 ${CONFIG_SESSION}       config-session
31 ${GOBGP_CFG}            gobgp.cfg
32 ${GOBGP_LOG}            gobgp.log
33 ${HOLDTIME}             180
34 ${RIB_INSTANCE}         example-bgp-rib
35 ${GOBGP_BINARY_URL}     https://github.com/osrg/gobgp/releases/download/v2.18.0/gobgp_2.18.0_linux_386.tar.gz
36 ${FILE_NAME}            gobgp_2.18.0_linux_386.tar.gz
37
38
39 *** Test Cases ***
40 Reconfigure_ODL_To_Accept_Connections
41     [Documentation]    Configure BGP peer modules with initiate-connection set to false with short ipv6 address.
42     &{mapping}    Create Dictionary
43     ...    IP=${TOOLS_SYSTEM_IP}
44     ...    HOLDTIME=${HOLDTIME}
45     ...    PEER_PORT=${BGP_TOOL_PORT}
46     ...    INITIATE=false
47     ...    BGP_RIB=${RIB_INSTANCE}
48     ...    PASSIVE_MODE=true
49     ...    BGP_RIB_OPENCONFIG=${RIB_INSTANCE}
50     ...    RIB_INSTANCE_NAME=${RIB_INSTANCE}
51     TemplatedRequests.Put_As_Xml_Templated
52     ...    ${BGP_VAR_FOLDER}/bgp_peer
53     ...    mapping=${mapping}
54     ...    session=${CONFIG_SESSION}
55
56 Start_Gobgp
57     [Tags]    critical
58     ${cmd}    BuiltIn.Set Variable    ${GOBGP_CFG} > ${GOBGP_LOG}
59     GoBgpLib.Start_GoBgp_And_Verify_Connected    ${cmd}    ${CONFIG_SESSION}    ${TOOLS_SYSTEM_IP}
60
61 Delete_Bgp_Peer_Configuration
62     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
63     &{mapping}    Create Dictionary
64     ...    IP=${TOOLS_SYSTEM_IP}
65     ...    HOLDTIME=${HOLDTIME}
66     ...    PEER_PORT=${BGP_TOOL_PORT}
67     ...    INITIATE=false
68     ...    BGP_RIB=${RIB_INSTANCE}
69     ...    PASSIVE_MODE=true
70     ...    BGP_RIB_OPENCONFIG=${RIB_INSTANCE}
71     ...    RIB_INSTANCE_NAME=${RIB_INSTANCE}
72     TemplatedRequests.Delete_Templated    ${BGP_VAR_FOLDER}/bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
73
74 Stop_All_Gobgps
75     [Documentation]    Save exabgp logs as exaipv6.log, and stop exabgp with ctrl-c bash signal
76     BGPcliKeywords.Store_File_To_Workspace    ${GOBGP_LOG}    ${GOBGP_LOG}
77     GoBgpLib.Stop_GoBgp
78
79
80 *** Keywords ***
81 Start_Suite
82     [Documentation]    Suite setup keyword.
83     SetupUtils.Setup_Utils_For_Setup_And_Teardown
84     ${tools_system_conn_id}    SSHLibrary.Open_Connection
85     ...    ${TOOLS_SYSTEM_IP}
86     ...    prompt=${DEFAULT_LINUX_PROMPT}
87     ...    timeout=6s
88     Builtin.Set_Suite_Variable    ${tools_system_conn_id}
89     SSHKeywords.Flexible_Mininet_Login    ${TOOLS_SYSTEM_USER}
90     RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
91     Upload_Config_Files
92     Download_Gobgp_Binary
93
94 Stop_Suite
95     [Documentation]    Suite teardown keyword
96     SSHLibrary.Close_All_Connections
97     RequestsLibrary.Delete_All_Sessions
98     BuiltIn.Run Keyword And Ignore Error    GoBgpLib.Stop_GoBgp
99
100 Upload_Config_Files
101     [Documentation]    Uploads gobgp config files
102     SSHLibrary.Put_File    ${GOBGP_FOLDER}/${GOBGP_CFG}    .
103     @{cfgfiles}    SSHLibrary.List_Files_In_Directory    .    *.cfg
104     FOR    ${cfgfile}    IN    @{cfgfiles}
105         SSHLibrary.Execute_Command    sed -i -e 's/GOBGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
106         SSHLibrary.Execute_Command    sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
107         SSHLibrary.Execute_Command    sed -i -e 's/ROUTERID/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
108         SSHLibrary.Execute_Command    sed -i -e 's/ROUTEREFRESH/disable/g' ${cfgfile}
109         SSHLibrary.Execute_Command    sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
110         ${stdout}    SSHLibrary.Execute_Command    cat ${cfgfile}
111         Log    ${stdout}
112     END
113
114 Download_Gobgp_Binary
115     [Documentation]    Downloads gobgp binary and untar the binary zip file
116     SSHKeywords.Open_Connection_To_Tools_System    ${TOOLS_SYSTEM_IP}
117     SSHLibrary.Execute Command    wget ${GOBGP_BINARY_URL}
118     SSHLibrary.File Should Exist    ./${FILE_NAME}
119     SSHLibrary.Execute Command    tar -xzf ${FILE_NAME}