Update Robot Framework format - step 3
[integration/test.git] / csit / suites / bgpcep / bgpingest / singlepeer_prefixcount.robot
1 *** Settings ***
2 Documentation       BGP performance of ingesting from 1 iBGP peer, data change counter is NOT used.
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 ...
11 ...                 This suite uses play.py as single iBGP peer.
12 ...                 The suite only looks at example-ipv4-topology, so RIB is not examined.
13 ...
14 ...                 The suite consists of two halves, differing on which side initiates BGP connection.
15 ...                 State of "work is being done" is detected by increasing value of prefixes in topology.
16 ...                 The time for Wait_For_Stable_* cases to finish is the main performance metric.
17 ...                 After waiting for stability is done, full check on number of prefixes present is performed.
18 ...
19 ...                 Brief description how to configure BGP peer can be found here:
20 ...                 https://wiki.opendaylight.org/view/BGP_LS_PCEP:User_Guide#BGP_Peer
21 ...                 http://docs.opendaylight.org/en/stable-boron/user-guide/bgp-user-guide.html#bgp-peering
22 ...
23 ...                 TODO: Currently, if a bug causes prefix count to remain at zero,
24 ...                 affected test cases will wait for max time. Reconsider.
25 ...                 If zero is allowed as stable, higher period or repetitions would be required.
26 ...
27 ...                 The prefix counting is quite heavyweight and may induce large variation in time.
28 ...                 Try the other version of the suite (singlepeer_changecount.robot) to get better precision.
29
30 Library             SSHLibrary    timeout=10s
31 Library             RequestsLibrary
32 Resource            ../../../libraries/BGPSpeaker.robot
33 Resource            ../../../libraries/FailFast.robot
34 Resource            ../../../libraries/KillPythonTool.robot
35 Resource            ../../../libraries/PrefixCounting.robot
36 Resource            ../../../libraries/SetupUtils.robot
37 Resource            ../../../libraries/SSHKeywords.robot
38 Resource            ../../../libraries/TemplatedRequests.robot
39 Resource            ../../../libraries/Utils.robot
40 Resource            ../../../variables/Variables.robot
41
42 Suite Setup         Setup_Everything
43 Suite Teardown      Teardown_Everything
44 Test Setup          SetupUtils.Setup_Test_With_Logging_And_Fast_Failing
45 Test Teardown       SetupUtils.Teardown_Test_Show_Bugs_And_Start_Fast_Failing_If_Test_Failed
46
47
48 *** Variables ***
49 ${BGP_TOOL_LOG_LEVEL}                               info
50 ${BGP_VARIABLES_FOLDER}                             ${CURDIR}/../../../variables/bgpuser/
51 ${CHECK_PERIOD}                                     60
52 ${CHECK_PERIOD_PREFIX_COUNT}                        ${CHECK_PERIOD}
53 ${CHECK_PERIOD_PREFIX_COUNT_SINGLE}                 ${CHECK_PERIOD_PREFIX_COUNT}
54 ${COUNT}                                            600000
55 ${COUNT_PREFIX_COUNT}                               ${COUNT}
56 ${COUNT_PREFIX_COUNT_SINGLE}                        ${COUNT_PREFIX_COUNT}
57 ${HOLDTIME}                                         180
58 ${HOLDTIME_PREFIX_COUNT}                            ${HOLDTIME}
59 ${HOLDTIME_PREFIX_COUNT_SINGLE}                     ${HOLDTIME_PREFIX_COUNT}
60 ${INSERT}                                           1
61 ${PREFILL}                                          0
62 ${REPETITIONS}                                      1
63 ${REPETITIONS_PREFIX_COUNT}                         ${REPETITIONS}
64 ${REPETITIONS_PREFIX_COUNT_SINGLE}                  ${REPETITIONS_PREFIX_COUNT}
65 ${RESULTS_FILE_NAME}                                bgp.csv
66 ${TEST_DURATION_MULTIPLIER}                         1
67 ${TEST_DURATION_MULTIPLIER_PREFIX_COUNT}            ${TEST_DURATION_MULTIPLIER}
68 ${TEST_DURATION_MULTIPLIER_PREFIX_COUNT_SINGLE}     ${TEST_DURATION_MULTIPLIER_PREFIX_COUNT}
69 ${UPDATE}                                           single
70 ${WITHDRAW}                                         0
71 ${RIB_INSTANCE}                                     example-bgp-rib
72 ${PROTOCOL_OPENCONFIG}                              ${RIB_INSTANCE}
73 ${DEVICE_NAME}                                      controller-config
74 ${BGP_PEER_NAME}                                    example-bgp-peer
75 # TODO: Option names can be better.
76
77
78 *** Test Cases ***
79 Check_For_Empty_Ipv4_Topology_Before_Talking
80     [Documentation]    Wait for example-ipv4-topology to come up and empty. Give large timeout for case when BGP boots slower than restconf.
81     [Tags]    critical
82     # TODO: Choose which tags to assign and make sure they are assigned correctly.
83     BuiltIn.Wait_Until_Keyword_Succeeds    120s    1s    PrefixCounting.Check_Ipv4_Topology_Is_Empty
84
85 Reconfigure_ODL_To_Accept_Connection
86     [Documentation]    Configure BGP peer module with initiate-connection set to false.
87     &{mapping}    Create Dictionary
88     ...    DEVICE_NAME=${DEVICE_NAME}
89     ...    BGP_NAME=${BGP_PEER_NAME}
90     ...    IP=${TOOLS_SYSTEM_IP}
91     ...    HOLDTIME=${HOLDTIME_PREFIX_COUNT_SINGLE}
92     ...    PEER_PORT=${BGP_TOOL_PORT}
93     ...    INITIATE=false
94     ...    BGP_RIB=${RIB_INSTANCE}
95     ...    PASSIVE_MODE=true
96     ...    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
97     ...    RIB_INSTANCE_NAME=${RIB_INSTANCE}
98     TemplatedRequests.Put_As_Xml_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    mapping=${mapping}
99
100 Start_Talking_BGP_Speaker
101     [Documentation]    Start Python speaker to connect to ODL.
102     # Myport value is needed for checking whether connection at precise port was established.
103     BGPSpeaker.Start_BGP_Speaker
104     ...    --amount ${COUNT_PREFIX_COUNT_SINGLE} --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT} --insert=${INSERT} --withdraw=${WITHDRAW} --prefill ${PREFILL} --update ${UPDATE} --${BGP_TOOL_LOG_LEVEL} --results ${RESULTS_FILE_NAME}
105
106 Wait_For_Stable_Talking_Ipv4_Topology
107     [Documentation]    Wait until example-ipv4-topology becomes stable. This is done by checking stability of prefix count.
108     PrefixCounting.Wait_For_Ipv4_Topology_Prefixes_To_Become_Stable
109     ...    timeout=${bgp_filling_timeout}
110     ...    period=${CHECK_PERIOD_PREFIX_COUNT_SINGLE}
111     ...    repetitions=${REPETITIONS_PREFIX_COUNT_SINGLE}
112     ...    excluded_count=0
113
114 Check_Talking_Ipv4_Topology_Count
115     [Documentation]    Count the routes in example-ipv4-topology and fail if the count is not correct.
116     [Tags]    critical
117     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
118     PrefixCounting.Check_Ipv4_Topology_Count    ${COUNT_PREFIX_COUNT_SINGLE}
119
120 Kill_Talking_BGP_Speaker
121     [Documentation]    Abort the Python speaker. Also, attempt to stop failing fast.
122     [Tags]    critical
123     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
124     BGPSpeaker.Kill_BGP_Speaker
125     FailFast.Do_Not_Fail_Fast_From_Now_On
126     # NOTE: It is still possible to remain failing fast, if both previous and this test have failed.
127     [Teardown]    SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
128
129 Store_Results_For_Talking_BGP_Speaker
130     [Documentation]    Store results for plotting
131     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
132     Store_File_To_Workspace    totals-${RESULTS_FILE_NAME}    totals-${RESULTS_FILE_NAME}
133     Store_File_To_Workspace    performance-${RESULTS_FILE_NAME}    performance-${RESULTS_FILE_NAME}
134     Store_File_To_Workspace    totals-${RESULTS_FILE_NAME}    prefixcount-talking-totals-${RESULTS_FILE_NAME}
135     Store_File_To_Workspace    performance-${RESULTS_FILE_NAME}    prefixcount-talking-performance-${RESULTS_FILE_NAME}
136
137 Wait_For_Stable_Ipv4_Topology_After_Talking
138     [Documentation]    Wait until example-ipv4-topology becomes stable again.
139     [Tags]    critical
140     # TODO: Is is possible to have failed at Check_Talking_Ipv4_Topology_Count and still have initial period of constant count?
141     # FIXME: If yes, do count here to get the initial value and use it (if nonzero).
142     # TODO: If yes, decide whether access to the FailFast state should have keyword or just variable name.
143     PrefixCounting.Wait_For_Ipv4_Topology_Prefixes_To_Become_Stable
144     ...    timeout=${bgp_filling_timeout}
145     ...    period=${CHECK_PERIOD_PREFIX_COUNT_SINGLE}
146     ...    repetitions=${REPETITIONS_PREFIX_COUNT_SINGLE}
147     ...    excluded_count=${COUNT_PREFIX_COUNT_SINGLE}
148
149 Check_For_Empty_Ipv4_Topology_After_Talking
150     [Documentation]    Example-ipv4-topology should be empty now.
151     [Tags]    critical
152     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
153     PrefixCounting.Check_Ipv4_Topology_Is_Empty
154
155 Start_Listening_BGP_Speaker
156     [Documentation]    Start Python speaker in listening mode.
157     BGPSpeaker.Start_BGP_Speaker
158     ...    --amount ${COUNT_PREFIX_COUNT_SINGLE} --listen --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --insert=${INSERT} --withdraw=${WITHDRAW} --prefill ${PREFILL} --update ${UPDATE} --${BGP_TOOL_LOG_LEVEL} --results ${RESULTS_FILE_NAME}
159
160 Reconfigure_ODL_To_Initiate_Connection
161     [Documentation]    Replace BGP peer config module, now with initiate-connection set to true.
162     &{mapping}    Create Dictionary
163     ...    DEVICE_NAME=${DEVICE_NAME}
164     ...    BGP_NAME=${BGP_PEER_NAME}
165     ...    IP=${TOOLS_SYSTEM_IP}
166     ...    HOLDTIME=${HOLDTIME_PREFIX_COUNT_SINGLE}
167     ...    PEER_PORT=${BGP_TOOL_PORT}
168     ...    INITIATE=true
169     ...    BGP_RIB=${RIB_INSTANCE}
170     ...    PASSIVE_MODE=false
171     ...    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
172     ...    RIB_INSTANCE_NAME=${RIB_INSTANCE}
173     TemplatedRequests.Put_As_Xml_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    mapping=${mapping}
174
175 Wait_For_Stable_Listening_Ipv4_Topology
176     [Documentation]    Wait until example-ipv4-topology becomes stable.
177     PrefixCounting.Wait_For_Ipv4_Topology_Prefixes_To_Become_Stable
178     ...    timeout=${bgp_filling_timeout}
179     ...    period=${CHECK_PERIOD_PREFIX_COUNT_SINGLE}
180     ...    repetitions=${REPETITIONS_PREFIX_COUNT_SINGLE}
181     ...    excluded_count=0
182
183 Check_Listening_Ipv4_Topology_Count
184     [Documentation]    Count the routes in example-ipv4-topology and fail if the count is not correct.
185     [Tags]    critical
186     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
187     PrefixCounting.Check_Ipv4_Topology_Count    ${COUNT_PREFIX_COUNT_SINGLE}
188
189 Kill_Listening_BGP_Speaker
190     [Documentation]    Abort the Python speaker. Also, attempt to stop failing fast.
191     [Tags]    critical
192     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
193     BGPSpeaker.Kill_BGP_Speaker
194     FailFast.Do_Not_Fail_Fast_From_Now_On
195     # NOTE: It is still possible to remain failing fast, if both previous and this test have failed.
196     [Teardown]    SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
197
198 Store_Results_For_Listening_BGP_Speaker
199     [Documentation]    Store results for plotting
200     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
201     Store_File_To_Workspace    totals-${RESULTS_FILE_NAME}    totals-${RESULTS_FILE_NAME}
202     Store_File_To_Workspace    performance-${RESULTS_FILE_NAME}    performance-${RESULTS_FILE_NAME}
203     Store_File_To_Workspace    totals-${RESULTS_FILE_NAME}    prefixcount-listening-totals-${RESULTS_FILE_NAME}
204     Store_File_To_Workspace
205     ...    performance-${RESULTS_FILE_NAME}
206     ...    prefixcount-listening-performance-${RESULTS_FILE_NAME}
207
208 Wait_For_Stable_Ipv4_Topology_After_Listening
209     [Documentation]    Wait until example-ipv4-topology becomes stable again.
210     [Tags]    critical
211     PrefixCounting.Wait_For_Ipv4_Topology_Prefixes_To_Become_Stable
212     ...    timeout=${bgp_filling_timeout}
213     ...    period=${CHECK_PERIOD_PREFIX_COUNT_SINGLE}
214     ...    repetitions=${REPETITIONS_PREFIX_COUNT_SINGLE}
215     ...    excluded_count=${COUNT_PREFIX_COUNT_SINGLE}
216
217 Check_For_Empty_Ipv4_Topology_After_Listening
218     [Documentation]    Example-ipv4-topology should be empty now.
219     [Tags]    critical
220     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
221     PrefixCounting.Check_Ipv4_Topology_Is_Empty
222
223 Delete_Bgp_Peer_Configuration
224     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
225     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
226     &{mapping}    BuiltIn.Create_Dictionary
227     ...    DEVICE_NAME=${DEVICE_NAME}
228     ...    BGP_NAME=${BGP_PEER_NAME}
229     ...    IP=${TOOLS_SYSTEM_IP}
230     ...    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
231     TemplatedRequests.Delete_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    mapping=${mapping}
232
233
234 *** Keywords ***
235 Setup_Everything
236     [Documentation]    Setup imported resources, SSH-login to tools system,
237     ...    create HTTP session, put Python tool to tools system.
238     SetupUtils.Setup_Utils_For_Setup_And_Teardown
239     TemplatedRequests.Create_Default_Session
240     PrefixCounting.PC_Setup
241     RequestsLibrary.Create_Session
242     ...    operational
243     ...    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
244     ...    auth=${AUTH}
245     ...    timeout=125
246     ...    max_retries=0
247     # TODO: Do not include slash in ${OPERATIONAL_TOPO_API}, having it typed here is more readable.
248     # TODO: Alternatively, create variable in Variables which starts with http.
249     # Both TODOs would probably need to update every suite relying on current Variables.
250     SSHLibrary.Set_Default_Configuration    prompt=${TOOLS_SYSTEM_PROMPT}
251     SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}
252     SSHKeywords.Flexible_Mininet_Login
253     SSHKeywords.Require_Python
254     SSHKeywords.Assure_Library_Ipaddr    target_dir=.
255     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/fastbgp/play.py
256     # Calculate the timeout value based on how many routes are going to be pushed
257     # TODO: Replace 20 with some formula from period and repetitions.
258     ${timeout}    BuiltIn.Evaluate
259     ...    ${TEST_DURATION_MULTIPLIER_PREFIX_COUNT_SINGLE} * (${COUNT_PREFIX_COUNT_SINGLE} * 9.0 / 10000 + 20)
260     Builtin.Set_Suite_Variable    ${bgp_filling_timeout}    ${timeout}
261
262 Teardown_Everything
263     [Documentation]    Make sure Python tool was killed and tear down imported Resources.
264     # Environment issue may have dropped the SSH connection, but we do not want Teardown to fail.
265     BuiltIn.Run_Keyword_And_Ignore_Error    KillPythonTool.Search_And_Kill_Remote_Python    'play\.py'
266     BuiltIn.Run_Keyword_And_Ignore_Error    Utils.Get_Sysstat_Statistics
267     RequestsLibrary.Delete_All_Sessions
268     SSHLibrary.Close_All_Connections
269
270 Store_File_To_Workspace
271     [Documentation]    Store the provided file from the SSH client to workspace.
272     [Arguments]    ${src_file_name}    ${dst_file_name}
273     ${files}    SSHLibrary.List Files In Directory    .
274     ${output_log}    SSHLibrary.Execute_Command    cat ${src_file_name}
275     BuiltIn.Log    ${output_log}
276     Create File    ${dst_file_name}    ${output_log}