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
82 [Documentation] Checks netconf readiness.
83 BuiltIn.Pass_Execution_If ${USE_NETCONF_CONNECTOR}==${True} Netconf connector is used. Next testcases do their job in this case.
84 BuiltIn.Wait_Until_Keyword_Succeeds 10x 1s Check_Netconf_Topology_Ready
86 Check_Whether_Netconf_Connector_Is_Up_And_Running
87 [Documentation] Make one request to Netconf topology to see whether Netconf is up and running.
89 Check_Netconf_Up_And_Running
90 BuiltIn.Set_Suite_Variable ${netconf_is_ready} True
92 Wait_For_Netconf_Connector
93 [Documentation] Wait for the Netconf to go up for configurable time.
95 BuiltIn.Run_Keyword_Unless ${netconf_is_ready} BuiltIn.Wait_Until_Keyword_Succeeds ${NETCONFREADY_WAIT} 1s Check_Netconf_Up_And_Running
96 BuiltIn.Set_Suite_Variable ${netconf_is_ready} True
99 [Documentation] Bugs such as 7175 may require to wait longer till netconf-connector works.
101 BuiltIn.Pass_Execution_If ${netconf_is_ready} Netconf was detected to be up and running so bug 5014 did not show up.
102 BuiltIn.Wait_Until_Keyword_Succeeds ${NETCONFREADY_FALLBACK_WAIT} 10s Check_Netconf_Up_And_Running
103 BuiltIn.Set_Suite_Variable ${netconf_is_ready} True
106 [Documentation] If Netconf appears to be down, it may be due to bug 5014. Check if it is so and fail if yes.
107 ... Bug 5014 is about Netconf playing dead on boot until a device
108 ... configuration request is sent to it. To uncover this attempt to
109 ... configure and then deconfigure a device and then check if Netconf
110 ... is now up and running. If that turns out to be true, fail the case
111 ... as this signifies the bug 5014 to be present. Skip this testcase
112 ... if Netconf is detected to be up and running.
114 BuiltIn.Pass_Execution_If ${netconf_is_ready} Netconf was detected to be up and running so bug 5014 did not show up.
115 ${status} ${error}= BuiltIn.Run_Keyword_And_Ignore_Error Check_Netconf_Usable
116 BuiltIn.Run_Keyword_If '${status}'=='PASS' BuiltIn.Set_Suite_Variable ${netconf_is_ready} True
117 BuiltIn.Should_Be_Equal '${status}' 'FAIL'
119 Check_Whether_Netconf_Can_Pretty_Print
120 [Documentation] Make one request to netconf-connector and see if it works.
122 BuiltIn.Run_Keyword_Unless ${netconf_is_ready} Fail Netconf is not ready so it can't pretty-print now.
123 Check_Netconf_Up_And_Running ?prettyPrint=true
127 [Documentation] Wait for the MDSAL feature to become online
128 ${status} ${message}= BuiltIn.Run_Keyword_And_Ignore_Error KarafKeywords.Verify_Feature_Is_Installed odl-netconf-mdsal
129 BuiltIn.Run_Keyword_If '${status}' == 'FAIL' BuiltIn.Pass_Execution The 'odl-netconf-mdsal' feature is not installed so no need to wait for it.
130 SSHKeywords.Open_Connection_To_ODL_System
131 BuiltIn.Wait_Until_Keyword_Succeeds ${NETCONFREADY_WAIT_MDSAL} 1s Check_Netconf_MDSAL_Up_And_Running
132 SSHLibrary.Close_Connection
136 [Documentation] Initialize SetupUtils. Setup requests library and log into karaf.log that the netconf readiness wait starts.
137 SetupUtils.Setup_Utils_For_Setup_And_Teardown
138 ${connector}= Set_Netconf_Connector
139 BuiltIn.Set_Suite_Variable ${netconf_connector} ${connector}
140 BuiltIn.Comment A workaround for EOF error follows. TODO: Create a test case for the EOF bug, possibly tagged "exclude".
141 BuiltIn.Wait_Until_Keyword_Succeeds 2x 1s KarafKeywords.Open_Controller_Karaf_Console_On_Background
142 KarafKeywords.Log_Message_To_Controller_Karaf Starting Netconf readiness test suite
143 BuiltIn.Run_Keyword_If ${DEBUG_LOGGING_FOR_EVERYTHING} KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set DEBUG
144 RequestsLibrary.Create_Session ses http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
145 NetconfKeywords.Setup_Netconf_Keywords
148 [Documentation] Destroy all sessions in the requests library and log into karaf.log that the netconf readiness wait is over.
149 KarafKeywords.Log_Message_To_Controller_Karaf Ending Netconf readiness test suite
150 RequestsLibrary.Delete_All_Sessions
152 Set_Netconf_Connector
153 [Documentation] Sets netconf connector verify url according to the ${ODL_STREAM} and ${USE_NETCONF_CONNECTOR} combination
154 ${streamconnector}= Set Variable /node/controller-config/yang-ext:mount/config:modules/module/sal-restconf-service:json-restconf-service-impl/json-restconf-service-impl
155 ${connector}= BuiltIn.Set_Variable_If ${USE_NETCONF_CONNECTOR} ${streamconnector} ${EMPTY}
156 BuiltIn.Return_From_Keyword ${connector}
158 Check_Netconf_Topology_Ready
159 [Documentation] Verifies the netconf readiness for every odl node.
160 FOR ${idx} IN @{ClusterManagement__member_index_list}
161 Verify_Netconf_Topology_Ready_For_Node ${idx}
164 Verify_Netconf_Topology_Ready_For_Node
165 [Arguments] ${node_index}
166 [Documentation] Netconf readines for a node is done by creating a netconf device connected to that node
167 ... and performing GET operation got from the device's mount point.
168 ${session} = ClusterManagement.Resolve_Http_Session_For_Member member_index=${node_index}
169 Configure_Netconf_Device ${DEVICE_NAME} ${session} ${ODL_SYSTEM_${node_index}_IP}
170 &{mapping} BuiltIn.Create_Dictionary DEVICE_NAME=${DEVICE_NAME}
171 Wait_Netconf_Device_Mounted ${DEVICE_NAME} ${session} ${mapping}
172 FOR ${idx} IN @{ClusterManagement__member_index_list}
173 ${mod_session}= ClusterManagement.Resolve_Http_Session_For_Member member_index=${idx}
174 BuiltIn.Wait_Until_Keyword_Succeeds 5x 3s TemplatedRequests.Get_As_Xml_Templated ${NETCONF_FOLDER}${/}netconf-state mapping=${mapping}
175 ... session=${mod_session}
177 [Teardown] Remove_Netconf_Device ${DEVICE_NAME} ${session}
179 Configure_Netconf_Device
180 [Arguments] ${device_name} ${session} ${device_ip}
181 [Documentation] Configures the device via REST api.
182 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
183 ... session=${session}
185 Remove_Netconf_Device
186 [Arguments] ${device_name} ${session}
187 [Documentation] Removes configured device
188 NetconfKeywords.Remove_Device_From_Netconf ${device_name} session=${session}
190 Wait_Netconf_Device_Mounted
191 [Arguments] ${device_name} ${session} ${mapping} ${timeout}=30s
192 [Documentation] Checks weather the device was mounted.
193 BuiltIn.Wait_Until_Keyword_Succeeds ${timeout} 3s TemplatedRequests.Get_As_Xml_Templated ${NETCONF_FOLDER}${/}full-uri-mount mapping=${mapping} session=${session}
195 Check_Netconf_Up_And_Running
196 [Arguments] ${pretty_print}=${EMPTY}
197 [Documentation] Make a request to netconf connector's list of mounted devices and check that the request was successful.
198 ${response}= RequestsLibrary.Get_Request ses rests/data/network-topology:network-topology/topology\=topology-netconf${netconf_connector}${pretty_print}
199 BuiltIn.Log ${response.text}
200 ${status}= BuiltIn.Run_Keyword_And_Return_Status BuiltIn.Should_Contain ${response.text} data model content does not exist
201 BuiltIn.Run_Keyword_If ${status} BuiltIn.Set_Suite_Variable ${netconf_not_ready_cause} 5832
202 BuiltIn.Run_Keyword_If ${status} SetupUtils.Set_Known_Bug_Id 5832
203 BuiltIn.Should_Be_Equal_As_Strings ${response.status_code} 200
206 NetconfKeywords.Configure_Device_In_Netconf test-device device_type=configure-via-topology
207 NetconfKeywords.Remove_Device_From_Netconf test-device
208 Check_Netconf_Up_And_Running
210 Check_Netconf_MDSAL_Up_And_Running
211 ${count}= SSHKeywords.Count_Port_Occurences ${ODL_NETCONF_MDSAL_PORT} LISTEN java
212 BuiltIn.Should_Be_Equal_As_Integers ${count} 1