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