updating bgp userfeatures suites to support openconfig peer configuration
[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/norm_json.py
58 Variables         ${CURDIR}/../../../variables/Variables.py
59 Variables         ${CURDIR}/../../../variables/bgpuser/variables.py    ${TOOLS_SYSTEM_IP}    ${ODL_STREAM}
60 Resource          ${CURDIR}/../../../libraries/BGPcliKeywords.robot
61 Resource          ${CURDIR}/../../../libraries/BGPSpeaker.robot
62 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
63 Resource          ${CURDIR}/../../../libraries/FailFast.robot
64 Resource          ${CURDIR}/../../../libraries/KillPythonTool.robot
65 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
66 Resource          ${CURDIR}/../../../libraries/SSHKeywords.robot
67 Resource          ${CURDIR}/../../../libraries/Utils.robot
68 Resource          ${CURDIR}/../../../libraries/WaitForFailure.robot
69 Resource          ${CURDIR}/../../../libraries/CompareStream.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}    ${ODL_SYSTEM_IP}
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} --stream=${ODL_STREAM}
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} --stream=${ODL_STREAM}
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} --stream=${ODL_STREAM}
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} --stream=${ODL_STREAM}
88 ${BGP_APP_PEER_GET_COMMAND}    python bgp_app_peer.py --host ${ODL_SYSTEM_IP} --port ${RESTCONFPORT} --command get --${BGP_APP_PEER_LOG_LEVEL} --stream=${ODL_STREAM}
89 ${BGP_APP_PEER_OPTIONS}    &>/dev/null
90 ${BGP_APP_PEER_TIMEOUT}    30s
91 ${BGP_PEER_APP_NAME}    example-bgp-peer-app
92 ${CONFIG_SESSION}    session
93 ${RIB_INSTANCE}    example-bgp-rib
94 ${PROTOCOL_OPENCONFIG}    ${RIB_INSTANCE}
95 ${DEVICE_NAME}    controller-config
96 ${BGP_PEER_NAME}    example-bgp-peer
97 ${RIB_INSTANCE}    example-bgp-rib
98
99 *** Test Cases ***
100 Reconfigure_ODL_To_Accept_BGP_Peer_Connection
101     [Documentation]    Configure BGP peer module with initiate-connection set to false.
102     [Tags]    critical
103     &{mapping}    Create Dictionary    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}
104     ...    INITIATE=false    BGP_RIB=${RIB_INSTANCE}    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}    RIB_INSTANCE_NAME=${RIB_INSTANCE}
105     TemplatedRequests.Put_As_Xml_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
106
107 Reconfigure_ODL_To_Accept_BGP_Application_Peer
108     [Documentation]    Configure BGP application peer module.
109     [Tags]    critical
110     &{mapping}    Create Dictionary    DEVICE_NAME=${DEVICE_NAME}    NAME=${BGP_PEER_APP_NAME}    RIB_INSTANCE_NAME=${RIB_INSTANCE}    IP=${BGP_APP_PEER_ID}    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
111     TemplatedRequests.Put_As_Xml_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_application_peer    mapping=${mapping}    session=${CONFIG_SESSION}
112
113 Check_For_Empty_Example-IPv4-Topology
114     [Documentation]    Sanity check example-ipv4-topology is up but empty.
115     [Tags]    critical
116     Wait_For_Topology_To_Change_To    ${empty_json}    000_Empty.json    timeout=120s
117
118 TC1_BGP_Application_Peer_Post_3_Initial_Routes
119     [Documentation]    Start BGP application peer tool and give it ${BGP_APP_PEER_TIMEOUT}
120     [Tags]    critical
121     Switch_To_BGP_Application_Peer_Console
122     Start_Console_Tool    ${BGP_APP_PEER_POST_COMMAND} ${scritp_uri_opt}    ${BGP_APP_PEER_OPTIONS}
123     Wait_Until_Console_Tool_Finish    ${BGP_APP_PEER_TIMEOUT}
124     Store_File_To_Workspace    bgp_app_peer.log    bgp_app_peer_initial_post_tc1.log
125
126 TC1_Check_Example-IPv4-Topology_Is_Filled_With_3_Routes
127     [Documentation]    See new routes in example-ipv4-topology as a proof that synchronization was correct.
128     [Tags]    critical
129     Wait_For_Topology_To_Change_To    ${filled_json}    010_Filled.json
130
131 TC1_Connect_BGP_Peer
132     [Documentation]    Start BGP peer tool
133     [Tags]    critical
134     Switch_To_BGP_Peer_Console
135     Start_Console_Tool    ${BGP_PEER_COMMAND}    ${BGP_PEER_OPTIONS}
136     Read_And_Fail_If_Prompt_Is_Seen
137
138 TC1_BGP_Peer_Check_Incomming_Updates_For_3_Introduced_Prefixes
139     [Documentation]    Check incomming updates for new routes
140     [Tags]    critical
141     Switch_To_BGP_Peer_Console
142     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received:    3
143     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received: 8.0.1.0/28    1
144     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received: 8.0.1.16/28    1
145     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received: 8.0.1.32/28    1
146     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received:    0
147     [Teardown]    Report_Failure_Due_To_Bug    4714
148
149 TC1_BGP_Application_Peer_Delete_3_Initial_Routes
150     [Documentation]    Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
151     [Tags]    critical
152     Switch_To_BGP_Application_Peer_Console
153     Start_Console_Tool    ${BGP_APP_PEER_DELETE_COMMAND} ${scritp_uri_opt}    ${BGP_APP_PEER_OPTIONS}
154     Wait_Until_Console_Tool_Finish    ${BGP_APP_PEER_TIMEOUT}
155     Store_File_To_Workspace    bgp_app_peer.log    bgp_app_peer_delete_tc1.log
156
157 TC1_Check_Example-IPv4-Topology_Is_Empty
158     [Documentation]    See new routes are deleted.
159     [Tags]    critical
160     Wait_For_Topology_To_Change_To    ${empty_json}    011_Empty.json
161
162 TC1_Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes
163     [Documentation]    Check incomming updates for new routes
164     [Tags]    critical
165     Switch_To_BGP_Peer_Console
166     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received:    3
167     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received: 8.0.1.0/28    1
168     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received: 8.0.1.16/28    1
169     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received: 8.0.1.32/28    1
170     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received:    3
171     [Teardown]    Report_Failure_Due_To_Bug    4714
172
173 TC1_Stop_BGP_Peer
174     [Documentation]    Stop BGP peer tool
175     [Tags]    critical
176     Switch_To_BGP_Peer_Console
177     Stop_Console_Tool
178     Store_File_To_Workspace    bgp_peer.log    bgp_peer_tc1.log
179
180 TC2_Reconnect_BGP_Peer
181     [Documentation]    Start BGP peer tool
182     [Tags]    critical
183     Switch_To_BGP_Peer_Console
184     Start_Console_Tool    ${BGP_PEER_COMMAND}    ${BGP_PEER_OPTIONS}
185     Read_And_Fail_If_Prompt_Is_Seen
186     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received:    0
187     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received:    0
188
189 TC2_BGP_Application_Peer_Put_3_Routes
190     [Documentation]    Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
191     [Tags]    critical
192     Switch_To_BGP_Application_Peer_Console
193     Start_Console_Tool    ${BGP_APP_PEER_PUT_COMMAND} ${scritp_uri_opt}    ${BGP_APP_PEER_OPTIONS}
194     Wait_Until_Console_Tool_Finish    ${BGP_APP_PEER_TIMEOUT}
195     Store_File_To_Workspace    bgp_app_peer.log    bgp_app_peer_put_tc2.log
196
197 TC2_Check_Example-IPv4-Topology_Is_Filled_With_3_Routes
198     [Documentation]    See new routes in example-ipv4-topology as a proof that synchronization was correct.
199     [Tags]    critical
200     Wait_For_Topology_To_Change_To    ${filled_json}    020_Filled.json
201
202 TC2_BGP_Peer_Check_Incomming_Updates_For_3_Introduced_Prefixes
203     [Documentation]    Check incomming updates for new routes
204     [Tags]    critical
205     Switch_To_BGP_Peer_Console
206     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received:    3
207     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received: 8.0.1.0/28    1
208     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received: 8.0.1.16/28    1
209     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received: 8.0.1.32/28    1
210     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received:    0
211
212 TC2_BGP_Application_Peer_Delete_All_Routes
213     [Documentation]    Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
214     [Tags]    critical
215     Switch_To_BGP_Application_Peer_Console
216     Start_Console_Tool    ${BGP_APP_PEER_DELETE_ALL_COMMAND} ${scritp_uri_opt}    ${BGP_APP_PEER_OPTIONS}
217     Wait_Until_Console_Tool_Finish    ${BGP_APP_PEER_TIMEOUT}
218     Store_File_To_Workspace    bgp_app_peer.log    bgp_app_peer_delete_all_tc2.log
219
220 TC2_Check_Example-IPv4-Topology_Is_Empty
221     [Documentation]    See new routes are deleted.
222     [Tags]    critical
223     Wait_For_Topology_To_Change_To    ${empty_json}    021_Empty.json
224
225 TC2_BGP_Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes
226     [Documentation]    Check incomming updates for new routes
227     [Tags]    critical
228     Switch_To_BGP_Peer_Console
229     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received:    3
230     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received: 8.0.1.0/28    1
231     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received: 8.0.1.16/28    1
232     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received: 8.0.1.32/28    1
233     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received:    3
234
235 TC2_Stop_BGP_Peer
236     [Documentation]    Stop BGP peer tool
237     [Tags]    critical
238     Switch_To_BGP_Peer_Console
239     Stop_Console_Tool
240     Store_File_To_Workspace    bgp_peer.log    bgp_peer_tc2.log
241
242 TC3_BGP_Application_Peer_Put_3_Routes
243     [Documentation]    Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
244     [Tags]    critical
245     Switch_To_BGP_Application_Peer_Console
246     Start_Console_Tool    ${BGP_APP_PEER_PUT_COMMAND}    ${BGP_APP_PEER_OPTIONS}
247     Wait_Until_Console_Tool_Finish    ${BGP_APP_PEER_TIMEOUT}
248     Store_File_To_Workspace    bgp_app_peer.log    bgp_app_peer_put_tc3.log
249
250 TC3_Check_Example-IPv4-Topology_Is_Filled_With_3_Routes
251     [Documentation]    See new routes in example-ipv4-topology as a proof that synchronization was correct.
252     [Tags]    critical
253     Wait_For_Topology_To_Change_To    ${filled_json}    030_Filled.json
254
255 TC3_Reconnect_BGP_Peer_And_Check_Incomming_Updates_For_3_Introduced_Prefixes
256     [Documentation]    Start BGP peer tool
257     [Tags]    critical
258     Switch_To_BGP_Peer_Console
259     Start_Console_Tool    ${BGP_PEER_COMMAND}    ${BGP_PEER_OPTIONS}
260     Read_And_Fail_If_Prompt_Is_Seen
261     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received:    3
262     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received:    3
263     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received: 8.0.1.0/28    1
264     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received: 8.0.1.16/28    1
265     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received: 8.0.1.32/28    1
266     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received:    0
267
268 TC3_BGP_Application_Peer_Delete_All_Routes
269     [Documentation]    Start BGP application peer tool and give him ${BGP_APP_PEER_TIMEOUT}
270     [Tags]    critical
271     Switch_To_BGP_Application_Peer_Console
272     Start_Console_Tool    ${BGP_APP_PEER_DELETE_ALL_COMMAND}    ${BGP_APP_PEER_OPTIONS}
273     Wait_Until_Console_Tool_Finish    ${BGP_APP_PEER_TIMEOUT}
274     Store_File_To_Workspace    bgp_app_peer.log    bgp_app_peer_delete_all_tc3.log
275
276 TC3_Check_Example-IPv4-Topology_Is_Empty
277     [Documentation]    See new routes are deleted.
278     [Tags]    critical
279     Wait_For_Topology_To_Change_To    ${empty_json}    031_Empty.json
280
281 TC3_BGP_Peer_Check_Incomming_Updates_For_3_Withdrawn_Prefixes
282     [Documentation]    Check incomming updates for new routes
283     [Tags]    critical
284     Switch_To_BGP_Peer_Console
285     BuiltIn.Wait_Until_Keyword_Succeeds    60s    1s    Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received:    3
286     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received: 8.0.1.0/28    1
287     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received: 8.0.1.16/28    1
288     Check_File_For_Word_Count    bgp_peer.log    withdrawn_prefix_received: 8.0.1.32/28    1
289     Check_File_For_Word_Count    bgp_peer.log    nlri_prefix_received:    3
290
291 TC3_Stop_BGP_Peer
292     [Documentation]    Stop BGP peer tool
293     [Tags]    critical
294     Switch_To_BGP_Peer_Console
295     Stop_Console_Tool
296     Store_File_To_Workspace    bgp_peer.log    bgp_peer_tc3.log
297
298 Delete_Bgp_Peer_Configuration
299     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
300     [Tags]    critical
301     &{mapping}    BuiltIn.Create_Dictionary    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
302     TemplatedRequests.Delete_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    mapping=${mapping}    session=${CONFIG_SESSION}
303
304 Delete_Bgp_Application_Peer_Configuration
305     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
306     [Tags]    critical
307     &{mapping}    BuiltIn.Create_Dictionary    DEVICE_NAME=${DEVICE_NAME}    NAME=${BGP_PEER_APP_NAME}    IP=${TOOLS_SYSTEM_IP}    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
308     TemplatedRequests.Delete_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_application_peer    mapping=${mapping}    session=${CONFIG_SESSION}
309
310 *** Keywords ***
311 Setup_Everything
312     [Documentation]    Initialize SetupUtils. SSH-login to mininet machine, create HTTP session,
313     ...    prepare directories for responses, put Python tool to mininet machine, setup imported resources.
314     SetupUtils.Setup_Utils_For_Setup_And_Teardown
315     SSHLibrary.Set_Default_Configuration    prompt=${TOOLS_SYSTEM_PROMPT}
316     Open_BGP_Peer_Console
317     SSHKeywords.Require_Python
318     SSHKeywords.Assure_Library_Ipaddr    target_dir=.
319     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/fastbgp/play.py
320     Open_BGP_Aplicationp_Peer_Console
321     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/fastbgp/bgp_app_peer.py
322     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/fastbgp/ipv4-routes-template.xml*
323     OperatingSystem.Remove_Directory    ${EXPECTED_RESPONSES_FOLDER}    recursive=True
324     OperatingSystem.Remove_Directory    ${ACTUAL_RESPONSES_FOLDER}    recursive=True
325     # The previous suite may have been using the same directories.
326     OperatingSystem.Create_Directory    ${EXPECTED_RESPONSES_FOLDER}
327     OperatingSystem.Create_Directory    ${ACTUAL_RESPONSES_FOLDER}
328     RequestsLibrary.Create_Session    operational    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}${OPERATIONAL_TOPO_API}    auth=${AUTH}
329     RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
330     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${CONTROLLER_LOG_LEVEL}
331     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${CONTROLLER_BGP_LOG_LEVEL} org.opendaylight.bgpcep
332     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${CONTROLLER_BGP_LOG_LEVEL} org.opendaylight.protocol
333     ${scritp_uri_opt}=    CompareStream.Set_Variable_If_At_Most_Boron    ${Empty}    --uri config/bgp-rib:application-rib/${TOOLS_SYSTEM_IP}/tables/bgp-types:ipv4-address-family/bgp-types:unicast-subsequent-address-family/
334     BuiltIn.Set_Suite_Variable    ${scritp_uri_opt}
335
336 Teardown_Everything
337     [Documentation]    Create and Log the diff between expected and actual responses, make sure Python tool was killed.
338     ...    Tear down imported Resources.
339     ${diff}=    OperatingSystem.Run    diff -dur ${EXPECTED_RESPONSES_FOLDER} ${ACTUAL_RESPONSES_FOLDER}
340     BuiltIn.Log    ${diff}
341     KillPythonTool.Search_And_Kill_Remote_Python    'play\.py'
342     KillPythonTool.Search_And_Kill_Remote_Python    'bgp_app_peer\.py'
343     RequestsLibrary.Delete_All_Sessions
344     SSHLibrary.Close_All_Connections
345
346 Open_BGP_Peer_Console
347     [Documentation]    Create a session for BGP peer.
348     SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}    alias=bgp_peer_console
349     Utils.Flexible_Mininet_Login
350
351 Open_BGP_Aplicationp_Peer_Console
352     [Documentation]    Create a session for BGP peer.
353     SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}    alias=bgp_app_peer_console
354     Utils.Flexible_Mininet_Login
355
356 Switch_To_BGP_Peer_Console
357     SSHLibrary.Switch Connection    bgp_peer_console
358
359 Switch_To_BGP_Application_Peer_Console
360     SSHLibrary.Switch Connection    bgp_app_peer_console
361
362 Wait_For_Topology_To_Change_To
363     [Arguments]    ${json_topology}    ${filename}    ${timeout}=10s    ${refresh}=1s
364     [Documentation]    Normalize the expected json topology and save it to ${EXPECTED_RESPONSES_FOLDER}.
365     ...    Wait until Compare_Topology matches. ${ACTUAL_RESPONSES_FOLDER} will hold its last result.
366     ${topology_normalized}=    Normalize_And_Save_Expected_Json    ${json_topology}    ${filename}    ${EXPECTED_RESPONSES_FOLDER}
367     BuiltIn.Wait_Until_Keyword_Succeeds    ${timeout}    ${refresh}    Compare_Topology    ${topology_normalized}    ${filename}
368
369 Verify_That_Topology_Does_Not_Change_From
370     [Arguments]    ${json_topology}    ${filename}    ${timeout}=10s    ${refresh}=1s
371     [Documentation]    Normalize the expected json topology and save it to ${EXPECTED_RESPONSES_FOLDER}.
372     ...    Verify that Compare_Topology keeps passing. ${ACTUAL_RESPONSES_FOLDER} will hold its last result.
373     ${topology_normalized}=    Normalize_And_Save_Expected_Json    ${json_topology}    ${filename}    ${EXPECTED_RESPONSES_FOLDER}
374     WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout    ${timeout}    ${refresh}    Compare_Topology    ${topology_normalized}    ${filename}
375
376 Compare_Topology
377     [Arguments]    ${expected_normalized}    ${filename}
378     [Documentation]    Get current example-ipv4-topology as json, normalize it, save to ${ACTUAL_RESPONSES_FOLDER}.
379     ...    Check that status code is 200, check that normalized jsons match exactly.
380     ${response}=    RequestsLibrary.Get Request    operational    topology/example-ipv4-topology
381     BuiltIn.Log    ${response.status_code}
382     BuiltIn.Log    ${response.text}
383     ${actual_normalized}=    Normalize_And_Save_Expected_Json    ${response.text}    ${filename}    ${ACTUAL_RESPONSES_FOLDER}
384     BuiltIn.Should_Be_Equal_As_Strings    ${response.status_code}    200
385     BuiltIn.Should_Be_Equal    ${expected_normalized}    ${actual_normalized}
386
387 Normalize_And_Save_Expected_Json
388     [Arguments]    ${json_text}    ${filename}    ${directory}
389     [Documentation]    Normalize given json using norm_json library. Log and save the result to given filename under given directory.
390     ${json_normalized}=    norm_json.normalize_json_text    ${json_text}
391     BuiltIn.Log    ${json_normalized}
392     OperatingSystem.Create_File    ${directory}${/}${filename}    ${json_normalized}
393     # TODO: Should we prepend .json to the filename? When we detect it is not already prepended?
394     [Return]    ${json_normalized}