2 Documentation netconf-connector readiness test suite.
4 ... Copyright (c) 2015,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 ... Try to detect whether Netconf is up and running and wait for
12 ... it for a configurable time if it is not yet up and running.
14 ... This is achieved by the test Check_Whether_Netconf_Topology_Is_Ready. This test case
15 ... does not use controller-config device. This test case is skipped (Pass Execution) if
16 ... the usage of controller-config device is indicated.
17 ... Testing itself is done by creating a netconf test device configured
18 ... to all odl nodes one by one and check if GET works from mounted
19 ... device. GET is done from all the odl nodes and it works for both, 1 or 3 nodes
22 ... The next test cases are basically dedicated to test readiness of the netconf using
23 ... controller-config device. This device is created when odl-netconf-connector-ssh|all
24 ... feature is installed. Robot variable USE_NETCONF_CONNECTOR should be set to True.
25 ... Connector test cases change behavior depending on ${USE_NETCONF_CONNECTOR}. If True,
26 ... they check data mounted behind controller-config is readable, if False they only check
27 ... topology-netconf is readable.
29 ... Some testsuites expect netconf-connector to be ready as soon as possible and will
30 ... fail if it is not. We want to see a failure if this is the cause of the failure.
33 ... The usage of netconf-connector happens in other suites than netconf,
34 ... especially bgpcep to configure odl's bgp peers. Testing the readiness
35 ... of the netconf-connector must be invoked by the Robot invocation
36 ... argument USE_NETCONF_CONNECTOR. By default it is set to False and
37 ... test jobs should be responsible to set it to True if needed. In the
38 ... default configuration the affected test cases waits for the netconf
39 ... topology to appear only.
41 ... If the netconf-connector is not ready upon startup and it's usage is set
42 ... to True (as seen by the second test case failing), the next case starts
43 ... to repeat the query for a minute to see whether it is going "to fix itself"
44 ... within the minute. If yes, then the testcase will pass, which
45 ... indicates that the "ODL cooldown" of 1 minute is not long enough
46 ... to allow for netconf-connector to initialize properly.
47 ... If this fails, one more check with even longer timeout is run.
48 ... If the Check_Whether_Netconf_Is_Up_And_Running pass, then the next test
49 ... case does nothing.
51 ... The other test case then checks whether Netconf can pretty print
52 ... data. This sometimes makes problems, most likely due to too
53 ... new Robot Requests library with an interface incompatible with
55 Suite Setup Setup_Everything
56 Suite Teardown Teardown_Everything
57 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
58 Test Teardown SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
59 Resource ${CURDIR}/../../../libraries/ClusterManagement.robot
60 Resource ${CURDIR}/../../../libraries/CompareStream.robot
61 Resource ${CURDIR}/../../../libraries/KarafKeywords.robot
62 Library RequestsLibrary
63 Resource ${CURDIR}/../../../libraries/NetconfKeywords.robot
64 Resource ${CURDIR}/../../../libraries/SetupUtils.robot
65 Resource ${CURDIR}/../../../libraries/SSHKeywords.robot
66 Variables ${CURDIR}/../../../variables/Variables.py
69 ${netconf_is_ready} False
70 ${NETCONFREADY_WAIT} 60s
71 ${NETCONFREADY_FALLBACK_WAIT} 1200s
72 ${USE_NETCONF_CONNECTOR} False
73 ${DEBUG_LOGGING_FOR_EVERYTHING} False
74 ${NETCONFREADY_WAIT_MDSAL} 60s
75 ${DEVICE_NAME} test-device
77 ${NETCONF_FOLDER} ${CURDIR}/../../../variables/netconf/device
80 Check_Whether_Netconf_Topology_Is_Ready
81 [Documentation] Checks netconf readiness.
82 BuiltIn.Pass_Execution_If ${USE_NETCONF_CONNECTOR}==${True} Netconf connector is used. Next testcases do their job in this case.
83 BuiltIn.Wait_Until_Keyword_Succeeds 10x 1s Check_Netconf_Topology_Ready
85 Check_Whether_Netconf_Connector_Is_Up_And_Running
86 [Documentation] Make one request to Netconf topology to see whether Netconf is up and running.
88 Check_Netconf_Up_And_Running
89 BuiltIn.Set_Suite_Variable ${netconf_is_ready} True
91 Wait_For_Netconf_Connector
92 [Documentation] Wait for the Netconf to go up for configurable time.
94 BuiltIn.Run_Keyword_Unless ${netconf_is_ready} BuiltIn.Wait_Until_Keyword_Succeeds ${NETCONFREADY_WAIT} 1s Check_Netconf_Up_And_Running
95 BuiltIn.Set_Suite_Variable ${netconf_is_ready} True
98 [Documentation] Bugs such as 7175 may require to wait longer till netconf-connector works.
100 BuiltIn.Pass_Execution_If ${netconf_is_ready} Netconf was detected to be up and running so bug 5014 did not show up.
101 BuiltIn.Wait_Until_Keyword_Succeeds ${NETCONFREADY_FALLBACK_WAIT} 10s Check_Netconf_Up_And_Running
102 BuiltIn.Set_Suite_Variable ${netconf_is_ready} True
105 [Documentation] If Netconf appears to be down, it may be due to bug 5014. Check if it is so and fail if yes.
106 ... Bug 5014 is about Netconf playing dead on boot until a device
107 ... configuration request is sent to it. To uncover this attempt to
108 ... configure and then deconfigure a device and then check if Netconf
109 ... is now up and running. If that turns out to be true, fail the case
110 ... as this signifies the bug 5014 to be present. Skip this testcase
111 ... if Netconf is detected to be up and running.
113 BuiltIn.Pass_Execution_If ${netconf_is_ready} Netconf was detected to be up and running so bug 5014 did not show up.
114 ${status} ${error}= BuiltIn.Run_Keyword_And_Ignore_Error Check_Netconf_Usable
115 BuiltIn.Run_Keyword_If '${status}'=='PASS' BuiltIn.Set_Suite_Variable ${netconf_is_ready} True
116 BuiltIn.Should_Be_Equal '${status}' 'FAIL'
118 Check_Whether_Netconf_Can_Pretty_Print
119 [Documentation] Make one request to netconf-connector and see if it works.
121 BuiltIn.Run_Keyword_Unless ${netconf_is_ready} Fail Netconf is not ready so it can't pretty-print now.
122 Check_Netconf_Up_And_Running ?prettyPrint=true
125 [Documentation] Wait for the MDSAL feature to become online
126 ${status} ${message}= BuiltIn.Run_Keyword_And_Ignore_Error KarafKeywords.Verify_Feature_Is_Installed odl-netconf-mdsal
127 BuiltIn.Run_Keyword_If '${status}' == 'FAIL' BuiltIn.Pass_Execution The 'odl-netconf-mdsal' feature is not installed so no need to wait for it.
128 SSHKeywords.Open_Connection_To_ODL_System
129 BuiltIn.Wait_Until_Keyword_Succeeds ${NETCONFREADY_WAIT_MDSAL} 1s Check_Netconf_MDSAL_Up_And_Running
130 SSHLibrary.Close_Connection
134 [Documentation] Initialize SetupUtils. Setup requests library and log into karaf.log that the netconf readiness wait starts.
135 SetupUtils.Setup_Utils_For_Setup_And_Teardown
136 ${connector}= Set_Netconf_Connector
137 BuiltIn.Set_Suite_Variable ${netconf_connector} ${connector}
138 BuiltIn.Comment A workaround for EOF error follows. TODO: Create a test case for the EOF bug, possibly tagged "exclude".
139 BuiltIn.Wait_Until_Keyword_Succeeds 2x 1s KarafKeywords.Open_Controller_Karaf_Console_On_Background
140 KarafKeywords.Log_Message_To_Controller_Karaf Starting Netconf readiness test suite
141 BuiltIn.Run_Keyword_If ${DEBUG_LOGGING_FOR_EVERYTHING} KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set DEBUG
142 RequestsLibrary.Create_Session ses http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
143 NetconfKeywords.Setup_Netconf_Keywords
146 [Documentation] Destroy all sessions in the requests library and log into karaf.log that the netconf readiness wait is over.
147 KarafKeywords.Log_Message_To_Controller_Karaf Ending Netconf readiness test suite
148 RequestsLibrary.Delete_All_Sessions
150 Set_Netconf_Connector
151 [Documentation] Sets netconf connector verify url according to the ${ODL_STREAM} and ${USE_NETCONF_CONNECTOR} combination
152 ${streamconnector}= Set Variable /node/controller-config/yang-ext:mount/config:modules/module/sal-restconf-service:json-restconf-service-impl/json-restconf-service-impl
153 ${connector}= BuiltIn.Set_Variable_If ${USE_NETCONF_CONNECTOR} ${streamconnector} ${EMPTY}
154 BuiltIn.Return_From_Keyword ${connector}
156 Check_Netconf_Topology_Ready
157 [Documentation] Verifies the netconf readiness for every odl node.
158 FOR ${idx} IN @{ClusterManagement__member_index_list}
159 Verify_Netconf_Topology_Ready_For_Node ${idx}
162 Verify_Netconf_Topology_Ready_For_Node
163 [Arguments] ${node_index}
164 [Documentation] Netconf readines for a node is done by creating a netconf device connected to that node
165 ... and performing GET operation got from the device's mount point.
166 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${node_index}
167 Configure_Netconf_Device ${DEVICE_NAME} ${session} ${ODL_SYSTEM_${node_index}_IP}
168 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME}
169 Wait_Netconf_Device_Mounted ${DEVICE_NAME} ${session} ${mapping}
170 FOR ${idx} IN @{ClusterManagement__member_index_list}
171 ${mod_session}= ClusterManagement.Resolve_Http_Session_For_Member member_index=${idx}
172 BuiltIn.Wait_Until_Keyword_Succeeds 5x 3s TemplatedRequests.Get_As_Xml_Templated ${NETCONF_FOLDER}${/}netconf-state mapping=${mapping}
173 ... session=${mod_session}
175 [Teardown] Remove_Netconf_Device ${DEVICE_NAME} ${session}
177 Configure_Netconf_Device
178 [Arguments] ${device_name} ${session} ${device_ip}
179 [Documentation] Configures the device via REST api.
180 NetconfKeywords.Configure_Device_In_Netconf ${device_name} device_type=full-uri-device device_port=${DEVICE_PORT} device_address=${device_ip} device_user=admin device_password=admin
181 ... session=${session}
183 Remove_Netconf_Device
184 [Arguments] ${device_name} ${session}
185 [Documentation] Removes configured device
186 NetconfKeywords.Remove_Device_From_Netconf ${device_name} session=${session}
188 Wait_Netconf_Device_Mounted
189 [Arguments] ${device_name} ${session} ${mapping} ${timeout}=30s
190 [Documentation] Checks weather the device was mounted.
191 BuiltIn.Wait_Until_Keyword_Succeeds ${timeout} 3s TemplatedRequests.Get_As_Xml_Templated ${NETCONF_FOLDER}${/}full-uri-mount mapping=${mapping} session=${session}
193 Check_Netconf_Up_And_Running
194 [Arguments] ${pretty_print}=${EMPTY}
195 [Documentation] Make a request to netconf connector's list of mounted devices and check that the request was successful.
196 ${response}= RequestsLibrary.Get_Request ses restconf/config/network-topology:network-topology/topology/topology-netconf${netconf_connector}${pretty_print}
197 BuiltIn.Log ${response.text}
198 ${status}= BuiltIn.Run_Keyword_And_Return_Status BuiltIn.Should_Contain ${response.text} data model content does not exist
199 BuiltIn.Run_Keyword_If ${status} BuiltIn.Set_Suite_Variable ${netconf_not_ready_cause} 5832
200 BuiltIn.Run_Keyword_If ${status} SetupUtils.Set_Known_Bug_Id 5832
201 BuiltIn.Should_Be_Equal_As_Strings ${response.status_code} 200
204 NetconfKeywords.Configure_Device_In_Netconf test-device device_type=configure-via-topology
205 NetconfKeywords.Remove_Device_From_Netconf test-device
206 Check_Netconf_Up_And_Running
208 Check_Netconf_MDSAL_Up_And_Running
209 ${count}= SSHKeywords.Count_Port_Occurences ${ODL_NETCONF_MDSAL_PORT} LISTEN java
210 BuiltIn.Should_Be_Equal_As_Integers ${count} 1