e6d3d3ec35a5f30984fcf9101660b2df483e4c5e
[integration/test.git] / csit / suites / bgpcep / bgpuser / ibgp_peers_basic.robot
1 *** Settings ***
2 Documentation     Basic tests for iBGP peers.
3 ...
4 ...               Copyright (c) 2015-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 ...               Test suite performs basic iBGP functional test cases for
11 ...               BGP peers in different roles (iBGP, iBGP RR-client):
12 ...
13 ...               Test Case 1: Two iBGP RR-client peers introduce prefixes
14 ...               Expected result: controller forwards updates towards both peers
15 ...
16 ...               Test Case 2: Two iBGP peers: one RR client and one non-client introduces prefixes
17 ...               Expected result: controller forwards updates towards both peers
18 ...
19 ...               Test Case 3: Two iBGP RR non-client peers introduce prefixes
20 ...               Expected result: controller does not forward any update towards peers
21 ...
22 ...               For polices see: https://wiki.opendaylight.org/view/BGP_LS_PCEP:BGP
23 ...
24 ...               Covered bugs:
25 ...               Bug 4791 - BGPSessionImpl: Failed to send message Update logged even all UPDATE mesages received by iBGP peer
26 ...               Bug 4819 - No routes advertised to one of newly configured iBGP RR-client peer
27 Suite Setup       Setup_Everything
28 Suite Teardown    Teardown_Everything
29 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
30 Test Teardown     FailFast.Start_Failing_Fast_If_This_Failed
31 Library           OperatingSystem
32 Library           RequestsLibrary
33 Library           DateTime
34 Library           ${CURDIR}/../../../libraries/HsfJson/hsf_json.py
35 Variables         ${CURDIR}/../../../variables/Variables.py
36 Variables         ${CURDIR}/../../../variables/bgpuser/variables.py    ${ODL_SYSTEM_PROMPT}
37 Resource          ${CURDIR}/../../../libraries/BGPcliKeywords.robot
38 Resource          ${CURDIR}/../../../libraries/BGPSpeaker.robot
39 Resource          ${CURDIR}/../../../libraries/ConfigViaRestconf.robot
40 Resource          ${CURDIR}/../../../libraries/FailFast.robot
41 Resource          ${CURDIR}/../../../libraries/KarafKeywords.robot
42 Resource          ${CURDIR}/../../../libraries/KillPythonTool.robot
43 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
44 Resource          ${CURDIR}/../../../libraries/SSHKeywords.robot
45 Resource          ${CURDIR}/../../../libraries/Utils.robot
46 Resource          ${CURDIR}/../../../libraries/WaitForFailure.robot
47
48 *** Variables ***
49 ${BGP_VARIABLES_FOLDER}    ${CURDIR}/../../../variables/bgpuser/
50 ${HOLDTIME}       180
51 ${BGP_PEER_LOG_LEVEL}    debug
52 ${CONTROLLER_LOG_LEVEL}    INFO
53 ${CONTROLLER_BGP_LOG_LEVEL}    DEFAULT
54 ${BGP_PEER1_IP}    127.0.0.1
55 ${BGP_PEER2_IP}    127.0.0.2
56 ${BGP_PEER1_FIRST_PREFIX_IP}    8.1.0.0
57 ${BGP_PEER2_FIRST_PREFIX_IP}    8.2.0.0
58 ${PREFIX_LEN}     28
59 ${BGP_PEER1_PREFIX_LEN}    ${PREFIX_LEN}
60 ${BGP_PEER2_PREFIX_LEN}    ${PREFIX_LEN}
61 ${PREFIX_COUNT}    3
62 ${BGP_PEER1_PREFIX_COUNT}    ${PREFIX_COUNT}
63 ${BGP_PEER2_PREFIX_COUNT}    ${PREFIX_COUNT}
64 ${BGP_PEER1_LOG_FILE}    bgp_peer1.log
65 ${BGP_PEER2_LOG_FILE}    bgp_peer2.log
66 ${BGP_PEER1_COMMAND}    python play.py --firstprefix ${BGP_PEER1_FIRST_PREFIX_IP} --prefixlen ${BGP_PEER1_PREFIX_LEN} --amount ${BGP_PEER1_PREFIX_COUNT} --myip=${BGP_PEER1_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT} --${BGP_PEER_LOG_LEVEL} --logfile ${BGP_PEER1_LOG_FILE}
67 ${BGP_PEER2_COMMAND}    python play.py --firstprefix ${BGP_PEER2_FIRST_PREFIX_IP} --prefixlen ${BGP_PEER2_PREFIX_LEN} --amount ${BGP_PEER2_PREFIX_COUNT} --myip=${BGP_PEER2_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT} --${BGP_PEER_LOG_LEVEL} --logfile ${BGP_PEER2_LOG_FILE}
68 ${BGP_PEER1_OPTIONS}    &>${BGP_PEER1_LOG_FILE}
69 ${BGP_PEER2_OPTIONS}    &>${BGP_PEER2_LOG_FILE}
70 ${DEFAULT_LOG_CHECK_TIMEOUT}    20s
71 ${DEFAULT_LOG_CHECK_PERIOD}    1s
72 ${DEFAULT_TOPOLOGY_CHECK_TIMEOUT}    10s
73 ${DEFAULT_TOPOLOGY_CHECK_PERIOD}    1s
74
75 *** Test Cases ***
76 TC1_Configure_Two_iBGP_Route_Reflector_Client_Peers
77     [Documentation]    Configure two iBGP peers as routing reflector clients.
78     [Tags]    critical
79     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer1', 'IP': '${BGP_PEER1_IP}', 'HOLDTIME': '${HOLDTIME}', 'PEER_PORT': '${BGP_TOOL_PORT}','PEER_ROLE': 'rr-client', 'INITIATE': 'false'}
80     ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}ibgp_peers    ${template_as_string}
81     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer2', 'IP': '${BGP_PEER2_IP}', 'HOLDTIME': '${HOLDTIME}', 'PEER_PORT': '${BGP_TOOL_PORT}','PEER_ROLE': 'rr-client', 'INITIATE': 'false'}
82     ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}ibgp_peers    ${template_as_string}
83     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer1'}
84     ${result}=    ConfigViaRestconf.Get_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}ibgp_peers    ${template_as_string}
85     BuiltIn.Log    ${result}
86     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer2'}
87     ${result}=    ConfigViaRestconf.Get_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}ibgp_peers    ${template_as_string}
88     BuiltIn.Log    ${result}
89
90 TC1_Connect_BGP_Peer1
91     [Documentation]    Connect BGP peer
92     [Tags]    critical
93     SSHLibrary.Switch Connection    bgp_peer1_console
94     Start_Console_Tool    ${BGP_PEER1_COMMAND}    ${BGP_PEER1_OPTIONS}
95     Read_And_Fail_If_Prompt_Is_Seen
96     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_TOPOLOGY_CHECK_TIMEOUT}    ${DEFAULT_TOPOLOGY_CHECK_PERIOD}    Check_Example_IPv4_Topology_Content    {"prefix":"${BGP_PEER1_FIRST_PREFIX_IP}/${PREFIX_LEN}"}
97
98 TC1_Connect_BGP_Peer2
99     [Documentation]    Connect BGP peer
100     [Tags]    critical
101     SSHLibrary.Switch Connection    bgp_peer2_console
102     Start_Console_Tool    ${BGP_PEER2_COMMAND}    ${BGP_PEER2_OPTIONS}
103     Read_And_Fail_If_Prompt_Is_Seen
104     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_TOPOLOGY_CHECK_TIMEOUT}    ${DEFAULT_TOPOLOGY_CHECK_PERIOD}    Check_Example_IPv4_Topology_Content    {"prefix":"${BGP_PEER2_FIRST_PREFIX_IP}/${PREFIX_LEN}"}
105
106 TC1_BGP_Peer1_Check_Log_For_Introduced_Prefixes
107     [Documentation]    Check incomming updates for new routes
108     [Tags]    critical
109     SSHLibrary.Switch Connection    bgp_peer1_console
110     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_LOG_CHECK_TIMEOUT}    ${DEFAULT_LOG_CHECK_PERIOD}    Check_File_For_Word_Count    ${BGP_PEER1_LOG_FILE}    nlri_prefix_received:    ${BGP_PEER2_PREFIX_COUNT}
111     Check_File_For_Word_Count    ${BGP_PEER1_LOG_FILE}    nlri_prefix_received: ${BGP_PEER2_FIRST_PREFIX_IP}/${BGP_PEER2_PREFIX_LEN}    1
112     Check_File_For_Word_Count    ${BGP_PEER1_LOG_FILE}    withdrawn_prefix_received:    0
113     [Teardown]    Report_Failure_Due_To_Bug    4819
114
115 TC1_BGP_Peer2_Check_Log_For_Introduced_Prefixes
116     [Documentation]    Check incomming updates for new routes
117     [Tags]    critical
118     SSHLibrary.Switch Connection    bgp_peer2_console
119     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_LOG_CHECK_TIMEOUT}    ${DEFAULT_LOG_CHECK_PERIOD}    Check_File_For_Word_Count    ${BGP_PEER2_LOG_FILE}    nlri_prefix_received:    ${BGP_PEER1_PREFIX_COUNT}
120     Check_File_For_Word_Count    ${BGP_PEER2_LOG_FILE}    nlri_prefix_received: ${BGP_PEER1_FIRST_PREFIX_IP}/${BGP_PEER1_PREFIX_LEN}    1
121     Check_File_For_Word_Count    ${BGP_PEER2_LOG_FILE}    withdrawn_prefix_received:    0
122     [Teardown]    Report_Failure_Due_To_Bug    4819
123
124 TC1_Disconnect_BGP_Peer1
125     [Documentation]    Stop BGP peer & store logs
126     [Tags]    critical
127     SSHLibrary.Switch Connection    bgp_peer1_console
128     Stop_Console_Tool
129     Store_File_To_Workspace    ${BGP_PEER1_LOG_FILE}    tc1_${BGP_PEER1_LOG_FILE}
130
131 TC1_BGP_Peer2_Check_Log_For_Withdrawn_Prefixes
132     [Documentation]    Check incomming updates for withdrawn routes
133     [Tags]    critical
134     SSHLibrary.Switch Connection    bgp_peer2_console
135     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_LOG_CHECK_TIMEOUT}    ${DEFAULT_LOG_CHECK_PERIOD}    Check_File_For_Word_Count    ${BGP_PEER2_LOG_FILE}    withdrawn_prefix_received:    ${BGP_PEER1_PREFIX_COUNT}
136     Check_File_For_Word_Count    ${BGP_PEER2_LOG_FILE}    withdrawn_prefix_received: ${BGP_PEER1_FIRST_PREFIX_IP}/${BGP_PEER1_PREFIX_LEN}    1
137     [Teardown]    Report_Failure_Due_To_Bug    4819
138
139 TC1_Disconnect_BGP_Peer2
140     [Documentation]    Stop BGP peer & store logs
141     [Tags]    critical
142     SSHLibrary.Switch Connection    bgp_peer2_console
143     Stop_Console_Tool
144     Store_File_To_Workspace    ${BGP_PEER2_LOG_FILE}    tc1_${BGP_PEER2_LOG_FILE}
145
146 TC_1_Check_for_Empty_IPv4_Topology
147     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_TOPOLOGY_CHECK_TIMEOUT}    ${DEFAULT_TOPOLOGY_CHECK_PERIOD}    Check_Example_IPv4_Topology_Does_Not_Contain    prefix
148
149 TC1_Delete_BGP_Peers_Configuration
150     [Documentation]    Delete all previously configured BGP peers.
151     [Tags]    critical
152     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer1'}
153     ConfigViaRestconf.Delete_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}ibgp_peers    ${template_as_string}
154     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer2'}
155     ConfigViaRestconf.Delete_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}ibgp_peers    ${template_as_string}
156
157 TC2_Configure_One_iBGP_Route_Reflector_Client_And_One_iBGP_Non_Client
158     [Documentation]    Configure iBGP peers: 1st one as RR client, 2nd one as RR non-client.
159     [Tags]    critical
160     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer1', 'IP': '${BGP_PEER1_IP}', 'HOLDTIME': '${HOLDTIME}', 'PEER_PORT': '${BGP_TOOL_PORT}','PEER_ROLE': 'rr-client', 'INITIATE': 'false'}
161     ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}ibgp_peers    ${template_as_string}
162     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer2', 'IP': '${BGP_PEER2_IP}', 'HOLDTIME': '${HOLDTIME}', 'PEER_PORT': '${BGP_TOOL_PORT}','PEER_ROLE': 'ibgp', 'INITIATE': 'false'}
163     ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}ibgp_peers    ${template_as_string}
164     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer1'}
165     ${result}=    ConfigViaRestconf.Get_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}ibgp_peers    ${template_as_string}
166     BuiltIn.Log    ${result}
167     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer2'}
168     ${result}=    ConfigViaRestconf.Get_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}ibgp_peers    ${template_as_string}
169     BuiltIn.Log    ${result}
170
171 TC2_Connect_BGP_Peer1
172     [Documentation]    Connect BGP peer
173     [Tags]    critical
174     SSHLibrary.Switch Connection    bgp_peer1_console
175     Start_Console_Tool    ${BGP_PEER1_COMMAND}    ${BGP_PEER1_OPTIONS}
176     Read_And_Fail_If_Prompt_Is_Seen
177     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_TOPOLOGY_CHECK_TIMEOUT}    ${DEFAULT_TOPOLOGY_CHECK_PERIOD}    Check_Example_IPv4_Topology_Content    {"prefix":"${BGP_PEER1_FIRST_PREFIX_IP}/${PREFIX_LEN}"}
178
179 TC2_Connect_BGP_Peer2
180     [Documentation]    Connect BGP peer
181     [Tags]    critical
182     SSHLibrary.Switch Connection    bgp_peer2_console
183     Start_Console_Tool    ${BGP_PEER2_COMMAND}    ${BGP_PEER2_OPTIONS}
184     Read_And_Fail_If_Prompt_Is_Seen
185     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_TOPOLOGY_CHECK_TIMEOUT}    ${DEFAULT_TOPOLOGY_CHECK_PERIOD}    Check_Example_IPv4_Topology_Content    {"prefix":"${BGP_PEER2_FIRST_PREFIX_IP}/${PREFIX_LEN}"}
186
187 TC2_BGP_Peer1_Check_Log_For_Introduced_Prefixes
188     [Documentation]    Check incomming updates for new routes
189     [Tags]    critical
190     SSHLibrary.Switch Connection    bgp_peer1_console
191     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_LOG_CHECK_TIMEOUT}    ${DEFAULT_LOG_CHECK_PERIOD}    Check_File_For_Word_Count    ${BGP_PEER1_LOG_FILE}    nlri_prefix_received:    ${BGP_PEER2_PREFIX_COUNT}
192     Check_File_For_Word_Count    ${BGP_PEER1_LOG_FILE}    nlri_prefix_received: ${BGP_PEER2_FIRST_PREFIX_IP}/${BGP_PEER2_PREFIX_LEN}    1
193     Check_File_For_Word_Count    ${BGP_PEER1_LOG_FILE}    withdrawn_prefix_received:    0
194
195 TC2_BGP_Peer2_Check_Log_For_Introduced_Prefixes
196     [Documentation]    Check incomming updates for new routes
197     [Tags]    critical
198     SSHLibrary.Switch Connection    bgp_peer2_console
199     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_LOG_CHECK_TIMEOUT}    ${DEFAULT_LOG_CHECK_PERIOD}    Check_File_For_Word_Count    ${BGP_PEER2_LOG_FILE}    nlri_prefix_received:    ${BGP_PEER1_PREFIX_COUNT}
200     Check_File_For_Word_Count    ${BGP_PEER2_LOG_FILE}    nlri_prefix_received: ${BGP_PEER1_FIRST_PREFIX_IP}/${BGP_PEER1_PREFIX_LEN}    1
201     Check_File_For_Word_Count    ${BGP_PEER2_LOG_FILE}    withdrawn_prefix_received:    0
202     [Teardown]    Report_Failure_Due_To_Bug    4791
203
204 TC2_Disconnect_BGP_Peer1
205     [Documentation]    Stop BGP peer & store logs
206     [Tags]    critical
207     SSHLibrary.Switch Connection    bgp_peer1_console
208     Stop_Console_Tool
209     Store_File_To_Workspace    ${BGP_PEER1_LOG_FILE}    tc2_${BGP_PEER1_LOG_FILE}
210
211 TC2_BGP_Peer2_Check_Log_For_Withdrawn_Prefixes
212     [Documentation]    Check incomming updates for withdrawn routes
213     [Tags]    critical
214     SSHLibrary.Switch Connection    bgp_peer2_console
215     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_LOG_CHECK_TIMEOUT}    ${DEFAULT_LOG_CHECK_PERIOD}    Check_File_For_Word_Count    ${BGP_PEER2_LOG_FILE}    withdrawn_prefix_received:    ${BGP_PEER1_PREFIX_COUNT}
216     Check_File_For_Word_Count    ${BGP_PEER2_LOG_FILE}    withdrawn_prefix_received: ${BGP_PEER1_FIRST_PREFIX_IP}/${BGP_PEER1_PREFIX_LEN}    1
217
218 TC2_Disconnect_BGP_Peer2
219     [Documentation]    Stop BGP peer & store logs
220     [Tags]    critical
221     SSHLibrary.Switch Connection    bgp_peer2_console
222     Stop_Console_Tool
223     Store_File_To_Workspace    ${BGP_PEER2_LOG_FILE}    tc2_${BGP_PEER2_LOG_FILE}
224
225 TC_2_Check_for_Empty_IPv4_Topology
226     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_TOPOLOGY_CHECK_TIMEOUT}    ${DEFAULT_TOPOLOGY_CHECK_PERIOD}    Check_Example_IPv4_Topology_Does_Not_Contain    prefix
227
228 TC2_Delete_BGP_Peers_Configuration
229     [Documentation]    Delete all previously configured BGP peers.
230     [Tags]    critical
231     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer1'}
232     ConfigViaRestconf.Delete_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}ibgp_peers    ${template_as_string}
233     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer2'}
234     ConfigViaRestconf.Delete_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}ibgp_peers    ${template_as_string}
235
236 TC3_Configure_Two_iBGP_Non_Client_Peers
237     [Documentation]    Configure iBGP peers: 1st one as RR client, 2nd one as RR non-client.
238     [Tags]    critical
239     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer1', 'IP': '${BGP_PEER1_IP}', 'HOLDTIME': '${HOLDTIME}', 'PEER_PORT': '${BGP_TOOL_PORT}','PEER_ROLE': 'ibgp', 'INITIATE': 'false'}
240     ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}ibgp_peers    ${template_as_string}
241     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer2', 'IP': '${BGP_PEER2_IP}', 'HOLDTIME': '${HOLDTIME}', 'PEER_PORT': '${BGP_TOOL_PORT}','PEER_ROLE': 'ibgp', 'INITIATE': 'false'}
242     ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}ibgp_peers    ${template_as_string}
243     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer1'}
244     ${result}=    ConfigViaRestconf.Get_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}ibgp_peers    ${template_as_string}
245     BuiltIn.Log    ${result}
246     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer2'}
247     ${result}=    ConfigViaRestconf.Get_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}ibgp_peers    ${template_as_string}
248     BuiltIn.Log    ${result}
249
250 TC3_Connect_BGP_Peer1
251     [Documentation]    Connect BGP peer
252     [Tags]    critical
253     SSHLibrary.Switch Connection    bgp_peer1_console
254     Start_Console_Tool    ${BGP_PEER1_COMMAND}    ${BGP_PEER1_OPTIONS}
255     Read_And_Fail_If_Prompt_Is_Seen
256     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_TOPOLOGY_CHECK_TIMEOUT}    ${DEFAULT_TOPOLOGY_CHECK_PERIOD}    Check_Example_IPv4_Topology_Content    {"prefix":"${BGP_PEER1_FIRST_PREFIX_IP}/${PREFIX_LEN}"}
257
258 TC3_Connect_BGP_Peer2
259     [Documentation]    Connect BGP peer
260     [Tags]    critical
261     SSHLibrary.Switch Connection    bgp_peer2_console
262     Start_Console_Tool    ${BGP_PEER2_COMMAND}    ${BGP_PEER2_OPTIONS}
263     Read_And_Fail_If_Prompt_Is_Seen
264     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_TOPOLOGY_CHECK_TIMEOUT}    ${DEFAULT_TOPOLOGY_CHECK_PERIOD}    Check_Example_IPv4_Topology_Content    {"prefix":"${BGP_PEER2_FIRST_PREFIX_IP}/${PREFIX_LEN}"}
265
266 TC3_BGP_Peer1_Check_Log_For_No_Updates
267     [Documentation]    Check for no updates received by iBGP peer No. 1
268     [Tags]    critical
269     SSHLibrary.Switch Connection    bgp_peer1_console
270     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_LOG_CHECK_TIMEOUT}    ${DEFAULT_LOG_CHECK_PERIOD}    Check_File_For_Word_Count    ${BGP_PEER1_LOG_FILE}    total_received_update_message_counter: 0    2
271
272 TC3_Disconnect_BGP_Peer1
273     [Documentation]    Stop BGP peer & store logs
274     [Tags]    critical
275     SSHLibrary.Switch Connection    bgp_peer1_console
276     Stop_Console_Tool
277     Store_File_To_Workspace    ${BGP_PEER1_LOG_FILE}    tc3_${BGP_PEER1_LOG_FILE}
278
279 TC3_BGP_Peer2_Check_Log_For_No_Updates
280     [Documentation]    Consequent check for no updates received by iBGP peer No. 2
281     [Tags]    critical
282     SSHLibrary.Switch Connection    bgp_peer2_console
283     ${log_check_timeout}=    DateTime.Convert_Time    ${DEFAULT_LOG_CHECK_TIMEOUT}    result_format=number
284     BuiltIn.Wait_Until_Keyword_Succeeds    ${log_check_timeout*2}    ${DEFAULT_LOG_CHECK_PERIOD}    Check_File_For_Word_Count    ${BGP_PEER2_LOG_FILE}    total_received_update_message_counter: 0    4
285
286 TC3_Disconnect_BGP_Peer2
287     [Documentation]    Stop BGP peer & store logs
288     [Tags]    critical
289     SSHLibrary.Switch Connection    bgp_peer2_console
290     Stop_Console_Tool
291     Store_File_To_Workspace    ${BGP_PEER2_LOG_FILE}    tc3_${BGP_PEER2_LOG_FILE}
292
293 TC_3_Check_for_Empty_IPv4_Topology
294     BuiltIn.Wait_Until_Keyword_Succeeds    ${DEFAULT_TOPOLOGY_CHECK_TIMEOUT}    ${DEFAULT_TOPOLOGY_CHECK_PERIOD}    Check_Example_IPv4_Topology_Does_Not_Contain    prefix
295
296 TC3_Delete_BGP_Peers_Configuration
297     [Documentation]    Delete all previously configured BGP peers.
298     [Tags]    critical
299     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer1'}
300     ConfigViaRestconf.Delete_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}ibgp_peers    ${template_as_string}
301     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer2'}
302     ConfigViaRestconf.Delete_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}ibgp_peers    ${template_as_string}
303
304 *** Keywords ***
305 Setup_Everything
306     [Documentation]    SSH-login to mininet machine, create HTTP session,
307     ...    prepare directories for responses, put Python tool to mininet machine, setup imported resources.
308     # TODO: Choose keywords used by more than one test suite to be placed in a common place.
309     SetupUtils.Setup_Utils_For_Setup_And_Teardown
310     SSHLibrary.Set_Default_Configuration    prompt=${ODL_SYSTEM_PROMPT}
311     SSHLibrary.Open_Connection    ${ODL_SYSTEM_IP}    alias=bgp_peer1_console
312     Utils.Flexible_Controller_Login
313     SSHLibrary.Open_Connection    ${ODL_SYSTEM_IP}    alias=bgp_peer2_console
314     Utils.Flexible_Controller_Login
315     SSHKeywords.Require_Python
316     SSHKeywords.Assure_Library_Ipaddr    target_dir=.
317     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/fastbgp/play.py
318     RequestsLibrary.Create_Session    operational    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}${OPERATIONAL_TOPO_API}    auth=${AUTH}
319     ConfigViaRestconf.Setup_Config_Via_Restconf
320     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${CONTROLLER_LOG_LEVEL}
321     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${CONTROLLER_BGP_LOG_LEVEL} org.opendaylight.bgpcep
322     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${CONTROLLER_BGP_LOG_LEVEL} org.opendaylight.protocol
323
324 Teardown_Everything
325     [Documentation]    Create and Log the diff between expected and actual responses, make sure Python tool was killed.
326     ...    Tear down imported Resources.
327     KillPythonTool.Search_And_Kill_Remote_Python    'play\.py'
328     ConfigViaRestconf.Teardown_Config_Via_Restconf
329     RequestsLibrary.Delete_All_Sessions
330     SSHLibrary.Close_All_Connections
331
332 Check_Example_IPv4_Topology_Content
333     [Arguments]    ${string_to_check}=${EMPTY}
334     [Documentation]    Check the example-ipv4-topology content for string
335     ${response}=    RequestsLibrary.Get Request    operational    topology/example-ipv4-topology
336     BuiltIn.Log    ${response.status_code}
337     BuiltIn.Log    ${response.text}
338     BuiltIn.Should_Contain    ${response.text}    ${string_to_check}
339
340 Check_Example_IPv4_Topology_Does_Not_Contain
341     [Arguments]    ${string_to_check}
342     [Documentation]    Check the example-ipv4-topology does not contain the string
343     ${response}=    RequestsLibrary.Get Request    operational    topology/example-ipv4-topology
344     BuiltIn.Log    ${response.status_code}
345     BuiltIn.Log    ${response.text}
346     BuiltIn.Should_Not_Contain    ${response.text}    ${string_to_check}