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 ... Bug 3934 - Websockets: Scope ONE doesn't work correctly
17 ... TODO: Use cars/people model for data
18 Suite Setup Setup_Everything
19 Suite Teardown Teardown_Everything
20 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
21 Test Teardown FailFast.Start_Failing_Fast_If_This_Failed
22 Library OperatingSystem
23 Library SSHLibrary timeout=10s
24 Library RequestsLibrary
26 Library ${CURDIR}/../../../libraries/HsfJson/hsf_json.py
27 Variables ${CURDIR}/../../../variables/Variables.py
28 Resource ${CURDIR}/../../../libraries/ConfigViaRestconf.robot
29 Resource ${CURDIR}/../../../libraries/FailFast.robot
30 Resource ${CURDIR}/../../../libraries/KarafKeywords.robot
31 Resource ${CURDIR}/../../../libraries/SetupUtils.robot
32 Resource ${CURDIR}/../../../libraries/SSHKeywords.robot
33 Resource ${CURDIR}/../../../libraries/Utils.robot
34 Resource ${CURDIR}/../../../libraries/WaitForFailure.robot
37 ${TEMPLATE_FOLDER} ${CURDIR}/templates
38 ${RESTCONF_SUBSCRIBE_URI} restconf/operations/sal-remote:create-data-change-event-subscription
39 ${RESTCONF_SUBSCRIBE_DATA} subscribe.xml
40 ${RESTCONF_GET_SUBSCRIPTION_URI} restconf/streams/stream/data-change-event-subscription/opendaylight-inventory:nodes/datastore=CONFIGURATION/scope=BASE
41 ${RESTCONF_GET_SUBSCRIPTION_URI_LITHIUM} restconf/streams/stream/opendaylight-inventory:nodes/datastore=CONFIGURATION/scope=BASE
42 ${RESTCONF_CONFIG_URI} restconf/config
43 ${RESTCONF_CONFIG_DATA} config_data.xml
44 ${RECEIVER_LOG_FILE} wsreceiver.log
45 ${RECEIVER_OPTIONS} ${EMPTY}
46 ${CONTROLLER_LOG_LEVEL} INFO
50 [Documentation] Delete item in configuration.
52 BuiltIn.Log ${CONFIG_NODES_API}
53 ${resp} = RequestsLibrary.Delete_Request restconf ${CONFIG_NODES_API} headers=${SEND_ACCEPT_XML_HEADERS}
55 BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 200
58 [Documentation] Subscribe for notifications.
60 ${body} = OperatingSystem.Get_File ${TEMPLATE_FOLDER}/${RESTCONF_SUBSCRIBE_DATA}
61 BuiltIn.Log ${RESTCONF_SUBSCRIBE_URI}
63 ${resp} = RequestsLibrary.Post_Request restconf ${RESTCONF_SUBSCRIBE_URI} headers=${SEND_ACCEPT_XML_HEADERS} data=${body}
65 BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 200
68 [Documentation] Get & check subscribtion ...
70 ${resp} = RequestsLibrary.Get_Request restconf ${restconf_subscription_stream_uri} headers=${SEND_ACCEPT_XML_HEADERS}
72 BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 200 Response status code error
73 ${location} = Collections.Get_From_Dictionary ${resp.headers} location
74 BuiltIn.Log ${location}
75 BuiltIn.Set_Suite_Variable ${location}
78 [Documentation] Start the websocket listener
79 ${output} = SSHLibrary.Write python wsreceiver.py --uri ${location} --count 2 --logfile ${RECEIVER_LOG_FILE} ${RECEIVER_OPTIONS}
81 ${output} = SSHLibrary.Read delay=2s
85 [Documentation] Make a change in configuration.
87 ${body} = OperatingSystem.Get_File ${TEMPLATE_FOLDER}/${RESTCONF_CONFIG_DATA}
88 BuiltIn.Log ${RESTCONF_CONFIG_URI}
90 ${resp} = RequestsLibrary.Post_Request restconf ${RESTCONF_CONFIG_URI} headers=${SEND_ACCEPT_XML_HEADERS} data=${body}
92 BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 204
93 BuiltIn.Log ${CONFIG_NODES_API}
94 ${resp} = RequestsLibrary.Delete_Request restconf ${CONFIG_NODES_API} headers=${SEND_ACCEPT_XML_HEADERS}
96 BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 200
98 Check_Create_Notification
99 [Documentation] Check the websocket listener log for a change notification.
101 ${notification} = SSHLibrary.Execute_Command cat ${RECEIVER_LOG_FILE}
102 BuiltIn.Log ${notification}
103 BuiltIn.Set_Suite_Variable ${notification}
104 BuiltIn.Should_Contain ${notification} <notification xmlns=
105 BuiltIn.Should_Contain ${notification} <eventTime>
106 BuiltIn.Should_Contain ${notification} <data-changed-notification xmlns=
107 BuiltIn.Should_Contain ${notification} <operation>created</operation>
108 BuiltIn.Should_Contain ${notification} </data-change-event>
109 BuiltIn.Should_Contain ${notification} </data-changed-notification>
110 BuiltIn.Should_Contain ${notification} </notification>
113 [Documentation] Check the websocket listener log for the bug correction.
115 ${data} = OperatingSystem.Get_File ${TEMPLATE_FOLDER}/${RESTCONF_CONFIG_DATA}
117 BuiltIn.Log ${notification}
118 ${packed_data} = String.Remove_String ${data} ${SPACE}
119 ${packed_notification} = String.Remove_String ${notification} ${SPACE}
120 BuiltIn.Should_Contain ${packed_notification} ${packed_data}
121 [Teardown] Report_Failure_Due_To_Bug 3934
123 Check_Delete_Notification
124 [Documentation] Check the websocket listener log for a delete notification.
126 BuiltIn.Should_Contain ${notification} <operation>deleted</operation>
130 [Documentation] SSH-login to mininet machine, create HTTP session,
131 ... prepare directories for responses, put Python tool to mininet machine, setup imported resources.
132 SetupUtils.Setup_Utils_For_Setup_And_Teardown
133 SSHLibrary.Set_Default_Configuration prompt=${TOOLS_SYSTEM_PROMPT}
134 SSHLibrary.Open_Connection ${TOOLS_SYSTEM_IP} alias=receiver
135 Utils.Flexible_Mininet_Login
136 SSHLibrary.Put_File ${CURDIR}/../../../../tools/wstools/wsreceiver.py
137 ${output_log} ${error_log} = SSHLibrary.Execute Command sudo apt-get install -y python-pip return_stdout=True return_stderr=True
138 BuiltIn.Log ${output_log}
139 BuiltIn.Log ${error_log}
140 ${output_log} = SSHLibrary.Execute_Command sudo pip install websocket-client
141 BuiltIn.Log ${output_log}
142 ${output_log} = SSHLibrary.Execute_Command python -c "help('modules')"
143 BuiltIn.Log ${output_log}
144 Should Contain ${output_log} websocket
145 RequestsLibrary.Create Session restconf http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
146 BuiltIn.Log http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
147 ${restconf_subscription_stream_uri} = BuiltIn.Set_Variable_If """"ODL_STREAM""" == "stable-lithium" ${RESTCONF_GET_SUBSCRIPTION_URI_LITHIUM} ${RESTCONF_GET_SUBSCRIPTION_URI}
148 BuiltIn.Set_Suite_Variable \${restconf_subscription_stream_uri}
149 KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set ${CONTROLLER_LOG_LEVEL}
152 [Documentation] Close connections.
153 ... Tear down imported Resources.
154 ConfigViaRestconf.Teardown_Config_Via_Restconf
155 RequestsLibrary.Delete_All_Sessions
156 SSHLibrary.Close_All_Connections
160 [Documentation] Log response.
162 BuiltIn.Log ${resp.headers}
163 BuiltIn.Log ${resp.content}