Bgpcluster tests netconf removal
[integration/test.git] / csit / suites / bgpcep / bgpclustering / 050_bgp_ha_karaf_stop.robot
1 *** Settings ***
2 Documentation     BGP functional HA testing with one exabgp peer.
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 ...               This suite uses exabgp. It is configured to have 3 peers (all 3 nodes of odl).
11 ...               Bgp implemented with singleton accepts only one incomming conection. Exabgp
12 ...               logs will show that one peer will be connected and two will fail.
13 ...               After stopping karaf which owned connection new owner should be elected and
14 ...               this new owner should accept incomming bgp connection.
15 ...               TODO: Add similar keywords from all bgpclustering-ha tests into same libraries
16 Suite Setup       Setup_Everything
17 Suite Teardown    Teardown_Everything
18 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
19 Test Teardown     SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
20 Library           SSHLibrary    timeout=10s
21 Library           RequestsLibrary
22 Resource          ../../../variables/Variables.robot
23 Resource          ../../../libraries/SetupUtils.robot
24 Resource          ../../../libraries/ClusterManagement.robot
25 Resource          ../../../libraries/SSHKeywords.robot
26 Resource          ../../../libraries/TemplatedRequests.robot
27 Resource          ../../../libraries/BGPcliKeywords.robot
28 Resource          ../../../libraries/ExaBgpLib.robot
29
30 *** Variables ***
31 ${BGP_VAR_FOLDER}    ${CURDIR}/../../../variables/bgpclustering
32 ${BGP_PEER_FOLDER}    ${CURDIR}/../../../variables/bgpclustering/bgp_peer_openconf
33 ${DEFAULT_EXA_CFG}    exa.cfg
34 ${EXA_CMD}        env exabgp.tcp.port=1790 exabgp
35 ${HOLDTIME}       180
36 ${RIB_INSTANCE}    example-bgp-rib
37
38 *** Test Cases ***
39 Get_Example_Bgp_Rib_Owner
40     [Documentation]    Find an odl node which is able to accept incomming connection.
41     ${rib_owner}    ${rib_candidates}=    BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    ClusterManagement.Get_Owner_And_Successors_For_Device    example-bgp-rib
42     ...    org.opendaylight.mdsal.ServiceEntityType    1
43     BuiltIn.Set Suite variable    ${rib_owner}
44     BuiltIn.Log    ${ODL_SYSTEM_${rib_owner}_IP}
45     BuiltIn.Set Suite variable    ${rib_candidates}
46     ${session}=    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${rib_owner}
47     BuiltIn.Set_Suite_Variable    ${living_session}    ${session}
48     BuiltIn.Set_Suite_Variable    ${living_node}    ${rib_owner}
49
50 Reconfigure_ODL_To_Accept_Connection
51     [Documentation]    Configure BGP peer module with initiate-connection set to false.
52     [Setup]    SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
53     &{mapping}    Create Dictionary    IP=${TOOLS_SYSTEM_IP}    HOLDTIME=${HOLDTIME}    PEER_PORT=${BGP_TOOL_PORT}    PASSIVE_MODE=true    BGP_RIB_OPENCONFIG=${RIB_INSTANCE}
54     TemplatedRequests.Put_As_Xml_Templated    ${BGP_PEER_FOLDER}    mapping=${mapping}    session=${living_session}    http_timeout=5
55     [Teardown]    SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
56
57 Start_ExaBgp_Peer
58     [Documentation]    Starts exabgp
59     SSHKeywords.Virtual_Env_Activate_On_Current_Session    log_output=${True}
60     BGPcliKeywords.Start_Console_Tool    ${EXA_CMD}    ${DEFAULT_EXA_CFG}
61
62 Verify_ExaBgp_Connected
63     [Documentation]    Verifies exabgp's presence in operational ds.
64     BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    ExaBgpLib.Verify_ExaBgps_Connection    ${living_session}
65
66 Stop_Current_Owner_Member
67     [Documentation]    Stopping karaf which is connected with exabgp.
68     Kill_Single_Member    ${rib_owner}
69     BuiltIn.Set Suite variable    ${old_rib_owner}    ${rib_owner}
70     BuiltIn.Set Suite variable    ${old_rib_candidates}    ${rib_candidates}
71     ${idx}=    Collections.Get From List    ${old_rib_candidates}    0
72     ${session}=    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${idx}
73     BuiltIn.Set_Suite_Variable    ${living_session}    ${session}
74     BuiltIn.Set_Suite_Variable    ${living_node}    ${idx}
75
76 Verify_New_Rib_Owner
77     [Documentation]    Verifies if new owner of example-bgp-rib is elected.
78     BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    Verify_New_Rib_Owner_Elected    ${old_rib_owner}    ${living_node}
79
80 Verify_ExaBgp_Reconnected
81     [Documentation]    Verifies exabgp's presence in operational ds.
82     BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    ExaBgpLib.Verify_ExaBgps_Connection    ${living_session}
83
84 Start_Stopped_Member
85     [Documentation]    Starting stopped node
86     Start_Single_Member    ${old_rib_owner}
87
88 Verify_New_Candidate
89     [Documentation]    Verifies started node become candidate for example-bgp-rib
90     BuiltIn.Wait_Until_Keyword_Succeeds    10x    5s    Verify_New_Rib_Candidate_Present    ${old_rib_owner}    ${living_node}
91
92 Verify_ExaBgp_Still_Connected
93     [Documentation]    Verifies exabgp's presence in operational ds
94     BuiltIn.Wait_Until_Keyword_Succeeds    5x    2s    ExaBgpLib.Verify_ExaBgps_Connection    ${living_session}
95
96 Stop_ExaBgp_Peer
97     [Documentation]    Stops exabgp tool by sending ctrl+c
98     BGPcliKeywords.Stop_Console_Tool_And_Wait_Until_Prompt
99     SSHKeywords.Virtual_Env_Deactivate_On_Current_Session    log_output=${True}
100
101 Delete_Bgp_Peer_Configuration
102     [Documentation]    Revert the BGP configuration to the original state: without any configured peers
103     &{mapping}    Create Dictionary    BGP_RIB_OPENCONFIG=${RIB_INSTANCE}    IP=${TOOLS_SYSTEM_IP}
104     TemplatedRequests.Delete_Templated    ${BGP_PEER_FOLDER}    mapping=${mapping}    session=${living_session}    http_timeout=5
105
106 *** Keywords ***
107 Setup_Everything
108     [Documentation]    Initial setup
109     SetupUtils.Setup_Utils_For_Setup_And_Teardown
110     ClusterManagement.ClusterManagement_Setup
111     ${tools_system_conn_id}=    SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}    prompt=${DEFAULT_LINUX_PROMPT}    timeout=6s
112     Builtin.Set_Suite_Variable    ${tools_system_conn_id}
113     SSHKeywords.Flexible_Mininet_Login    ${TOOLS_SYSTEM_USER}
114     SSHKeywords.Virtual_Env_Create
115     SSHKeywords.Virtual_Env_Install_Package    exabgp==3.4.16
116     ExaBgpLib.Upload_ExaBgp_Cluster_Config_Files    ${BGP_VAR_FOLDER}    ${DEFAULT_EXA_CFG}
117
118 Teardown_Everything
119     [Documentation]    Suite cleanup
120     SSHKeywords.Virtual_Env_Delete
121     RequestsLibrary.Delete_All_Sessions
122     SSHLibrary.Close_All_Connections
123
124 Verify_New_Rib_Owner_Elected
125     [Arguments]    ${old_owner}    ${node_to_ask}
126     [Documentation]    Verifies new owner was elected
127     ${owner}    ${candidates}=    ClusterManagement.Get_Owner_And_Successors_For_device    example-bgp-rib    org.opendaylight.mdsal.ServiceEntityType    ${node_to_ask}
128     BuiltIn.Should_Not_Be_Equal    ${old_owner}    ${owner}
129
130 Verify_New_Rib_Candidate_Present
131     [Arguments]    ${candidate}    ${node_to_ask}
132     [Documentation]    Verifies candidate's presence.
133     ${owner}    ${candidates}=    ClusterManagement.Get_Owner_And_Successors_For_device    example-bgp-rib    org.opendaylight.mdsal.ServiceEntityType    ${node_to_ask}
134     BuiltIn.Should_Contain    ${candidates}    ${candidate}