2 Documentation Basic tests for BGP application peer.
4 ... Copyright (c) 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
10 ... Test suite performs basic subscribtion case for data store notifications.
11 ... For procedure description see the
12 ... https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL:Restconf:Change_event_notification_subscription
15 ... This suite uses inventory (config part) as an area to make dummy writes into,
16 ... just to trigger data change listener to produce a notification.
17 ... Openflowplugin may have some data there, and before Boron, netconf-connector
18 ... was also exposing some data in inventory.
20 ... To avoid unexpected responses, this suite depetes all data from config inventory,
21 ... so this suite should not be followed by any suite expecting default data there.
24 ... Bug 3934 - Websockets: Scope ONE doesn't work correctly
26 ... TODO: Use cars/people model for data
29 Library OperatingSystem
30 Library RequestsLibrary
31 Library SSHLibrary timeout=10s
33 Resource ${CURDIR}/../../../libraries/ClusterManagement.robot
34 Resource ${CURDIR}/../../../libraries/FailFast.robot
35 Resource ${CURDIR}/../../../libraries/KarafKeywords.robot
36 Resource ${CURDIR}/../../../libraries/NetconfKeywords.robot
37 Resource ${CURDIR}/../../../libraries/Restconf.robot
38 Resource ${CURDIR}/../../../libraries/SetupUtils.robot
39 Resource ${CURDIR}/../../../libraries/SSHKeywords.robot
40 Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot
41 Resource ${CURDIR}/../../../libraries/WaitForFailure.robot
42 Resource ${CURDIR}/../../../variables/Variables.robot
44 Suite Setup Setup_Everything
45 Suite Teardown Teardown_Everything
46 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
47 Test Teardown SetupUtils.Teardown_Test_Show_Bugs_And_Start_Fast_Failing_If_Test_Failed
51 ${TEMPLATE_FOLDER} ${CURDIR}/templates
52 ${DRAFT_STREAMS_URI} restconf/streams
53 ${RFC8040_STREAMS_URI} rests/data/ietf-restconf-monitoring:restconf-state/streams
54 ${NODES_STREAM_PATH} network-topology:network-topology/datastore=CONFIGURATION/scope=BASE
55 ${DRAFT_DCN_STREAM_URI} ${DRAFT_STREAMS_URI}/stream/data-change-event-subscription/${NODES_STREAM_PATH}
56 ${RFC8040_DCN_STREAM_URI} ${RFC8040_STREAMS_URI}/stream/data-change-event-subscription/${NODES_STREAM_PATH}
57 ${RESTCONF_SUBSCRIBE_DATA} subscribe.xml
58 ${RESTCONF_CONFIG_DATA} config_data.xml
59 ${RECEIVER_LOG_FILE} receiver.log
60 ${RECEIVER_OPTIONS} ${EMPTY}
61 ${CONTROLLER_LOG_LEVEL} INFO
66 [Documentation] Create DCN stream.
68 Comment Create DCN subscription
69 ${body} = OperatingSystem.Get_File ${TEMPLATE_FOLDER}/${RESTCONF_SUBSCRIBE_DATA}
70 ${uri} = Restconf.Generate URI sal-remote:create-data-change-event-subscription rpc
71 ${resp} = RequestsLibrary.Post_On_Session
74 ... headers=${SEND_ACCEPT_XML_HEADERS}
77 BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
79 Subscribe_To_DCN_Stream
80 [Documentation] Subscribe to DCN streams.
82 ${uri} = Set Variable If "${USE_RFC8040}" == "False" ${DRAFT_DCN_STREAM_URI} ${RFC8040_DCN_STREAM_URI}
83 ${resp} = RequestsLibrary.Get_On_Session restconf url=${uri} headers=${SEND_ACCEPT_XML_HEADERS}
85 BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
86 ${location} = XML.Get_Element_Text ${resp.content}
87 BuiltIn.Log ${location}
88 BuiltIn.Log ${resp.headers["Location"]}
89 Should Contain ${location} ${resp.headers["Location"]}
90 BuiltIn.Set_Suite_Variable ${location}
93 [Documentation] List DCN streams.
95 ${uri} = BuiltIn.Set_Variable_If
96 ... "${USE_RFC8040}" == "False"
97 ... ${DRAFT_STREAMS_URI}
98 ... ${RFC8040_STREAMS_URI}
99 ${resp} = RequestsLibrary.Get_On_Session restconf url=${uri} headers=${SEND_ACCEPT_XML_HEADERS}
101 BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
102 Comment Stream only shows in RFC URL.
103 IF "${USE_RFC8040}" == "True"
104 BuiltIn.Should_Contain ${resp.text} ${NODES_STREAM_PATH}
108 [Documentation] Start the websocket listener
109 IF "${USE_RFC8040}" == "False"
110 ${output} = SSHLibrary.Write
111 ... python3 wsreceiver.py --uri ${location} --count 2 --logfile ${RECEIVER_LOG_FILE} ${RECEIVER_OPTIONS}
113 ${output} = SSHLibrary.Write python3 ssereceiver.py --uri ${location} --logfile ${RECEIVER_LOG_FILE}
115 BuiltIn.Log ${output}
116 ${output} = SSHLibrary.Read delay=2s
117 BuiltIn.Log ${output}
120 [Documentation] Make a change in DS configuration.
122 ${body} = OperatingSystem.Get_File ${TEMPLATE_FOLDER}/${RESTCONF_CONFIG_DATA}
123 ${uri} = BuiltIn.Set_Variable_If
124 ... "${USE_RFC8040}" == "False"
125 ... /restconf/config/network-topology:network-topology
126 ... /rests/data/network-topology:network-topology
127 ${resp} = RequestsLibrary.Put_On_Session
130 ... headers=${SEND_ACCEPT_XML_HEADERS}
133 BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
134 ${uri} = BuiltIn.Set_Variable_If
135 ... "${USE_RFC8040}" == "False"
136 ... /restconf/config/network-topology:network-topology/topology/netconf-notif
137 ... /rests/data/network-topology:network-topology/topology=netconf-notif
138 ${resp} = RequestsLibrary.Delete_On_Session restconf ${uri} headers=${SEND_ACCEPT_XML_HEADERS}
140 BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
143 [Documentation] Check the WSS/SSE listener log for a change notification.
145 ${notification} = SSHLibrary.Execute_Command cat ${RECEIVER_LOG_FILE}
146 BuiltIn.Log ${notification}
147 BuiltIn.Set_Suite_Variable ${notification}
148 BuiltIn.Should_Contain ${notification} <notification xmlns=
149 BuiltIn.Should_Contain ${notification} <eventTime>
150 BuiltIn.Should_Contain ${notification} <data-changed-notification xmlns=
151 BuiltIn.Should_Contain ${notification} <operation>updated</operation>
152 BuiltIn.Should_Contain ${notification} </data-change-event>
153 BuiltIn.Should_Contain ${notification} </data-changed-notification>
154 BuiltIn.Should_Contain ${notification} </notification>
156 Check_Delete_Notification
157 [Documentation] Check the websocket listener log for a delete notification.
159 BuiltIn.Should_Contain ${notification} <operation>deleted</operation>
162 [Documentation] Check the websocket listener log for the bug correction.
164 ${data} = OperatingSystem.Get_File ${TEMPLATE_FOLDER}/${RESTCONF_CONFIG_DATA}
166 BuiltIn.Log ${notification}
167 ${packed_data} = String.Remove_String ${data} \n
168 ${packed_data} = String.Remove_String ${packed_data} ${SPACE}
169 ${packed_notification} = String.Remove_String ${notification} \n
170 ${packed_notification} = String.Remove_String ${packed_notification} \\n
171 ${packed_notification} = String.Remove_String ${packed_notification} ${SPACE}
172 BuiltIn.Should_Contain ${packed_notification} ${packed_data}
173 [Teardown] Report_Failure_Due_To_Bug 3934
178 [Documentation] SSH-login to mininet machine, create HTTP session,
179 ... prepare directories for responses, put Python tool to mininet machine, setup imported resources.
180 SetupUtils.Setup_Utils_For_Setup_And_Teardown
181 KarafKeywords.Open_Controller_Karaf_Console_On_Background
182 SSHKeywords.Open_Connection_To_Tools_System
183 SSHLibrary.Put_File ${CURDIR}/../../../../tools/wstools/wsreceiver.py
184 SSHLibrary.Put_File ${CURDIR}/../../../../tools/wstools/ssereceiver.py
185 SSHLibrary.Execute_Command sudo apt-get install -y python3-pip return_stdout=True return_stderr=True
186 SSHLibrary.Execute_Command
187 ... sudo python3 -m pip install --upgrade pip setuptools wheel
188 ... return_stdout=True
189 ... return_stderr=True
190 SSHLibrary.Execute_Command
191 ... sudo python3 -m pip install websocket-client asyncio aiohttp aiohttp-sse-client coroutine
192 ... return_stdout=True
193 ... return_stderr=True
194 RequestsLibrary.Create_Session restconf http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
195 KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set ${CONTROLLER_LOG_LEVEL}
198 [Documentation] Close connections.
199 ... Tear down imported Resources.
200 RequestsLibrary.Delete_All_Sessions
201 SSHLibrary.Close_All_Connections
204 [Documentation] Log response.
207 BuiltIn.Log ${resp.headers}
208 BuiltIn.Log ${resp.text}