2 Documentation Test suite for netconf device entity ownership handling during isolation.
4 ... Copyright (c) 2017 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
11 ... Performs basic operations (Create, Read, Update and Delete or CRUD) on device
12 ... data mounted onto a netconf connector and verifies cluster recovery after
13 ... network isolation and rejoin of the Entity_Owner node.
15 ... The suite recognizes 3 nodes,
16 ... - "CONFIGURER" (the node that configures the device at the beginning and then
17 ... deconfigures it at the end).
18 ... - "SETTER" (the node that manipulates the data on the device)
19 ... - "CHECKER" (the node that checks the data on the device). The configured
20 ... device and the results of each data operation on it is expected to be visible
21 ... on all nodes. After each operation three test cases verify they can see the
22 ... result on their respective CONFIGURER,SETTER,CHECKER nodes.
24 ... The 3 nodes are configured by placing "node1", "node2" or "node3" into the
25 ... ${NODE_CONFIGURER}, ${NODE_SETTER} and ${NODE_CHECKER} variables. This makes
26 ... a node "CONFIGURER", "SETTER" and "CHECKER" respectively.
27 ... The "nodeX" name refers to the node with its IP address configured with the
28 ... ${ODL_SYSTEM_X_IP} variable where the "X" is 1, 2 or 3.
30 ... The suite verifies the presence of the device and the integrity
31 ... of device data for nodes that have at least one of the roles
32 ... ("CONFIGURER", "SETTER" and "CHECKER") assigned.
34 ... TODO: Multiple improvements are possible, but apply them to entity.robot at the same time please.
37 Library RequestsLibrary
38 Library OperatingSystem
40 Library SSHLibrary timeout=10s
41 Resource ${CURDIR}/../../../libraries/ClusterManagement.robot
42 Resource ${CURDIR}/../../../libraries/FailFast.robot
43 Resource ${CURDIR}/../../../libraries/KarafKeywords.robot
44 Resource ${CURDIR}/../../../libraries/NetconfKeywords.robot
45 Resource ${CURDIR}/../../../libraries/SetupUtils.robot
46 Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot
47 Resource ${CURDIR}/../../../libraries/Utils.robot
48 Resource ${CURDIR}/../../../variables/Variables.robot
50 Suite Setup Setup_Everything
51 Suite Teardown Teardown_Everything
52 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
56 ${DEVICE_CHECK_TIMEOUT} 60s
57 ${DEVICE_BOOT_TIMEOUT} 100s
58 ${CLUSTER_RECOVERY_TIMEOUT} 300s
59 ${DEVICE_NAME} netconf-test-device
64 [Documentation] Deploy and start test tool, then wait for all its devices to become online.
65 NetconfKeywords.Install_And_Start_Testtool
67 ... schemas=${CURDIR}/../../../variables/netconf/CRUD/schemas
69 Check_Device_Is_Not_Mounted_At_Beginning
70 [Documentation] Sanity check making sure our device is not there. Fail if found.
71 NetconfKeywords.Check_Device_Has_No_Netconf_Connector ${DEVICE_NAME} session=${node1_session}
72 NetconfKeywords.Check_Device_Has_No_Netconf_Connector ${DEVICE_NAME} session=${node2_session}
73 NetconfKeywords.Check_Device_Has_No_Netconf_Connector ${DEVICE_NAME} session=${node3_session}
75 Configure_Device_On_Netconf
76 [Documentation] Use node 1 to configure a testtool device on Netconf connector.
77 NetconfKeywords.Configure_Device_In_Netconf
79 ... device_type=configure-via-topology
80 ... session=${node1_session}
82 Wait_For_Device_To_Become_Visible_For_All_Nodes
83 [Documentation] Wait for the whole cluster to see the device.
84 NetconfKeywords.Wait_Device_Connected ${DEVICE_NAME} session=${node1_session}
85 NetconfKeywords.Wait_Device_Connected ${DEVICE_NAME} session=${node2_session}
86 NetconfKeywords.Wait_Device_Connected ${DEVICE_NAME} session=${node3_session}
88 Check_Config_Data_Before_Data_Creation
89 [Documentation] Check if there really is no data present on none of the nodes
90 BuiltIn.Wait_Until_Keyword_Succeeds
91 ... ${DEVICE_CHECK_TIMEOUT}
96 BuiltIn.Wait_Until_Keyword_Succeeds
97 ... ${DEVICE_CHECK_TIMEOUT}
102 BuiltIn.Wait_Until_Keyword_Succeeds
103 ... ${DEVICE_CHECK_TIMEOUT}
105 ... Check_Config_Data
110 [Documentation] Create some data on the device and propagate it throughout the cluster.
111 ${template_as_string}= BuiltIn.Create_Dictionary DEVICE_NAME=${device_name}
112 TemplatedRequests.Post_As_Xml_Templated
113 ... ${directory_with_template_folders}${/}dataorig
114 ... ${template_as_string}
115 ... session=${node2_session}
117 Check_Config_Data_After_Data_Creation
118 [Documentation] Check if the data we just added into the cluster is really there
119 BuiltIn.Wait_Until_Keyword_Succeeds
120 ... ${DEVICE_CHECK_TIMEOUT}
122 ... Check_Config_Data
125 BuiltIn.Wait_Until_Keyword_Succeeds
126 ... ${DEVICE_CHECK_TIMEOUT}
128 ... Check_Config_Data
131 BuiltIn.Wait_Until_Keyword_Succeeds
132 ... ${DEVICE_CHECK_TIMEOUT}
134 ... Check_Config_Data
138 Find_And_Isolate_Device_Entity_Owner
139 [Documentation] Simulate a failure of the owner of the entity that represents the device.
140 ${owner} ${followers}= ClusterManagement.Get_Owner_And_Successors_For_device
145 Length Should Be ${followers} 2 Wrong count of followers returned
146 BuiltIn.Set_Suite_Variable ${original_device_owner} ${owner}
147 BuiltIn.Set_Suite_Variable ${follower1} ${followers}[0]
148 BuiltIn.Set_Suite_Variable ${follower2} ${followers}[1]
149 ${original_device_owner_session}= ClusterManagement.Resolve_Http_Session_For_Member
150 ... member_index=${original_device_owner}
151 ${follower1_session}= ClusterManagement.Resolve_Http_Session_For_Member member_index=${follower1}
152 ${follower2_session}= ClusterManagement.Resolve_Http_Session_For_Member member_index=${follower2}
153 BuiltIn.Set_Suite_Variable ${original_device_owner_session}
154 BuiltIn.Set_Suite_Variable ${follower1_session}
155 BuiltIn.Set_Suite_Variable ${follower2_session}
156 #ClusterManagement.Kill_Single_Member ${owner}
157 ClusterManagement.Isolate_Member_From_List_Or_All ${owner}
159 Wait_For_New_Owner_To_Appear
160 [Documentation] Wait for the cluster to recover from the failure and choose a new owner for the entity.
162 BuiltIn.Wait_Until_Keyword_Succeeds ${CLUSTER_RECOVERY_TIMEOUT} 1s Check_Owner_Reconfigured
164 Check_Config_Data_Before_Modification_With_Original_Owner_Down
165 [Documentation] Check if data is present and retrievable from follower nodes
166 BuiltIn.Wait_Until_Keyword_Succeeds
167 ... ${DEVICE_CHECK_TIMEOUT}
169 ... Check_Config_Data
170 ... ${follower1_session}
172 BuiltIn.Wait_Until_Keyword_Succeeds
173 ... ${DEVICE_CHECK_TIMEOUT}
175 ... Check_Config_Data
176 ... ${follower2_session}
179 Modify_Device_Data_When_Original_Owner_Is_Down
180 [Documentation] Attempt to modify the data on the device after recovery and see if it still works.
181 ${template_as_string}= BuiltIn.Create_Dictionary DEVICE_NAME=${device_name}
182 TemplatedRequests.Put_As_Xml_Templated
183 ... ${directory_with_template_folders}${/}datamod1
184 ... ${template_as_string}
185 ... session=${follower1_session}
187 Check_Config_Data_After_Modification_With_Original_Owner_Down
188 [Documentation] Check if data is written correctly when original owner is shut down
189 BuiltIn.Wait_Until_Keyword_Succeeds
190 ... ${DEVICE_CHECK_TIMEOUT}
192 ... Check_Config_Data
193 ... ${follower1_session}
195 BuiltIn.Wait_Until_Keyword_Succeeds
196 ... ${DEVICE_CHECK_TIMEOUT}
198 ... Check_Config_Data
199 ... ${follower2_session}
202 Rejoin_Original_Entity_Owner
203 [Documentation] Restart the original entity owner and see if it can still see the device and the new data on it.
204 ClusterManagement.Rejoin_Member_From_List_Or_All ${original_device_owner}
206 Check_Config_Data_After_Original_Owner_Restart
207 [Documentation] Sanity check if we still can retrieve our data from the original device owner.
208 BuiltIn.Wait_Until_Keyword_Succeeds
209 ... ${DEVICE_CHECK_TIMEOUT}
211 ... Check_Config_Data
212 ... ${original_device_owner_session}
214 [Teardown] Utils.Report_Failure_Due_To_Bug 8999
216 Modify_Device_Data_With_Original_Owner
217 [Documentation] Check that the original owner of the entity is still able to modify the data on the device
218 ${template_as_string}= BuiltIn.Create_Dictionary DEVICE_NAME=${device_name}
219 TemplatedRequests.Put_As_Xml_Templated
220 ... ${directory_with_template_folders}${/}datamod2
221 ... ${template_as_string}
222 ... session=${original_device_owner_session}
224 Check_Config_Data_After_Modification_With_Original_Owner_Up
225 [Documentation] Check if data has really been written as we expect. Fails if Modify_Device_Data_With_Original_Owner fails.
226 BuiltIn.Wait_Until_Keyword_Succeeds
227 ... ${DEVICE_CHECK_TIMEOUT}
229 ... Check_Config_Data
231 ... ${modified_data_2}
232 BuiltIn.Wait_Until_Keyword_Succeeds
233 ... ${DEVICE_CHECK_TIMEOUT}
235 ... Check_Config_Data
237 ... ${modified_data_2}
238 BuiltIn.Wait_Until_Keyword_Succeeds
239 ... ${DEVICE_CHECK_TIMEOUT}
241 ... Check_Config_Data
243 ... ${modified_data_2}
245 Deconfigure_Device_In_Netconf
246 [Documentation] Make request to deconfigure the device on Netconf connector and see if it works.
248 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
249 NetconfKeywords.Remove_Device_From_Netconf ${DEVICE_NAME} session=${node1_session}
250 NetconfKeywords.Wait_Device_Fully_Removed ${DEVICE_NAME} session=${node1_session}
251 NetconfKeywords.Wait_Device_Fully_Removed ${DEVICE_NAME} session=${node2_session}
252 NetconfKeywords.Wait_Device_Fully_Removed ${DEVICE_NAME} session=${node3_session}
257 [Documentation] Setup everything needed for the test cases.
258 # Setup resources used by the suite.
259 SetupUtils.Setup_Utils_For_Setup_And_Teardown http_timeout=2
260 ClusterManagement.ClusterManagement_Setup
261 NetconfKeywords.Setup_Netconf_Keywords create_session_for_templated_requests=False
262 ${node1_session}= ClusterManagement.Resolve_Http_Session_For_Member member_index=1
263 ${node2_session}= ClusterManagement.Resolve_Http_Session_For_Member member_index=2
264 ${node3_session}= ClusterManagement.Resolve_Http_Session_For_Member member_index=3
265 BuiltIn.Set_Suite_Variable ${node1_session}
266 BuiltIn.Set_Suite_Variable ${node2_session}
267 BuiltIn.Set_Suite_Variable ${node3_session}
268 # Constants that are not meant to be overriden by the users
269 BuiltIn.Set_Suite_Variable ${directory_with_template_folders} ${CURDIR}/../../../variables/netconf/CRUD
270 BuiltIn.Set_Suite_Variable ${empty_data} <data xmlns="${ODL_NETCONF_NAMESPACE}"></data>
271 ${cont}= BuiltIn.Set_Variable
272 ... <data xmlns="${ODL_NETCONF_NAMESPACE}"><cont xmlns="urn:opendaylight:test:netconf:crud"><l>
273 ${contend}= BuiltIn.Set_Variable </l></cont></data>
274 BuiltIn.Set_Suite_Variable ${original_data} ${cont}Content${contend}
275 BuiltIn.Set_Suite_Variable ${modified_data} ${cont}Modified Content${contend}
276 BuiltIn.Set_Suite_Variable ${modified_data_2} ${cont}Another Modified Content${contend}
279 [Documentation] Teardown the test infrastructure, perform cleanup and release all resources.
280 RequestsLibrary.Delete_All_Sessions
281 NetconfKeywords.Stop_Testtool
284 [Documentation] Check that the data on the device matches the specified expectations.
285 ... TODO: Needs to be extracted into a suitable Resource as there is
286 ... the same code in at least two other suites (CRUD and clustered
288 [Arguments] ${session} ${expected} ${contains}=False
289 ${url}= Builtin.Set_Variable
290 ... ${REST_API}/network-topology:network-topology/topology=topology-netconf/node=${DEVICE_NAME}/yang-ext:mount?content=config
291 ${data}= TemplatedRequests.Get_As_Xml_From_Uri ${url} session=${session}
293 BuiltIn.Should_Be_Equal_As_Strings ${data} ${expected}
295 IF ${contains} BuiltIn.Should_Contain ${data} ${expected}
297 Check_Owner_Reconfigured
298 [Documentation] Check whether the entity owner changed. Fail if not or no owner found.
299 Log Original Owner Index: ${original_device_owner}
300 Log Follower 1: node${follower1}
301 Log Follower 2: node${follower2}
302 ${owner} ${candidates}= ClusterManagement.Get_Owner_And_Candidates_For_Device
306 BuiltIn.Should_Not_Be_Equal_As_Integers ${owner} ${original_device_owner}