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
27 Suite Setup Setup_Everything
28 Suite Teardown Teardown_Everything
29 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
30 Test Teardown SetupUtils.Teardown_Test_Show_Bugs_And_Start_Fast_Failing_If_Test_Failed
32 Library OperatingSystem
33 Library RequestsLibrary
34 Library SSHLibrary timeout=10s
36 Resource ${CURDIR}/../../../variables/Variables.robot
37 Resource ${CURDIR}/../../../libraries/FailFast.robot
38 Resource ${CURDIR}/../../../libraries/KarafKeywords.robot
39 Resource ${CURDIR}/../../../libraries/Restconf.robot
40 Resource ${CURDIR}/../../../libraries/SetupUtils.robot
41 Resource ${CURDIR}/../../../libraries/SSHKeywords.robot
42 Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot
43 Resource ${CURDIR}/../../../libraries/WaitForFailure.robot
46 ${TEMPLATE_FOLDER} ${CURDIR}/templates
47 ${RESTCONF_SUBSCRIBE_URI} restconf/operations/sal-remote:create-data-change-event-subscription
48 ${RESTCONF_SUBSCRIBE_DATA} subscribe.xml
49 ${NODES_STREAM_PATH} opendaylight-inventory:nodes/datastore=CONFIGURATION/scope=BASE
50 ${RESTCONF_GET_SUBSCRIPTION_URI} restconf/streams/stream/data-change-event-subscription/${NODES_STREAM_PATH}
51 ${RFC8040_NOTIFICATIONS_STREAMS_URI} rests/data/ietf-restconf-monitoring:restconf-state/streams
52 ${RFC8040_GET_SUBSCRIPTION_URI} ${RFC8040_NOTIFICATIONS_STREAMS_URI}/stream/data-change-event-subscription/${NODES_STREAM_PATH}
53 ${RESTCONF_CONFIG_DATA} config_data.xml
54 ${RECEIVER_LOG_FILE} wsreceiver.log
55 ${RECEIVER_OPTIONS} ${EMPTY}
56 ${CONTROLLER_LOG_LEVEL} INFO
60 [Documentation] Make sure config inventory is empty.
62 ${uri} = Restconf.Generate URI opendaylight-inventory:nodes config
63 TemplatedRequests.Delete_From_Uri uri=${uri} additional_allowed_status_codes=${DELETED_STATUS_CODES}
64 # TODO: Rework also other test cases to use TemplatedRequests.
67 [Documentation] Subscribe for notifications.
69 # check get streams url passes prior to creating a subscription
70 ${resp} = RequestsLibrary.Get_Request restconf ${RFC8040_NOTIFICATIONS_STREAMS_URI} headers=${SEND_ACCEPT_XML_HEADERS}
72 BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
73 ${body} = OperatingSystem.Get_File ${TEMPLATE_FOLDER}/${RESTCONF_SUBSCRIBE_DATA}
74 BuiltIn.Log ${RESTCONF_SUBSCRIBE_URI}
76 ${uri} = Restconf.Generate URI sal-remote:create-data-change-event-subscription rpc
77 ${resp} = RequestsLibrary.Post_Request restconf ${uri} headers=${SEND_ACCEPT_XML_HEADERS} data=${body}
79 BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
81 Check_Notification_Stream
82 [Documentation] Check any notification stream via RESTCONF is accessible
84 ${resp} = RequestsLibrary.Get_Request restconf ${RFC8040_NOTIFICATIONS_STREAMS_URI} headers=${SEND_ACCEPT_XML_HEADERS}
86 BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
87 ${root}= XML.Parse XML ${resp.content}
88 ${name}= Get Elements Texts ${root} stream/name
89 BuiltIn.Log ${name[0]}
90 ${resp} = RequestsLibrary.Get_Request restconf ${RFC8040_NOTIFICATIONS_STREAMS_URI}/stream=${name[0]}/access=JSON/location headers=${SEND_ACCEPT_XML_HEADERS}
92 BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
95 [Documentation] Get & check subscription ...
97 ${uri} = Set Variable If "${USE_RFC8040}" == "False" ${RESTCONF_GET_SUBSCRIPTION_URI} ${RFC8040_GET_SUBSCRIPTION_URI}
98 ${resp} = RequestsLibrary.Get_Request restconf ${uri} headers=${SEND_ACCEPT_XML_HEADERS}
100 BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
101 ${location} = XML.Get Element Text ${resp.content}
102 BuiltIn.Log ${location}
103 BuiltIn.Log ${resp.headers["Location"]}
104 Should Contain ${location} ${resp.headers["Location"]}
105 BuiltIn.Set_Suite_Variable ${location}
108 [Documentation] Start the websocket listener
109 ${output} = SSHLibrary.Write python wsreceiver.py --uri ${location} --count 2 --logfile ${RECEIVER_LOG_FILE} ${RECEIVER_OPTIONS}
110 BuiltIn.Log ${output}
111 ${output} = SSHLibrary.Read delay=2s
112 BuiltIn.Log ${output}
115 [Documentation] Make a change in configuration.
117 ${body} = OperatingSystem.Get_File ${TEMPLATE_FOLDER}/${RESTCONF_CONFIG_DATA}
118 ${uri} = Set Variable If "${USE_RFC8040}" == "False" ${CONFIG_API} rests/data
120 ${resp} = RequestsLibrary.Post_Request restconf ${uri} headers=${SEND_ACCEPT_XML_HEADERS} data=${body}
122 BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
123 ${uri} = Restconf.Generate URI opendaylight-inventory:nodes config
124 ${resp} = RequestsLibrary.Delete_Request restconf ${uri} headers=${SEND_ACCEPT_XML_HEADERS}
126 BuiltIn.Should_Contain ${ALLOWED_STATUS_CODES} ${resp.status_code}
128 Check_Create_Notification
129 [Documentation] Check the websocket listener log for a change notification.
131 ${notification} = SSHLibrary.Execute_Command cat ${RECEIVER_LOG_FILE}
132 BuiltIn.Log ${notification}
133 BuiltIn.Set_Suite_Variable ${notification}
134 BuiltIn.Should_Contain ${notification} <notification xmlns=
135 BuiltIn.Should_Contain ${notification} <eventTime>
136 BuiltIn.Should_Contain ${notification} <data-changed-notification xmlns=
137 BuiltIn.Should_Contain ${notification} <operation>created</operation>
138 BuiltIn.Should_Contain ${notification} </data-change-event>
139 BuiltIn.Should_Contain ${notification} </data-changed-notification>
140 BuiltIn.Should_Contain ${notification} </notification>
143 [Documentation] Check the websocket listener log for the bug correction.
145 ${data} = OperatingSystem.Get_File ${TEMPLATE_FOLDER}/${RESTCONF_CONFIG_DATA}
147 BuiltIn.Log ${notification}
148 ${packed_data} = String.Remove_String ${data} ${SPACE}
149 ${packed_notification} = String.Remove_String ${notification} ${SPACE}
150 BuiltIn.Should_Contain ${packed_notification} ${packed_data}
151 [Teardown] Report_Failure_Due_To_Bug 3934
153 Check_Delete_Notification
154 [Documentation] Check the websocket listener log for a delete notification.
156 BuiltIn.Should_Contain ${notification} <operation>deleted</operation>
160 [Documentation] SSH-login to mininet machine, create HTTP session,
161 ... prepare directories for responses, put Python tool to mininet machine, setup imported resources.
162 SetupUtils.Setup_Utils_For_Setup_And_Teardown
163 TemplatedRequests.Create_Default_Session
164 SSHLibrary.Set_Default_Configuration prompt=${TOOLS_SYSTEM_PROMPT}
165 SSHLibrary.Open_Connection ${TOOLS_SYSTEM_IP} alias=receiver
166 SSHKeywords.Flexible_Mininet_Login
167 SSHLibrary.Put_File ${CURDIR}/../../../../tools/wstools/wsreceiver.py
168 ${output_log} ${error_log} = SSHLibrary.Execute Command sudo apt-get install -y python-pip return_stdout=True return_stderr=True
169 BuiltIn.Log ${output_log}
170 BuiltIn.Log ${error_log}
171 ${output_log} = SSHLibrary.Execute_Command sudo pip install websocket-client
172 BuiltIn.Log ${output_log}
173 ${output_log} = SSHLibrary.Execute_Command python -c "help('modules')"
174 BuiltIn.Log ${output_log}
175 Should Contain ${output_log} websocket
176 RequestsLibrary.Create Session restconf http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
177 BuiltIn.Log http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
178 KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set ${CONTROLLER_LOG_LEVEL}
181 [Documentation] Close connections.
182 ... Tear down imported Resources.
183 RequestsLibrary.Delete_All_Sessions
184 SSHLibrary.Close_All_Connections
188 [Documentation] Log response.
190 BuiltIn.Log ${resp.headers}
191 BuiltIn.Log ${resp.content}