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