2 Documentation netconf-connector CRUD-Action test suite.
4 ... Copyright (c) 2019 Ericsson Software Technology AB. 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 using RPC for node supporting Yang 1.1
13 ... addition and see if invoking Action Operation work.
14 Suite Setup Setup_Everything
15 Suite Teardown Teardown_Everything
16 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
18 Library RequestsLibrary
19 Library OperatingSystem
21 Library SSHLibrary timeout=10s
22 Resource ${CURDIR}/../../../libraries/CompareStream.robot
23 Resource ${CURDIR}/../../../libraries/FailFast.robot
24 Resource ${CURDIR}/../../../libraries/NetconfKeywords.robot
25 Resource ${CURDIR}/../../../libraries/SetupUtils.robot
26 Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot
27 Resource ${CURDIR}/../../../variables/Variables.robot
30 ${DIRECTORY_WITH_TEMPLATE_FOLDERS} ${CURDIR}/../../../variables/netconf/CRUD
31 ${DEVICE_NAME} netconf-test-device
32 ${DEVICE_TYPE_RPC} rpc-device
33 ${DEVICE_TYPE_RPC_CREATE} rpc-create-device
34 ${DEVICE_TYPE_RPC_DELETE} rpc-delete-device
35 ${USE_NETCONF_CONNECTOR} ${False}
36 ${DELETE_LOCATION} delete_location
37 ${RPC_FILE} ${CURDIR}/../../../variables/netconf/CRUD/customaction/customaction.xml
40 Check_Device_Is_Not_Configured_At_Beginning
41 [Documentation] Sanity check making sure our device is not there. Fail if found.
43 NetconfKeywords.Check_Device_Has_No_Netconf_Connector ${DEVICE_NAME}
45 Configure_Device_On_Netconf
46 [Documentation] Make request to configure a testtool device on Netconf connector.
48 NetconfKeywords.Configure_Device_In_Netconf ${DEVICE_NAME} device_type=${DEVICE_TYPE} http_timeout=2 http_method=post
50 Check_ODL_Has_Netconf_Connector_For_Device
51 [Documentation] Get the list of configured devices and search for our device there. Fail if not found.
53 ${count} = NetconfKeywords.Count_Netconf_Connectors_For_Device ${DEVICE_NAME}
54 Builtin.Should_Be_Equal_As_Strings ${count} 1
56 Wait_For_Device_To_Become_Connected
57 [Documentation] Wait until the device becomes available through Netconf.
58 NetconfKeywords.Wait_Device_Connected ${DEVICE_NAME}
60 Check_Device_Data_Is_Empty
61 [Documentation] Get the device data and make sure it is empty.
62 Run_Keyword_If_Less_Than_Neon Check_Config_Data <data xmlns\="${ODL_NETCONF_NAMESPACE}"></data>
63 Run_Keyword_If_At_Least_Neon Check_Config_Data <data xmlns\="${ODL_NETCONF_NAMESPACE}"/>
65 Invoke_Yang1.1_Action_Via_Xml_Post
66 [Documentation] Send a sample test data label into the device and check that the request went OK.
67 ${template_as_string} = BuiltIn.Set_Variable {'DEVICE_NAME': '${DEVICE_NAME}'}
68 TemplatedRequests.Post_As_Xml_Templated ${DIRECTORY_WITH_TEMPLATE_FOLDERS}${/}dataorigaction ${template_as_string}
70 Invoke_Yang1.1_Action_Via_Json_Post
71 [Documentation] Send a sample test data label into the device and check that the request went OK.
72 ${template_as_string} = BuiltIn.Set_Variable {'DEVICE_NAME': '${DEVICE_NAME}'}
73 TemplatedRequests.Post_As_Json_RFC8040_Templated ${DIRECTORY_WITH_TEMPLATE_FOLDERS}${/}dataorigaction ${template_as_string}
75 Deconfigure_Device_From_Netconf
76 [Documentation] Make request to deconfigure the testtool device on Netconf connector.
78 [Setup] SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
79 CompareStream.Run_Keyword_If_At_Most_Nitrogen NetconfKeywords.Remove_Device_From_Netconf ${DEVICE_NAME} location=${DELETE_LOCATION}
80 CompareStream.Run_Keyword_If_At_Least_Oxygen NetconfKeywords.Configure_Device_In_Netconf ${DEVICE_NAME} device_type=${DEVICE_TYPE_RPC_DELETE} http_timeout=2 http_method=post
82 Check_Device_Going_To_Be_Gone_After_Deconfiguring
83 [Documentation] Check that the device is really going to be gone. Fail
84 ... if found after one minute. This is an expected behavior as the
85 ... delete request is sent to the config subsystem which then triggers
86 ... asynchronous destruction of the netconf connector referring to the
87 ... device and the device's data. This test makes sure this
88 ... asynchronous operation does not take unreasonable amount of time
89 ... by making sure that both the netconf connector and the device's
90 ... data is gone before reporting success.
92 NetconfKeywords.Wait_Device_Fully_Removed ${DEVICE_NAME}
96 [Documentation] Initialize SetupUtils. Setup everything needed for the test cases.
97 SetupUtils.Setup_Utils_For_Setup_And_Teardown
98 RequestsLibrary.Create_Session operational http://${ODL_SYSTEM_IP}:${RESTCONFPORT}${OPERATIONAL_API} auth=${AUTH}
99 NetconfKeywords.Setup_Netconf_Keywords
100 ${DEVICE_TYPE_RPC} = BuiltIn.Set_Variable_If """${USE_NETCONF_CONNECTOR}""" == """True""" default ${DEVICE_TYPE_RPC}
101 ${DEVICE_TYPE} = CompareStream.Set_Variable_If_At_Most_Nitrogen ${DEVICE_TYPE_RPC} ${DEVICE_TYPE_RPC_CREATE}
102 BuiltIn.Set_Suite_Variable ${DEVICE_TYPE}
103 OperatingSystem.File Should Exist ${RPC_FILE}
104 NetconfKeywords.Install_And_Start_Testtool device-count=1 schemas=${CURDIR}/../../../variables/netconf/CRUD/schemas rpc_config=${RPC_FILE}
107 [Documentation] Teardown the test infrastructure, perform cleanup and release all resources.
108 RequestsLibrary.Delete_All_Sessions
109 BuiltIn.Run_Keyword_And_Ignore_Error NetconfKeywords.Stop_Testtool
112 [Documentation] Get and return the config data from the device.
113 ${url} = Builtin.Set_Variable ${CONFIG_API}/network-topology:network-topology/topology/topology-netconf/node/${DEVICE_NAME}/yang-ext:mount
114 ${data} = TemplatedRequests.Get_As_Xml_From_Uri ${url}
118 [Arguments] ${expected} ${contains}=False
119 ${data} = Get_Config_Data
120 BuiltIn.Run_Keyword_Unless ${contains} BuiltIn.Should_Be_Equal_As_Strings ${data} ${expected}
121 BuiltIn.Run_Keyword_If ${contains} BuiltIn.Should_Contain ${data} ${expected}