Add Rpc Provider Test Suites
[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]    TODO: more desctiptive comment than: Invoke get-contexted-constant rpc.
64     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
65     &{mapping}    BuiltIn.Create_Dictionary    CONTEXT=${context}
66     ${test} =    TemplatedRequests.Post_As_Xml_Templated    ${GET_CONTEXTED_CONSTANT_DIR}    mapping=${mapping}    session=${session}
67     BuiltIn.Fail    TODO: to format output data or at least to check the format
68     BuiltIn.Return_From_Keyword    ${formatted_output}
69
70 Get_Singleton_Constant
71     [Arguments]    ${member_index}
72     [Documentation]    TODO: more desctiptive comment than: Invoke get-singleton-constant rpc.
73     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
74     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${GET_SINGLETON_CONSTANT_DIR}    base_name=location    extension=uri
75     ${text} =    TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
76     BuiltIn.Fail    TODO: to format output data
77     BuiltIn.Return_From_Keyword    ${formatted_output}
78
79 Register_Constant
80     [Arguments]    ${member_index}    ${constant}
81     [Documentation]    Register the get-constant rpc on the requested node with given constant.
82     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
83     &{mapping}    BuiltIn.Create_Dictionary    CONSTANT=${constant}
84     TemplatedRequests.Post_As_Xml_Templated    ${REGISTER_CONSTANT_DIR}    mapping=${mapping}    session=${session}
85
86 Unregister_Constant
87     [Arguments]    ${member_index}
88     [Documentation]    Unregister the get-constant rpc on the given node.
89     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
90     TemplatedRequests.Post_As_Xml_Templated    ${UNREGISTER_CONSTANT_DIR}    session=${session}
91
92 Register_Singleton_Constant
93     [Arguments]    ${member_index}    ${constant}
94     [Documentation]    TODO: more desctiptive comment than: Invoke register-singleton-constant rpc.
95     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
96     &{mapping}    BuiltIn.Create_Dictionary    CONSTANT=${constant}
97     TemplatedRequests.Post_As_Xml_Templated    ${REGISTER_SINGLETON_CONSTANT_DIR}    mapping=${mapping}    session=${session}
98
99 Unregister_Singleton_Constant
100     [Arguments]    ${member_index}
101     [Documentation]    TODO: more desctiptive comment than: Invoke unregister-singleton-constant rpc.
102     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
103     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${UNREGISTER_SINGLETON_CONSTANT_DIR}    base_name=location    extension=uri
104     ${text} =    TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
105
106 Register_Flapping_Singleton
107     [Arguments]    ${member_index}
108     [Documentation]    TODO: more desctiptive comment than: Invoke register-flapping-singleton rpc.
109     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
110     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${REGISTER_FLAPPING_SINGLETON_DIR}    base_name=location    extension=uri
111     TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
112
113 Unregister_Flapping_Singleton
114     [Arguments]    ${member_index}
115     [Documentation]    TODO: more desctiptive comment than: Invoke unregister-flapping-singleton rpc.
116     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
117     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${UNREGISTER_FLAPPING_SINGLETON_DIR}    base_name=location    extension=uri
118     ${text} =    TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
119
120 Write_Transactions
121     [Arguments]    ${member_index}    ${seconds}    ${trans_per_sec}    ${chained_trans}=${True}
122     [Documentation]    TODO: more desctiptive comment than: Invoke write-transactions rpc.
123     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
124     &{mapping}    BuiltIn.Create_Dictionary    SECONDS=${seconds}    TPS=${trans_per_sec}    CHAINED_TRANSACTIONS=${chained_trans}
125     TemplatedRequests.Post_As_Xml_Templated    ${WRITE_TRANSACTIONS_DIR}    mapping=${mapping}    session=${session}
126
127 Produce_Transactions
128     [Arguments]    ${member_index}    ${seconds}    ${trans_per_sec}    ${isolated_trans}=${True}
129     [Documentation]    TODO: more desctiptive comment than: Invoke produce-transactions rpc.
130     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
131     &{mapping}    BuiltIn.Create_Dictionary    SECONDS=${seconds}    TPS=${trans_per_sec}    ISOLATED_TRANSACTIONS=${chained_trans}
132     TemplatedRequests.Post_As_Xml_Templated    ${PRODUCE_TRANSACTIONS_DIR}    mapping=${mapping}    session=${session}
133
134 Become_Prefix_Leader
135     [Arguments]    ${member_index}    ${shard_name}
136     [Documentation]    TODO: more desctiptive comment than: Invoke become-prefix-leader rpc.
137     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
138     &{mapping}    BuiltIn.Create_Dictionary    SHARD_NAME=${shard_name}
139     ${text} =    TemplatedRequests.Post_As_Xml_Templated    ${BECOME_PREFIX_LEADER_DIR}    mapping=${mapping}    session=${session}
140
141 Become_Module_Leader
142     [Arguments]    ${member_index}    ${shard_name}
143     [Documentation]    TODO: more desctiptive comment than: Invoke become-module-leader rpc.
144     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
145     &{mapping}    BuiltIn.Create_Dictionary    SHARD_NAME=${shard_name}
146     ${text} =    TemplatedRequests.Post_As_Xml_Templated    ${BECOME_MODULE_LEADER_DIR}    mapping=${mapping}    session=${session}
147
148 Remove_Shard_Replica
149     [Arguments]    ${member_index}    ${shard_name}
150     [Documentation]    TODO: more desctiptive comment than: Invoke remove-shard-replica rpc.
151     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
152     &{mapping}    BuiltIn.Create_Dictionary    SHARD_NAME=${shard_name}
153     TemplatedRequests.Post_As_Xml_Templated    ${REMOVE_SHARD_REPLICA_DIR}    mapping=${mapping}    session=${session}
154
155 Add_Shard_Replica
156     [Arguments]    ${member_index}    ${shard_name}
157     [Documentation]    TODO: more desctiptive comment than: Invoke add-shard-replica rpc.
158     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
159     &{mapping}    BuiltIn.Create_Dictionary    SHARD_NAME=${shard_name}
160     TemplatedRequests.Post_As_Xml_Templated    ${ADD_SHARD_REPLICA_DIR}    mapping=${mapping}    session=${session}
161
162 Deconfigure_Id_Ints_Shard
163     [Arguments]    ${member_index}
164     [Documentation]    TODO: more desctiptive comment than: Invoke deconfigure-id-ints-shard rpc.
165     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
166     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${DECONFIGURE_ID_INTS_SHARD_DIR}    base_name=location    extension=uri
167     TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
168
169 Is_Client_Aborted
170     [Arguments]    ${member_index}
171     [Documentation]    TODO: more desctiptive comment than: Invoke is-client-aborted rpc.
172     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
173     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${IS_CLIENT_ABORTED_SHARD_DIR}    base_name=location    extension=uri
174     ${text} =    TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
175
176 Subscribe_Dtcl
177     [Arguments]    ${member_index}
178     [Documentation]    TODO: more desctiptive comment than: Invoke subscribe-dtcl rpc.
179     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
180     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${SUBSCRIBE_DTCL_DIR}    base_name=location    extension=uri
181     TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
182
183 Unsubscribe_Dtcl
184     [Arguments]    ${member_index}
185     [Documentation]    TODO: more desctiptive comment than: Invoke unsubscribe-dtcl rpc.
186     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
187     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${UNSUBSCRIBE_DTCL_DIR}    base_name=location    extension=uri
188     ${text} =    TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
189
190 Subscribe_Ddtl
191     [Arguments]    ${member_index}
192     [Documentation]    TODO: more desctiptive comment than: Invoke subscribe-ddtl rpc.
193     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
194     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${SUBSCRIBE_DDTL_DIR}    base_name=location    extension=uri
195     TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
196
197 Unsubscribe_Ddtl
198     [Arguments]    ${member_index}
199     [Documentation]    TODO: more desctiptive comment than: Invoke unsubscribe-ddtl rpc.
200     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
201     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${UNSUBSCRIBE_DDTL_DIR}    base_name=location    extension=uri
202     ${text} =    TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}
203
204 Publish_Notifications
205     [Arguments]    ${member_index}    ${seconds}    ${notif_per_sec}
206     [Documentation]    TODO: more desctiptive comment than: Invoke publish-notifications rpc.
207     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
208     &{mapping}    BuiltIn.Create_Dictionary    SECONDS=${seconds}    NPS=${notif_per_sec}
209     TemplatedRequests.Post_As_Xml_Templated    ${PUBLISH_NOTIFICATIONS_DIR}    mapping=${mapping}    session=${session}
210
211 Subscribe_Ynl
212     [Arguments]    ${member_index}
213     [Documentation]    TODO: more desctiptive comment than: Invoke subscribe-ynl rpc.
214     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
215     &{mapping}    BuiltIn.Create_Dictionary
216     TemplatedRequests.Post_As_Xml_Templated    ${SUBSCRIBE_YNL_DIR}    mapping=${mapping}    session=${session}
217
218 Unsubscribe_Ynl
219     [Arguments]    ${member_index}
220     [Documentation]    TODO: more desctiptive comment than: Invoke unsubscribe-ynl rpc.
221     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
222     &{mapping}    BuiltIn.Create_Dictionary
223     ${text} =    TemplatedRequests.Post_As_Xml_Templated    ${UNSUBSCRIBE_YNL_DIR}    mapping=${mapping}    session=${session}
224
225 Register_Bound_Constant
226     [Arguments]    ${member_index}
227     [Documentation]    TODO: more desctiptive comment than: Invoke register-bound-constant rpc.
228     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
229     &{mapping}    BuiltIn.Create_Dictionary
230     ${text} =    TemplatedRequests.Post_As_Xml_Templated    ${REGISTER_BOUND_CONSTANT_DIR}    mapping=${mapping}    session=${session}
231
232 Unregister_Bound_Constant
233     [Arguments]    ${member_index}
234     [Documentation]    TODO: more desctiptive comment than: Invoke unregister-bound-constant rpc.
235     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
236     &{mapping}    BuiltIn.Create_Dictionary
237     TemplatedRequests.Post_As_Xml_Templated    ${UNREGISTER_BOUND_CONSTANT_DIR}    mapping=${mapping}    session=${session}
238
239 Register_Default_Constant
240     [Arguments]    ${member_index}
241     [Documentation]    TODO: more desctiptive comment than: Invoke register-default-constant rpc.
242     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
243     &{mapping}    BuiltIn.Create_Dictionary
244     TemplatedRequests.Post_As_Xml_Templated    ${REGISTER_DEFAULT_CONSTANT_DIR}    mapping=${mapping}    session=${session}
245
246 Unregister_Default_Constant
247     [Arguments]    ${member_index}
248     [Documentation]    TODO: more desctiptive comment than: Invoke unregister-default-constant rpc.
249     ${session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${member_index}
250     ${uri} =    TemplatedRequests.Resolve_Text_From_Template_Folder    folder=${UNREGISTER_DEFAULT_CONSTANT_DIR}    base_name=location    extension=uri
251     TemplatedRequests.Post_To_Uri    uri=${uri}    data=${EMPTY}    accept=${ACCEPT_JSON}    content_type=${HEADERS_YANG_JSON}    session=${session}