28e74d8f8ae835204d5f305fa4b3d4d8c4f0fa5a
[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 ...               TODO: Is there a need for version of this suite where ODL connects to pers?
39 ...               Note that configuring ODL is slow, which may affect measured performance singificantly.
40 ...               Advanced TODO: Give manager ability to start pushing on trigger long after connections are established.
41 Suite Setup       Setup_Everything
42 Suite Teardown    Teardown_Everything
43 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Fast_Failing
44 Test Teardown     FailFast.Start_Failing_Fast_If_This_Failed
45 Library           DateTime
46 Library           RequestsLibrary
47 Library           SSHLibrary    timeout=10s
48 Variables         ${CURDIR}/../../../variables/Variables.py
49 Resource          ${CURDIR}/../../../libraries/BGPSpeaker.robot
50 Resource          ${CURDIR}/../../../libraries/ConfigViaRestconf.robot
51 Resource          ${CURDIR}/../../../libraries/FailFast.robot
52 Resource          ${CURDIR}/../../../libraries/KillPythonTool.robot
53 Resource          ${CURDIR}/../../../libraries/PrefixCounting.robot
54 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
55 Resource          ${CURDIR}/../../../libraries/SSHKeywords.robot
56
57 *** Variables ***
58 ${BGP_VARIABLES_FOLDER}    ${CURDIR}/../../../variables/bgpuser/
59 ${HOLDTIME}       180
60 ${HOLDTIME_PREFIX_COUNT}    ${HOLDTIME}
61 ${COUNT}          1000000
62 ${COUNT_PREFIX_COUNT}    ${COUNT}
63 ${FIRST_PEER_IP}    127.0.0.1
64 ${MULTIPLICITY}    2    # May be increased after Bug 4488 is fixed.
65 ${MULTIPLICITY_PREFIX_COUNT}    ${MULTIPLICITY}
66 ${CHECK_PERIOD}    4    # ${MULTIPLICITY*2}
67 ${CHECK_PERIOD_PREFIX_COUNT}    ${CHECK_PERIOD}
68 ${REPETITIONS}    1
69 ${REPETITIONS_PREFIX_COUNT}    ${REPETITIONS}
70 ${BGPCEP_LOG_LEVEL}    INFO
71 # TODO: Option names can be better.
72 ${last_prefix_count}    -1
73
74 *** Test Cases ***
75 Check_For_Empty_Ipv4_Topology_Before_Talking
76     [Documentation]    Wait for example-ipv4-topology to come up and empty. Give large timeout for case when BGP boots slower than restconf.
77     [Tags]    critical
78     # TODO: Choose which tags to assign and make sure they are assigned correctly.
79     BuiltIn.Wait_Until_Keyword_Succeeds    120s    1s    PrefixCounting.Check_Ipv4_Topology_Is_Empty
80
81 Reconfigure_ODL_To_Accept_Connections
82     [Documentation]    Configure BGP peer modules with initiate-connection set to false.
83     : FOR    ${index}    IN RANGE    1    ${MULTIPLICITY}+1
84     \    ${peer_name} =    BuiltIn.Set_Variable    example-bgp-peer-${index}
85     \    ${peer_ip} =    BuiltIn.Evaluate    str(ipaddr.IPAddress('${FIRST_PEER_IP}') + ${index} - 1)    modules=ipaddr
86     \    ${template_as_string} =    BuiltIn.Set_Variable    {'NAME': '${peer_name}', 'IP': '${peer_ip}', 'PEER_PORT': '${BGP_TOOL_PORT}', 'HOLDTIME': '${HOLDTIME_PREFIX_COUNT}', 'INITIATE': 'false'}
87     \    ConfigViaRestconf.Put_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLES_FOLDER}${/}bgp_peer    ${template_as_string}
88     # FIXME: Add testcase to change bgpcep and protocol log levels, when a Keyword that does it without messing with current connection is ready.
89
90 Set_Logging_Levels
91     [Documentation]    For Bug 4488 examination, more verbose logging may be needed.
92     KarafKeywords.Set_Bgpcep_Log_Levels    bgpcep_level=${BGPCEP_LOG_LEVEL}    protocol_level=${PROTOCOL_LOG_LEVEL}
93
94 Start_Talking_BGP_Manager
95     [Documentation]    Start Python manager to connect speakers to ODL.
96     # Myport value is needed for checking whether connection at precise port was established.
97     BGPSpeaker.Start_BGP_Manager    --amount=${COUNT_PREFIX_COUNT} --multiplicity=${MULTIPLICITY} --myip=${FIRST_PEER_IP} --myport=${BGP_TOOL_PORT} --peerip=${ODL_SYSTEM_IP} --peerport=${ODL_BGP_PORT}
98
99 Wait_For_Stable_Talking_Ipv4_Topology
100     [Documentation]    Wait until example-ipv4-topology becomes stable. This is done by checking stability of prefix count.
101     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
102
103 Check_Talking_Ipv4_Topology_Count
104     [Documentation]    Count the routes in example-ipv4-topology and fail if the count is not correct.
105     [Tags]    critical
106     PrefixCounting.Check_Ipv4_Topology_Count    ${COUNT_PREFIX_COUNT}
107
108 Kill_Talking_BGP_Speakers
109     [Documentation]    Abort the Python speakers. Also, attempt to stop failing fast.
110     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
111     BGPSpeaker.Kill_BGP_Speaker
112     FailFast.Do_Not_Fail_Fast_From_Now_On
113     # NOTE: It is still possible to remain failing fast, if both previous and this test have failed.
114     [Teardown]    FailFast.Do_Not_Start_Failing_If_This_Failed
115
116 Wait_For_Stable_Ipv4_Topology_After_Talking
117     [Documentation]    Wait until example-ipv4-topology becomes stable again.
118     [Tags]    critical
119     # TODO: Is is possible to have failed at Check_Talking_Ipv4_Topology_Count and still have initial period of constant count?
120     # FIXME: If yes, do count here to get the initial value and use it (if nonzero).
121     # TODO: If yes, decide whether access to the FailFast state should have keyword or just variable name.
122     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}
123
124 Check_For_Empty_Ipv4_Topology_After_Talking
125     [Documentation]    Example-ipv4-topology should be empty now.
126     [Tags]    critical
127     PrefixCounting.Check_Ipv4_Topology_Is_Empty
128
129 Restore_Logging_Levels
130     [Documentation]    Set logging on bgpcep and protocol to default values.
131     KarafKeywords.Set_Bgpcep_Log_Levels
132
133 Delete_Bgp_Peer_Configuration
134     [Documentation]    Revert the BGP configuration to the original state: without any configured peers.
135     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
136     # TODO: Is it useful to extract peer naming logic to separate Keyword?
137     : FOR    ${index}    IN RANGE    1    ${MULTIPLICITY}+1
138     \    ${template_as_string}=    BuiltIn.Set_Variable    {'NAME': 'example-bgp-peer-${index}'}
139     \    ConfigViaRestconf.Delete_Xml_Template_Folder_Config_Via_Restconf    ${BGP_VARIABLESFOLDER}${/}bgp_peer    ${template_as_string}
140
141 *** Keywords ***
142 Setup_Everything
143     [Documentation]    Setup imported resources, SSH-login to ODL system,
144     ...    create HTTP session, put Python tool to ODL system.
145     SetupUtils.Setup_Utils_For_Setup_And_Teardown
146     ConfigViaRestconf.Setup_Config_Via_Restconf
147     PrefixCounting.PC_Setup
148     SSHLibrary.Set_Default_Configuration    prompt=${ODL_SYSTEM_PROMPT}
149     SSHLibrary.Open_Connection    ${ODL_SYSTEM_IP}
150     Utils.Flexible_Controller_Login
151     RequestsLibrary.Create_Session    operational    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}${OPERATIONAL_API}    auth=${AUTH}
152     # TODO: Do not include slash in ${OPERATIONAL_TOPO_API}, having it typed here is more readable.
153     # TODO: Alternatively, create variable in Variables which starts with http.
154     # Both TODOs would probably need to update every suite relying on current Variables.
155     SSHKeywords.Require_Python
156     SSHKeywords.Assure_Library_Ipaddr    target_dir=.
157     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/fastbgp/play.py
158     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/fastbgp/manage_play.py
159     # Calculate the timeout value based on how many routes are going to be pushed.
160     ${period} =    DateTime.Convert_Time    ${CHECK_PERIOD_PREFIX_COUNT}    result_format=number
161     ${timeout} =    BuiltIn.Evaluate    ${COUNT_PREFIX_COUNT} * 3 / 10000 + ${period} * (${REPETITIONS_PREFIX_COUNT} + 1)
162     Builtin.Set_Suite_Variable    ${bgp_filling_timeout}    ${timeout}
163     ${timeout} =    BuiltIn.Evaluate    ${COUNT_PREFIX_COUNT} * 2 / 10000 + ${period} * (${REPETITIONS_PREFIX_COUNT} + 1)
164     Builtin.Set_Suite_Variable    ${bgp_emptying_timeout}    ${timeout}
165
166 Teardown_Everything
167     [Documentation]    Make sure Python tool was killed and tear down imported Resources.
168     KillPythonTool.Search_And_Kill_Remote_Python    'play\.py'
169     ConfigViaRestconf.Teardown_Config_Via_Restconf
170     RequestsLibrary.Delete_All_Sessions
171     SSHLibrary.Close_All_Connections