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
31 Library OperatingSystem
32 Library SSHLibrary timeout=10s
33 Library RequestsLibrary
35 Variables ${CURDIR}/../../../variables/Variables.py
36 Resource ${CURDIR}/../../../libraries/FailFast.robot
37 Resource ${CURDIR}/../../../libraries/KarafKeywords.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
44 ${TEMPLATE_FOLDER} ${CURDIR}/templates
45 ${RESTCONF_SUBSCRIBE_URI} restconf/operations/sal-remote:create-data-change-event-subscription
46 ${RESTCONF_SUBSCRIBE_DATA} subscribe.xml
47 ${RESTCONF_GET_SUBSCRIPTION_URI} restconf/streams/stream/data-change-event-subscription/opendaylight-inventory:nodes/datastore=CONFIGURATION/scope=BASE
48 ${RESTCONF_CONFIG_URI} restconf/config
49 ${RESTCONF_CONFIG_DATA} config_data.xml
50 ${RECEIVER_LOG_FILE} wsreceiver.log
51 ${RECEIVER_OPTIONS} ${EMPTY}
52 ${CONTROLLER_LOG_LEVEL} INFO
56 [Documentation] Make sure config inventory is empty.
58 BuiltIn.Log ${CONFIG_NODES_API}
59 TemplatedRequests.Delete_From_Uri uri=${CONFIG_NODES_API} additional_allowed_status_codes=${DELETED_STATUS_CODE}
60 # TODO: Rework also other test cases to use TemplatedRequests.
63 [Documentation] Subscribe for notifications.
65 ${body} = OperatingSystem.Get_File ${TEMPLATE_FOLDER}/${RESTCONF_SUBSCRIBE_DATA}
66 BuiltIn.Log ${RESTCONF_SUBSCRIBE_URI}
68 ${resp} = RequestsLibrary.Post_Request restconf ${RESTCONF_SUBSCRIBE_URI} headers=${SEND_ACCEPT_XML_HEADERS} data=${body}
70 BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 200
73 [Documentation] Get & check subscribtion ...
75 ${resp} = RequestsLibrary.Get_Request restconf ${RESTCONF_GET_SUBSCRIPTION_URI} headers=${SEND_ACCEPT_XML_HEADERS}
77 BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 200 Response status code error
78 ${location} = Collections.Get_From_Dictionary ${resp.headers} location
79 BuiltIn.Log ${location}
80 BuiltIn.Set_Suite_Variable ${location}
83 [Documentation] Start the websocket listener
84 ${output} = SSHLibrary.Write python wsreceiver.py --uri ${location} --count 2 --logfile ${RECEIVER_LOG_FILE} ${RECEIVER_OPTIONS}
86 ${output} = SSHLibrary.Read delay=2s
90 [Documentation] Make a change in configuration.
92 ${body} = OperatingSystem.Get_File ${TEMPLATE_FOLDER}/${RESTCONF_CONFIG_DATA}
93 BuiltIn.Log ${RESTCONF_CONFIG_URI}
95 ${resp} = RequestsLibrary.Post_Request restconf ${RESTCONF_CONFIG_URI} headers=${SEND_ACCEPT_XML_HEADERS} data=${body}
97 BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 204
98 BuiltIn.Log ${CONFIG_NODES_API}
99 ${resp} = RequestsLibrary.Delete_Request restconf ${CONFIG_NODES_API} headers=${SEND_ACCEPT_XML_HEADERS}
101 BuiltIn.Should_Be_Equal_As_Strings ${resp.status_code} 200
103 Check_Create_Notification
104 [Documentation] Check the websocket listener log for a change notification.
106 ${notification} = SSHLibrary.Execute_Command cat ${RECEIVER_LOG_FILE}
107 BuiltIn.Log ${notification}
108 BuiltIn.Set_Suite_Variable ${notification}
109 BuiltIn.Should_Contain ${notification} <notification xmlns=
110 BuiltIn.Should_Contain ${notification} <eventTime>
111 BuiltIn.Should_Contain ${notification} <data-changed-notification xmlns=
112 BuiltIn.Should_Contain ${notification} <operation>created</operation>
113 BuiltIn.Should_Contain ${notification} </data-change-event>
114 BuiltIn.Should_Contain ${notification} </data-changed-notification>
115 BuiltIn.Should_Contain ${notification} </notification>
118 [Documentation] Check the websocket listener log for the bug correction.
120 ${data} = OperatingSystem.Get_File ${TEMPLATE_FOLDER}/${RESTCONF_CONFIG_DATA}
122 BuiltIn.Log ${notification}
123 ${packed_data} = String.Remove_String ${data} ${SPACE}
124 ${packed_notification} = String.Remove_String ${notification} ${SPACE}
125 BuiltIn.Should_Contain ${packed_notification} ${packed_data}
126 [Teardown] Report_Failure_Due_To_Bug 3934
128 Check_Delete_Notification
129 [Documentation] Check the websocket listener log for a delete notification.
131 BuiltIn.Should_Contain ${notification} <operation>deleted</operation>
135 [Documentation] SSH-login to mininet machine, create HTTP session,
136 ... prepare directories for responses, put Python tool to mininet machine, setup imported resources.
137 SetupUtils.Setup_Utils_For_Setup_And_Teardown
138 TemplatedRequests.Create_Default_Session
139 SSHLibrary.Set_Default_Configuration prompt=${TOOLS_SYSTEM_PROMPT}
140 SSHLibrary.Open_Connection ${TOOLS_SYSTEM_IP} alias=receiver
141 SSHKeywords.Flexible_Mininet_Login
142 SSHLibrary.Put_File ${CURDIR}/../../../../tools/wstools/wsreceiver.py
143 ${output_log} ${error_log} = SSHLibrary.Execute Command sudo apt-get install -y python-pip return_stdout=True return_stderr=True
144 BuiltIn.Log ${output_log}
145 BuiltIn.Log ${error_log}
146 ${output_log} = SSHLibrary.Execute_Command sudo pip install websocket-client
147 BuiltIn.Log ${output_log}
148 ${output_log} = SSHLibrary.Execute_Command python -c "help('modules')"
149 BuiltIn.Log ${output_log}
150 Should Contain ${output_log} websocket
151 RequestsLibrary.Create Session restconf http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH}
152 BuiltIn.Log http://${ODL_SYSTEM_IP}:${RESTCONFPORT}
153 KarafKeywords.Execute_Controller_Karaf_Command_On_Background log:set ${CONTROLLER_LOG_LEVEL}
156 [Documentation] Close connections.
157 ... Tear down imported Resources.
158 RequestsLibrary.Delete_All_Sessions
159 SSHLibrary.Close_All_Connections
163 [Documentation] Log response.
165 BuiltIn.Log ${resp.headers}
166 BuiltIn.Log ${resp.content}