Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / suites / bgpcep / bgpclustering / PrefixcountKeywords.robot
1 *** Settings ***
2 Documentation     BGP performance of ingesting from 1 iBGP peer, data change counter is NOT used.
3 ...
4 ...               Copyright (c) 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 ...               For propper usage of this resource ${config_session} varaible has to be set.
11 ...               It should point to http://<ip-addr>:${RESTCONFPORT}.
12 Library           SSHLibrary    timeout=10s
13 Library           RequestsLibrary
14 Resource          ../../../libraries/BGPcliKeywords.robot
15 Resource          ../../../libraries/BGPSpeaker.robot
16 Resource          ../../../libraries/ClusterAdmin.robot
17 Resource          ../../../libraries/ClusterManagement.robot
18 Resource          ../../../libraries/FailFast.robot
19 Resource          ../../../libraries/KillPythonTool.robot
20 Resource          ../../../libraries/PrefixCounting.robot
21 Resource          ../../../libraries/SetupUtils.robot
22 Resource          ../../../libraries/ShardStability.robot
23 Resource          ../../../libraries/SSHKeywords.robot
24 Resource          ../../../libraries/TemplatedRequests.robot
25 Resource          ../../../variables/Variables.robot
26
27 *** Variables ***
28 ${BGP_TOOL_LOG_LEVEL}    info
29 ${BGP_PEER_FOLDER}    ${CURDIR}/../../../variables/bgpclustering/bgp_peer_openconf    # used for configuration of bgp peer via openconfig
30 ${BGP_VARIABLES_FOLDER}    ${CURDIR}/../../../variables/bgpclustering/bgp_peer    # used for configuration of bgp peer
31 ${BGP_VARIABLES_FOLDER_OP}    ${CURDIR}/../../../variables/bgpclustering/bgp_peer_operational
32 ${CHECK_PERIOD}    10
33 ${HOLDTIME}       180
34 ${INSERT}         1
35 ${KARAF_LOG_LEVEL}    INFO
36 ${KARAF_BGPCEP_LOG_LEVEL}    ${KARAF_LOG_LEVEL}
37 ${KARAF_PROTOCOL_LOG_LEVEL}    ${KARAF_BGPCEP_LOG_LEVEL}
38 ${PREFILL}        0
39 ${REPETITIONS}    1
40 ${RESULTS_FILE_NAME}    bgp.csv
41 ${TEST_DURATION_MULTIPLIER}    1
42 ${UPDATE}         single
43 ${WITHDRAW}       0
44 ${INITIAL_RESTCONF_TIMEOUT}    30s
45 ${KARAF_HOME}     ${WORKSPACE}/${BUNDLEFOLDER}
46 ${SHARD_DEFAULT_CONFIG}    shard-default-config
47 ${SHARD_DEFAULT_OPERATIONAL}    shard-default-operational
48 ${EXAMPLE_IPV4_TOPOLOGY}    example-ipv4-topology
49 ${DEVICE_NAME}    peer-controller-config
50 ${DEVICE_CHECK_TIMEOUT}    60s
51 ${RIB_INSTANCE}    example-bgp-rib
52 ${PROTOCOL_OPENCONFIG}    ${RIB_INSTANCE}
53 ${BGP_PEER_NAME}    example-bgp-peer
54 ${PEER_CHECK_URL}    /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/peer/bgp:%2F%2F
55 @{SHARD_MONITOR_LIST}    default:config    default:operational    topology:config    topology:operational    inventory:config    inventory:operational
56
57 *** Keywords ***
58 Setup_Everything
59     [Documentation]    Setup imported resources, SSH-login to tools system,
60     ...    create HTTP session, put Python tool to tools system.
61     SetupUtils.Setup_Utils_For_Setup_And_Teardown    http_timeout=125
62     PrefixCounting.PC_Setup
63     ${indices} =    ClusterManagement.List_All_Indices
64     FOR    ${member_index}    IN    @{indices}
65         ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    ${member_index}
66         BuiltIn.Set_Suite_Variable    ${operational_${member_index}}    ${session}
67     END
68     BuiltIn.Set_Suite_Variable    ${pc_all_indices}    ${indices}
69     SSHLibrary.Set_Default_Configuration    prompt=${TOOLS_SYSTEM_PROMPT}
70     SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}
71     SSHKeywords.Flexible_Mininet_Login
72     # TODO: Do not include slash in ${OPERATIONAL_TOPO_API}, having it typed here is more readable.
73     # TODO: Alternatively, create variable in Variables which starts with http.
74     # Both TODOs would probably need to update every suite relying on current Variables.
75     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/fastbgp/play.py
76     SSHKeywords.Require_Python
77     SSHKeywords.Assure_Library_Ipaddr    target_dir=.
78     # Calculate the timeout value based on how many routes are going to be pushed
79     # TODO: Replace 35 with some formula from period and repetitions.
80     ${timeout} =    BuiltIn.Evaluate    ${TEST_DURATION_MULTIPLIER} * (${COUNT} * 6.0 / 10000 + 35)
81     Builtin.Set_Suite_Variable    ${bgp_filling_timeout}    ${timeout}
82     Builtin.Set_Suite_Variable    ${bgp_emptying_timeout}    ${bgp_filling_timeout*3.0/4}
83     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${KARAF_LOG_LEVEL}
84     ${init_shard_details} =    ShardStability.Shards_Stability_Get_Details    ${SHARD_MONITOR_LIST}
85     BuiltIn.Set_Suite_Variable    ${init_shard_details}
86
87 Teardown_Everything
88     [Documentation]    Make sure Python tool was killed and tear down imported Resources.
89     # TODO:    This keyword is not specific to prefix counting. Find a better place for it.
90     # Environment issue may have dropped the SSH connection, but we do not want Teardown to fail.
91     BuiltIn.Run_Keyword_And_Ignore_Error    KillPythonTool.Search_And_Kill_Remote_Python    'play\.py'
92     RequestsLibrary.Delete_All_Sessions
93     SSHLibrary.Close_All_Connections
94
95 Start_Bgp_Peer
96     [Arguments]    ${peerip}=${rib_owner_node_id}
97     [Documentation]    Starts bgp peer and verifies that the peer runs.
98     # TODO:    This keyword is not specific to prefix counting. Find a better place for it.
99     BGPSpeaker.Start_BGP_Speaker    --amount ${COUNT} --myip=${TOOLS_SYSTEM_IP} --myport=${BGP_TOOL_PORT} --peerip=${peerip} --peerport=${ODL_BGP_PORT} --insert=${INSERT} --withdraw=${WITHDRAW} --prefill ${PREFILL} --update ${UPDATE} --${BGP_TOOL_LOG_LEVEL} --results ${RESULTS_FILE_NAME}
100
101 Start_Bgp_Peer_And_Verify_Connected
102     [Arguments]    ${connection_retries}=${1}    ${peerip}=${rib_owner_node_id}
103     [Documentation]    Starts the peer and verifies its connection. The verification is done by checking the presence
104     ...    of the peer in the bgp rib.
105     # TODO:    This keyword is not specific to prefix counting. Find a better place for it.
106     FOR    ${idx}    IN RANGE    ${connection_retries}
107         Start_Bgp_Peer    peerip=${peerip}
108         ${status}    ${value}=    BuiltIn.Run_Keyword_And_Ignore_Error    BuiltIn.Wait_Until_Keyword_Succeeds    3x    3s
109         ...    Verify_Bgp_Peer_Connection    ${config_session}    ${TOOLS_SYSTEM_IP}    connected=${True}
110         BuiltIn.Run_Keyword_Unless    "${status}" == "PASS"    BGPSpeaker.Kill_BGP_Speaker
111         BuiltIn.Return_From_Keyword_If    "${status}" == "PASS"
112     END
113     BuiltIn.Fail    Unable to connect bgp peer to ODL
114
115 Verify_Bgp_Peer_Connection
116     [Arguments]    ${session}    ${peer_ip}    ${connected}=${True}
117     [Documentation]    Checks peer presence in operational datastore
118     # TODO:    This keyword is not specific to prefix counting. Find a better place for it.
119     ${exp_status_code}=    BuiltIn.Set_Variable_If    ${connected}    ${200}    ${404}
120     ${rsp}=    RequestsLibrary.Get Request    ${session}    ${PEER_CHECK_URL}${peer_ip}
121     BuiltIn.Log    ${rsp.content}
122     BuiltIn.Should_Be_Equal_As_Numbers    ${exp_status_code}    ${rsp.status_code}
123
124 Set_Shard_Leaders_Location_And_Verify
125     [Arguments]    ${requested_shard_localtion_idx}
126     [Documentation]    Move default/topology config/operational shard location to local or remote node as requested
127     ...    towards the given rib singleton instance location.
128     ShardStability.Set_Shard_Location    ${requested_shard_localtion_idx}
129     BuiltIn.Wait_Until_Keyword_Succeeds    30s    5s    ShardStability.Verify_Shard_Leader_Located_As_Expected    ${requested_shard_localtion_idx}    http_timeout=125
130     ${init_shard_details} =    ShardStability.Shards_Stability_Get_Details    ${SHARD_MONITOR_LIST}
131     BuiltIn.Set_Suite_Variable    ${init_shard_details}