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