Pin python setuptools version to 44.0.0
[integration/test.git] / csit / suites / bgpcep / bgpfunct / 010_bgp_functional_l3vpn.robot
1 *** Settings ***
2 Documentation     Functional test suite for bgp - l3vpn-ipv4
3 ...
4 ...               Copyright (c) 2016 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 advertising and receiveing routes with l3vpn content.
11 ...               It uses odl and exabgp as bgp peers. Routes advertized from odl
12 ...               are configured via application peer. Routes advertised from exabgp is
13 ...               statically configured in exabgp config file.
14 ...
15 ...               For fluorine and further, instead of exabgp, play.py is used. When sending
16 ...               routes from odl to peer, first route containg route-target argument have to
17 ...               be send from peer to odl, so odl can identify this peer. Than it sends l3vpn
18 ...               route containg this argument to odl app peer, and we check that app peer
19 ...               advertizes this route back to the peer.
20 Suite Setup       Start_Suite
21 Suite Teardown    Stop_Suite
22 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
23 Library           RequestsLibrary
24 Library           SSHLibrary
25 Library           ../../../libraries/BgpRpcClient.py    ${TOOLS_SYSTEM_IP}
26 Resource          ../../../libraries/BGPcliKeywords.robot
27 Resource          ../../../libraries/BgpOperations.robot
28 Resource          ../../../libraries/BGPSpeaker.robot
29 Resource          ../../../libraries/CompareStream.robot
30 Resource          ../../../libraries/ExaBgpLib.robot
31 Resource          ../../../libraries/SetupUtils.robot
32 Resource          ../../../libraries/SSHKeywords.robot
33 Resource          ../../../libraries/TemplatedRequests.robot
34 Resource          ../../../variables/Variables.robot
35
36 *** Variables ***
37 ${BGP_L3VPN_DIR}    ${BGP_VAR_FOLDER}/l3vpn_ipv4
38 ${BGP_VAR_FOLDER}    ${CURDIR}/../../../variables/bgpfunctional
39 ${CONFIG_SESSION}    config-session
40 ${DEFAULT_BGPCEP_LOG_LEVEL}    INFO
41 ${DEFAULT_EXA_CFG}    exa.cfg
42 ${EXARPCSCRIPT}    ${CURDIR}/../../../../tools/exabgp_files/exarpc.py
43 ${HOLDTIME}       180
44 ${L3VPN_EXA_CFG}    bgp-l3vpn-ipv4.cfg
45 ${L3VPN_EXP}      exa_expected
46 ${L3VPN_RSP}      bgp_l3vpn_ipv4
47 ${L3VPN_RSPEMPTY}    bgp_l3vpn_ipv4_empty
48 ${L3VPN_RSP_PATH}    bgp_l3vpn_ipv4_path
49 ${OLD_AS_PATH}    \n"as-path": {},
50 ${NEW_AS_PATH}    ${EMPTY}
51 ${PLAY_SCRIPT}    ${CURDIR}/../../../../tools/fastbgp/play.py
52 ${RIB_INSTANCE}    example-bgp-rib
53 ${RT_CONSTRAIN_DIR}    ${CURDIR}/../../../variables/bgpfunctional/rt_constrain
54
55 *** Test Cases ***
56 Configure_App_Peer
57     [Documentation]    Configures bgp application peer. Openconfig is used for carbon and above.
58     &{mapping}    BuiltIn.Create_Dictionary    BGP_RIB=${RIB_INSTANCE}    IP=${ODL_SYSTEM_IP}
59     TemplatedRequests.Put_As_Xml_Templated    ${RT_CONSTRAIN_DIR}/app_peer    mapping=${mapping}    session=${CONFIG_SESSION}
60
61 Reconfigure_ODL_To_Accept_Connection
62     [Documentation]    Configures BGP peer module with initiate-connection set to false.
63     &{mapping}    BuiltIn.Create_Dictionary    IP=${TOOLS_SYSTEM_IP}    BGP_RIB=${RIB_INSTANCE}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    INITIATE=false
64     ...    BGP_RIB_OPENCONFIG=${RIB_INSTANCE}    PASSIVE_MODE=true
65     CompareStream.Run_Keyword_If_At_Least_Fluorine    TemplatedRequests.Put_As_Xml_Templated    ${RT_CONSTRAIN_DIR}/bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
66     CompareStream.Run_Keyword_If_Less_Than_Fluorine    TemplatedRequests.Put_As_Xml_Templated    ${BGP_VAR_FOLDER}/bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
67
68 L3vpn_Ipv4_To_Odl
69     [Documentation]    Testing mpls vpn ipv4 routes reported to odl from exabgp
70     [Setup]    Setup_Testcase    ${L3VPN_EXA_CFG}
71     ${L3VPN_RESPONSE}    CompareStream.Set_Variable_If_At_Least_Fluorine    ${L3VPN_RSP_PATH}    ${L3VPN_RSP}
72     BuiltIn.Wait_Until_Keyword_Succeeds    15s    1s    Verify_Reported_Data    ${L3VPN_RESPONSE}
73     [Teardown]    Teardown_Simple
74
75 Start_Play
76     [Documentation]    Start Python speaker to connect to ODL. We need to do WUKS until odl really starts to accept incomming bgp connection. The failure happens if the incomming connection comes too quickly after configuring the peer in the previous test case.
77     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
78     CompareStream.Run_Keyword_If_Less_Than_Fluorine    BuiltIn.Pass_Execution    "Only run on Fluorine and later"
79     SSHLibrary.Put_File    ${PLAY_SCRIPT}    .
80     SSHKeywords.Assure_Library_Ipaddr    target_dir=.
81     SSHLibrary.Read
82     BuiltIn.Wait_Until_Keyword_Succeeds    3x    1s    Start_Bgp_Peer
83
84 Play_To_Odl_rt_constrain_type_0
85     [Documentation]    This keyword sends route-target route containg route-target argument so odl
86     ...    can identify this peer as appropriate for advertizement when it recieves such route.
87     CompareStream.Run_Keyword_If_Less_Than_Fluorine    BuiltIn.Pass_Execution    "Only run on Fluorine and later"
88     BgpOperations.Play_To_Odl_Non_Removal_Template    rt_constrain_type_0    ${RT_CONSTRAIN_DIR}
89
90 Odl_To_Play_l3vpn
91     [Documentation]    Send l3vpn route to app peer, and than checks that app peer advertizes this route.
92     CompareStream.Run_Keyword_If_At_Least_Fluorine    BuiltIn.Pass_Execution    "Only run on less than Fluorine"
93     Setup_Testcase    ${DEFAULT_EXA_CFG}
94     L3vpn_Ipv4_To_App
95     [Teardown]    CompareStream.Run_Keyword_If_Less_Than_Fluorine    Teardowm_With_Remove_Route
96
97 Odl_To_Play_l3vpn_rt_arg
98     [Documentation]    Same as TC before but fluorine and further this l3vpn route also needs to contain route-target argument.
99     CompareStream.Run_Keyword_If_Less_Than_Fluorine    BuiltIn.Pass_Execution    "Only run on Fluorine and later"
100     BgpOperations.Odl_To_Play_Template    l3vpn_rt_arg    ${RT_CONSTRAIN_DIR}    False
101
102 Kill_Talking_BGP_Speaker
103     [Documentation]    Abort the Python speaker
104     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
105     CompareStream.Run_Keyword_If_Less_Than_Fluorine    BuiltIn.Pass_Execution    "Only run on Fluorine and later"
106     BGPSpeaker.Kill_BGP_Speaker
107     BGPcliKeywords.Store_File_To_Workspace    play.py.out    010_l3vpn_play.log
108
109 Delete_Bgp_Peer_Configuration
110     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
111     &{mapping}    BuiltIn.Create_Dictionary    IP=${TOOLS_SYSTEM_IP}    BGP_RIB=${RIB_INSTANCE}
112     TemplatedRequests.Delete_Templated    ${RT_CONSTRAIN_DIR}/bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
113
114 Deconfigure_App_Peer
115     [Documentation]    Revert the BGP configuration to the original state: without application peer
116     &{mapping}    BuiltIn.Create_Dictionary    IP=${ODL_SYSTEM_IP}    BGP_RIB=${RIB_INSTANCE}
117     TemplatedRequests.Delete_Templated    ${RT_CONSTRAIN_DIR}/app_peer    mapping=${mapping}    session=${CONFIG_SESSION}
118
119 *** Keywords ***
120 Start_Suite
121     [Documentation]    Suite setup keyword.
122     SetupUtils.Setup_Utils_For_Setup_And_Teardown
123     ${tools_system_conn_id} =    SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=6s
124     Builtin.Set_Suite_Variable    ${tools_system_conn_id}
125     SSHKeywords.Flexible_Mininet_Login    ${TOOLS_SYSTEM_USER}
126     SSHKeywords.Virtual_Env_Create
127     SSHKeywords.Virtual_Env_Install_Package    setuptools==44.0.0
128     SSHKeywords.Virtual_Env_Install_Package    exabgp==3.4.16
129     RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
130     Upload_Config_Files
131     ${AS_PATH} =    CompareStream.Set_Variable_If_At_Least_Neon    ${NEW_AS_PATH}    ${OLD_AS_PATH}
132     BuiltIn.Set_Suite_Variable    ${AS_PATH}
133
134 Stop_Suite
135     [Documentation]    Suite teardown keyword
136     SSHKeywords.Virtual_Env_Delete
137     SSHLibrary.Close_All_Connections
138     RequestsLibrary.Delete_All_Sessions
139
140 Upload_Config_Files
141     [Documentation]    Uploads exabgp config files and needed scripts
142     SSHLibrary.Put_File    ${BGP_VAR_FOLDER}/${DEFAULT_EXA_CFG}    .
143     SSHLibrary.Put_File    ${BGP_L3VPN_DIR}/${L3VPN_EXA_CFG}    .
144     SSHLibrary.Put_File    ${EXARPCSCRIPT}    .
145     @{cfgfiles}=    SSHLibrary.List_Files_In_Directory    .    *.cfg
146     FOR    ${cfgfile}    IN    @{cfgfiles}
147         SSHLibrary.Execute_Command    sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
148         SSHLibrary.Execute_Command    sed -i -e 's/ODLIP/${ODL_SYSTEM_IP}/g' ${cfgfile}
149         SSHLibrary.Execute_Command    sed -i -e 's/ROUTEREFRESH/disable/g' ${cfgfile}
150         SSHLibrary.Execute_Command    sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
151         ${stdout}=    SSHLibrary.Execute_Command    cat ${cfgfile}
152         Log    ${stdout}
153     END
154
155 Setup_Testcase
156     [Arguments]    ${cfg_file}
157     [Documentation]    Verifies initial test condition and starts the exabgp
158     SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
159     BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    Verify_Empty_Reported_Data
160     ExaBgpLib.Start_ExaBgp_And_Verify_Connected    ${cfg_file}    ${CONFIG_SESSION}    ${TOOLS_SYSTEM_IP}    connection_retries=${3}
161
162 Teardowm_With_Remove_Route
163     [Documentation]    Removes configured route from application peer and stops the exabgp
164     &{mapping}    BuiltIn.Create_Dictionary    APP_PEER_IP=${ODL_SYSTEM_IP}
165     TemplatedRequests.Delete_Templated    ${BGP_L3VPN_DIR}/route    mapping=${mapping}    session=${CONFIG_SESSION}
166     Teardown_Simple
167
168 Teardown_Simple
169     [Documentation]    Testcse teardown with data verification
170     ExaBgpLib.Stop_ExaBgp
171     BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    Verify_Empty_Reported_Data
172
173 Verify_ExaBgp_Received_Update
174     [Arguments]    ${exp_update_fn}
175     [Documentation]    Verification of receiving particular update message
176     ${exp_update} =    TemplatedRequests.Resolve_Text_From_Template_File    ${BGP_L3VPN_DIR}${/}${exp_update_fn}    data.json
177     ${rcv_update_dict} =    BgpRpcClient.exa_get_update_message    msg_only=${True}
178     ${rcv_update} =    BuiltIn.Evaluate    json.dumps(${rcv_update_dict})    modules=json
179     TemplatedRequests.Normalize_Jsons_And_Compare    ${exp_update}    ${rcv_update}
180
181 Verify_Empty_Reported_Data
182     [Documentation]    Verfiy empty data response
183     CompareStream.Run_Keyword_If_At_Most_Fluorine    TemplatedRequests.Get_As_Json_Templated    ${BGP_L3VPN_DIR}${/}${L3VPN_RSPEMPTY}    session=${CONFIG_SESSION}    verify=True
184     CompareStream.Run_Keyword_If_At_Least_Neon    Verify_Empty_Data_Neon
185
186 Verify_Reported_Data
187     [Arguments]    ${exprspdir}
188     [Documentation]    Verifies expected response
189     &{mapping}    BuiltIn.Create_Dictionary    AS_PATH=${AS_PATH}
190     TemplatedRequests.Get_As_Json_Templated    ${BGP_L3VPN_DIR}${/}${exprspdir}    mapping=${mapping}    session=${CONFIG_SESSION}    verify=True
191
192 Start_Bgp_Peer
193     [Documentation]    Starts bgp peer and verifies that the peer runs.
194     BGPSpeaker.Start_BGP_Speaker    --amount 0 --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT} --debug --allf --wfr 1
195     BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
196
197 L3vpn_Ipv4_To_App
198     [Documentation]    Testing mpls vpn ipv4 routes reported to odl from exabgp
199     BgpRpcClient.exa_clean_update_message
200     &{mapping}    BuiltIn.Create_Dictionary    BGP_PEER_IP=${TOOLS_SYSTEM_IP}    APP_PEER_IP=${ODL_SYSTEM_IP}
201     TemplatedRequests.Post_As_Xml_Templated    ${BGP_L3VPN_DIR}/route    mapping=${mapping}    session=${CONFIG_SESSION}
202     BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    Verify_ExaBgp_Received_Update    ${L3VPN_EXP}
203
204 Verify_Empty_Data_Neon
205     [Documentation]    Verify empty data on neon
206     TemplatedRequests.Get_As_Json_Templated    ${BGP_L3VPN_DIR}${/}empty_route    session=${CONFIG_SESSION}    verify=True