bgp prefixcount suite with nonreplicated bgp_rib
[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 Library           SSHLibrary    timeout=10s
10 Library           RequestsLibrary
11 Variables         ${CURDIR}/../../../variables/Variables.py
12 Resource          ${CURDIR}/../../../libraries/BGPSpeaker.robot
13 Resource          ${CURDIR}/../../../libraries/BGPcliKeywords.robot
14 Resource          ${CURDIR}/../../../libraries/FailFast.robot
15 Resource          ${CURDIR}/../../../libraries/KillPythonTool.robot
16 Resource          ${CURDIR}/../../../libraries/PrefixCounting.robot
17 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
18 Resource          ${CURDIR}/../../../libraries/ClusterManagement.robot
19 Resource          ${CURDIR}/../../../libraries/SSHKeywords.robot
20 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
21
22 *** Variables ***
23 ${BGP_TOOL_LOG_LEVEL}    info
24 ${BGP_PEER_FOLDER}    ${CURDIR}/../../../variables/bgpfunctional/openconfig_bgp_peer    # used for configuration of bgp peer via openconfig
25 ${BGP_VARIABLES_FOLDER}    ${CURDIR}/../../../variables/bgpclustering/bgp_peer    # used for configuration of bgp peer vie netconf connector
26 ${BGP_VARIABLES_FOLDER_OP}    ${CURDIR}/../../../variables/bgpclustering/bgp_peer_operational
27 ${NETCONF_DEV_FOLDER}    ${CURDIR}/../../../variables/netconf/device/full-uri-device
28 ${NETCONF_MOUNT_FOLDER}    ${CURDIR}/../../../variables/netconf/device/full-uri-mount
29 ${CHECK_PERIOD}    10
30 ${HOLDTIME}       180
31 ${INSERT}         1
32 ${KARAF_LOG_LEVEL}    INFO
33 ${KARAF_BGPCEP_LOG_LEVEL}    ${KARAF_LOG_LEVEL}
34 ${KARAF_PROTOCOL_LOG_LEVEL}    ${KARAF_BGPCEP_LOG_LEVEL}
35 ${PREFILL}        0
36 ${REPETITIONS}    1
37 ${RESULTS_FILE_NAME}    bgp.csv
38 ${TEST_DURATION_MULTIPLIER}    1
39 ${UPDATE}         single
40 ${WITHDRAW}       0
41 ${INITIAL_RESTCONF_TIMEOUT}    30s
42 ${KARAF_HOME}     ${WORKSPACE}/${BUNDLEFOLDER}
43 ${SHARD_DEFAULT_CONFIG}    shard-default-config
44 ${SHARD_DEFAULT_OPERATIONAL}    shard-default-operational
45 ${CONFIG_SESSION}    config-session
46 ${CONFIGURATION_1}    operational-1
47 ${CONFIGURATION_2}    operational-2
48 ${CONFIGURATION_3}    operational-3
49 ${EXAMPLE_IPV4_TOPOLOGY}    example-ipv4-topology
50 ${DEVICE_NAME}    peer-controller-config
51 ${DEVICE_CHECK_TIMEOUT}    60s
52 ${RIB_INSTANCE}    example-bgp-rib
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
56 *** Keywords ***
57 Setup_Everything
58     [Documentation]    Setup imported resources, SSH-login to tools system,
59     ...    create HTTP session, put Python tool to tools system.
60     SetupUtils.Setup_Utils_For_Setup_And_Teardown
61     RequestsLibrary.Create_Session    ${CONFIGURATION_1}    http://${ODL_SYSTEM_1_IP}:${RESTCONFPORT}${OPERATIONAL_API}    auth=${AUTH}
62     RequestsLibrary.Create_Session    ${CONFIGURATION_2}    http://${ODL_SYSTEM_2_IP}:${RESTCONFPORT}${OPERATIONAL_API}    auth=${AUTH}
63     RequestsLibrary.Create_Session    ${CONFIGURATION_3}    http://${ODL_SYSTEM_3_IP}:${RESTCONFPORT}${OPERATIONAL_API}    auth=${AUTH}
64     PrefixCounting.PC_Setup
65     SSHLibrary.Set_Default_Configuration    prompt=${TOOLS_SYSTEM_PROMPT}
66     SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}
67     Utils.Flexible_Mininet_Login
68     # TODO: Do not include slash in ${OPERATIONAL_TOPO_API}, having it typed here is more readable.
69     # TODO: Alternatively, create variable in Variables which starts with http.
70     # Both TODOs would probably need to update every suite relying on current Variables.
71     SSHLibrary.Put_File    ${CURDIR}/../../../../tools/fastbgp/play.py
72     SSHKeywords.Require_Python
73     SSHKeywords.Assure_Library_Ipaddr    target_dir=.
74     # Calculate the timeout value based on how many routes are going to be pushed
75     # TODO: Replace 35 with some formula from period and repetitions.
76     ${timeout} =    BuiltIn.Evaluate    ${TEST_DURATION_MULTIPLIER} * (${COUNT} * 6.0 / 10000 + 35)
77     Builtin.Set_Suite_Variable    ${bgp_filling_timeout}    ${timeout}
78     Builtin.Set_Suite_Variable    ${bgp_emptying_timeout}    ${bgp_filling_timeout*3.0/4}
79     KarafKeywords.Execute_Controller_Karaf_Command_On_Background    log:set ${KARAF_LOG_LEVEL}
80
81 Teardown_Everything
82     [Documentation]    Make sure Python tool was killed and tear down imported Resources.
83     # Environment issue may have dropped the SSH connection, but we do not want Teardown to fail.
84     BuiltIn.Run_Keyword_And_Ignore_Error    KillPythonTool.Search_And_Kill_Remote_Python    'play\.py'
85     RequestsLibrary.Delete_All_Sessions
86     SSHLibrary.Close_All_Connections
87
88 Configure_Netconf_Device_And_Check_Mounted
89     [Arguments]    ${mapping}
90     [Documentation]    Configures netconf device
91     TemplatedRequests.Put_As_Xml_Templated    ${NETCONF_DEV_FOLDER}    mapping=${mapping}    session=${CONFIG_SESSION}
92     BuiltIn.Wait_Until_Keyword_Succeeds    10x    3s    TemplatedRequests.Get_As_Xml_Templated    ${NETCONF_MOUNT_FOLDER}    mapping=${mapping}    session=${CONFIG_SESSION}
93
94 Start_Bgp_Peer
95     [Arguments]    ${peerip}=${rib_owner_node_id}
96     [Documentation]    Starts bgp peer and verifies that the peer runs.
97     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}
98
99 Start_Bgp_Peer_And_Verify_Connected
100     [Arguments]    ${connection_retries}=${1}    ${peerip}=${rib_owner_node_id}
101     [Documentation]    Starts the peer and verifies its connection. The verification is done by checking the presence
102     ...    of the peer in the bgp rib.
103     : FOR    ${idx}    IN RANGE    ${connection_retries}
104     \    Start_Bgp_Peer    peerip=${peerip}
105     \    ${status}    ${value}=    BuiltIn.Run_Keyword_And_Ignore_Error    BuiltIn.Wait_Until_Keyword_Succeeds    3x    3s
106     \    ...    Verify_Bgp_Peer_Connection    ${CONFIG_SESSION}    ${TOOLS_SYSTEM_IP}    connected=${True}
107     \    BuiltIn.Run_Keyword_Unless    "${status}" == "PASS"    BGPSpeaker.Kill_BGP_Speaker
108     \    BuiltIn.Return_From_Keyword_If    "${status}" == "PASS"
109     BuiltIn.Fail    Unable to connect bgp peer to ODL
110
111 Verify_Bgp_Peer_Connection
112     [Arguments]    ${session}    ${peer_ip}    ${connected}=${True}
113     [Documentation]    Checks peer presence in operational datastore
114     ${exp_status_code}=    BuiltIn.Set_Variable_If    ${connected}    ${200}    ${404}
115     ${rsp}=    RequestsLibrary.Get Request    ${session}    ${PEER_CHECK_URL}${peer_ip}
116     BuiltIn.Log    ${rsp.content}
117     BuiltIn.Should_Be_Equal_As_Numbers    ${exp_status_code}    ${rsp.status_code}