Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / suites / bgpcep / bgpfunct / bgp_functional_md5.robot
1 *** Settings ***
2 Documentation     Functional test suite for bgp - n-path and all-path selection
3 ...
4 ...               Copyright (c) 2017 Cisco Systems, Inc. and others. 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 tcpmd5 connection of bgp peers. It uses odl and exabgp as bgp
11 ...               peer. No routes are advertized, simple peer presence in the datastore is tested.
12 ...               are configured via application peer.
13 Suite Setup       Start_Suite
14 Suite Teardown    Stop_Suite
15 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
16 Test Teardown     Delete_Bgp_Peer_Configuration
17 Library           RequestsLibrary
18 Library           SSHLibrary
19 Resource          ${CURDIR}/../../../variables/Variables.robot
20 Resource          ${CURDIR}/../../../libraries/BGPcliKeywords.robot
21 Resource          ${CURDIR}/../../../libraries/CompareStream.robot
22 Resource          ${CURDIR}/../../../libraries/ExaBgpLib.robot
23 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
24 Resource          ${CURDIR}/../../../libraries/SSHKeywords.robot
25 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
26 Resource          ${CURDIR}/../../../libraries/WaitForFailure.robot
27
28 *** Variables ***
29 ${HOLDTIME}       180
30 ${BGP_VAR_FOLDER}    ${CURDIR}/../../../variables/bgpfunctional/bgp_md5
31 ${BGP_PEER_FOLDER}    ${BGP_VAR_FOLDER}${/}bgp_peer
32 ${BGP_EXAMD5_CFG}    exa-md5.cfg
33 ${MD5_SAME_PASSWD}    topsecret
34 ${MD5_DIFF_PASSWD}    different
35 ${PROTOCOL_OPENCONFIG}    example-bgp-rib
36 ${CONFIG_SESSION}    session
37
38 *** Test Cases ***
39 Verify Exabgp Connected
40     [Documentation]    Verifies exabgp connected with md5 settings
41     [Tags]    critical
42     [Setup]    Reconfigure_ODL_To_Accept_Connection    ${MD5_SAME_PASSWD}
43     ExaBgpLib.Start_ExaBgp_And_Verify_Connected    ${BGP_EXAMD5_CFG}    ${CONFIG_SESSION}    ${TOOLS_SYSTEM_IP}    connection_retries=${3}
44     ExaBgpLib.Stop_ExaBgp
45
46 Verify Exabgp Not Connected
47     [Documentation]    Verifies exabgp connected with md5 settings
48     [Tags]    critical
49     [Setup]    Reconfigure_ODL_To_Accept_Connection    ${MD5_DIFF_PASSWD}
50     ExaBgpLib.Start_ExaBgp    ${BGP_EXAMD5_CFG}
51     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout    15s    2s    ExaBgpLib.Verify_ExaBgps_Connection    ${CONFIG_SESSION}    ${TOOLS_SYSTEM_IP}
52     ExaBgpLib.Stop_ExaBgp
53
54 *** Keywords ***
55 Start_Suite
56     [Documentation]    Suite setup keyword.
57     SetupUtils.Setup_Utils_For_Setup_And_Teardown
58     ${tools_system_conn_id}=    SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=6s
59     Builtin.Set_Suite_Variable    ${tools_system_conn_id}
60     SSHKeywords.Flexible_Mininet_Login    ${TOOLS_SYSTEM_USER}
61     SSHKeywords.Virtual_Env_Create
62     SSHKeywords.Virtual_Env_Install_Package    exabgp==3.4.17
63     RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
64     Upload_Config_Files
65
66 Stop_Suite
67     [Documentation]    Suite teardown keyword with old rib restoration
68     SSHKeywords.Virtual_Env_Delete
69     SSHLibrary.Close_All_Connections
70     RequestsLibrary.Delete_All_Sessions
71
72 Reconfigure_ODL_To_Accept_Connection
73     [Arguments]    ${password}
74     [Documentation]    Configures BGP peer module with initiate-connection set to false.
75     &{mapping}    BuiltIn.Create_Dictionary    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    PASSWORD=${password}
76     ...    PASSIVE_MODE=true
77     TemplatedRequests.Put_As_Xml_Templated    ${BGP_PEER_FOLDER}    mapping=${mapping}    session=${CONFIG_SESSION}
78
79 Delete_Bgp_Peer_Configuration
80     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
81     &{mapping}    BuiltIn.Create_Dictionary    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}    IP=${TOOLS_SYSTEM_IP}
82     TemplatedRequests.Delete_Templated    ${BGP_PEER_FOLDER}    mapping=${mapping}    session=${CONFIG_SESSION}
83
84 Upload_Config_Files
85     [Arguments]    ${addpath}=disable
86     [Documentation]    Uploads exabgp config files
87     SSHLibrary.Put_File    ${BGP_VAR_FOLDER}${/}exa-md5.cfg    .
88     @{cfgfiles}=    SSHLibrary.List_Files_In_Directory    .    *.cfg
89     FOR    ${cfgfile}    IN    @{cfgfiles}
90         SSHLibrary.Execute_Command    sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
91         SSHLibrary.Execute_Command    sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
92         SSHLibrary.Execute_Command    sed -i -e 's/ROUTEREFRESH/enable/g' ${cfgfile}
93         SSHLibrary.Execute_Command    sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
94         SSHLibrary.Execute_Command    sed -i -e 's/PASSWORD/${MD5_SAME_PASSWD}/g' ${cfgfile}
95         ${stdout}=    SSHLibrary.Execute_Command    cat ${cfgfile}
96         Log    ${stdout}
97     END