2 Documentation Test suite for netconf device entity ownership handling during outages.
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
11 ... Perform basic operations (Create, Read, Update and Delete or CRUD) on device
12 ... data mounted onto a netconf connector and see if they work.
14 ... The suite recognizes 3 nodes, "CONFIGURER" (the node that configures the
15 ... device at the beginning and then deconfigures it at the end), "SETTER" (the
16 ... node that manipulates the data on the device) and "CHECKER" (the node that
17 ... checks the data on the device). The configured device and the results of each
18 ... data operation on it is expected to be visible on all nodes so after each
19 ... operation three test cases make sure they can see the result on their
22 ... The 3 nodes are configured by placing "node1", "node2" or "node3" into the
23 ... ${NODE_CONFIGURER}, ${NODE_SETTER} and ${NODE_CHECKER} to make the node
24 ... a "CONFIGURER", "SETTER" and "CHECKER" respectively. The "nodeX" name refers
25 ... to the node with its IP address configured with the ${ODL_SYSTEM_X_IP}
26 ... variable where the "X" is 1, 2 or 3.
28 ... The suite checks the integrity of the presence of the device and the data
29 ... seen on the device only for nodes that have at least one of the roles
30 ... ("CONFIGURER", "SETTER" and "CHECKER") assigned. A better design would have
31 ... a "checker list" of sorts and have only one checking test case that runs
32 ... through the check list and performs the test on each node listed. However
33 ... this currently has fairly low priority due to Beryllium delivery date so
35 Suite Setup Setup_Everything
36 Suite Teardown Teardown_Everything
37 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
39 Library RequestsLibrary
40 Library OperatingSystem
42 Library SSHLibrary timeout=10s
43 Resource ${CURDIR}/../../../libraries/ClusterManagement.robot
44 Resource ${CURDIR}/../../../libraries/FailFast.robot
45 Resource ${CURDIR}/../../../libraries/KarafKeywords.robot
46 Resource ${CURDIR}/../../../libraries/NetconfKeywords.robot
47 Resource ${CURDIR}/../../../libraries/SetupUtils.robot
48 Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot
49 Resource ${CURDIR}/../../../libraries/Utils.robot
50 Variables ${CURDIR}/../../../variables/Variables.py
53 ${DEVICE_CHECK_TIMEOUT} 60s
54 ${DEVICE_BOOT_TIMEOUT} 100s
55 ${CLUSTER_RECOVERY_TIMEOUT} 120s
56 ${DEVICE_NAME} netconf-test-device
60 [Documentation] Deploy and start test tool, then wait for all its devices to become online.
61 NetconfKeywords.Install_And_Start_Testtool device-count=1 schemas=${CURDIR}/../../../variables/netconf/CRUD/schemas
63 Check_Device_Is_Not_Mounted_At_Beginning
64 [Documentation] Sanity check making sure our device is not there. Fail if found.
65 NetconfKeywords.Check_Device_Has_No_Netconf_Connector ${DEVICE_NAME} session=${node1_session}
66 NetconfKeywords.Check_Device_Has_No_Netconf_Connector ${DEVICE_NAME} session=${node2_session}
67 NetconfKeywords.Check_Device_Has_No_Netconf_Connector ${DEVICE_NAME} session=${node3_session}
69 Configure_Device_On_Netconf
70 [Documentation] Use node 1 to configure a testtool device on Netconf connector.
71 NetconfKeywords.Configure_Device_In_Netconf ${DEVICE_NAME} device_type=configure-via-topology session=${node1_session}
72 [Teardown] Utils.Report_Failure_Due_To_Bug 5089
74 Wait_For_Device_To_Become_Visible_For_All_Nodes
75 [Documentation] Wait for the whole cluster to see the device.
76 NetconfKeywords.Wait_Device_Connected ${DEVICE_NAME} session=${node1_session}
77 NetconfKeywords.Wait_Device_Connected ${DEVICE_NAME} session=${node2_session}
78 NetconfKeywords.Wait_Device_Connected ${DEVICE_NAME} session=${node3_session}
80 Check_Config_Data_Before_Data_Creation
81 [Documentation] Check if there really is no data present on none of the nodes
82 BuiltIn.Wait_Until_Keyword_Succeeds ${DEVICE_CHECK_TIMEOUT} 1s Check_Config_Data ${node1_session} ${empty_data}
83 BuiltIn.Wait_Until_Keyword_Succeeds ${DEVICE_CHECK_TIMEOUT} 1s Check_Config_Data ${node2_session} ${empty_data}
84 BuiltIn.Wait_Until_Keyword_Succeeds ${DEVICE_CHECK_TIMEOUT} 1s Check_Config_Data ${node3_session} ${empty_data}
87 [Documentation] Create some data on the device and propagate it throughout the cluster.
88 ${template_as_string}= BuiltIn.Set_Variable {'DEVICE_NAME': '${DEVICE_NAME}'}
89 TemplatedRequests.Post_As_Xml_Templated ${directory_with_template_folders}${/}dataorig ${template_as_string} session=${node2_session}
91 Check_Config_Data_After_Data_Creation
92 [Documentation] Check if the data we just added into the cluster is really there
93 BuiltIn.Wait_Until_Keyword_Succeeds ${DEVICE_CHECK_TIMEOUT} 1s Check_Config_Data ${node1_session} ${original_data}
94 BuiltIn.Wait_Until_Keyword_Succeeds ${DEVICE_CHECK_TIMEOUT} 1s Check_Config_Data ${node2_session} ${original_data}
95 BuiltIn.Wait_Until_Keyword_Succeeds ${DEVICE_CHECK_TIMEOUT} 1s Check_Config_Data ${node3_session} ${original_data}
97 Find_And_Shutdown_Device_Entity_Owner
98 [Documentation] Simulate a failure of the owner of the entity that represents the device.
99 ${owner} ${followers}= ClusterManagement.Get_Owner_And_Successors_For_device ${DEVICE NAME} netconf 1
101 Length Should Be ${followers} 2 Wrong count of followers returned
102 BuiltIn.Set_Suite_Variable ${original_device_owner} ${owner}
103 BuiltIn.Set_Suite_Variable ${follower1} ${followers}[0]
104 BuiltIn.Set_Suite_Variable ${follower2} ${followers}[1]
105 ${original_device_owner_session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${original_device_owner}
106 ${follower1_session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${follower1}
107 ${follower2_session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${follower2}
108 BuiltIn.Set_Suite_Variable ${original_device_owner_session}
109 BuiltIn.Set_Suite_Variable ${follower1_session}
110 BuiltIn.Set_Suite_Variable ${follower2_session}
111 ClusterManagement.Kill_Single_Member ${owner}
113 Wait_For_New_Owner_To_Appear
114 [Documentation] Wait for the cluster to recover from the failure and choose a new owner for the entity.
116 BuiltIn.Wait_Until_Keyword_Succeeds ${CLUSTER_RECOVERY_TIMEOUT} 1s Check_Owner_Reconfigured
118 Check_Config_Data_Before_Modification_With_Original_Owner_Down
119 [Documentation] Check if data is present and retrievable from follower nodes
120 BuiltIn.Wait_Until_Keyword_Succeeds ${DEVICE_CHECK_TIMEOUT} 1s Check_Config_Data ${follower1_session} ${original_data}
121 BuiltIn.Wait_Until_Keyword_Succeeds ${DEVICE_CHECK_TIMEOUT} 1s Check_Config_Data ${follower2_session} ${original_data}
122 [Teardown] Utils.Report_Failure_Due_To_Bug 6067
124 Modify_Device_Data_When_Original_Owner_Is_Down
125 [Documentation] Attempt to modify the data on the device after recovery and see if it still works.
126 ${template_as_string}= BuiltIn.Set_Variable {'DEVICE_NAME': '${DEVICE_NAME}'}
127 TemplatedRequests.Put_As_Xml_Templated ${directory_with_template_folders}${/}datamod1 ${template_as_string} session=${follower1_session}
128 [Teardown] Utils.Report_Failure_Due_To_Bug 4968
130 Check_Config_Data_After_Modification_With_Original_Owner_Down
131 [Documentation] Check if data is written correctly when original owner is shut down
132 BuiltIn.Wait_Until_Keyword_Succeeds ${DEVICE_CHECK_TIMEOUT} 1s Check_Config_Data ${follower1_session} ${modified_data}
133 BuiltIn.Wait_Until_Keyword_Succeeds ${DEVICE_CHECK_TIMEOUT} 1s Check_Config_Data ${follower2_session} ${modified_data}
134 [Teardown] Utils.Report_Failure_Due_To_Bug 6067
136 Restart_Original_Entity_Owner
137 [Documentation] Restart the original entity owner and see if it can still see the device and the new data on it.
138 ClusterManagement.Start_Single_Member ${original_device_owner}
140 Check_Config_Data_After_Original_Owner_Restart
141 [Documentation] Sanity check if we still can retrieve our data from the original device owner.
142 BuiltIn.Wait_Until_Keyword_Succeeds ${DEVICE_CHECK_TIMEOUT} 1s Check_Config_Data ${original_device_owner_session} ${modified_data}
143 [Teardown] Utils.Report_Failure_Due_To_Bug 5761
145 Modify_Device_Data_With_Original_Owner
146 [Documentation] Check that the original owner of the entity is still able to modify the data on the device
147 ${template_as_string}= BuiltIn.Set_Variable {'DEVICE_NAME': '${DEVICE_NAME}'}
148 TemplatedRequests.Put_As_Xml_Templated ${directory_with_template_folders}${/}datamod2 ${template_as_string} session=${original_device_owner_session}
149 [Teardown] Utils.Report_Failure_Due_To_Bug 5761
151 Check_Config_Data_After_Modification_With_Original_Owner_Up
152 [Documentation] Check if data has really been written as we expect. Fails if Modify_Device_Data_With_Original_Owner fails.
153 BuiltIn.Wait_Until_Keyword_Succeeds ${DEVICE_CHECK_TIMEOUT} 1s Check_Config_Data ${node1_session} ${modified_data_2}
154 BuiltIn.Wait_Until_Keyword_Succeeds ${DEVICE_CHECK_TIMEOUT} 1s Check_Config_Data ${node2_session} ${modified_data_2}
155 BuiltIn.Wait_Until_Keyword_Succeeds ${DEVICE_CHECK_TIMEOUT} 1s Check_Config_Data ${node3_session} ${modified_data_2}
157 Deconfigure_Device_In_Netconf
158 [Documentation] Make request to deconfigure the device on Netconf connector and see if it works.
160 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
161 NetconfKeywords.Remove_Device_From_Netconf ${DEVICE_NAME} session=${node1_session}
162 NetconfKeywords.Wait_Device_Fully_Removed ${DEVICE_NAME} session=${node1_session}
163 NetconfKeywords.Wait_Device_Fully_Removed ${DEVICE_NAME} session=${node2_session}
164 NetconfKeywords.Wait_Device_Fully_Removed ${DEVICE_NAME} session=${node3_session}
168 [Documentation] Setup everything needed for the test cases.
169 # Setup resources used by the suite.
170 SetupUtils.Setup_Utils_For_Setup_And_Teardown http_timeout=2
171 ClusterManagement.ClusterManagement_Setup
172 NetconfKeywords.Setup_Netconf_Keywords create_session_for_templated_requests=False
173 ${node1_session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=1
174 ${node2_session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=2
175 ${node3_session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=3
176 BuiltIn.Set_Suite_Variable ${node1_session}
177 BuiltIn.Set_Suite_Variable ${node2_session}
178 BuiltIn.Set_Suite_Variable ${node3_session}
179 # Constants that are not meant to be overriden by the users
180 BuiltIn.Set_Suite_Variable ${directory_with_template_folders} ${CURDIR}/../../../variables/netconf/CRUD
181 BuiltIn.Set_Suite_Variable ${empty_data} <data xmlns="${ODL_NETCONF_NAMESPACE}"></data>
182 ${cont}= BuiltIn.Set_Variable <data xmlns="${ODL_NETCONF_NAMESPACE}"><cont xmlns="urn:opendaylight:test:netconf:crud"><l>
183 ${contend}= BuiltIn.Set_Variable </l></cont></data>
184 BuiltIn.Set_Suite_Variable ${original_data} ${cont}Content${contend}
185 BuiltIn.Set_Suite_Variable ${modified_data} ${cont}Modified Content${contend}
186 BuiltIn.Set_Suite_Variable ${modified_data_2} ${cont}Another Modified Content${contend}
189 [Documentation] Teardown the test infrastructure, perform cleanup and release all resources.
190 RequestsLibrary.Delete_All_Sessions
191 NetconfKeywords.Stop_Testtool
194 [Arguments] ${session} ${expected} ${contains}=False
195 [Documentation] Check that the data on the device matches the specified expectations.
196 ... TODO: Needs to be extracted into a suitable Resource as there is
197 ... the same code in at least two other suites (CRUD and clustered
199 ${url}= Builtin.Set_Variable ${CONFIG_API}/network-topology:network-topology/topology/topology-netconf/node/${DEVICE_NAME}/yang-ext:mount
200 ${data}= TemplatedRequests.Get_As_Xml_From_Uri ${url} session=${session}
201 BuiltIn.Run_Keyword_Unless ${contains} BuiltIn.Should_Be_Equal_As_Strings ${data} ${expected}
202 BuiltIn.Run_Keyword_If ${contains} BuiltIn.Should_Contain ${data} ${expected}
204 Check_Owner_Reconfigured
205 [Documentation] Check whether the entity owner changed. Fail if not or no owner found.
206 Log Original Owner Index: ${original_device_owner}
207 Log Follower 1: node${follower1}
208 Log Follower 2: node${follower2}
209 ${owner} ${candidates}= ClusterManagement.Get_Owner_And_Candidates_For_Device ${DEVICE_NAME} netconf ${follower1}
210 BuiltIn.Should_Not_Be_Equal_As_Integers ${owner} ${original_device_owner}