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/opendaylight-inventory:nodes/datastore=CONFIGURATION/scope=BASE
41 ${RESTCONF_CONFIG_URI} restconf/config
42 ${RESTCONF_CONFIG_DATA} config_data.xml
43 ${RECEIVER_LOG_FILE} wsreceiver.log
44 ${RECEIVER_OPTIONS} ${EMPTY}
45 ${CONTROLLER_LOG_LEVEL} INFO
49 [Documentation] Delete item in configuration.
51 BuiltIn.Log ${CONFIG_NODES_API}
52 ${resp}= RequestsLibrary.Delete_Request restconf ${CONFIG_NODES_API} headers=${SEND_ACCEPT_XML_HEADERS}
54 BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 200
57 [Documentation] Subscribe for notifications.
59 ${body}= OperatingSystem.Get_File ${TEMPLATE_FOLDER}/${RESTCONF_SUBSCRIBE_DATA}
60 BuiltIn.Log ${RESTCONF_SUBSCRIBE_URI}
62 ${resp}= RequestsLibrary.Post_Request restconf ${RESTCONF_SUBSCRIBE_URI} headers=${SEND_ACCEPT_XML_HEADERS} data=${body}
64 BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 200
67 [Documentation] Get & check subscribtion ...
69 ${resp}= RequestsLibrary.Get_Request restconf ${RESTCONF_GET_SUBSCRIPTION_URI} headers=${SEND_ACCEPT_XML_HEADERS}
71 BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 200 Response status code error
72 ${location}= Collections.Get_From_Dictionary ${resp.headers} location
73 BuiltIn.Log ${location}
74 BuiltIn.Set_Suite_Variable ${location}
77 [Documentation] Start the websocket listener
78 ${output}= SSHLibrary.Write python wsreceiver.py --uri ${location} --count 2 --logfile ${RECEIVER_LOG_FILE} ${RECEIVER_OPTIONS}
80 ${output}= SSHLibrary.Read delay=2s
84 [Documentation] Make a change in configuration.
86 ${body}= OperatingSystem.Get_File ${TEMPLATE_FOLDER}/${RESTCONF_CONFIG_DATA}
87 BuiltIn.Log ${RESTCONF_CONFIG_URI}
89 ${resp}= RequestsLibrary.Post_Request restconf ${RESTCONF_CONFIG_URI} headers=${SEND_ACCEPT_XML_HEADERS} data=${body}
91 BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 204
92 BuiltIn.Log ${CONFIG_NODES_API}
93 ${resp}= RequestsLibrary.Delete_Request restconf ${CONFIG_NODES_API} headers=${SEND_ACCEPT_XML_HEADERS}
95 BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 200
97 Check_Create_Notification
98 [Documentation] Check the websocket listener log for a change notification.
100 ${notification}= SSHLibrary.Execute_Command cat ${RECEIVER_LOG_FILE}
101 BuiltIn.Log ${notification}
102 BuiltIn.Set_Suite_Variable ${notification}
103 BuiltIn.Should_Contain ${notification} <notification xmlns=
104 BuiltIn.Should_Contain ${notification} <eventTime>
105 BuiltIn.Should_Contain ${notification} <data-changed-notification xmlns=
106 BuiltIn.Should_Contain ${notification} <operation>created</operation>
107 BuiltIn.Should_Contain ${notification} </data-change-event>
108 BuiltIn.Should_Contain ${notification} </data-changed-notification>
109 BuiltIn.Should_Contain ${notification} </notification>
112 [Documentation] Check the websocket listener log for the bug correction.
114 ${data}= OperatingSystem.Get_File ${TEMPLATE_FOLDER}/${RESTCONF_CONFIG_DATA}
116 BuiltIn.Log ${notification}
117 ${packed_data}= String.Remove_String ${data} ${SPACE}
118 ${packed_notification}= String.Remove_String ${notification} ${SPACE}
119 BuiltIn.Should_Contain ${packed_notification} ${packed_data}
120 [Teardown] Report_Failure_Due_To_Bug 3934
122 Check_Delete_Notification
123 [Documentation] Check the websocket listener log for a delete notification.
125 BuiltIn.Should_Contain ${notification} <operation>deleted</operation>
129 [Documentation] SSH-login to mininet machine, create HTTP session,
130 ... prepare directories for responses, put Python tool to mininet machine, setup imported resources.
131 SetupUtils.Setup_Utils_For_Setup_And_Teardown
132 SSHLibrary.Set_Default_Configuration prompt=${TOOLS_SYSTEM_PROMPT}
133 SSHLibrary.Open_Connection ${TOOLS_SYSTEM_IP} alias=receiver
134 Utils.Flexible_Mininet_Login
135 SSHLibrary.Put_File ${CURDIR}/../../../../tools/wstools/wsreceiver.py
136 ${output_log} = SSHLibrary.Execute_Command sudo pip install websocket-client
137 BuiltIn.Log ${output_log}
138 ${output_log} = SSHLibrary.Execute_Command python -c "help('modules')"
139 BuiltIn.Log ${output_log}
140 Should Contain ${output_log} websocket
141 RequestsLibrary.Create Session restconf http://${CONTROLLER}:${RESTCONFPORT} auth=${AUTH}
142 BuiltIn.Log http://${CONTROLLER}:${RESTCONFPORT}
143 KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set ${CONTROLLER_LOG_LEVEL}
146 [Documentation] Close connections.
147 ... Tear down imported Resources.
148 ConfigViaRestconf.Teardown_Config_Via_Restconf
149 RequestsLibrary.Delete_All_Sessions
150 SSHLibrary.Close_All_Connections
154 [Documentation] Log response.
156 BuiltIn.Log ${resp.headers}
157 BuiltIn.Log ${resp.content}