06647b29a8609809f63e1e7e704666200e1c9d77
[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 Suite Setup       Setup_Everything
30 Suite Teardown    Teardown_Everything
31 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Fast_Failing
32 Test Teardown     SetupUtils.Teardown_Test_Show_Bugs_And_Start_Fast_Failing_If_Test_Failed
33 Library           SSHLibrary    timeout=10s
34 Library           RequestsLibrary
35 Resource          ../../../libraries/BGPSpeaker.robot
36 Resource          ../../../libraries/FailFast.robot
37 Resource          ../../../libraries/KarafKeywords.robot
38 Resource          ../../../libraries/KillPythonTool.robot
39 Resource          ../../../libraries/PrefixCounting.robot
40 Resource          ../../../libraries/SetupUtils.robot
41 Resource          ../../../libraries/SSHKeywords.robot
42 Resource          ../../../libraries/TemplatedRequests.robot
43 Resource          ../../../libraries/Utils.robot
44 Resource          ../../../variables/Variables.robot
45
46 *** Variables ***
47 ${BGP_TOOL_LOG_LEVEL}    info
48 ${BGP_VARIABLES_FOLDER}    ${CURDIR}/../../../variables/bgpuser/
49 ${CHECK_PERIOD}    60
50 ${CHECK_PERIOD_PREFIX_COUNT}    ${CHECK_PERIOD}
51 ${CHECK_PERIOD_PREFIX_COUNT_SINGLE}    ${CHECK_PERIOD_PREFIX_COUNT}
52 ${COUNT}          600000
53 ${COUNT_PREFIX_COUNT}    ${COUNT}
54 ${COUNT_PREFIX_COUNT_SINGLE}    ${COUNT_PREFIX_COUNT}
55 ${HOLDTIME}       180
56 ${HOLDTIME_PREFIX_COUNT}    ${HOLDTIME}
57 ${HOLDTIME_PREFIX_COUNT_SINGLE}    ${HOLDTIME_PREFIX_COUNT}
58 ${INSERT}         1
59 ${KARAF_LOG_LEVEL}    INFO
60 ${KARAF_BGPCEP_LOG_LEVEL}    ${KARAF_LOG_LEVEL}
61 ${KARAF_PROTOCOL_LOG_LEVEL}    ${KARAF_BGPCEP_LOG_LEVEL}
62 ${PREFILL}        0
63 ${REPETITIONS}    1
64 ${REPETITIONS_PREFIX_COUNT}    ${REPETITIONS}
65 ${REPETITIONS_PREFIX_COUNT_SINGLE}    ${REPETITIONS_PREFIX_COUNT}
66 ${RESULTS_FILE_NAME}    bgp.csv
67 ${TEST_DURATION_MULTIPLIER}    1
68 ${TEST_DURATION_MULTIPLIER_PREFIX_COUNT}    ${TEST_DURATION_MULTIPLIER}
69 ${TEST_DURATION_MULTIPLIER_PREFIX_COUNT_SINGLE}    ${TEST_DURATION_MULTIPLIER_PREFIX_COUNT}
70 ${UPDATE}         single
71 ${WITHDRAW}       0
72 ${RIB_INSTANCE}    example-bgp-rib
73 ${PROTOCOL_OPENCONFIG}    ${RIB_INSTANCE}
74 ${DEVICE_NAME}    controller-config
75 ${BGP_PEER_NAME}    example-bgp-peer
76 # TODO: Option names can be better.
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    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME_PREFIX_COUNT_SINGLE}    PEER_PORT=${BGP_TOOL_PORT}
88     ...    INITIATE=false    BGP_RIB=${RIB_INSTANCE}    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}    RIB_INSTANCE_NAME=${RIB_INSTANCE}
89     TemplatedRequests.Put_As_Xml_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    mapping=${mapping}
90
91 Change_Karaf_Logging_Levels
92     [Documentation]    We may want to set more verbose logging here after configuration is done.
93     KarafKeywords.Set_Bgpcep_Log_Levels    bgpcep_level=${KARAF_BGPCEP_LOG_LEVEL}    protocol_level=${KARAF_PROTOCOL_LOG_LEVEL}
94
95 Start_Talking_BGP_Speaker
96     [Documentation]    Start Python speaker to connect to ODL.
97     # Myport value is needed for checking whether connection at precise port was established.
98     BGPSpeaker.Start_BGP_Speaker    --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}
99
100 Wait_For_Stable_Talking_Ipv4_Topology
101     [Documentation]    Wait until example-ipv4-topology becomes stable. This is done by checking stability of prefix count.
102     PrefixCounting.Wait_For_Ipv4_Topology_Prefixes_To_Become_Stable    timeout=${bgp_filling_timeout}    period=${CHECK_PERIOD_PREFIX_COUNT_SINGLE}    repetitions=${REPETITIONS_PREFIX_COUNT_SINGLE}    excluded_count=0
103
104 Check_Talking_Ipv4_Topology_Count
105     [Documentation]    Count the routes in example-ipv4-topology and fail if the count is not correct.
106     [Tags]    critical
107     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
108     PrefixCounting.Check_Ipv4_Topology_Count    ${COUNT_PREFIX_COUNT_SINGLE}
109
110 Kill_Talking_BGP_Speaker
111     [Documentation]    Abort the Python speaker. Also, attempt to stop failing fast.
112     [Tags]    critical
113     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
114     BGPSpeaker.Kill_BGP_Speaker
115     FailFast.Do_Not_Fail_Fast_From_Now_On
116     # NOTE: It is still possible to remain failing fast, if both previous and this test have failed.
117     [Teardown]    SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
118
119 Store_Results_For_Talking_BGP_Speaker
120     [Documentation]    Store results for plotting
121     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
122     Store_File_To_Workspace    totals-${RESULTS_FILE_NAME}    totals-${RESULTS_FILE_NAME}
123     Store_File_To_Workspace    performance-${RESULTS_FILE_NAME}    performance-${RESULTS_FILE_NAME}
124     Store_File_To_Workspace    totals-${RESULTS_FILE_NAME}    prefixcount-talking-totals-${RESULTS_FILE_NAME}
125     Store_File_To_Workspace    performance-${RESULTS_FILE_NAME}    prefixcount-talking-performance-${RESULTS_FILE_NAME}
126
127 Wait_For_Stable_Ipv4_Topology_After_Talking
128     [Documentation]    Wait until example-ipv4-topology becomes stable again.
129     [Tags]    critical
130     # TODO: Is is possible to have failed at Check_Talking_Ipv4_Topology_Count and still have initial period of constant count?
131     # FIXME: If yes, do count here to get the initial value and use it (if nonzero).
132     # TODO: If yes, decide whether access to the FailFast state should have keyword or just variable name.
133     PrefixCounting.Wait_For_Ipv4_Topology_Prefixes_To_Become_Stable    timeout=${bgp_filling_timeout}    period=${CHECK_PERIOD_PREFIX_COUNT_SINGLE}    repetitions=${REPETITIONS_PREFIX_COUNT_SINGLE}    excluded_count=${COUNT_PREFIX_COUNT_SINGLE}
134
135 Check_For_Empty_Ipv4_Topology_After_Talking
136     [Documentation]    Example-ipv4-topology should be empty now.
137     [Tags]    critical
138     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
139     PrefixCounting.Check_Ipv4_Topology_Is_Empty
140
141 Start_Listening_BGP_Speaker
142     [Documentation]    Start Python speaker in listening mode.
143     BGPSpeaker.Start_BGP_Speaker    --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}
144
145 Reconfigure_ODL_To_Initiate_Connection
146     [Documentation]    Replace BGP peer config module, now with initiate-connection set to true.
147     &{mapping}    Create Dictionary    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME_PREFIX_COUNT_SINGLE}    PEER_PORT=${BGP_TOOL_PORT}
148     ...    INITIATE=true    BGP_RIB=${RIB_INSTANCE}    PASSIVE_MODE=false    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}    RIB_INSTANCE_NAME=${RIB_INSTANCE}
149     TemplatedRequests.Put_As_Xml_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    mapping=${mapping}
150
151 Wait_For_Stable_Listening_Ipv4_Topology
152     [Documentation]    Wait until example-ipv4-topology becomes stable.
153     PrefixCounting.Wait_For_Ipv4_Topology_Prefixes_To_Become_Stable    timeout=${bgp_filling_timeout}    period=${CHECK_PERIOD_PREFIX_COUNT_SINGLE}    repetitions=${REPETITIONS_PREFIX_COUNT_SINGLE}    excluded_count=0
154
155 Check_Listening_Ipv4_Topology_Count
156     [Documentation]    Count the routes in example-ipv4-topology and fail if the count is not correct.
157     [Tags]    critical
158     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
159     PrefixCounting.Check_Ipv4_Topology_Count    ${COUNT_PREFIX_COUNT_SINGLE}
160
161 Kill_Listening_BGP_Speaker
162     [Documentation]    Abort the Python speaker. Also, attempt to stop failing fast.
163     [Tags]    critical
164     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
165     BGPSpeaker.Kill_BGP_Speaker
166     FailFast.Do_Not_Fail_Fast_From_Now_On
167     # NOTE: It is still possible to remain failing fast, if both previous and this test have failed.
168     [Teardown]    SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
169
170 Store_Results_For_Listening_BGP_Speaker
171     [Documentation]    Store results for plotting
172     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
173     Store_File_To_Workspace    totals-${RESULTS_FILE_NAME}    totals-${RESULTS_FILE_NAME}
174     Store_File_To_Workspace    performance-${RESULTS_FILE_NAME}    performance-${RESULTS_FILE_NAME}
175     Store_File_To_Workspace    totals-${RESULTS_FILE_NAME}    prefixcount-listening-totals-${RESULTS_FILE_NAME}
176     Store_File_To_Workspace    performance-${RESULTS_FILE_NAME}    prefixcount-listening-performance-${RESULTS_FILE_NAME}
177
178 Wait_For_Stable_Ipv4_Topology_After_Listening
179     [Documentation]    Wait until example-ipv4-topology becomes stable again.
180     [Tags]    critical
181     PrefixCounting.Wait_For_Ipv4_Topology_Prefixes_To_Become_Stable    timeout=${bgp_filling_timeout}    period=${CHECK_PERIOD_PREFIX_COUNT_SINGLE}    repetitions=${REPETITIONS_PREFIX_COUNT_SINGLE}    excluded_count=${COUNT_PREFIX_COUNT_SINGLE}
182
183 Check_For_Empty_Ipv4_Topology_After_Listening
184     [Documentation]    Example-ipv4-topology should be empty now.
185     [Tags]    critical
186     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
187     PrefixCounting.Check_Ipv4_Topology_Is_Empty
188
189 Restore_Karaf_Logging_Levels
190     [Documentation]    Set logging on bgpcep and protocol to the global value.
191     KarafKeywords.Set_Bgpcep_Log_Levels    bgpcep_level=${KARAF_LOG_LEVEL}    protocol_level=${KARAF_LOG_LEVEL}
192
193 Delete_Bgp_Peer_Configuration
194     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
195     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
196     &{mapping}    BuiltIn.Create_Dictionary    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
197     TemplatedRequests.Delete_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    mapping=${mapping}
198
199 *** Keywords ***
200 Setup_Everything
201     [Documentation]    Setup imported resources, SSH-login to tools system,
202     ...    create HTTP session, put Python tool to tools system.
203     SetupUtils.Setup_Utils_For_Setup_And_Teardown
204     TemplatedRequests.Create_Default_Session
205     PrefixCounting.PC_Setup
206     RequestsLibrary.Create_Session    operational    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    timeout=125    max_retries=0
207     # TODO: Do not include slash in ${OPERATIONAL_TOPO_API}, having it typed here is more readable.
208     # TODO: Alternatively, create variable in Variables which starts with http.
209     # Both TODOs would probably need to update every suite relying on current Variables.
210     SSHLibrary.Set_Default_Configuration    prompt=${TOOLS_SYSTEM_PROMPT}
211     SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}
212     SSHKeywords.Flexible_Mininet_Login
213     SSHKeywords.Require_Python
214     SSHKeywords.Assure_Library_Ipaddr    target_dir=.
215     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/fastbgp/play.py
216     # Calculate the timeout value based on how many routes are going to be pushed
217     # TODO: Replace 20 with some formula from period and repetitions.
218     ${timeout} =    BuiltIn.Evaluate    ${TEST_DURATION_MULTIPLIER_PREFIX_COUNT_SINGLE} * (${COUNT_PREFIX_COUNT_SINGLE} * 9.0 / 10000 + 20)
219     Builtin.Set_Suite_Variable    ${bgp_filling_timeout}    ${timeout}
220     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${KARAF_LOG_LEVEL}
221
222 Teardown_Everything
223     [Documentation]    Make sure Python tool was killed and tear down imported Resources.
224     # Environment issue may have dropped the SSH connection, but we do not want Teardown to fail.
225     BuiltIn.Run_Keyword_And_Ignore_Error    KillPythonTool.Search_And_Kill_Remote_Python    'play\.py'
226     BuiltIn.Run_Keyword_And_Ignore_Error    Utils.Get_Sysstat_Statistics
227     RequestsLibrary.Delete_All_Sessions
228     SSHLibrary.Close_All_Connections
229
230 Store_File_To_Workspace
231     [Arguments]    ${src_file_name}    ${dst_file_name}
232     [Documentation]    Store the provided file from the SSH client to workspace.
233     ${files}=    SSHLibrary.List Files In Directory    .
234     ${output_log}=    SSHLibrary.Execute_Command    cat ${src_file_name}
235     BuiltIn.Log    ${output_log}
236     Create File    ${dst_file_name}    ${output_log}