7aca78e9a279180446be6419591054576902a6f1
[integration/test.git] / csit / suites / bgpcep / bgpuser / bgp_app_peer_basic.robot
1 *** Settings ***
2 Documentation     Basic tests for BGP application peer.
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 for
11 ...               BGP application peer operations and checks for IP4 topology updates
12 ...               and updates towards BGP peer as follows:
13 ...
14 ...               Test case 1: Initial BGP peer connection with pre-filled topology (Bug 4714),
15 ...               POST and simple DELETE requests used.
16 ...               BGP_Application_Peer_Post_3_Initial_Routes,
17 ...               Check_Example-IPv4-Topology_Is_Filled_With_3_Routes,
18 ...               Connect_BGP_Peer,
19 ...               BGP_Peer_Check_Incomming_Updates_For_3_Introduced_Prefixes,
20 ...               BGP_Application_Peer_Delete_3_Initial_Routes,
21 ...               Check_Example-IPv4-Topology_Is_Empty,
22 ...               Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes,
23 ...               Stop_BGP_Peer.
24 ...
25 ...               Test case 2: PUT and DELETE all routes requests while BGP peer is connected.
26 ...               Reconnect_BGP_Peer,
27 ...               BGP_Application_Peer_Put_3_Routes,
28 ...               Check_Example-IPv4-Topology_Is_Filled_With_3_Routes,
29 ...               BGP_Peer_Check_Incomming_Updates_For_3_Introduced_Prefixes,
30 ...               BGP_Application_Peer_Delete_All_Routes,
31 ...               Check_Example-IPv4-Topology_Is_Empty,
32 ...               BGP_Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes,
33 ...               Stop_BGP_Peer.
34 ...
35 ...               Test case 3: Repeated BGP peer re-connection with pre-filled topology.
36 ...               BGP_Application_Peer_Put_3_Routes,
37 ...               Check_Example-IPv4-Topology_Is_Filled_With_3_Routes,
38 ...               Reconnect_BGP_Peer_And_Check_Incomming_Updates_For_3_Introduced_Prefixes,
39 ...               BGP_Application_Peer_Delete_All_Routes,
40 ...               Check_Example-IPv4-Topology_Is_Empty,
41 ...               BGP_Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes,
42 ...               Stop_BGP_Peer.
43 ...
44 ...               Brief description how to configure BGP application peer and
45 ...               how to use restconf application peer interface:
46 ...               https://wiki.opendaylight.org/view/BGP_LS_PCEP:User_Guide#BGP_Application_Peer
47 ...               https://wiki.opendaylight.org/view/BGP_LS_PCEP:Programmer_Guide#BGP
48 ...               Covered bugs:
49 ...               Bug 4714 - No routes from loc-rib are advertised to newly connected peer
50 Suite Setup       Setup_Everything
51 Suite Teardown    Teardown_Everything
52 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
53 Test Teardown     FailFast.Start_Failing_Fast_If_This_Failed
54 Library           OperatingSystem
55 Library           SSHLibrary    timeout=10s
56 Library           RequestsLibrary
57 Library           ${CURDIR}/../../../libraries/HsfJson/hsf_json.py
58 Variables         ${CURDIR}/../../../variables/Variables.py
59 Variables         ${CURDIR}/../../../variables/bgpuser/variables.py    ${TOOLS_SYSTEM_IP}
60 Resource          ${CURDIR}/../../../libraries/BGPcliKeywords.robot
61 Resource          ${CURDIR}/../../../libraries/BGPSpeaker.robot
62 Resource          ${CURDIR}/../../../libraries/ConfigViaRestconf.robot
63 Resource          ${CURDIR}/../../../libraries/FailFast.robot
64 Resource          ${CURDIR}/../../../libraries/KarafKeywords.robot
65 Resource          ${CURDIR}/../../../libraries/KillPythonTool.robot
66 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
67 Resource          ${CURDIR}/../../../libraries/SSHKeywords.robot
68 Resource          ${CURDIR}/../../../libraries/Utils.robot
69 Resource          ${CURDIR}/../../../libraries/WaitForFailure.robot
70
71 *** Variables ***
72 ${ACTUAL_RESPONSES_FOLDER}    ${TEMPDIR}/actual
73 ${EXPECTED_RESPONSES_FOLDER}    ${TEMPDIR}/expected
74 ${BGP_VARIABLES_FOLDER}    ${CURDIR}/../../../variables/bgpuser/
75 ${TOOLS_SYSTEM_PROMPT}    ${DEFAULT_LINUX_PROMPT}
76 ${HOLDTIME}       180
77 ${BGP_PEER_LOG_LEVEL}    debug
78 ${BGP_APP_PEER_LOG_LEVEL}    debug
79 ${CONTROLLER_LOG_LEVEL}    INFO
80 ${CONTROLLER_BGP_LOG_LEVEL}    DEFAULT
81 ${BGP_PEER_COMMAND}    python play.py --amount 0 --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT} --${BGP_PEER_LOG_LEVEL}
82 ${BGP_PEER_OPTIONS}    ${EMPTY}
83 ${BGP_APP_PEER_ID}    10.0.0.10
84 ${BGP_APP_PEER_POST_COMMAND}    python bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command post --count 3 --prefix 8.0.1.0 --prefixlen 28 --${BGP_APP_PEER_LOG_LEVEL}
85 ${BGP_APP_PEER_PUT_COMMAND}    python bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command put --count 3 --prefix 8.0.1.0 --prefixlen 28 --${BGP_APP_PEER_LOG_LEVEL}
86 ${BGP_APP_PEER_DELETE_COMMAND}    python bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command delete --count 3 --prefix 8.0.1.0 --prefixlen 28 --${BGP_APP_PEER_LOG_LEVEL}
87 ${BGP_APP_PEER_DELETE_ALL_COMMAND}    python bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command delete-all --${BGP_APP_PEER_LOG_LEVEL}
88 ${BGP_APP_PEER_GET_COMMAND}    python bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command get --${BGP_APP_PEER_LOG_LEVEL}
89 ${BGP_APP_PEER_OPTIONS}    &>/dev/null
90 ${BGP_APP_PEER_TIMEOUT}    30s
91
92 *** Test Cases ***
93 Reconfigure_ODL_To_Accept_BGP_Peer_Connection
94     [Documentation]    Configure BGP peer module with initiate-connection set to false.
95     [Tags]    critical
96     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer', 'IP': '${TOOLS_SYSTEM_IP}', 'HOLDTIME': '${HOLDTIME}', 'PEER_PORT': '${BGP_TOOL_PORT}', 'INITIATE': 'false'}
97     ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    ${template_as_string}
98
99 Reconfigure_ODL_To_Accept_BGP_Application_Peer
100     [Documentation]    Configure BGP application peer module.
101     [Tags]    critical
102     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer-app', 'IP': '${BGP_APP_PEER_ID}'}
103     ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}bgp_application_peer    ${template_as_string}
104
105 Check_For_Empty_Example-IPv4-Topology
106     [Documentation]    Sanity check example-ipv4-topology is up but empty.
107     [Tags]    critical
108     Wait_For_Topology_To_Change_To    ${empty_json}    000_Empty.json    timeout=120s
109
110 TC1_BGP_Application_Peer_Post_3_Initial_Routes
111     [Documentation]    Start BGP application peer tool and give it ${BGP_APP_PEER_TIMEOUT}
112     [Tags]    critical
113     Switch_To_BGP_Application_Peer_Console
114     Start_Console_Tool    ${BGP_APP_PEER_POST_COMMAND}    ${BGP_APP_PEER_OPTIONS}
115     Wait_Until_Console_Tool_Finish    ${BGP_APP_PEER_TIMEOUT}
116     Store_File_To_Workspace    bgp_app_peer.log    bgp_app_peer_initial_post_tc1.log
117
118 TC1_Check_Example-IPv4-Topology_Is_Filled_With_3_Routes
119     [Documentation]    See new routes in example-ipv4-topology as a proof that synchronization was correct.
120     [Tags]    critical
121     Wait_For_Topology_To_Change_To    ${filled_json}    010_Filled.json
122
123 TC1_Connect_BGP_Peer
124     [Documentation]    Start BGP peer tool
125     [Tags]    critical
126     Switch_To_BGP_Peer_Console
127     Start_Console_Tool    ${BGP_PEER_COMMAND}    ${BGP_PEER_OPTIONS}
128     Read_And_Fail_If_Prompt_Is_Seen
129
130 TC1_BGP_Peer_Check_Incomming_Updates_For_3_Introduced_Prefixes
131     [Documentation]    Check incomming updates for new routes
132     [Tags]    critical
133     Switch_To_BGP_Peer_Console
134     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received:    3
135     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received: 8.0.1.0/28    1
136     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received: 8.0.1.16/28    1
137     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received: 8.0.1.32/28    1
138     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received:    0
139     [Teardown]    Report_Failure_Due_To_Bug    4714
140
141 TC1_BGP_Application_Peer_Delete_3_Initial_Routes
142     [Documentation]    Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
143     [Tags]    critical
144     Switch_To_BGP_Application_Peer_Console
145     Start_Console_Tool    ${BGP_APP_PEER_DELETE_COMMAND}    ${BGP_APP_PEER_OPTIONS}
146     Wait_Until_Console_Tool_Finish    ${BGP_APP_PEER_TIMEOUT}
147     Store_File_To_Workspace    bgp_app_peer.log    bgp_app_peer_delete_tc1.log
148
149 TC1_Check_Example-IPv4-Topology_Is_Empty
150     [Documentation]    See new routes are deleted.
151     [Tags]    critical
152     Wait_For_Topology_To_Change_To    ${empty_json}    011_Empty.json
153
154 TC1_Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes
155     [Documentation]    Check incomming updates for new routes
156     [Tags]    critical
157     Switch_To_BGP_Peer_Console
158     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received:    3
159     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received: 8.0.1.0/28    1
160     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received: 8.0.1.16/28    1
161     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received: 8.0.1.32/28    1
162     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received:    3
163     [Teardown]    Report_Failure_Due_To_Bug    4714
164
165 TC1_Stop_BGP_Peer
166     [Documentation]    Stop BGP peer tool
167     [Tags]    critical
168     Switch_To_BGP_Peer_Console
169     Stop_Console_Tool
170     Store_File_To_Workspace    bgp_peer.log    bgp_peer_tc1.log
171
172 TC2_Reconnect_BGP_Peer
173     [Documentation]    Start BGP peer tool
174     [Tags]    critical
175     Switch_To_BGP_Peer_Console
176     Start_Console_Tool    ${BGP_PEER_COMMAND}    ${BGP_PEER_OPTIONS}
177     Read_And_Fail_If_Prompt_Is_Seen
178     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received:    0
179     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received:    0
180
181 TC2_BGP_Application_Peer_Put_3_Routes
182     [Documentation]    Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
183     [Tags]    critical
184     Switch_To_BGP_Application_Peer_Console
185     Start_Console_Tool    ${BGP_APP_PEER_PUT_COMMAND}    ${BGP_APP_PEER_OPTIONS}
186     Wait_Until_Console_Tool_Finish    ${BGP_APP_PEER_TIMEOUT}
187     Store_File_To_Workspace    bgp_app_peer.log    bgp_app_peer_put_tc2.log
188
189 TC2_Check_Example-IPv4-Topology_Is_Filled_With_3_Routes
190     [Documentation]    See new routes in example-ipv4-topology as a proof that synchronization was correct.
191     [Tags]    critical
192     Wait_For_Topology_To_Change_To    ${filled_json}    020_Filled.json
193
194 TC2_BGP_Peer_Check_Incomming_Updates_For_3_Introduced_Prefixes
195     [Documentation]    Check incomming updates for new routes
196     [Tags]    critical
197     Switch_To_BGP_Peer_Console
198     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received:    3
199     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received: 8.0.1.0/28    1
200     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received: 8.0.1.16/28    1
201     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received: 8.0.1.32/28    1
202     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received:    0
203
204 TC2_BGP_Application_Peer_Delete_All_Routes
205     [Documentation]    Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
206     [Tags]    critical
207     Switch_To_BGP_Application_Peer_Console
208     Start_Console_Tool    ${BGP_APP_PEER_DELETE_ALL_COMMAND}    ${BGP_APP_PEER_OPTIONS}
209     Wait_Until_Console_Tool_Finish    ${BGP_APP_PEER_TIMEOUT}
210     Store_File_To_Workspace    bgp_app_peer.log    bgp_app_peer_delete_all_tc2.log
211
212 TC2_Check_Example-IPv4-Topology_Is_Empty
213     [Documentation]    See new routes are deleted.
214     [Tags]    critical
215     Wait_For_Topology_To_Change_To    ${empty_json}    021_Empty.json
216
217 TC2_BGP_Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes
218     [Documentation]    Check incomming updates for new routes
219     [Tags]    critical
220     Switch_To_BGP_Peer_Console
221     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received:    3
222     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received: 8.0.1.0/28    1
223     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received: 8.0.1.16/28    1
224     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received: 8.0.1.32/28    1
225     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received:    3
226
227 TC2_Stop_BGP_Peer
228     [Documentation]    Stop BGP peer tool
229     [Tags]    critical
230     Switch_To_BGP_Peer_Console
231     Stop_Console_Tool
232     Store_File_To_Workspace    bgp_peer.log    bgp_peer_tc2.log
233
234 TC3_BGP_Application_Peer_Put_3_Routes
235     [Documentation]    Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
236     [Tags]    critical
237     Switch_To_BGP_Application_Peer_Console
238     Start_Console_Tool    ${BGP_APP_PEER_PUT_COMMAND}    ${BGP_APP_PEER_OPTIONS}
239     Wait_Until_Console_Tool_Finish    ${BGP_APP_PEER_TIMEOUT}
240     Store_File_To_Workspace    bgp_app_peer.log    bgp_app_peer_put_tc3.log
241
242 TC3_Check_Example-IPv4-Topology_Is_Filled_With_3_Routes
243     [Documentation]    See new routes in example-ipv4-topology as a proof that synchronization was correct.
244     [Tags]    critical
245     Wait_For_Topology_To_Change_To    ${filled_json}    030_Filled.json
246
247 TC3_Reconnect_BGP_Peer_And_Check_Incomming_Updates_For_3_Introduced_Prefixes
248     [Documentation]    Start BGP peer tool
249     [Tags]    critical
250     Switch_To_BGP_Peer_Console
251     Start_Console_Tool    ${BGP_PEER_COMMAND}    ${BGP_PEER_OPTIONS}
252     Read_And_Fail_If_Prompt_Is_Seen
253     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received:    3
254     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received:    3
255     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received: 8.0.1.0/28    1
256     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received: 8.0.1.16/28    1
257     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received: 8.0.1.32/28    1
258     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received:    0
259
260 TC3_BGP_Application_Peer_Delete_All_Routes
261     [Documentation]    Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
262     [Tags]    critical
263     Switch_To_BGP_Application_Peer_Console
264     Start_Console_Tool    ${BGP_APP_PEER_DELETE_ALL_COMMAND}    ${BGP_APP_PEER_OPTIONS}
265     Wait_Until_Console_Tool_Finish    ${BGP_APP_PEER_TIMEOUT}
266     Store_File_To_Workspace    bgp_app_peer.log    bgp_app_peer_delete_all_tc3.log
267
268 TC3_Check_Example-IPv4-Topology_Is_Empty
269     [Documentation]    See new routes are deleted.
270     [Tags]    critical
271     Wait_For_Topology_To_Change_To    ${empty_json}    031_Empty.json
272
273 TC3_BGP_Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes
274     [Documentation]    Check incomming updates for new routes
275     [Tags]    critical
276     Switch_To_BGP_Peer_Console
277     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received:    3
278     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received: 8.0.1.0/28    1
279     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received: 8.0.1.16/28    1
280     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received: 8.0.1.32/28    1
281     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received:    3
282
283 TC3_Stop_BGP_Peer
284     [Documentation]    Stop BGP peer tool
285     [Tags]    critical
286     Switch_To_BGP_Peer_Console
287     Stop_Console_Tool
288     Store_File_To_Workspace    bgp_peer.log    bgp_peer_tc3.log
289
290 Delete_Bgp_Peer_Configuration
291     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
292     [Tags]    critical
293     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer'}
294     ConfigViaRestconf.Delete_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    ${template_as_string}
295
296 Delete_Bgp_Application_Peer_Configuration
297     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
298     [Tags]    critical
299     ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer-app'}
300     ConfigViaRestconf.Delete_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}bgp_application_peer    ${template_as_string}
301
302 *** Keywords ***
303 Setup_Everything
304     [Documentation]    SSH-login to mininet machine, create HTTP session,
305     ...    prepare directories for responses, put Python tool to mininet machine, setup imported resources.
306     SetupUtils.Setup_Utils_For_Setup_And_Teardown
307     SSHLibrary.Set_Default_Configuration    prompt=${TOOLS_SYSTEM_PROMPT}
308     Open_BGP_Peer_Console
309     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/fastbgp/play.py
310     Open_BGP_Aplicationp_Peer_Console
311     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/fastbgp/bgp_app_peer.py
312     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/fastbgp/ipv4-routes-template.xml
313     OperatingSystem.Remove_Directory    ${EXPECTED_RESPONSES_FOLDER}    recursive=True
314     OperatingSystem.Remove_Directory    ${ACTUAL_RESPONSES_FOLDER}    recursive=True
315     # The previous suite may have been using the same directories.
316     OperatingSystem.Create_Directory    ${EXPECTED_RESPONSES_FOLDER}
317     OperatingSystem.Create_Directory    ${ACTUAL_RESPONSES_FOLDER}
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     ${diff}=    OperatingSystem.Run    diff -dur ${EXPECTED_RESPONSES_FOLDER} ${ACTUAL_RESPONSES_FOLDER}
328     BuiltIn.Log    ${diff}
329     KillPythonTool.Search_And_Kill_Remote_Python    'play\.py'
330     KillPythonTool.Search_And_Kill_Remote_Python    'bgp_app_peer\.py'
331     ConfigViaRestconf.Teardown_Config_Via_Restconf
332     RequestsLibrary.Delete_All_Sessions
333     SSHLibrary.Close_All_Connections
334
335 Open_BGP_Peer_Console
336     [Documentation]    Create a session for BGP peer.
337     SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}    alias=bgp_peer_console
338     Utils.Flexible_Mininet_Login
339
340 Open_BGP_Aplicationp_Peer_Console
341     [Documentation]    Create a session for BGP peer.
342     SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}    alias=bgp_app_peer_console
343     Utils.Flexible_Mininet_Login
344
345 Switch_To_BGP_Peer_Console
346     SSHLibrary.Switch Connection    bgp_peer_console
347
348 Switch_To_BGP_Application_Peer_Console
349     SSHLibrary.Switch Connection    bgp_app_peer_console
350
351 Wait_For_Topology_To_Change_To
352     [Arguments]    ${json_topology}    ${filename}    ${timeout}=10s    ${refresh}=1s
353     [Documentation]    Normalize the expected json topology and save it to ${EXPECTED_RESPONSES_FOLDER}.
354     ...    Wait until Compare_Topology matches. ${ACTUAL_RESPONSES_FOLDER} will hold its last result.
355     ${topology_normalized}=    Normalize_And_Save_Expected_Json    ${json_topology}    ${filename}    ${EXPECTED_RESPONSES_FOLDER}
356     BuiltIn.Wait_Until_Keyword_Succeeds    ${timeout}    ${refresh}    Compare_Topology    ${topology_normalized}    ${filename}
357
358 Verify_That_Topology_Does_Not_Change_From
359     [Arguments]    ${json_topology}    ${filename}    ${timeout}=10s    ${refresh}=1s
360     [Documentation]    Normalize the expected json topology and save it to ${EXPECTED_RESPONSES_FOLDER}.
361     ...    Verify that Compare_Topology keeps passing. ${ACTUAL_RESPONSES_FOLDER} will hold its last result.
362     ${topology_normalized}=    Normalize_And_Save_Expected_Json    ${json_topology}    ${filename}    ${EXPECTED_RESPONSES_FOLDER}
363     WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout    ${timeout}    ${refresh}    Compare_Topology    ${topology_normalized}    ${filename}
364
365 Compare_Topology
366     [Arguments]    ${expected_normalized}    ${filename}
367     [Documentation]    Get current example-ipv4-topology as json, normalize it, save to ${ACTUAL_RESPONSES_FOLDER}.
368     ...    Check that status code is 200, check that normalized jsons match exactly.
369     ${response}=    RequestsLibrary.Get Request    operational    topology/example-ipv4-topology
370     BuiltIn.Log    ${response.status_code}
371     BuiltIn.Log    ${response.text}
372     ${actual_normalized}=    Normalize_And_Save_Expected_Json    ${response.text}    ${filename}    ${ACTUAL_RESPONSES_FOLDER}
373     BuiltIn.Should_Be_Equal_As_Strings    ${response.status_code}    200
374     BuiltIn.Should_Be_Equal    ${actual_normalized}    ${expected_normalized}
375
376 Normalize_And_Save_Expected_Json
377     [Arguments]    ${json_text}    ${filename}    ${directory}
378     [Documentation]    Normalize given json using hsf_json library. Log and save the result to given filename under given directory.
379     ${json_normalized}=    hsf_json.Hsf_Json    ${json_text}
380     BuiltIn.Log    ${json_normalized}
381     OperatingSystem.Create_File    ${directory}${/}${filename}    ${json_normalized}
382     # TODO: Should we prepend .json to the filename? When we detect it is not already prepended?
383     [Return]    ${json_normalized}