xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_lock_management.robot (revision e33c6e6a79202e777c276a8253825f2944b2167f)
1bc331e22SVijay*** Settings ***
2bc331e22SVijay
3d03f2ce1SSushil SinghDocumentation        Test lock management feature of management console on BMC.
4bc331e22SVijay
5bc331e22SVijayResource             ../../lib/resource.robot
6bc331e22SVijayResource             ../../lib/openbmc_ffdc.robot
7566daaf3SGeorge KeishingResource             ../../lib/bmc_redfish_utils.robot
8d03f2ce1SSushil SinghResource             ../../lib/external_intf/management_console_utils.robot
9bc331e22SVijay
1040ef0eb7SSushil SinghSuite Setup          Run Keyword And Ignore Error  Delete All Redfish Sessions
11d03f2ce1SSushil SinghSuite Teardown       Redfish.Logout
12d03f2ce1SSushil SinghTest Setup           Printn
13d03f2ce1SSushil SinghTest Teardown        FFDC On Test Case Fail
14bc331e22SVijay
15bc331e22SVijay*** Variables ***
16bc331e22SVijay
17d03f2ce1SSushil Singh${BAD_REQUEST}       Bad Request
18bc331e22SVijay
19bc331e22SVijay*** Test Cases ***
20bc331e22SVijay
21d03f2ce1SSushil SinghAcquire Read Write Lock
22bc331e22SVijay    [Documentation]  Acquire and release different read locks.
23d03f2ce1SSushil Singh    [Tags]  Acquire_Read_Write_Lock
24d03f2ce1SSushil Singh    [Template]  Acquire Lock On Resource
25bc331e22SVijay
26d03f2ce1SSushil Singh    # client_id    lock_type     reboot_flag
27d03f2ce1SSushil Singh    HMCID-01       ReadCase1     False
28d03f2ce1SSushil Singh    HMCID-01       ReadCase2     False
29d03f2ce1SSushil Singh    HMCID-01       ReadCase3     False
30d03f2ce1SSushil Singh    HMCID-01       WriteCase1    False
31d03f2ce1SSushil Singh    HMCID-01       WriteCase2    False
32d03f2ce1SSushil Singh    HMCID-01       WriteCase3    False
33bc331e22SVijay
34bc331e22SVijay
35d03f2ce1SSushil SinghCheck Lock Persistency On BMC Reboot
36d03f2ce1SSushil Singh    [Documentation]  Acquire lock and check after reboot it remain same.
37d03f2ce1SSushil Singh    [Tags]  Check_Lock_Persistency_On_BMC_Reboot
38d03f2ce1SSushil Singh    [Template]  Acquire Lock On Resource
39bc331e22SVijay
40d03f2ce1SSushil Singh    # client_id    lock_type     reboot_flag
41d03f2ce1SSushil Singh    HMCID-01       ReadCase1     True
42d03f2ce1SSushil Singh    HMCID-01       ReadCase2     True
43d03f2ce1SSushil Singh    HMCID-01       ReadCase3     True
44d03f2ce1SSushil Singh    HMCID-01       WriteCase1    True
45d03f2ce1SSushil Singh    HMCID-01       WriteCase2    True
46d03f2ce1SSushil Singh    HMCID-01       WriteCase3    True
47bc331e22SVijay
48bc331e22SVijay
49d03f2ce1SSushil SinghAcquire Read Lock On Read Lock
50d03f2ce1SSushil Singh    [Documentation]  Acquire read lock on another read lock.
51d03f2ce1SSushil Singh    [Tags]  Acquire_Read_Lock_On_Read_Lock
52d03f2ce1SSushil Singh    [Template]  Acquire Lock On Another Lock
53bc331e22SVijay
54d03f2ce1SSushil Singh    # client_id
55d03f2ce1SSushil Singh    HMCID-01
56bc331e22SVijay
57bc331e22SVijay
58d03f2ce1SSushil SinghGet Lock Records Empty For Invalid Session
59d03f2ce1SSushil Singh    [Documentation]  Record of lock list is empty for invalid session.
60d03f2ce1SSushil Singh    [Tags]  Get_Lock_Records_Empty_For_Invalid_Session
61d03f2ce1SSushil Singh    [Template]  Verify Empty Lock Records For Invalid Session
62355daac7SVijay
63d03f2ce1SSushil Singh    # client_id
64d03f2ce1SSushil Singh    HMCID-01
65355daac7SVijay
66355daac7SVijay
67d03f2ce1SSushil SinghFail To Acquire Lock On Another Lock
68d03f2ce1SSushil Singh    [Documentation]  Fail to acquire another lock.
69d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_On_Another_Lock
70d03f2ce1SSushil Singh    [Template]  Verify Acquire Lock Fails On Another Lock
7185610eeeSVijay
72d03f2ce1SSushil Singh    # client_id    lock_type
73d03f2ce1SSushil Singh    HMCID-01       ReadCase2,WriteCase2
74d03f2ce1SSushil Singh    HMCID-01       WriteCase2,WriteCase2
75d03f2ce1SSushil Singh    HMCID-01       WriteCase2,ReadCase2
76566daaf3SGeorge Keishing
77566daaf3SGeorge Keishing
78*e33c6e6aSSushil SinghAcquire Lock After Reboot
79*e33c6e6aSSushil Singh    [Documentation]  Acquire and release read and write locks after reboot.
80*e33c6e6aSSushil Singh    [Tags]  Acquire_Lock_After_Reboot
81*e33c6e6aSSushil Singh    [Template]  Verify Acquire Lock After Reboot
82*e33c6e6aSSushil Singh
83*e33c6e6aSSushil Singh    # client_id    lock_type
84*e33c6e6aSSushil Singh    HMCID-01       ReadCase1
85*e33c6e6aSSushil Singh    HMCID-01       ReadCase2
86*e33c6e6aSSushil Singh    HMCID-01       ReadCase3
87*e33c6e6aSSushil Singh    HMCID-01       WriteCase1
88*e33c6e6aSSushil Singh    HMCID-01       WriteCase2
89*e33c6e6aSSushil Singh    HMCID-01       WriteCase3
90*e33c6e6aSSushil Singh
91*e33c6e6aSSushil Singh
92d03f2ce1SSushil SinghAcquire And Release Lock In Loop
93d03f2ce1SSushil Singh    [Documentation]  Acquire and release read, write locks in loop.
94d03f2ce1SSushil Singh    [Tags]  Acquire_And_Release_Lock_In_Loop
95d03f2ce1SSushil Singh    [Template]  Verify Acquire And Release Lock In Loop
96566daaf3SGeorge Keishing
97d03f2ce1SSushil Singh    # client_id    lock_type
98d03f2ce1SSushil Singh    HMCID-01       ReadCase1
99d03f2ce1SSushil Singh    HMCID-01       ReadCase2
100d03f2ce1SSushil Singh    HMCID-01       ReadCase3
101d03f2ce1SSushil Singh    HMCID-01       WriteCase1
102d03f2ce1SSushil Singh    HMCID-01       WriteCase2
103d03f2ce1SSushil Singh    HMCID-01       WriteCase3
10485610eeeSVijay
10585610eeeSVijay
106d03f2ce1SSushil SinghVerify Release Of Valid Locks
107d03f2ce1SSushil Singh    [Documentation]  Release all valid locks.
108d03f2ce1SSushil Singh    [Tags]  Verify_Release_Of_Valid_Locks
109d03f2ce1SSushil Singh    [Template]  Acquire And Release Multiple Locks
110afdd2a1dSVijay
111d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
112d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
113d03f2ce1SSushil Singh    HMCID-02       ReadCase1,ReadCase1,ReadCase1    Session
114afdd2a1dSVijay
115afdd2a1dSVijay
116d03f2ce1SSushil SinghInvalid Locks Fail To Release
117d03f2ce1SSushil Singh    [Documentation]  Release in-valid lock result in fail.
118d03f2ce1SSushil Singh    [Tags]  Invalid_Locks_Fail_To_Release
119d03f2ce1SSushil Singh    [Template]  Verify Invalid Locks Fail To Release
120afdd2a1dSVijay
121d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
122d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
123d03f2ce1SSushil Singh    12345          ReadCase2,ReadCase2,ReadCase2    Transaction
124d03f2ce1SSushil Singh    HMCID          ReadCase3,ReadCase3,ReadCase3    Transaction
125afdd2a1dSVijay
126afdd2a1dSVijay
127d03f2ce1SSushil SinghFail To Release Lock For Another Session
128d03f2ce1SSushil Singh    [Documentation]  Failed to release locks from another session.
129d03f2ce1SSushil Singh    [Tags]  Fail_To_Release_Lock_For_Another_Session
130d03f2ce1SSushil Singh    [Template]  Verify Fail To Release Lock For Another Session
131afdd2a1dSVijay
132d03f2ce1SSushil Singh    # client_id          lock_type
133d03f2ce1SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
134afdd2a1dSVijay
135afdd2a1dSVijay
136*e33c6e6aSSushil SinghTest Invalid Resource ID Data Type Locking
137*e33c6e6aSSushil Singh    [Documentation]  Failed to acquire lock for invalid resource id data type.
138*e33c6e6aSSushil Singh    [Tags]  Test_Invalid_Resource_ID_Data_Type_Locking
139*e33c6e6aSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Resource ID Data Type
140*e33c6e6aSSushil Singh
141*e33c6e6aSSushil Singh    # client_id    lock_type
142*e33c6e6aSSushil Singh    HMCID-01       ReadCase1
143*e33c6e6aSSushil Singh    HMCID-01       ReadCase2
144*e33c6e6aSSushil Singh    HMCID-01       ReadCase3
145*e33c6e6aSSushil Singh    HMCID-01       WriteCase1
146*e33c6e6aSSushil Singh    HMCID-01       WriteCase2
147*e33c6e6aSSushil Singh    HMCID-01       WriteCase3
148*e33c6e6aSSushil Singh
149*e33c6e6aSSushil Singh
150d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Type
151d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read, write lock for invalid lock data passed.
152d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Type
153d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
154afdd2a1dSVijay
155d03f2ce1SSushil Singh    # client_id    lock_type      message
156d03f2ce1SSushil Singh    HMCID-01       ReadCase1      ${BAD_REQUEST}
157d03f2ce1SSushil Singh    HMCID-01       ReadCase2      ${BAD_REQUEST}
158d03f2ce1SSushil Singh    HMCID-01       ReadCase3      ${BAD_REQUEST}
159d03f2ce1SSushil Singh    HMCID-01       ReadCase4      ${BAD_REQUEST}
160d03f2ce1SSushil Singh    HMCID-01       ReadCase5      ${BAD_REQUEST}
161d03f2ce1SSushil Singh    HMCID-01       WriteCase1     ${BAD_REQUEST}
162d03f2ce1SSushil Singh    HMCID-01       WriteCase2     ${BAD_REQUEST}
163d03f2ce1SSushil Singh    HMCID-01       WriteCase3     ${BAD_REQUEST}
164d03f2ce1SSushil Singh    HMCID-01       WriteCase4     ${BAD_REQUEST}
165d03f2ce1SSushil Singh    HMCID-01       WriteCase5     ${BAD_REQUEST}
166afdd2a1dSVijay
167afdd2a1dSVijay
168d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Flag
169d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid lock flag passed.
170d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
171d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
172afdd2a1dSVijay
173d03f2ce1SSushil Singh    # client_id    lock_type       message
174d03f2ce1SSushil Singh    HMCID-01       ReadCase6       ${BAD_REQUEST}
175d03f2ce1SSushil Singh    HMCID-01       ReadCase7       ${BAD_REQUEST}
176d03f2ce1SSushil Singh    HMCID-01       ReadCase8       ${BAD_REQUEST}
177d03f2ce1SSushil Singh    HMCID-01       ReadCase9       ${BAD_REQUEST}
178d03f2ce1SSushil Singh    HMCID-01       ReadCase10      ${BAD_REQUEST}
179d03f2ce1SSushil Singh    HMCID-01       ReadCase11      ${BAD_REQUEST}
180d03f2ce1SSushil Singh    HMCID-01       WriteCase6      ${BAD_REQUEST}
181d03f2ce1SSushil Singh    HMCID-01       WriteCase7      ${BAD_REQUEST}
182d03f2ce1SSushil Singh    HMCID-01       WriteCase8      ${BAD_REQUEST}
183d03f2ce1SSushil Singh    HMCID-01       WriteCase9      ${BAD_REQUEST}
184d03f2ce1SSushil Singh    HMCID-01       WriteCase10     ${BAD_REQUEST}
185d03f2ce1SSushil Singh    HMCID-01       WriteCase11     ${BAD_REQUEST}
186afdd2a1dSVijay
187afdd2a1dSVijay
188d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Segment Flag
189d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
190d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Flag
191d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
192d03f2ce1SSushil Singh
193d03f2ce1SSushil Singh    # client_id    lock_type       message
194d03f2ce1SSushil Singh    HMCID-01       ReadCase12      ${BAD_REQUEST}
195d03f2ce1SSushil Singh    HMCID-01       ReadCase13      ${BAD_REQUEST}
196d03f2ce1SSushil Singh    HMCID-01       ReadCase14      ${BAD_REQUEST}
197d03f2ce1SSushil Singh    HMCID-01       WriteCase12     ${BAD_REQUEST}
198d03f2ce1SSushil Singh    HMCID-01       WriteCase13     ${BAD_REQUEST}
199d03f2ce1SSushil Singh    HMCID-01       WriteCase14     ${BAD_REQUEST}
200afdd2a1dSVijay
201bc331e22SVijay*** Keywords ***
202bc331e22SVijay
203d03f2ce1SSushil SinghCreate Redfish Session With ClientID
204d03f2ce1SSushil Singh    [Documentation]  Create redifish session with client id.
205d03f2ce1SSushil Singh    [Arguments]  ${client_id}
20685610eeeSVijay
20785610eeeSVijay    # Description of argument(s):
208d03f2ce1SSushil Singh    # client_id    This client id can contain string value
209d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
21085610eeeSVijay
211d03f2ce1SSushil Singh    ${session_info}=  Create Dictionary
212d03f2ce1SSushil Singh    ${session}=  Redfish Login  kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
21385610eeeSVijay
214d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  SessionIDs  ${session['Id']}
215d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  ClientID  ${session["Oem"]["OpenBMC"]["ClientID"]}
21685610eeeSVijay
217d03f2ce1SSushil Singh    [Return]  ${session_info}
21885610eeeSVijay
21985610eeeSVijay
220d03f2ce1SSushil SinghRW General Dictionary
221d03f2ce1SSushil Singh    [Documentation]  Create dictionay of lock request.
222d03f2ce1SSushil Singh    [Arguments]  ${read_case}  ${res_id}
223bc331e22SVijay
224bc331e22SVijay    # Description of argument(s):
225d03f2ce1SSushil Singh    # read_case    Read or Write lock type.
226d03f2ce1SSushil Singh    # res_id       Resource id.
227bc331e22SVijay
228d03f2ce1SSushil Singh    ${request_dict}=  Create Dictionary
229566daaf3SGeorge Keishing
230d03f2ce1SSushil Singh    FOR  ${key}  IN  @{read_case.keys()}
231d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  LockType  ${key}
232d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  SegmentFlags  ${read_case["${key}"]}
233d03f2ce1SSushil Singh    END
234bc331e22SVijay
235d03f2ce1SSushil Singh    Set To Dictionary  ${request_dict}  ResourceID  ${res_id}
236d03f2ce1SSushil Singh
237d03f2ce1SSushil Singh    [Return]  ${request_dict}
238bc331e22SVijay
239bc331e22SVijay
240d03f2ce1SSushil SinghReturn Description Of Response
241d03f2ce1SSushil Singh    [Documentation]  Return description of REST response.
242bc331e22SVijay    [Arguments]  ${resp_text}
243bc331e22SVijay
244bc331e22SVijay    # Description of argument(s):
245d03f2ce1SSushil Singh    # resp_text    REST response body.
246bc331e22SVijay
247d03f2ce1SSushil Singh    # resp_text after successful partition file upload looks like:
248d03f2ce1SSushil Singh    # {
249d03f2ce1SSushil Singh    #    "Description": "File Created"
250d03f2ce1SSushil Singh    # }
251bc331e22SVijay
252d03f2ce1SSushil Singh    ${message}=  Evaluate  json.loads('''${resp_text}''')  json
253d03f2ce1SSushil Singh
254d03f2ce1SSushil Singh    [Return]  ${message}
255bc331e22SVijay
256bc331e22SVijay
257d03f2ce1SSushil SinghRedfish Post Acquire Lock
258d03f2ce1SSushil Singh    [Documentation]  Acquire and release lock.
259d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
260bc331e22SVijay
261bc331e22SVijay    # Description of argument(s):
262d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
263d03f2ce1SSushil Singh    # status_code    HTTP status code.
264bc331e22SVijay
265*e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Lock  ${lock_type}
266*e33c6e6aSSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
267d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
268d03f2ce1SSushil Singh    ${resp}=  Return Description Of Response  ${resp.content}
269bc331e22SVijay
270d03f2ce1SSushil Singh    [Return]  ${resp}
271bc331e22SVijay
272bc331e22SVijay
273d03f2ce1SSushil SinghRedfish Post Acquire Invalid Lock
274d03f2ce1SSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock.
275d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${message}  ${status_code}=${HTTP_OK}
276bc331e22SVijay
277bc331e22SVijay    # Description of argument(s):
278d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
279d03f2ce1SSushil Singh    # message        Return message from URI.
280d03f2ce1SSushil Singh    # status_code    HTTP status code.
281bc331e22SVijay
282*e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Invalid Lock  ${lock_type}
283*e33c6e6aSSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
284d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
285d03f2ce1SSushil Singh    Valid Value  message  ['${resp.content}']
286d03f2ce1SSushil Singh
287d03f2ce1SSushil Singh    [Return]  ${resp}
288bc331e22SVijay
289bc331e22SVijay
290*e33c6e6aSSushil SinghRedfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
291*e33c6e6aSSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock with invalid data type of resource id.
292*e33c6e6aSSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
293*e33c6e6aSSushil Singh
294*e33c6e6aSSushil Singh    # Description of argument(s):
295*e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
296*e33c6e6aSSushil Singh    # status_code    HTTP status code.
297*e33c6e6aSSushil Singh
298*e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID  ${lock_type}
299*e33c6e6aSSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
300*e33c6e6aSSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
301*e33c6e6aSSushil Singh
302*e33c6e6aSSushil Singh    [Return]  ${resp}
303*e33c6e6aSSushil Singh
304*e33c6e6aSSushil Singh
305d03f2ce1SSushil SinghForm Data To Acquire Lock
306d03f2ce1SSushil Singh    [Documentation]  Create a dictionay for lock request.
307d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
308d03f2ce1SSushil Singh
309d03f2ce1SSushil Singh    # Description of argument(s):
310d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
311d03f2ce1SSushil Singh
312d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
313d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
314d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
315d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
316d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
317*e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
318d03f2ce1SSushil Singh
319*e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
320*e33c6e6aSSushil Singh
321*e33c6e6aSSushil Singh
322*e33c6e6aSSushil SinghForm Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
323*e33c6e6aSSushil Singh    [Documentation]  Create a dictionay for in-valid lock request.
324*e33c6e6aSSushil Singh    [Arguments]  ${lock_type}
325*e33c6e6aSSushil Singh
326*e33c6e6aSSushil Singh    # Description of argument(s):
327*e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
328*e33c6e6aSSushil Singh
329*e33c6e6aSSushil Singh    ${lock_res_info}=  Get Lock Resource Information
330*e33c6e6aSSushil Singh    ${resp}=  RW General Dictionary
331*e33c6e6aSSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
332*e33c6e6aSSushil Singh    ...    ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
333*e33c6e6aSSushil Singh    ${temp_list}=  Create List  ${resp}
334*e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
335*e33c6e6aSSushil Singh
336*e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
337d03f2ce1SSushil Singh
338d03f2ce1SSushil Singh
339d03f2ce1SSushil SinghForm Data To Acquire Invalid Lock
340d03f2ce1SSushil Singh    [Documentation]  Create a dictionay for in-valid lock request.
341d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
342d03f2ce1SSushil Singh
343d03f2ce1SSushil Singh    # Description of argument(s):
344d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
345d03f2ce1SSushil Singh
346d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
347d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
348d03f2ce1SSushil Singh    ...    ${lock_res_info["Invalid Case"]["${lock_type}"]}
349d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
350d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
351*e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
352d03f2ce1SSushil Singh
353*e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
354d03f2ce1SSushil Singh
355d03f2ce1SSushil Singh
356d03f2ce1SSushil SinghGet Locks List On Resource
357bc331e22SVijay    [Documentation]  Get locks list.
358d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${exp_status_code}=${HTTP_OK}
359bc331e22SVijay
360bc331e22SVijay    # Description of argument(s):
361d03f2ce1SSushil Singh    # session_info       Session information in dict.
362d03f2ce1SSushil Singh    # exp_status_code    Expected HTTP status code.
363bc331e22SVijay
364d03f2ce1SSushil Singh    ${data}=  Set Variable  {"SessionIDs": ["${session_info['SessionIDs']}"]}
365566daaf3SGeorge Keishing    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
366566daaf3SGeorge Keishing    ...  data=${data}
367bc331e22SVijay    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
368bc331e22SVijay
369bc331e22SVijay    [Return]  ${locks["Records"]}
370bc331e22SVijay
371bc331e22SVijay
372d03f2ce1SSushil SinghVerify Lock On Resource
373d03f2ce1SSushil Singh    [Documentation]  Verify lock on resource.
374d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${transaction_id}
375bc331e22SVijay
376bc331e22SVijay    # Description of argument(s):
377d03f2ce1SSushil Singh    # session_info      Session information in dict.
378d03f2ce1SSushil Singh    # transaction_id    Transaction id in list stored in dict.
379bc331e22SVijay
380d03f2ce1SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
381d03f2ce1SSushil Singh    Rprint Vars  sessions
382d03f2ce1SSushil Singh    ${lock_list}=  Get Locks List On Resource  ${session_info}
383d03f2ce1SSushil Singh    ${lock_length}=  Get Length  ${lock_list}
384d03f2ce1SSushil Singh    ${tran_id_length}=  Get Length  ${transaction_id}
385d03f2ce1SSushil Singh    Should Be Equal As Integers  ${tran_id_length}  ${lock_length}
386afdd2a1dSVijay
387d03f2ce1SSushil Singh    FOR  ${tran_id}  ${lock}  IN ZIP  ${transaction_id}  ${lock_list}
388d03f2ce1SSushil Singh      Valid Value  session_info['ClientID']  ['${lock['HMCID']}']
389d03f2ce1SSushil Singh      Valid Value  session_info['SessionIDs']  ['${lock['SessionID']}']
390d03f2ce1SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock['TransactionID']}
391bc331e22SVijay    END
392bc331e22SVijay
393bc331e22SVijay
394d03f2ce1SSushil SinghRedfish Delete Session
395d03f2ce1SSushil Singh    [Documentation]  Redfish delete session.
396d03f2ce1SSushil Singh    [Arguments]  ${session_info}
397355daac7SVijay
398355daac7SVijay    # Description of argument(s):
399d03f2ce1SSushil Singh    # session_info      Session information in dict.
400355daac7SVijay
401d03f2ce1SSushil Singh    Redfish.Delete  /redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}
402355daac7SVijay
403355daac7SVijay
404d03f2ce1SSushil SinghAcquire Lock On Resource
405d03f2ce1SSushil Singh    [Documentation]  Acquire lock on resource.
406d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${reboot_flag}=False
407bc331e22SVijay
408bc331e22SVijay    # Description of argument(s):
409d03f2ce1SSushil Singh    # client_id    This client id can contain string value
410d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
411d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
412d03f2ce1SSushil Singh    # reboot_flag  Flag is used to run reboot the BMC code.
413d03f2ce1SSushil Singh    #               (e.g. True or False).
414bc331e22SVijay
415d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
416d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
417d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
418d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
419d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
420566daaf3SGeorge Keishing
421*e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
422bc331e22SVijay
423d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'True'
424d03f2ce1SSushil Singh    ...  Run Keywords  Redfish OBMC Reboot (off)  AND
425d03f2ce1SSushil Singh    ...  Redfish Login  AND
426*e33c6e6aSSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
427d03f2ce1SSushil Singh    ...  Verify Lock On Resource  ${session_info}  ${trans_id_list}  AND
428d03f2ce1SSushil Singh    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
429bc331e22SVijay
430d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'False'
431d03f2ce1SSushil Singh    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
432bc331e22SVijay
433d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
434d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
435d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
436bc331e22SVijay
437bc331e22SVijay
438d03f2ce1SSushil SinghForm Data To Release Lock
439d03f2ce1SSushil Singh    [Documentation]  Create a dictonay to release lock.
440d03f2ce1SSushil Singh    [Arguments]  ${trans_id_list}
441355daac7SVijay
442355daac7SVijay    # Description of argument(s):
443d03f2ce1SSushil Singh    # trans_id_list
444355daac7SVijay
445d03f2ce1SSushil Singh    @{tran_ids}=  Create List
446355daac7SVijay
447d03f2ce1SSushil Singh    FOR  ${item}  IN  @{trans_id_list}
448d03f2ce1SSushil Singh      Append To List  ${tran_ids}  ${item['TransactionID']}
449d03f2ce1SSushil Singh    END
450d03f2ce1SSushil Singh
451d03f2ce1SSushil Singh    [Return]  ${tran_ids}
452d03f2ce1SSushil Singh
453d03f2ce1SSushil Singh
454d03f2ce1SSushil SinghRelease Locks On Resource
455d03f2ce1SSushil Singh    [Documentation]  Redfish request to release a lock.
456d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}  ${release_lock_type}=Transaction  ${status_code}=${HTTP_OK}
457d03f2ce1SSushil Singh
458d03f2ce1SSushil Singh    # Description of argument(s):
459d03f2ce1SSushil Singh    # session_info        Session information in dict.
460d03f2ce1SSushil Singh    # trans_id_list       Transaction id list.
461d03f2ce1SSushil Singh    # release_lock_type   Release lock by Transaction, Session.
462d03f2ce1SSushil Singh    # status_code         HTTP status code.
463d03f2ce1SSushil Singh
464d03f2ce1SSushil Singh    ${tran_ids}=  Form Data To Release Lock  ${trans_id_list}
465d03f2ce1SSushil Singh    ${data}=  Set Variable  {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
466d03f2ce1SSushil Singh    ${data}=  Evaluate  json.dumps(${data})  json
467d03f2ce1SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock  data=${data}
468d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
469d03f2ce1SSushil Singh
470d03f2ce1SSushil Singh
471d03f2ce1SSushil SinghAcquire Lock On Another Lock
472d03f2ce1SSushil Singh    [Documentation]  Acquire lock on another lock.
473d03f2ce1SSushil Singh    [Arguments]  ${client_id}
474d03f2ce1SSushil Singh
475d03f2ce1SSushil Singh    # Description of argument(s):
476d03f2ce1SSushil Singh    # client_id    This client id can contain string value
477d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
478d03f2ce1SSushil Singh
479d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
480d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
481d03f2ce1SSushil Singh
482d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
483d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
484d03f2ce1SSushil Singh
485d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
486d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
487d03f2ce1SSushil Singh
488d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
489d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}
490d03f2ce1SSushil Singh
491d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
492d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
493d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
494d03f2ce1SSushil Singh
495d03f2ce1SSushil Singh
496d03f2ce1SSushil SinghVerify Empty Lock Records For Invalid Session
497d03f2ce1SSushil Singh    [Documentation]  Verify no lock record found for invalid session.
498d03f2ce1SSushil Singh    [Arguments]  ${client_id}
499d03f2ce1SSushil Singh
500d03f2ce1SSushil Singh    # Description of argument(s):
501d03f2ce1SSushil Singh    # client_id    This client id can contain string value
502d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
503d03f2ce1SSushil Singh
504d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_id}
505d03f2ce1SSushil Singh
506d03f2ce1SSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
507d03f2ce1SSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
508d03f2ce1SSushil Singh
509d03f2ce1SSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
510d03f2ce1SSushil Singh    set to dictionary  ${session_info2}  SessionIDs  xxyXyyYZZz
511d03f2ce1SSushil Singh
512d03f2ce1SSushil Singh    ${lock_list2}=  Get Locks List On Resource  ${session_info2}
513d03f2ce1SSushil Singh    ${lock_length2}=  Get Length  ${lock_list1}
514d03f2ce1SSushil Singh
515d03f2ce1SSushil Singh    Valid Value  lock_length1  ${lock_list2}
516d03f2ce1SSushil Singh
517d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
518d03f2ce1SSushil Singh
519d03f2ce1SSushil Singh
520d03f2ce1SSushil SinghVerify Acquire Lock Fails On Another Lock
521d03f2ce1SSushil Singh    [Documentation]  Verify acquire lock on another lock fails.
522d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
523d03f2ce1SSushil Singh
524d03f2ce1SSushil Singh    # Description of argument(s):
525d03f2ce1SSushil Singh    # client_id    This client id can contain string value
526d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
527d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
528d03f2ce1SSushil Singh
529d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
530d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
531d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
532d03f2ce1SSushil Singh
533d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
534d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
535d03f2ce1SSushil Singh
536d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
537d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
538d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}
539d03f2ce1SSushil Singh
540d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
541d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
542d03f2ce1SSushil Singh
543d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
544d03f2ce1SSushil Singh
545d03f2ce1SSushil Singh
546*e33c6e6aSSushil SinghVerify Acquire Lock After Reboot
547*e33c6e6aSSushil Singh    [Documentation]  Acquire read and write lock after the reboot and release lock.
548*e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
549*e33c6e6aSSushil Singh
550*e33c6e6aSSushil Singh    # Description of argument(s):
551*e33c6e6aSSushil Singh    # client_id    This client id can contain string value
552*e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
553*e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
554*e33c6e6aSSushil Singh
555*e33c6e6aSSushil Singh    ${trans_id_list}=  Create List
556*e33c6e6aSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
557*e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
558*e33c6e6aSSushil Singh    Redfish OBMC Reboot (off)
559*e33c6e6aSSushil Singh    Redfish Login
560*e33c6e6aSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}
561*e33c6e6aSSushil Singh
562*e33c6e6aSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
563*e33c6e6aSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
564*e33c6e6aSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
565*e33c6e6aSSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
566*e33c6e6aSSushil Singh
567*e33c6e6aSSushil Singh    ${trans_id_emptylist}=  Create List
568*e33c6e6aSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
569*e33c6e6aSSushil Singh    Redfish Delete Session  ${session_info}
570*e33c6e6aSSushil Singh
571*e33c6e6aSSushil Singh
572d03f2ce1SSushil SinghVerify Acquire And Release Lock In Loop
573d03f2ce1SSushil Singh    [Documentation]  Acquire lock in loop.
574d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
575d03f2ce1SSushil Singh
576d03f2ce1SSushil Singh    # Description of argument(s):
577d03f2ce1SSushil Singh    # client_id    This client id can contain string value
578d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
579d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
580d03f2ce1SSushil Singh
581d03f2ce1SSushil Singh    FOR  ${count}  IN RANGE  1  11
582d03f2ce1SSushil Singh      ${trans_id_list}=  Create List
583d03f2ce1SSushil Singh      ${session_info}=  Create Redfish Session With ClientID  ${client_id}
584d03f2ce1SSushil Singh      ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
585d03f2ce1SSushil Singh      Append To List  ${trans_id_list}  ${trans_id}
586d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_list}
587d03f2ce1SSushil Singh      Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
588d03f2ce1SSushil Singh      ${trans_id_emptylist}=  Create List
589d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
590d03f2ce1SSushil Singh    END
591d03f2ce1SSushil Singh
592d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
593d03f2ce1SSushil Singh
594d03f2ce1SSushil Singh
595d03f2ce1SSushil SinghAcquire And Release Multiple Locks
596d03f2ce1SSushil Singh    [Documentation]  Acquire mutilple locks on resource.
597d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
598d03f2ce1SSushil Singh
599d03f2ce1SSushil Singh    # Description of argument(s):
600d03f2ce1SSushil Singh    # client_id          This client id can contain string value
601d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
602d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
603d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
604d03f2ce1SSushil Singh
605d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
606d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
607d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
608d03f2ce1SSushil Singh
609d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
610d03f2ce1SSushil Singh
611d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
612d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
613d03f2ce1SSushil Singh
614d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
615d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
616d03f2ce1SSushil Singh
617d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
618d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
619d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
620d03f2ce1SSushil Singh
621d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
622d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
623d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
624d03f2ce1SSushil Singh
625d03f2ce1SSushil Singh
626d03f2ce1SSushil SinghVerify Invalid Locks Fail To Release
627d03f2ce1SSushil Singh    [Documentation]  Verify invalid locks fails to be released.
628d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
629d03f2ce1SSushil Singh
630d03f2ce1SSushil Singh    # Description of argument(s):
631d03f2ce1SSushil Singh    # client_id          This client id can contain string value
632d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
633d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
634d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
635d03f2ce1SSushil Singh
636d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
637d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
638d03f2ce1SSushil Singh
639d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
640d03f2ce1SSushil Singh
641d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
642d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
643d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
644d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
645d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
646d03f2ce1SSushil Singh
647d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
648d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
649d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
650d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
651d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
652d03f2ce1SSushil Singh
653d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
654d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
655d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
656d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
657d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
658d03f2ce1SSushil Singh
659d03f2ce1SSushil Singh    Release Locks On Resource
660d03f2ce1SSushil Singh    ...  ${session_info}  ${trans_id_list}
661d03f2ce1SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
662d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
663d03f2ce1SSushil Singh
664d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
665d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
666d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
667d03f2ce1SSushil Singh
668d03f2ce1SSushil Singh
669d03f2ce1SSushil SinghVerify Fail To Release Lock For Another Session
670d03f2ce1SSushil Singh    [Documentation]  Verify failed to release the lock form another session.
671d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
672d03f2ce1SSushil Singh
673d03f2ce1SSushil Singh    # Description of argument(s):
674d03f2ce1SSushil Singh    # client_id    This client id can contain string value
675d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
676d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
677d03f2ce1SSushil Singh
678d03f2ce1SSushil Singh    ${client_ids}=  Split String  ${client_id}  ,
679d03f2ce1SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
680d03f2ce1SSushil Singh    ${trans_id_list1}=  Create List
681d03f2ce1SSushil Singh    ${trans_id_list2}=  Create List
682d03f2ce1SSushil Singh
683d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_ids}[0]
684d03f2ce1SSushil Singh
685d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
686d03f2ce1SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
687d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
688d03f2ce1SSushil Singh
689d03f2ce1SSushil Singh    ${session_info2}=  Create Redfish Session With ClientID  ${client_ids}[1]
690d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
691d03f2ce1SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
692d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info2}  ${trans_id_list2}
693d03f2ce1SSushil Singh
694d03f2ce1SSushil Singh    Release Locks On Resource
695d03f2ce1SSushil Singh    ...  ${session_info1}  ${trans_id_list1}  Transaction  status_code=${HTTP_UNAUTHORIZED}
696d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
697d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Session
698d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Session
699d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
700d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info2}
701d03f2ce1SSushil Singh
702d03f2ce1SSushil Singh
703*e33c6e6aSSushil SinghVerify Fail To Acquire Lock For Invalid Resource ID Data Type
704*e33c6e6aSSushil Singh    [Documentation]  Verify fail to acquire the lock with invalid resource id data type.
705*e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
706*e33c6e6aSSushil Singh
707*e33c6e6aSSushil Singh    # Description of argument(s):
708*e33c6e6aSSushil Singh    # client_id    This client id can contain string value
709*e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
710*e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
711*e33c6e6aSSushil Singh
712*e33c6e6aSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
713*e33c6e6aSSushil Singh    Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
714*e33c6e6aSSushil Singh    ...  ${lock_type}  status_code=${HTTP_BAD_REQUEST}
715*e33c6e6aSSushil Singh    Redfish Delete Session  ${session_info}
716*e33c6e6aSSushil Singh
717*e33c6e6aSSushil Singh
718d03f2ce1SSushil SinghVerify Fail To Acquire Lock For Invalid Lock Data
719*e33c6e6aSSushil Singh    [Documentation]  Verify fail to acquired lock with invalid lock types, lock flags, segement flags.
720d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${message}
721d03f2ce1SSushil Singh
722d03f2ce1SSushil Singh    # Description of argument(s):
723d03f2ce1SSushil Singh    # client_id    This client id can contain string value
724d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
725d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
726d03f2ce1SSushil Singh    # message      Return message from URI.
727d03f2ce1SSushil Singh
728d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
729d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Invalid Lock  ${lock_type}  message=${message}  status_code=${HTTP_BAD_REQUEST}
730d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
731