40be12b7a77a8d44091d8cc3d83a62fd2d068d4a
[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 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 ...               TODO: Currently, if a bug causes prefix count to remain at zero,
20 ...               affected test cases will wait for max time. Reconsider.
21 ...               If zero is allowed as stable, higher period or repetitions would be required.
22 ...
23 ...               The prefix counting is quite heavyweight and may induce large variation in time.
24 ...               Try the other version of the suite (singlepeer_changecount.robot) to get better precision.
25 Suite Setup       Setup_Everything
26 Suite Teardown    Teardown_Everything
27 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Fast_Failing
28 Test Teardown     FailFast.Start_Failing_Fast_If_This_Failed
29 Library           SSHLibrary    timeout=10s
30 Library           RequestsLibrary
31 Variables         ${CURDIR}/../../../variables/Variables.py
32 Resource          ${CURDIR}/../../../libraries/BGPSpeaker.robot
33 Resource          ${CURDIR}/../../../libraries/ConfigViaRestconf.robot
34 Resource          ${CURDIR}/../../../libraries/FailFast.robot
35 Resource          ${CURDIR}/../../../libraries/KillPythonTool.robot
36 Resource          ${CURDIR}/../../../libraries/PrefixCounting.robot
37 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
38
39 *** Variables ***
40 ${BGP_VARIABLES_FOLDER}    ${CURDIR}/../../../variables/bgpuser/
41 ${HOLDTIME}       180
42 ${HOLDTIME_PREFIX_COUNT}    ${HOLDTIME}
43 ${COUNT}          1000000
44 ${COUNT_PREFIX_COUNT}    ${COUNT}
45 ${CHECK_PERIOD}    1
46 ${CHECK_PERIOD_PREFIX_COUNT}    ${CHECK_PERIOD}
47 ${REPETITIONS_PREFIX_COUNT}    1
48 # TODO: Option names can be better.
49 ${last_prefix_count}    -1
50
51 *** Test Cases ***
52 Check_For_Empty_Ipv4_Topology_Before_Talking
53     [Documentation]    Wait for example-ipv4-topology to come up and empty. Give large timeout for case when BGP boots slower than restconf.
54     [Tags]    critical
55     # TODO: Choose which tags to assign and make sure they are assigned correctly.
56     BuiltIn.Wait_Until_Keyword_Succeeds    120s    1s    PrefixCounting.Check_Ipv4_Topology_Is_Empty
57
58 Reconfigure_ODL_To_Accept_Connection
59     [Documentation]    Configure BGP peer module with initiate-connection set to false.
60     ${template_as_string} =    BuiltIn.Set_Variable    {'IP': '${TOOLS_SYSTEM_IP}', 'HOLDTIME': '${HOLDTIME_PREFIX_COUNT}', 'PEER_PORT': '${BGP_TOOL_PORT}', 'INITIATE': 'false'}
61     ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    ${template_as_string}
62
63 Start_Talking_BGP_speaker
64     [Documentation]    Start Python speaker to connect to ODL.
65     # Myport value is needed for checking whether connection at precise port was established.
66     BGPSpeaker.Start_BGP_speaker    --amount ${COUNT_PREFIX_COUNT} --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT}
67
68 Wait_For_Stable_Talking_Ipv4_Topology
69     [Documentation]    Wait until example-ipv4-topology becomes stable. This is done by checking stability of prefix count.
70     PrefixCounting.Wait_For_Ipv4_Topology_Prefixes_To_Become_Stable    timeout=${bgp_filling_timeout}    period=${CHECK_PERIOD_PREFIX_COUNT}    repetitions=${REPETITIONS_PREFIX_COUNT}    excluded_count=0
71
72 Check_Talking_Ipv4_Topology_Count
73     [Documentation]    Count the routes in example-ipv4-topology and fail if the count is not correct.
74     [Tags]    critical
75     PrefixCounting.Check_Ipv4_Topology_Count    ${COUNT_PREFIX_COUNT}
76
77 Kill_Talking_BGP_Speaker
78     [Documentation]    Abort the Python speaker. Also, attempt to stop failing fast.
79     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
80     BGPSpeaker.Kill_BGP_Speaker
81     FailFast.Do_Not_Fail_Fast_From_Now_On
82     # NOTE: It is still possible to remain failing fast, if both previous and this test have failed.
83     [Teardown]    FailFast.Do_Not_Start_Failing_If_This_Failed
84
85 Wait_For_Stable_Ipv4_Topology_After_Talking
86     [Documentation]    Wait until example-ipv4-topology becomes stable again.
87     [Tags]    critical
88     # TODO: Is is possible to have failed at Check_Talking_Ipv4_Topology_Count and still have initial period of constant count?
89     # FIXME: If yes, do count here to get the initial value and use it (if nonzero).
90     # TODO: If yes, decide whether access to the FailFast state should have keyword or just variable name.
91     PrefixCounting.Wait_For_Ipv4_Topology_Prefixes_To_Become_Stable    timeout=${bgp_filling_timeout}    period=${CHECK_PERIOD_PREFIX_COUNT}    repetitions=${REPETITIONS_PREFIX_COUNT}    excluded_count=${COUNT_PREFIX_COUNT}
92
93 Check_For_Empty_Ipv4_Topology_After_Talking
94     [Documentation]    Example-ipv4-topology should be empty now.
95     [Tags]    critical
96     PrefixCounting.Check_Ipv4_Topology_Is_Empty
97
98 Start_Listening_BGP_Speaker
99     [Documentation]    Start Python speaker in listening mode.
100     BGPSpeaker.Start_BGP_speaker    --amount ${COUNT_PREFIX_COUNT} --listen --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP}
101
102 Reconfigure_ODL_To_Initiate_Connection
103     [Documentation]    Replace BGP peer config module, now with initiate-connection set to true.
104     ${template_as_string} =    BuiltIn.Set_Variable    {'IP': '${TOOLS_SYSTEM_IP}', 'HOLDTIME': '${HOLDTIME_PREFIX_COUNT}', 'PEER_PORT': '${BGP_TOOL_PORT}', 'INITIATE': 'true'}
105     ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    ${template_as_string}
106
107 Wait_For_Stable_Listening_Ipv4_Topology
108     [Documentation]    Wait until example-ipv4-topology becomes stable.
109     PrefixCounting.Wait_For_Ipv4_Topology_Prefixes_To_Become_Stable    timeout=${bgp_filling_timeout}    period=${CHECK_PERIOD_PREFIX_COUNT}    repetitions=${REPETITIONS_PREFIX_COUNT}    excluded_count=0
110
111 Check_Listening_Ipv4_Topology_Count
112     [Documentation]    Count the routes in example-ipv4-topology and fail if the count is not correct.
113     [Tags]    critical
114     PrefixCounting.Check_Ipv4_Topology_Count    ${COUNT_PREFIX_COUNT}
115
116 Kill_Listening_BGP_Speaker
117     [Documentation]    Abort the Python speaker. Also, attempt to stop failing fast.
118     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
119     BGPSpeaker.Kill_BGP_Speaker
120     FailFast.Do_Not_Fail_Fast_From_Now_On
121     # NOTE: It is still possible to remain failing fast, if both previous and this test have failed.
122     [Teardown]    FailFast.Do_Not_Start_Failing_If_This_Failed
123
124 Wait_For_Stable_Ipv4_Topology_After_Listening
125     [Documentation]    Wait until example-ipv4-topology becomes stable again.
126     [Tags]    critical
127     PrefixCounting.Wait_For_Ipv4_Topology_Prefixes_To_Become_Stable    timeout=${bgp_filling_timeout}    period=${CHECK_PERIOD_PREFIX_COUNT}    repetitions=${REPETITIONS_PREFIX_COUNT}    excluded_count=${COUNT_PREFIX_COUNT}
128
129 Check_For_Empty_Ipv4_Topology_After_Listening
130     [Documentation]    Example-ipv4-topology should be empty now.
131     [Tags]    critical
132     PrefixCounting.Check_Ipv4_Topology_Is_Empty
133
134 Delete_Bgp_Peer_Configuration
135     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
136     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
137     ConfigViaRestconf.Delete_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}bgp_peer
138
139 *** Keywords ***
140 Setup_Everything
141     [Documentation]    Setup imported resources, SSH-login to mininet machine,
142     ...    create HTTP session, put Python tool to mininet machine.
143     SetupUtils.Setup_Utils_For_Setup_And_Teardown
144     ConfigViaRestconf.Setup_Config_Via_Restconf
145     PrefixCounting.PC_Setup
146     SSHLibrary.Set_Default_Configuration    prompt=${TOOLS_SYSTEM_PROMPT}
147     SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}
148     Utils.Flexible_Mininet_Login
149     RequestsLibrary.Create_Session    operational    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}${OPERATIONAL_API}    auth=${AUTH}
150     # TODO: Do not include slash in ${OPERATIONAL_TOPO_API}, having it typed here is more readable.
151     # TODO: Alternatively, create variable in Variables which starts with http.
152     # Both TODOs would probably need to update every suite relying on current Variables.
153     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/fastbgp/play.py
154     # Calculate the timeout value based on how many routes are going to be pushed
155     ${count} =    Builtin.Convert_To_Integer    ${COUNT_PREFIX_COUNT}
156     # TODO: Replace 20 with some formula from period and repetitions.
157     Builtin.Set_Suite_Variable    ${bgp_filling_timeout}    ${count*3/10000+20}
158     Builtin.Set_Suite_Variable    ${bgp_emptying_timeout}    ${bgp_filling_timeout*3/4}
159
160 Teardown_Everything
161     [Documentation]    Make sure Python tool was killed and tear down imported Resources.
162     KillPythonTool.Search_And_Kill_Remote_Python    'play\.py'
163     ConfigViaRestconf.Teardown_Config_Via_Restconf
164     RequestsLibrary.Delete_All_Sessions
165     SSHLibrary.Close_All_Connections