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