2 Documentation BGP functional HA testing with one exabgp peer.
4 ... Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
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 killing karaf which owned connection new owner should be elected and
14 ... this new owner should accept incomming bgp connection.
15 Suite Setup Setup_Everything
16 Suite Teardown Teardown_Everything
17 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
18 Test Teardown SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
19 Library SSHLibrary timeout=10s
20 Library RequestsLibrary
21 Variables ${CURDIR}/../../../variables/Variables.py
22 Resource ${CURDIR}/../../../libraries/SetupUtils.robot
23 Resource ${CURDIR}/../../../libraries/ClusterManagement.robot
24 Resource ${CURDIR}/../../../libraries/SSHKeywords.robot
25 Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot
28 ${BGP_VAR_FOLDER} ${CURDIR}/../../../variables/bgpclustering
29 ${BGP_PEER_FOLDER} ${CURDIR}/../../../variables/bgpclustering/bgp_peer_openconf
30 ${DEFAUTL_EXA_CFG} exa.cfg
31 ${EXA_CMD} env exabgp.tcp.port=1790 exabgp
32 ${PEER_CHECK_URL} /restconf/operational/bgp-rib:bgp-rib/rib/example-bgp-rib/peer/bgp:%2F%2F
34 ${RIB_INSTANCE} example-bgp-rib
37 Get Example Bgp Rib Owner
38 [Documentation] Find an odl node which is able to accept incomming connection. To this node netconf connector should be configured.
39 ${rib_owner} ${rib_candidates}= ClusterManagement.Get_Owner_And_Successors_For_device example-bgp-rib org.opendaylight.mdsal.ServiceEntityType 1
40 BuiltIn.Set Suite variable ${rib_owner} ${rib_owner}
41 BuiltIn.Set Suite variable ${rib_owner_node_id} ${ODL_SYSTEM_${rib_owner}_IP}
42 BuiltIn.Set Suite variable ${rib_candidates} ${rib_candidates}
43 ${session}= Resolve_Http_Session_For_Member member_index=${rib_owner}
44 BuiltIn.Set_Suite_Variable ${living_session} ${session}
45 BuiltIn.Set_Suite_Variable ${living_node} ${rib_owner}
47 Reconfigure_ODL_To_Accept_Connection
48 [Documentation] Configure BGP peer module with initiate-connection set to false.
49 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
50 &{mapping} Create Dictionary IP=${TOOLS_SYSTEM_IP} HOLDTIME=${HOLDTIME} PEER_PORT=${BGP_TOOL_PORT} PASSIVE_MODE=true BGP_RIB_OPENCONFIG=${RIB_INSTANCE}
51 TemplatedRequests.Put_As_Xml_Templated ${BGP_PEER_FOLDER} mapping=${mapping} session=${living_session}
52 [Teardown] SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
55 [Documentation] Starts exabgp
56 Start_Tool ${DEFAUTL_EXA_CFG}
58 Verify ExaBgp Connected
59 [Documentation] Verifies exabgp's presence in operational ds.
60 BuiltIn.Wait_Until_Keyword_Succeeds 5x 2s Verify_Tools_Connection ${living_session}
62 Isolate_Current_Owner_Member
63 [Documentation] Isolating cluster node which is connected with exabgp.
64 ClusterManagement.Isolate_Member_From_List_Or_All ${rib_owner}
65 BuiltIn.Set Suite variable ${old_rib_owner} ${rib_owner}
66 BuiltIn.Set Suite variable ${old_rib_candidates} ${rib_candidates}
67 ${idx}= Collections.Get From List ${old_rib_candidates} 0
68 ${session}= Resolve_Http_Session_For_Member member_index=${idx}
69 BuiltIn.Set_Suite_Variable ${living_session} ${session}
70 BuiltIn.Set_Suite_Variable ${living_node} ${idx}
73 [Documentation] Verifies if new owner of example-bgp-rib is elected.
74 BuiltIn.Wait_Until_Keyword_Succeeds 5x 2s Verify_New_Rib_Owner_Elected ${old_rib_owner} ${living_node}
76 Verify_ExaBgp_Reconnected
77 [Documentation] Verifies exabgp's presence in operational ds.
78 BuiltIn.Wait_Until_Keyword_Succeeds 5x 2s Verify_Tools_Connection ${living_session}
80 Rejoin_Isolated_Member
81 [Documentation] Rejoin isolated node
82 ClusterManagement.Rejoin_Member_From_List_Or_All ${old_rib_owner}
85 [Documentation] Verifies started node become candidate for example-bgp-rib
86 BuiltIn.Wait_Until_Keyword_Succeeds 10x 5s Verify_New_Rib_Candidate_Present ${old_rib_owner} ${living_node}
88 Verify ExaBgp Still Connected
89 [Documentation] Verifies exabgp's presence in operational ds
90 Verify_Tools_Connection ${living_session}
93 [Documentation] Stops exabgp
96 Delete_Bgp_Peer_Configuration
97 [Documentation] Revert the BGP configuration to the original state: without any configured peers
98 &{mapping} Create Dictionary BGP_RIB_OPENCONFIG=${RIB_INSTANCE} IP=${TOOLS_SYSTEM_IP}
99 TemplatedRequests.Delete_Templated ${BGP_PEER_FOLDER} mapping=${mapping} session=${living_session}
103 [Documentation] Initial setup
104 SetupUtils.Setup_Utils_For_Setup_And_Teardown
105 ClusterManagement.ClusterManagement_Setup
106 ${tools_system_conn_id}= SSHLibrary.Open_Connection ${TOOLS_SYSTEM_IP} prompt=${DEFAULT_LINUX_PROMPT} timeout=6s
107 Builtin.Set_Suite_Variable ${tools_system_conn_id}
108 Utils.Flexible_Mininet_Login ${TOOLS_SYSTEM_USER}
109 SSHKeywords.Virtual_Env_Create
110 SSHKeywords.Virtual_Env_Install_Package exabgp==3.4.16
114 [Documentation] Suite cleanup
115 SSHKeywords.Virtual_Env_Delete
116 RequestsLibrary.Delete_All_Sessions
117 SSHLibrary.Close_All_Connections
120 [Arguments] ${cfg_file} ${mapping}={}
121 [Documentation] Starts the tool
122 ${start_cmd} BuiltIn.Set_Variable ${EXA_CMD} ${cfg_file}
123 BuiltIn.Log ${start_cmd}
124 SSHKeywords.Virtual_Env_Activate_On_Current_Session log_output=${True}
125 ${output}= SSHLibrary.Write ${start_cmd}
126 BuiltIn.Log ${output}
129 [Documentation] Stops the tool by sending ctrl+c
130 ${output}= SSHLibrary.Read
131 BuiltIn.Log ${output}
132 Utils.Write_Bare_Ctrl_C
133 ${output}= SSHLibrary.Read_Until_Prompt
134 BuiltIn.Log ${output}
135 SSHKeywords.Virtual_Env_Deactivate_On_Current_Session log_output=${True}
138 [Documentation] Uploads exabgp config files.
139 SSHLibrary.Put_File ${BGP_VAR_FOLDER}/${DEFAUTL_EXA_CFG} .
140 @{cfgfiles}= SSHLibrary.List_Files_In_Directory . *.cfg
141 : FOR ${cfgfile} IN @{cfgfiles}
142 \ SSHLibrary.Execute_Command sed -i -e 's/EXABGPIP/${TOOLS_SYSTEM_IP}/g' ${cfgfile}
143 \ SSHLibrary.Execute_Command sed -i -e 's/ODLIP1/${ODL_SYSTEM_1_IP}/g' ${cfgfile}
144 \ SSHLibrary.Execute_Command sed -i -e 's/ODLIP2/${ODL_SYSTEM_2_IP}/g' ${cfgfile}
145 \ SSHLibrary.Execute_Command sed -i -e 's/ODLIP3/${ODL_SYSTEM_3_IP}/g' ${cfgfile}
146 \ SSHLibrary.Execute_Command sed -i -e 's/ROUTEREFRESH/disable/g' ${cfgfile}
147 \ SSHLibrary.Execute_Command sed -i -e 's/ADDPATH/disable/g' ${cfgfile}
148 \ ${stdout}= SSHLibrary.Execute_Command cat ${cfgfile}
151 Verify_New_Rib_Owner_Elected
152 [Arguments] ${old_owner} ${node_to_ask}
153 [Documentation] Verifies new owner was elected
154 ${owner} ${candidates}= ClusterManagement.Get_Owner_And_Successors_For_device example-bgp-rib org.opendaylight.mdsal.ServiceEntityType ${node_to_ask}
155 BuiltIn.Should_Not_Be_Equal ${old_owner} ${owner}
157 Verify_New_Rib_Candidate_Present
158 [Arguments] ${candidate} ${node_to_ask}
159 [Documentation] Verifies candidate's presence.
160 ${owner} ${candidates}= ClusterManagement.Get_Owner_And_Successors_For_device example-bgp-rib org.opendaylight.mdsal.ServiceEntityType ${node_to_ask}
161 BuiltIn.Should_Contain ${candidates} ${candidate}
163 Verify_Tools_Connection
164 [Arguments] ${session} ${connected}=${True}
165 [Documentation] Checks peer presence in operational datastore
166 ${exp_status_code}= BuiltIn.Set_Variable_If ${connected} ${200} ${404}
167 ${rsp}= RequestsLibrary.Get Request ${session} ${PEER_CHECK_URL}${TOOLS_SYSTEM_IP}
168 BuiltIn.Log ${rsp.content}
169 BuiltIn.Should_Be_Equal_As_Numbers ${exp_status_code} ${rsp.status_code}