2 Documentation Metconf MDSAL Northbound test suite.
4 ... Copyright (c) 2015 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 ... The request produced by test cases "Get Config Running", "Get Config Running
12 ... To Confirm No_Edit Before Commit", "Get Config Running To Confirm Delete
13 ... After Commit" and "Get Config Candidate To Confirm Discard" all use the same
14 ... message id ("empty") for their requests. This is possible because the
15 ... requests produced by this suite are strictly serialized. The RFC 6241 does
16 ... not state that these IDs are unique, it only requires that each ID used is
17 ... "XML attribute normalized" if the client wants it to be returned unmodified.
18 ... The RFC specifically says that "the content of this attribute is not
19 ... interpreted in any way, it only is stored to be returned with the reply to
20 ... the request. The reuse of the "empty" string for the 4 test cases was chosen
23 ... TODO: Change the 4 testcases to use unique message IDs.
24 Suite Setup Setup_Everything
25 Suite Teardown Teardown_Everything
26 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
27 Library RequestsLibrary
29 Resource ${CURDIR}/../../../libraries/FailFast.robot
30 Resource ${CURDIR}/../../../libraries/SetupUtils.robot
31 Resource ${CURDIR}/../../../libraries/SSHKeywords.robot
32 Resource ${CURDIR}/../../../libraries/Utils.robot
33 Variables ${CURDIR}/../../../variables/Variables.py
36 ${datadir} ${CURDIR}/../../../variables/netconf/MDSAL
41 Connect_To_ODL_Netconf
42 [Documentation] Connect to ODL Netconf and fail if that is not possible.
43 Create_ODL_Netconf_Connection
44 Open_ODL_Netconf_Connection
47 [Documentation] Make sure the configuration has only the default elements in it.
48 Check_Test_Objects_Not_Present_In_Config get-config
50 Missing_Message_ID_Attribute
51 [Documentation] Check that messages with missing "message-ID" attribute are rejected with the correct error (RFC 6241, section 4.1).
52 Perform_Test missing-attr
54 Additional_Attributes_In_Message
55 [Documentation] Check that additional attributes in messages are returned properly (RFC 6241, sections 4.1 and 4.2).
56 ${reply}= Load_And_Send_Message additional-attr
57 BuiltIn.Should_Contain ${reply} xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
58 BuiltIn.Should_Contain ${reply} message-id="1"
59 BuiltIn.Should_Contain ${reply} attribute="something"
60 BuiltIn.Should_Contain ${reply} additional="otherthing"
61 BuiltIn.Should_Contain ${reply} xmlns:prefix="http://www.example.com/my-schema-example.html"
63 Edit_Config_Modules_Merge
64 [Documentation] Request a "merge" operation adding an element in candidate configuration and check the reply.
65 Perform_Test config-modules-merge-1
67 Get_Config_Running_To_Confirm_No_Edit_Before_Commit
68 [Documentation] Make sure the running configuration is still unchanged as the change was not commited yet.
69 Check_Test_Objects_Not_Present_In_Config get-config-no-edit-before-commit
72 [Documentation] Commit the change and check the reply.
73 Perform_Test commit-edit
75 name0_In_Config_Running_To_Confirm_Edit_After_Commit
76 [Documentation] Check that the change is now in the configuration.
77 ${reply}= Load_And_Send_Message get-config-edit-after-commit
78 BuiltIn.Should_Contain ${reply} <name>name0</name>
80 name0_In_Config_Modules_Via_Restconf
81 [Documentation] Check that the change is also visible through Restconf.
82 ${data}= Utils.Get_Data_From_URI config config:modules headers=${ACCEPT_XML}
83 BuiltIn.Should_Contain ${data} <name>name0</name>
85 Terminate_Connection_Gracefully
86 [Documentation] Close the session and disconnect.
87 Close_ODL_Netconf_Connection_Gracefully
89 name0_In_Config_Modules_Via_Restconf_After_Disconnect
90 [Documentation] Check that the change is still visible through Restconf after Netconf disconnect.
91 ${data}= Utils.Get_Data_From_URI config config:modules headers=${ACCEPT_XML}
92 BuiltIn.Should_Contain ${data} <name>name0</name>
94 Reconnect_To_ODL_Netconf_After_Graceful_Session_End
95 [Documentation] Reconnect to ODL Netconf and fail if that is not possible.
96 Open_ODL_Netconf_Connection
98 name0_In_Config_Running_After_Reconnect
99 [Documentation] Check that the change is now in the configuration.
100 ${reply}= Load_And_Send_Message get-config-edit-after-commit
101 BuiltIn.Should_Contain ${reply} <name>name0</name>
103 name0_In_Config_Modules_Via_Restconf_After_Reconnect
104 [Documentation] Check that the change is still visible through Restconf after Netconf reconnect.
105 ${data}= Utils.Get_Data_From_URI config config:modules headers=${ACCEPT_XML}
106 BuiltIn.Should_Contain ${data} <name>name0</name>
108 Edit_Config_Modules_Create_Shall_Fail_Now
109 [Documentation] Request a "create" operation of an element that already exists and check that it fails with the correct error (RFC 6241, section 7.2, operation "create").
110 Perform_Test config-modules-create
113 [Documentation] Delete the created element from the candidate configuration and check the reply.
114 Perform_Test config-modules-delete
116 Get_Config_Running_To_Confirm_No_Delete_Before_Commit
117 [Documentation] Make sure the element is still present in the running configuration as the delete command was not committed yet.
118 ${reply}= Load_And_Send_Message get-config-no-delete-before-commit
119 BuiltIn.Should_Contain ${reply} <name>name0</name>
122 [Documentation] Commit the deletion of the element and check the reply.
123 Perform_Test commit-delete
125 Get_Config_Running_To_Confirm_Delete_After_Commit
126 [Documentation] Check that the element is gone.
127 Check_Test_Objects_Not_Present_In_Config get-config-delete-after-commit
129 Restconf_Get_Modules_Shall_Return_404
130 [Documentation] Check that "Not Found" is returned when Restconf is asked for the deleted element.
131 ${response}= RequestsLibrary.Get config config:modules ${ACCEPT_XML}
132 BuiltIn.Should_Be_Equal_As_Strings 404 ${response.status_code}
134 Commit_No_Transaction
135 [Documentation] Attempt to perform "commit" when there are no changes in the candidate configuration and check that it returns OK status.
136 Perform_Test commit-no-transaction
138 Edit_Config_Another_Modules_Merge_For_Discard
139 [Documentation] Create an element to be discarded and check the reply.
140 Perform_Test config-modules-merge-2
142 Get_And_Check_Config_Candidate_For_Discard
143 [Documentation] Check that the element to be discarded is present in the candidate configuration.
144 ${reply}= Load_And_Send_Message get-config-candidate
145 BuiltIn.Should_Contain ${reply} <name>name1</name>
146 BuiltIn.Should_Not_Contain ${reply} name0
148 Discard_Changes_Using_Discard_Request
149 [Documentation] Ask the server to discard the candidate and check the reply.
150 Perform_Test commit-discard
152 Get_And_Check_Config_Candidate_To_Confirm_Discard
153 [Documentation] Check that the element was really discarded.
154 Check_Test_Objects_Not_Present_In_Config get-config-candidate-discard
156 Edit_Config_Modules_Multiple_Modules_Merge_1
157 [Documentation] Create the element with "name2" subelement again and check the reply.
158 Perform_Test merge-multiple-1
160 Edit_Config_Modules_Multiple_Modules_Merge_2
161 [Documentation] Add a "name3" subelement to the element and check the reply.
162 Perform_Test merge-multiple-2
164 Edit_Config_Modules_Multiple_Modules_Merge_3
165 [Documentation] Add a "name4" subelement to the element and check the reply.
166 Perform_Test merge-multiple-3
168 Commit_Multiple_Modules_Merge
169 [Documentation] Commit the changes and check the reply.
170 Perform_Test merge-multiple-commit
172 name2_name3_name4_In_Running_Config
173 [Documentation] Check that the 3 subelements are now present in the running configuration.
174 ${reply}= Load_And_Send_Message merge-multiple-check
175 BuiltIn.Should_Contain ${reply} <name>name2</name>
176 BuiltIn.Should_Contain ${reply} <name>name3</name>
177 BuiltIn.Should_Contain ${reply} <name>name4</name>
179 name2_name3_name4_In_Config_Modules_Via_Restconf
180 [Documentation] Check that the 3 subelements are visible via Restconf.
181 ${data}= Utils.Get_Data_From_URI config config:modules headers=${ACCEPT_XML}
182 BuiltIn.Should_Contain ${data} <name>name2</name>
183 BuiltIn.Should_Contain ${data} <name>name3</name>
184 BuiltIn.Should_Contain ${data} <name>name4</name>
186 Abort_Connection_To_Simulate_Session_Failure
187 [Documentation] Simulate session failure by disconnecting without terminating the session.
188 Abort_ODL_Netconf_Connection
190 name2_name3_name4_In_Config_Modules_Via_Restconf_After_Session_Fail
191 [Documentation] Check that the 3 subelements are visible via Restconf.
192 ${data}= Utils.Get_Data_From_URI config config:modules headers=${ACCEPT_XML}
193 BuiltIn.Should_Contain ${data} <name>name2</name>
194 BuiltIn.Should_Contain ${data} <name>name3</name>
195 BuiltIn.Should_Contain ${data} <name>name4</name>
197 Reconnect_To_ODL_Netconf_After_Session_Failure
198 [Documentation] Reconnect to ODL Netconf and fail if that is not possible.
199 Open_ODL_Netconf_Connection
201 name2_name3_name4_In_Running_Config_After_Session_Failure
202 [Documentation] Check that the 3 subelements are now present in the running configuration.
203 ${reply}= Load_And_Send_Message merge-multiple-check
204 BuiltIn.Should_Contain ${reply} <name>name2</name>
205 BuiltIn.Should_Contain ${reply} <name>name3</name>
206 BuiltIn.Should_Contain ${reply} <name>name4</name>
208 Edit_Multiple_Modules_Merge
209 [Documentation] Add another subelement named "test" to the element and check the reply.
210 Perform_Test merge-multiple-edit
212 Commit_Multiple_Modules_Merge_Edit
213 [Documentation] Commit the addition of the "test" subelement and check the reply.
214 Perform_Test merge-multiple-edit-commit
216 Check_Multiple_Modules_Merge_Edit
217 [Documentation] Check that the "test" subelement exists and has correct value for "port" subelement.
218 ${reply}= Load_And_Send_Message merge-multiple-edit-check
219 BuiltIn.Should_Contain ${reply} <port xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">2022</port>
221 Update_Multiple_Modules_Merge
222 [Documentation] Update the value of the "port" subelement of the "test" subelement and check the reply.
223 Perform_Test merge-multiple-update
225 Commit_Multiple_Modules_Merge_Update
226 [Documentation] Commit the update and check the reply.
227 Perform_Test merge-multiple-update-commit
229 Check_Multiple_Modules_Merge_Update
230 [Documentation] Check that the value of the "port" was really updated.
231 ${reply}= Load_And_Send_Message merge-multiple-update-check
232 BuiltIn.Should_Contain ${reply} <port xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">3000</port>
234 Replace_Multiple_Modules_Merge
235 [Documentation] Replace the content of the "test" with another completely different and check the reply.
236 Perform_Test merge-multiple-replace
238 Commit_Multiple_Modules_Merge_Replace
239 [Documentation] Commit the replace and check the reply.
240 Perform_Test merge-multiple-replace-commit
242 Check_Multiple_Modules_Merge_Replace
243 [Documentation] Check that the new content is there and the old content is gone.
244 ${reply}= Load_And_Send_Message merge-multiple-replace-check
245 BuiltIn.Should_Contain ${reply} <name>test</name>
246 BuiltIn.Should_Contain ${reply} <address xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">10.194.132.42</address>
247 BuiltIn.Should_Contain ${reply} <tcp-only xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">false</tcp-only>
248 BuiltIn.Should_Contain ${reply} <port xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">4000</port>
249 BuiltIn.Should_Contain ${reply} <password xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">admin</password>
250 BuiltIn.Should_Contain ${reply} <username xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">admin</username>
251 BuiltIn.Should_Not_Contain ${reply} <name>global-event-executor</name>
252 BuiltIn.Should_Not_Contain ${reply} <name>binding-osgi-broker</name>
253 BuiltIn.Should_Not_Contain ${reply} <name>dom-broker</name>
254 BuiltIn.Should_Not_Contain ${reply} <name>global-netconf-dispatcher</name>
255 BuiltIn.Should_Not_Contain ${reply} <name>global-netconf-processing-executor</name>
257 Remove_Multiple_Modules
258 [Documentation] Remove the testing "module" element and all its subelements and check the reply.
259 Perform_Test merge-multiple-remove
261 Commit_Multiple_Modules_Removal
262 [Documentation] Commit the removal and check the reply.
263 Perform_Test merge-multiple-remove-commit
265 Delete_Not_Existing_Module
266 [Documentation] Attempt to delete the "module" element again and check that it fails with the correct error.
267 Perform_Test delete-not-existing
269 Commit_Delete_Not_Existing_Module
270 [Documentation] Attempt to commit and check the reply.
271 Perform_Test commit-no-transaction
273 Remove_Not_Existing_Module
274 [Documentation] Attempt to remove the "module" element again and check that the operation is "silently ignored".
275 Perform_Test remove-not-existing
277 Commit_Remove_Not_Existing_Module
278 [Documentation] Attempt to commit and check the reply.
279 Perform_Test remove-not-existing-commit
282 [Documentation] Close the session and check that it was closed properly.
283 Perform_Test close-session
288 [Documentation] Load the specified data from the data directory and return it.
289 ${data}= OperatingSystem.Get_File ${datadir}${/}${name}.${dataext}
292 Create_ODL_Netconf_Connection
293 [Arguments] ${host}=${CONTROLLER} ${port}=${ODL_NETCONF_PORT} ${user}=${ODL_NETCONF_USER} ${password}=${ODL_NETCONF_PASSWORD}
294 [Documentation] Open a netconf connecion to the given machine.
295 # The "-s netconf" flag (see the "SSHLibrary.Write" line below) is not
296 # supported by SSHLibrary, therefore we need to use this elaborate and
297 # pretty tricky way to connect to the ODL Netconf port.
298 # TODO: Extract into NetconfKeywords as there are other tests that are
299 # going to need to use this operation (Netconf Performance and Scaling
300 # comes to my mind now as one of the things tested is the performance
301 # of the direct netconf connection.
302 # TODO: Make this keyword return a dictionary object with all the
303 # data about the prepared connection neatly packaged. Make all
304 # the other keywords handling the connection accept such an
305 # object and pull the data out of it rather than relying on
306 # global variables. This will allow for tracking more Netconf
307 # connections, increasing utility.
308 ${control}= SSHLibrary.Open_Connection ${host} prompt=${ODL_SYSTEM_PROMPT} timeout=10s
309 Utils.Flexible_Controller_Login
310 BuiltIn.Set_Suite_Variable ${ssh_control} ${control}
311 ${netconf}= SSHLibrary.Open_Connection ${host} prompt=${ODL_SYSTEM_PROMPT} timeout=10s
312 Utils.Flexible_Controller_Login
313 BuiltIn.Set_Suite_Variable ${ssh_netconf} ${netconf}
314 BuiltIn.Set_Suite_Variable ${ssh_port} ${port}
315 BuiltIn.Set_Suite_Variable ${ssh_user} ${user}
316 BuiltIn.Set_Suite_Variable ${ssh_password} ${password}
318 Reopen_ODL_Netconf_Connection
319 [Documentation] Reopen a closed netconf connection.
320 SSHLibrary.Write sshpass -p ${ssh_password} ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${ssh_user}\@127.0.0.1 -p ${ssh_port} -s netconf
321 ${hello}= SSHLibrary.Read_Until ${ODL_NETCONF_PROMPT}
322 SSHLibrary.Switch_Connection ${ssh_control}
323 ${pid}= SSHLibrary.Execute_Command ps -A | grep sshpass | cut -b 1-6
324 BuiltIn.Set_Suite_Variable ${ssh_netconf_pid} ${pid}
325 SSHLibrary.Switch_Connection ${ssh_netconf}
328 Open_ODL_Netconf_Connection
329 [Documentation] Open a prepared netconf connecion.
330 ${hello}= Reopen_ODL_Netconf_Connection
331 ${hello_message}= Get_Data hello
332 Transmit_Message ${hello_message}
336 [Arguments] ${message}
337 [Documentation] Transmit message to Netconf connection and discard the echo of the message.
338 SSHLibrary.Write ${message}
339 SSHLibrary.Write ${ODL_NETCONF_PROMPT}
340 SSHLibrary.Read_Until ${ODL_NETCONF_PROMPT}
343 [Arguments] ${message}
344 [Documentation] Send message to Netconf connection and get the reply.
345 Transmit_Message ${message}
346 ${reply}= SSHLibrary.Read_Until ${ODL_NETCONF_PROMPT}
350 [Arguments] ${searched_string}
351 [Documentation] Prepare the specified string for searching in Netconf connection replies.
352 ... The string passed to this keyword is coming from a data
353 ... file which has different end of line conventions than
354 ... the actual Netconf reply. This keyword patches the string
355 ... to match what Netconf actually returns.
356 ${result}= BuiltIn.Evaluate "\\r\\n".join("""${searched_string}""".split("\\n"))
359 Load_And_Send_Message
361 [Documentation] Load a message from the data file set, send it to Netconf and return the reply.
362 ${request}= Get_Data ${name}-request
363 ${reply}= Send_Message ${request}
368 [Documentation] Load the expected reply from the data file set and return it.
369 ${expected_reply}= Get_Data ${name}-reply
370 ${expected}= Prepare_For_Search ${expected_reply}
373 Abort_ODL_Netconf_Connection
374 [Documentation] Correctly close the Netconf connection and make sure it is really dead.
375 BuiltIn.Return_From_Keyword_If ${ssh_netconf_pid} == -1
376 ${kill_command}= BuiltIn.Set_Variable kill ${ssh_netconf_pid}
377 BuiltIn.Set_Suite_Variable ${ssh_netconf_pid} -1
378 SSHLibrary.Switch_Connection ${ssh_control}
379 SSHLibrary.Write ${kill_command}
380 SSHLibrary.Read_Until_Prompt
381 SSHLibrary.Switch_Connection ${ssh_netconf}
382 SSHLibrary.Read_Until_Prompt
384 Close_ODL_Netconf_Connection_Gracefully
385 Perform_Test close-session
386 Abort_ODL_Netconf_Connection
389 [Documentation] Setup resources and create session for Restconf checking.
390 SetupUtils.Setup_Utils_For_Setup_And_Teardown
391 RequestsLibrary.Create_Session config http://${CONTROLLER}:${RESTCONFPORT}${CONFIG_API} auth=${AUTH}
394 [Documentation] Close the Netconf connection and destroy all sessions in the requests library.
395 Abort_ODL_Netconf_Connection
396 RequestsLibrary.Delete_All_Sessions
398 Check_Test_Objects_Not_Present_In_Config
400 [Documentation] Use dataset with the specified name to get the configuration and check that none of our test objects are there.
401 ${reply}= Load_And_Send_Message ${name}
402 BuiltIn.Should_Not_Contain ${reply} <name>name0</name>
403 BuiltIn.Should_Not_Contain ${reply} <name>name1</name>
404 BuiltIn.Should_Not_Contain ${reply} <name>name2</name>
405 BuiltIn.Should_Not_Contain ${reply} <name>name3</name>
406 BuiltIn.Should_Not_Contain ${reply} <name>name4</name>
410 [Documentation] Load and send the request from the dataset and compare the returned reply to the one stored in the dataset.
411 ${actual}= Load_And_Send_Message ${name}
412 ${expected}= Load_Expected_Reply ${name}
413 ${newline}= BuiltIn.Evaluate "\\r\\n"
414 BuiltIn.Should_Be_Equal ${newline}${expected}${ODL_NETCONF_PROMPT} ${actual}
418 [Arguments] ${name} ${expected}
419 ${actual}= Load_And_Send_Message ${name}
420 BuiltIn.Should_Be_Equal ${expected} ${actual}