Peer group reconfig test case
[integration/test.git] / csit / suites / bgpcep / bgpuser / basic.robot
1 *** Settings ***
2 Documentation     Basic tests for odl-bgpcep-bgp-all feature.
3 ...
4 ...               Copyright (c) 2015 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 BGP functional test cases:
11 ...               BGP peer initiated connection
12 ...               - introduce and check 3 prefixes in one update message
13 ...               ODL controller initiated connection:
14 ...               - introduce and check 3 prefixes in one update message
15 ...               - introduce 2 prefixes in first update message and then additional 2 prefixes
16 ...               in another update while the very first prefix is withdrawn
17 ...               - introduce 3 prefixes and try to withdraw the first one
18 ...               (to be ignored by controller) in a single update message
19 ...
20 ...               For versions Oxygen and further, there are TC_R (test case reset) which
21 ...               test session-reset functionality.
22 ...               Resets the session, and than verifies that example-ipv4-topology is empty again.
23 ...
24 ...               For versions Fluorine and further, there are TC_PG (test case peer group) which
25 ...               test configuration and reconfiguration of peer-groups and neighbors configured by them.
26 ...               - configure peer-group, and assign neighbor to this peer-group
27 ...               - check filled topology
28 ...               - reconfigure peer-group without ipv4 unicast afi-safi
29 ...               - check empty topology
30 ...               - reconfigre neighbor without peer-group, delete peer-group
31 ...
32 ...               Brief description how to perform BGP functional test:
33 ...               https://wiki.opendaylight.org/view/BGP_LS_PCEP:Lithium_Feature_Tests#How_to_test_2
34 ...
35 ...               Reported bugs:
36 ...               https://bugs.opendaylight.org/show_bug.cgi?id=4409
37 ...               https://bugs.opendaylight.org/show_bug.cgi?id=4634
38 Suite Setup       Setup_Everything
39 Suite Teardown    Teardown_Everything
40 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Fast_Failing
41 Test Teardown     FailFast.Start_Failing_Fast_If_This_Failed
42 Library           OperatingSystem
43 Library           SSHLibrary    timeout=10s
44 Library           RequestsLibrary
45 Library           ../../../libraries/norm_json.py
46 Variables         ../../../variables/bgpuser/variables.py    ${TOOLS_SYSTEM_IP}    ${ODL_STREAM}
47 Resource          ../../../variables/Variables.robot
48 Resource          ../../../libraries/BGPcliKeywords.robot
49 Resource          ../../../libraries/BGPSpeaker.robot
50 Resource          ../../../libraries/FailFast.robot
51 Resource          ../../../libraries/KillPythonTool.robot
52 Resource          ../../../libraries/SetupUtils.robot
53 Resource          ../../../libraries/SSHKeywords.robot
54 Resource          ../../../libraries/TemplatedRequests.robot
55 Resource          ../../../libraries/Utils.robot
56 Resource          ../../../libraries/WaitForFailure.robot
57 Resource          ../../../libraries/CompareStream.robot
58
59 *** Variables ***
60 ${ACTUAL_RESPONSES_FOLDER}    ${TEMPDIR}/actual
61 ${EXPECTED_RESPONSES_FOLDER}    ${TEMPDIR}/expected
62 ${BGP_VARIABLES_FOLDER}    ${CURDIR}/../../../variables/bgpuser/
63 ${TOOLS_SYSTEM_PROMPT}    ${DEFAULT_LINUX_PROMPT}
64 ${HOLDTIME}       180
65 ${BGP_TOOL_LOG_LEVEL}    info
66 ${ODL_LOG_LEVEL}    INFO
67 ${ODL_BGP_LOG_LEVEL}    DEFAULT
68 ${CONFIG_SESSION}    session
69 ${PEER_GROUP}     internal-neighbors
70 ${PROTOCOL_OPENCONFIG}    ${RIB_INSTANCE}
71 ${DEVICE_NAME}    controller-config
72 ${BGP_PEER_NAME}    example-bgp-peer
73 ${RIB_INSTANCE}    example-bgp-rib
74
75 *** Test Cases ***
76 Check_For_Empty_Topology_Before_Talking
77     [Documentation]    Sanity check example-ipv4-topology is up but empty.
78     [Tags]    critical
79     Wait_For_Topology_To_Change_To    ${empty_json}    010_Empty.json    timeout=180s
80
81 Reconfigure_ODL_To_Accept_Connection
82     [Documentation]    Configure BGP peer module with initiate-connection set to false.
83     &{mapping}    Create Dictionary    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}
84     ...    INITIATE=false    BGP_RIB=${RIB_INSTANCE}    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}    RIB_INSTANCE_NAME=${RIB_INSTANCE}
85     TemplatedRequests.Put_As_Xml_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
86     [Teardown]    SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
87
88 Start_Talking_BGP_speaker
89     [Documentation]    Start Python speaker to connect to ODL, verify that the tool does not promptly exit.
90     # Myport value is needed for checking whether connection at precise port was established.
91     BGPSpeaker.Start_BGP_Speaker    --amount 3 --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT} --${BGP_TOOL_LOG_LEVEL}
92     Read_And_Fail_If_Prompt_Is_Seen
93
94 Check_Talking_Connection_Is_Established
95     [Documentation]    See TCP (BGP) connection in established state.
96     # This case is separate from the previous one, to resemble structure of the second half of this suite more closely.
97     Check_Speaker_Is_Connected
98     [Teardown]    Utils.Report_Failure_Due_To_Bug    5171
99
100 Check_Talking_Topology_Is_Filled
101     [Documentation]    See new routes in example-ipv4-topology as a proof that synchronization was correct.
102     [Tags]    critical
103     Wait_For_Topology_To_Change_To    ${filled_json}    020_Filled.json
104
105 TC_R_Reset_Bgp_Peer_Session
106     [Documentation]    Reset Peer Session
107     [Tags]    Critical
108     &{mapping}    Create Dictionary    IP=${TOOLS_SYSTEM_IP}    RIB_INSTANCE_NAME=${RIB_INSTANCE}
109     CompareStream.Run_Keyword_If_At_Least_Oxygen    TemplatedRequests.Post_As_Xml_Templated    folder=${BGP_VARIABLES_FOLDER}${/}peer_session/restart    mapping=${mapping}    session=${CONFIG_SESSION}
110
111 TC_R_Check_For_Empty_Topology_After_Resetting
112     [Documentation]    See example-ipv4-topology empty after resetting session
113     [Tags]    critical
114     CompareStream.Run_Keyword_If_At_Least_Oxygen    Wait_For_Topology_To_Change_To    ${empty_json}    030_Empty.json
115
116 TC_PG_Reconfigure_ODL_With_Peer_Group_To_Accept_Connection
117     [Documentation]    Configure BGP peer module with initiate-connection set to false.
118     &{mapping}    BuiltIn.Create_Dictionary    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
119     CompareStream.Run_Keyword_If_At_Least_Fluorine    TemplatedRequests.Delete_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
120     CompareStream.Run_Keyword_If_At_Least_Fluorine    Configure_Peer_Group
121     &{mapping}    Create Dictionary    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}
122     ...    PEER_GROUP_NAME=${PEER_GROUP}    INITIATE=false    BGP_RIB=${RIB_INSTANCE}    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}    RIB_INSTANCE_NAME=${RIB_INSTANCE}
123     CompareStream.Run_Keyword_If_At_Least_Fluorine    TemplatedRequests.Put_As_Xml_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_peer_group    mapping=${mapping}    session=${CONFIG_SESSION}
124     [Teardown]    SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
125
126 TC_PG_Restart_Talking_BGP_Speaker
127     [Documentation]    Abort the Python speaker. Also, attempt to stop failing fast.
128     [Tags]    critical
129     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
130     CompareStream.Run_Keyword_If_At_Least_Fluorine    Restart_Talking_BGP_Speaker
131     [Teardown]    FailFast.Do_Not_Start_Failing_If_This_Failed
132
133 TC_PG_Check_Talking_Topology_Is_Filled
134     [Documentation]    See new routes in example-ipv4-topology as a proof that synchronization was correct.
135     [Tags]    critical
136     CompareStream.Run_Keyword_If_At_Least_Fluorine    Wait_For_Topology_To_Change_To    ${filled_json}    021_Filled.json
137
138 TC_PG_Reconfigure_ODL_With_Peer_Group_Without_Ipv4_Unicast
139     [Documentation]    Configure BGP peer module with initiate-connection set to false. (Fluorine only)
140     CompareStream.Run_Keyword_If_At_Least_Fluorine    Configure_Peer_Group    peer_group_folder=peer_group_without_ipv4
141     [Teardown]    SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
142
143 TC_PG_Check_For_Empty_Topology_After_Deconfiguration
144     [Documentation]    See example-ipv4-topology empty after resetting session (Fluorine only)
145     [Tags]    critical
146     CompareStream.Run_Keyword_If_At_Least_Fluorine    Wait_For_Topology_To_Change_To    ${empty_json}    031_Empty.json
147
148 TC_PG_Reconfigure_ODL_To_Accept_Connection
149     [Documentation]    Configure BGP peer module with initiate-connection set to false. (Fluorine only)
150     &{mapping}    Create Dictionary    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}
151     ...    PEER_GROUP_NAME=${PEER_GROUP}    INITIATE=false    BGP_RIB=${RIB_INSTANCE}    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}    RIB_INSTANCE_NAME=${RIB_INSTANCE}
152     CompareStream.Run_Keyword_If_At_Least_Fluorine    TemplatedRequests.Delete_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_peer_group    mapping=${mapping}    session=${CONFIG_SESSION}
153     CompareStream.Run_Keyword_If_At_Least_Fluorine    TemplatedRequests.Put_As_Xml_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
154     CompareStream.Run_Keyword_If_At_Least_Fluorine    Deconfigure_Peer_Group
155     [Teardown]    SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
156
157 Kill_Talking_BGP_Speaker
158     [Documentation]    Abort the Python speaker. Also, attempt to stop failing fast.
159     [Tags]    critical
160     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
161     BGPSpeaker.Kill_BGP_Speaker
162     FailFast.Do_Not_Fail_Fast_From_Now_On
163     # NOTE: It is still possible to remain failing fast, if both previous and this test have failed.
164     [Teardown]    FailFast.Do_Not_Start_Failing_If_This_Failed
165
166 Check_For_Empty_Topology_After_Talking
167     [Documentation]    See example-ipv4-topology empty again.
168     [Tags]    critical
169     Wait_For_Topology_To_Change_To    ${empty_json}    030_Empty.json
170
171 Start_Listening_BGP_Speaker
172     [Documentation]    Start Python speaker in listening mode, verify that the tool does not exit quickly.
173     BGPSpeaker.Start_BGP_Speaker    --amount 3 --listen --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --${BGP_TOOL_LOG_LEVEL}
174     Read_And_Fail_If_Prompt_Is_Seen
175
176 Check_Listening_Connection_Is_Not_Established_Yet
177     [Documentation]    See no TCP connection, as both ODL and tool are in listening mode.
178     Check_Speaker_Is_Not_Connected
179
180 Check_For_Empty_Topology_Before_Listening
181     [Documentation]    Sanity check example-ipv4-topology is still empty.
182     [Tags]    critical
183     Verify_That_Topology_Does_Not_Change_From    ${empty_json}    040_Empty.json
184
185 Reconfigure_ODL_To_Initiate_Connection
186     [Documentation]    Replace BGP peer config module, now with initiate-connection set to true.
187     &{mapping}    Create Dictionary    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}
188     ...    INITIATE=true    BGP_RIB=${RIB_INSTANCE}    PASSIVE_MODE=false    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}    RIB_INSTANCE_NAME=${RIB_INSTANCE}
189     TemplatedRequests.Put_As_Xml_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
190
191 Check_Listening_Connection_Is_Established
192     [Documentation]    See TCP (BGP) connection in established state.
193     Check_Speaker_Is_Connected
194
195 Check_Listening_Topology_Is_Filled
196     [Documentation]    See new routes in example-ipv4-topology as a proof that synchronization was correct.
197     [Tags]    critical
198     Wait_For_Topology_To_Change_To    ${filled_json}    050_Filled.json
199
200 Kill_Listening_BGP_Speaker
201     [Documentation]    Abort the Python speaker. Also, attempt to stop failing fast.
202     [Tags]    critical
203     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
204     BGPSpeaker.Kill_BGP_Speaker
205     FailFast.Do_Not_Fail_Fast_From_Now_On
206     # NOTE: It is still possible to remain failing fast, if both previous and this test have failed.
207     [Teardown]    FailFast.Do_Not_Start_Failing_If_This_Failed
208
209 Check_For_Empty_Topology_After_Listening
210     [Documentation]    Post-condition: Check example-ipv4-topology is empty again.
211     [Tags]    critical
212     Wait_For_Topology_To_Change_To    ${empty_json}    060_Empty.json
213
214 Start_Listening_BGP_Speaker_Case_2
215     [Documentation]    BGP Speaker introduces 2 prefixes in the first update & another 2 prefixes while the very first is withdrawn in 2nd update
216     BGPSpeaker.Start_BGP_Speaker    --amount 3 --listen --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --prefill=2 --insert=2 --withdraw=1 --updates=single --firstprefix=8.0.0.240 --${BGP_TOOL_LOG_LEVEL}
217     Read_And_Fail_If_Prompt_Is_Seen
218
219 Check_Listening_Connection_Is_Established_Case_2
220     [Documentation]    See TCP (BGP) connection in established state.
221     Check_Speaker_Is_Connected
222
223 Check_Listening_Topology_Is_Filled_Case_2
224     [Documentation]    See new routes in example-ipv4-topology as a proof that synchronization was correct.
225     [Tags]    critical
226     Wait_For_Topology_To_Change_To    ${filled_json}    050_Filled.json
227     [Teardown]    Report_Failure_Due_To_Bug    4409
228
229 Kill_Listening_BGP_Speaker_Case_2
230     [Documentation]    Abort the Python speaker. Also, attempt to stop failing fast.
231     [Tags]    critical
232     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
233     BGPSpeaker.Kill_BGP_Speaker
234     FailFast.Do_Not_Fail_Fast_From_Now_On
235     # NOTE: It is still possible to remain failing fast, if both previous and this test have failed.
236     [Teardown]    FailFast.Do_Not_Start_Failing_If_This_Failed
237
238 Check_For_Empty_Topology_After_Listening_Case_2
239     [Documentation]    Post-condition: Check example-ipv4-topology is empty again.
240     [Tags]    critical
241     Wait_For_Topology_To_Change_To    ${empty_json}    060_Empty.json
242
243 Start_Listening_BGP_Speaker_Case_3
244     [Documentation]    BGP Speaker introduces 3 prefixes while the first one occures again in the withdrawn list (to be ignored bu controller)
245     BGPSpeaker.Start_BGP_Speaker    --amount 2 --listen --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --prefill=0 --insert=3 --withdraw=1 --updates=single --${BGP_TOOL_LOG_LEVEL}
246     Read_And_Fail_If_Prompt_Is_Seen
247
248 Check_Listening_Connection_Is_Established_Case_3
249     [Documentation]    See TCP (BGP) connection in established state.
250     Check_Speaker_Is_Connected
251
252 Check_Listening_Topology_Is_Filled_Case_3
253     [Documentation]    See new routes in example-ipv4-topology as a proof that synchronization was correct.
254     [Tags]    critical
255     Wait_For_Topology_To_Change_To    ${filled_json}    050_Filled.json
256     [Teardown]    Report_Failure_Due_To_Bug    4634
257
258 Kill_Listening_BGP_Speaker_Case_3
259     [Documentation]    Abort the Python speaker. Also, attempt to stop failing fast.
260     [Tags]    critical
261     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
262     BGPSpeaker.Kill_BGP_Speaker
263     FailFast.Do_Not_Fail_Fast_From_Now_On
264     # NOTE: It is still possible to remain failing fast, if both previous and this test have failed.
265     [Teardown]    FailFast.Do_Not_Start_Failing_If_This_Failed
266
267 Check_For_Empty_Topology_After_Listening_Case_3
268     [Documentation]    Post-condition: Check example-ipv4-topology is empty again.
269     [Tags]    critical
270     Wait_For_Topology_To_Change_To    ${empty_json}    060_Empty.json
271
272 Delete_Bgp_Peer_Configuration
273     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
274     &{mapping}    BuiltIn.Create_Dictionary    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
275     TemplatedRequests.Delete_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
276     # TODO: Do we need to check something else?
277
278 *** Keywords ***
279 Setup_Everything
280     [Documentation]    Initialize SetupUtils. SSH-login to mininet machine, create HTTP session,
281     ...    prepare directories for responses, put Python tool to mininet machine, setup imported resources.
282     SetupUtils.Setup_Utils_For_Setup_And_Teardown
283     SSHLibrary.Set_Default_Configuration    prompt=${TOOLS_SYSTEM_PROMPT}
284     RequestsLibrary.Create_Session    operational    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}${OPERATIONAL_TOPO_API}    auth=${AUTH}
285     # TODO: Do not include slash in ${OPERATIONAL_TOPO_API}, having it typed here is more readable.
286     # TODO: Alternatively, create variable in Variables which starts with http.
287     # Both TODOs would probably need to update every suite relying on current Variables.
288     OperatingSystem.Remove_Directory    ${EXPECTED_RESPONSES_FOLDER}    recursive=True
289     OperatingSystem.Remove_Directory    ${ACTUAL_RESPONSES_FOLDER}    recursive=True
290     # The previous suite may have been using the same directories.
291     OperatingSystem.Create_Directory    ${EXPECTED_RESPONSES_FOLDER}
292     OperatingSystem.Create_Directory    ${ACTUAL_RESPONSES_FOLDER}
293     SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}
294     SSHKeywords.Flexible_Mininet_Login
295     SSHKeywords.Require_Python
296     SSHKeywords.Assure_Library_Ipaddr    target_dir=.
297     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/fastbgp/play.py
298     RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
299     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${ODL_LOG_LEVEL}
300     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${ODL_BGP_LOG_LEVEL} org.opendaylight.bgpcep
301     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${ODL_BGP_LOG_LEVEL} org.opendaylight.protocol
302
303 Teardown_Everything
304     [Documentation]    Create and Log the diff between expected and actual responses, make sure Python tool was killed.
305     ...    Tear down imported Resources.
306     ${diff}=    OperatingSystem.Run    diff -dur ${EXPECTED_RESPONSES_FOLDER} ${ACTUAL_RESPONSES_FOLDER}
307     BuiltIn.Log    ${diff}
308     KillPythonTool.Search_And_Kill_Remote_Python    'play\.py'
309     RequestsLibrary.Delete_All_Sessions
310     SSHLibrary.Close_All_Connections
311
312 Wait_For_Topology_To_Change_To
313     [Arguments]    ${json_topology}    ${filename}    ${timeout}=10s    ${refresh}=1s
314     [Documentation]    Normalize the expected json topology and save it to ${EXPECTED_RESPONSES_FOLDER}.
315     ...    Wait until Compare_Topology matches. ${ACTUAL_RESPONSES_FOLDER} will hold its last result.
316     ${topology_normalized}=    Normalize_And_Save_Expected_Json    ${json_topology}    ${filename}    ${EXPECTED_RESPONSES_FOLDER}
317     BuiltIn.Wait_Until_Keyword_Succeeds    ${timeout}    ${refresh}    Compare_Topology    ${topology_normalized}    ${filename}
318
319 Verify_That_Topology_Does_Not_Change_From
320     [Arguments]    ${json_topology}    ${filename}    ${timeout}=10s    ${refresh}=1s
321     [Documentation]    Normalize the expected json topology and save it to ${EXPECTED_RESPONSES_FOLDER}.
322     ...    Verify that Compare_Topology keeps passing. ${ACTUAL_RESPONSES_FOLDER} will hold its last result.
323     ${topology_normalized}=    Normalize_And_Save_Expected_Json    ${json_topology}    ${filename}    ${EXPECTED_RESPONSES_FOLDER}
324     WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout    ${timeout}    ${refresh}    Compare_Topology    ${topology_normalized}    ${filename}
325
326 Compare_Topology
327     [Arguments]    ${expected_normalized}    ${filename}
328     [Documentation]    Get current example-ipv4-topology as json, normalize it, save to ${ACTUAL_RESPONSES_FOLDER}.
329     ...    Check that status code is 200, check that normalized jsons match exactly.
330     ${response}=    RequestsLibrary.Get Request    operational    topology/example-ipv4-topology
331     BuiltIn.Log    ${response.status_code}
332     BuiltIn.Log    ${response.text}
333     ${actual_normalized}=    Normalize_And_Save_Expected_Json    ${response.text}    ${filename}    ${ACTUAL_RESPONSES_FOLDER}
334     BuiltIn.Should_Be_Equal_As_Strings    ${response.status_code}    200
335     BuiltIn.Should_Be_Equal    ${actual_normalized}    ${expected_normalized}
336
337 Normalize_And_Save_Expected_Json
338     [Arguments]    ${json_text}    ${filename}    ${directory}
339     [Documentation]    Normalize given json using norm_json library. Log and save the result to given filename under given directory.
340     ${json_normalized}=    norm_json.normalize_json_text    ${json_text}
341     BuiltIn.Log    ${json_normalized}
342     OperatingSystem.Create_File    ${directory}${/}${filename}    ${json_normalized}
343     # TODO: Should we prepend .json to the filename? When we detect it is not already prepended?
344     [Return]    ${json_normalized}
345
346 Check_Speaker_Is_Not_Connected
347     [Documentation]    Give it a few tries to see zero established connections.
348     BuiltIn.Wait_Until_Keyword_Succeeds    3s    1s    Check_Number_Of_Speaker_Connections    0
349
350 Check_Speaker_Is_Connected
351     [Documentation]    Give it several tries to see exactly one established connection.
352     BuiltIn.Wait_Until_Keyword_Succeeds    5s    1s    Check_Number_Of_Speaker_Connections    1
353
354 Check_Number_Of_Speaker_Connections
355     [Arguments]    ${howmany}
356     [Documentation]    Run netstat in mininet machine and parse it for number of established connections. Check it is ${howmany}.
357     ${output}=    SSHKeywords.Count_Port_Occurences    17900    ESTABLISHED    python
358     BuiltIn.Should_Be_Equal_As_Strings    ${output}    ${howmany}
359
360 Configure_Peer_Group
361     [Arguments]    ${peer_group_folder}=peer_group
362     [Documentation]    Configures peer group which is template for all the neighbors which are going
363     ...    to be configured. Also after PUT, this case verifies presence of peer group within
364     ...    peer-groups. This case is specific to versions Fluorine and above.
365     &{mapping}    Create Dictionary    DEVICE_NAME=${DEVICE_NAME}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    INITIATE=false    BGP_RIB=${RIB_INSTANCE}
366     ...    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}    RIB_INSTANCE_NAME=${RIB_INSTANCE}    PEER_GROUP_NAME=${PEER_GROUP}    RR_CLIENT=false
367     TemplatedRequests.Put_As_Xml_Templated    ${BGP_VARIABLES_FOLDER}${/}${peer_group_folder}    mapping=${mapping}    session=${CONFIG_SESSION}
368     TemplatedRequests.Get_As_Json_Templated    ${BGP_VARIABLES_FOLDER}${/}verify_${peer_group_folder}    mapping=${mapping}    session=${CONFIG_SESSION}    verify=True
369
370 Deconfigure_Peer_Group
371     [Documentation]    Deconfigures peer group which is template for all the neighbors
372     ...    This test case is specific to versions Fluorine and above.
373     &{mapping}    Create Dictionary    DEVICE_NAME=${DEVICE_NAME}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    INITIATE=false    BGP_RIB=${RIB_INSTANCE}
374     ...    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}    RIB_INSTANCE_NAME=${RIB_INSTANCE}    PEER_GROUP_NAME=${PEER_GROUP}    RR_CLIENT=false
375     TemplatedRequests.Delete_Templated    ${BGP_VARIABLES_FOLDER}${/}peer_group    mapping=${mapping}    session=${CONFIG_SESSION}
376
377 Restart_Talking_BGP_Speaker
378     [Documentation]    Abort the Python speaker. Also, attempt to stop failing fast. And Start it again.
379     ...    We have to restart it this way because we reset session before
380     BGPSpeaker.Kill_BGP_Speaker
381     FailFast.Do_Not_Fail_Fast_From_Now_On
382     BGPSpeaker.Start_BGP_Speaker    --amount 3 --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT} --${BGP_TOOL_LOG_LEVEL}
383     Read_And_Fail_If_Prompt_Is_Seen