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