xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_lock_management.robot (revision f9a536cab11c76df09a2cb0fff577baeeb2eff7c)
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
9977f8f58SSushil SinghResource             ../../lib/rest_response_code.robot
10728ef9c9SSushil SinghLibrary              ../../lib/bmc_network_utils.py
11bc331e22SVijay
1240ef0eb7SSushil SinghSuite Setup          Run Keyword And Ignore Error  Delete All Redfish Sessions
13d03f2ce1SSushil SinghSuite Teardown       Redfish.Logout
14d03f2ce1SSushil SinghTest Setup           Printn
15d03f2ce1SSushil SinghTest Teardown        FFDC On Test Case Fail
16bc331e22SVijay
17bc331e22SVijay*** Variables ***
18bc331e22SVijay
19d03f2ce1SSushil Singh${BAD_REQUEST}       Bad Request
20bc331e22SVijay
21bc331e22SVijay*** Test Cases ***
22bc331e22SVijay
23d03f2ce1SSushil SinghAcquire Read Write Lock
24bc331e22SVijay    [Documentation]  Acquire and release different read locks.
25d03f2ce1SSushil Singh    [Tags]  Acquire_Read_Write_Lock
26d03f2ce1SSushil Singh    [Template]  Acquire Lock On Resource
27bc331e22SVijay
28d03f2ce1SSushil Singh    # client_id    lock_type     reboot_flag
29d03f2ce1SSushil Singh    HMCID-01       ReadCase1     False
30d03f2ce1SSushil Singh    HMCID-01       ReadCase2     False
31d03f2ce1SSushil Singh    HMCID-01       ReadCase3     False
32d03f2ce1SSushil Singh    HMCID-01       WriteCase1    False
33d03f2ce1SSushil Singh    HMCID-01       WriteCase2    False
34d03f2ce1SSushil Singh    HMCID-01       WriteCase3    False
35bc331e22SVijay
36bc331e22SVijay
37d03f2ce1SSushil SinghCheck Lock Persistency On BMC Reboot
38d03f2ce1SSushil Singh    [Documentation]  Acquire lock and check after reboot it remain same.
39d03f2ce1SSushil Singh    [Tags]  Check_Lock_Persistency_On_BMC_Reboot
40d03f2ce1SSushil Singh    [Template]  Acquire Lock On Resource
41bc331e22SVijay
42d03f2ce1SSushil Singh    # client_id    lock_type     reboot_flag
43d03f2ce1SSushil Singh    HMCID-01       ReadCase1     True
44d03f2ce1SSushil Singh    HMCID-01       ReadCase2     True
45d03f2ce1SSushil Singh    HMCID-01       ReadCase3     True
46d03f2ce1SSushil Singh    HMCID-01       WriteCase1    True
47d03f2ce1SSushil Singh    HMCID-01       WriteCase2    True
48d03f2ce1SSushil Singh    HMCID-01       WriteCase3    True
49bc331e22SVijay
50bc331e22SVijay
51d03f2ce1SSushil SinghAcquire Read Lock On Read Lock
52d03f2ce1SSushil Singh    [Documentation]  Acquire read lock on another read lock.
53d03f2ce1SSushil Singh    [Tags]  Acquire_Read_Lock_On_Read_Lock
54d03f2ce1SSushil Singh    [Template]  Acquire Lock On Another Lock
55bc331e22SVijay
56d03f2ce1SSushil Singh    # client_id
57d03f2ce1SSushil Singh    HMCID-01
58bc331e22SVijay
59bc331e22SVijay
60d03f2ce1SSushil SinghFail To Acquire Lock On Another Lock
61d03f2ce1SSushil Singh    [Documentation]  Fail to acquire another lock.
62d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_On_Another_Lock
63d03f2ce1SSushil Singh    [Template]  Verify Acquire Lock Fails On Another Lock
6485610eeeSVijay
65d03f2ce1SSushil Singh    # client_id    lock_type
66d03f2ce1SSushil Singh    HMCID-01       ReadCase2,WriteCase2
67d03f2ce1SSushil Singh    HMCID-01       WriteCase2,WriteCase2
68d03f2ce1SSushil Singh    HMCID-01       WriteCase2,ReadCase2
69566daaf3SGeorge Keishing
70566daaf3SGeorge Keishing
71e33c6e6aSSushil SinghAcquire Lock After Reboot
72e33c6e6aSSushil Singh    [Documentation]  Acquire and release read and write locks after reboot.
73e33c6e6aSSushil Singh    [Tags]  Acquire_Lock_After_Reboot
74e33c6e6aSSushil Singh    [Template]  Verify Acquire Lock After Reboot
75e33c6e6aSSushil Singh
76e33c6e6aSSushil Singh    # client_id    lock_type
77e33c6e6aSSushil Singh    HMCID-01       ReadCase1
78e33c6e6aSSushil Singh    HMCID-01       ReadCase2
79e33c6e6aSSushil Singh    HMCID-01       ReadCase3
80e33c6e6aSSushil Singh    HMCID-01       WriteCase1
81e33c6e6aSSushil Singh    HMCID-01       WriteCase2
82e33c6e6aSSushil Singh    HMCID-01       WriteCase3
83e33c6e6aSSushil Singh
84e33c6e6aSSushil Singh
85d03f2ce1SSushil SinghAcquire And Release Lock In Loop
86d03f2ce1SSushil Singh    [Documentation]  Acquire and release read, write locks in loop.
87d03f2ce1SSushil Singh    [Tags]  Acquire_And_Release_Lock_In_Loop
88d03f2ce1SSushil Singh    [Template]  Verify Acquire And Release Lock In Loop
89566daaf3SGeorge Keishing
90d03f2ce1SSushil Singh    # client_id    lock_type
91d03f2ce1SSushil Singh    HMCID-01       ReadCase1
92d03f2ce1SSushil Singh    HMCID-01       ReadCase2
93d03f2ce1SSushil Singh    HMCID-01       ReadCase3
94d03f2ce1SSushil Singh    HMCID-01       WriteCase1
95d03f2ce1SSushil Singh    HMCID-01       WriteCase2
96d03f2ce1SSushil Singh    HMCID-01       WriteCase3
9785610eeeSVijay
9885610eeeSVijay
99977f8f58SSushil SinghFail To Acquire Read And Write In Single Request
100977f8f58SSushil Singh    [Documentation]  Fail to acquire read and write lock in single request.
101977f8f58SSushil Singh    [Tags]  Fail_To_Acquire_Read_And_Write_In_Single_Request
102977f8f58SSushil Singh    [Template]  Verify Fail To Acquire Read And Write In Single Request
103977f8f58SSushil Singh
104977f8f58SSushil Singh    # client_id    lock_type
105977f8f58SSushil Singh    HMCID-01       ReadCase1,WriteCase1
106977f8f58SSushil Singh    HMCID-01       WriteCase1,ReadCase1
107977f8f58SSushil Singh
108977f8f58SSushil Singh
109d03f2ce1SSushil SinghVerify Release Of Valid Locks
110d03f2ce1SSushil Singh    [Documentation]  Release all valid locks.
111d03f2ce1SSushil Singh    [Tags]  Verify_Release_Of_Valid_Locks
112d03f2ce1SSushil Singh    [Template]  Acquire And Release Multiple Locks
113afdd2a1dSVijay
114d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
115d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
116d03f2ce1SSushil Singh    HMCID-02       ReadCase1,ReadCase1,ReadCase1    Session
117afdd2a1dSVijay
118afdd2a1dSVijay
119d03f2ce1SSushil SinghInvalid Locks Fail To Release
120d03f2ce1SSushil Singh    [Documentation]  Release in-valid lock result in fail.
121d03f2ce1SSushil Singh    [Tags]  Invalid_Locks_Fail_To_Release
122d03f2ce1SSushil Singh    [Template]  Verify Invalid Locks Fail To Release
123afdd2a1dSVijay
124d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
125d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
126d03f2ce1SSushil Singh    12345          ReadCase2,ReadCase2,ReadCase2    Transaction
127d03f2ce1SSushil Singh    HMCID          ReadCase3,ReadCase3,ReadCase3    Transaction
128afdd2a1dSVijay
129afdd2a1dSVijay
130d03f2ce1SSushil SinghFail To Release Lock For Another Session
131d03f2ce1SSushil Singh    [Documentation]  Failed to release locks from another session.
132d03f2ce1SSushil Singh    [Tags]  Fail_To_Release_Lock_For_Another_Session
133d03f2ce1SSushil Singh    [Template]  Verify Fail To Release Lock For Another Session
134afdd2a1dSVijay
135d03f2ce1SSushil Singh    # client_id          lock_type
136d03f2ce1SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
137afdd2a1dSVijay
138afdd2a1dSVijay
139e33c6e6aSSushil SinghTest Invalid Resource ID Data Type Locking
140e33c6e6aSSushil Singh    [Documentation]  Failed to acquire lock for invalid resource id data type.
141e33c6e6aSSushil Singh    [Tags]  Test_Invalid_Resource_ID_Data_Type_Locking
142e33c6e6aSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Resource ID Data Type
143e33c6e6aSSushil Singh
144e33c6e6aSSushil Singh    # client_id    lock_type
145e33c6e6aSSushil Singh    HMCID-01       ReadCase1
146e33c6e6aSSushil Singh    HMCID-01       ReadCase2
147e33c6e6aSSushil Singh    HMCID-01       ReadCase3
148e33c6e6aSSushil Singh    HMCID-01       WriteCase1
149e33c6e6aSSushil Singh    HMCID-01       WriteCase2
150e33c6e6aSSushil Singh    HMCID-01       WriteCase3
151e33c6e6aSSushil Singh
152e33c6e6aSSushil Singh
153d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Type
154d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read, write lock for invalid lock data passed.
155d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Type
156d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
157afdd2a1dSVijay
158d03f2ce1SSushil Singh    # client_id    lock_type      message
159d03f2ce1SSushil Singh    HMCID-01       ReadCase1      ${BAD_REQUEST}
160d03f2ce1SSushil Singh    HMCID-01       ReadCase2      ${BAD_REQUEST}
161d03f2ce1SSushil Singh    HMCID-01       ReadCase3      ${BAD_REQUEST}
162d03f2ce1SSushil Singh    HMCID-01       ReadCase4      ${BAD_REQUEST}
163d03f2ce1SSushil Singh    HMCID-01       ReadCase5      ${BAD_REQUEST}
164d03f2ce1SSushil Singh    HMCID-01       WriteCase1     ${BAD_REQUEST}
165d03f2ce1SSushil Singh    HMCID-01       WriteCase2     ${BAD_REQUEST}
166d03f2ce1SSushil Singh    HMCID-01       WriteCase3     ${BAD_REQUEST}
167d03f2ce1SSushil Singh    HMCID-01       WriteCase4     ${BAD_REQUEST}
168d03f2ce1SSushil Singh    HMCID-01       WriteCase5     ${BAD_REQUEST}
169afdd2a1dSVijay
170afdd2a1dSVijay
171d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Flag
172d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid lock flag passed.
173d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
174d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
175afdd2a1dSVijay
176d03f2ce1SSushil Singh    # client_id    lock_type       message
177d03f2ce1SSushil Singh    HMCID-01       ReadCase6       ${BAD_REQUEST}
178d03f2ce1SSushil Singh    HMCID-01       ReadCase7       ${BAD_REQUEST}
179d03f2ce1SSushil Singh    HMCID-01       ReadCase8       ${BAD_REQUEST}
180d03f2ce1SSushil Singh    HMCID-01       ReadCase9       ${BAD_REQUEST}
181d03f2ce1SSushil Singh    HMCID-01       ReadCase10      ${BAD_REQUEST}
182d03f2ce1SSushil Singh    HMCID-01       ReadCase11      ${BAD_REQUEST}
183d03f2ce1SSushil Singh    HMCID-01       WriteCase6      ${BAD_REQUEST}
184d03f2ce1SSushil Singh    HMCID-01       WriteCase7      ${BAD_REQUEST}
185d03f2ce1SSushil Singh    HMCID-01       WriteCase8      ${BAD_REQUEST}
186d03f2ce1SSushil Singh    HMCID-01       WriteCase9      ${BAD_REQUEST}
187d03f2ce1SSushil Singh    HMCID-01       WriteCase10     ${BAD_REQUEST}
188d03f2ce1SSushil Singh    HMCID-01       WriteCase11     ${BAD_REQUEST}
189afdd2a1dSVijay
190afdd2a1dSVijay
191d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Segment Flag
192d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
193d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Flag
194d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
195d03f2ce1SSushil Singh
196d03f2ce1SSushil Singh    # client_id    lock_type       message
197d03f2ce1SSushil Singh    HMCID-01       ReadCase12      ${BAD_REQUEST}
198d03f2ce1SSushil Singh    HMCID-01       ReadCase13      ${BAD_REQUEST}
199d03f2ce1SSushil Singh    HMCID-01       ReadCase14      ${BAD_REQUEST}
200d03f2ce1SSushil Singh    HMCID-01       WriteCase12     ${BAD_REQUEST}
201d03f2ce1SSushil Singh    HMCID-01       WriteCase13     ${BAD_REQUEST}
202d03f2ce1SSushil Singh    HMCID-01       WriteCase14     ${BAD_REQUEST}
203afdd2a1dSVijay
204bace3005SSushil Singh
2053b3a7ecaSSushil SinghFail To Acquire Lock For Invalid Segment Data Type Flag
2063b3a7ecaSSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
2073b3a7ecaSSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Data_Type_Flag
2083b3a7ecaSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
2093b3a7ecaSSushil Singh
2103b3a7ecaSSushil Singh    # client_id    lock_type       message
2113b3a7ecaSSushil Singh    HMCID-01       ReadCase15      ${EMPTY}
2123b3a7ecaSSushil Singh    HMCID-01       ReadCase16      ${EMPTY}
2133b3a7ecaSSushil Singh    HMCID-01       ReadCase17      ${EMPTY}
2143b3a7ecaSSushil Singh    HMCID-01       ReadCase18      ${EMPTY}
2153b3a7ecaSSushil Singh    HMCID-01       WriteCase15     ${EMPTY}
2163b3a7ecaSSushil Singh    HMCID-01       WriteCase16     ${EMPTY}
2173b3a7ecaSSushil Singh    HMCID-01       WriteCase17     ${EMPTY}
2183b3a7ecaSSushil Singh    HMCID-01       WriteCase18     ${EMPTY}
2193b3a7ecaSSushil Singh
2203b3a7ecaSSushil Singh
221bace3005SSushil SinghGet Empty Lock Records For Session Where No Locks Acquired
222bace3005SSushil Singh    [Documentation]  If session does not acquire locks then get lock should return
223bace3005SSushil Singh    ...              empty lock records.
224bace3005SSushil Singh    [Tags]  Get_Empty_Lock_Records_For_Session_Where_No_Locks_Acquired
225bace3005SSushil Singh    [Template]  Verify No Locks Records For Session With No Acquired Lock
226bace3005SSushil Singh
227bace3005SSushil Singh    # client_id
228bace3005SSushil Singh    HMCID-01
229bace3005SSushil Singh
230728ef9c9SSushil Singh
231*f9a536caSSushil SinghGet Lock Records Empty For Invalid Session
232*f9a536caSSushil Singh    [Documentation]  Record of lock list is empty for invalid session.
233*f9a536caSSushil Singh    [Tags]  Get_Lock_Records_Empty_For_Invalid_Session
234*f9a536caSSushil Singh    [Template]  Verify Empty Lock Records For Invalid Session
235*f9a536caSSushil Singh
236*f9a536caSSushil Singh    # client_id
237*f9a536caSSushil Singh    HMCID-01
238*f9a536caSSushil Singh
239*f9a536caSSushil Singh
240728ef9c9SSushil SinghGet Lock Records For Multiple Session
241728ef9c9SSushil Singh    [Documentation]  Get lock records of multiple session.
242728ef9c9SSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Session
243728ef9c9SSushil Singh    [Template]  Verify Lock Records Of Multiple Session
244728ef9c9SSushil Singh
245728ef9c9SSushil Singh    # client_ids         lock_type
246728ef9c9SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
247728ef9c9SSushil Singh
248728ef9c9SSushil Singh
249*f9a536caSSushil SinghGet Lock Records For Multiple Invalid Session
250*f9a536caSSushil Singh    [Documentation]  Record of lock list is empty for list of invalid session.
251*f9a536caSSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Invalid_Session
252*f9a536caSSushil Singh    [Template]  Verify Lock Records For Multiple Invalid Session
253*f9a536caSSushil Singh
254*f9a536caSSushil Singh    # client_id
255*f9a536caSSushil Singh    HMCID-01
256*f9a536caSSushil Singh
257bc331e22SVijay*** Keywords ***
258bc331e22SVijay
259d03f2ce1SSushil SinghCreate Redfish Session With ClientID
260d03f2ce1SSushil Singh    [Documentation]  Create redifish session with client id.
261d03f2ce1SSushil Singh    [Arguments]  ${client_id}
26285610eeeSVijay
26385610eeeSVijay    # Description of argument(s):
264d03f2ce1SSushil Singh    # client_id    This client id can contain string value
265d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
26685610eeeSVijay
267d03f2ce1SSushil Singh    ${session_info}=  Create Dictionary
268d03f2ce1SSushil Singh    ${session}=  Redfish Login  kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
26985610eeeSVijay
270d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  SessionIDs  ${session['Id']}
271d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  ClientID  ${session["Oem"]["OpenBMC"]["ClientID"]}
27285610eeeSVijay
273d03f2ce1SSushil Singh    [Return]  ${session_info}
27485610eeeSVijay
27585610eeeSVijay
276d03f2ce1SSushil SinghRW General Dictionary
277d03f2ce1SSushil Singh    [Documentation]  Create dictionay of lock request.
278d03f2ce1SSushil Singh    [Arguments]  ${read_case}  ${res_id}
279bc331e22SVijay
280bc331e22SVijay    # Description of argument(s):
281d03f2ce1SSushil Singh    # read_case    Read or Write lock type.
282d03f2ce1SSushil Singh    # res_id       Resource id.
283bc331e22SVijay
284d03f2ce1SSushil Singh    ${request_dict}=  Create Dictionary
285566daaf3SGeorge Keishing
286d03f2ce1SSushil Singh    FOR  ${key}  IN  @{read_case.keys()}
287d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  LockType  ${key}
288d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  SegmentFlags  ${read_case["${key}"]}
289d03f2ce1SSushil Singh    END
290bc331e22SVijay
291d03f2ce1SSushil Singh    Set To Dictionary  ${request_dict}  ResourceID  ${res_id}
292d03f2ce1SSushil Singh
293d03f2ce1SSushil Singh    [Return]  ${request_dict}
294bc331e22SVijay
295bc331e22SVijay
296d03f2ce1SSushil SinghReturn Description Of Response
297d03f2ce1SSushil Singh    [Documentation]  Return description of REST response.
298bc331e22SVijay    [Arguments]  ${resp_text}
299bc331e22SVijay
300bc331e22SVijay    # Description of argument(s):
301d03f2ce1SSushil Singh    # resp_text    REST response body.
302bc331e22SVijay
303d03f2ce1SSushil Singh    # resp_text after successful partition file upload looks like:
304d03f2ce1SSushil Singh    # {
305d03f2ce1SSushil Singh    #    "Description": "File Created"
306d03f2ce1SSushil Singh    # }
307bc331e22SVijay
308d03f2ce1SSushil Singh    ${message}=  Evaluate  json.loads('''${resp_text}''')  json
309d03f2ce1SSushil Singh
310d03f2ce1SSushil Singh    [Return]  ${message}
311bc331e22SVijay
312bc331e22SVijay
313a7d71f02SSushil SinghVerify Redfish Session Deleted
314a7d71f02SSushil Singh    [Documentation]  Verify the redfish session is deleted.
315a7d71f02SSushil Singh    [Arguments]  ${session_info}
316a7d71f02SSushil Singh
317a7d71f02SSushil Singh    # Description of argument(s):
318a7d71f02SSushil Singh    # session_info    Session information are stored in dictionary.
319a7d71f02SSushil Singh
320a7d71f02SSushil Singh    # ${session_info} = {
321a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
322a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
323a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
324a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
325a7d71f02SSushil Singh    # }
326a7d71f02SSushil Singh
327a7d71f02SSushil Singh    # SessionIDs   : Session IDs
328a7d71f02SSushil Singh    # ClientID     : Client ID
329a7d71f02SSushil Singh    # SessionToken : Session token
330a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
331a7d71f02SSushil Singh
332a7d71f02SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions
333a7d71f02SSushil Singh
334a7d71f02SSushil Singh    FOR  ${session}  IN  @{sessions['Members']}
335a7d71f02SSushil Singh      Should Not Be Equal As Strings  session  ['/redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}']
336a7d71f02SSushil Singh    END
337a7d71f02SSushil Singh
338a7d71f02SSushil Singh
339a7d71f02SSushil SinghVerify Redfish List Of Session Deleted
340a7d71f02SSushil Singh    [Documentation]  Verify all the list of redfish session is deleted.
341a7d71f02SSushil Singh    [Arguments]  ${session_info_list}
342a7d71f02SSushil Singh
343a7d71f02SSushil Singh    # Description of argument(s):
344a7d71f02SSushil Singh    # session_info_list    List contains individual session record are stored in dictionary.
345a7d71f02SSushil Singh
346a7d71f02SSushil Singh    # ${session_info_list} = [{
347a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
348a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
349a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
350a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
351a7d71f02SSushil Singh    # }]
352a7d71f02SSushil Singh
353a7d71f02SSushil Singh    # SessionIDs   : Session IDs
354a7d71f02SSushil Singh    # ClientID     : Client ID
355a7d71f02SSushil Singh    # SessionToken : Session token
356a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
357a7d71f02SSushil Singh
358a7d71f02SSushil Singh    FOR  ${session_record}  IN  @{session_info_list}
359a7d71f02SSushil Singh      Verify Redfish Session Deleted  ${session_record}
360a7d71f02SSushil Singh    END
361a7d71f02SSushil Singh
362a7d71f02SSushil Singh
363d03f2ce1SSushil SinghRedfish Post Acquire Lock
364d03f2ce1SSushil Singh    [Documentation]  Acquire and release lock.
365d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
366bc331e22SVijay
367bc331e22SVijay    # Description of argument(s):
368d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
369d03f2ce1SSushil Singh    # status_code    HTTP status code.
370bc331e22SVijay
371e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Lock  ${lock_type}
372e33c6e6aSSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
373d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
374d03f2ce1SSushil Singh    ${resp}=  Return Description Of Response  ${resp.content}
375bc331e22SVijay
376d03f2ce1SSushil Singh    [Return]  ${resp}
377bc331e22SVijay
378bc331e22SVijay
379977f8f58SSushil SinghRedfish Post Acquire List Lock
380977f8f58SSushil Singh    [Documentation]  Acquire and release lock.
381977f8f58SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
382977f8f58SSushil Singh
383977f8f58SSushil Singh    # Description of argument(s):
384977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
385977f8f58SSushil Singh    # status_code    HTTP status code.
386977f8f58SSushil Singh
387977f8f58SSushil Singh    ${lock_dict_param}=  Create Data To Acquire List Of Lock  ${lock_type}
388977f8f58SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
389977f8f58SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
390977f8f58SSushil Singh
391977f8f58SSushil Singh    [Return]  ${resp}
392977f8f58SSushil Singh
393977f8f58SSushil Singh
394d03f2ce1SSushil SinghRedfish Post Acquire Invalid Lock
395d03f2ce1SSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock.
396d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${message}  ${status_code}=${HTTP_OK}
397bc331e22SVijay
398bc331e22SVijay    # Description of argument(s):
399d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
400d03f2ce1SSushil Singh    # message        Return message from URI.
401d03f2ce1SSushil Singh    # status_code    HTTP status code.
402bc331e22SVijay
403e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Invalid Lock  ${lock_type}
404e33c6e6aSSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
405d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
4063b3a7ecaSSushil Singh    Run Keyword If  '${message}' != '${EMPTY}'
4073b3a7ecaSSushil Singh    ...  Valid Value  message  ['${resp.content}']
408d03f2ce1SSushil Singh
409d03f2ce1SSushil Singh    [Return]  ${resp}
410bc331e22SVijay
411bc331e22SVijay
412e33c6e6aSSushil SinghRedfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
413e33c6e6aSSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock with invalid data type of resource id.
414e33c6e6aSSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
415e33c6e6aSSushil Singh
416e33c6e6aSSushil Singh    # Description of argument(s):
417e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
418e33c6e6aSSushil Singh    # status_code    HTTP status code.
419e33c6e6aSSushil Singh
420e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID  ${lock_type}
421e33c6e6aSSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
422e33c6e6aSSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
423e33c6e6aSSushil Singh
424e33c6e6aSSushil Singh    [Return]  ${resp}
425e33c6e6aSSushil Singh
426e33c6e6aSSushil Singh
427d03f2ce1SSushil SinghForm Data To Acquire Lock
428d03f2ce1SSushil Singh    [Documentation]  Create a dictionay for lock request.
429d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
430d03f2ce1SSushil Singh
431d03f2ce1SSushil Singh    # Description of argument(s):
432d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
433d03f2ce1SSushil Singh
434d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
435d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
436d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
437d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
438d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
439e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
440d03f2ce1SSushil Singh
441e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
442e33c6e6aSSushil Singh
443e33c6e6aSSushil Singh
444977f8f58SSushil SinghCreate Data To Acquire List Of Lock
445977f8f58SSushil Singh    [Documentation]  Create a dictionay for list of lock request.
446977f8f58SSushil Singh    [Arguments]  ${lock_type_list}
447977f8f58SSushil Singh
448977f8f58SSushil Singh    # Description of argument(s):
449977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
450977f8f58SSushil Singh
451977f8f58SSushil Singh    ${temp_list}=  Create List
452977f8f58SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
453977f8f58SSushil Singh
454977f8f58SSushil Singh    FOR  ${lock_type}  IN  @{lock_type_list}
455977f8f58SSushil Singh      ${resp}=  RW General Dictionary
456977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
457977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["ResourceID"]}
458977f8f58SSushil Singh      Append To List  ${temp_list}  ${resp}
459977f8f58SSushil Singh    END
460977f8f58SSushil Singh
461977f8f58SSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
462977f8f58SSushil Singh
463977f8f58SSushil Singh    [Return]  ${lock_request_dict}
464977f8f58SSushil Singh
465977f8f58SSushil Singh
466e33c6e6aSSushil SinghForm Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
467e33c6e6aSSushil Singh    [Documentation]  Create a dictionay for in-valid lock request.
468e33c6e6aSSushil Singh    [Arguments]  ${lock_type}
469e33c6e6aSSushil Singh
470e33c6e6aSSushil Singh    # Description of argument(s):
471e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
472e33c6e6aSSushil Singh
473e33c6e6aSSushil Singh    ${lock_res_info}=  Get Lock Resource Information
474e33c6e6aSSushil Singh    ${resp}=  RW General Dictionary
475e33c6e6aSSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
476e33c6e6aSSushil Singh    ...    ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
477e33c6e6aSSushil Singh    ${temp_list}=  Create List  ${resp}
478e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
479e33c6e6aSSushil Singh
480e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
481d03f2ce1SSushil Singh
482d03f2ce1SSushil Singh
483d03f2ce1SSushil SinghForm Data To Acquire Invalid Lock
484d03f2ce1SSushil Singh    [Documentation]  Create a dictionay for in-valid lock request.
485d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
486d03f2ce1SSushil Singh
487d03f2ce1SSushil Singh    # Description of argument(s):
488d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
489d03f2ce1SSushil Singh
490d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
491d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
492d03f2ce1SSushil Singh    ...    ${lock_res_info["Invalid Case"]["${lock_type}"]}
493d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
494d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
495e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
496d03f2ce1SSushil Singh
497e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
498d03f2ce1SSushil Singh
499d03f2ce1SSushil Singh
500d03f2ce1SSushil SinghGet Locks List On Resource
501bc331e22SVijay    [Documentation]  Get locks list.
502d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${exp_status_code}=${HTTP_OK}
503bc331e22SVijay
504bc331e22SVijay    # Description of argument(s):
505d03f2ce1SSushil Singh    # session_info       Session information in dict.
506d03f2ce1SSushil Singh    # exp_status_code    Expected HTTP status code.
507bc331e22SVijay
508d03f2ce1SSushil Singh    ${data}=  Set Variable  {"SessionIDs": ["${session_info['SessionIDs']}"]}
509566daaf3SGeorge Keishing    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
510566daaf3SGeorge Keishing    ...  data=${data}
511bc331e22SVijay    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
512bc331e22SVijay
513bc331e22SVijay    [Return]  ${locks["Records"]}
514bc331e22SVijay
515bc331e22SVijay
516d03f2ce1SSushil SinghVerify Lock On Resource
517d03f2ce1SSushil Singh    [Documentation]  Verify lock on resource.
518d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${transaction_id}
519bc331e22SVijay
520bc331e22SVijay    # Description of argument(s):
521d03f2ce1SSushil Singh    # session_info      Session information in dict.
522d03f2ce1SSushil Singh    # transaction_id    Transaction id in list stored in dict.
523bc331e22SVijay
524d03f2ce1SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
525d03f2ce1SSushil Singh    Rprint Vars  sessions
526d03f2ce1SSushil Singh    ${lock_list}=  Get Locks List On Resource  ${session_info}
527d03f2ce1SSushil Singh    ${lock_length}=  Get Length  ${lock_list}
528d03f2ce1SSushil Singh    ${tran_id_length}=  Get Length  ${transaction_id}
529d03f2ce1SSushil Singh    Should Be Equal As Integers  ${tran_id_length}  ${lock_length}
530afdd2a1dSVijay
531d03f2ce1SSushil Singh    FOR  ${tran_id}  ${lock}  IN ZIP  ${transaction_id}  ${lock_list}
532d03f2ce1SSushil Singh      Valid Value  session_info['ClientID']  ['${lock['HMCID']}']
533d03f2ce1SSushil Singh      Valid Value  session_info['SessionIDs']  ['${lock['SessionID']}']
534d03f2ce1SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock['TransactionID']}
535bc331e22SVijay    END
536bc331e22SVijay
537bc331e22SVijay
538d03f2ce1SSushil SinghAcquire Lock On Resource
539d03f2ce1SSushil Singh    [Documentation]  Acquire lock on resource.
540d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${reboot_flag}=False
541bc331e22SVijay
542bc331e22SVijay    # Description of argument(s):
543d03f2ce1SSushil Singh    # client_id    This client id can contain string value
544d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
545d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
546d03f2ce1SSushil Singh    # reboot_flag  Flag is used to run reboot the BMC code.
547d03f2ce1SSushil Singh    #               (e.g. True or False).
548bc331e22SVijay
549d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
550d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
551d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
552d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
553d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
554566daaf3SGeorge Keishing
555e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
556bc331e22SVijay
557d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'True'
558d03f2ce1SSushil Singh    ...  Run Keywords  Redfish OBMC Reboot (off)  AND
559d03f2ce1SSushil Singh    ...  Redfish Login  AND
560e33c6e6aSSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
561d03f2ce1SSushil Singh    ...  Verify Lock On Resource  ${session_info}  ${trans_id_list}  AND
562d03f2ce1SSushil Singh    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
563bc331e22SVijay
564d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'False'
565d03f2ce1SSushil Singh    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
566bc331e22SVijay
567d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
568d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
569d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
570bc331e22SVijay
571bc331e22SVijay
572d03f2ce1SSushil SinghForm Data To Release Lock
573d03f2ce1SSushil Singh    [Documentation]  Create a dictonay to release lock.
574d03f2ce1SSushil Singh    [Arguments]  ${trans_id_list}
575355daac7SVijay
576355daac7SVijay    # Description of argument(s):
577d03f2ce1SSushil Singh    # trans_id_list
578355daac7SVijay
579d03f2ce1SSushil Singh    @{tran_ids}=  Create List
580355daac7SVijay
581d03f2ce1SSushil Singh    FOR  ${item}  IN  @{trans_id_list}
582d03f2ce1SSushil Singh      Append To List  ${tran_ids}  ${item['TransactionID']}
583d03f2ce1SSushil Singh    END
584d03f2ce1SSushil Singh
585d03f2ce1SSushil Singh    [Return]  ${tran_ids}
586d03f2ce1SSushil Singh
587d03f2ce1SSushil Singh
588d03f2ce1SSushil SinghRelease Locks On Resource
589d03f2ce1SSushil Singh    [Documentation]  Redfish request to release a lock.
590d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}  ${release_lock_type}=Transaction  ${status_code}=${HTTP_OK}
591d03f2ce1SSushil Singh
592d03f2ce1SSushil Singh    # Description of argument(s):
593d03f2ce1SSushil Singh    # session_info        Session information in dict.
594d03f2ce1SSushil Singh    # trans_id_list       Transaction id list.
595d03f2ce1SSushil Singh    # release_lock_type   Release lock by Transaction, Session.
596d03f2ce1SSushil Singh    # status_code         HTTP status code.
597d03f2ce1SSushil Singh
598d03f2ce1SSushil Singh    ${tran_ids}=  Form Data To Release Lock  ${trans_id_list}
599d03f2ce1SSushil Singh    ${data}=  Set Variable  {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
600d03f2ce1SSushil Singh    ${data}=  Evaluate  json.dumps(${data})  json
601d03f2ce1SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock  data=${data}
602d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
603d03f2ce1SSushil Singh
604d03f2ce1SSushil Singh
605d03f2ce1SSushil SinghAcquire Lock On Another Lock
606d03f2ce1SSushil Singh    [Documentation]  Acquire lock on another lock.
607d03f2ce1SSushil Singh    [Arguments]  ${client_id}
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
613d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
614d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
615d03f2ce1SSushil Singh
616d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
617d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
618d03f2ce1SSushil Singh
619d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
620d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
621d03f2ce1SSushil Singh
622d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
623d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}
624d03f2ce1SSushil Singh
625d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
626d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
627d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
628d03f2ce1SSushil Singh
629d03f2ce1SSushil Singh
630977f8f58SSushil SinghVerify Fail To Acquire Read And Write In Single Request
631977f8f58SSushil Singh    [Documentation]  Verify fail to acquire read and write lock passed in single request.
632977f8f58SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
633977f8f58SSushil Singh
634977f8f58SSushil Singh    # Description of argument(s):
635977f8f58SSushil Singh    # client_id    This client id can contain string value
636977f8f58SSushil Singh    #              (e.g. 12345, "HMCID").
637977f8f58SSushil Singh    # lock_type    Read lock or Write lock.
638977f8f58SSushil Singh
639977f8f58SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
640977f8f58SSushil Singh
641977f8f58SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
642977f8f58SSushil Singh    ${trans_id}=  Redfish Post Acquire List Lock  ${lock_type_list}  status_code=${HTTP_BAD_REQUEST}
643977f8f58SSushil Singh    Redfish Delete Session  ${session_info}
644977f8f58SSushil Singh
645977f8f58SSushil Singh
646d03f2ce1SSushil SinghVerify Empty Lock Records For Invalid Session
647d03f2ce1SSushil Singh    [Documentation]  Verify no lock record found for invalid session.
648d03f2ce1SSushil Singh    [Arguments]  ${client_id}
649d03f2ce1SSushil Singh
650d03f2ce1SSushil Singh    # Description of argument(s):
651d03f2ce1SSushil Singh    # client_id    This client id can contain string value
652d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
653d03f2ce1SSushil Singh
654d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_id}
655d03f2ce1SSushil Singh
656d03f2ce1SSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
657d03f2ce1SSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
658d03f2ce1SSushil Singh
659d03f2ce1SSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
660d03f2ce1SSushil Singh    set to dictionary  ${session_info2}  SessionIDs  xxyXyyYZZz
661d03f2ce1SSushil Singh
662d03f2ce1SSushil Singh    ${lock_list2}=  Get Locks List On Resource  ${session_info2}
663*f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list2}
664d03f2ce1SSushil Singh
665*f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
666d03f2ce1SSushil Singh
667d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
668d03f2ce1SSushil Singh
669d03f2ce1SSushil Singh
670d03f2ce1SSushil SinghVerify Acquire Lock Fails On Another Lock
671d03f2ce1SSushil Singh    [Documentation]  Verify acquire lock on another lock fails.
672d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
673d03f2ce1SSushil Singh
674d03f2ce1SSushil Singh    # Description of argument(s):
675d03f2ce1SSushil Singh    # client_id    This client id can contain string value
676d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
677d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
678d03f2ce1SSushil Singh
679d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
680d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
681d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
682d03f2ce1SSushil Singh
683d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
684d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
685d03f2ce1SSushil Singh
686d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
687d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
688d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}
689d03f2ce1SSushil Singh
690d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
691d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
692d03f2ce1SSushil Singh
693d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
694d03f2ce1SSushil Singh
695d03f2ce1SSushil Singh
696e33c6e6aSSushil SinghVerify Acquire Lock After Reboot
697e33c6e6aSSushil Singh    [Documentation]  Acquire read and write lock after the reboot and release lock.
698e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
699e33c6e6aSSushil Singh
700e33c6e6aSSushil Singh    # Description of argument(s):
701e33c6e6aSSushil Singh    # client_id    This client id can contain string value
702e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
703e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
704e33c6e6aSSushil Singh
705e33c6e6aSSushil Singh    ${trans_id_list}=  Create List
706*f9a536caSSushil Singh    ${session_info}=  Create Session With ClientID  ${client_id}
707e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
708e33c6e6aSSushil Singh    Redfish OBMC Reboot (off)
709e33c6e6aSSushil Singh    Redfish Login
710e33c6e6aSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}
711e33c6e6aSSushil Singh
712e33c6e6aSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
713e33c6e6aSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
714e33c6e6aSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
715e33c6e6aSSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
716e33c6e6aSSushil Singh
717e33c6e6aSSushil Singh    ${trans_id_emptylist}=  Create List
718e33c6e6aSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
719e33c6e6aSSushil Singh    Redfish Delete Session  ${session_info}
720e33c6e6aSSushil Singh
721e33c6e6aSSushil Singh
722d03f2ce1SSushil SinghVerify Acquire And Release Lock In Loop
723d03f2ce1SSushil Singh    [Documentation]  Acquire lock in loop.
724d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
725d03f2ce1SSushil Singh
726d03f2ce1SSushil Singh    # Description of argument(s):
727d03f2ce1SSushil Singh    # client_id    This client id can contain string value
728d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
729d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
730d03f2ce1SSushil Singh
731d03f2ce1SSushil Singh    FOR  ${count}  IN RANGE  1  11
732d03f2ce1SSushil Singh      ${trans_id_list}=  Create List
733d03f2ce1SSushil Singh      ${session_info}=  Create Redfish Session With ClientID  ${client_id}
734d03f2ce1SSushil Singh      ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
735d03f2ce1SSushil Singh      Append To List  ${trans_id_list}  ${trans_id}
736d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_list}
737d03f2ce1SSushil Singh      Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
738d03f2ce1SSushil Singh      ${trans_id_emptylist}=  Create List
739d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
740d03f2ce1SSushil Singh    END
741d03f2ce1SSushil Singh
742d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
743d03f2ce1SSushil Singh
744d03f2ce1SSushil Singh
745d03f2ce1SSushil SinghAcquire And Release Multiple Locks
746d03f2ce1SSushil Singh    [Documentation]  Acquire mutilple locks on resource.
747d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
748d03f2ce1SSushil Singh
749d03f2ce1SSushil Singh    # Description of argument(s):
750d03f2ce1SSushil Singh    # client_id          This client id can contain string value
751d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
752d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
753d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
754d03f2ce1SSushil Singh
755d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
756d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
757d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
758d03f2ce1SSushil Singh
759d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
760d03f2ce1SSushil Singh
761d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
762d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
763d03f2ce1SSushil Singh
764d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
765d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
766d03f2ce1SSushil Singh
767d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
768d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
769d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
770d03f2ce1SSushil Singh
771d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
772d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
773d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
774d03f2ce1SSushil Singh
775d03f2ce1SSushil Singh
776d03f2ce1SSushil SinghVerify Invalid Locks Fail To Release
777d03f2ce1SSushil Singh    [Documentation]  Verify invalid locks fails to be released.
778d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
779d03f2ce1SSushil Singh
780d03f2ce1SSushil Singh    # Description of argument(s):
781d03f2ce1SSushil Singh    # client_id          This client id can contain string value
782d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
783d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
784d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
785d03f2ce1SSushil Singh
786d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
787d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
788d03f2ce1SSushil Singh
789d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
790d03f2ce1SSushil Singh
791d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
792d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
793d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
794d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
795d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
796d03f2ce1SSushil Singh
797d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
798d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
799d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
800d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
801d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
802d03f2ce1SSushil Singh
803d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
804d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
805d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
806d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
807d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
808d03f2ce1SSushil Singh
809d03f2ce1SSushil Singh    Release Locks On Resource
810d03f2ce1SSushil Singh    ...  ${session_info}  ${trans_id_list}
811d03f2ce1SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
812d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
813d03f2ce1SSushil Singh
814d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
815d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
816d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
817d03f2ce1SSushil Singh
818d03f2ce1SSushil Singh
819d03f2ce1SSushil SinghVerify Fail To Release Lock For Another Session
820d03f2ce1SSushil Singh    [Documentation]  Verify failed to release the lock form another session.
821d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
822d03f2ce1SSushil Singh
823d03f2ce1SSushil Singh    # Description of argument(s):
824d03f2ce1SSushil Singh    # client_id    This client id can contain string value
825d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
826d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
827d03f2ce1SSushil Singh
828d03f2ce1SSushil Singh    ${client_ids}=  Split String  ${client_id}  ,
829d03f2ce1SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
830d03f2ce1SSushil Singh    ${trans_id_list1}=  Create List
831d03f2ce1SSushil Singh    ${trans_id_list2}=  Create List
832d03f2ce1SSushil Singh
833d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_ids}[0]
834d03f2ce1SSushil Singh
835d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
836d03f2ce1SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
837d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
838d03f2ce1SSushil Singh
839d03f2ce1SSushil Singh    ${session_info2}=  Create Redfish Session With ClientID  ${client_ids}[1]
840d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
841d03f2ce1SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
842d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info2}  ${trans_id_list2}
843d03f2ce1SSushil Singh
844d03f2ce1SSushil Singh    Release Locks On Resource
845d03f2ce1SSushil Singh    ...  ${session_info1}  ${trans_id_list1}  Transaction  status_code=${HTTP_UNAUTHORIZED}
846d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
847d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Session
848d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Session
849d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
850d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info2}
851d03f2ce1SSushil Singh
852d03f2ce1SSushil Singh
853e33c6e6aSSushil SinghVerify Fail To Acquire Lock For Invalid Resource ID Data Type
854e33c6e6aSSushil Singh    [Documentation]  Verify fail to acquire the lock with invalid resource id data type.
855e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
856e33c6e6aSSushil Singh
857e33c6e6aSSushil Singh    # Description of argument(s):
858e33c6e6aSSushil Singh    # client_id    This client id can contain string value
859e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
860e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
861e33c6e6aSSushil Singh
862e33c6e6aSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
863e33c6e6aSSushil Singh    Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
864e33c6e6aSSushil Singh    ...  ${lock_type}  status_code=${HTTP_BAD_REQUEST}
865e33c6e6aSSushil Singh    Redfish Delete Session  ${session_info}
866e33c6e6aSSushil Singh
867e33c6e6aSSushil Singh
868d03f2ce1SSushil SinghVerify Fail To Acquire Lock For Invalid Lock Data
869e33c6e6aSSushil Singh    [Documentation]  Verify fail to acquired lock with invalid lock types, lock flags, segement flags.
870d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${message}
871d03f2ce1SSushil Singh
872d03f2ce1SSushil Singh    # Description of argument(s):
873d03f2ce1SSushil Singh    # client_id    This client id can contain string value
874d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
875d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
876d03f2ce1SSushil Singh    # message      Return message from URI.
877d03f2ce1SSushil Singh
878d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
879d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Invalid Lock  ${lock_type}  message=${message}  status_code=${HTTP_BAD_REQUEST}
880d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
881bace3005SSushil Singh
882bace3005SSushil Singh
883bace3005SSushil SinghVerify No Locks Records For Session With No Acquired Lock
884bace3005SSushil Singh    [Documentation]  Verify no records found for a session where no lock is acquired.
885bace3005SSushil Singh    [Arguments]  ${client_id}
886bace3005SSushil Singh
887bace3005SSushil Singh    # Description of argument(s):
888bace3005SSushil Singh    # client_id    This client id can contain string value
889bace3005SSushil Singh    #              (e.g. 12345, "HMCID").
890bace3005SSushil Singh
891bace3005SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
892bace3005SSushil Singh    ${trans_id_emptylist}=  Create List
893bace3005SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
894bace3005SSushil Singh    Redfish Delete Session  ${session_info}
895728ef9c9SSushil Singh
896728ef9c9SSushil Singh
897728ef9c9SSushil SinghCreate List Of Session ID
898728ef9c9SSushil Singh    [Documentation]  Create session id list from session dict info.
899728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}
900728ef9c9SSushil Singh
901728ef9c9SSushil Singh    # Description of argument(s):
902728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
903728ef9c9SSushil Singh
904728ef9c9SSushil Singh    @{session_id_list}=  Create List
905728ef9c9SSushil Singh
906728ef9c9SSushil Singh    FOR  ${session}  IN  @{session_dict_info}
907728ef9c9SSushil Singh      Append To List  ${session_id_list}  ${session["SessionIDs"]}
908728ef9c9SSushil Singh    END
909728ef9c9SSushil Singh
910728ef9c9SSushil Singh    ${num_id}=  Get Length  ${session_id_list}
911728ef9c9SSushil Singh    Should Not Be Equal As Integers  ${num_id}  ${0}
912728ef9c9SSushil Singh
913728ef9c9SSushil Singh    ${session_id_list}=  Evaluate  json.dumps(${session_id_list})  json
914728ef9c9SSushil Singh
915728ef9c9SSushil Singh    [Return]  ${session_id_list}
916728ef9c9SSushil Singh
917728ef9c9SSushil Singh
918728ef9c9SSushil SinghGet Locks List On Resource With Session List
919728ef9c9SSushil Singh    [Documentation]  Get locks list from session of list.
920728ef9c9SSushil Singh    [Arguments]  ${session_id_list}  ${exp_status_code}=${HTTP_OK}
921728ef9c9SSushil Singh
922728ef9c9SSushil Singh    # Description of argument(s):
923728ef9c9SSushil Singh    # session_id_list    Session ids list.
924728ef9c9SSushil Singh    # exp_status_code    Expected HTTP status code.
925728ef9c9SSushil Singh
926728ef9c9SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
927728ef9c9SSushil Singh    ...  data={"SessionIDs": ${session_id_list}}
928728ef9c9SSushil Singh    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
929728ef9c9SSushil Singh
930728ef9c9SSushil Singh    [Return]  ${locks}
931728ef9c9SSushil Singh
932728ef9c9SSushil Singh
933728ef9c9SSushil SinghVerify List Of Session Lock On Resource
934728ef9c9SSushil Singh    [Documentation]  Verify list of lock record from list of sessions.
935728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}  ${transaction_id_list}
936728ef9c9SSushil Singh
937728ef9c9SSushil Singh    # Description of argument(s):
938728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
939728ef9c9SSushil Singh    # transaction_id_list    Transaction id in list stored in dict.
940728ef9c9SSushil Singh
941728ef9c9SSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_info}
942728ef9c9SSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
943728ef9c9SSushil Singh    ${lock_list}=  Set Variable  ${lock_list_resp['Records']}
944728ef9c9SSushil Singh
945728ef9c9SSushil Singh    FOR  ${session_id}  ${tran_id}  ${lock_record}  IN ZIP  ${session_dict_info}  ${transaction_id_list}  ${lock_list}
946728ef9c9SSushil Singh      Valid Value  session_id['SessionIDs']  ['${lock_record['SessionID']}']
947728ef9c9SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock_record['TransactionID']}
948728ef9c9SSushil Singh    END
949728ef9c9SSushil Singh
950728ef9c9SSushil Singh
951728ef9c9SSushil SinghVerify Lock Records Of Multiple Session
952728ef9c9SSushil Singh    [Documentation]  Verify all records found for a multiple sessions.
953728ef9c9SSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
954728ef9c9SSushil Singh
955728ef9c9SSushil Singh    # Description of argument(s):
956728ef9c9SSushil Singh    # client_ids    This client id can contain string value
957728ef9c9SSushil Singh    #               (e.g. 12345, "HMCID").
958728ef9c9SSushil Singh    # lock_type     Read lock or Write lock.
959728ef9c9SSushil Singh
960728ef9c9SSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
961728ef9c9SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
962728ef9c9SSushil Singh    ${trans_id_list1}=  Create List
963728ef9c9SSushil Singh    ${trans_id_list2}=  Create List
964728ef9c9SSushil Singh
965728ef9c9SSushil Singh    ${session_dict_list}=  Create List
966728ef9c9SSushil Singh    ${lock_list}=  Create List
967728ef9c9SSushil Singh
968728ef9c9SSushil Singh    ${client_id1}=  Create List
969728ef9c9SSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
970728ef9c9SSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
971728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
972728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
973728ef9c9SSushil Singh
974728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
975728ef9c9SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
976728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
977728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
978728ef9c9SSushil Singh
979728ef9c9SSushil Singh
980728ef9c9SSushil Singh    ${client_id2}=  Create List
981728ef9c9SSushil Singh    Append To List  ${client_id2}  ${client_id_list}[1]
982728ef9c9SSushil Singh    ${session_info2}=  Create Session With List Of ClientID  ${client_id2}
983728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
984728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id2}  ${session_info2}
985728ef9c9SSushil Singh
986728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
987728ef9c9SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
988728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
989728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_list2}
990728ef9c9SSushil Singh
991728ef9c9SSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
992728ef9c9SSushil Singh
993728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
994728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
995728ef9c9SSushil Singh
996728ef9c9SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
997728ef9c9SSushil Singh
998728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info2}[0]  SessionToken
999728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1000728ef9c9SSushil Singh
1001728ef9c9SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Transaction
1002728ef9c9SSushil Singh
1003728ef9c9SSushil Singh    ${trans_id_emptylist}=  Create List
1004728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
1005728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_emptylist}
1006728ef9c9SSushil Singh
1007728ef9c9SSushil Singh    Redfish Delete List Of Session  ${session_dict_list}
1008*f9a536caSSushil Singh
1009*f9a536caSSushil Singh
1010*f9a536caSSushil SinghVerify Lock Records For Multiple Invalid Session
1011*f9a536caSSushil Singh    [Documentation]  Verify no lock record found for multiple invalid session.
1012*f9a536caSSushil Singh    [Arguments]  ${client_id}
1013*f9a536caSSushil Singh
1014*f9a536caSSushil Singh    # Description of argument(s):
1015*f9a536caSSushil Singh    # client_id    This client id can contain string value
1016*f9a536caSSushil Singh    #              (e.g. 12345, "HMCID").
1017*f9a536caSSushil Singh
1018*f9a536caSSushil Singh    ${session_dict_list}=  Create List
1019*f9a536caSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz  xXyXYyYZzz
1020*f9a536caSSushil Singh
1021*f9a536caSSushil Singh    ${session_info1}=  Create Session With ClientID  ${client_id}
1022*f9a536caSSushil Singh
1023*f9a536caSSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
1024*f9a536caSSushil Singh    set to dictionary  ${session_info2}  SessionIDs  ${invalid_session_ids}[0]
1025*f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}
1026*f9a536caSSushil Singh
1027*f9a536caSSushil Singh    ${session_info3}=  Copy Dictionary  ${session_info1}  deepcopy=True
1028*f9a536caSSushil Singh    set to dictionary  ${session_info3}  SessionIDs  ${invalid_session_ids}[0]
1029*f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info3}
1030*f9a536caSSushil Singh
1031*f9a536caSSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
1032*f9a536caSSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
1033*f9a536caSSushil Singh
1034*f9a536caSSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_list}
1035*f9a536caSSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1036*f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list_resp['Records']}
1037*f9a536caSSushil Singh
1038*f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
1039*f9a536caSSushil Singh
1040*f9a536caSSushil Singh    Redfish Delete Session  ${session_info1}
1041