Add DOMNotificationBroker Test Suite
[integration/test.git] / csit / libraries / MdsalLowlevel.robot
1 *** Settings ***
2 Documentation     Keywords wrapping controller's odl-mdsal-lowlevel yang model rpcs.
3 ...
4 ...               This is just an initial skeleton implementation, calls are debugged. Multiple
5 ...               changes will follow as suites will be implemented.
6 ...               This suite should be preferably merged before any suite to avoid conflicting
7 ...               situations while suites will be implementing.
8 ...
9 ...               Copyright (c) 2017 Cisco Systems, Inc. and others. All rights reserved.
10 ...
11 ...               This program and the accompanying materials are made available under the
12 ...               terms of the Eclipse Public License v1.0 which accompanies this distribution,
13 ...               and is available at http://www.eclipse.org/legal/epl-v10.html
14 Library           XML
15 Resource          ${CURDIR}/ClusterManagement.robot
16 Resource          ${CURDIR}/TemplatedRequests.robot
17
18 *** Variables ***
19 ${RPC_DIR}        ${CURDIR}/../variables/mdsal/lowlevelrpc
20 ${ADD_SHARD_REPLICA_DIR}    ${RPC_DIR}/add_shard_replica
21 ${BECOME_MODULE_LEADER_DIR}    ${RPC_DIR}/become_module_leader
22 ${BECOME_PREFIX_LEADER_DIR}    ${RPC_DIR}/become_prefix_leader
23 ${DECONFIGURE_ID_INTS_SHARD_DIR}    ${RPC_DIR}/deconfigure_id_ints_shard
24 ${GET_CONSTANT_DIR}    ${RPC_DIR}/get_constant
25 ${GET_CONTEXTED_CONSTANT_DIR}    ${RPC_DIR}/get_contexted_constant
26 ${GET_SINGLETON_CONSTANT_DIR}    ${RPC_DIR}/get_singleton_constant
27 ${IS_CLIENT_ABORTED_DIR}    ${RPC_DIR}/is_client_aborted
28 ${PRODUCE_TRANSACTIONS_DIR}    ${RPC_DIR}/produce_transactions
29 ${PUBLISH_NOTIFICATIONS_DIR}    ${RPC_DIR}/publish_notifications
30 ${REGISTER_BOUND_CONSTANT_DIR}    ${RPC_DIR}/register_bound_constant
31 ${REGISTER_CONSTANT_DIR}    ${RPC_DIR}/register_constant
32 ${REGISTER_DEFAULT_CONSTANT_DIR}    ${RPC_DIR}/register_default_constant
33 ${REGISTER_FLAPPING_SINGLETON_DIR}    ${RPC_DIR}/register_flapping_singleton
34 ${REGISTER_SINGLETON_CONSTANT_DIR}    ${RPC_DIR}/register_singleton_constant
35 ${REMOVE_SHARD_REPLICA_DIR}    ${RPC_DIR}/remove_shard_replica
36 ${SUBSCRIBE_DDTL_DIR}    ${RPC_DIR}/subscribe_ddtl
37 ${SUBSCRIBE_DTCL_DIR}    ${RPC_DIR}/subscribe_dtcl
38 ${SUBSCRIBE_YNL_DIR}    ${RPC_DIR}/subscribe_ynl
39 ${UNREGISTER_BOUND_CONSTANT_DIR}    ${RPC_DIR}/unregister_bound_constant
40 ${UNREGISTER_CONSTANT_DIR}    ${RPC_DIR}/unregister_constant
41 ${UNREGISTER_DEFAULT_CONSTANT_DIR}    ${RPC_DIR}/unregister_default_constant
42 ${UNREGISTER_FLAPPING_SINGLETON_DIR}    ${RPC_DIR}/unregister_flapping_singleton
43 ${UNREGISTER_SINGLETON_CONSTANT_DIR}    ${RPC_DIR}/unregister_singleton_constant
44 ${UNSUBSCRIBE_DDTL_DIR}    ${RPC_DIR}/unsubscribe_ddtl
45 ${UNSUBSCRIBE_DTCL_DIR}    ${RPC_DIR}/unsubscribe_dtcl
46 ${UNSUBSCRIBE_YNL_DIR}    ${RPC_DIR}/unsubscribe_ynl
47 ${WRITE_TRANSACTIONS_DIR}    ${RPC_DIR}/write_transactions
48
49 *** Keywords ***
50 Get_Constant
51     [Arguments]    ${member_index}    ${explicit_status_codes}=${NO_STATUS_CODES}
52     [Documentation]    Invoke get-constant rpc on the requested member and return the registered constant. The ${explicit_status_codes} is a list
53     ...    of http status codes for which the rpc call is considered as passed and is used for calls with expected failures on odl's side, such as
54     ...    calling the rpc on isolated node etc.
55     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
56     ${text} =    TemplatedRequests.Post_As_Xml_Templated    ${GET_CONSTANT_DIR}    session=${session}    explicit_status_codes=${explicit_status_codes}
57     ${xml} =    XML.Parse_Xml    ${text}
58     ${constant} =    XML.Get_Element_Text    ${xml}    xpath=constant
59     BuiltIn.Return_From_Keyword    ${constant}
60
61 Get_Contexted_Constant
62     [Arguments]    ${member_index}    ${context}
63     [Documentation]    Invoke get-contexted-constant rpc on the requested member and return the registered constant. The argument ${context} is only the string part
64     ...    of the whole instance identifier. The ${explicit_status_codes} is a list of http status codes for which the rpc call is considered as passed and is used for
65     ...    calls with expected failures on odl's side, such as calling the rpc on isolated node etc.
66     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
67     &{mapping}    BuiltIn.Create_Dictionary    CONTEXT=${context}
68     ${text} =    TemplatedRequests.Post_As_Xml_Templated    ${GET_CONTEXTED_CONSTANT_DIR}    mapping=${mapping}    session=${session}
69     ${xml} =    XML.Parse_Xml    ${text}
70     ${constant} =    XML.Get_Element_Text    ${xml}    xpath=constant
71     BuiltIn.Return_From_Keyword    ${constant}
72
73 Get_Singleton_Constant
74     [Arguments]    ${member_index}
75     [Documentation]    TODO: more desctiptive comment than: Invoke get-singleton-constant rpc.
76     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
77     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${GET_SINGLETON_CONSTANT_DIR}    base_name=location    extension=uri
78     ${text} =    TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
79     BuiltIn.Fail    TODO: to format output data
80     BuiltIn.Return_From_Keyword    ${formatted_output}
81
82 Register_Constant
83     [Arguments]    ${member_index}    ${constant}
84     [Documentation]    Register the get-constant rpc on the requested node with given constant.
85     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
86     &{mapping}    BuiltIn.Create_Dictionary    CONSTANT=${constant}
87     TemplatedRequests.Post_As_Xml_Templated    ${REGISTER_CONSTANT_DIR}    mapping=${mapping}    session=${session}
88
89 Unregister_Constant
90     [Arguments]    ${member_index}
91     [Documentation]    Unregister the get-constant rpc on the given node.
92     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
93     TemplatedRequests.Post_As_Xml_Templated    ${UNREGISTER_CONSTANT_DIR}    session=${session}
94
95 Register_Singleton_Constant
96     [Arguments]    ${member_index}    ${constant}
97     [Documentation]    TODO: more desctiptive comment than: Invoke register-singleton-constant rpc.
98     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
99     &{mapping}    BuiltIn.Create_Dictionary    CONSTANT=${constant}
100     TemplatedRequests.Post_As_Xml_Templated    ${REGISTER_SINGLETON_CONSTANT_DIR}    mapping=${mapping}    session=${session}
101
102 Unregister_Singleton_Constant
103     [Arguments]    ${member_index}
104     [Documentation]    TODO: more desctiptive comment than: Invoke unregister-singleton-constant rpc.
105     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
106     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${UNREGISTER_SINGLETON_CONSTANT_DIR}    base_name=location    extension=uri
107     ${text} =    TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
108
109 Register_Flapping_Singleton
110     [Arguments]    ${member_index}
111     [Documentation]    TODO: more desctiptive comment than: Invoke register-flapping-singleton rpc.
112     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
113     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${REGISTER_FLAPPING_SINGLETON_DIR}    base_name=location    extension=uri
114     TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
115
116 Unregister_Flapping_Singleton
117     [Arguments]    ${member_index}
118     [Documentation]    TODO: more desctiptive comment than: Invoke unregister-flapping-singleton rpc.
119     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
120     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${UNREGISTER_FLAPPING_SINGLETON_DIR}    base_name=location    extension=uri
121     ${text} =    TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
122
123 Write_Transactions
124     [Arguments]    ${member_index}    ${seconds}    ${trans_per_sec}    ${chained_trans}=${True}
125     [Documentation]    TODO: more desctiptive comment than: Invoke write-transactions rpc.
126     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
127     &{mapping}    BuiltIn.Create_Dictionary    SECONDS=${seconds}    TPS=${trans_per_sec}    CHAINED_TRANSACTIONS=${chained_trans}
128     TemplatedRequests.Post_As_Xml_Templated    ${WRITE_TRANSACTIONS_DIR}    mapping=${mapping}    session=${session}
129
130 Produce_Transactions
131     [Arguments]    ${member_index}    ${seconds}    ${trans_per_sec}    ${isolated_trans}=${True}
132     [Documentation]    TODO: more desctiptive comment than: Invoke produce-transactions rpc.
133     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
134     &{mapping}    BuiltIn.Create_Dictionary    SECONDS=${seconds}    TPS=${trans_per_sec}    ISOLATED_TRANSACTIONS=${chained_trans}
135     TemplatedRequests.Post_As_Xml_Templated    ${PRODUCE_TRANSACTIONS_DIR}    mapping=${mapping}    session=${session}
136
137 Become_Prefix_Leader
138     [Arguments]    ${member_index}    ${shard_name}
139     [Documentation]    TODO: more desctiptive comment than: Invoke become-prefix-leader rpc.
140     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
141     &{mapping}    BuiltIn.Create_Dictionary    SHARD_NAME=${shard_name}
142     ${text} =    TemplatedRequests.Post_As_Xml_Templated    ${BECOME_PREFIX_LEADER_DIR}    mapping=${mapping}    session=${session}
143
144 Become_Module_Leader
145     [Arguments]    ${member_index}    ${shard_name}
146     [Documentation]    TODO: more desctiptive comment than: Invoke become-module-leader rpc.
147     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
148     &{mapping}    BuiltIn.Create_Dictionary    SHARD_NAME=${shard_name}
149     ${text} =    TemplatedRequests.Post_As_Xml_Templated    ${BECOME_MODULE_LEADER_DIR}    mapping=${mapping}    session=${session}
150
151 Remove_Shard_Replica
152     [Arguments]    ${member_index}    ${shard_name}
153     [Documentation]    TODO: more desctiptive comment than: Invoke remove-shard-replica rpc.
154     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
155     &{mapping}    BuiltIn.Create_Dictionary    SHARD_NAME=${shard_name}
156     TemplatedRequests.Post_As_Xml_Templated    ${REMOVE_SHARD_REPLICA_DIR}    mapping=${mapping}    session=${session}
157
158 Add_Shard_Replica
159     [Arguments]    ${member_index}    ${shard_name}
160     [Documentation]    TODO: more desctiptive comment than: Invoke add-shard-replica rpc.
161     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
162     &{mapping}    BuiltIn.Create_Dictionary    SHARD_NAME=${shard_name}
163     TemplatedRequests.Post_As_Xml_Templated    ${ADD_SHARD_REPLICA_DIR}    mapping=${mapping}    session=${session}
164
165 Deconfigure_Id_Ints_Shard
166     [Arguments]    ${member_index}
167     [Documentation]    TODO: more desctiptive comment than: Invoke deconfigure-id-ints-shard rpc.
168     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
169     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${DECONFIGURE_ID_INTS_SHARD_DIR}    base_name=location    extension=uri
170     TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
171
172 Is_Client_Aborted
173     [Arguments]    ${member_index}
174     [Documentation]    TODO: more desctiptive comment than: Invoke is-client-aborted rpc.
175     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
176     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${IS_CLIENT_ABORTED_SHARD_DIR}    base_name=location    extension=uri
177     ${text} =    TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
178
179 Subscribe_Dtcl
180     [Arguments]    ${member_index}
181     [Documentation]    TODO: more desctiptive comment than: Invoke subscribe-dtcl rpc.
182     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
183     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${SUBSCRIBE_DTCL_DIR}    base_name=location    extension=uri
184     TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
185
186 Unsubscribe_Dtcl
187     [Arguments]    ${member_index}
188     [Documentation]    TODO: more desctiptive comment than: Invoke unsubscribe-dtcl rpc.
189     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
190     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${UNSUBSCRIBE_DTCL_DIR}    base_name=location    extension=uri
191     ${text} =    TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
192
193 Subscribe_Ddtl
194     [Arguments]    ${member_index}
195     [Documentation]    TODO: more desctiptive comment than: Invoke subscribe-ddtl rpc.
196     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
197     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${SUBSCRIBE_DDTL_DIR}    base_name=location    extension=uri
198     TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
199
200 Unsubscribe_Ddtl
201     [Arguments]    ${member_index}
202     [Documentation]    TODO: more desctiptive comment than: Invoke unsubscribe-ddtl rpc.
203     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
204     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${UNSUBSCRIBE_DDTL_DIR}    base_name=location    extension=uri
205     ${text} =    TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
206
207 Publish_Notifications
208     [Arguments]    ${member_index}    ${gid}    ${seconds}    ${notif_per_sec}
209     [Documentation]    Start publishing notifications by invoking publish-notifications rpc. This call is blocking
210     ...    and it returns when publishing is over. It suppose to take as long as ${seconds}.
211     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
212     &{mapping}    BuiltIn.Create_Dictionary    ID=${gid}    DURATION=${seconds}    RATE=${notif_per_sec}
213     TemplatedRequests.Post_As_Xml_Templated    ${PUBLISH_NOTIFICATIONS_DIR}    mapping=${mapping}    session=${session}
214
215 Subscribe_Ynl
216     [Arguments]    ${member_index}    ${gid}
217     [Documentation]    Subscribe listener for the notifications with identifier ${gid}.
218     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
219     &{mapping}    BuiltIn.Create_Dictionary    ID=${gid}
220     TemplatedRequests.Post_As_Xml_Templated    ${SUBSCRIBE_YNL_DIR}    mapping=${mapping}    session=${session}
221
222 Unsubscribe_Ynl
223     [Arguments]    ${member_index}    ${gid}
224     [Documentation]    Unsubscribe listener for the ${gid} identifier. Return statistics of the publishing process.
225     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
226     &{mapping}    BuiltIn.Create_Dictionary    ID=${gid}
227     ${text} =    TemplatedRequests.Post_As_Xml_Templated    ${UNSUBSCRIBE_YNL_DIR}    mapping=${mapping}    session=${session}
228     ${xml} =    XML.Parse_Xml    ${text}
229     ${all_not} =    XML.Get_Element_Text    ${xml}    xpath=all-not
230     ${id_not} =    XML.Get_Element_Text    ${xml}    xpath=id-not
231     ${err_not} =    XML.Get_Element_Text    ${xml}    xpath=err-not
232     ${local_number} =    XML.Get_Element_Text    ${xml}    xpath=local-number
233     BuiltIn.Return_From_Keyword    ${all_not}    ${id_not}    ${err_not}    ${local_number}
234
235 Register_Bound_Constant
236     [Arguments]    ${member_index}    ${context}    ${constant}
237     [Documentation]    Invoke register-bound-constant rpc and register get-contexted-constant rpc. The argument ${context} is only the string part
238     ...    of the whole instance identifier.
239     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
240     &{mapping}    BuiltIn.Create_Dictionary    CONTEXT=${context}    CONSTANT=${constant}
241     ${text} =    TemplatedRequests.Post_As_Xml_Templated    ${REGISTER_BOUND_CONSTANT_DIR}    mapping=${mapping}    session=${session}
242
243 Unregister_Bound_Constant
244     [Arguments]    ${member_index}    ${context}
245     [Documentation]    Invoke unregister-bound-constant rpc and unregister get-contexted-constant rpc. The argument ${context} is only the string part
246     ...    of the whole instance identifier.
247     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
248     &{mapping}    BuiltIn.Create_Dictionary    CONTEXT=${context}
249     TemplatedRequests.Post_As_Xml_Templated    ${UNREGISTER_BOUND_CONSTANT_DIR}    mapping=${mapping}    session=${session}
250
251 Register_Default_Constant
252     [Arguments]    ${member_index}    ${constant}
253     [Documentation]    TODO: more desctiptive comment than: Invoke register-default-constant rpc.
254     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
255     &{mapping}    BuiltIn.Create_Dictionary    CONSTANT=${constant}
256     TemplatedRequests.Post_As_Xml_Templated    ${REGISTER_DEFAULT_CONSTANT_DIR}    mapping=${mapping}    session=${session}
257
258 Unregister_Default_Constant
259     [Arguments]    ${member_index}
260     [Documentation]    TODO: more desctiptive comment than: Invoke unregister-default-constant rpc.
261     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
262     TemplatedRequests.Post_As_Xml_Templated    ${REGISTER_DEFAULT_CONSTANT_DIR}    session=${session}