xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_lock_management.robot (revision bace3005d042e031e72a99f1d58a5c5d74aa0d59)
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
78e33c6e6aSSushil SinghAcquire Lock After Reboot
79e33c6e6aSSushil Singh    [Documentation]  Acquire and release read and write locks after reboot.
80e33c6e6aSSushil Singh    [Tags]  Acquire_Lock_After_Reboot
81e33c6e6aSSushil Singh    [Template]  Verify Acquire Lock After Reboot
82e33c6e6aSSushil Singh
83e33c6e6aSSushil Singh    # client_id    lock_type
84e33c6e6aSSushil Singh    HMCID-01       ReadCase1
85e33c6e6aSSushil Singh    HMCID-01       ReadCase2
86e33c6e6aSSushil Singh    HMCID-01       ReadCase3
87e33c6e6aSSushil Singh    HMCID-01       WriteCase1
88e33c6e6aSSushil Singh    HMCID-01       WriteCase2
89e33c6e6aSSushil Singh    HMCID-01       WriteCase3
90e33c6e6aSSushil Singh
91e33c6e6aSSushil 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
136e33c6e6aSSushil SinghTest Invalid Resource ID Data Type Locking
137e33c6e6aSSushil Singh    [Documentation]  Failed to acquire lock for invalid resource id data type.
138e33c6e6aSSushil Singh    [Tags]  Test_Invalid_Resource_ID_Data_Type_Locking
139e33c6e6aSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Resource ID Data Type
140e33c6e6aSSushil Singh
141e33c6e6aSSushil Singh    # client_id    lock_type
142e33c6e6aSSushil Singh    HMCID-01       ReadCase1
143e33c6e6aSSushil Singh    HMCID-01       ReadCase2
144e33c6e6aSSushil Singh    HMCID-01       ReadCase3
145e33c6e6aSSushil Singh    HMCID-01       WriteCase1
146e33c6e6aSSushil Singh    HMCID-01       WriteCase2
147e33c6e6aSSushil Singh    HMCID-01       WriteCase3
148e33c6e6aSSushil Singh
149e33c6e6aSSushil 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
201*bace3005SSushil Singh
202*bace3005SSushil SinghGet Empty Lock Records For Session Where No Locks Acquired
203*bace3005SSushil Singh    [Documentation]  If session does not acquire locks then get lock should return
204*bace3005SSushil Singh    ...              empty lock records.
205*bace3005SSushil Singh    [Tags]  Get_Empty_Lock_Records_For_Session_Where_No_Locks_Acquired
206*bace3005SSushil Singh    [Template]  Verify No Locks Records For Session With No Acquired Lock
207*bace3005SSushil Singh
208*bace3005SSushil Singh    # client_id
209*bace3005SSushil Singh    HMCID-01
210*bace3005SSushil Singh
211bc331e22SVijay*** Keywords ***
212bc331e22SVijay
213d03f2ce1SSushil SinghCreate Redfish Session With ClientID
214d03f2ce1SSushil Singh    [Documentation]  Create redifish session with client id.
215d03f2ce1SSushil Singh    [Arguments]  ${client_id}
21685610eeeSVijay
21785610eeeSVijay    # Description of argument(s):
218d03f2ce1SSushil Singh    # client_id    This client id can contain string value
219d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
22085610eeeSVijay
221d03f2ce1SSushil Singh    ${session_info}=  Create Dictionary
222d03f2ce1SSushil Singh    ${session}=  Redfish Login  kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
22385610eeeSVijay
224d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  SessionIDs  ${session['Id']}
225d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  ClientID  ${session["Oem"]["OpenBMC"]["ClientID"]}
22685610eeeSVijay
227d03f2ce1SSushil Singh    [Return]  ${session_info}
22885610eeeSVijay
22985610eeeSVijay
230d03f2ce1SSushil SinghRW General Dictionary
231d03f2ce1SSushil Singh    [Documentation]  Create dictionay of lock request.
232d03f2ce1SSushil Singh    [Arguments]  ${read_case}  ${res_id}
233bc331e22SVijay
234bc331e22SVijay    # Description of argument(s):
235d03f2ce1SSushil Singh    # read_case    Read or Write lock type.
236d03f2ce1SSushil Singh    # res_id       Resource id.
237bc331e22SVijay
238d03f2ce1SSushil Singh    ${request_dict}=  Create Dictionary
239566daaf3SGeorge Keishing
240d03f2ce1SSushil Singh    FOR  ${key}  IN  @{read_case.keys()}
241d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  LockType  ${key}
242d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  SegmentFlags  ${read_case["${key}"]}
243d03f2ce1SSushil Singh    END
244bc331e22SVijay
245d03f2ce1SSushil Singh    Set To Dictionary  ${request_dict}  ResourceID  ${res_id}
246d03f2ce1SSushil Singh
247d03f2ce1SSushil Singh    [Return]  ${request_dict}
248bc331e22SVijay
249bc331e22SVijay
250d03f2ce1SSushil SinghReturn Description Of Response
251d03f2ce1SSushil Singh    [Documentation]  Return description of REST response.
252bc331e22SVijay    [Arguments]  ${resp_text}
253bc331e22SVijay
254bc331e22SVijay    # Description of argument(s):
255d03f2ce1SSushil Singh    # resp_text    REST response body.
256bc331e22SVijay
257d03f2ce1SSushil Singh    # resp_text after successful partition file upload looks like:
258d03f2ce1SSushil Singh    # {
259d03f2ce1SSushil Singh    #    "Description": "File Created"
260d03f2ce1SSushil Singh    # }
261bc331e22SVijay
262d03f2ce1SSushil Singh    ${message}=  Evaluate  json.loads('''${resp_text}''')  json
263d03f2ce1SSushil Singh
264d03f2ce1SSushil Singh    [Return]  ${message}
265bc331e22SVijay
266bc331e22SVijay
267d03f2ce1SSushil SinghRedfish Post Acquire Lock
268d03f2ce1SSushil Singh    [Documentation]  Acquire and release lock.
269d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
270bc331e22SVijay
271bc331e22SVijay    # Description of argument(s):
272d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
273d03f2ce1SSushil Singh    # status_code    HTTP status code.
274bc331e22SVijay
275e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Lock  ${lock_type}
276e33c6e6aSSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
277d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
278d03f2ce1SSushil Singh    ${resp}=  Return Description Of Response  ${resp.content}
279bc331e22SVijay
280d03f2ce1SSushil Singh    [Return]  ${resp}
281bc331e22SVijay
282bc331e22SVijay
283d03f2ce1SSushil SinghRedfish Post Acquire Invalid Lock
284d03f2ce1SSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock.
285d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${message}  ${status_code}=${HTTP_OK}
286bc331e22SVijay
287bc331e22SVijay    # Description of argument(s):
288d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
289d03f2ce1SSushil Singh    # message        Return message from URI.
290d03f2ce1SSushil Singh    # status_code    HTTP status code.
291bc331e22SVijay
292e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Invalid Lock  ${lock_type}
293e33c6e6aSSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
294d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
295d03f2ce1SSushil Singh    Valid Value  message  ['${resp.content}']
296d03f2ce1SSushil Singh
297d03f2ce1SSushil Singh    [Return]  ${resp}
298bc331e22SVijay
299bc331e22SVijay
300e33c6e6aSSushil SinghRedfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
301e33c6e6aSSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock with invalid data type of resource id.
302e33c6e6aSSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
303e33c6e6aSSushil Singh
304e33c6e6aSSushil Singh    # Description of argument(s):
305e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
306e33c6e6aSSushil Singh    # status_code    HTTP status code.
307e33c6e6aSSushil Singh
308e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID  ${lock_type}
309e33c6e6aSSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
310e33c6e6aSSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
311e33c6e6aSSushil Singh
312e33c6e6aSSushil Singh    [Return]  ${resp}
313e33c6e6aSSushil Singh
314e33c6e6aSSushil Singh
315d03f2ce1SSushil SinghForm Data To Acquire Lock
316d03f2ce1SSushil Singh    [Documentation]  Create a dictionay for lock request.
317d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
318d03f2ce1SSushil Singh
319d03f2ce1SSushil Singh    # Description of argument(s):
320d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
321d03f2ce1SSushil Singh
322d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
323d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
324d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
325d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
326d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
327e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
328d03f2ce1SSushil Singh
329e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
330e33c6e6aSSushil Singh
331e33c6e6aSSushil Singh
332e33c6e6aSSushil SinghForm Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
333e33c6e6aSSushil Singh    [Documentation]  Create a dictionay for in-valid lock request.
334e33c6e6aSSushil Singh    [Arguments]  ${lock_type}
335e33c6e6aSSushil Singh
336e33c6e6aSSushil Singh    # Description of argument(s):
337e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
338e33c6e6aSSushil Singh
339e33c6e6aSSushil Singh    ${lock_res_info}=  Get Lock Resource Information
340e33c6e6aSSushil Singh    ${resp}=  RW General Dictionary
341e33c6e6aSSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
342e33c6e6aSSushil Singh    ...    ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
343e33c6e6aSSushil Singh    ${temp_list}=  Create List  ${resp}
344e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
345e33c6e6aSSushil Singh
346e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
347d03f2ce1SSushil Singh
348d03f2ce1SSushil Singh
349d03f2ce1SSushil SinghForm Data To Acquire Invalid Lock
350d03f2ce1SSushil Singh    [Documentation]  Create a dictionay for in-valid lock request.
351d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
352d03f2ce1SSushil Singh
353d03f2ce1SSushil Singh    # Description of argument(s):
354d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
355d03f2ce1SSushil Singh
356d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
357d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
358d03f2ce1SSushil Singh    ...    ${lock_res_info["Invalid Case"]["${lock_type}"]}
359d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
360d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
361e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
362d03f2ce1SSushil Singh
363e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
364d03f2ce1SSushil Singh
365d03f2ce1SSushil Singh
366d03f2ce1SSushil SinghGet Locks List On Resource
367bc331e22SVijay    [Documentation]  Get locks list.
368d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${exp_status_code}=${HTTP_OK}
369bc331e22SVijay
370bc331e22SVijay    # Description of argument(s):
371d03f2ce1SSushil Singh    # session_info       Session information in dict.
372d03f2ce1SSushil Singh    # exp_status_code    Expected HTTP status code.
373bc331e22SVijay
374d03f2ce1SSushil Singh    ${data}=  Set Variable  {"SessionIDs": ["${session_info['SessionIDs']}"]}
375566daaf3SGeorge Keishing    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
376566daaf3SGeorge Keishing    ...  data=${data}
377bc331e22SVijay    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
378bc331e22SVijay
379bc331e22SVijay    [Return]  ${locks["Records"]}
380bc331e22SVijay
381bc331e22SVijay
382d03f2ce1SSushil SinghVerify Lock On Resource
383d03f2ce1SSushil Singh    [Documentation]  Verify lock on resource.
384d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${transaction_id}
385bc331e22SVijay
386bc331e22SVijay    # Description of argument(s):
387d03f2ce1SSushil Singh    # session_info      Session information in dict.
388d03f2ce1SSushil Singh    # transaction_id    Transaction id in list stored in dict.
389bc331e22SVijay
390d03f2ce1SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
391d03f2ce1SSushil Singh    Rprint Vars  sessions
392d03f2ce1SSushil Singh    ${lock_list}=  Get Locks List On Resource  ${session_info}
393d03f2ce1SSushil Singh    ${lock_length}=  Get Length  ${lock_list}
394d03f2ce1SSushil Singh    ${tran_id_length}=  Get Length  ${transaction_id}
395d03f2ce1SSushil Singh    Should Be Equal As Integers  ${tran_id_length}  ${lock_length}
396afdd2a1dSVijay
397d03f2ce1SSushil Singh    FOR  ${tran_id}  ${lock}  IN ZIP  ${transaction_id}  ${lock_list}
398d03f2ce1SSushil Singh      Valid Value  session_info['ClientID']  ['${lock['HMCID']}']
399d03f2ce1SSushil Singh      Valid Value  session_info['SessionIDs']  ['${lock['SessionID']}']
400d03f2ce1SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock['TransactionID']}
401bc331e22SVijay    END
402bc331e22SVijay
403bc331e22SVijay
404d03f2ce1SSushil SinghRedfish Delete Session
405d03f2ce1SSushil Singh    [Documentation]  Redfish delete session.
406d03f2ce1SSushil Singh    [Arguments]  ${session_info}
407355daac7SVijay
408355daac7SVijay    # Description of argument(s):
409d03f2ce1SSushil Singh    # session_info      Session information in dict.
410355daac7SVijay
411d03f2ce1SSushil Singh    Redfish.Delete  /redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}
412355daac7SVijay
413355daac7SVijay
414d03f2ce1SSushil SinghAcquire Lock On Resource
415d03f2ce1SSushil Singh    [Documentation]  Acquire lock on resource.
416d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${reboot_flag}=False
417bc331e22SVijay
418bc331e22SVijay    # Description of argument(s):
419d03f2ce1SSushil Singh    # client_id    This client id can contain string value
420d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
421d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
422d03f2ce1SSushil Singh    # reboot_flag  Flag is used to run reboot the BMC code.
423d03f2ce1SSushil Singh    #               (e.g. True or False).
424bc331e22SVijay
425d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
426d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
427d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
428d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
429d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
430566daaf3SGeorge Keishing
431e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
432bc331e22SVijay
433d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'True'
434d03f2ce1SSushil Singh    ...  Run Keywords  Redfish OBMC Reboot (off)  AND
435d03f2ce1SSushil Singh    ...  Redfish Login  AND
436e33c6e6aSSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
437d03f2ce1SSushil Singh    ...  Verify Lock On Resource  ${session_info}  ${trans_id_list}  AND
438d03f2ce1SSushil Singh    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
439bc331e22SVijay
440d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'False'
441d03f2ce1SSushil Singh    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
442bc331e22SVijay
443d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
444d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
445d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
446bc331e22SVijay
447bc331e22SVijay
448d03f2ce1SSushil SinghForm Data To Release Lock
449d03f2ce1SSushil Singh    [Documentation]  Create a dictonay to release lock.
450d03f2ce1SSushil Singh    [Arguments]  ${trans_id_list}
451355daac7SVijay
452355daac7SVijay    # Description of argument(s):
453d03f2ce1SSushil Singh    # trans_id_list
454355daac7SVijay
455d03f2ce1SSushil Singh    @{tran_ids}=  Create List
456355daac7SVijay
457d03f2ce1SSushil Singh    FOR  ${item}  IN  @{trans_id_list}
458d03f2ce1SSushil Singh      Append To List  ${tran_ids}  ${item['TransactionID']}
459d03f2ce1SSushil Singh    END
460d03f2ce1SSushil Singh
461d03f2ce1SSushil Singh    [Return]  ${tran_ids}
462d03f2ce1SSushil Singh
463d03f2ce1SSushil Singh
464d03f2ce1SSushil SinghRelease Locks On Resource
465d03f2ce1SSushil Singh    [Documentation]  Redfish request to release a lock.
466d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}  ${release_lock_type}=Transaction  ${status_code}=${HTTP_OK}
467d03f2ce1SSushil Singh
468d03f2ce1SSushil Singh    # Description of argument(s):
469d03f2ce1SSushil Singh    # session_info        Session information in dict.
470d03f2ce1SSushil Singh    # trans_id_list       Transaction id list.
471d03f2ce1SSushil Singh    # release_lock_type   Release lock by Transaction, Session.
472d03f2ce1SSushil Singh    # status_code         HTTP status code.
473d03f2ce1SSushil Singh
474d03f2ce1SSushil Singh    ${tran_ids}=  Form Data To Release Lock  ${trans_id_list}
475d03f2ce1SSushil Singh    ${data}=  Set Variable  {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
476d03f2ce1SSushil Singh    ${data}=  Evaluate  json.dumps(${data})  json
477d03f2ce1SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock  data=${data}
478d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
479d03f2ce1SSushil Singh
480d03f2ce1SSushil Singh
481d03f2ce1SSushil SinghAcquire Lock On Another Lock
482d03f2ce1SSushil Singh    [Documentation]  Acquire lock on another lock.
483d03f2ce1SSushil Singh    [Arguments]  ${client_id}
484d03f2ce1SSushil Singh
485d03f2ce1SSushil Singh    # Description of argument(s):
486d03f2ce1SSushil Singh    # client_id    This client id can contain string value
487d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
488d03f2ce1SSushil Singh
489d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
490d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
491d03f2ce1SSushil Singh
492d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
493d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
494d03f2ce1SSushil Singh
495d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
496d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
497d03f2ce1SSushil Singh
498d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
499d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}
500d03f2ce1SSushil Singh
501d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
502d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
503d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
504d03f2ce1SSushil Singh
505d03f2ce1SSushil Singh
506d03f2ce1SSushil SinghVerify Empty Lock Records For Invalid Session
507d03f2ce1SSushil Singh    [Documentation]  Verify no lock record found for invalid session.
508d03f2ce1SSushil Singh    [Arguments]  ${client_id}
509d03f2ce1SSushil Singh
510d03f2ce1SSushil Singh    # Description of argument(s):
511d03f2ce1SSushil Singh    # client_id    This client id can contain string value
512d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
513d03f2ce1SSushil Singh
514d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_id}
515d03f2ce1SSushil Singh
516d03f2ce1SSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
517d03f2ce1SSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
518d03f2ce1SSushil Singh
519d03f2ce1SSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
520d03f2ce1SSushil Singh    set to dictionary  ${session_info2}  SessionIDs  xxyXyyYZZz
521d03f2ce1SSushil Singh
522d03f2ce1SSushil Singh    ${lock_list2}=  Get Locks List On Resource  ${session_info2}
523d03f2ce1SSushil Singh    ${lock_length2}=  Get Length  ${lock_list1}
524d03f2ce1SSushil Singh
525d03f2ce1SSushil Singh    Valid Value  lock_length1  ${lock_list2}
526d03f2ce1SSushil Singh
527d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
528d03f2ce1SSushil Singh
529d03f2ce1SSushil Singh
530d03f2ce1SSushil SinghVerify Acquire Lock Fails On Another Lock
531d03f2ce1SSushil Singh    [Documentation]  Verify acquire lock on another lock fails.
532d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
533d03f2ce1SSushil Singh
534d03f2ce1SSushil Singh    # Description of argument(s):
535d03f2ce1SSushil Singh    # client_id    This client id can contain string value
536d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
537d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
538d03f2ce1SSushil Singh
539d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
540d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
541d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
542d03f2ce1SSushil Singh
543d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
544d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
545d03f2ce1SSushil Singh
546d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
547d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
548d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}
549d03f2ce1SSushil Singh
550d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
551d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
552d03f2ce1SSushil Singh
553d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
554d03f2ce1SSushil Singh
555d03f2ce1SSushil Singh
556e33c6e6aSSushil SinghVerify Acquire Lock After Reboot
557e33c6e6aSSushil Singh    [Documentation]  Acquire read and write lock after the reboot and release lock.
558e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
559e33c6e6aSSushil Singh
560e33c6e6aSSushil Singh    # Description of argument(s):
561e33c6e6aSSushil Singh    # client_id    This client id can contain string value
562e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
563e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
564e33c6e6aSSushil Singh
565e33c6e6aSSushil Singh    ${trans_id_list}=  Create List
566e33c6e6aSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
567e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
568e33c6e6aSSushil Singh    Redfish OBMC Reboot (off)
569e33c6e6aSSushil Singh    Redfish Login
570e33c6e6aSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}
571e33c6e6aSSushil Singh
572e33c6e6aSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
573e33c6e6aSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
574e33c6e6aSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
575e33c6e6aSSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
576e33c6e6aSSushil Singh
577e33c6e6aSSushil Singh    ${trans_id_emptylist}=  Create List
578e33c6e6aSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
579e33c6e6aSSushil Singh    Redfish Delete Session  ${session_info}
580e33c6e6aSSushil Singh
581e33c6e6aSSushil Singh
582d03f2ce1SSushil SinghVerify Acquire And Release Lock In Loop
583d03f2ce1SSushil Singh    [Documentation]  Acquire lock in loop.
584d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
585d03f2ce1SSushil Singh
586d03f2ce1SSushil Singh    # Description of argument(s):
587d03f2ce1SSushil Singh    # client_id    This client id can contain string value
588d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
589d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
590d03f2ce1SSushil Singh
591d03f2ce1SSushil Singh    FOR  ${count}  IN RANGE  1  11
592d03f2ce1SSushil Singh      ${trans_id_list}=  Create List
593d03f2ce1SSushil Singh      ${session_info}=  Create Redfish Session With ClientID  ${client_id}
594d03f2ce1SSushil Singh      ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
595d03f2ce1SSushil Singh      Append To List  ${trans_id_list}  ${trans_id}
596d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_list}
597d03f2ce1SSushil Singh      Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
598d03f2ce1SSushil Singh      ${trans_id_emptylist}=  Create List
599d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
600d03f2ce1SSushil Singh    END
601d03f2ce1SSushil Singh
602d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
603d03f2ce1SSushil Singh
604d03f2ce1SSushil Singh
605d03f2ce1SSushil SinghAcquire And Release Multiple Locks
606d03f2ce1SSushil Singh    [Documentation]  Acquire mutilple locks on resource.
607d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
608d03f2ce1SSushil Singh
609d03f2ce1SSushil Singh    # Description of argument(s):
610d03f2ce1SSushil Singh    # client_id          This client id can contain string value
611d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
612d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
613d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
614d03f2ce1SSushil Singh
615d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
616d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
617d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
618d03f2ce1SSushil Singh
619d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
620d03f2ce1SSushil Singh
621d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
622d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
623d03f2ce1SSushil Singh
624d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
625d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
626d03f2ce1SSushil Singh
627d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
628d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
629d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
630d03f2ce1SSushil Singh
631d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
632d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
633d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
634d03f2ce1SSushil Singh
635d03f2ce1SSushil Singh
636d03f2ce1SSushil SinghVerify Invalid Locks Fail To Release
637d03f2ce1SSushil Singh    [Documentation]  Verify invalid locks fails to be released.
638d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
639d03f2ce1SSushil Singh
640d03f2ce1SSushil Singh    # Description of argument(s):
641d03f2ce1SSushil Singh    # client_id          This client id can contain string value
642d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
643d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
644d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
645d03f2ce1SSushil Singh
646d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
647d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
648d03f2ce1SSushil Singh
649d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
650d03f2ce1SSushil Singh
651d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
652d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
653d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
654d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
655d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
656d03f2ce1SSushil Singh
657d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
658d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
659d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
660d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
661d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
662d03f2ce1SSushil Singh
663d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
664d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
665d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
666d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
667d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
668d03f2ce1SSushil Singh
669d03f2ce1SSushil Singh    Release Locks On Resource
670d03f2ce1SSushil Singh    ...  ${session_info}  ${trans_id_list}
671d03f2ce1SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
672d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
673d03f2ce1SSushil Singh
674d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
675d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
676d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
677d03f2ce1SSushil Singh
678d03f2ce1SSushil Singh
679d03f2ce1SSushil SinghVerify Fail To Release Lock For Another Session
680d03f2ce1SSushil Singh    [Documentation]  Verify failed to release the lock form another session.
681d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
682d03f2ce1SSushil Singh
683d03f2ce1SSushil Singh    # Description of argument(s):
684d03f2ce1SSushil Singh    # client_id    This client id can contain string value
685d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
686d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
687d03f2ce1SSushil Singh
688d03f2ce1SSushil Singh    ${client_ids}=  Split String  ${client_id}  ,
689d03f2ce1SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
690d03f2ce1SSushil Singh    ${trans_id_list1}=  Create List
691d03f2ce1SSushil Singh    ${trans_id_list2}=  Create List
692d03f2ce1SSushil Singh
693d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_ids}[0]
694d03f2ce1SSushil Singh
695d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
696d03f2ce1SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
697d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
698d03f2ce1SSushil Singh
699d03f2ce1SSushil Singh    ${session_info2}=  Create Redfish Session With ClientID  ${client_ids}[1]
700d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
701d03f2ce1SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
702d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info2}  ${trans_id_list2}
703d03f2ce1SSushil Singh
704d03f2ce1SSushil Singh    Release Locks On Resource
705d03f2ce1SSushil Singh    ...  ${session_info1}  ${trans_id_list1}  Transaction  status_code=${HTTP_UNAUTHORIZED}
706d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
707d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Session
708d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Session
709d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
710d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info2}
711d03f2ce1SSushil Singh
712d03f2ce1SSushil Singh
713e33c6e6aSSushil SinghVerify Fail To Acquire Lock For Invalid Resource ID Data Type
714e33c6e6aSSushil Singh    [Documentation]  Verify fail to acquire the lock with invalid resource id data type.
715e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
716e33c6e6aSSushil Singh
717e33c6e6aSSushil Singh    # Description of argument(s):
718e33c6e6aSSushil Singh    # client_id    This client id can contain string value
719e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
720e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
721e33c6e6aSSushil Singh
722e33c6e6aSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
723e33c6e6aSSushil Singh    Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
724e33c6e6aSSushil Singh    ...  ${lock_type}  status_code=${HTTP_BAD_REQUEST}
725e33c6e6aSSushil Singh    Redfish Delete Session  ${session_info}
726e33c6e6aSSushil Singh
727e33c6e6aSSushil Singh
728d03f2ce1SSushil SinghVerify Fail To Acquire Lock For Invalid Lock Data
729e33c6e6aSSushil Singh    [Documentation]  Verify fail to acquired lock with invalid lock types, lock flags, segement flags.
730d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${message}
731d03f2ce1SSushil Singh
732d03f2ce1SSushil Singh    # Description of argument(s):
733d03f2ce1SSushil Singh    # client_id    This client id can contain string value
734d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
735d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
736d03f2ce1SSushil Singh    # message      Return message from URI.
737d03f2ce1SSushil Singh
738d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
739d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Invalid Lock  ${lock_type}  message=${message}  status_code=${HTTP_BAD_REQUEST}
740d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
741*bace3005SSushil Singh
742*bace3005SSushil Singh
743*bace3005SSushil SinghVerify No Locks Records For Session With No Acquired Lock
744*bace3005SSushil Singh    [Documentation]  Verify no records found for a session where no lock is acquired.
745*bace3005SSushil Singh    [Arguments]  ${client_id}
746*bace3005SSushil Singh
747*bace3005SSushil Singh    # Description of argument(s):
748*bace3005SSushil Singh    # client_id    This client id can contain string value
749*bace3005SSushil Singh    #              (e.g. 12345, "HMCID").
750*bace3005SSushil Singh
751*bace3005SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
752*bace3005SSushil Singh    ${trans_id_emptylist}=  Create List
753*bace3005SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
754*bace3005SSushil Singh    Redfish Delete Session  ${session_info}
755