Update Robot Framework format - step 3
[integration/test.git] / csit / suites / bgpcep / bgpingest / manypeers_prefixcount.robot
1 *** Settings ***
2 Documentation       BGP performance of ingesting from many iBGP peers, data change counter 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 processes as iBGP peers.
12 ...                 This is analogue of single peer performance suite, which uses many peers.
13 ...                 Each peer is of ibgp type, and they contribute to the same example-bgp-rib,
14 ...                 and thus to the same single example-ipv4-topology.
15 ...                 The suite only looks at example-ipv4-topology, so RIB is not examined.
16 ...
17 ...                 The suite consists of two halves, differing on which side initiates BGP connection.
18 ...                 State of "work is being done" is detected by increasing value of prefixes in topology.
19 ...                 The time for Wait_For_Stable_* cases to finish is the main performance metric.
20 ...                 After waiting for stability is done, full check on number of prefixes present is performed.
21 ...
22 ...                 TODO: Currently, if a bug causes prefix count to remain at zero,
23 ...                 affected test cases will wait for max time. Reconsider.
24 ...                 If zero is allowed as stable, higher period or repetitions would be required.
25 ...
26 ...                 The prefix counting is quite heavyweight and may induce large variation in time.
27 ...                 Try the other version of the suite (manypeers_changecount.robot) to get better precision.
28 ...
29 ...                 ODL distinguishes peers by their IP addresses.
30 ...                 Currently, this suite requires python utils to be started on ODL System,
31 ...                 to guarantee IP address block is available for them to bind to.
32 ...                 TODO: Figure out how to use Docker and docker IP pool available in RelEng.
33 ...
34 ...                 Currently, 127.0.0.1 is hardcoded as the first peer address to use.
35 ...                 TODO: Figure out how to make it configurable.
36 ...                 As peer IP adresses are set incrementally, we need ipaddr to be used in Robot somehow.
37 ...
38 ...                 Brief description how to configure BGP peer can be found here:
39 ...                 https://wiki.opendaylight.org/view/BGP_LS_PCEP:User_Guide#BGP_Peer
40 ...                 http://docs.opendaylight.org/en/stable-boron/user-guide/bgp-user-guide.html#bgp-peering
41 ...
42 ...                 TODO: Is there a need for version of this suite where ODL connects to pers?
43 ...                 Note that configuring ODL is slow, which may affect measured performance singificantly.
44 ...                 Advanced TODO: Give manager ability to start pushing on trigger long after connections are established.
45
46 Library             DateTime
47 Library             RequestsLibrary
48 Library             SSHLibrary    timeout=10s
49 Resource            ../../../libraries/BGPSpeaker.robot
50 Resource            ../../../libraries/FailFast.robot
51 Resource            ../../../libraries/KarafKeywords.robot
52 Resource            ../../../libraries/KillPythonTool.robot
53 Resource            ../../../libraries/PrefixCounting.robot
54 Resource            ../../../libraries/SetupUtils.robot
55 Resource            ../../../libraries/SSHKeywords.robot
56 Resource            ../../../libraries/TemplatedRequests.robot
57 Resource            ../../../libraries/Utils.robot
58 Resource            ../../../variables/Variables.robot
59
60 Suite Setup         Setup_Everything
61 Suite Teardown      Teardown_Everything
62 Test Setup          SetupUtils.Setup_Test_With_Logging_And_Fast_Failing
63 Test Teardown       SetupUtils.Teardown_Test_Show_Bugs_And_Start_Fast_Failing_If_Test_Failed
64
65
66 *** Variables ***
67 ${BGP_TOOL_LOG_LEVEL}                               info
68 ${BGP_VARIABLES_FOLDER}                             ${CURDIR}/../../../variables/bgpuser/
69 # ${MULTIPLICITY*2} recommended for this suite, but keeping the common default.
70 ${CHECK_PERIOD}
71 ...                                                 60
72 ${CHECK_PERIOD_PREFIX_COUNT}                        ${CHECK_PERIOD}
73 ${CHECK_PERIOD_PREFIX_COUNT_MANY}                   ${CHECK_PERIOD_PREFIX_COUNT}
74 ${COUNT}                                            600000
75 ${COUNT_PREFIX_COUNT}                               ${COUNT}
76 ${COUNT_PREFIX_COUNT_MANY}                          ${COUNT_PREFIX_COUNT}
77 ${FIRST_PEER_IP}                                    127.0.0.1
78 ${HOLDTIME}                                         180
79 ${HOLDTIME_PREFIX_COUNT}                            ${HOLDTIME}
80 ${HOLDTIME_PREFIX_COUNT_MANY}                       ${HOLDTIME_PREFIX_COUNT}
81 ${KARAF_LOG_LEVEL}                                  INFO
82 ${KARAF_BGPCEP_LOG_LEVEL}                           ${KARAF_LOG_LEVEL}
83 ${KARAF_PROTOCOL_LOG_LEVEL}                         ${KARAF_BGPCEP_LOG_LEVEL}
84 ${MULTIPLICITY}                                     2    # Changed in releng-builder variables
85 ${MULTIPLICITY_PREFIX_COUNT}                        ${MULTIPLICITY}
86 ${MULTIPLICITY_PREFIX_COUNT_MANY}                   ${MULTIPLICITY_PREFIX_COUNT}
87 ${REPETITIONS}                                      1
88 ${REPETITIONS_PREFIX_COUNT}                         ${REPETITIONS}
89 ${REPETITIONS_PREFIX_COUNT_MANY}                    ${REPETITIONS_PREFIX_COUNT}
90 ${TEST_DURATION_MULTIPLIER}                         1
91 ${TEST_DURATION_MULTIPLIER_PREFIX_COUNT}            ${TEST_DURATION_MULTIPLIER}
92 ${TEST_DURATION_MULTIPLIER_PREFIX_COUNT_MANY}       ${TEST_DURATION_MULTIPLIER_PREFIX_COUNT}
93 ${RIB_INSTANCE}                                     example-bgp-rib
94 ${PROTOCOL_OPENCONFIG}                              ${RIB_INSTANCE}
95 ${DEVICE_NAME}                                      controller-config
96 # TODO: Option names can be better.
97
98
99 *** Test Cases ***
100 Check_For_Empty_Ipv4_Topology_Before_Talking
101     [Documentation]    Wait for example-ipv4-topology to come up and empty. Give large timeout for case when BGP boots slower than restconf.
102     [Tags]    critical
103     # TODO: Choose which tags to assign and make sure they are assigned correctly.
104     BuiltIn.Wait_Until_Keyword_Succeeds    120s    1s    PrefixCounting.Check_Ipv4_Topology_Is_Empty
105
106 Reconfigure_ODL_To_Accept_Connections
107     [Documentation]    Configure BGP peer modules with initiate-connection set to false.
108     FOR    ${index}    IN RANGE    1    ${MULTIPLICITY_PREFIX_COUNT_MANY}+1
109         ${peer_name} =    BuiltIn.Set_Variable    example-bgp-peer-${index}
110         ${peer_ip} =    BuiltIn.Evaluate    str(ipaddr.IPAddress('${FIRST_PEER_IP}') + ${index} - 1)    modules=ipaddr
111         &{mapping} =    Create Dictionary
112         ...    DEVICE_NAME=${DEVICE_NAME}
113         ...    BGP_NAME=${peer_name}
114         ...    IP=${peer_ip}
115         ...    HOLDTIME=${HOLDTIME_PREFIX_COUNT_MANY}
116         ...    PEER_PORT=${BGP_TOOL_PORT}
117         ...    INITIATE=false
118         ...    BGP_RIB=${RIB_INSTANCE}
119         ...    PASSIVE_MODE=true
120         ...    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
121         ...    RIB_INSTANCE_NAME=${RIB_INSTANCE}
122         TemplatedRequests.Put_As_Xml_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    mapping=${mapping}
123         # FIXME: Add testcase to change bgpcep and protocol log levels, when a Keyword that does it without messing with current connection is ready.
124     END
125
126 Change_Karaf_Logging_Levels
127     [Documentation]    We may want to set more verbose logging here after configuration is done.
128     KarafKeywords.Set_Bgpcep_Log_Levels
129     ...    bgpcep_level=${KARAF_BGPCEP_LOG_LEVEL}
130     ...    protocol_level=${KARAF_PROTOCOL_LOG_LEVEL}
131
132 Start_Talking_BGP_Manager
133     [Documentation]    Start Python manager to connect speakers to ODL.
134     # Myport value is needed for checking whether connection at precise port was established.
135     BGPSpeaker.Start_BGP_Manager
136     ...    --amount=${COUNT_PREFIX_COUNT_MANY} --multiplicity=${MULTIPLICITY_PREFIX_COUNT_MANY} --myip=${FIRST_PEER_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT}
137
138 Wait_For_Stable_Talking_Ipv4_Topology
139     [Documentation]    Wait until example-ipv4-topology becomes stable. This is done by checking stability of prefix count.
140     PrefixCounting.Wait_For_Ipv4_Topology_Prefixes_To_Become_Stable
141     ...    timeout=${bgp_filling_timeout}
142     ...    period=${CHECK_PERIOD_PREFIX_COUNT_MANY}
143     ...    repetitions=${REPETITIONS_PREFIX_COUNT_MANY}
144     ...    excluded_count=0
145
146 Check_Talking_Ipv4_Topology_Count
147     [Documentation]    Count the routes in example-ipv4-topology and fail if the count is not correct.
148     [Tags]    critical
149     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
150     PrefixCounting.Check_Ipv4_Topology_Count    ${COUNT_PREFIX_COUNT_MANY}
151
152 Kill_Talking_BGP_Speakers
153     [Documentation]    Abort the Python speakers. Also, attempt to stop failing fast.
154     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
155     BGPSpeaker.Kill_BGP_Speaker
156     FailFast.Do_Not_Fail_Fast_From_Now_On
157     # NOTE: It is still possible to remain failing fast, if both previous and this test have failed.
158     [Teardown]    SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
159
160 Wait_For_Stable_Ipv4_Topology_After_Talking
161     [Documentation]    Wait until example-ipv4-topology becomes stable again.
162     [Tags]    critical
163     # TODO: Is is possible to have failed at Check_Talking_Ipv4_Topology_Count and still have initial period of constant count?
164     # FIXME: If yes, do count here to get the initial value and use it (if nonzero).
165     # TODO: If yes, decide whether access to the FailFast state should have keyword or just variable name.
166     PrefixCounting.Wait_For_Ipv4_Topology_Prefixes_To_Become_Stable
167     ...    timeout=${bgp_filling_timeout}
168     ...    period=${CHECK_PERIOD_PREFIX_COUNT_MANY}
169     ...    repetitions=${REPETITIONS_PREFIX_COUNT_MANY}
170     ...    excluded_count=${COUNT_PREFIX_COUNT_MANY}
171
172 Check_For_Empty_Ipv4_Topology_After_Talking
173     [Documentation]    Example-ipv4-topology should be empty now.
174     [Tags]    critical
175     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
176     PrefixCounting.Check_Ipv4_Topology_Is_Empty
177
178 Restore_Karaf_Logging_Levels
179     [Documentation]    Set logging on bgpcep and protocol to the global value.
180     KarafKeywords.Set_Bgpcep_Log_Levels    bgpcep_level=${KARAF_LOG_LEVEL}    protocol_level=${KARAF_LOG_LEVEL}
181
182 Delete_Bgp_Peer_Configuration
183     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
184     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
185     # TODO: Is it useful to extract peer naming logic to separate Keyword?
186     FOR    ${index}    IN RANGE    1    ${MULTIPLICITY_PREFIX_COUNT_MANY}+1
187         ${peer_name} =    BuiltIn.Set_Variable    example-bgp-peer-${index}
188         ${peer_ip} =    BuiltIn.Evaluate    str(ipaddr.IPAddress('${FIRST_PEER_IP}') + ${index} - 1)    modules=ipaddr
189         &{mapping} =    BuiltIn.Create_Dictionary
190         ...    DEVICE_NAME=${DEVICE_NAME}
191         ...    BGP_NAME=${peer_name}
192         ...    IP=${peer_ip}
193         ...    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
194         TemplatedRequests.Delete_Templated    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    mapping=${mapping}
195     END
196
197
198 *** Keywords ***
199 Setup_Everything
200     [Documentation]    Setup imported resources, SSH-login to ODL system,
201     ...    create HTTP session, put Python tool to ODL system.
202     SetupUtils.Setup_Utils_For_Setup_And_Teardown
203     TemplatedRequests.Create_Default_Session
204     PrefixCounting.PC_Setup
205     RequestsLibrary.Create_Session
206     ...    operational
207     ...    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
208     ...    auth=${AUTH}
209     ...    timeout=125
210     ...    max_retries=0
211     # TODO: Do not include slash in ${OPERATIONAL_TOPO_API}, having it typed here is more readable.
212     # TODO: Alternatively, create variable in Variables which starts with http.
213     # Both TODOs would probably need to update every suite relying on current Variables.
214     SSHLibrary.Set_Default_Configuration    prompt=${ODL_SYSTEM_PROMPT}
215     SSHLibrary.Open_Connection    ${ODL_SYSTEM_IP}
216     SSHKeywords.Flexible_Controller_Login
217     SSHKeywords.Require_Python
218     SSHKeywords.Assure_Library_Ipaddr    target_dir=.
219     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/fastbgp/play.py
220     # Calculate the timeout value based on how many routes are going to be pushed.
221     ${period} =    DateTime.Convert_Time    ${CHECK_PERIOD_PREFIX_COUNT_MANY}    result_format=number
222     ${timeout} =    BuiltIn.Evaluate
223     ...    ${TEST_DURATION_MULTIPLIER_PREFIX_COUNT_MANY} * (${COUNT_PREFIX_COUNT_MANY} * 3.0 / 10000 + ${period} * (${REPETITIONS_PREFIX_COUNT_MANY} + 1)) + 20
224     Builtin.Set_Suite_Variable    ${bgp_filling_timeout}    ${timeout}
225     ${timeout} =    BuiltIn.Evaluate
226     ...    ${TEST_DURATION_MULTIPLIER_PREFIX_COUNT_MANY} * (${COUNT_PREFIX_COUNT_MANY} * 2.0 / 10000 + ${period} * (${REPETITIONS_PREFIX_COUNT_MANY} + 1)) + 20
227     Builtin.Set_Suite_Variable    ${bgp_emptying_timeout}    ${timeout}
228     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${KARAF_LOG_LEVEL}
229
230 Teardown_Everything
231     [Documentation]    Make sure Python tool was killed and tear down imported Resources.
232     # Environment issue may have dropped the SSH connection, but we do not want Teardown to fail.
233     BuiltIn.Run_Keyword_And_Ignore_Error    KillPythonTool.Search_And_Kill_Remote_Python    'play\.py'
234     BuiltIn.Run_Keyword_And_Ignore_Error    Utils.Get_Sysstat_Statistics
235     RequestsLibrary.Delete_All_Sessions
236     SSHLibrary.Close_All_Connections