a1f1bbc4bc0bb1f1ce08600a87f25d895913d5dc
[integration/test.git] / csit / suites / bgpcep / bgpclustering / 030_singlepeer_prefixcount_1Mroutes_Be.robot
1 *** Settings ***
2 Documentation     BGP performance of ingesting from 1 iBGP peer, data change counter is NOT used.
3 ...
4 ...               Copyright (c) 2015-2016 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 ...               This suite uses play.py as single iBGP peer which talks to
11 ...               single controller in three node cluster configuration.
12 ...               Test suite checks changes of the the example-ipv4-topology-<dst_id> on all nodes.
13 ...               RIB is not examined.
14 ...               <dst-id> is recognized during the suite run, should be the Leader of default
15 ...               operational Shard, otherwise the scenario would fail due to
16 ...               https://bugs.opendaylight.org/show_bug.cgi?id=5536
17 Suite Setup       Setup_Everything
18 Suite Teardown    Teardown_Everything
19 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Fast_Failing
20 Test Teardown     SetupUtils.Teardown_Test_Show_Bugs_And_Start_Fast_Failing_If_Test_Failed
21 Library           SSHLibrary    timeout=10s
22 Library           RequestsLibrary
23 Variables         ${CURDIR}/../../../variables/Variables.py
24 Resource          ${CURDIR}/../../../libraries/BGPSpeaker.robot
25 Resource          ${CURDIR}/../../../libraries/BGPcliKeywords.robot
26 Resource          ${CURDIR}/../../../libraries/FailFast.robot
27 Resource          ${CURDIR}/../../../libraries/KillPythonTool.robot
28 Resource          ${CURDIR}/../../../libraries/PrefixCounting.robot
29 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
30 Resource          ${CURDIR}/../../../libraries/ClusterManagement.robot
31 Resource          ${CURDIR}/../../../libraries/SSHKeywords.robot
32 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
33
34 *** Variables ***
35 ${BGP_TOOL_LOG_LEVEL}    info
36 ${BGP_VARIABLES_FOLDER}    ${CURDIR}/../../../variables/bgpclustering/bgp_peer
37 ${BGP_VARIABLES_FOLDER_OP}    ${CURDIR}/../../../variables/bgpclustering/bgp_peer_operational
38 ${NETCONF_DEV_FOLDER}    ${CURDIR}/../../../variables/netconf/device/full-uri-device
39 ${NETCONF_MOUNT_FOLDER}    ${CURDIR}/../../../variables/netconf/device/full-uri-mount
40 ${CHECK_PERIOD}    10
41 ${COUNT}          1000000
42 ${HOLDTIME}       180
43 ${INSERT}         1
44 ${KARAF_LOG_LEVEL}    INFO
45 ${KARAF_BGPCEP_LOG_LEVEL}    ${KARAF_LOG_LEVEL}
46 ${KARAF_PROTOCOL_LOG_LEVEL}    ${KARAF_BGPCEP_LOG_LEVEL}
47 ${PREFILL}        0
48 ${REPETITIONS}    1
49 ${RESULTS_FILE_NAME}    bgp.csv
50 ${TEST_DURATION_MULTIPLIER}    1
51 ${UPDATE}         single
52 ${WITHDRAW}       0
53 ${INITIAL_RESTCONF_TIMEOUT}    30s
54 ${KARAF_HOME}     ${WORKSPACE}/${BUNDLEFOLDER}
55 ${SHARD_DEFAULT_CONFIG}    shard-default-config
56 ${SHARD_DEFAULT_OPERATIONAL}    shard-default-operational
57 ${CONFIG_SESSION}    config-session
58 ${CONFIGURATION_1}    operational-1
59 ${CONFIGURATION_2}    operational-2
60 ${CONFIGURATION_3}    operational-3
61 ${EXAMPLE_IPV4_TOPOLOGY_PREF}    example-ipv4-topology-
62 ${DEVICE_NAME}    peer-controller-config
63 ${DEVICE_CHECK_TIMEOUT}    60s
64 ${RIB_INSTANCE}    example-bgp-rib
65 ${BGP_PEER_NAME}    example-bgp-peer
66
67 *** Test Cases ***
68 Get Default Operational Shard Leader
69     ${dos_leader}    ${dos_followers}=    ClusterManagement.Get_Leader_And_Followers_For_Shard
70     BuiltIn.Set Suite variable    ${dos_leader}    ${dos_leader}
71     BuiltIn.Set Suite variable    ${default_oper_shard_leader_node_ip}    ${ODL_SYSTEM_${dos_leader}_IP}
72     RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_${dos_leader}_IP}:${RESTCONFPORT}    auth=${AUTH}
73
74 Check_For_Empty_Ipv4_Topology_Before_Talking_1
75     [Documentation]    Wait for ${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader} to come up and empty. Give large timeout for case when BGP boots slower than restconf.
76     [Tags]    critical
77     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
78     BuiltIn.Wait_Until_Keyword_Succeeds    ${INITIAL_RESTCONF_TIMEOUT}    1s    PrefixCounting.Check_Ipv4_Topology_Is_Empty    session=${CONFIGURATION_1}    topology=${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader}
79
80 Check_For_Empty_Ipv4_Topology_Before_Talking_2
81     [Documentation]    Wait for ${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader} to come up and empty. Give large timeout for case when BGP boots slower than restconf.
82     [Tags]    critical
83     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
84     BuiltIn.Wait_Until_Keyword_Succeeds    ${INITIAL_RESTCONF_TIMEOUT}    1s    PrefixCounting.Check_Ipv4_Topology_Is_Empty    session=${CONFIGURATION_2}    topology=${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader}
85
86 Check_For_Empty_Ipv4_Topology_Before_Talking_3
87     [Documentation]    Wait for ${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader} to come up and empty. Give large timeout for case when BGP boots slower than restconf.
88     [Tags]    critical
89     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
90     BuiltIn.Wait_Until_Keyword_Succeeds    ${INITIAL_RESTCONF_TIMEOUT}    1s    PrefixCounting.Check_Ipv4_Topology_Is_Empty    session=${CONFIGURATION_3}    topology=${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader}
91
92 Configure_Netconf_Device
93     [Documentation]    Configures and verifies netconf device configuration. If configuration is not successful, it de-configures the device before the next attempt.
94     &{mapping}    Create Dictionary    DEVICE_NAME=${DEVICE_NAME}    DEVICE_PORT=1830    DEVICE_IP=${default_oper_shard_leader_node_ip}    DEVICE_USER=admin    DEVICE_PASSWORD=admin
95     # After the netconf device is configured, odl starts downloading schemas. If the downloading will not finish within akka timeout, more tries are needed, 3 is based on a user experience.
96     : FOR    ${index}    IN RANGE    0    3
97     \    ${status}    ${value}=    Run Keyword And Ignore Error    Configure Netconf Device And Check Mounted    ${mapping}
98     \    Exit For Loop If    '${status}' == 'PASS'
99     \    Run Keyword Unless    '${status}' == 'PASS'    TemplatedRequests.Delete_Templated    ${NETCONF_DEV_FOLDER}    mapping=${mapping}    session=${CONFIG_SESSION}
100     Run Keyword Unless    '${status}' == 'PASS'    Fail
101
102 Reconfigure_ODL_To_Accept_Connection
103     [Documentation]    Configure BGP peer module with initiate-connection set to false.
104     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
105     &{mapping}    Create Dictionary    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}
106     ...    INITIATE=false    BGP_RIB=${RIB_INSTANCE}
107     TemplatedRequests.Put_As_Json_Templated    ${BGP_VARIABLES_FOLDER}    mapping=${mapping}    session=${CONFIG_SESSION}
108     [Teardown]    SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
109
110 Start_Talking_BGP_Speaker
111     [Documentation]    Start Python speaker to connect to ODL. We need to do WUKS until odl really starts to accept incomming bgp connection. The failure happens if the incomming connection comes too quickly after configuring the peer in the previous test case.
112     BuiltIn.Wait_Until_Keyword_Succeeds    3x    1s    Start Bgp Peer
113
114 Wait_For_Stable_Talking_Ipv4_Topology_1
115     [Documentation]    Wait until ${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader} becomes stable. This is done by checking stability of prefix count as seen from node 1.
116     PrefixCounting.Wait_For_Ipv4_Topology_Prefixes_To_Become_Stable    timeout=${bgp_filling_timeout}    period=${CHECK_PERIOD}    repetitions=${REPETITIONS}    excluded_count=0    session=${CONFIGURATION_1}    topology=${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader}
117
118 Wait_For_Stable_Talking_Ipv4_Topology_2
119     [Documentation]    Wait until ${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader} becomes stable. This is done by checking stability of prefix count as seen from node 2.
120     PrefixCounting.Wait_For_Ipv4_Topology_Prefixes_To_Become_Stable    timeout=${bgp_filling_timeout}    period=${CHECK_PERIOD}    repetitions=${REPETITIONS}    excluded_count=0    session=${CONFIGURATION_2}    topology=${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader}
121
122 Wait_For_Stable_Talking_Ipv4_Topology_3
123     [Documentation]    Wait until ${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader} becomes stable. This is done by checking stability of prefix count as seen from node 3.
124     PrefixCounting.Wait_For_Ipv4_Topology_Prefixes_To_Become_Stable    timeout=${bgp_filling_timeout}    period=${CHECK_PERIOD}    repetitions=${REPETITIONS}    excluded_count=0    session=${CONFIGURATION_3}    topology=${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader}
125
126 Check_Talking_Ipv4_Topology_Count_1
127     [Documentation]    Count the routes in ${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader} and fail if the count is not correct as seen from node 1.
128     [Tags]    critical
129     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
130     PrefixCounting.Check_Ipv4_Topology_Count    ${COUNT}    session=${CONFIGURATION_1}    topology=${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader}
131
132 Check_Talking_Ipv4_Topology_Count_2
133     [Documentation]    Count the routes in ${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader} and fail if the count is not correct as seen from node 2.
134     [Tags]    critical
135     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
136     PrefixCounting.Check_Ipv4_Topology_Count    ${COUNT}    session=${CONFIGURATION_2}    topology=${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader}
137
138 Check_Talking_Ipv4_Topology_Count_3
139     [Documentation]    Count the routes in ${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader} and fail if the count is not correct as seen from node 3.
140     [Tags]    critical
141     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
142     PrefixCounting.Check_Ipv4_Topology_Count    ${COUNT}    session=${CONFIGURATION_3}    topology=${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader}
143
144 Kill_Talking_BGP_Speaker
145     [Documentation]    Abort the Python speaker. Also, attempt to stop failing fast.
146     [Tags]    critical
147     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
148     BGPSpeaker.Kill_BGP_Speaker
149     FailFast.Do_Not_Fail_Fast_From_Now_On
150
151 Wait_For_Stable_Ipv4_Topology_After_Listening_1
152     [Documentation]    Wait until ${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader} becomes stable again as seen from node 1.
153     [Tags]    critical
154     PrefixCounting.Wait_For_Ipv4_Topology_Prefixes_To_Become_Stable    timeout=${bgp_filling_timeout}    period=${CHECK_PERIOD}    repetitions=${REPETITIONS}    excluded_count=${COUNT}    session=${CONFIGURATION_1}    topology=${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader}
155
156 Wait_For_Stable_Ipv4_Topology_After_Listening_2
157     [Documentation]    Wait until ${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader} becomes stable again as seen from node 2.
158     [Tags]    critical
159     PrefixCounting.Wait_For_Ipv4_Topology_Prefixes_To_Become_Stable    timeout=${bgp_filling_timeout}    period=${CHECK_PERIOD}    repetitions=${REPETITIONS}    excluded_count=${COUNT}    session=${CONFIGURATION_2}    topology=${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader}
160
161 Wait_For_Stable_Ipv4_Topology_After_Listening_3
162     [Documentation]    Wait until ${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader} becomes stable again as seen from node 3.
163     [Tags]    critical
164     PrefixCounting.Wait_For_Ipv4_Topology_Prefixes_To_Become_Stable    timeout=${bgp_filling_timeout}    period=${CHECK_PERIOD}    repetitions=${REPETITIONS}    excluded_count=${COUNT}    session=${CONFIGURATION_3}    topology=${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader}
165
166 Check_For_Empty_Ipv4_Topology_After_Listening_1
167     [Documentation]    Example-ipv4-topology should be empty now as seen from node 1.
168     [Tags]    critical
169     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
170     PrefixCounting.Check_Ipv4_Topology_Is_Empty    session=${CONFIGURATION_1}    topology=${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader}
171
172 Check_For_Empty_Ipv4_Topology_After_Listening_2
173     [Documentation]    Example-ipv4-topology should be empty now as seen from node 2.
174     [Tags]    critical
175     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
176     PrefixCounting.Check_Ipv4_Topology_Is_Empty    session=${CONFIGURATION_2}    topology=${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader}
177
178 Check_For_Empty_Ipv4_Topology_After_Listening_3
179     [Documentation]    Example-ipv4-topology should be empty now as seen from node 3.
180     [Tags]    critical
181     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
182     PrefixCounting.Check_Ipv4_Topology_Is_Empty    session=${CONFIGURATION_3}    topology=${EXAMPLE_IPV4_TOPOLOGY_PREF}${dos_leader}
183
184 Delete_Bgp_Peer_Configuration
185     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
186     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
187     &{mapping}    Create Dictionary    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}
188     ...    INITIATE=false    BGP_RIB=${RIB_INSTANCE}
189     TemplatedRequests.Delete_Templated    ${BGP_VARIABLES_FOLDER}    mapping=${mapping}    session=${CONFIG_SESSION}
190
191 Delete_Netconf_Device_Configuration
192     [Documentation]    Revert the netconf configuration to the original stat
193     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
194     &{mapping}    Create Dictionary    DEVICE_NAME=${DEVICE_NAME}    DEVICE_PORT=1830    DEVICE_IP=${default_oper_shard_leader_node_ip}    DEVICE_USER=admin    DEVICE_PASSWORD=admin
195     TemplatedRequests.Delete_Templated    ${NETCONF_DEV_FOLDER}    mapping=${mapping}    session=${CONFIG_SESSION}
196
197 *** Keywords ***
198 Setup_Everything
199     [Documentation]    Setup imported resources, SSH-login to tools system,
200     ...    create HTTP session, put Python tool to tools system.
201     SetupUtils.Setup_Utils_For_Setup_And_Teardown
202     ClusterManagement.ClusterManagement_Setup
203     RequestsLibrary.Create_Session    ${CONFIGURATION_1}    http://${ODL_SYSTEM_1_IP}:${RESTCONFPORT}${OPERATIONAL_API}    auth=${AUTH}
204     RequestsLibrary.Create_Session    ${CONFIGURATION_2}    http://${ODL_SYSTEM_2_IP}:${RESTCONFPORT}${OPERATIONAL_API}    auth=${AUTH}
205     RequestsLibrary.Create_Session    ${CONFIGURATION_3}    http://${ODL_SYSTEM_3_IP}:${RESTCONFPORT}${OPERATIONAL_API}    auth=${AUTH}
206     PrefixCounting.PC_Setup
207     SSHLibrary.Set_Default_Configuration    prompt=${TOOLS_SYSTEM_PROMPT}
208     SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}
209     Utils.Flexible_Mininet_Login
210     # TODO: Do not include slash in ${OPERATIONAL_TOPO_API}, having it typed here is more readable.
211     # TODO: Alternatively, create variable in Variables which starts with http.
212     # Both TODOs would probably need to update every suite relying on current Variables.
213     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/fastbgp/play.py
214     SSHKeywords.Require_Python
215     SSHKeywords.Assure_Library_Ipaddr    target_dir=.
216     # Calculate the timeout value based on how many routes are going to be pushed
217     # TODO: Replace 35 with some formula from period and repetitions.
218     ${timeout} =    BuiltIn.Evaluate    ${TEST_DURATION_MULTIPLIER} * (${COUNT} * 6.0 / 10000 + 35)
219     Builtin.Set_Suite_Variable    ${bgp_filling_timeout}    ${timeout}
220     Builtin.Set_Suite_Variable    ${bgp_emptying_timeout}    ${bgp_filling_timeout*3.0/4}
221     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${KARAF_LOG_LEVEL}
222
223 Teardown_Everything
224     [Documentation]    Make sure Python tool was killed and tear down imported Resources.
225     # Environment issue may have dropped the SSH connection, but we do not want Teardown to fail.
226     BuiltIn.Run_Keyword_And_Ignore_Error    KillPythonTool.Search_And_Kill_Remote_Python    'play\.py'
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}
237
238 Configure Netconf Device And Check Mounted
239     [Arguments]    ${mapping}
240     TemplatedRequests.Put_As_Xml_Templated    ${NETCONF_DEV_FOLDER}    mapping=${mapping}    session=${CONFIG_SESSION}
241     BuiltIn.Wait Until Keyword Succeeds    10x    3s    TemplatedRequests.Get_As_Xml_Templated    ${NETCONF_MOUNT_FOLDER}    mapping=${mapping}    session=${CONFIG_SESSION}
242
243 Start Bgp Peer
244     [Documentation]    Starts bgp peer and verifies that the peer runs.
245     BGPSpeaker.Start_BGP_Speaker    --amount ${COUNT} --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${default_oper_shard_leader_node_ip} --peerport=${ODL_BGP_PORT} --insert=${INSERT} --withdraw=${WITHDRAW} --prefill ${PREFILL} --update ${UPDATE} --${BGP_TOOL_LOG_LEVEL} --results ${RESULTS_FILE_NAME}
246     BGPcliKeywords.Read_And_Fail_If_Prompt_Is_Seen