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