4a0e16407e774e51997c9cf0eca898887993eece
[integration/test.git] / csit / suites / bgpcep / bgpfunct / 030_bgp_functional_evpn.robot
1 *** Settings ***
2 Documentation     Functional test for bgp - evpn
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 evpn content.
11 ...               It uses play.py and odl as bgp peers. Routes advertized from odl
12 ...               are configured via application peer. Routes advertised from play.py are
13 ...               stored in *.hex files. These files are used also as expected data which
14 ...               is recevied from odl.
15 Suite Setup       Start_Suite
16 Suite Teardown    Stop_Suite
17 Test Setup        Run Keywords    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
18 ...               AND    Verify Test Preconditions
19 Library           RequestsLibrary
20 Library           SSHLibrary
21 Variables         ${CURDIR}/../../../variables/Variables.py
22 Resource          ${CURDIR}/../../../libraries/Utils.robot
23 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
24 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
25 Library           ${CURDIR}/../../../libraries/BgpRpcClient.py    ${TOOLS_SYSTEM_IP}
26 Resource          ${CURDIR}/../../../libraries/BGPcliKeywords.robot
27 Resource          ${CURDIR}/../../../libraries/BGPSpeaker.robot
28 Resource          ${CURDIR}/../../../libraries/SSHKeywords.robot
29
30 *** Variables ***
31 ${HOLDTIME}       180
32 ${DEVICE_NAME}    controller-config
33 ${BGP_PEER_NAME}    example-bgp-peer
34 ${RIB_INSTANCE}    example-bgp-rib
35 ${PROTOCOL_OPENCONFIG}    ${RIB_INSTANCE}
36 ${APP_PEER_NAME}    example-bgp-peer-app
37 ${BGP_VARIABLES_FOLDER}    ${CURDIR}/../../../variables/bgpfunctional
38 ${DEFAUTL_RPC_CFG}    exa.cfg
39 ${CONFIG_SESSION}    config-session
40 ${EVPN_VARIABLES_DIR}    ${CURDIR}/../../../variables/bgpfunctional/l2vpn_evpn
41 ${BGP_TOOL_LOG_LEVEL}    debug
42 ${PLAY_SCRIPT}    ${CURDIR}/../../../../tools/fastbgp/play.py
43
44 *** Test Cases ***
45 Configure_App_Peer
46     [Documentation]    Configures bgp application peer. Openconfig is used for carbon and above.
47     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
48     &{mapping}    BuiltIn.Create_Dictionary    DEVICE_NAME=${DEVICE_NAME}    APP_PEER_NAME=${APP_PEER_NAME}    RIB_INSTANCE_NAME=${RIB_INSTANCE}    APP_PEER_ID=${ODL_SYSTEM_IP}    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
49     ...    IP=${ODL_SYSTEM_IP}
50     TemplatedRequests.Put_As_Xml_Templated    ${BGP_VARIABLES_FOLDER}/app_peer    mapping=${mapping}    session=${CONFIG_SESSION}
51
52 Reconfigure_ODL_To_Accept_Connection
53     [Documentation]    Configures BGP peer module with initiate-connection set to false.
54     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
55     &{mapping}    BuiltIn.Create_Dictionary    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}
56     ...    INITIATE=false    RIB_INSTANCE_NAME=${RIB_INSTANCE}    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}    PASSIVE_MODE=true
57     TemplatedRequests.Put_As_Xml_Templated    ${BGP_VARIABLES_FOLDER}/bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
58
59 Start_Bgp_Peer
60     [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.
61     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
62     BuiltIn.Wait_Until_Keyword_Succeeds    3x    1s    Start Bgp Peer
63
64 Odl_To_Play_route_es_arb
65     [Template]    Odl_To_Play_Template
66     route_es_arb
67
68 Play_To_Odl_route_es_arb
69     [Template]    Play_To_Odl_Template
70     route_es_arb
71
72 Odl_To_Play_route_es_as
73     [Template]    Odl_To_Play_Template
74     route_es_as
75
76 Play_To_Odl_route_es_as
77     [Template]    Play_To_Odl_Template
78     route_es_as
79
80 Odl_To_Play_route_es_lacp
81     [Template]    Odl_To_Play_Template
82     route_es_lacp
83
84 Play_To_Odl_route_es_lacp
85     [Template]    Play_To_Odl_Template
86     route_es_lacp
87
88 Odl_To_Play_route_es_lan
89     [Template]    Odl_To_Play_Template
90     route_es_lan
91
92 Play_To_Odl_route_es_lan
93     [Template]    Play_To_Odl_Template
94     route_es_lan
95
96 Odl_To_Play_route_es_mac
97     [Template]    Odl_To_Play_Template
98     route_es_mac
99
100 Play_To_Odl_route_es_mac
101     [Template]    Play_To_Odl_Template
102     route_es_mac
103
104 Odl_To_Play_route_es_rou
105     [Template]    Odl_To_Play_Template
106     route_es_rou
107
108 Play_To_Odl_route_es_rou
109     [Template]    Play_To_Odl_Template
110     route_es_rou
111
112 Odl_To_Play_route_eth_arb
113     [Template]    Odl_To_Play_Template
114     route_eth_arb
115
116 Play_To_Odl_route_eth_arb
117     [Template]    Play_To_Odl_Template
118     route_eth_arb
119
120 Odl_To_Play_route_eth_as
121     [Template]    Odl_To_Play_Template
122     route_eth_as
123
124 Play_To_Odl_route_eth_as
125     [Template]    Play_To_Odl_Template
126     route_eth_as
127
128 Odl_To_Play_route_eth_lacp
129     [Template]    Odl_To_Play_Template
130     route_eth_lacp
131
132 Play_To_Odl_route_eth_lacp
133     [Template]    Play_To_Odl_Template
134     route_eth_lacp
135
136 Odl_To_Play_route_eth_lacp_extdef
137     [Template]    Odl_To_Play_Template
138     route_eth_lacp_extdef
139
140 Play_To_Odl_route_eth_lacp_extdef
141     [Template]    Play_To_Odl_Template
142     route_eth_lacp_extdef
143
144 Odl_To_Play_route_eth_lacp_extesilab
145     [Template]    Odl_To_Play_Template
146     route_eth_lacp_extesilab
147
148 Play_To_Odl_route_eth_lacp_extesilab
149     [Template]    Play_To_Odl_Template
150     route_eth_lacp_extesilab
151
152 Odl_To_Play_route_eth_lacp_extesr
153     [Template]    Odl_To_Play_Template
154     route_eth_lacp_extesr
155
156 Play_To_Odl_route_eth_lacp_extesr
157     [Template]    Play_To_Odl_Template
158     route_eth_lacp_extesr
159
160 Odl_To_Play_route_eth_lacp_extl2
161     [Template]    Odl_To_Play_Template
162     route_eth_lacp_extl2
163
164 Play_To_Odl_route_eth_lacp_extl2
165     [Template]    Play_To_Odl_Template
166     route_eth_lacp_extl2
167
168 Odl_To_Play_route_eth_lacp_extmac
169     [Template]    Odl_To_Play_Template
170     route_eth_lacp_extmac
171
172 Play_To_Odl_route_eth_lacp_extmac
173     [Template]    Play_To_Odl_Template
174     route_eth_lacp_extmac
175
176 Odl_To_Play_route_eth_lan
177     [Template]    Odl_To_Play_Template
178     route_eth_lan
179
180 Play_To_Odl_route_eth_lan
181     [Template]    Play_To_Odl_Template
182     route_eth_lan
183
184 Odl_To_Play_route_eth_mac
185     [Template]    Odl_To_Play_Template
186     route_eth_mac
187
188 Play_To_Odl_route_eth_mac
189     [Template]    Play_To_Odl_Template
190     route_eth_mac
191
192 Odl_To_Play_route_eth_rou
193     [Template]    Odl_To_Play_Template
194     route_eth_rou
195
196 Play_To_Odl_route_eth_rou
197     [Template]    Play_To_Odl_Template
198     route_eth_rou
199
200 Odl_To_Play_route_inc_arb
201     [Template]    Odl_To_Play_Template
202     route_inc_arb
203
204 Play_To_Odl_route_inc_arb
205     [Template]    Play_To_Odl_Template
206     route_inc_arb
207
208 Odl_To_Play_route_inc_as
209     [Template]    Odl_To_Play_Template
210     route_inc_as
211
212 Play_To_Odl_route_inc_as
213     [Template]    Play_To_Odl_Template
214     route_inc_as
215
216 Odl_To_Play_route_inc_lacp
217     [Template]    Odl_To_Play_Template
218     route_inc_lacp
219
220 Play_To_Odl_route_inc_lacp
221     [Template]    Play_To_Odl_Template
222     route_inc_lacp
223
224 Odl_To_Play_route_inc_lan
225     [Template]    Odl_To_Play_Template
226     route_inc_lan
227
228 Play_To_Odl_route_inc_lan
229     [Template]    Play_To_Odl_Template
230     route_inc_lan
231
232 Odl_To_Play_route_inc_mac
233     [Template]    Odl_To_Play_Template
234     route_inc_mac
235
236 Play_To_Odl_route_inc_mac
237     [Template]    Play_To_Odl_Template
238     route_inc_mac
239
240 Odl_To_Play_route_inc_rou
241     [Template]    Odl_To_Play_Template
242     route_inc_rou
243
244 Play_To_Odl_route_inc_rou
245     [Template]    Play_To_Odl_Template
246     route_inc_rou
247
248 Odl_To_Play_route_mac_arb
249     [Template]    Odl_To_Play_Template
250     route_mac_arb
251
252 Play_To_Odl_route_mac_arb
253     [Template]    Play_To_Odl_Template
254     route_mac_arb
255
256 Odl_To_Play_route_mac_as
257     [Template]    Odl_To_Play_Template
258     route_mac_as
259
260 Play_To_Odl_route_mac_as
261     [Template]    Play_To_Odl_Template
262     route_mac_as
263
264 Odl_To_Play_route_mac_lacp
265     [Template]    Odl_To_Play_Template
266     route_mac_lacp
267
268 Play_To_Odl_route_mac_lacp
269     [Template]    Play_To_Odl_Template
270     route_mac_lacp
271
272 Odl_To_Play_route_mac_lan
273     [Template]    Odl_To_Play_Template
274     route_mac_lan
275
276 Play_To_Odl_route_mac_lan
277     [Template]    Play_To_Odl_Template
278     route_mac_lan
279
280 Odl_To_Play_route_mac_mac
281     [Template]    Odl_To_Play_Template
282     route_mac_mac
283
284 Play_To_Odl_route_mac_mac
285     [Template]    Play_To_Odl_Template
286     route_mac_mac
287
288 Odl_To_Play_route_mac_rou
289     [Template]    Odl_To_Play_Template
290     route_mac_rou
291
292 Play_To_Odl_route_mac_rou
293     [Template]    Play_To_Odl_Template
294     route_mac_rou
295
296 Kill_Talking_BGP_Speaker
297     [Documentation]    Abort the Python speaker
298     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
299     BGPSpeaker.Kill_BGP_Speaker
300
301 Delete_Bgp_Peer_Configuration
302     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
303     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
304     &{mapping}    BuiltIn.Create_Dictionary    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
305     TemplatedRequests.Delete_Templated    ${BGP_VARIABLES_FOLDER}/bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
306
307 Deconfigure_App_Peer
308     [Documentation]    Revert the BGP configuration to the original state: without application peer
309     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
310     &{mapping}    BuiltIn.Create_Dictionary    DEVICE_NAME=${DEVICE_NAME}    APP_PEER_NAME=${APP_PEER_NAME}    IP=${ODL_SYSTEM_IP}    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
311     TemplatedRequests.Delete_Templated    ${BGP_VARIABLES_FOLDER}/app_peer    mapping=${mapping}    session=${CONFIG_SESSION}
312
313 *** Keywords ***
314 Start_Suite
315     [Documentation]    Initialize SetupUtils. Suite setup keyword.
316     SetupUtils.Setup_Utils_For_Setup_And_Teardown
317     ${mininet_conn_id}=    SSHLibrary.Open Connection    ${TOOLS_SYSTEM_IP}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=6s
318     Builtin.Set Suite Variable    ${mininet_conn_id}
319     Utils.Flexible Mininet Login    ${TOOLS_SYSTEM_USER}
320     RequestsLibrary.Create Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
321     SSHLibrary.Put File    ${PLAY_SCRIPT}    .
322     SSHKeywords.Assure_Library_Ipaddr    target_dir=.
323     ${app_rib}=    CompareStream.Set_Variable_If_At_Most_Boron    example-app-rib    ${ODL_SYSTEM_IP}
324     ${bgp_rib}=    CompareStream.Set_Variable_If_At_Most_Boron    example-bgp-rib    example-bgp-rib
325     BuiltIn.Set_Suite_Variable    ${EVPN_CONF_URL}    /restconf/config/bgp-rib:application-rib/${app_rib}/tables/odl-bgp-evpn:l2vpn-address-family/odl-bgp-evpn:evpn-subsequent-address-family/odl-bgp-evpn:evpn-routes/
326     BuiltIn.Set_Suite_Variable    ${EVPN_LOC_RIB_OPER_URL}    /restconf/operational/bgp-rib:bgp-rib/rib/${bgp_rib}/loc-rib/tables/odl-bgp-evpn:l2vpn-address-family/odl-bgp-evpn:evpn-subsequent-address-family/odl-bgp-evpn:evpn-routes
327
328 Stop_Suite
329     [Documentation]    Suite teardown keyword
330     SSHLibrary.Close_All_Connections
331     RequestsLibrary.Delete_All_Sessions
332
333 Start_Bgp_Peer
334     [Documentation]    Starts bgp peer and verifies that the peer runs.
335     BGPSpeaker.Start_BGP_Speaker    --amount 0 --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT} --${BGP_TOOL_LOG_LEVEL} --evpn --wfr 1
336     BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
337
338 Odl_To_Play_Template
339     [Arguments]    ${totest}
340     ${data_xml}=    OperatingSystem.Get_File    ${EVPN_VARIABLES_DIR}/${totest}.xml
341     ${data_json}=    OperatingSystem.Get_File    ${EVPN_VARIABLES_DIR}/${totest}.json
342     ${announce_hex}=    OperatingSystem.Get_File    ${EVPN_VARIABLES_DIR}/announce_${totest}.hex
343     ${withdraw_hex}=    OperatingSystem.Get_File    ${EVPN_VARIABLES_DIR}/withdraw_${totest}.hex
344     BuiltIn.Log    ${data_xml}
345     BuiltIn.Log    ${data_json}
346     BuiltIn.Log    ${announce_hex}
347     BuiltIn.Log    ${withdraw_hex}
348     BgpRpcClient.play_clean
349     ${resp}=    RequestsLibrary.Post_Request    ${CONFIG_SESSION}    ${EVPN_CONF_URL}    data=${data_xml}    headers=${HEADERS_XML}
350     BuiltIn.Should_Be_Equal_As_Numbers    ${resp.status_code}    204
351     ${resp}=    RequestsLibrary.Get_Request    ${CONFIG_SESSION}    ${EVPN_CONF_URL}    headers=${HEADERS_XML}
352     BuiltIn.Log    ${resp.content}
353     ${aupdate}=    BuiltIn.Wait_Until_Keyword_Succeeds    4x    2s    Get_Update_Content
354     BuiltIn.Log    ${aupdate}
355     BuiltIn.Should_Be_Equal_As_Strings    ${aupdate}    ${announce_hex}
356     BgpRpcClient.play_clean
357     Remove_Configured_Routes
358     ${wupdate}=    BuiltIn.Wait_Until_Keyword_Succeeds    4x    2s    Get_Update_Content
359     BuiltIn.Log    ${wupdate}
360     BuiltIn.Should Be Equal As Strings    ${wupdate}    ${withdraw_hex}
361     [Teardown]    Remove_Configured_Routes
362
363 Play_To_Odl_Template
364     [Arguments]    ${totest}
365     ${data_xml}=    OperatingSystem.Get_File    ${EVPN_VARIABLES_DIR}/${totest}.xml
366     ${data_json}=    OperatingSystem.Get_File    ${EVPN_VARIABLES_DIR}/${totest}.json
367     ${announce_hex}=    OperatingSystem.Get_File    ${EVPN_VARIABLES_DIR}/announce_${totest}.hex
368     ${withdraw_hex}=    OperatingSystem.Get_File    ${EVPN_VARIABLES_DIR}/withdraw_${totest}.hex
369     ${empty_routes}=    OperatingSystem.Get_File    ${EVPN_VARIABLES_DIR}/empty_routes.json
370     BuiltIn.Set_Suite_Variable    ${withdraw_hex}
371     BuiltIn.Set_Suite_Variable    ${empty_routes}
372     BuiltIn.Log    ${data_xml}
373     BuiltIn.Log    ${data_json}
374     BuiltIn.Log    ${announce_hex}
375     BuiltIn.Log    ${withdraw_hex}
376     BuiltIn.Log    ${empty_routes}
377     BgpRpcClient.play_clean
378     BgpRpcClient.play_send    ${announce_hex}
379     BuiltIn.Wait_Until_Keyword_Succeeds    4x    2s    Loc_Rib_Presnece    ${data_json}
380     BgpRpcClient.play_send    ${withdraw_hex}
381     BuiltIn.Wait_Until_Keyword_Succeeds    4x    2s    Loc_Rib_Presnece    ${empty_routes}
382     [Teardown]    Withdraw_Route_And_Verify    ${withdraw_hex}
383
384 Verify_Test_Preconditions
385     ${resp}=    RequestsLibrary.Get_Request    ${CONFIG_SESSION}    ${EVPN_CONF_URL}
386     BuiltIn.Should_Be_Equal_As_Numbers    ${resp.status_code}    404
387     ${empty_routes}=    OperatingSystem.Get_File    ${EVPN_VARIABLES_DIR}/empty_routes.json
388     Loc_Rib_Presnece    ${empty_routes}
389
390 Remove_Configured_Routes
391     [Documentation]    Removes the route if present. First GET is for debug purposes.
392     ${rsp}=    RequestsLibrary.Get_Request    ${CONFIG_SESSION}    ${EVPN_LOC_RIB_OPER_URL}    headers=${HEADERS}
393     Log    ${rsp.content}
394     ${rsp}=    RequestsLibrary.Get_Request    ${CONFIG_SESSION}    ${EVPN_CONF_URL}    headers=${HEADERS}
395     Log    ${rsp.content}
396     BuiltIn.Return_From_Keyword_If    "${rsp.status_code}"=="404"
397     ${resp}=    RequestsLibrary.Delete_Request    ${CONFIG_SESSION}    ${EVPN_CONF_URL}
398     BuiltIn.Should_Be_Equal_As_Numbers    ${resp.status_code}    200
399
400 Withdraw_Route_And_Verify
401     [Arguments]    ${withdraw_hex}
402     [Documentation]    Sends withdraw update message from exabgp and verifies route removal from odl's rib
403     BgpRpcClient.play_send    ${withdraw_hex}
404     BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    Loc Rib Presnece    ${empty_routes}
405
406 Get_Update_Content
407     [Documentation]    Gets received data from odl's peer
408     ${resp}=    RequestsLibrary.Get_Request    ${CONFIG_SESSION}    ${EVPN_LOC_RIB_OPER_URL}    headers=${HEADERS_XML}
409     BuiltIn.Log    ${resp.content}
410     ${update}=    BgpRpcClient.play_get
411     BuiltIn.Should_Not_Be_Equal    ${update}    ${Empty}
412     [Return]    ${update}
413
414 Loc_Rib_Presnece
415     [Arguments]    ${exp_content}
416     [Documentation]    Verifies if loc-rib contains expected data
417     ${rsp}=    RequestsLibrary.Get_Request    ${CONFIG_SESSION}    ${EVPN_LOC_RIB_OPER_URL}    headers=${HEADERS}
418     TemplatedRequests.Normalize_Jsons_And_Compare    ${exp_content}    ${rsp.content}