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 ${RFC8040_STREAMS_URI} rests/data/ietf-restconf-monitoring:restconf-state/streams
53 ${NODES_STREAM_PATH} network-topology:network-topology/datastore=CONFIGURATION/scope=BASE
54 ${RFC8040_DCN_STREAM_URI} ${RFC8040_STREAMS_URI}/stream/data-change-event-subscription/${NODES_STREAM_PATH}
55 ${RESTCONF_SUBSCRIBE_DATA} subscribe.xml
56 ${RESTCONF_CONFIG_DATA} config_data.xml
57 ${RECEIVER_LOG_FILE} receiver.log
58 ${CONTROLLER_LOG_LEVEL} INFO
63 [Documentation] Create DCN stream.
65 Comment Create DCN subscription
66 ${body} = OperatingSystem.Get_File ${TEMPLATE_FOLDER}/${RESTCONF_SUBSCRIBE_DATA}
67 ${uri} = Restconf.Generate URI sal-remote:create-data-change-event-subscription rpc
68 ${resp} = RequestsLibrary.Post_On_Session
71 ... headers=${SEND_ACCEPT_XML_HEADERS}
74 BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
76 Subscribe_To_DCN_Stream
77 [Documentation] Subscribe to DCN streams.
79 ${resp} = RequestsLibrary.Get_On_Session restconf url=${RFC8040_DCN_STREAM_URI} headers=${SEND_ACCEPT_XML_HEADERS}
81 BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
82 ${location} = XML.Get_Element_Text ${resp.content}
83 BuiltIn.Log ${location}
84 BuiltIn.Log ${resp.headers["Location"]}
85 Should Contain ${location} ${resp.headers["Location"]}
86 BuiltIn.Set_Suite_Variable ${location}
89 [Documentation] List DCN streams.
91 ${resp} = RequestsLibrary.Get_On_Session restconf url=${RFC8040_DCN_STREAM_URI} headers=${SEND_ACCEPT_XML_HEADERS}
93 BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
94 Comment Stream only shows in RFC URL.
95 BuiltIn.Should_Contain ${resp.text} ${NODES_STREAM_PATH}
98 [Documentation] Start the websocket listener
99 ${output} = SSHLibrary.Write python3 ssereceiver.py --uri ${location} --logfile ${RECEIVER_LOG_FILE}
100 BuiltIn.Log ${output}
101 ${output} = SSHLibrary.Read delay=2s
102 BuiltIn.Log ${output}
105 [Documentation] Make a change in DS configuration.
107 ${body} = OperatingSystem.Get_File ${TEMPLATE_FOLDER}/${RESTCONF_CONFIG_DATA}
108 ${uri} = BuiltIn.Set_Variable /rests/data/network-topology:network-topology
109 ${resp} = RequestsLibrary.Put_On_Session
112 ... headers=${SEND_ACCEPT_XML_HEADERS}
115 BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
116 ${uri} = BuiltIn.Set_Variable /rests/data/network-topology:network-topology/topology=netconf-notif
117 ${resp} = RequestsLibrary.Delete_On_Session restconf ${uri} headers=${SEND_ACCEPT_XML_HEADERS}
119 BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
122 [Documentation] Check the WSS/SSE listener log for a change notification.
124 ${notification} = SSHLibrary.Execute_Command cat ${RECEIVER_LOG_FILE}
125 BuiltIn.Log ${notification}
126 BuiltIn.Set_Suite_Variable ${notification}
127 BuiltIn.Should_Contain ${notification} <notification xmlns=
128 BuiltIn.Should_Contain ${notification} <eventTime>
129 BuiltIn.Should_Contain ${notification} <data-changed-notification xmlns=
130 BuiltIn.Should_Contain ${notification} <operation>updated</operation>
131 BuiltIn.Should_Contain ${notification} </data-change-event>
132 BuiltIn.Should_Contain ${notification} </data-changed-notification>
133 BuiltIn.Should_Contain ${notification} </notification>
135 Check_Delete_Notification
136 [Documentation] Check the websocket listener log for a delete notification.
138 BuiltIn.Should_Contain ${notification} <operation>deleted</operation>
141 [Documentation] Check the websocket listener log for the bug correction.
143 ${data} = OperatingSystem.Get_File ${TEMPLATE_FOLDER}/${RESTCONF_CONFIG_DATA}
145 BuiltIn.Log ${notification}
146 ${packed_data} = String.Remove_String ${data} \n
147 ${packed_data} = String.Remove_String ${packed_data} ${SPACE}
148 ${packed_notification} = String.Remove_String ${notification} \n
149 ${packed_notification} = String.Remove_String ${packed_notification} \\n
150 ${packed_notification} = String.Remove_String ${packed_notification} ${SPACE}
151 BuiltIn.Should_Contain ${packed_notification} ${packed_data}
152 [Teardown] Report_Failure_Due_To_Bug 3934
157 [Documentation] SSH-login to mininet machine, create HTTP session,
158 ... prepare directories for responses, put Python tool to mininet machine, setup imported resources.
159 SetupUtils.Setup_Utils_For_Setup_And_Teardown
160 KarafKeywords.Open_Controller_Karaf_Console_On_Background
161 SSHKeywords.Open_Connection_To_Tools_System
162 SSHLibrary.Put_File ${CURDIR}/../../../../tools/wstools/wsreceiver.py
163 SSHLibrary.Put_File ${CURDIR}/../../../../tools/wstools/ssereceiver.py
164 SSHLibrary.Execute_Command sudo apt-get install -y python3-pip return_stdout=True return_stderr=True
165 SSHLibrary.Execute_Command
166 ... sudo python3 -m pip install --upgrade pip setuptools wheel
167 ... return_stdout=True
168 ... return_stderr=True
169 SSHLibrary.Execute_Command
170 ... sudo python3 -m pip install websocket-client asyncio aiohttp aiohttp-sse-client coroutine
171 ... return_stdout=True
172 ... return_stderr=True
173 RequestsLibrary.Create_Session restconf http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
174 KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set ${CONTROLLER_LOG_LEVEL}
177 [Documentation] Close connections.
178 ... Tear down imported Resources.
179 RequestsLibrary.Delete_All_Sessions
180 SSHLibrary.Close_All_Connections
183 [Documentation] Log response.
186 BuiltIn.Log ${resp.headers}
187 BuiltIn.Log ${resp.text}