2 Documentation Resource housing Keywords common to several suites for cluster functional testing.
4 ... Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
5 ... Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved.
7 ... This program and the accompanying materials are made available under the
8 ... terms of the Eclipse Public License v1.0 which accompanies this distribution,
9 ... and is available at http://www.eclipse.org/legal/epl-v10.html
12 ... This resource holds private state (in suite variables),
13 ... which is generated once at Setup with ClusterManagement_Setup KW.
14 ... The state includes member indexes, IP addresses and Http (RequestsLibrary) sessions.
15 ... Cluster Keywords normally use member index, member list or nothing (all members) as argument.
17 ... All index lists returned should be sorted numerically, fix if not.
20 ... odl-jolokia is assumed to be installed.
22 ... Keywords are ordered as follows:
24 ... - Shard state, leader and followers
25 ... - Entity Owner, candidates and successors
26 ... - Kill, Stop and Start Member
27 ... - Isolate and Rejoin Member
28 ... - Run Commands On Member
29 ... - REST requests and checks on Members
31 ... TODO: Unify capitalization of Leaders and Followers.
32 Library RequestsLibrary # for Create_Session and To_Json
34 Resource ${CURDIR}/CompareStream.robot
35 Resource ${CURDIR}/KarafKeywords.robot
36 Resource ${CURDIR}/SSHKeywords.robot
37 Resource ${CURDIR}/TemplatedRequests.robot # for Get_As_Json_From_Uri
38 Resource ${CURDIR}/Utils.robot # for Run_Command_On_Controller
41 ${ENTITY_OWNER_URI} restconf/operational/entity-owners:entity-owners
42 ${JAVA_HOME} ${EMPTY} # releng/builder scripts should provide correct value
43 ${JOLOKIA_CONF_SHARD_MANAGER_URI} jolokia/read/org.opendaylight.controller:Category=ShardManager,name=shard-manager-config,type=DistributedConfigDatastore
44 ${JOLOKIA_OPER_SHARD_MANAGER_URI} jolokia/read/org.opendaylight.controller:Category=ShardManager,name=shard-manager-operational,type=DistributedOperationalDatastore
45 ${JOLOKIA_READ_URI} jolokia/read/org.opendaylight.controller
46 ${KARAF_HOME} ${WORKSPACE}${/}${BUNDLEFOLDER} # TODO: Migrate to Variables.robot
47 @{ODL_DEFAULT_DATA_PATHS} tmp/ data/ cache/ snapshots/ journal/ etc/opendaylight/current/
48 ${RESTCONF_MODULES_DIR} ${CURDIR}/../variables/restconf/modules
49 ${SINGLETON_NETCONF_DEVICE_ID_PREFIX} /odl-general-entity:entity[odl-general-entity:name='KeyedInstanceIdentifier{targetType=interface org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node, path=[org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology, org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology[key=TopologyKey [_topologyId=Uri [_value=topology-netconf]]], org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node[key=NodeKey [_nodeId=Uri [_value=
50 ${SINGLETON_NETCONF_DEVICE_ID_SUFFIX} ]]]]}']
51 ${SINGLETON_ELECTION_ENTITY_TYPE} org.opendaylight.mdsal.ServiceEntityType
52 ${SINGLETON_CHANGE_OWNERSHIP_ENTITY_TYPE} org.opendaylight.mdsal.AsyncServiceCloseEntityType
53 ${NODE_START_COMMAND} ${KARAF_HOME}/bin/start
54 ${NODE_STOP_COMMAND} ${KARAF_HOME}/bin/stop
55 ${NODE_KILL_COMMAND} ps axf | grep org.apache.karaf | grep -v grep | awk '{print \"kill -9 \" $1}' | sh
58 ClusterManagement_Setup
59 [Documentation] Detect repeated call, or detect number of members and initialize derived suite variables.
60 # Avoid multiple initialization by several downstream libraries.
61 ${already_done} = BuiltIn.Get_Variable_Value \${ClusterManagement__has_setup_run} False
62 BuiltIn.Return_From_Keyword_If ${already_done}
63 BuiltIn.Set_Suite_Variable \${ClusterManagement__has_setup_run} True
64 ${cluster_size} = BuiltIn.Get_Variable_Value \${NUM_ODL_SYSTEM} 1
65 ${status} ${possibly_int_of_members} = BuiltIn.Run_Keyword_And_Ignore_Error BuiltIn.Convert_To_Integer ${cluster_size}
66 ${int_of_members} = BuiltIn.Set_Variable_If '${status}' != 'PASS' ${1} ${possibly_int_of_members}
67 ClusterManagement__Compute_Derived_Variables int_of_members=${int_of_members}
69 Check_Cluster_Is_In_Sync
70 [Arguments] ${member_index_list}=${EMPTY}
71 [Documentation] Fail if no-sync is detected on a member from list (or any).
72 ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list}
73 : FOR ${index} IN @{index_list} # usually: 1, 2, 3.
74 \ ${status} = Get_Sync_Status_Of_Member member_index=${index}
75 \ BuiltIn.Continue_For_Loop_If 'True' == '${status}'
76 \ BuiltIn.Fail Index ${index} has incorrect status: ${status}
78 Get_Sync_Status_Of_Member
79 [Arguments] ${member_index}
80 [Documentation] Obtain IP, two GETs from jolokia URIs, return combined sync status as string.
81 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
82 ${conf_text} = TemplatedRequests.Get_As_Json_From_Uri uri=${JOLOKIA_CONF_SHARD_MANAGER_URI} session=${session}
83 ${conf_status} = ClusterManagement__Parse_Sync_Status shard_manager_text=${conf_text}
84 BuiltIn.Return_From_Keyword_If 'False' == ${conf_status} False
85 ${oper_text} = TemplatedRequests.Get_As_Json_From_Uri uri=${JOLOKIA_OPER_SHARD_MANAGER_URI} session=${session}
86 ${oper_status} = ClusterManagement__Parse_Sync_Status shard_manager_text=${oper_text}
87 [Return] ${oper_status}
89 Verify_Leader_Exists_For_Each_Shard
90 [Arguments] ${shard_name_list} ${shard_type}=operational ${member_index_list}=${EMPTY} ${verify_restconf}=True
91 [Documentation] For each shard name, call Get_Leader_And_Followers_For_Shard.
92 ... Not much logic there, but single Keyword is useful when using BuiltIn.Wait_Until_Keyword_Succeeds.
93 : FOR ${shard_name} IN @{shard_name_list}
94 \ Get_Leader_And_Followers_For_Shard shard_name=${shard_name} shard_type=${shard_type} validate=True member_index_list=${member_index_list} verify_restconf=${verify_restconf}
96 Get_Leader_And_Followers_For_Shard
97 [Arguments] ${shard_name}=default ${shard_type}=operational ${validate}=True ${member_index_list}=${EMPTY} ${verify_restconf}=True
98 [Documentation] Get role lists, validate there is one leader, return the leader and list of followers.
99 ... Optionally, issue GET to a simple restconf URL to make sure subsequent operations will not encounter 503.
100 ${leader_list} ${follower_list} = Get_State_Info_For_Shard shard_name=${shard_name} shard_type=${shard_type} validate=True member_index_list=${member_index_list}
101 ... verify_restconf=${verify_restconf}
102 ${leader_count} = BuiltIn.Get_Length ${leader_list}
103 BuiltIn.Run_Keyword_If ${leader_count} < 1 BuiltIn.Fail No leader found.
104 BuiltIn.Length_Should_Be ${leader_list} ${1} Too many Leaders.
105 ${leader} = Collections.Get_From_List ${leader_list} 0
106 [Return] ${leader} ${follower_list}
108 Get_State_Info_For_Shard
109 [Arguments] ${shard_name}=default ${shard_type}=operational ${validate}=False ${member_index_list}=${EMPTY} ${verify_restconf}=False
110 [Documentation] Return lists of Leader and Follower member indices from a given member index list
111 ... (or from the full list if empty). If \${shard_type} is not 'config', 'operational' is assumed.
112 ... If \${validate}, Fail if raft state is not Leader or Follower (for example on Candidate).
113 ... The biggest difference from Get_Leader_And_Followers_For_Shard
114 ... is that no check on number of Leaders is performed.
115 ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list}
116 Collections.Sort_List ${index_list} # to guarantee return values are also sorted lists
117 # TODO: Support alternative capitalization of 'config'?
118 ${ds_type} = BuiltIn.Set_Variable_If '${shard_type}' != 'config' operational config
119 ${leader_list} = BuiltIn.Create_List
120 ${follower_list} = BuiltIn.Create_List
121 : FOR ${index} IN @{index_list} # usually: 1, 2, 3.
122 \ ${raft_state} = Get_Raft_State_Of_Shard_At_Member shard_name=${shard_name} shard_type=${ds_type} member_index=${index} verify_restconf=${verify_restconf}
123 \ BuiltIn.Run_Keyword_If 'Follower' == '${raft_state}' Collections.Append_To_List ${follower_list} ${index}
124 \ ... ELSE IF 'Leader' == '${raft_state}' Collections.Append_To_List ${leader_list} ${index}
125 \ ... ELSE IF ${validate} BuiltIn.Fail Unrecognized Raft state: ${raft_state}
126 [Return] ${leader_list} ${follower_list}
128 Get_Raft_State_Of_Shard_At_Member
129 [Arguments] ${shard_name} ${shard_type} ${member_index} ${verify_restconf}=False
130 [Documentation] Send request to Jolokia on indexed member, return extracted Raft status.
131 ... Optionally, check restconf works.
132 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
133 # TODO: Does the used URI tend to generate large data which floods log.html?
134 BuiltIn.Run_Keyword_If ${verify_restconf} TemplatedRequests.Get_As_Json_Templated session=${session} folder=${RESTCONF_MODULES_DIR} verify=False
135 ${type_class} = Resolve_Shard_Type_Class shard_type=${shard_type}
136 ${uri} = BuiltIn.Set_Variable ${JOLOKIA_READ_URI}:Category=Shards,name=member-${member_index}-shard-${shard_name}-${shard_type},type=${type_class}
137 ${data_text} = TemplatedRequests.Get_As_Json_From_Uri uri=${uri} session=${session}
138 ${data_object} = RequestsLibrary.To_Json ${data_text}
139 ${value} = Collections.Get_From_Dictionary ${data_object} value
140 ${raft_state} = Collections.Get_From_Dictionary ${value} RaftState
141 [Return] ${raft_state}
143 Verify_Shard_Leader_Elected
144 [Arguments] ${shard_name} ${shard_type} ${new_elected} ${old_leader} ${member_index_list}=${EMPTY}
145 [Documentation] Verify new leader was elected or remained the same. Bool paramter ${new_elected} indicates if
146 ... new leader is elected or should remained the same as ${old_leader}
147 ${leader} ${followers}= Get_Leader_And_Followers_For_Shard shard_name=${shard_name} shard_type=${shard_type} member_index_list=${member_index_list}
148 BuiltIn.Run_Keyword_If ${new_elected} BuiltIn.Should_Not_Be_Equal_As_Numbers ${old_leader} ${leader}
149 BuiltIn.Run_Keyword_Unless ${new_elected} BuiltIn.Should_Be_Equal_As_numbers ${old_leader} ${leader}
150 BuiltIn.Return_From_Keyword ${leader} ${followers}
152 Verify_Owner_And_Successors_For_Device
153 [Arguments] ${device_name} ${device_type} ${member_index} ${candidate_list}=${EMPTY} ${after_stop}=False
154 [Documentation] Returns the owner and successors for the SB device ${device_name} of type ${device_type}. Request is sent to member ${member_index}.
155 ... For Boron and beyond, candidates are not removed on node down or isolation,
156 ... so this keyword expects candidates to be all members from Boron on.
157 ... Extra check is done to verify owner and successors are within the ${candidate_list}. This KW is useful when combined with WUKS.
158 ... ${candidate_list} minus owner is returned as ${successor list}.
159 ... Users can still use Get_Owner_And_Successors_For_Device if they are interested in downed candidates,
160 ... or for testing heterogeneous clusters.
161 ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${candidate_list}
162 ${owner} ${successor_list} = Get_Owner_And_Successors_For_Device device_name=${device_name} device_type=${device_type} member_index=${member_index}
163 Collections.List_Should_Contain_Value ${index_list} ${owner} Owner ${owner} is not in candidate list ${index_list}
164 # In Beryllium or after stopping an instance, the removed instance does not show in the candidate list.
165 ${expected_candidate_list_origin} = BuiltIn.Set_Variable_If '${ODL_STREAM}' == 'beryllium' or ${after_stop} ${index_list} ${ClusterManagement__member_index_list}
166 # We do not want to manipulate either origin list.
167 ${expected_successor_list} = BuiltIn.Create_List @{expected_candidate_list_origin}
168 Collections.Remove_Values_From_List ${expected_successor_list} ${owner}
169 Collections.Lists_Should_Be_Equal ${expected_successor_list} ${successor_list} Successor list ${successor_list} is not the came as expected ${expected_successor_list}
170 # User expects the returned successor list to be the provided candidate list minus the owner.
171 Collections.Remove_Values_From_List ${index_list} ${owner}
172 [Return] ${owner} ${index_list}
174 Get_Owner_And_Successors_For_Device
175 [Arguments] ${device_name} ${device_type} ${member_index}
176 [Documentation] Returns the owner and a list of successors for the SB device ${device_name} of type ${device_type}. Request is sent to member ${member_index}.
177 ... Successors are those device candidates not elected as owner. The list of successors = (list of candidates) - (owner).
178 ... The returned successor list is sorted numerically.
179 ... Note that "candidate list" definition currently differs between Beryllium and Boron.
180 ... Use Verify_Owner_And_Successors_For_Device if you want the older semantics (inaccessible nodes not present in the list).
181 ${owner} ${candidate_list} = Get_Owner_And_Candidates_For_Device device_name=${device_name} device_type=${device_type} member_index=${member_index}
182 ${successor_list} = BuiltIn.Create_List @{candidate_list} # Copy operation is not required, but new variable name requires a line anyway.
183 Collections.Remove_Values_From_List ${successor_list} ${owner}
184 [Return] ${owner} ${successor_list}
186 Get_Owner_And_Candidates_For_Device_Old
187 [Arguments] ${device_name} ${device_type} ${member_index}
188 [Documentation] Returns the owner and a list of candidates for the SB device ${device_name} of type ${device_type}. Request is sent to member ${member_index}.
189 ... Candidates are all members that register to own a device, so the list of candiates includes the owner.
190 ... The returned candidate list is sorted numerically.
191 ... Note that "candidate list" definition currently differs between Beryllium and Boron.
192 ... It is recommended to use Get_Owner_And_Successors_For_Device instead of this keyword, see documentation there.
193 BuiltIn.Comment TODO: Can this implementation be changed to call Get_Owner_And_Candidates_For_Type_And_Id?
194 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
195 ${data} = TemplatedRequests.Get_As_Json_From_Uri uri=${ENTITY_OWNER_URI} session=${session}
196 ${candidate_list} = BuiltIn.Create_List
197 ${entity_type} = BuiltIn.Set_Variable_If '${device_type}' == 'netconf' netconf-node/${device_name} ${device_type}
198 ${clear_data} = BuiltIn.Run_Keyword_If '${device_type}' == 'openflow' or '${device_type}' == 'netconf' Extract_OpenFlow_Device_Data ${data}
199 ... ELSE IF '${device_type}' == 'ovsdb' Extract_Ovsdb_Device_Data ${data}
200 ... ELSE IF '${device_type}' == 'org.opendaylight.mdsal.ServiceEntityType' Extract_Service_Entity_Type ${data}
201 ... ELSE Fail Not recognized device type: ${device_type}
202 ${json} = RequestsLibrary.To_Json ${clear_data}
203 ${entity_type_list} = Collections.Get_From_Dictionary &{json}[entity-owners] entity-type
204 ${entity_type_index} = Utils.Get_Index_From_List_Of_Dictionaries ${entity_type_list} type ${entity_type}
205 BuiltIn.Should_Not_Be_Equal_As_Integers ${entity_type_index} -1 No Entity Owner found for ${device_type}
206 ${entity_list} = Collections.Get_From_Dictionary @{entity_type_list}[${entity_type_index}] entity
207 ${entity_index} = Utils.Get_Index_From_List_Of_Dictionaries ${entity_list} id ${device_name}
208 BuiltIn.Should_Not_Be_Equal_As_Integers ${entity_index} -1 Device ${device_name} not found in Entity Owner ${device_type}
209 ${entity_owner} = Collections.Get_From_Dictionary @{entity_list}[${entity_index}] owner
210 BuiltIn.Should_Not_Be_Empty ${entity_owner} No owner found for ${device_name}
211 ${owner} = String.Replace_String ${entity_owner} member- ${EMPTY}
212 ${owner} = BuiltIn.Convert_To_Integer ${owner}
213 ${entity_candidates_list} = Collections.Get_From_Dictionary @{entity_list}[${entity_index}] candidate
214 : FOR ${entity_candidate} IN @{entity_candidates_list}
215 \ ${candidate} = String.Replace_String &{entity_candidate}[name] member- ${EMPTY}
216 \ ${candidate} = BuiltIn.Convert_To_Integer ${candidate}
217 \ Collections.Append_To_List ${candidate_list} ${candidate}
218 Collections.Sort_List ${candidate_list}
219 [Return] ${owner} ${candidate_list}
221 Get_Owner_And_Candidates_For_Device_Singleton
222 [Arguments] ${device_name} ${device_type} ${member_index}
223 [Documentation] Returns the owner and a list of candidates for the SB device ${device_name} of type ${device_type}. Request is sent to member ${member_index}.
224 ... Parsing method is selected by device type
225 ... Separate kw for every supported device type must be defined
226 BuiltIn.Keyword_Should_Exist Get_Owner_And_Candidates_For_Device_Singleton_${device_type}
227 BuiltIn.Run_Keyword_And_Return Get_Owner_And_Candidates_For_Device_Singleton_${device_type} ${device_name} ${member_index}
229 Get_Owner_And_Candidates_For_Device_Singleton_Netconf
230 [Arguments] ${device_name} ${member_index}
231 [Documentation] Returns the owner and a list of candidates for the SB device ${device_name} of type netconf. Request is sent to member ${member_index}.
232 ... Parsing method is set as netconf (using netconf device id prefix and suffix)
233 # Get election entity type results
234 ${type} = BuiltIn.Set_Variable ${SINGLETON_ELECTION_ENTITY_TYPE}
235 ${id} = BuiltIn.Set_Variable ${SINGLETON_NETCONF_DEVICE_ID_PREFIX}${device_name}${SINGLETON_NETCONF_DEVICE_ID_SUFFIX}
236 ${owner_1} ${candidate_list_1} = Get_Owner_And_Candidates_For_Type_And_Id ${type} ${id} ${member_index}
237 # Get change ownership entity type results
238 ${type} = BuiltIn.Set_Variable ${SINGLETON_CHANGE_OWNERSHIP_ENTITY_TYPE}
239 ${id} = BuiltIn.Set_Variable ${SINGLETON_NETCONF_DEVICE_ID_PREFIX}${device_name}${SINGLETON_NETCONF_DEVICE_ID_SUFFIX}
240 ${owner_2} ${candidate_list_2} = Get_Owner_And_Candidates_For_Type_And_Id ${type} ${id} ${member_index}
241 # Owners must be same, if not, there is still some election or change ownership in progress
242 BuiltIn.Should_Be_Equal_As_Integers ${owner_1} ${owner_2} Owners for device ${device_name} are not same
243 [Return] ${owner_1} ${candidate_list_1}
245 Get_Owner_And_Candidates_For_Device
246 [Arguments] ${device_name} ${device_type} ${member_index}
247 [Documentation] Returns the owner and a list of candidates for the SB device ${device_name} of type ${device_type}. Request is sent to member ${member_index}.
248 ... If parsing as singleton failed, kw try to parse data in old way (without singleton).
249 ... Candidates are all members that register to own a device, so the list of candiates includes the owner.
250 ... The returned candidate list is sorted numerically.
251 ... Note that "candidate list" definition currently differs between Beryllium and Boron.
252 ... It is recommended to use Get_Owner_And_Successors_For_Device instead of this keyword, see documentation there.
254 ${status} ${results} = BuiltIn.Run_Keyword_And_Ignore_Error Get_Owner_And_Candidates_For_Device_Singleton device_name=${device_name} device_type=${device_type} member_index=${member_index}
255 BuiltIn.Return_From_Keyword_If "${status}"=="PASS" ${results}
256 # If singleton failed, try parsing in old way
257 ${status} ${results} = BuiltIn.Run_Keyword_And_Ignore_Error Get_Owner_And_Candidates_For_Device_Old device_name=${device_name} device_type=${device_type} member_index=${member_index}
258 # previous 3 lines (BuilIn.Return.., # If singleton..., ${status}....) could be deleted when old way will not be supported anymore
259 BuiltIn.Run_Keyword_If '${status}'=='FAIL' BuiltIn.Fail Could not parse owner and candidates for device ${device_name}
262 Get_Owner_And_Candidates_For_Type_And_Id
263 [Arguments] ${type} ${id} ${member_index} ${require_candidate_list}=${EMPTY}
264 [Documentation] Returns the owner and a list of candidates for entity specified by ${type} and ${id}
265 ... Request is sent to member ${member_index}.
266 ... Candidates are all members that register to own a device, so the list of candiates includes the owner.
267 ... Bear in mind that for Boron and beyond, candidates are not removed on node down or isolation.
268 ... If ${require_candidate_list} is not \${EMPTY}, check whether the actual list of candidates matches.
269 ... Note that differs from "given list" semantics used in other keywords,
270 ... namely you cannot use \${EMPTY} to stand for "full list" in this keyword.
271 BuiltIn.Comment TODO: Find a way to unify and deduplicate code blocks in Get_Owner_And_Candidates_* keywords.
272 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
273 ${data} = TemplatedRequests.Get_As_Json_From_Uri uri=${ENTITY_OWNER_URI} session=${session}
274 ${candidate_list} = BuiltIn.Create_List
275 ${json} = RequestsLibrary.To_Json ${data}
276 ${entity_type_list} = Collections.Get_From_Dictionary &{json}[entity-owners] entity-type
277 ${entity_type_index} = Utils.Get_Index_From_List_Of_Dictionaries ${entity_type_list} type ${type}
278 BuiltIn.Should_Not_Be_Equal_As_Integers ${entity_type_index} -1 No Entity Owner found for ${type}
279 ${entity_list} = Collections.Get_From_Dictionary @{entity_type_list}[${entity_type_index}] entity
280 ${entity_index} = Utils.Get_Index_From_List_Of_Dictionaries ${entity_list} id ${id}
281 BuiltIn.Should Not_Be_Equal_As_Integers ${entity_index} -1 Id ${id} not found in Entity Owner ${type}
282 ${entity_owner} = Collections.Get_From_Dictionary @{entity_list}[${entity_index}] owner
283 BuiltIn.Should_Not_Be_Empty ${entity_owner} No owner found for type=${type} id=${id}
284 ${owner} = String.Replace_String ${entity_owner} member- ${EMPTY}
285 ${owner} = BuiltIn.Convert_To_Integer ${owner}
286 ${entity_candidates_list} = Collections.Get_From_Dictionary @{entity_list}[${entity_index}] candidate
287 : FOR ${entity_candidate} IN @{entity_candidates_list}
288 \ ${candidate} = String.Replace_String &{entity_candidate}[name] member- ${EMPTY}
289 \ ${candidate} = BuiltIn.Convert_To_Integer ${candidate}
290 \ Collections.Append_To_List ${candidate_list} ${candidate}
291 Collections.Sort_List ${candidate_list}
292 BuiltIn.Comment TODO: Separate check lines into Verify_Owner_And_Candidates_For_Type_And_Id
293 BuiltIn.Run_Keyword_If """${require_candidate_list}""" BuiltIn.Should_Be_Equal ${require_candidate_list} ${candidate_list} Candidate list does not match: ${candidate_list} is not ${require_candidate_list}
294 [Return] ${owner} ${candidate_list}
296 Extract_Service_Entity_Type
298 [Documentation] Remove superfluous device data from Entity Owner printout.
299 ${clear_data} = String.Replace_String ${data} /odl-general-entity:entity[odl-general-entity:name=' ${EMPTY}
300 ${clear_data} = String.Replace_String ${clear_data} -service-group'] ${EMPTY}
302 [Return] ${clear_data}
304 Extract_OpenFlow_Device_Data
306 [Documentation] Remove superfluous OpenFlow device data from Entity Owner printout.
307 ${clear_data} = BuiltIn.Run Keyword If '${ODL_STREAM}' != 'beryllium' and '${ODL_OF_PLUGIN}' == 'lithium' String.Replace_String ${data} org.opendaylight.mdsal.ServiceEntityType openflow
308 ... ELSE BuiltIn.Set_Variable ${data}
309 ${clear_data} = String.Replace_String ${clear_data} /odl-general-entity:entity[odl-general-entity:name=' ${EMPTY}
310 ${clear_data} = String.Replace_String ${clear_data} /general-entity:entity[general-entity:name=' ${EMPTY}
311 ${clear_data} = String.Replace_String ${clear_data} '] ${EMPTY}
313 [Return] ${clear_data}
315 Extract_Ovsdb_Device_Data
317 [Documentation] Remove superfluous OVSDB device data from Entity Owner printout.
318 ${clear_data} = String.Replace_String ${data} /network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id=' ${EMPTY}
319 ${clear_data} = String.Replace_String ${clear_data} '] ${EMPTY}
321 [Return] ${clear_data}
324 [Arguments] ${member} ${original_index_list}=${EMPTY} ${confirm}=True
325 [Documentation] Convenience keyword that kills the specified member of the cluster.
326 ... The KW will return a list of available members: \${updated index_list}=\${original_index_list}-\${member}
327 ${index_list} = ClusterManagement__Build_List ${member}
328 ${updated_index_list} = Kill_Members_From_List_Or_All ${index_list} ${original_index_list} ${confirm}
329 [Return] ${updated_index_list}
331 Kill_Members_From_List_Or_All
332 [Arguments] ${member_index_list}=${EMPTY} ${original_index_list}=${EMPTY} ${confirm}=True
333 [Documentation] If the list is empty, kill all ODL instances. Otherwise, kill members based on \${kill_index_list}
334 ... If \${confirm} is True, sleep 1 second and verify killed instances are not there anymore.
335 ... The KW will return a list of available members: \${updated index_list}=\${original_index_list}-\${member_index_list}
336 ${kill_index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list}
337 ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${original_index_list}
338 Run_Bash_Command_On_List_Or_All command=${NODE_KILL_COMMAND} member_index_list=${member_index_list}
339 ${updated_index_list} = BuiltIn.Create_List @{index_list}
340 Collections.Remove_Values_From_List ${updated_index_list} @{kill_index_list}
341 BuiltIn.Return_From_Keyword_If not ${confirm} ${updated_index_list}
342 # TODO: Convert to WUKS with configurable timeout if it turns out 1 second is not enough.
343 BuiltIn.Sleep 1s Kill -9 closes open files, which may take longer than ssh overhead, but not long enough to warrant WUKS.
344 : FOR ${index} IN @{kill_index_list}
345 \ Verify_Karaf_Is_Not_Running_On_Member member_index=${index}
346 [Return] ${updated_index_list}
349 [Arguments] ${member} ${original_index_list}=${EMPTY} ${confirm}=True
350 [Documentation] Convenience keyword that stops the specified member of the cluster.
351 ... The KW will return a list of available members: \${updated index_list}=\${original_index_list}-\${member}
352 ${index_list} = ClusterManagement__Build_List ${member}
353 ${updated_index_list} = Stop_Members_From_List_Or_All ${index_list} ${original_index_list} ${confirm}
354 [Return] ${updated_index_list}
356 Stop_Members_From_List_Or_All
357 [Arguments] ${member_index_list}=${EMPTY} ${original_index_list}=${EMPTY} ${confirm}=True ${timeout}=120s
358 [Documentation] If the list is empty, stops all ODL instances. Otherwise stop members based on \${stop_index_list}
359 ... If \${confirm} is True, verify stopped instances are not there anymore.
360 ... The KW will return a list of available members: \${updated index_list}=\${original_index_list}-\${member_index_list}
361 ${stop_index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list}
362 ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${original_index_list}
363 Run_Bash_Command_On_List_Or_All command=${NODE_STOP_COMMAND} member_index_list=${member_index_list}
364 ${updated_index_list} = BuiltIn.Create_List @{index_list}
365 Collections.Remove_Values_From_List ${updated_index_list} @{stop_index_list}
366 BuiltIn.Return_From_Keyword_If not ${confirm} ${updated_index_list}
367 : FOR ${index} IN @{stop_index_list}
368 \ BuiltIn.Wait Until Keyword Succeeds ${timeout} 2s Verify_Karaf_Is_Not_Running_On_Member member_index=${index}
369 [Return] ${updated_index_list}
372 [Arguments] ${member} ${wait_for_sync}=True ${timeout}=300s
373 [Documentation] Convenience keyword that starts the specified member of the cluster.
374 ${index_list} = ClusterManagement__Build_List ${member}
375 Start_Members_From_List_Or_All ${index_list} ${wait_for_sync} ${timeout}
377 Start_Members_From_List_Or_All
378 [Arguments] ${member_index_list}=${EMPTY} ${wait_for_sync}=True ${timeout}=300s ${karaf_home}=${EMPTY} ${export_java_home}=${EMPTY}
379 [Documentation] If the list is empty, start all cluster members. Otherwise, start members based on present indices.
380 ... If ${wait_for_sync}, wait for cluster sync on listed members.
381 ... Optionally karaf_home can be overriden. Optionally specific JAVA_HOME is used for starting.
382 ${base_command} = BuiltIn.Set_Variable_If "${karaf_home}" ${karaf_home}/bin/start ${NODE_START_COMMAND}
383 ${command} = BuiltIn.Set_Variable_If "${export_java_home}" export JAVA_HOME="${export_java_home}"; ${base_command} ${base_command}
384 Run_Bash_Command_On_List_Or_All command=${command} member_index_list=${member_index_list}
385 BuiltIn.Return_From_Keyword_If not ${wait_for_sync}
386 BuiltIn.Wait_Until_Keyword_Succeeds ${timeout} 10s Check_Cluster_Is_In_Sync member_index_list=${member_index_list}
387 # TODO: Do we also want to check Shard Leaders here?
389 Clean_Journals_And_Snapshots_On_List_Or_All
390 [Arguments] ${member_index_list}=${EMPTY} ${karaf_home}=${KARAF_HOME}
391 [Documentation] Delete journal and snapshots directories on every node listed (or all).
392 ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list}
393 ${command} = Set Variable rm -rf "${karaf_home}/journal" "${karaf_home}/snapshots"
394 : FOR ${index} IN @{index_list} # usually: 1, 2, 3.
395 \ Run_Bash_Command_On_Member command=${command} member_index=${index}
397 Verify_Karaf_Is_Not_Running_On_Member
398 [Arguments] ${member_index}
399 [Documentation] Fail if non-zero karaf instances are counted on member of given index.
400 ${count} = Count_Running_Karafs_On_Member member_index=${member_index}
401 BuiltIn.Should_Be_Equal 0 ${count} Found running Karaf count: ${count}
403 Verify_Single_Karaf_Is_Running_On_Member
404 [Arguments] ${member_index}
405 [Documentation] Fail if number of karaf instances on member of given index is not one.
406 ${count} = Count_Running_Karafs_On_Member member_index=${member_index}
407 BuiltIn.Should_Be_Equal 1 ${count} Wrong number of Karafs running: ${count}
409 Count_Running_Karafs_On_Member
410 [Arguments] ${member_index}
411 [Documentation] Remotely execute grep for karaf process, return count as string.
412 ${command} = BuiltIn.Set_Variable ps axf | grep org.apache.karaf | grep -v grep | wc -l
413 ${count} = Run_Bash_Command_On_Member command=${command} member_index=${member_index}
416 Isolate_Member_From_List_Or_All
417 [Arguments] ${isolate_member_index} ${member_index_list}=${EMPTY}
418 [Documentation] If the list is empty, isolate member from all ODL instances. Otherwise, isolate member based on present indices.
419 ... The KW will return a list of available members: \${updated index_list}=\${member_index_list}-\${isolate_member_index}
420 ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list}
421 ${source} = Collections.Get_From_Dictionary ${ClusterManagement__index_to_ip_mapping} ${isolate_member_index}
422 : FOR ${index} IN @{index_list}
423 \ ${destination} = Collections.Get_From_Dictionary ${ClusterManagement__index_to_ip_mapping} ${index}
424 \ ${command} = BuiltIn.Set_Variable sudo /sbin/iptables -I OUTPUT -p all --source ${source} --destination ${destination} -j DROP
425 \ BuiltIn.Run_Keyword_If "${index}" != "${isolate_member_index}" Run_Bash_Command_On_Member command=${command} member_index=${isolate_member_index}
426 ${command} = BuiltIn.Set_Variable sudo /sbin/iptables -L -n
427 ${output} = Run_Bash_Command_On_Member command=${command} member_index=${isolate_member_index}
428 BuiltIn.Log ${output}
429 ${updated_index_list} = BuiltIn.Create_List @{index_list}
430 Collections.Remove_Values_From_List ${updated_index_list} ${isolate_member_index}
431 [Return] ${updated_index_list}
433 Rejoin_Member_From_List_Or_All
434 [Arguments] ${rejoin_member_index} ${member_index_list}=${EMPTY}
435 [Documentation] If the list is empty, rejoin member from all ODL instances. Otherwise, rejoin member based on present indices.
436 ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list}
437 ${source} = Collections.Get_From_Dictionary ${ClusterManagement__index_to_ip_mapping} ${rejoin_member_index}
438 : FOR ${index} IN @{index_list}
439 \ ${destination} = Collections.Get_From_Dictionary ${ClusterManagement__index_to_ip_mapping} ${index}
440 \ ${command} = BuiltIn.Set_Variable sudo /sbin/iptables -D OUTPUT -p all --source ${source} --destination ${destination} -j DROP
441 \ BuiltIn.Run_Keyword_If "${index}" != "${rejoin_member_index}" Run_Bash_Command_On_Member command=${command} member_index=${rejoin_member_index}
442 ${command} = BuiltIn.Set_Variable sudo /sbin/iptables -L -n
443 ${output} = Run_Bash_Command_On_Member command=${command} member_index=${rejoin_member_index}
444 BuiltIn.Log ${output}
446 Flush_Iptables_From_List_Or_All
447 [Arguments] ${member_index_list}=${EMPTY}
448 [Documentation] If the list is empty, flush IPTables in all ODL instances. Otherwise, flush member based on present indices.
449 ${command} = BuiltIn.Set_Variable sudo iptables -v -F
450 ${output} = Run_Bash_Command_On_List_Or_All command=${command} member_index_list=${member_index_list}
452 Run_Bash_Command_On_List_Or_All
453 [Arguments] ${command} ${member_index_list}=${EMPTY}
454 [Documentation] Cycle through indices (or all), run command on each.
455 ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list}
456 : FOR ${index} IN @{index_list}
457 \ Run_Bash_Command_On_Member command=${command} member_index=${index}
459 Run_Bash_Command_On_Member
460 [Arguments] ${command} ${member_index}
461 [Documentation] Obtain IP, call Utils and return output. This does not preserve active ssh session.
462 # TODO: Rename these keyword to Run_Bash_Command_On_Member to distinguish from Karaf (or even Windows) commands.
463 ${member_ip} = Collections.Get_From_Dictionary dictionary=${ClusterManagement__index_to_ip_mapping} key=${member_index}
464 ${output} = SSHKeywords.Run_Keyword_Preserve_Connection Utils.Run_Command_On_Controller ${member_ip} ${command}
467 Run_Karaf_Command_On_List_Or_All
468 [Arguments] ${command} ${member_index_list}=${EMPTY} ${timeout}=10s
469 [Documentation] Cycle through indices (or all), run karaf command on each.
470 ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list}
471 : FOR ${index} IN @{index_list}
472 \ ${member_ip} = Collections.Get_From_Dictionary dictionary=${ClusterManagement__index_to_ip_mapping} key=${index}
473 \ KarafKeywords.Safe_Issue_Command_On_Karaf_Console ${command} ${member_ip} timeout=${timeout}
475 Run_Karaf_Command_On_Member
476 [Arguments] ${command} ${member_index} ${timeout}=10s
477 [Documentation] Obtain IP address, call KarafKeywords and return output. This does not preserve active ssh session.
478 ... This keyword is not used by Run_Karaf_Command_On_List_Or_All, but returned output may be useful.
479 ${member_ip} = Collections.Get_From_Dictionary dictionary=${ClusterManagement__index_to_ip_mapping} key=${member_index}
480 ${output} = KarafKeywords.Safe_Issue_Command_On_Karaf_Console ${command} controller=${member_ip} timeout=${timeout}
483 Install_Feature_On_List_Or_All
484 [Arguments] ${feature_name} ${member_index_list}=${EMPTY} ${timeout}=60s
485 [Documentation] Attempt installation on each member from list (or all). Then look for failures.
486 ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list}
487 ${status_list} = BuiltIn.Create_List
488 : FOR ${index} IN @{index_list}
489 \ ${status} ${text} = BuiltIn.Run_Keyword_And_Ignore_Error Install_Feature_On_Member feature_name=${feature_name} member_index=${index}
490 \ ... timeout=${timeout}
491 \ BuiltIn.Log ${text}
492 \ Collections.Append_To_List ${status_list} ${status}
493 : FOR ${status} IN @{status_list}
494 \ BuiltIn.Run_Keyword_If "${status}" != "PASS" BuiltIn.Fail ${feature_name} installation failed, see log.
496 Install_Feature_On_Member
497 [Arguments] ${feature_name} ${member_index} ${timeout}=60s
498 [Documentation] Run feature:install karaf command, fail if installation was not successful. Return output.
499 ${status} ${output} = BuiltIn.Run_Keyword_And_Ignore_Error Run_Karaf_Command_On_Member command=feature:install ${feature_name} member_index=${member_index} timeout=${timeout}
500 BuiltIn.Run_Keyword_If "${status}" != "PASS" BuiltIn.Fail Failed to install ${feature_name}: ${output}
501 BuiltIn.Should_Not_Contain ${output} Can't install Failed to install ${feature_name}: ${output}
504 With_Ssh_To_List_Or_All_Run_Keyword
505 [Arguments] ${member_index_list} ${keyword_name} @{args} &{kwargs}
506 [Documentation] For each index in given list (or all): activate SSH connection, run given Keyword, close active connection. Return None.
507 ... Note that if the Keyword affects SSH connections, results are still deterministic, but perhaps undesirable.
508 ... Beware that in order to avoid "got positional argument after named arguments", first two arguments in the call should not be named.
509 BuiltIn.Comment This keyword is experimental and there is high risk of being replaced by another approach.
510 # TODO: For_Index_From_List_Or_All_Run_Keyword applied to With_Ssh_To_Member_Run_Keyword?
511 ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list}
512 : FOR ${member_index} IN @{index_list}
513 \ ${member_ip} = Resolve_IP_Address_For_Member ${member_index}
514 \ SSHKeywords.Open_Connection_To_Odl_System ip_address=${member_ip}
515 \ BuiltIn.Run_Keyword ${keyword_name} @{args} &{kwargs}
516 \ SSHLibrary.Close_Connection
518 Safe_With_Ssh_To_List_Or_All_Run_Keyword
519 [Arguments] ${member_index_list} ${keyword_name} @{args} &{kwargs}
520 [Documentation] Remember active ssh connection index, call With_Ssh_To_List_Or_All_Run_Keyword, return None. Restore the conection index on teardown.
521 SSHKeywords.Run_Keyword_Preserve_Connection With_Ssh_To_List_Or_All_Run_Keyword ${member_index_list} ${keyword_name} @{args} &{kwargs}
523 Clean_Directories_On_List_Or_All
524 [Arguments] ${member_index_list}=${EMPTY} ${directory_list}=${EMPTY} ${karaf_home}=${KARAF_HOME}
525 [Documentation] Clear @{directory_list} or @{ODL_DEFAULT_DATA_PATHS} for members in given list or all. Return None.
526 ... This is intended to return Karaf (offline) to the state it was upon the first boot.
527 ${path_list} = Builtin.Set Variable If "${directory_list}" == "${EMPTY}" ${ODL_DEFAULT_DATA_PATHS} ${directory_list}
528 Safe_With_Ssh_To_List_Or_All_Run_Keyword ${member_index_list} ClusterManagement__Clean_Directories ${path_list} ${karaf_home}
530 Store_Karaf_Log_On_List_Or_All
531 [Arguments] ${member_index_list}=${EMPTY} ${dst_dir}=/tmp ${karaf_home}=${KARAF_HOME}
532 [Documentation] Saves karaf.log to the ${dst_dir} for members in given list or all. Return None.
533 Safe_With_Ssh_To_List_Or_All_Run_Keyword ${member_index_list} SSHKeywords.Execute_Command_Should_Pass cp ${karaf_home}/data/log/karaf.log ${dst_dir}
535 Restore_Karaf_Log_On_List_Or_All
536 [Arguments] ${member_index_list}=${EMPTY} ${src_dir}=/tmp ${karaf_home}=${KARAF_HOME}
537 [Documentation] Places stored karaf.log to the ${karaf_home}/data/log for members in given list or all. Return None.
538 Safe_With_Ssh_To_List_Or_All_Run_Keyword ${member_index_list} SSHKeywords.Execute_Command_Should_Pass cp ${src_dir}/karaf.log ${karaf_home}/data/log/
540 ClusterManagement__Clean_Directories
541 [Arguments] ${relative_path_list} ${karaf_home}
542 [Documentation] For each relative path, remove files with respect to ${karaf_home}. Return None.
543 : FOR ${relative_path} IN @{relative_path_list}
544 \ SSHLibrary.Execute_Command rm -rf ${karaf_home}${/}${relative_path}
546 Put_As_Json_And_Check_Member_List_Or_All
547 [Arguments] ${uri} ${data} ${member_index} ${member_index_list}=${EMPTY}
548 [Documentation] Send a PUT with the supplied uri ${uri} and body ${data} to member ${member_index}.
549 ... Then check data is replicated in all or some members defined in ${member_index_list}.
550 ${response_text} = Put_As_Json_To_Member uri=${uri} data=${data} member_index=${member_index}
551 Wait Until Keyword Succeeds 5s 1s Check_Json_Member_List_Or_All uri=${uri} expected_data=${data} member_index_list=${member_index_list}
552 [Return] ${response_text}
554 Put_As_Json_To_Member
555 [Arguments] ${uri} ${data} ${member_index}
556 [Documentation] Send a PUT with the supplied uri and data to member ${member_index}.
557 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
558 ${response_text} = TemplatedRequests.Put_As_Json_To_Uri uri=${uri} data=${data} session=${session}
559 [Return] ${response_text}
561 Post_As_Json_To_Member
562 [Arguments] ${uri} ${data} ${member_index}
563 [Documentation] Send a POST with the supplied uri and data to member ${member_index}.
564 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
565 ${response_text} = TemplatedRequests.Post_As_Json_To_Uri uri=${uri} data=${data} session=${session}
566 [Return] ${response_text}
568 Delete_And_Check_Member_List_Or_All
569 [Arguments] ${uri} ${member_index} ${member_index_list}=${EMPTY}
570 [Documentation] Send a DELETE with the supplied uri to the member ${member_index}.
571 ... Then check the data is removed from all members in ${member_index_list}.
572 ${response_text} = Delete_From_Member ${uri} ${member_index}
573 BuiltIn.Wait_Until_Keyword_Succeeds 5s 1s Check_No_Content_Member_List_Or_All uri=${uri} member_index_list=${member_index_list}
574 [Return] ${response_text}
577 [Arguments] ${uri} ${member_index}
578 [Documentation] Send a DELETE with the supplied uri to member ${member_index}.
579 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
580 ${response_text} = TemplatedRequests.Delete_From_Uri uri=${uri} session=${session}
581 [Return] ${response_text}
583 Check_Json_Member_List_Or_All
584 [Arguments] ${uri} ${expected_data} ${member_index_list}=${EMPTY}
585 [Documentation] Send a GET with the supplied uri to all or some members defined in ${member_index_list}.
586 ... Then check received data is = ${expected data}.
587 ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list}
588 : FOR ${index} IN @{index_list}
589 \ ${data} = Get_From_Member uri=${uri} member_index=${index}
590 \ TemplatedRequests.Normalize_Jsons_And_Compare ${expected_data} ${data}
592 Check_Item_Occurrence_Member_List_Or_All
593 [Arguments] ${uri} ${dictionary} ${member_index_list}=${EMPTY}
594 [Documentation] Send a GET with the supplied uri to all or some members defined in ${member_index_list}.
595 ... Then check received for occurrences of items expressed in a dictionary ${dictionary}.
596 ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list}
597 : FOR ${index} IN @{index_list}
598 \ ${data} = Get_From_Member uri=${uri} member_index=${index}
599 \ Utils.Check Item Occurrence ${data} ${dictionary}
601 Check_No_Content_Member_List_Or_All
602 [Arguments] ${uri} ${member_index_list}=${EMPTY}
603 [Documentation] Send a GET with the supplied uri to all or some members defined in ${member_index_list}.
604 ... Then check there is no content.
605 ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list}
606 : FOR ${index} IN @{index_list}
607 \ ${session} = Resolve_Http_Session_For_Member member_index=${index}
608 \ Utils.No_Content_From_URI ${session} ${uri}
611 [Arguments] ${uri} ${member_index} ${access}=${ACCEPT_EMPTY}
612 [Documentation] Send a GET with the supplied uri to member ${member_index}.
613 ${session} = Resolve_Http_Session_For_Member member_index=${member_index}
614 ${response_text} = TemplatedRequests.Get_From_Uri uri=${uri} accept=${access} session=${session}
615 [Return] ${response_text}
617 Resolve_IP_Address_For_Member
618 [Arguments] ${member_index}
619 [Documentation] Return node IP address of given index.
620 ${ip_address} = Collections.Get From Dictionary dictionary=${ClusterManagement__index_to_ip_mapping} key=${member_index}
621 [Return] ${ip_address}
623 Resolve_Http_Session_For_Member
624 [Arguments] ${member_index}
625 [Documentation] Return RequestsLibrary session alias pointing to node of given index.
626 ${session} = BuiltIn.Set_Variable ClusterManagement__session_${member_index}
629 Resolve_Shard_Type_Class
630 [Arguments] ${shard_type}
631 [Documentation] Simple lookup for class name corresponding to desired type.
632 BuiltIn.Run_Keyword_If '${shard_type}' == 'config' BuiltIn.Return_From_Keyword DistributedConfigDatastore
633 ... ELSE IF '${shard_type}' == 'operational' BuiltIn.Return_From_Keyword DistributedOperationalDatastore
634 BuiltIn.Fail Unrecognized shard type: ${shard_type}
636 ClusterManagement__Build_List
637 [Arguments] ${member}
638 ${member_int} = BuiltIn.Convert_To_Integer ${member}
639 ${index_list} = BuiltIn.Create_List ${member_int}
640 [Return] ${index_list}
642 ClusterManagement__Parse_Sync_Status
643 [Arguments] ${shard_manager_text}
644 [Documentation] Return sync status parsed out of given text. Called twice by Get_Sync_Status_Of_Member.
645 BuiltIn.Log ${shard_manager_text}
646 ${manager_object} = RequestsLibrary.To_Json ${shard_manager_text}
647 ${value_object} = Collections.Get_From_Dictionary dictionary=${manager_object} key=value
648 ${sync_status} = Collections.Get_From_Dictionary dictionary=${value_object} key=SyncStatus
649 [Return] ${sync_status}
651 List_Indices_Minus_Member
652 [Arguments] ${member_index} ${member_index_list}=${EMPTY}
653 [Documentation] Create a new list which contains indices from ${member_index_list} (or all) without ${member_index}.
654 ${index_list} = ClusterManagement__Given_Or_Empty_List ${member_index_list}
655 Collections.Remove Values From List ${index_list} ${member_index}
656 [Return] ${index_list}
658 ClusterManagement__Given_Or_Internal_Index_List
659 [Arguments] ${given_list}=${EMPTY}
660 [Documentation] Utility to allow \${EMPTY} as default argument value, as the internal list is computed at runtime.
661 ... This keyword always return a (shallow) copy of given or default list,
662 ... so operations with the returned list should not affect other lists.
663 ... Also note that this keyword does not consider empty list to be \${EMPTY}.
664 ... TODO: This keyword is frequently used for obtaining copy of ${ClusterManagement__member_index_list}. Give this keyword public name.
665 ${return_list_reference} = BuiltIn.Set_Variable_If """${given_list}""" != "" ${given_list} ${ClusterManagement__member_index_list}
666 ${return_list_copy} = BuiltIn.Create_List @{return_list_reference}
667 [Return] ${return_list_copy}
669 ClusterManagement__Given_Or_Empty_List
670 [Arguments] ${given_list}=${EMPTY}
671 [Documentation] Utility to allow \${EMPTY} as default argument value, as an empty list is computed at runtime.
672 ${empty_list} = BuiltIn.Create_List
673 ${given_length} = BuiltIn.Get_Length ${given_list}
674 ${return_list} = BuiltIn.Set_Variable_If ${given_length} > 0 ${given_list} ${empty_list}
675 [Return] ${return_list}
677 ClusterManagement__Compute_Derived_Variables
678 [Arguments] ${int_of_members}
679 [Documentation] Construct index list, session list and IP mapping, publish them as suite variables.
680 @{member_index_list} = BuiltIn.Create_List
681 @{session_list} = BuiltIn.Create_List
682 &{index_to_ip_mapping} = BuiltIn.Create_Dictionary
683 : FOR ${index} IN RANGE 1 ${int_of_members+1}
684 \ ClusterManagement__Include_Member_Index ${index} ${member_index_list} ${session_list} ${index_to_ip_mapping}
685 BuiltIn.Set_Suite_Variable \${ClusterManagement__member_index_list} ${member_index_list}
686 BuiltIn.Set_Suite_Variable \${ClusterManagement__index_to_ip_mapping} ${index_to_ip_mapping}
687 BuiltIn.Set_Suite_Variable \${ClusterManagement__session_list} ${session_list}
689 ClusterManagement__Include_Member_Index
690 [Arguments] ${index} ${member_index_list} ${session_list} ${index_to_ip_mapping}
691 [Documentation] Add a corresponding item based on index into the last three arguments.
692 ... Create the Http session whose alias is added to list.
693 Collections.Append_To_List ${member_index_list} ${index}
694 ${member_ip} = BuiltIn.Set_Variable ${ODL_SYSTEM_${index}_IP}
695 # ${index} is int (not string) so "key=value" syntax does not work in the following line.
696 Collections.Set_To_Dictionary ${index_to_ip_mapping} ${index} ${member_ip}
697 # Http session, with ${AUTH}, without headers.
698 ${session_alias} = Resolve_Http_Session_For_Member member_index=${index}
699 RequestsLibrary.Create_Session ${session_alias} http://${member_ip}:${RESTCONFPORT} auth=${AUTH} max_retries=0
700 Collections.Append_To_List ${session_list} ${session_alias}
702 Sync_Status_Should_Be_False
703 [Arguments] ${controller_index}
704 [Documentation] Verify that cluster node is not in sync with others
705 ${status} Get_Sync_Status_Of_Member ${controller_index}
706 BuiltIn.Should_Not_Be_True ${status}
708 Sync_Status_Should_Be_True
709 [Arguments] ${controller_index}
710 [Documentation] Verify that cluster node is in sync with others
711 ${status} Get_Sync_Status_Of_Member ${controller_index}
712 BuiltIn.Should_Be_True ${status}