Bgpcep l3vpn multicast test coverage
[integration/test.git] / csit / suites / bgpcep / bgpfunct / 060_bgp_functional_mvpn.robot
1 *** Settings ***
2 Documentation     Functional test for bgp - mvpn
3 ...
4 ...               Copyright (c) 2018 AT&T Intellectual Property. 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 distbmution,
8 ...               and is available at http://www.eclipse.org/legal/epl-v10.html
9 ...
10 ...               This suite tests advertising mvpn routes to odl. For advertising play.py is used,
11 ...               and particular files are stored as *.hex files. There are 7 different
12 ...               types of routes used for auto-discovery of multicast network. Also 4 more routes
13 ...               with new attributes specific for mvpn.
14 ...               TODO: Unify Keywords with 070_bgp_functional_l3vpn_mcast.robot test suite
15 Suite Setup       Start_Suite
16 Suite Teardown    Stop_Suite
17 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
18 Library           RequestsLibrary
19 Library           SSHLibrary
20 Library           String
21 Library           ../../../libraries/BgpRpcClient.py    ${TOOLS_SYSTEM_IP}
22 Resource          ../../../libraries/BGPcliKeywords.robot
23 Resource          ../../../libraries/BGPSpeaker.robot
24 Resource          ../../../libraries/SetupUtils.robot
25 Resource          ../../../libraries/SSHKeywords.robot
26 Resource          ../../../libraries/TemplatedRequests.robot
27 Resource          ../../../variables/Variables.robot
28
29 *** Variables ***
30 ${HOLDTIME}       180
31 ${CONFIG_SESSION}    config-session
32 ${MVPN_DIR}       ${CURDIR}/../../../variables/bgpfunctional/mvpn
33 ${PLAY_SCRIPT}    ${CURDIR}/../../../../tools/fastbgp/play.py
34 ${RIB_NAME}       example-bgp-rib
35 &{MVPN_ADJ_RIB_IN}    PATH=peer/bgp:%2F%2F${TOOLS_SYSTEM_IP}/adj-rib-in    BGP_RIB=${RIB_NAME}
36 &{MVPN_LOC_RIB}    PATH=loc-rib    BGP_RIB=${RIB_NAME}
37 &{MVPN_EFFECTIVE_RIB_IN}    PATH=peer/bgp:%2F%2F${TOOLS_SYSTEM_IP}/effective-rib-in    BGP_RIB=${RIB_NAME}
38 &{MVPN_APP_PEER}    IP=${ODL_SYSTEM_IP}    BGP_RIB=${RIB_NAME}
39 &{MVPN_ODL_CONFIG}    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    INITIATE=false    BGP_RIB=${RIB_NAME}    PASSIVE_MODE=true
40
41 *** Test Cases ***
42 Configure_App_Peer
43     [Documentation]    Configures bgp application peer.
44     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
45     TemplatedRequests.Put_As_Xml_Templated    ${MVPN_DIR}/app_peer    mapping=${MVPN_APP_PEER}    session=${CONFIG_SESSION}
46
47 Reconfigure_ODL_To_Accept_Connection
48     [Documentation]    Configures BGP peer module with initiate-connection set to false.
49     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
50     TemplatedRequests.Put_As_Xml_Templated    ${MVPN_DIR}/bgp_peer    mapping=${MVPN_ODL_CONFIG}    session=${CONFIG_SESSION}
51
52 Start_Bgp_Peer
53     [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.
54     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
55     BuiltIn.Wait_Until_Keyword_Succeeds    3x    1s    Start Bgp Peer
56
57 Odl_To_Play_intra_as_ipmsi_ad
58     [Template]    Odl_To_Play_Template
59     intra_as_ipmsi_ad
60
61 Play_To_Odl_intra_as_ipmsi_ad
62     [Template]    Play_To_Odl_Template
63     intra_as_ipmsi_ad
64
65 Odl_To_Play_inter_as_ipmsi_ad
66     [Template]    Odl_To_Play_Template
67     inter_as_ipmsi_ad
68
69 Play_To_Odl_inter_as_ipmsi_ad
70     [Template]    Play_To_Odl_Template
71     inter_as_ipmsi_ad
72
73 Odl_To_Play_spmsi_ad
74     [Template]    Odl_To_Play_Template
75     spmsi_ad
76
77 Play_To_Odl_spmsi_ad
78     [Template]    Play_To_Odl_Template
79     spmsi_ad
80
81 Odl_To_Play_leaf_ad
82     [Template]    Odl_To_Play_Template
83     leaf_ad
84
85 Play_To_Odl_leaf_ad
86     [Template]    Play_To_Odl_Template
87     leaf_ad
88
89 Odl_To_Play_source_active_ad
90     [Template]    Odl_To_Play_Template
91     source_active_ad
92
93 Play_To_Odl_source_active_ad
94     [Template]    Play_To_Odl_Template
95     source_active_ad
96
97 Odl_To_Play_shared_tree_join
98     [Template]    Odl_To_Play_Template
99     shared_tree_join
100
101 Play_To_Odl_shared_tree_join
102     [Template]    Play_To_Odl_Template
103     shared_tree_join
104
105 Odl_To_Play_source_tree_join
106     [Template]    Odl_To_Play_Template
107     source_tree_join
108
109 Play_To_Odl_source_tree_join
110     [Template]    Play_To_Odl_Template
111     source_tree_join
112
113 Odl_To_Play_intra_pe_distinguisher
114     [Template]    Odl_To_Play_Template
115     intra_pe_distinguisher
116
117 Play_To_Odl_intra_pe_distinguisher
118     [Template]    Play_To_Odl_Template
119     intra_pe_distinguisher
120
121 Odl_To_Play_intra_vrf
122     [Template]    Odl_To_Play_Template
123     intra_vrf
124
125 Play_To_Odl_intra_vrf
126     [Template]    Play_To_Odl_Template
127     intra_vrf
128
129 Odl_To_Play_intra_source_as
130     [Template]    Odl_To_Play_Template
131     intra_source_as
132
133 Play_To_Odl_intra_source_as
134     [Template]    Play_To_Odl_Template
135     intra_source_as
136
137 Odl_To_Play_intra_source_as_4
138     [Template]    Odl_To_Play_Template
139     intra_source_as_4
140
141 Play_To_Odl_intra_source_as_4
142     [Template]    Play_To_Odl_Template
143     intra_source_as_4
144
145 Kill_Talking_BGP_Speaker
146     [Documentation]    Abort the Python speaker
147     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
148     BGPSpeaker.Kill_BGP_Speaker
149     BGPcliKeywords.Store_File_To_Workspace    play.py.out    mvpn_play.log
150
151 Delete_Bgp_Peer_Configuration
152     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
153     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
154     TemplatedRequests.Delete_Templated    ${MVPN_DIR}/bgp_peer    mapping=${MVPN_ODL_CONFIG}    session=${CONFIG_SESSION}
155
156 Deconfigure_App_Peer
157     [Documentation]    Revert the BGP configuration to the original state: without application peer
158     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
159     TemplatedRequests.Delete_Templated    ${MVPN_DIR}/app_peer    mapping=${MVPN_APP_PEER}    session=${CONFIG_SESSION}
160
161 *** Keywords ***
162 Start_Suite
163     [Documentation]    Initialize SetupUtils. Suite setup keyword.
164     SetupUtils.Setup_Utils_For_Setup_And_Teardown
165     ${mininet_conn_id} =    SSHLibrary.Open Connection    ${TOOLS_SYSTEM_IP}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=6s
166     Builtin.Set Suite Variable    ${mininet_conn_id}
167     SSHKeywords.Flexible Mininet Login    ${TOOLS_SYSTEM_USER}
168     RequestsLibrary.Create Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
169     SSHLibrary.Put File    ${PLAY_SCRIPT}    .
170     SSHKeywords.Assure_Library_Ipaddr    target_dir=.
171
172 Stop_Suite
173     [Documentation]    Suite teardown keyword
174     SSHLibrary.Close_All_Connections
175     RequestsLibrary.Delete_All_Sessions
176
177 Start_Bgp_Peer
178     [Documentation]    Starts bgp peer and verifies that the peer runs.
179     BGPSpeaker.Start_BGP_Speaker    --amount 0 --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT} --debug --mvpn --wfr 1
180     BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen
181
182 Odl_To_Play_Template
183     [Arguments]    ${totest}
184     ${announce_hex} =    OperatingSystem.Get_File    ${MVPN_DIR}/${totest}/announce_${totest}.hex
185     ${announce_hex} =    String.Remove_String    ${announce_hex}    \n
186     ${withdraw_hex} =    OperatingSystem.Get_File    ${MVPN_DIR}/${totest}/withdraw_${totest}.hex
187     ${withdraw_hex} =    String.Remove_String    ${withdraw_hex}    \n
188     BgpRpcClient.play_clean
189     TemplatedRequests.Post_As_Xml_Templated    ${MVPN_DIR}/${totest}/app    mapping=${MVPN_APP_PEER}    session=${CONFIG_SESSION}
190     ${update}    BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    Get_Update_Message
191     BuiltIn.Should_Be_Equal_As_Strings    ${update}    ${announce_hex}
192     BgpRpcClient.play_clean
193     Remove_Configured_Routes    ${totest}
194     ${update}    BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    Get_Update_Message
195     BuiltIn.Should_Be_Equal_As_Strings    ${update}    ${withdraw_hex}
196     [Teardown]    Remove_Configured_Routes    ${totest}
197
198 Play_To_Odl_Template
199     [Arguments]    ${totest}
200     ${announce_hex} =    OperatingSystem.Get_File    ${MVPN_DIR}/${totest}/announce_${totest}.hex
201     ${withdraw_hex} =    OperatingSystem.Get_File    ${MVPN_DIR}/${totest}/withdraw_${totest}.hex
202     BgpRpcClient.play_clean
203     BgpRpcClient.play_send    ${announce_hex}
204     BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    TemplatedRequests.Get_As_Json_Templated    ${MVPN_DIR}/${totest}/rib    mapping=${MVPN_ADJ_RIB_IN}    session=${CONFIG_SESSION}
205     ...    verify=True
206     BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    TemplatedRequests.Get_As_Json_Templated    ${MVPN_DIR}/${totest}/rib    mapping=${MVPN_EFFECTIVE_RIB_IN}    session=${CONFIG_SESSION}
207     ...    verify=True
208     BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    TemplatedRequests.Get_As_Json_Templated    ${MVPN_DIR}/${totest}/rib    mapping=${MVPN_LOC_RIB}    session=${CONFIG_SESSION}
209     ...    verify=True
210     BgpRpcClient.play_send    ${withdraw_hex}
211     ${ipv}    BuiltIn.Set_Variable_If    '${totest}' == 'intra_ipv6'    ipv6    ipv4
212     BuiltIn.Wait_Until_Keyword_Succeeds    3x    2s    TemplatedRequests.Get_As_Json_Templated    ${MVPN_DIR}/empty_routes/${ipv}    mapping=${MVPN_LOC_RIB}    session=${CONFIG_SESSION}
213     ...    verify=True
214     [Teardown]    BgpRpcClient.play_send    ${withdraw_hex}
215
216 Get_Update_Message
217     [Documentation]    Returns hex update message.
218     ${update} =    BgpRpcClient.play_get
219     BuiltIn.Should_Not_Be_Equal    ${update}    ${Empty}
220     [Return]    ${update}
221
222 Remove_Configured_Routes
223     [Arguments]    ${totest}
224     [Documentation]    Removes the route if present.
225     BuiltIn.Run_Keyword_And_Ignore_Error    TemplatedRequests.Delete_Templated    ${MVPN_DIR}/${totest}/app    mapping=${MVPN_APP_PEER}    session=${CONFIG_SESSION}