Minimize connection time in new BGP cluster suites
[integration/test.git] / csit / suites / bgpcep / bgpclustering / 010_singlepeer_prefixcount_1route.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       PrefixcountKeywords.Setup_Everything
18 Suite Teardown    PrefixcountKeywords.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 Resource          ${CURDIR}/../../../libraries/CompareStream.robot
34 Resource          ${CURDIR}/PrefixcountKeywords.robot
35
36 *** Variables ***
37 ${COUNT}          1
38
39 *** Test Cases ***
40 Get Example Bgp Rib Owner
41     [Documentation]    Find an odl node which is able to accept incomming connection. To this node netconf connector should be configured.
42     ${rib_owner}    ${rib_candidates}=    ClusterManagement.Get_Owner_And_Successors_For_device    example-bgp-rib    org.opendaylight.mdsal.ServiceEntityType    1
43     BuiltIn.Set_Suite_Variable    ${rib_owner}    ${rib_owner}
44     BuiltIn.Set_Suite_Variable    ${rib_owner_node_id}    ${ODL_SYSTEM_${rib_owner}_IP}
45     RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_${rib_owner}_IP}:${RESTCONFPORT}    auth=${AUTH}    timeout=10    max_retries=0
46
47 Check_For_Empty_Ipv4_Topology_Before_Talking_1
48     [Documentation]    Wait for ${EXAMPLE_IPV4_TOPOLOGY} to come up and empty. Give large timeout for case when BGP boots slower than restconf.
49     [Tags]    critical
50     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
51     BuiltIn.Wait_Until_Keyword_Succeeds    ${INITIAL_RESTCONF_TIMEOUT}    1s    PrefixCounting.Check_Ipv4_Topology_Is_Empty    session=${CONFIGURATION_1}    topology=${EXAMPLE_IPV4_TOPOLOGY}
52
53 Check_For_Empty_Ipv4_Topology_Before_Talking_2
54     [Documentation]    Wait for ${EXAMPLE_IPV4_TOPOLOGY} to come up and empty. Give large timeout for case when BGP boots slower than restconf.
55     [Tags]    critical
56     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
57     BuiltIn.Wait_Until_Keyword_Succeeds    ${INITIAL_RESTCONF_TIMEOUT}    1s    PrefixCounting.Check_Ipv4_Topology_Is_Empty    session=${CONFIGURATION_2}    topology=${EXAMPLE_IPV4_TOPOLOGY}
58
59 Check_For_Empty_Ipv4_Topology_Before_Talking_3
60     [Documentation]    Wait for ${EXAMPLE_IPV4_TOPOLOGY} to come up and empty. Give large timeout for case when BGP boots slower than restconf.
61     [Tags]    critical
62     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
63     BuiltIn.Wait_Until_Keyword_Succeeds    ${INITIAL_RESTCONF_TIMEOUT}    1s    PrefixCounting.Check_Ipv4_Topology_Is_Empty    session=${CONFIGURATION_3}    topology=${EXAMPLE_IPV4_TOPOLOGY}
64
65 Configure_Netconf_Device
66     [Documentation]    Configures and verifies netconf device configuration. If configuration is not successful, it de-configures the device before the next attempt.
67     # No need for configuring netconf device in carbon and above, openconfig is used
68     CompareStream.Run_Keyword_If_At_Least_Carbon    BuiltIn.Pass_Execution    Openconfig usage does not need netconf connector
69     &{mapping}    BuiltIn.Create_Dictionary    DEVICE_NAME=${DEVICE_NAME}    DEVICE_PORT=1830    DEVICE_IP=${rib_owner_node_id}    DEVICE_USER=admin    DEVICE_PASSWORD=admin
70     # 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.
71     : FOR    ${index}    IN RANGE    0    3
72     \    ${status}    ${value}=    Run Keyword And Ignore Error    PrefixcountKeywords.Configure_Netconf_Device_And_Check_Mounted    ${mapping}
73     \    Exit For Loop If    '${status}' == 'PASS'
74     \    Run Keyword Unless    '${status}' == 'PASS'    TemplatedRequests.Delete_Templated    ${NETCONF_DEV_FOLDER}    mapping=${mapping}    session=${CONFIG_SESSION}
75     Run Keyword Unless    '${status}' == 'PASS'    Fail
76
77 Reconfigure_ODL_To_Accept_Connection
78     [Documentation]    Configure BGP peer module with initiate-connection set to false.
79     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
80     &{mapping}    BuiltIn.Create_Dictionary    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}
81     ...    INITIATE=false    BGP_RIB=${RIB_INSTANCE}    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
82     TemplatedRequests.Put_As_Json_Templated    ${BGP_VARIABLES_FOLDER}    mapping=${mapping}    session=${CONFIG_SESSION}
83     [Teardown]    SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
84
85 Start_Talking_BGP_Speaker
86     [Documentation]    Start Python speaker to connect to ODL.
87     PrefixcountKeywords.Start_Bgp_Peer_And_Verify_Connected    connection_retries=${3}
88
89 Wait_For_Stable_Talking_Ipv4_Topology_1
90     [Documentation]    Wait until ${EXAMPLE_IPV4_TOPOLOGY} becomes stable. This is done by checking stability of prefix count as seen from node 1.
91     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}
92
93 Wait_For_Stable_Talking_Ipv4_Topology_2
94     [Documentation]    Wait until ${EXAMPLE_IPV4_TOPOLOGY} becomes stable. This is done by checking stability of prefix count as seen from node 2.
95     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}
96
97 Wait_For_Stable_Talking_Ipv4_Topology_3
98     [Documentation]    Wait until ${EXAMPLE_IPV4_TOPOLOGY} becomes stable. This is done by checking stability of prefix count as seen from node 3.
99     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}
100
101 Check_Talking_Ipv4_Topology_Count_1
102     [Documentation]    Count the routes in ${EXAMPLE_IPV4_TOPOLOGY} and fail if the count is not correct as seen from node 1.
103     [Tags]    critical
104     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
105     PrefixCounting.Check_Ipv4_Topology_Count    ${COUNT}    session=${CONFIGURATION_1}    topology=${EXAMPLE_IPV4_TOPOLOGY}
106
107 Check_Talking_Ipv4_Topology_Count_2
108     [Documentation]    Count the routes in ${EXAMPLE_IPV4_TOPOLOGY} and fail if the count is not correct as seen from node 2.
109     [Tags]    critical
110     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
111     PrefixCounting.Check_Ipv4_Topology_Count    ${COUNT}    session=${CONFIGURATION_2}    topology=${EXAMPLE_IPV4_TOPOLOGY}
112
113 Check_Talking_Ipv4_Topology_Count_3
114     [Documentation]    Count the routes in ${EXAMPLE_IPV4_TOPOLOGY} and fail if the count is not correct as seen from node 3.
115     [Tags]    critical
116     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
117     PrefixCounting.Check_Ipv4_Topology_Count    ${COUNT}    session=${CONFIGURATION_3}    topology=${EXAMPLE_IPV4_TOPOLOGY}
118
119 Kill_Talking_BGP_Speaker
120     [Documentation]    Abort the Python speaker. Also, attempt to stop failing fast.
121     [Tags]    critical
122     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
123     BGPSpeaker.Kill_BGP_Speaker
124     FailFast.Do_Not_Fail_Fast_From_Now_On
125
126 Wait_For_Stable_Ipv4_Topology_After_Listening_1
127     [Documentation]    Wait until ${EXAMPLE_IPV4_TOPOLOGY} becomes stable again as seen from node 1.
128     [Tags]    critical
129     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}
130
131 Wait_For_Stable_Ipv4_Topology_After_Listening_2
132     [Documentation]    Wait until ${EXAMPLE_IPV4_TOPOLOGY} becomes stable again as seen from node 2.
133     [Tags]    critical
134     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}
135
136 Wait_For_Stable_Ipv4_Topology_After_Listening_3
137     [Documentation]    Wait until ${EXAMPLE_IPV4_TOPOLOGY} becomes stable again as seen from node 3.
138     [Tags]    critical
139     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}
140
141 Check_For_Empty_Ipv4_Topology_After_Listening_1
142     [Documentation]    Example-ipv4-topology should be empty now as seen from node 1.
143     [Tags]    critical
144     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
145     PrefixCounting.Check_Ipv4_Topology_Is_Empty    session=${CONFIGURATION_1}    topology=${EXAMPLE_IPV4_TOPOLOGY}
146
147 Check_For_Empty_Ipv4_Topology_After_Listening_2
148     [Documentation]    Example-ipv4-topology should be empty now as seen from node 2.
149     [Tags]    critical
150     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
151     PrefixCounting.Check_Ipv4_Topology_Is_Empty    session=${CONFIGURATION_2}    topology=${EXAMPLE_IPV4_TOPOLOGY}
152
153 Check_For_Empty_Ipv4_Topology_After_Listening_3
154     [Documentation]    Example-ipv4-topology should be empty now as seen from node 3.
155     [Tags]    critical
156     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
157     PrefixCounting.Check_Ipv4_Topology_Is_Empty    session=${CONFIGURATION_3}    topology=${EXAMPLE_IPV4_TOPOLOGY}
158
159 Delete_Bgp_Peer_Configuration
160     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
161     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
162     &{mapping}    BuiltIn.Create_Dictionary    DEVICE_NAME=${DEVICE_NAME}    BGP_NAME=${BGP_PEER_NAME}    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}
163     ...    INITIATE=false    BGP_RIB=${RIB_INSTANCE}    BGP_RIB_OPENCONFIG=${PROTOCOL_OPENCONFIG}
164     TemplatedRequests.Delete_Templated    ${BGP_VARIABLES_FOLDER}    mapping=${mapping}    session=${CONFIG_SESSION}
165
166 Delete_Netconf_Device_Configuration
167     [Documentation]    Revert the netconf configuration to the original stat
168     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
169     CompareStream.Run_Keyword_If_At_Least_Carbon    BuiltIn.Pass_Execution    Openconfig usage does not need netconf connector
170     &{mapping}    BuiltIn.Create_Dictionary    DEVICE_NAME=${DEVICE_NAME}    DEVICE_PORT=1830    DEVICE_IP=${rib_owner_node_id}    DEVICE_USER=admin    DEVICE_PASSWORD=admin
171     TemplatedRequests.Delete_Templated    ${NETCONF_DEV_FOLDER}    mapping=${mapping}    session=${CONFIG_SESSION}