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.
25 ... TODO: There are many sections with too many "Should_[Not_]Contain" keyword
26 ... invocations (see Check_Multiple_Modules_Merge_Replace for a particularly bad
27 ... example). Create a resource that will be able to extract the data from the
28 ... requests and search for them in the response, then convert to usage of this
29 ... resource (think "Thou shall not repeat yourself").
30 Suite Setup Setup_Everything
31 Suite Teardown Teardown_Everything
32 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
33 Library RequestsLibrary
35 Resource ${CURDIR}/../../../libraries/FailFast.robot
36 Resource ${CURDIR}/../../../libraries/SetupUtils.robot
37 Resource ${CURDIR}/../../../libraries/SSHKeywords.robot
38 Resource ${CURDIR}/../../../libraries/Utils.robot
39 Variables ${CURDIR}/../../../variables/Variables.py
42 ${datadir} ${CURDIR}/../../../variables/netconf/MDSAL
47 Connect_To_ODL_Netconf
48 [Documentation] Connect to ODL Netconf and fail if that is not possible.
49 Create_ODL_Netconf_Connection
50 Open_ODL_Netconf_Connection
53 [Documentation] Make sure the configuration has only the default elements in it.
54 Check_Test_Objects_Not_Present_In_Config get-config
56 Missing_Message_ID_Attribute
57 [Documentation] Check that messages with missing "message-ID" attribute are rejected with the correct error (RFC 6241, section 4.1).
58 Perform_Test missing-attr
60 Additional_Attributes_In_Message
61 [Documentation] Check that additional attributes in messages are returned properly (RFC 6241, sections 4.1 and 4.2).
62 ${reply}= Load_And_Send_Message additional-attr
63 BuiltIn.Should_Contain ${reply} xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
64 BuiltIn.Should_Contain ${reply} message-id="1"
65 BuiltIn.Should_Contain ${reply} attribute="something"
66 BuiltIn.Should_Contain ${reply} additional="otherthing"
67 BuiltIn.Should_Contain ${reply} xmlns:prefix="http://www.example.com/my-schema-example.html"
69 Edit_Config_First_Batch_Merge
70 [Documentation] Request a "merge" operation adding an element in candidate configuration and check the reply.
73 Get_Config_Running_To_Confirm_No_Edit_Before_Commit
74 [Documentation] Make sure the running configuration is still unchanged as the change was not commited yet.
75 Check_Test_Objects_Not_Present_In_Config get-config-no-edit-before-commit
78 [Documentation] Commit the change and check the reply.
79 Perform_Test commit-edit
81 First_Batch_In_Config_Running_To_Confirm_Edit_After_Commit
82 [Documentation] Check that the change is now in the configuration.
83 ${reply}= Load_And_Send_Message get-config-edit-after-commit
84 Check_First_Batch_Data_Present ${reply}
86 Terminate_Connection_Gracefully
87 [Documentation] Close the session and disconnect.
88 Close_ODL_Netconf_Connection_Gracefully
90 Reconnect_To_ODL_Netconf_After_Graceful_Session_End
91 [Documentation] Reconnect to ODL Netconf and fail if that is not possible.
92 Open_ODL_Netconf_Connection
94 First_Batch_In_Config_Running_After_Reconnect
95 [Documentation] Check that the change is now in the configuration.
96 ${reply}= Load_And_Send_Message get-config-edit-after-commit
97 Check_First_Batch_Data_Present ${reply}
99 Edit_Config_Create_Shall_Fail_Now
100 [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").
104 [Documentation] Delete the created element from the candidate configuration and check the reply.
107 Get_Config_Running_To_Confirm_No_Delete_Before_Commit
108 [Documentation] Make sure the element is still present in the running configuration as the delete command was not committed yet.
109 ${reply}= Load_And_Send_Message get-config-no-delete-before-commit
110 Check_First_Batch_Data_Present ${reply}
113 [Documentation] Commit the deletion of the element and check the reply.
114 Perform_Test commit-delete
116 Get_Config_Running_To_Confirm_Delete_After_Commit
117 [Documentation] Check that the element is gone.
118 Check_Test_Objects_Not_Present_In_Config get-config-delete-after-commit
120 Commit_No_Transaction
121 [Documentation] Attempt to perform "commit" when there are no changes in the candidate configuration and check that it returns OK status.
122 Perform_Test commit-no-transaction
124 Edit_Config_Second_Batch_Merge
125 [Documentation] Create an element to be discarded and check the reply.
128 Get_And_Check_Config_Candidate_For_Discard
129 [Documentation] Check that the element to be discarded is present in the candidate configuration.
130 ${reply}= Load_And_Send_Message get-config-candidate
131 Check_First_Batch_Data_Not_Present ${reply}
132 Check_Second_Batch_Data_Present ${reply}
134 Discard_Changes_Using_Discard_Request
135 [Documentation] Ask the server to discard the candidate and check the reply.
136 Perform_Test commit-discard
138 Get_And_Check_Config_Candidate_To_Confirm_Discard
139 [Documentation] Check that the element was really discarded.
140 Check_Test_Objects_Not_Present_In_Config get-config-candidate-discard
142 Edit_Config_Multiple_Batch_Merge_Create
143 [Documentation] Use a create request with the third batch to create the infrastructure.
144 Perform_Test merge-multiple-create
146 Edit_Config_Multiple_Batch_Merge_Third
147 [Documentation] Use a create request with the third batch to create the infrastructure.
148 Perform_Test merge-multiple-1
150 Edit_Config_Multiple_Batch_Merge_Fourth
151 [Documentation] Use a merge request with the third batch to create the infrastructure.
152 [Documentation] Add a "name3" subelement to the element and check the reply.
153 Perform_Test merge-multiple-2
155 Edit_Config_Multiple_Batch_Merge_Fifth
156 [Documentation] Add a "name4" subelement to the element and check the reply.
157 Perform_Test merge-multiple-3
159 Commit_Multiple_Merge
160 [Documentation] Commit the changes and check the reply.
161 Perform_Test merge-multiple-commit
163 Multiple_Batch_Data_In_Running_Config
164 [Documentation] Check that the 3 subelements are now present in the running configuration.
165 ${reply}= Load_And_Send_Message merge-multiple-check
166 Check_Multiple_Batch_Data_Present ${reply}
168 Abort_Connection_To_Simulate_Session_Failure
169 [Documentation] Simulate session failure by disconnecting without terminating the session.
170 Abort_ODL_Netconf_Connection
172 Reconnect_To_ODL_Netconf_After_Session_Failure
173 [Documentation] Reconnect to ODL Netconf and fail if that is not possible.
174 Open_ODL_Netconf_Connection
176 Multiple_Batch_Data_In_Running_Config_After_Session_Failure
177 [Documentation] Check that the 3 subelements are now present in the running configuration.
178 ${reply}= Load_And_Send_Message merge-multiple-check
179 Check_Multiple_Batch_Data_Present ${reply}
181 Edit_Multiple_Merge_Data
182 [Documentation] Add another subelement named "test" to the element and check the reply.
183 Perform_Test merge-multiple-edit
185 Commit_Multiple_Modules_Merge_Edit
186 [Documentation] Commit the addition of the "test" subelement and check the reply.
187 Perform_Test merge-multiple-edit-commit
189 Check_Multiple_Modules_Merge_Edit
190 [Documentation] Check that the "test" subelement exists and has correct value for "port" subelement.
191 ${reply}= Load_And_Send_Message merge-multiple-edit-check
192 BuiltIn.Should_Contain ${reply} <id>test</id>
193 BuiltIn.Should_Contain ${reply} <model>Dixi</model>
194 BuiltIn.Should_Contain ${reply} <manufacturer>BMW</manufacturer>
195 BuiltIn.Should_Contain ${reply} <year>1928</year>
197 Update_Multiple_Modules_Merge
198 [Documentation] Update the value of the "port" subelement of the "test" subelement and check the reply.
199 Perform_Test merge-multiple-update
201 Commit_Multiple_Modules_Merge_Update
202 [Documentation] Commit the update and check the reply.
203 Perform_Test merge-multiple-update-commit
205 Check_Multiple_Modules_Merge_Update
206 [Documentation] Check that the value of the "port" was really updated.
207 ${reply}= Load_And_Send_Message merge-multiple-update-check
208 BuiltIn.Should_Contain ${reply} <id>test</id>
209 BuiltIn.Should_Contain ${reply} <model>Bentley Speed Six</model>
210 BuiltIn.Should_Contain ${reply} <manufacturer>Bentley</manufacturer>
211 BuiltIn.Should_Contain ${reply} <year>1930</year>
212 BuiltIn.Should_Not_Contain ${reply} <model>Dixi</model>
213 BuiltIn.Should_Not_Contain ${reply} <manufacturer>BMW</manufacturer>
214 BuiltIn.Should_Not_Contain ${reply} <year>1928</year>
216 Replace_Multiple_Modules_Merge
217 [Documentation] Replace the content of the "test" with another completely different and check the reply.
218 Perform_Test merge-multiple-replace
220 Commit_Multiple_Modules_Merge_Replace
221 [Documentation] Commit the replace and check the reply.
222 Perform_Test merge-multiple-replace-commit
224 Check_Multiple_Modules_Merge_Replace
225 [Documentation] Check that the new content is there and the old content is gone.
226 ${reply}= Load_And_Send_Message merge-multiple-replace-check
227 BuiltIn.Should_Contain ${reply} <id>REPLACE</id>
228 BuiltIn.Should_Contain ${reply} <manufacturer>FIAT</manufacturer>
229 BuiltIn.Should_Contain ${reply} <model>Panda</model>
230 BuiltIn.Should_Contain ${reply} <year>2003</year>
231 BuiltIn.Should_Contain ${reply} <car-id>REPLACE</car-id>
232 BuiltIn.Should_Not_Contain ${reply} <id>TOY001</id>
233 BuiltIn.Should_Not_Contain ${reply} <id>CUST001</id>
234 BuiltIn.Should_Not_Contain ${reply} <car-id>TOY001</car-id>
235 BuiltIn.Should_Not_Contain ${reply} <person-id>CUST001</person-id>
236 BuiltIn.Should_Not_Contain ${reply} <id>OLD001</id>
237 BuiltIn.Should_Not_Contain ${reply} <id>CUST002</id>
238 BuiltIn.Should_Not_Contain ${reply} <car-id>OLD001</car-id>
239 BuiltIn.Should_Not_Contain ${reply} <person-id>CUST002</person-id>
240 BuiltIn.Should_Not_Contain ${reply} <id>CAROLD</id>
241 BuiltIn.Should_Contain ${reply} <id>CUSTOLD</id>
242 BuiltIn.Should_Not_Contain ${reply} <car-id>CAROLD</car-id>
243 BuiltIn.Should_Not_Contain ${reply} <person-id>CUSTOLD</person-id>
244 BuiltIn.Should_Not_Contain ${reply} <id>CARYOUNG</id>
245 BuiltIn.Should_Contain ${reply} <id>CUSTYOUNG</id>
246 BuiltIn.Should_Not_Contain ${reply} <car-id>CARYOUNG</car-id>
247 BuiltIn.Should_Contain ${reply} <person-id>CUSTYOUNG</person-id>
248 BuiltIn.Should_Not_Contain ${reply} <id>CARMID</id>
249 BuiltIn.Should_Contain ${reply} <id>CUSTMID</id>
250 BuiltIn.Should_Not_Contain ${reply} <car-id>CARMID</car-id>
251 BuiltIn.Should_Not_Contain ${reply} <person-id>CUSTMID</person-id>
252 BuiltIn.Should_Not_Contain ${reply} <id>CAROLD2</id>
253 BuiltIn.Should_Contain ${reply} <id>CUSTOLD2</id>
254 BuiltIn.Should_Not_Contain ${reply} <car-id>CAROLD2</car-id>
255 BuiltIn.Should_Not_Contain ${reply} <person-id>CUSTOLD2</person-id>
256 BuiltIn.Should_Not_Contain ${reply} <id>CUSTBAD</id>
257 BuiltIn.Should_Not_Contain ${reply} <id>test</id>
260 [Documentation] Remove the testing elements and all their subelements and check the reply.
261 Perform_Test merge-multiple-remove
263 Commit_Test_Data_Removal
264 [Documentation] Commit the removal and check the reply.
265 Perform_Test merge-multiple-remove-commit
267 Delete_Not_Existing_Element
268 [Documentation] Attempt to delete the elements again and check that it fails with the correct error.
269 Perform_Test delete-not-existing
271 Commit_Delete_Not_Existing_Module
272 [Documentation] Attempt to commit and check the reply.
273 Perform_Test commit-no-transaction
275 Remove_Not_Existing_Module
276 [Documentation] Attempt to remove the "module" element again and check that the operation is "silently ignored".
277 Perform_Test remove-not-existing
279 Commit_Remove_Not_Existing_Module
280 [Documentation] Attempt to commit and check the reply.
281 Perform_Test remove-not-existing-commit
284 [Documentation] Close the session and check that it was closed properly.
285 Perform_Test close-session
290 [Documentation] Load the specified data from the data directory and return it.
291 ${data}= OperatingSystem.Get_File ${datadir}${/}${name}.${dataext}
294 Create_ODL_Netconf_Connection
295 [Arguments] ${host}=${CONTROLLER} ${port}=${ODL_NETCONF_PORT} ${user}=${ODL_NETCONF_USER} ${password}=${ODL_NETCONF_PASSWORD}
296 [Documentation] Open a netconf connecion to the given machine.
297 # The "-s netconf" flag (see the "SSHLibrary.Write" line below) is not
298 # supported by SSHLibrary, therefore we need to use this elaborate and
299 # pretty tricky way to connect to the ODL Netconf port.
300 # TODO: Extract into NetconfKeywords as there are other tests that are
301 # going to need to use this operation (Netconf Performance and Scaling
302 # comes to my mind now as one of the things tested is the performance
303 # of the direct netconf connection.
304 # TODO: Make this keyword return a dictionary object with all the
305 # data about the prepared connection neatly packaged. Make all
306 # the other keywords handling the connection accept such an
307 # object and pull the data out of it rather than relying on
308 # global variables. This will allow for tracking more Netconf
309 # connections, increasing utility.
310 ${control}= SSHLibrary.Open_Connection ${host} prompt=${ODL_SYSTEM_PROMPT} timeout=10s
311 Utils.Flexible_Controller_Login
312 BuiltIn.Set_Suite_Variable ${ssh_control} ${control}
313 ${netconf}= SSHLibrary.Open_Connection ${host} prompt=${ODL_SYSTEM_PROMPT} timeout=10s
314 Utils.Flexible_Controller_Login
315 BuiltIn.Set_Suite_Variable ${ssh_netconf} ${netconf}
316 BuiltIn.Set_Suite_Variable ${ssh_port} ${port}
317 BuiltIn.Set_Suite_Variable ${ssh_user} ${user}
318 BuiltIn.Set_Suite_Variable ${ssh_password} ${password}
320 Reopen_ODL_Netconf_Connection
321 [Documentation] Reopen a closed netconf connection.
322 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
323 ${hello}= SSHLibrary.Read_Until ${ODL_NETCONF_PROMPT}
324 SSHLibrary.Switch_Connection ${ssh_control}
325 ${pid}= SSHLibrary.Execute_Command ps -A | grep sshpass | cut -b 1-6
326 BuiltIn.Set_Suite_Variable ${ssh_netconf_pid} ${pid}
327 SSHLibrary.Switch_Connection ${ssh_netconf}
330 Open_ODL_Netconf_Connection
331 [Documentation] Open a prepared netconf connecion.
332 ${hello}= Reopen_ODL_Netconf_Connection
333 ${hello_message}= Get_Data hello
334 Transmit_Message ${hello_message}
338 [Arguments] ${message}
339 [Documentation] Transmit message to Netconf connection and discard the echo of the message.
340 SSHLibrary.Write ${message}
341 SSHLibrary.Write ${ODL_NETCONF_PROMPT}
342 SSHLibrary.Read_Until ${ODL_NETCONF_PROMPT}
345 [Arguments] ${message}
346 [Documentation] Send message to Netconf connection and get the reply.
347 Transmit_Message ${message}
348 ${reply}= SSHLibrary.Read_Until ${ODL_NETCONF_PROMPT}
352 [Arguments] ${searched_string}
353 [Documentation] Prepare the specified string for searching in Netconf connection replies.
354 ... The string passed to this keyword is coming from a data
355 ... file which has different end of line conventions than
356 ... the actual Netconf reply. This keyword patches the string
357 ... to match what Netconf actually returns.
358 ${result}= BuiltIn.Evaluate "\\r\\n".join("""${searched_string}""".split("\\n"))
361 Load_And_Send_Message
363 [Documentation] Load a message from the data file set, send it to Netconf and return the reply.
364 ${request}= Get_Data ${name}-request
365 ${reply}= Send_Message ${request}
370 [Documentation] Load the expected reply from the data file set and return it.
371 ${expected_reply}= Get_Data ${name}-reply
372 ${expected}= Prepare_For_Search ${expected_reply}
375 Abort_ODL_Netconf_Connection
376 [Documentation] Correctly close the Netconf connection and make sure it is really dead.
377 BuiltIn.Return_From_Keyword_If ${ssh_netconf_pid} == -1
378 ${kill_command}= BuiltIn.Set_Variable kill ${ssh_netconf_pid}
379 BuiltIn.Set_Suite_Variable ${ssh_netconf_pid} -1
380 SSHLibrary.Switch_Connection ${ssh_control}
381 SSHLibrary.Write ${kill_command}
382 SSHLibrary.Read_Until_Prompt
383 SSHLibrary.Switch_Connection ${ssh_netconf}
384 SSHLibrary.Read_Until_Prompt
386 Close_ODL_Netconf_Connection_Gracefully
387 Perform_Test close-session
388 Abort_ODL_Netconf_Connection
391 [Documentation] Setup resources and create session for Restconf checking.
392 SetupUtils.Setup_Utils_For_Setup_And_Teardown
393 RequestsLibrary.Create_Session config http://${CONTROLLER}:${RESTCONFPORT}${CONFIG_API} auth=${AUTH}
396 [Documentation] Close the Netconf connection and destroy all sessions in the requests library.
397 Abort_ODL_Netconf_Connection
398 RequestsLibrary.Delete_All_Sessions
400 Check_First_Batch_Data
401 [Arguments] ${reply} ${keyword}
402 BuiltIn.RunKeyword ${keyword} ${reply} <id>TOY001</id>
403 BuiltIn.RunKeyword ${keyword} ${reply} <id>CUST001</id>
404 BuiltIn.RunKeyword ${keyword} ${reply} <car-id>TOY001</car-id>
405 BuiltIn.RunKeyword ${keyword} ${reply} <person-id>CUST001</person-id>
407 Check_First_Batch_Data_Present
409 Check_First_Batch_Data ${reply} BuiltIn.Should_Contain
411 Check_First_Batch_Data_Not_Present
413 Check_First_Batch_Data ${reply} BuiltIn.Should_Not_Contain
415 Check_Second_Batch_Data
416 [Arguments] ${reply} ${keyword}
417 BuiltIn.RunKeyword ${keyword} ${reply} <id>OLD001</id>
418 BuiltIn.RunKeyword ${keyword} ${reply} <id>CUST002</id>
419 BuiltIn.RunKeyword ${keyword} ${reply} <car-id>OLD001</car-id>
420 BuiltIn.RunKeyword ${keyword} ${reply} <person-id>CUST002</person-id>
422 Check_Second_Batch_Data_Present
424 Check_Second_Batch_Data ${reply} BuiltIn.Should_Contain
426 Check_Multiple_Batch_Data
427 [Arguments] ${reply} ${keyword}
428 BuiltIn.RunKeyword ${keyword} ${reply} <id>CAROLD</id>
429 BuiltIn.RunKeyword ${keyword} ${reply} <id>CUSTOLD</id>
430 BuiltIn.RunKeyword ${keyword} ${reply} <car-id>CAROLD</car-id>
431 BuiltIn.RunKeyword ${keyword} ${reply} <person-id>CUSTOLD</person-id>
432 BuiltIn.RunKeyword ${keyword} ${reply} <id>CARYOUNG</id>
433 BuiltIn.RunKeyword ${keyword} ${reply} <id>CUSTYOUNG</id>
434 BuiltIn.RunKeyword ${keyword} ${reply} <car-id>CARYOUNG</car-id>
435 BuiltIn.RunKeyword ${keyword} ${reply} <person-id>CUSTYOUNG</person-id>
436 BuiltIn.RunKeyword ${keyword} ${reply} <id>CARMID</id>
437 BuiltIn.RunKeyword ${keyword} ${reply} <id>CUSTMID</id>
438 BuiltIn.RunKeyword ${keyword} ${reply} <car-id>CARMID</car-id>
439 BuiltIn.RunKeyword ${keyword} ${reply} <person-id>CUSTMID</person-id>
440 BuiltIn.RunKeyword ${keyword} ${reply} <id>CAROLD2</id>
441 BuiltIn.RunKeyword ${keyword} ${reply} <id>CUSTOLD2</id>
442 BuiltIn.RunKeyword ${keyword} ${reply} <car-id>CAROLD2</car-id>
443 BuiltIn.RunKeyword ${keyword} ${reply} <person-id>CUSTOLD2</person-id>
445 Check_Multiple_Batch_Data_Absent
447 Check_Multiple_Batch_Data ${reply} BuiltIn.Should_not_Contain
449 Check_Multiple_Batch_Data_Present
451 Check_Multiple_Batch_Data ${reply} BuiltIn.Should_Contain
454 [Arguments] ${reply} ${keyword}
455 BuiltIn.RunKeyword ${keyword} ${reply} <id>CUSTBAD</id>
456 BuiltIn.RunKeyword ${keyword} ${reply} <id>test</id>
458 Check_Test_Objects_Absent
460 Check_First_Batch_Data_Not_Present ${reply}
461 Check_Second_Batch_Data ${reply} BuiltIn.Should_not_Contain
462 Check_Multiple_Batch_Data_Absent ${reply}
463 Check_Auxiliary_Data ${reply} BuiltIn.Should_not_Contain
464 BuiltIn.Should_not_Contain ${reply} <id>test</id>
466 Check_Test_Objects_Not_Present_In_Config
468 [Documentation] Use dataset with the specified name to get the configuration and check that none of our test objects are there.
469 ${reply}= Load_And_Send_Message ${name}
470 Check_Test_Objects_Absent ${reply}
471 BuiltIn.Should_not_Contain ${reply} <id>REPLACE</id>
476 [Documentation] Load and send the request from the dataset and compare the returned reply to the one stored in the dataset.
477 ${actual}= Load_And_Send_Message ${name}
478 ${expected}= Load_Expected_Reply ${name}
479 ${newline}= BuiltIn.Evaluate "\\r\\n"
480 BuiltIn.Should_Be_Equal ${newline}${expected}${ODL_NETCONF_PROMPT} ${actual}
484 [Arguments] ${name} ${expected}
485 ${actual}= Load_And_Send_Message ${name}
486 BuiltIn.Should_Be_Equal ${expected} ${actual}