xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_lock_management.robot (revision 59011d08ab8fdd8146c43292371d1ff9da815ffe)
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
13df390b61SSushil SinghSuite Teardown       Run Keyword And Ignore Error  Delete All Redfish Sessions
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
109df390b61SSushil SinghAcquire Multiple Lock Request At CEC Level
110df390b61SSushil Singh    [Documentation]  Acquire write lock on read lock under CEC level.
111df390b61SSushil Singh    [Tags]  Acquire_Multiple_Lock_Request_At_CEC_Level
112df390b61SSushil Singh    [Template]  Verify Acquire Multiple Lock Request At CEC Level
113df390b61SSushil Singh
114df390b61SSushil Singh    # client_id    lock_type
115df390b61SSushil Singh    HMCID-01       ReadCase4,WriteCase4
116df390b61SSushil Singh    HMCID-01       WriteCase5,ReadCase5
117df390b61SSushil Singh    HMCID-01       ReadCase6,WriteCase6
118df390b61SSushil Singh    HMCID-01       WriteCase7,ReadCase7
119df390b61SSushil Singh
120df390b61SSushil Singh
121d03f2ce1SSushil SinghVerify Release Of Valid Locks
122d03f2ce1SSushil Singh    [Documentation]  Release all valid locks.
123d03f2ce1SSushil Singh    [Tags]  Verify_Release_Of_Valid_Locks
124d03f2ce1SSushil Singh    [Template]  Acquire And Release Multiple Locks
125afdd2a1dSVijay
126d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
127d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
128d03f2ce1SSushil Singh    HMCID-02       ReadCase1,ReadCase1,ReadCase1    Session
129afdd2a1dSVijay
130afdd2a1dSVijay
131*59011d08SSushil SinghFail To Release Lock With Invalid TransactionID
132*59011d08SSushil Singh    [Documentation]  Fail to release lock with invalid transaction id.
133*59011d08SSushil Singh    [Tags]  Fail_To_Release_Lock_With_Invalid_TransactionID
134*59011d08SSushil Singh    [Template]  Verify Fail To Release Lock With Invalid TransactionID
135*59011d08SSushil Singh
136*59011d08SSushil Singh    # client_id    lock_type    release_lock_type
137*59011d08SSushil Singh    HMCID-01       ReadCase1    Transaction
138*59011d08SSushil Singh
139*59011d08SSushil Singh
1401b59053dSSushil SinghFail To Release Multiple Lock With Invalid TransactionID
141d03f2ce1SSushil Singh    [Documentation]  Release in-valid lock result in fail.
1421b59053dSSushil Singh    [Tags]  Fail_To_Release_Multiple_Lock_With_Invalid_TransactionID
1431b59053dSSushil Singh    [Template]  Verify Fail To Release Multiple Lock With Invalid TransactionID
144afdd2a1dSVijay
145d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
146d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
147d03f2ce1SSushil Singh    12345          ReadCase2,ReadCase2,ReadCase2    Transaction
148d03f2ce1SSushil Singh    HMCID          ReadCase3,ReadCase3,ReadCase3    Transaction
149afdd2a1dSVijay
150afdd2a1dSVijay
151d03f2ce1SSushil SinghFail To Release Lock For Another Session
152d03f2ce1SSushil Singh    [Documentation]  Failed to release locks from another session.
153d03f2ce1SSushil Singh    [Tags]  Fail_To_Release_Lock_For_Another_Session
154d03f2ce1SSushil Singh    [Template]  Verify Fail To Release Lock For Another Session
155afdd2a1dSVijay
156d03f2ce1SSushil Singh    # client_id          lock_type
157d03f2ce1SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
158afdd2a1dSVijay
159afdd2a1dSVijay
160e33c6e6aSSushil SinghTest Invalid Resource ID Data Type Locking
161e33c6e6aSSushil Singh    [Documentation]  Failed to acquire lock for invalid resource id data type.
162e33c6e6aSSushil Singh    [Tags]  Test_Invalid_Resource_ID_Data_Type_Locking
163e33c6e6aSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Resource ID Data Type
164e33c6e6aSSushil Singh
165e33c6e6aSSushil Singh    # client_id    lock_type
166e33c6e6aSSushil Singh    HMCID-01       ReadCase1
167e33c6e6aSSushil Singh    HMCID-01       ReadCase2
168e33c6e6aSSushil Singh    HMCID-01       ReadCase3
169e33c6e6aSSushil Singh    HMCID-01       WriteCase1
170e33c6e6aSSushil Singh    HMCID-01       WriteCase2
171e33c6e6aSSushil Singh    HMCID-01       WriteCase3
172e33c6e6aSSushil Singh
173e33c6e6aSSushil Singh
174d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Type
175d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read, write lock for invalid lock data passed.
176d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Type
177d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
178afdd2a1dSVijay
179d03f2ce1SSushil Singh    # client_id    lock_type      message
180d03f2ce1SSushil Singh    HMCID-01       ReadCase1      ${BAD_REQUEST}
181d03f2ce1SSushil Singh    HMCID-01       ReadCase2      ${BAD_REQUEST}
182d03f2ce1SSushil Singh    HMCID-01       ReadCase3      ${BAD_REQUEST}
183d03f2ce1SSushil Singh    HMCID-01       ReadCase4      ${BAD_REQUEST}
184d03f2ce1SSushil Singh    HMCID-01       ReadCase5      ${BAD_REQUEST}
185d03f2ce1SSushil Singh    HMCID-01       WriteCase1     ${BAD_REQUEST}
186d03f2ce1SSushil Singh    HMCID-01       WriteCase2     ${BAD_REQUEST}
187d03f2ce1SSushil Singh    HMCID-01       WriteCase3     ${BAD_REQUEST}
188d03f2ce1SSushil Singh    HMCID-01       WriteCase4     ${BAD_REQUEST}
189d03f2ce1SSushil Singh    HMCID-01       WriteCase5     ${BAD_REQUEST}
190afdd2a1dSVijay
191afdd2a1dSVijay
192d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Flag
193d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid lock flag passed.
194d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
195d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
196afdd2a1dSVijay
197d03f2ce1SSushil Singh    # client_id    lock_type       message
198d03f2ce1SSushil Singh    HMCID-01       ReadCase6       ${BAD_REQUEST}
199d03f2ce1SSushil Singh    HMCID-01       ReadCase7       ${BAD_REQUEST}
200d03f2ce1SSushil Singh    HMCID-01       ReadCase8       ${BAD_REQUEST}
201d03f2ce1SSushil Singh    HMCID-01       ReadCase9       ${BAD_REQUEST}
202d03f2ce1SSushil Singh    HMCID-01       ReadCase10      ${BAD_REQUEST}
203d03f2ce1SSushil Singh    HMCID-01       ReadCase11      ${BAD_REQUEST}
204d03f2ce1SSushil Singh    HMCID-01       WriteCase6      ${BAD_REQUEST}
205d03f2ce1SSushil Singh    HMCID-01       WriteCase7      ${BAD_REQUEST}
206d03f2ce1SSushil Singh    HMCID-01       WriteCase8      ${BAD_REQUEST}
207d03f2ce1SSushil Singh    HMCID-01       WriteCase9      ${BAD_REQUEST}
208d03f2ce1SSushil Singh    HMCID-01       WriteCase10     ${BAD_REQUEST}
209d03f2ce1SSushil Singh    HMCID-01       WriteCase11     ${BAD_REQUEST}
210afdd2a1dSVijay
211afdd2a1dSVijay
212d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Segment Flag
213d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
214d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Flag
215d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
216d03f2ce1SSushil Singh
217d03f2ce1SSushil Singh    # client_id    lock_type       message
218d03f2ce1SSushil Singh    HMCID-01       ReadCase12      ${BAD_REQUEST}
219d03f2ce1SSushil Singh    HMCID-01       ReadCase13      ${BAD_REQUEST}
220d03f2ce1SSushil Singh    HMCID-01       ReadCase14      ${BAD_REQUEST}
221d03f2ce1SSushil Singh    HMCID-01       WriteCase12     ${BAD_REQUEST}
222d03f2ce1SSushil Singh    HMCID-01       WriteCase13     ${BAD_REQUEST}
223d03f2ce1SSushil Singh    HMCID-01       WriteCase14     ${BAD_REQUEST}
224afdd2a1dSVijay
225bace3005SSushil Singh
2263b3a7ecaSSushil SinghFail To Acquire Lock For Invalid Segment Data Type Flag
2273b3a7ecaSSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
2283b3a7ecaSSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Data_Type_Flag
2293b3a7ecaSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
2303b3a7ecaSSushil Singh
2313b3a7ecaSSushil Singh    # client_id    lock_type       message
2323b3a7ecaSSushil Singh    HMCID-01       ReadCase15      ${EMPTY}
2333b3a7ecaSSushil Singh    HMCID-01       ReadCase16      ${EMPTY}
2343b3a7ecaSSushil Singh    HMCID-01       ReadCase17      ${EMPTY}
2353b3a7ecaSSushil Singh    HMCID-01       ReadCase18      ${EMPTY}
2363b3a7ecaSSushil Singh    HMCID-01       WriteCase15     ${EMPTY}
2373b3a7ecaSSushil Singh    HMCID-01       WriteCase16     ${EMPTY}
2383b3a7ecaSSushil Singh    HMCID-01       WriteCase17     ${EMPTY}
2393b3a7ecaSSushil Singh    HMCID-01       WriteCase18     ${EMPTY}
2403b3a7ecaSSushil Singh
2413b3a7ecaSSushil Singh
242bace3005SSushil SinghGet Empty Lock Records For Session Where No Locks Acquired
243bace3005SSushil Singh    [Documentation]  If session does not acquire locks then get lock should return
244bace3005SSushil Singh    ...              empty lock records.
245bace3005SSushil Singh    [Tags]  Get_Empty_Lock_Records_For_Session_Where_No_Locks_Acquired
246bace3005SSushil Singh    [Template]  Verify No Locks Records For Session With No Acquired Lock
247bace3005SSushil Singh
248bace3005SSushil Singh    # client_id
249bace3005SSushil Singh    HMCID-01
250bace3005SSushil Singh
251728ef9c9SSushil Singh
252f9a536caSSushil SinghGet Lock Records Empty For Invalid Session
253f9a536caSSushil Singh    [Documentation]  Record of lock list is empty for invalid session.
254f9a536caSSushil Singh    [Tags]  Get_Lock_Records_Empty_For_Invalid_Session
255f9a536caSSushil Singh    [Template]  Verify Empty Lock Records For Invalid Session
256f9a536caSSushil Singh
257f9a536caSSushil Singh    # client_id
258f9a536caSSushil Singh    HMCID-01
259f9a536caSSushil Singh
260f9a536caSSushil Singh
261728ef9c9SSushil SinghGet Lock Records For Multiple Session
262728ef9c9SSushil Singh    [Documentation]  Get lock records of multiple session.
263728ef9c9SSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Session
264728ef9c9SSushil Singh    [Template]  Verify Lock Records Of Multiple Session
265728ef9c9SSushil Singh
266728ef9c9SSushil Singh    # client_ids         lock_type
267728ef9c9SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
268728ef9c9SSushil Singh
269728ef9c9SSushil Singh
270f9a536caSSushil SinghGet Lock Records For Multiple Invalid Session
271f9a536caSSushil Singh    [Documentation]  Record of lock list is empty for list of invalid session.
272f9a536caSSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Invalid_Session
273f9a536caSSushil Singh    [Template]  Verify Lock Records For Multiple Invalid Session
274f9a536caSSushil Singh
275f9a536caSSushil Singh    # client_id
276f9a536caSSushil Singh    HMCID-01
277f9a536caSSushil Singh
27811949a2cSSushil Singh
27911949a2cSSushil SinghGet Lock Records For Multiple Invalid And Valid Session
28011949a2cSSushil Singh    [Documentation]  Get record of lock from invalid and valid session.
28111949a2cSSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Invalid_And_Valid_Session
28211949a2cSSushil Singh    [Template]  Verify Lock Records For Multiple Invalid And Valid Session
28311949a2cSSushil Singh
28411949a2cSSushil Singh    # client_id          lock_type
28511949a2cSSushil Singh    HMCID-01,HMCID-02    ReadCase1
28611949a2cSSushil Singh
287bc331e22SVijay*** Keywords ***
288bc331e22SVijay
289d03f2ce1SSushil SinghCreate Redfish Session With ClientID
290d03f2ce1SSushil Singh    [Documentation]  Create redifish session with client id.
291d03f2ce1SSushil Singh    [Arguments]  ${client_id}
29285610eeeSVijay
29385610eeeSVijay    # Description of argument(s):
294d03f2ce1SSushil Singh    # client_id    This client id can contain string value
295d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
29685610eeeSVijay
297d03f2ce1SSushil Singh    ${session_info}=  Create Dictionary
298d03f2ce1SSushil Singh    ${session}=  Redfish Login  kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
29985610eeeSVijay
300d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  SessionIDs  ${session['Id']}
301d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  ClientID  ${session["Oem"]["OpenBMC"]["ClientID"]}
30285610eeeSVijay
303d03f2ce1SSushil Singh    [Return]  ${session_info}
30485610eeeSVijay
30585610eeeSVijay
306d03f2ce1SSushil SinghRW General Dictionary
307d03f2ce1SSushil Singh    [Documentation]  Create dictionay of lock request.
308d03f2ce1SSushil Singh    [Arguments]  ${read_case}  ${res_id}
309bc331e22SVijay
310bc331e22SVijay    # Description of argument(s):
311d03f2ce1SSushil Singh    # read_case    Read or Write lock type.
312d03f2ce1SSushil Singh    # res_id       Resource id.
313bc331e22SVijay
314d03f2ce1SSushil Singh    ${request_dict}=  Create Dictionary
315566daaf3SGeorge Keishing
316d03f2ce1SSushil Singh    FOR  ${key}  IN  @{read_case.keys()}
317d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  LockType  ${key}
318d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  SegmentFlags  ${read_case["${key}"]}
319d03f2ce1SSushil Singh    END
320bc331e22SVijay
321d03f2ce1SSushil Singh    Set To Dictionary  ${request_dict}  ResourceID  ${res_id}
322d03f2ce1SSushil Singh
323d03f2ce1SSushil Singh    [Return]  ${request_dict}
324bc331e22SVijay
325bc331e22SVijay
326d03f2ce1SSushil SinghReturn Description Of Response
327d03f2ce1SSushil Singh    [Documentation]  Return description of REST response.
328bc331e22SVijay    [Arguments]  ${resp_text}
329bc331e22SVijay
330bc331e22SVijay    # Description of argument(s):
331d03f2ce1SSushil Singh    # resp_text    REST response body.
332bc331e22SVijay
333d03f2ce1SSushil Singh    # resp_text after successful partition file upload looks like:
334d03f2ce1SSushil Singh    # {
335d03f2ce1SSushil Singh    #    "Description": "File Created"
336d03f2ce1SSushil Singh    # }
337bc331e22SVijay
338d03f2ce1SSushil Singh    ${message}=  Evaluate  json.loads('''${resp_text}''')  json
339d03f2ce1SSushil Singh
340d03f2ce1SSushil Singh    [Return]  ${message}
341bc331e22SVijay
342bc331e22SVijay
343a7d71f02SSushil SinghVerify Redfish Session Deleted
344a7d71f02SSushil Singh    [Documentation]  Verify the redfish session is deleted.
345a7d71f02SSushil Singh    [Arguments]  ${session_info}
346a7d71f02SSushil Singh
347a7d71f02SSushil Singh    # Description of argument(s):
348a7d71f02SSushil Singh    # session_info    Session information are stored in dictionary.
349a7d71f02SSushil Singh
350a7d71f02SSushil Singh    # ${session_info} = {
351a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
352a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
353a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
354a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
355a7d71f02SSushil Singh    # }
356a7d71f02SSushil Singh
357a7d71f02SSushil Singh    # SessionIDs   : Session IDs
358a7d71f02SSushil Singh    # ClientID     : Client ID
359a7d71f02SSushil Singh    # SessionToken : Session token
360a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
361a7d71f02SSushil Singh
362a7d71f02SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions
363a7d71f02SSushil Singh
364a7d71f02SSushil Singh    FOR  ${session}  IN  @{sessions['Members']}
365a7d71f02SSushil Singh      Should Not Be Equal As Strings  session  ['/redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}']
366a7d71f02SSushil Singh    END
367a7d71f02SSushil Singh
368a7d71f02SSushil Singh
369a7d71f02SSushil SinghVerify Redfish List Of Session Deleted
370a7d71f02SSushil Singh    [Documentation]  Verify all the list of redfish session is deleted.
371a7d71f02SSushil Singh    [Arguments]  ${session_info_list}
372a7d71f02SSushil Singh
373a7d71f02SSushil Singh    # Description of argument(s):
374a7d71f02SSushil Singh    # session_info_list    List contains individual session record are stored in dictionary.
375a7d71f02SSushil Singh
376a7d71f02SSushil Singh    # ${session_info_list} = [{
377a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
378a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
379a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
380a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
381a7d71f02SSushil Singh    # }]
382a7d71f02SSushil Singh
383a7d71f02SSushil Singh    # SessionIDs   : Session IDs
384a7d71f02SSushil Singh    # ClientID     : Client ID
385a7d71f02SSushil Singh    # SessionToken : Session token
386a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
387a7d71f02SSushil Singh
388a7d71f02SSushil Singh    FOR  ${session_record}  IN  @{session_info_list}
389a7d71f02SSushil Singh      Verify Redfish Session Deleted  ${session_record}
390a7d71f02SSushil Singh    END
391a7d71f02SSushil Singh
392a7d71f02SSushil Singh
393d03f2ce1SSushil SinghRedfish Post Acquire Lock
394d03f2ce1SSushil Singh    [Documentation]  Acquire and release lock.
395d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
396bc331e22SVijay
397bc331e22SVijay    # Description of argument(s):
398d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
399d03f2ce1SSushil Singh    # status_code    HTTP status code.
400bc331e22SVijay
401e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Lock  ${lock_type}
402e33c6e6aSSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
403d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
404df390b61SSushil Singh
405df390b61SSushil Singh    Run Keyword If  ${status_code} == ${HTTP_BAD_REQUEST}
406df390b61SSushil Singh    ...    Valid Value  ${BAD_REQUEST}  ['${resp.content}']
407df390b61SSushil Singh    ...  ELSE
408df390b61SSushil Singh    ...    Run Keyword And Return  Return Description Of Response  ${resp.content}
409bc331e22SVijay
410d03f2ce1SSushil Singh    [Return]  ${resp}
411bc331e22SVijay
412bc331e22SVijay
413977f8f58SSushil SinghRedfish Post Acquire List Lock
414977f8f58SSushil Singh    [Documentation]  Acquire and release lock.
415977f8f58SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
416977f8f58SSushil Singh
417977f8f58SSushil Singh    # Description of argument(s):
418977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
419977f8f58SSushil Singh    # status_code    HTTP status code.
420977f8f58SSushil Singh
421977f8f58SSushil Singh    ${lock_dict_param}=  Create Data To Acquire List Of Lock  ${lock_type}
422977f8f58SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
423977f8f58SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
424977f8f58SSushil Singh
425977f8f58SSushil Singh    [Return]  ${resp}
426977f8f58SSushil Singh
427977f8f58SSushil Singh
428d03f2ce1SSushil SinghRedfish Post Acquire Invalid Lock
429d03f2ce1SSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock.
430d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${message}  ${status_code}=${HTTP_OK}
431bc331e22SVijay
432bc331e22SVijay    # Description of argument(s):
433d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
434d03f2ce1SSushil Singh    # message        Return message from URI.
435d03f2ce1SSushil Singh    # status_code    HTTP status code.
436bc331e22SVijay
437e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Invalid Lock  ${lock_type}
438e33c6e6aSSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
439d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
4403b3a7ecaSSushil Singh    Run Keyword If  '${message}' != '${EMPTY}'
4413b3a7ecaSSushil Singh    ...  Valid Value  message  ['${resp.content}']
442d03f2ce1SSushil Singh
443d03f2ce1SSushil Singh    [Return]  ${resp}
444bc331e22SVijay
445bc331e22SVijay
446e33c6e6aSSushil SinghRedfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
447e33c6e6aSSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock with invalid data type of resource id.
448e33c6e6aSSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
449e33c6e6aSSushil Singh
450e33c6e6aSSushil Singh    # Description of argument(s):
451e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
452e33c6e6aSSushil Singh    # status_code    HTTP status code.
453e33c6e6aSSushil Singh
454e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID  ${lock_type}
455e33c6e6aSSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
456e33c6e6aSSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
457e33c6e6aSSushil Singh
458e33c6e6aSSushil Singh    [Return]  ${resp}
459e33c6e6aSSushil Singh
460e33c6e6aSSushil Singh
461d03f2ce1SSushil SinghForm Data To Acquire Lock
462d03f2ce1SSushil Singh    [Documentation]  Create a dictionay for lock request.
463d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
464d03f2ce1SSushil Singh
465d03f2ce1SSushil Singh    # Description of argument(s):
466d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
467d03f2ce1SSushil Singh
468d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
469d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
470d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
471d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
472d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
473e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
474d03f2ce1SSushil Singh
475e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
476e33c6e6aSSushil Singh
477e33c6e6aSSushil Singh
478977f8f58SSushil SinghCreate Data To Acquire List Of Lock
479977f8f58SSushil Singh    [Documentation]  Create a dictionay for list of lock request.
480977f8f58SSushil Singh    [Arguments]  ${lock_type_list}
481977f8f58SSushil Singh
482977f8f58SSushil Singh    # Description of argument(s):
483977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
484977f8f58SSushil Singh
485977f8f58SSushil Singh    ${temp_list}=  Create List
486977f8f58SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
487977f8f58SSushil Singh
488977f8f58SSushil Singh    FOR  ${lock_type}  IN  @{lock_type_list}
489977f8f58SSushil Singh      ${resp}=  RW General Dictionary
490977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
491977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["ResourceID"]}
492977f8f58SSushil Singh      Append To List  ${temp_list}  ${resp}
493977f8f58SSushil Singh    END
494977f8f58SSushil Singh
495977f8f58SSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
496977f8f58SSushil Singh
497977f8f58SSushil Singh    [Return]  ${lock_request_dict}
498977f8f58SSushil Singh
499977f8f58SSushil Singh
500e33c6e6aSSushil SinghForm Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
501e33c6e6aSSushil Singh    [Documentation]  Create a dictionay for in-valid lock request.
502e33c6e6aSSushil Singh    [Arguments]  ${lock_type}
503e33c6e6aSSushil Singh
504e33c6e6aSSushil Singh    # Description of argument(s):
505e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
506e33c6e6aSSushil Singh
507e33c6e6aSSushil Singh    ${lock_res_info}=  Get Lock Resource Information
508e33c6e6aSSushil Singh    ${resp}=  RW General Dictionary
509e33c6e6aSSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
510e33c6e6aSSushil Singh    ...    ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
511e33c6e6aSSushil Singh    ${temp_list}=  Create List  ${resp}
512e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
513e33c6e6aSSushil Singh
514e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
515d03f2ce1SSushil Singh
516d03f2ce1SSushil Singh
517d03f2ce1SSushil SinghForm Data To Acquire Invalid Lock
518d03f2ce1SSushil Singh    [Documentation]  Create a dictionay for in-valid lock request.
519d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
520d03f2ce1SSushil Singh
521d03f2ce1SSushil Singh    # Description of argument(s):
522d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
523d03f2ce1SSushil Singh
524d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
525d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
526d03f2ce1SSushil Singh    ...    ${lock_res_info["Invalid Case"]["${lock_type}"]}
527d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
528d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
529e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
530d03f2ce1SSushil Singh
531e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
532d03f2ce1SSushil Singh
533d03f2ce1SSushil Singh
534d03f2ce1SSushil SinghGet Locks List On Resource
535bc331e22SVijay    [Documentation]  Get locks list.
536d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${exp_status_code}=${HTTP_OK}
537bc331e22SVijay
538bc331e22SVijay    # Description of argument(s):
539d03f2ce1SSushil Singh    # session_info       Session information in dict.
540d03f2ce1SSushil Singh    # exp_status_code    Expected HTTP status code.
541bc331e22SVijay
542d03f2ce1SSushil Singh    ${data}=  Set Variable  {"SessionIDs": ["${session_info['SessionIDs']}"]}
543566daaf3SGeorge Keishing    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
544566daaf3SGeorge Keishing    ...  data=${data}
545bc331e22SVijay    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
546bc331e22SVijay
547bc331e22SVijay    [Return]  ${locks["Records"]}
548bc331e22SVijay
549bc331e22SVijay
550d03f2ce1SSushil SinghVerify Lock On Resource
551d03f2ce1SSushil Singh    [Documentation]  Verify lock on resource.
552d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${transaction_id}
553bc331e22SVijay
554bc331e22SVijay    # Description of argument(s):
555d03f2ce1SSushil Singh    # session_info      Session information in dict.
556d03f2ce1SSushil Singh    # transaction_id    Transaction id in list stored in dict.
557bc331e22SVijay
558d03f2ce1SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
559d03f2ce1SSushil Singh    Rprint Vars  sessions
560d03f2ce1SSushil Singh    ${lock_list}=  Get Locks List On Resource  ${session_info}
561d03f2ce1SSushil Singh    ${lock_length}=  Get Length  ${lock_list}
562d03f2ce1SSushil Singh    ${tran_id_length}=  Get Length  ${transaction_id}
563d03f2ce1SSushil Singh    Should Be Equal As Integers  ${tran_id_length}  ${lock_length}
564afdd2a1dSVijay
565d03f2ce1SSushil Singh    FOR  ${tran_id}  ${lock}  IN ZIP  ${transaction_id}  ${lock_list}
566d03f2ce1SSushil Singh      Valid Value  session_info['ClientID']  ['${lock['HMCID']}']
567d03f2ce1SSushil Singh      Valid Value  session_info['SessionIDs']  ['${lock['SessionID']}']
568d03f2ce1SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock['TransactionID']}
569bc331e22SVijay    END
570bc331e22SVijay
571bc331e22SVijay
572d03f2ce1SSushil SinghAcquire Lock On Resource
573d03f2ce1SSushil Singh    [Documentation]  Acquire lock on resource.
574d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${reboot_flag}=False
575bc331e22SVijay
576bc331e22SVijay    # Description of argument(s):
577d03f2ce1SSushil Singh    # client_id    This client id can contain string value
578d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
579d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
580d03f2ce1SSushil Singh    # reboot_flag  Flag is used to run reboot the BMC code.
581d03f2ce1SSushil Singh    #               (e.g. True or False).
582bc331e22SVijay
583d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
584d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
585d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
586d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
587d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
588566daaf3SGeorge Keishing
589e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
590bc331e22SVijay
591d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'True'
592d03f2ce1SSushil Singh    ...  Run Keywords  Redfish OBMC Reboot (off)  AND
593d03f2ce1SSushil Singh    ...  Redfish Login  AND
594e33c6e6aSSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
595d03f2ce1SSushil Singh    ...  Verify Lock On Resource  ${session_info}  ${trans_id_list}  AND
596d03f2ce1SSushil Singh    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
597bc331e22SVijay
598d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'False'
599d03f2ce1SSushil Singh    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
600bc331e22SVijay
601d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
602d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
603d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
604bc331e22SVijay
605bc331e22SVijay
606d03f2ce1SSushil SinghForm Data To Release Lock
607d03f2ce1SSushil Singh    [Documentation]  Create a dictonay to release lock.
608d03f2ce1SSushil Singh    [Arguments]  ${trans_id_list}
609355daac7SVijay
610355daac7SVijay    # Description of argument(s):
611d03f2ce1SSushil Singh    # trans_id_list
612355daac7SVijay
613d03f2ce1SSushil Singh    @{tran_ids}=  Create List
614355daac7SVijay
615d03f2ce1SSushil Singh    FOR  ${item}  IN  @{trans_id_list}
616d03f2ce1SSushil Singh      Append To List  ${tran_ids}  ${item['TransactionID']}
617d03f2ce1SSushil Singh    END
618d03f2ce1SSushil Singh
619d03f2ce1SSushil Singh    [Return]  ${tran_ids}
620d03f2ce1SSushil Singh
621d03f2ce1SSushil Singh
622d03f2ce1SSushil SinghRelease Locks On Resource
623d03f2ce1SSushil Singh    [Documentation]  Redfish request to release a lock.
624d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}  ${release_lock_type}=Transaction  ${status_code}=${HTTP_OK}
625d03f2ce1SSushil Singh
626d03f2ce1SSushil Singh    # Description of argument(s):
627d03f2ce1SSushil Singh    # session_info        Session information in dict.
628d03f2ce1SSushil Singh    # trans_id_list       Transaction id list.
629d03f2ce1SSushil Singh    # release_lock_type   Release lock by Transaction, Session.
630d03f2ce1SSushil Singh    # status_code         HTTP status code.
631d03f2ce1SSushil Singh
632d03f2ce1SSushil Singh    ${tran_ids}=  Form Data To Release Lock  ${trans_id_list}
633d03f2ce1SSushil Singh    ${data}=  Set Variable  {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
634d03f2ce1SSushil Singh    ${data}=  Evaluate  json.dumps(${data})  json
635d03f2ce1SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock  data=${data}
636d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
637d03f2ce1SSushil Singh
638d03f2ce1SSushil Singh
639df390b61SSushil SinghRelease locks And Delete Session
640df390b61SSushil Singh    [Documentation]  Release locks and delete redfish session.
641df390b61SSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}
642df390b61SSushil Singh
643df390b61SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}
644df390b61SSushil Singh
645df390b61SSushil Singh    ${trans_id_emptylist}=  Create List
646df390b61SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
647df390b61SSushil Singh
648df390b61SSushil Singh    Redfish Delete Session  ${session_info}
649df390b61SSushil Singh
650df390b61SSushil Singh
651d03f2ce1SSushil SinghAcquire Lock On Another Lock
652d03f2ce1SSushil Singh    [Documentation]  Acquire lock on another lock.
653d03f2ce1SSushil Singh    [Arguments]  ${client_id}
654d03f2ce1SSushil Singh
655d03f2ce1SSushil Singh    # Description of argument(s):
656d03f2ce1SSushil Singh    # client_id    This client id can contain string value
657d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
658d03f2ce1SSushil Singh
659d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
660d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
661d03f2ce1SSushil Singh
662d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
663d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
664d03f2ce1SSushil Singh
665d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
666d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
667d03f2ce1SSushil Singh
668d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
669d03f2ce1SSushil Singh
670df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
671d03f2ce1SSushil Singh
672d03f2ce1SSushil Singh
673977f8f58SSushil SinghVerify Fail To Acquire Read And Write In Single Request
674977f8f58SSushil Singh    [Documentation]  Verify fail to acquire read and write lock passed in single request.
675977f8f58SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
676977f8f58SSushil Singh
677977f8f58SSushil Singh    # Description of argument(s):
678977f8f58SSushil Singh    # client_id    This client id can contain string value
679977f8f58SSushil Singh    #              (e.g. 12345, "HMCID").
680977f8f58SSushil Singh    # lock_type    Read lock or Write lock.
681977f8f58SSushil Singh
682977f8f58SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
683977f8f58SSushil Singh
684977f8f58SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
685977f8f58SSushil Singh    ${trans_id}=  Redfish Post Acquire List Lock  ${lock_type_list}  status_code=${HTTP_BAD_REQUEST}
686977f8f58SSushil Singh    Redfish Delete Session  ${session_info}
687977f8f58SSushil Singh
688977f8f58SSushil Singh
689d03f2ce1SSushil SinghVerify Empty Lock Records For Invalid Session
690d03f2ce1SSushil Singh    [Documentation]  Verify no lock record found for invalid session.
691d03f2ce1SSushil Singh    [Arguments]  ${client_id}
692d03f2ce1SSushil Singh
693d03f2ce1SSushil Singh    # Description of argument(s):
694d03f2ce1SSushil Singh    # client_id    This client id can contain string value
695d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
696d03f2ce1SSushil Singh
697d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_id}
698d03f2ce1SSushil Singh
699d03f2ce1SSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
700d03f2ce1SSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
701d03f2ce1SSushil Singh
702d03f2ce1SSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
703d03f2ce1SSushil Singh    set to dictionary  ${session_info2}  SessionIDs  xxyXyyYZZz
704d03f2ce1SSushil Singh
705d03f2ce1SSushil Singh    ${lock_list2}=  Get Locks List On Resource  ${session_info2}
706f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list2}
707d03f2ce1SSushil Singh
708f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
709d03f2ce1SSushil Singh
710d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
711d03f2ce1SSushil Singh
712d03f2ce1SSushil Singh
713d03f2ce1SSushil SinghVerify Acquire Lock Fails On Another Lock
714d03f2ce1SSushil Singh    [Documentation]  Verify acquire lock on another lock fails.
715d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
716d03f2ce1SSushil Singh
717d03f2ce1SSushil Singh    # Description of argument(s):
718d03f2ce1SSushil Singh    # client_id    This client id can contain string value
719d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
720d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
721d03f2ce1SSushil Singh
722d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
723d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
724d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
725d03f2ce1SSushil Singh
726d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
727d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
728d03f2ce1SSushil Singh
729d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
730d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
731d03f2ce1SSushil Singh
732df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
733d03f2ce1SSushil Singh
734d03f2ce1SSushil Singh
735e33c6e6aSSushil SinghVerify Acquire Lock After Reboot
736e33c6e6aSSushil Singh    [Documentation]  Acquire read and write lock after the reboot and release lock.
737e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
738e33c6e6aSSushil Singh
739e33c6e6aSSushil Singh    # Description of argument(s):
740e33c6e6aSSushil Singh    # client_id    This client id can contain string value
741e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
742e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
743e33c6e6aSSushil Singh
744e33c6e6aSSushil Singh    ${trans_id_list}=  Create List
745f9a536caSSushil Singh    ${session_info}=  Create Session With ClientID  ${client_id}
746e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
747e33c6e6aSSushil Singh    Redfish OBMC Reboot (off)
748e33c6e6aSSushil Singh    Redfish Login
749e33c6e6aSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}
750e33c6e6aSSushil Singh
751e33c6e6aSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
752e33c6e6aSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
753e33c6e6aSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
754e33c6e6aSSushil Singh
755df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
756df390b61SSushil Singh
757df390b61SSushil Singh
758df390b61SSushil SinghVerify Acquire Multiple Lock Request At CEC Level
759df390b61SSushil Singh    [Documentation]  Acquire lock in loop.
760df390b61SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
761df390b61SSushil Singh
762df390b61SSushil Singh    # Description of argument(s):
763df390b61SSushil Singh    # client_id    This client id can contain string value
764df390b61SSushil Singh    #              (e.g. 12345, "HMCID").
765df390b61SSushil Singh    # lock_type    Read lock or Write lock.
766df390b61SSushil Singh
767df390b61SSushil Singh    ${trans_id_list}=  Create List
768df390b61SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
769df390b61SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
770df390b61SSushil Singh
771df390b61SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
772df390b61SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
773df390b61SSushil Singh
774df390b61SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
775df390b61SSushil Singh
776df390b61SSushil Singh    Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
777df390b61SSushil Singh
778df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
779e33c6e6aSSushil Singh
780e33c6e6aSSushil Singh
781d03f2ce1SSushil SinghVerify Acquire And Release Lock In Loop
782d03f2ce1SSushil Singh    [Documentation]  Acquire lock in loop.
783d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
784d03f2ce1SSushil Singh
785d03f2ce1SSushil Singh    # Description of argument(s):
786d03f2ce1SSushil Singh    # client_id    This client id can contain string value
787d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
788d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
789d03f2ce1SSushil Singh
790d03f2ce1SSushil Singh    FOR  ${count}  IN RANGE  1  11
791d03f2ce1SSushil Singh      ${trans_id_list}=  Create List
792d03f2ce1SSushil Singh      ${session_info}=  Create Redfish Session With ClientID  ${client_id}
793d03f2ce1SSushil Singh      ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
794d03f2ce1SSushil Singh      Append To List  ${trans_id_list}  ${trans_id}
795d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_list}
796d03f2ce1SSushil Singh      Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
797d03f2ce1SSushil Singh      ${trans_id_emptylist}=  Create List
798d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
799d03f2ce1SSushil Singh    END
800d03f2ce1SSushil Singh
801d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
802d03f2ce1SSushil Singh
803d03f2ce1SSushil Singh
804d03f2ce1SSushil SinghAcquire And Release Multiple Locks
805d03f2ce1SSushil Singh    [Documentation]  Acquire mutilple locks on resource.
806d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
807d03f2ce1SSushil Singh
808d03f2ce1SSushil Singh    # Description of argument(s):
809d03f2ce1SSushil Singh    # client_id          This client id can contain string value
810d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
811d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
812d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
813d03f2ce1SSushil Singh
814d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
815d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
816d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
817d03f2ce1SSushil Singh
818d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
819d03f2ce1SSushil Singh
820d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
821d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
822d03f2ce1SSushil Singh
823d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
824d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
825d03f2ce1SSushil Singh
826d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
827d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
828d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
829d03f2ce1SSushil Singh
830d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
831d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
832d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
833d03f2ce1SSushil Singh
834d03f2ce1SSushil Singh
835*59011d08SSushil SinghVerify Fail To Release Lock With Invalid TransactionID
836*59011d08SSushil Singh    [Documentation]  Verify fail to be release lock with invalid trasaction ID.
837*59011d08SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
838*59011d08SSushil Singh
839*59011d08SSushil Singh    # Description of argument(s):
840*59011d08SSushil Singh    # client_id          This client id can contain string value
841*59011d08SSushil Singh    #                    (e.g. 12345, "HMCID").
842*59011d08SSushil Singh    # lock_type          Read lock or Write lock.
843*59011d08SSushil Singh    # release_lock_type  The value can be Transaction or Session.
844*59011d08SSushil Singh
845*59011d08SSushil Singh    ${trans_id_list}=  Create List
846*59011d08SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
847*59011d08SSushil Singh
848*59011d08SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
849*59011d08SSushil Singh
850*59011d08SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
851*59011d08SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
852*59011d08SSushil Singh    ${value}=  Evaluate  ${value} + 10
853*59011d08SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
854*59011d08SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
855*59011d08SSushil Singh
856*59011d08SSushil Singh    Release Locks On Resource
857*59011d08SSushil Singh    ...  ${session_info}  ${trans_id_list}
858*59011d08SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
859*59011d08SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
860*59011d08SSushil Singh
861*59011d08SSushil Singh    ${trans_id_emptylist}=  Create List
862*59011d08SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
863*59011d08SSushil Singh    Redfish Delete Session  ${session_info}
864*59011d08SSushil Singh
865*59011d08SSushil Singh
8661b59053dSSushil SinghVerify Fail To Release Multiple Lock With Invalid TransactionID
8671b59053dSSushil Singh    [Documentation]  Verify release multiple locks with invalid transaction ID fails.
868d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
869d03f2ce1SSushil Singh
870d03f2ce1SSushil Singh    # Description of argument(s):
871d03f2ce1SSushil Singh    # client_id          This client id can contain string value
872d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
873d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
874d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
875d03f2ce1SSushil Singh
876d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
877d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
878d03f2ce1SSushil Singh
879d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
880d03f2ce1SSushil Singh
881d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
882d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
883d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
884d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
885d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
886d03f2ce1SSushil Singh
887d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
888d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
889d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
890d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
891d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
892d03f2ce1SSushil Singh
893d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
894d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
895d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
896d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
897d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
898d03f2ce1SSushil Singh
899d03f2ce1SSushil Singh    Release Locks On Resource
900d03f2ce1SSushil Singh    ...  ${session_info}  ${trans_id_list}
901d03f2ce1SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
902d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
903d03f2ce1SSushil Singh
904d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
905d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
906d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
907d03f2ce1SSushil Singh
908d03f2ce1SSushil Singh
909d03f2ce1SSushil SinghVerify Fail To Release Lock For Another Session
910d03f2ce1SSushil Singh    [Documentation]  Verify failed to release the lock form another session.
911d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
912d03f2ce1SSushil Singh
913d03f2ce1SSushil Singh    # Description of argument(s):
914d03f2ce1SSushil Singh    # client_id    This client id can contain string value
915d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
916d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
917d03f2ce1SSushil Singh
918d03f2ce1SSushil Singh    ${client_ids}=  Split String  ${client_id}  ,
919d03f2ce1SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
920d03f2ce1SSushil Singh    ${trans_id_list1}=  Create List
921d03f2ce1SSushil Singh    ${trans_id_list2}=  Create List
922d03f2ce1SSushil Singh
923d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_ids}[0]
924d03f2ce1SSushil Singh
925d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
926d03f2ce1SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
927d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
928d03f2ce1SSushil Singh
929d03f2ce1SSushil Singh    ${session_info2}=  Create Redfish Session With ClientID  ${client_ids}[1]
930d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
931d03f2ce1SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
932d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info2}  ${trans_id_list2}
933d03f2ce1SSushil Singh
934d03f2ce1SSushil Singh    Release Locks On Resource
935d03f2ce1SSushil Singh    ...  ${session_info1}  ${trans_id_list1}  Transaction  status_code=${HTTP_UNAUTHORIZED}
936d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
937d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Session
938d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Session
939d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
940d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info2}
941d03f2ce1SSushil Singh
942d03f2ce1SSushil Singh
943e33c6e6aSSushil SinghVerify Fail To Acquire Lock For Invalid Resource ID Data Type
944e33c6e6aSSushil Singh    [Documentation]  Verify fail to acquire the lock with invalid resource id data type.
945e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
946e33c6e6aSSushil Singh
947e33c6e6aSSushil Singh    # Description of argument(s):
948e33c6e6aSSushil Singh    # client_id    This client id can contain string value
949e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
950e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
951e33c6e6aSSushil Singh
952e33c6e6aSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
953e33c6e6aSSushil Singh    Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
954e33c6e6aSSushil Singh    ...  ${lock_type}  status_code=${HTTP_BAD_REQUEST}
955e33c6e6aSSushil Singh    Redfish Delete Session  ${session_info}
956e33c6e6aSSushil Singh
957e33c6e6aSSushil Singh
958d03f2ce1SSushil SinghVerify Fail To Acquire Lock For Invalid Lock Data
959e33c6e6aSSushil Singh    [Documentation]  Verify fail to acquired lock with invalid lock types, lock flags, segement flags.
960d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${message}
961d03f2ce1SSushil Singh
962d03f2ce1SSushil Singh    # Description of argument(s):
963d03f2ce1SSushil Singh    # client_id    This client id can contain string value
964d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
965d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
966d03f2ce1SSushil Singh    # message      Return message from URI.
967d03f2ce1SSushil Singh
968d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
969d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Invalid Lock  ${lock_type}  message=${message}  status_code=${HTTP_BAD_REQUEST}
970d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
971bace3005SSushil Singh
972bace3005SSushil Singh
973bace3005SSushil SinghVerify No Locks Records For Session With No Acquired Lock
974bace3005SSushil Singh    [Documentation]  Verify no records found for a session where no lock is acquired.
975bace3005SSushil Singh    [Arguments]  ${client_id}
976bace3005SSushil Singh
977bace3005SSushil Singh    # Description of argument(s):
978bace3005SSushil Singh    # client_id    This client id can contain string value
979bace3005SSushil Singh    #              (e.g. 12345, "HMCID").
980bace3005SSushil Singh
981bace3005SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
982bace3005SSushil Singh    ${trans_id_emptylist}=  Create List
983bace3005SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
984bace3005SSushil Singh    Redfish Delete Session  ${session_info}
985728ef9c9SSushil Singh
986728ef9c9SSushil Singh
987728ef9c9SSushil SinghCreate List Of Session ID
988728ef9c9SSushil Singh    [Documentation]  Create session id list from session dict info.
989728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}
990728ef9c9SSushil Singh
991728ef9c9SSushil Singh    # Description of argument(s):
992728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
993728ef9c9SSushil Singh
994728ef9c9SSushil Singh    @{session_id_list}=  Create List
995728ef9c9SSushil Singh
996728ef9c9SSushil Singh    FOR  ${session}  IN  @{session_dict_info}
997728ef9c9SSushil Singh      Append To List  ${session_id_list}  ${session["SessionIDs"]}
998728ef9c9SSushil Singh    END
999728ef9c9SSushil Singh
1000728ef9c9SSushil Singh    ${num_id}=  Get Length  ${session_id_list}
1001728ef9c9SSushil Singh    Should Not Be Equal As Integers  ${num_id}  ${0}
1002728ef9c9SSushil Singh
1003728ef9c9SSushil Singh    ${session_id_list}=  Evaluate  json.dumps(${session_id_list})  json
1004728ef9c9SSushil Singh
1005728ef9c9SSushil Singh    [Return]  ${session_id_list}
1006728ef9c9SSushil Singh
1007728ef9c9SSushil Singh
1008728ef9c9SSushil SinghGet Locks List On Resource With Session List
1009728ef9c9SSushil Singh    [Documentation]  Get locks list from session of list.
1010728ef9c9SSushil Singh    [Arguments]  ${session_id_list}  ${exp_status_code}=${HTTP_OK}
1011728ef9c9SSushil Singh
1012728ef9c9SSushil Singh    # Description of argument(s):
1013728ef9c9SSushil Singh    # session_id_list    Session ids list.
1014728ef9c9SSushil Singh    # exp_status_code    Expected HTTP status code.
1015728ef9c9SSushil Singh
1016728ef9c9SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
1017728ef9c9SSushil Singh    ...  data={"SessionIDs": ${session_id_list}}
1018728ef9c9SSushil Singh    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
1019728ef9c9SSushil Singh
1020728ef9c9SSushil Singh    [Return]  ${locks}
1021728ef9c9SSushil Singh
1022728ef9c9SSushil Singh
1023728ef9c9SSushil SinghVerify List Of Session Lock On Resource
1024728ef9c9SSushil Singh    [Documentation]  Verify list of lock record from list of sessions.
1025728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}  ${transaction_id_list}
1026728ef9c9SSushil Singh
1027728ef9c9SSushil Singh    # Description of argument(s):
1028728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
1029728ef9c9SSushil Singh    # transaction_id_list    Transaction id in list stored in dict.
1030728ef9c9SSushil Singh
1031728ef9c9SSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_info}
1032728ef9c9SSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1033728ef9c9SSushil Singh    ${lock_list}=  Set Variable  ${lock_list_resp['Records']}
1034728ef9c9SSushil Singh
1035728ef9c9SSushil Singh    FOR  ${session_id}  ${tran_id}  ${lock_record}  IN ZIP  ${session_dict_info}  ${transaction_id_list}  ${lock_list}
1036728ef9c9SSushil Singh      Valid Value  session_id['SessionIDs']  ['${lock_record['SessionID']}']
1037728ef9c9SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock_record['TransactionID']}
1038728ef9c9SSushil Singh    END
1039728ef9c9SSushil Singh
1040728ef9c9SSushil Singh
1041728ef9c9SSushil SinghVerify Lock Records Of Multiple Session
1042728ef9c9SSushil Singh    [Documentation]  Verify all records found for a multiple sessions.
1043728ef9c9SSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
1044728ef9c9SSushil Singh
1045728ef9c9SSushil Singh    # Description of argument(s):
1046728ef9c9SSushil Singh    # client_ids    This client id can contain string value
1047728ef9c9SSushil Singh    #               (e.g. 12345, "HMCID").
1048728ef9c9SSushil Singh    # lock_type     Read lock or Write lock.
1049728ef9c9SSushil Singh
1050728ef9c9SSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
1051728ef9c9SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
1052728ef9c9SSushil Singh    ${trans_id_list1}=  Create List
1053728ef9c9SSushil Singh    ${trans_id_list2}=  Create List
1054728ef9c9SSushil Singh
1055728ef9c9SSushil Singh    ${session_dict_list}=  Create List
1056728ef9c9SSushil Singh    ${lock_list}=  Create List
1057728ef9c9SSushil Singh
1058728ef9c9SSushil Singh    ${client_id1}=  Create List
1059728ef9c9SSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
1060728ef9c9SSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
1061728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
1062728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
1063728ef9c9SSushil Singh
1064728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1065728ef9c9SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
1066728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
1067728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
1068728ef9c9SSushil Singh
1069728ef9c9SSushil Singh
1070728ef9c9SSushil Singh    ${client_id2}=  Create List
1071728ef9c9SSushil Singh    Append To List  ${client_id2}  ${client_id_list}[1]
1072728ef9c9SSushil Singh    ${session_info2}=  Create Session With List Of ClientID  ${client_id2}
1073728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
1074728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id2}  ${session_info2}
1075728ef9c9SSushil Singh
1076728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1077728ef9c9SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
1078728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
1079728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_list2}
1080728ef9c9SSushil Singh
1081728ef9c9SSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
1082728ef9c9SSushil Singh
1083728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
1084728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1085728ef9c9SSushil Singh
1086728ef9c9SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
1087728ef9c9SSushil Singh
1088728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info2}[0]  SessionToken
1089728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1090728ef9c9SSushil Singh
1091728ef9c9SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Transaction
1092728ef9c9SSushil Singh
1093728ef9c9SSushil Singh    ${trans_id_emptylist}=  Create List
1094728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
1095728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_emptylist}
1096728ef9c9SSushil Singh
1097728ef9c9SSushil Singh    Redfish Delete List Of Session  ${session_dict_list}
1098f9a536caSSushil Singh
1099f9a536caSSushil Singh
1100f9a536caSSushil SinghVerify Lock Records For Multiple Invalid Session
1101f9a536caSSushil Singh    [Documentation]  Verify no lock record found for multiple invalid session.
1102f9a536caSSushil Singh    [Arguments]  ${client_id}
1103f9a536caSSushil Singh
1104f9a536caSSushil Singh    # Description of argument(s):
1105f9a536caSSushil Singh    # client_id    This client id can contain string value
1106f9a536caSSushil Singh    #              (e.g. 12345, "HMCID").
1107f9a536caSSushil Singh
1108f9a536caSSushil Singh    ${session_dict_list}=  Create List
1109f9a536caSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz  xXyXYyYZzz
1110f9a536caSSushil Singh
1111f9a536caSSushil Singh    ${session_info1}=  Create Session With ClientID  ${client_id}
1112f9a536caSSushil Singh
1113f9a536caSSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
1114f9a536caSSushil Singh    set to dictionary  ${session_info2}  SessionIDs  ${invalid_session_ids}[0]
1115f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}
1116f9a536caSSushil Singh
1117f9a536caSSushil Singh    ${session_info3}=  Copy Dictionary  ${session_info1}  deepcopy=True
1118f9a536caSSushil Singh    set to dictionary  ${session_info3}  SessionIDs  ${invalid_session_ids}[0]
1119f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info3}
1120f9a536caSSushil Singh
1121f9a536caSSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
1122f9a536caSSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
1123f9a536caSSushil Singh
1124f9a536caSSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_list}
1125f9a536caSSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1126f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list_resp['Records']}
1127f9a536caSSushil Singh
1128f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
1129f9a536caSSushil Singh
1130f9a536caSSushil Singh    Redfish Delete Session  ${session_info1}
113111949a2cSSushil Singh
113211949a2cSSushil Singh
113311949a2cSSushil SinghVerify Lock Records For Multiple Invalid And Valid Session
113411949a2cSSushil Singh    [Documentation]  Verify all records found for a valid and invalid sessions.
113511949a2cSSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
113611949a2cSSushil Singh
113711949a2cSSushil Singh    # Description of argument(s):
113811949a2cSSushil Singh    # client_ids    This client id can contain string value
113911949a2cSSushil Singh    #               (e.g. 12345, "HMCID").
114011949a2cSSushil Singh    # lock_type     Read lock or Write lock.
114111949a2cSSushil Singh
114211949a2cSSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
114311949a2cSSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
114411949a2cSSushil Singh    ${trans_id_list1}=  Create List
114511949a2cSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz
114611949a2cSSushil Singh
114711949a2cSSushil Singh    ${session_dict_list}=  Create List
114811949a2cSSushil Singh    ${lock_list}=  Create List
114911949a2cSSushil Singh
115011949a2cSSushil Singh    ${client_id1}=  Create List
115111949a2cSSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
115211949a2cSSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
115311949a2cSSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
115411949a2cSSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
115511949a2cSSushil Singh
115611949a2cSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
115711949a2cSSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
115811949a2cSSushil Singh    Append To List  ${lock_list}  ${trans_id}
115911949a2cSSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
116011949a2cSSushil Singh
116111949a2cSSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
116211949a2cSSushil Singh    set to dictionary  ${session_info2}[0]  SessionIDs  ${invalid_session_ids}[0]
116311949a2cSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
116411949a2cSSushil Singh
116511949a2cSSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
116611949a2cSSushil Singh
116711949a2cSSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
116811949a2cSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
116911949a2cSSushil Singh
117011949a2cSSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
117111949a2cSSushil Singh
117211949a2cSSushil Singh    ${trans_id_emptylist}=  Create List
117311949a2cSSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
117411949a2cSSushil Singh
117511949a2cSSushil Singh    Redfish Delete Session  ${session_info1}[0]
1176