5e4cfc1bacd68ceedabb83e7aa308b14fc69cb28
[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/Utils.robot
27 Resource          ${CURDIR}/../../../libraries/WaitForFailure.robot
28
29 *** Variables ***
30 ${HOLDTIME}       180
31 ${BGP_VAR_FOLDER}    ${CURDIR}/../../../variables/bgpfunctional/bgp_md5
32 ${BGP_PEER_FOLDER}    ${BGP_VAR_FOLDER}${/}bgp_peer
33 ${BGP_EXAMD5_CFG}    exa-md5.cfg
34 ${MD5_SAME_PASSWD}    topsecret
35 ${MD5_DIFF_PASSWD}    different
36 ${PROTOCOL_OPENCONFIG}    example-bgp-rib
37 ${CONFIG_SESSION}    session
38
39 *** Test Cases ***
40 Verify Exabgp Connected
41     [Documentation]    Verifies exabgp connected with md5 settings
42     [Tags]    critical
43     [Setup]    Reconfigure_ODL_To_Accept_Connection    ${MD5_SAME_PASSWD}
44     ExaBgpLib.Start_ExaBgp_And_Verify_Connected    ${BGP_EXAMD5_CFG}    ${CONFIG_SESSION}    ${TOOLS_SYSTEM_IP}    connection_retries=${3}
45     ExaBgpLib.Stop_ExaBgp
46
47 Verify Exabgp Not Connected
48     [Documentation]    Verifies exabgp connected with md5 settings
49     [Tags]    critical
50     [Setup]    Reconfigure_ODL_To_Accept_Connection    ${MD5_DIFF_PASSWD}
51     ExaBgpLib.Start_ExaBgp    ${BGP_EXAMD5_CFG}
52     WaitForFailure.Verify_Keyword_Never_Passes_Within_Timeout    15s    2s    ExaBgpLib.Verify_ExaBgps_Connection    ${CONFIG_SESSION}    ${TOOLS_SYSTEM_IP}
53     ExaBgpLib.Stop_ExaBgp
54
55 *** Keywords ***
56 Start_Suite
57     [Documentation]    Suite setup keyword.
58     SetupUtils.Setup_Utils_For_Setup_And_Teardown
59     ${tools_system_conn_id}=    SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=6s
60     Builtin.Set_Suite_Variable    ${tools_system_conn_id}
61     Utils.Flexible_Mininet_Login    ${TOOLS_SYSTEM_USER}
62     SSHKeywords.Virtual_Env_Create
63     SSHKeywords.Virtual_Env_Install_Package    exabgp==3.4.17
64     RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
65     Upload_Config_Files
66
67 Stop_Suite
68     [Documentation]    Suite teardown keyword with old rib restoration
69     SSHKeywords.Virtual_Env_Delete
70     SSHLibrary.Close_All_Connections
71     RequestsLibrary.Delete_All_Sessions
72
73 Reconfigure_ODL_To_Accept_Connection
74     [Arguments]    ${password}
75     [Documentation]    Configures BGP peer module with initiate-connection set to false.
76     &{mapping}    BuiltIn.Create_Dictionary    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    PASSWORD=${password}
77     ...    PASSIVE_MODE=true
78     TemplatedRequests.Put_As_Xml_Templated    ${BGP_PEER_FOLDER}    mapping=${mapping}    session=${CONFIG_SESSION}
79
80 Delete_Bgp_Peer_Configuration
81     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
82     &{mapping}    BuiltIn.Create_Dictionary    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}    IP=${TOOLS_SYSTEM_IP}
83     TemplatedRequests.Delete_Templated    ${BGP_PEER_FOLDER}    mapping=${mapping}    session=${CONFIG_SESSION}
84
85 Upload_Config_Files
86     [Arguments]    ${addpath}=disable
87     [Documentation]    Uploads exabgp config files
88     SSHLibrary.Put_File    ${BGP_VAR_FOLDER}${/}exa-md5.cfg    .
89     @{cfgfiles}=    SSHLibrary.List_Files_In_Directory    .    *.cfg
90     : FOR    ${cfgfile}    IN    @{cfgfiles}
91     \    SSHLibrary.Execute_Command    sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
92     \    SSHLibrary.Execute_Command    sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
93     \    SSHLibrary.Execute_Command    sed -i -e 's/ROUTEREFRESH/enable/g' ${cfgfile}
94     \    SSHLibrary.Execute_Command    sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
95     \    SSHLibrary.Execute_Command    sed -i -e 's/PASSWORD/${MD5_SAME_PASSWD}/g' ${cfgfile}
96     \    ${stdout}=    SSHLibrary.Execute_Command    cat ${cfgfile}
97     \    Log    ${stdout}