xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_lock_management.robot (revision e3f2e3ba863823edf06d6405d3e8bdec09870e29)
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
19*e3f2e3baSSushil Singh${CONFLICT_RQUEST}       Conflict
20d03f2ce1SSushil Singh${BAD_REQUEST}           Bad Request
218d420bf6SSushil Singh&{default_trans_id}      TransactionID=${1}
22bc331e22SVijay
23bc331e22SVijay*** Test Cases ***
24bc331e22SVijay
25d03f2ce1SSushil SinghAcquire Read Write Lock
26bc331e22SVijay    [Documentation]  Acquire and release different read locks.
27d03f2ce1SSushil Singh    [Tags]  Acquire_Read_Write_Lock
28d03f2ce1SSushil Singh    [Template]  Acquire Lock On Resource
29bc331e22SVijay
30d03f2ce1SSushil Singh    # client_id    lock_type     reboot_flag
31d03f2ce1SSushil Singh    HMCID-01       ReadCase1     False
32d03f2ce1SSushil Singh    HMCID-01       ReadCase2     False
33d03f2ce1SSushil Singh    HMCID-01       ReadCase3     False
34d03f2ce1SSushil Singh    HMCID-01       WriteCase1    False
35d03f2ce1SSushil Singh    HMCID-01       WriteCase2    False
36d03f2ce1SSushil Singh    HMCID-01       WriteCase3    False
37bc331e22SVijay
38bc331e22SVijay
39d8bf1424SSushil SinghVerify Lock Is Not Persistent On BMC Reboot
40d8bf1424SSushil Singh    [Documentation]  Acquire lock and after reboot the locks are removed as no persistency
41d8bf1424SSushil Singh    ...  maintained.
42d8bf1424SSushil Singh    [Tags]  Verify_Lock_Is_Not_Persistent_On_BMC_Reboot
43d03f2ce1SSushil Singh    [Template]  Acquire Lock On Resource
44bc331e22SVijay
45d03f2ce1SSushil Singh    # client_id    lock_type     reboot_flag
46d03f2ce1SSushil Singh    HMCID-01       ReadCase1     True
47d03f2ce1SSushil Singh    HMCID-01       ReadCase2     True
48d03f2ce1SSushil Singh    HMCID-01       ReadCase3     True
49d03f2ce1SSushil Singh    HMCID-01       WriteCase1    True
50d03f2ce1SSushil Singh    HMCID-01       WriteCase2    True
51d03f2ce1SSushil Singh    HMCID-01       WriteCase3    True
52bc331e22SVijay
53bc331e22SVijay
548d420bf6SSushil SinghCheck After Reboot Transaction ID Set To Default
558d420bf6SSushil Singh    [Documentation]  After reboot, the transaction id starts with default i.e. 1,
567fd1ac06SGeorge Keishing    ...  if any lock is acquired.
578d420bf6SSushil Singh    [Tags]  Check_After_Reboot_Transaction_ID_Set_To_Default
588d420bf6SSushil Singh    [Template]  Verify Acquire And Release Lock In Loop
598d420bf6SSushil Singh
608d420bf6SSushil Singh    # client_id    lock_type     reboot_flag
618d420bf6SSushil Singh    HMCID-01       ReadCase1     True
628d420bf6SSushil Singh    HMCID-01       WriteCase1    True
638d420bf6SSushil Singh
648d420bf6SSushil Singh
65d03f2ce1SSushil SinghAcquire Read Lock On Read Lock
66d03f2ce1SSushil Singh    [Documentation]  Acquire read lock on another read lock.
67d03f2ce1SSushil Singh    [Tags]  Acquire_Read_Lock_On_Read_Lock
68d03f2ce1SSushil Singh    [Template]  Acquire Lock On Another Lock
69bc331e22SVijay
70d03f2ce1SSushil Singh    # client_id
71d03f2ce1SSushil Singh    HMCID-01
72bc331e22SVijay
73bc331e22SVijay
74d03f2ce1SSushil SinghFail To Acquire Lock On Another Lock
75d03f2ce1SSushil Singh    [Documentation]  Fail to acquire another lock.
76d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_On_Another_Lock
77d03f2ce1SSushil Singh    [Template]  Verify Acquire Lock Fails On Another Lock
7885610eeeSVijay
79d03f2ce1SSushil Singh    # client_id    lock_type
805d05994bSSushil Singh    HMCID-01       ReadCase7,WriteCase6
815d05994bSSushil Singh    HMCID-01       WriteCase6,WriteCase6
825d05994bSSushil Singh    HMCID-01       WriteCase6,ReadCase7
83566daaf3SGeorge Keishing
84566daaf3SGeorge Keishing
85e33c6e6aSSushil SinghAcquire Lock After Reboot
86e33c6e6aSSushil Singh    [Documentation]  Acquire and release read and write locks after reboot.
87e33c6e6aSSushil Singh    [Tags]  Acquire_Lock_After_Reboot
88e33c6e6aSSushil Singh    [Template]  Verify Acquire Lock After Reboot
89e33c6e6aSSushil Singh
90e33c6e6aSSushil Singh    # client_id    lock_type
91e33c6e6aSSushil Singh    HMCID-01       ReadCase1
92e33c6e6aSSushil Singh    HMCID-01       ReadCase2
93e33c6e6aSSushil Singh    HMCID-01       ReadCase3
94e33c6e6aSSushil Singh    HMCID-01       WriteCase1
95e33c6e6aSSushil Singh    HMCID-01       WriteCase2
96e33c6e6aSSushil Singh    HMCID-01       WriteCase3
97e33c6e6aSSushil Singh
98e33c6e6aSSushil Singh
99d03f2ce1SSushil SinghAcquire And Release Lock In Loop
100d03f2ce1SSushil Singh    [Documentation]  Acquire and release read, write locks in loop.
101d03f2ce1SSushil Singh    [Tags]  Acquire_And_Release_Lock_In_Loop
102d03f2ce1SSushil Singh    [Template]  Verify Acquire And Release Lock In Loop
103566daaf3SGeorge Keishing
104d03f2ce1SSushil Singh    # client_id    lock_type
105d03f2ce1SSushil Singh    HMCID-01       ReadCase1
106d03f2ce1SSushil Singh    HMCID-01       ReadCase2
107d03f2ce1SSushil Singh    HMCID-01       ReadCase3
108d03f2ce1SSushil Singh    HMCID-01       WriteCase1
109d03f2ce1SSushil Singh    HMCID-01       WriteCase2
110d03f2ce1SSushil Singh    HMCID-01       WriteCase3
11185610eeeSVijay
11285610eeeSVijay
113977f8f58SSushil SinghFail To Acquire Read And Write In Single Request
114977f8f58SSushil Singh    [Documentation]  Fail to acquire read and write lock in single request.
115977f8f58SSushil Singh    [Tags]  Fail_To_Acquire_Read_And_Write_In_Single_Request
116977f8f58SSushil Singh    [Template]  Verify Fail To Acquire Read And Write In Single Request
117977f8f58SSushil Singh
118*e3f2e3baSSushil Singh    # client_id    lock_type               status_code
119*e3f2e3baSSushil Singh    HMCID-01       ReadCase1,WriteCase1    ${HTTP_CONFLICT}
120*e3f2e3baSSushil Singh    HMCID-01       WriteCase1,ReadCase1    ${HTTP_CONFLICT}
121*e3f2e3baSSushil Singh    HMCID-01       WriteCase1,WriteCase1   ${HTTP_CONFLICT}
122*e3f2e3baSSushil Singh
123*e3f2e3baSSushil Singh
124*e3f2e3baSSushil SinghAcquire Read In Single Request
125*e3f2e3baSSushil Singh    [Documentation]  Acquire read in single request.
126*e3f2e3baSSushil Singh    [Tags]  Acquire_Read_In_Single_Request
127*e3f2e3baSSushil Singh    [Template]  Verify Acquire Read In Single Request
128*e3f2e3baSSushil Singh
129977f8f58SSushil Singh    # client_id    lock_type
130*e3f2e3baSSushil Singh    HMCID-01       ReadCase1,ReadCase1
131977f8f58SSushil Singh
132977f8f58SSushil Singh
133df390b61SSushil SinghAcquire Multiple Lock Request At CEC Level
134df390b61SSushil Singh    [Documentation]  Acquire write lock on read lock under CEC level.
135df390b61SSushil Singh    [Tags]  Acquire_Multiple_Lock_Request_At_CEC_Level
136df390b61SSushil Singh    [Template]  Verify Acquire Multiple Lock Request At CEC Level
137df390b61SSushil Singh
138df390b61SSushil Singh    # client_id    lock_type
139df390b61SSushil Singh    HMCID-01       ReadCase4,WriteCase4
140df390b61SSushil Singh    HMCID-01       WriteCase5,ReadCase5
141df390b61SSushil Singh    HMCID-01       ReadCase6,WriteCase6
142df390b61SSushil Singh    HMCID-01       WriteCase7,ReadCase7
143df390b61SSushil Singh
144df390b61SSushil Singh
145d03f2ce1SSushil SinghVerify Release Of Valid Locks
146d03f2ce1SSushil Singh    [Documentation]  Release all valid locks.
147d03f2ce1SSushil Singh    [Tags]  Verify_Release_Of_Valid_Locks
148d03f2ce1SSushil Singh    [Template]  Acquire And Release Multiple Locks
149afdd2a1dSVijay
150d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
151d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
152d03f2ce1SSushil Singh    HMCID-02       ReadCase1,ReadCase1,ReadCase1    Session
153afdd2a1dSVijay
154afdd2a1dSVijay
15594116c61Ssusilsi7Release Lock When Session Deleted
15694116c61Ssusilsi7    [Documentation]  Release lock when session gets deleted.
15794116c61Ssusilsi7    [Tags]  Release_Lock_When_Session_Deleted
15894116c61Ssusilsi7    [Template]  Verify Release Lock When Session Deleted
15994116c61Ssusilsi7
16094116c61Ssusilsi7    # client_id    lock_type
16194116c61Ssusilsi7    HMCID-01       ReadCase1
16294116c61Ssusilsi7    HMCID-01       WriteCase1
16394116c61Ssusilsi7
16494116c61Ssusilsi7
16559011d08SSushil SinghFail To Release Lock With Invalid TransactionID
16659011d08SSushil Singh    [Documentation]  Fail to release lock with invalid transaction id.
16759011d08SSushil Singh    [Tags]  Fail_To_Release_Lock_With_Invalid_TransactionID
16859011d08SSushil Singh    [Template]  Verify Fail To Release Lock With Invalid TransactionID
16959011d08SSushil Singh
17059011d08SSushil Singh    # client_id    lock_type     release_lock_type
17159011d08SSushil Singh    HMCID-01       ReadCase1     Transaction
17243b0c063Ssusilsi7    HMCID-01       WriteCase1    Transaction
17359011d08SSushil Singh
17459011d08SSushil Singh
1751b59053dSSushil SinghFail To Release Multiple Lock With Invalid TransactionID
176d03f2ce1SSushil Singh    [Documentation]  Release in-valid lock result in fail.
1771b59053dSSushil Singh    [Tags]  Fail_To_Release_Multiple_Lock_With_Invalid_TransactionID
1781b59053dSSushil Singh    [Template]  Verify Fail To Release Multiple Lock With Invalid TransactionID
179afdd2a1dSVijay
180d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
181d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
182d03f2ce1SSushil Singh    12345          ReadCase2,ReadCase2,ReadCase2    Transaction
183d03f2ce1SSushil Singh    HMCID          ReadCase3,ReadCase3,ReadCase3    Transaction
184afdd2a1dSVijay
185afdd2a1dSVijay
1868bee358fSSushil SinghFail To Release Multiple Lock With Valid And Invalid TransactionID
1879614383dSGeorge Keishing    [Documentation]  Release multiple lock with valid and invalid transaction.
1888bee358fSSushil Singh    [Tags]  Fail_To_Release_Multiple_Lock_With_Valid_And_Invalid_TransactionID
1898bee358fSSushil Singh    [Template]  Verify Fail To Release Multiple Lock With Valid And Invalid TransactionID
1908bee358fSSushil Singh
1918bee358fSSushil Singh    # client_id    lock_type              release_lock_type
1928bee358fSSushil Singh    HMCID-01       ReadCase1,ReadCase1    Transaction
1938bee358fSSushil Singh
1948bee358fSSushil Singh
1951d7b996cSsusilsi7Fail To Release Lock With String As TransactionID Data Type
1961d7b996cSsusilsi7    [Documentation]  Fail to release lock with string as transaction id data type.
1971d7b996cSsusilsi7    [Tags]  Fail_To_Release_Lock_With_String_As_TransactionID_Data_Type
1981d7b996cSsusilsi7    [Template]  Verify Fail To Release Lock With TransactionID As String Type
1991d7b996cSsusilsi7
2001d7b996cSsusilsi7    # client_id    lock_type     release_lock_type
2011d7b996cSsusilsi7    HMCID-01       ReadCase1     Transaction
2021d7b996cSsusilsi7    HMCID-01       WriteCase1    Transaction
2031d7b996cSsusilsi7
2041d7b996cSsusilsi7
205d03f2ce1SSushil SinghFail To Release Lock For Another Session
206d03f2ce1SSushil Singh    [Documentation]  Failed to release locks from another session.
207d03f2ce1SSushil Singh    [Tags]  Fail_To_Release_Lock_For_Another_Session
208d03f2ce1SSushil Singh    [Template]  Verify Fail To Release Lock For Another Session
209afdd2a1dSVijay
210d03f2ce1SSushil Singh    # client_id          lock_type
211d03f2ce1SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
212afdd2a1dSVijay
213afdd2a1dSVijay
214e33c6e6aSSushil SinghTest Invalid Resource ID Data Type Locking
215e33c6e6aSSushil Singh    [Documentation]  Failed to acquire lock for invalid resource id data type.
216e33c6e6aSSushil Singh    [Tags]  Test_Invalid_Resource_ID_Data_Type_Locking
217e33c6e6aSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Resource ID Data Type
218e33c6e6aSSushil Singh
219e33c6e6aSSushil Singh    # client_id    lock_type
220e33c6e6aSSushil Singh    HMCID-01       ReadCase1
221e33c6e6aSSushil Singh    HMCID-01       ReadCase2
222e33c6e6aSSushil Singh    HMCID-01       ReadCase3
223e33c6e6aSSushil Singh    HMCID-01       WriteCase1
224e33c6e6aSSushil Singh    HMCID-01       WriteCase2
225e33c6e6aSSushil Singh    HMCID-01       WriteCase3
226e33c6e6aSSushil Singh
227e33c6e6aSSushil Singh
228d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Type
229d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read, write lock for invalid lock data passed.
230d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Type
231d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
232afdd2a1dSVijay
233d03f2ce1SSushil Singh    # client_id    lock_type      message
234d03f2ce1SSushil Singh    HMCID-01       ReadCase1      ${BAD_REQUEST}
235d03f2ce1SSushil Singh    HMCID-01       ReadCase2      ${BAD_REQUEST}
236d03f2ce1SSushil Singh    HMCID-01       ReadCase3      ${BAD_REQUEST}
237d03f2ce1SSushil Singh    HMCID-01       ReadCase4      ${BAD_REQUEST}
238d03f2ce1SSushil Singh    HMCID-01       ReadCase5      ${BAD_REQUEST}
239d03f2ce1SSushil Singh    HMCID-01       WriteCase1     ${BAD_REQUEST}
240d03f2ce1SSushil Singh    HMCID-01       WriteCase2     ${BAD_REQUEST}
241d03f2ce1SSushil Singh    HMCID-01       WriteCase3     ${BAD_REQUEST}
242d03f2ce1SSushil Singh    HMCID-01       WriteCase4     ${BAD_REQUEST}
243d03f2ce1SSushil Singh    HMCID-01       WriteCase5     ${BAD_REQUEST}
244afdd2a1dSVijay
245afdd2a1dSVijay
246d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Flag
247d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid lock flag passed.
248d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
249d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
250afdd2a1dSVijay
251d03f2ce1SSushil Singh    # client_id    lock_type       message
252d03f2ce1SSushil Singh    HMCID-01       ReadCase6       ${BAD_REQUEST}
253d03f2ce1SSushil Singh    HMCID-01       ReadCase7       ${BAD_REQUEST}
254d03f2ce1SSushil Singh    HMCID-01       ReadCase8       ${BAD_REQUEST}
255d03f2ce1SSushil Singh    HMCID-01       ReadCase9       ${BAD_REQUEST}
256d03f2ce1SSushil Singh    HMCID-01       ReadCase10      ${BAD_REQUEST}
257d03f2ce1SSushil Singh    HMCID-01       ReadCase11      ${BAD_REQUEST}
258d03f2ce1SSushil Singh    HMCID-01       WriteCase6      ${BAD_REQUEST}
259d03f2ce1SSushil Singh    HMCID-01       WriteCase7      ${BAD_REQUEST}
260d03f2ce1SSushil Singh    HMCID-01       WriteCase8      ${BAD_REQUEST}
261d03f2ce1SSushil Singh    HMCID-01       WriteCase9      ${BAD_REQUEST}
262d03f2ce1SSushil Singh    HMCID-01       WriteCase10     ${BAD_REQUEST}
263d03f2ce1SSushil Singh    HMCID-01       WriteCase11     ${BAD_REQUEST}
264afdd2a1dSVijay
265afdd2a1dSVijay
266d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Segment Flag
267d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
268d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Flag
269d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
270d03f2ce1SSushil Singh
271d03f2ce1SSushil Singh    # client_id    lock_type       message
272d03f2ce1SSushil Singh    HMCID-01       ReadCase12      ${BAD_REQUEST}
273d03f2ce1SSushil Singh    HMCID-01       ReadCase13      ${BAD_REQUEST}
274d03f2ce1SSushil Singh    HMCID-01       ReadCase14      ${BAD_REQUEST}
275d03f2ce1SSushil Singh    HMCID-01       WriteCase12     ${BAD_REQUEST}
276d03f2ce1SSushil Singh    HMCID-01       WriteCase13     ${BAD_REQUEST}
277d03f2ce1SSushil Singh    HMCID-01       WriteCase14     ${BAD_REQUEST}
278afdd2a1dSVijay
279bace3005SSushil Singh
2803b3a7ecaSSushil SinghFail To Acquire Lock For Invalid Segment Data Type Flag
2813b3a7ecaSSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
2823b3a7ecaSSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Data_Type_Flag
2833b3a7ecaSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
2843b3a7ecaSSushil Singh
2853b3a7ecaSSushil Singh    # client_id    lock_type       message
2863b3a7ecaSSushil Singh    HMCID-01       ReadCase15      ${EMPTY}
2873b3a7ecaSSushil Singh    HMCID-01       ReadCase16      ${EMPTY}
2883b3a7ecaSSushil Singh    HMCID-01       ReadCase17      ${EMPTY}
2893b3a7ecaSSushil Singh    HMCID-01       ReadCase18      ${EMPTY}
2903b3a7ecaSSushil Singh    HMCID-01       WriteCase15     ${EMPTY}
2913b3a7ecaSSushil Singh    HMCID-01       WriteCase16     ${EMPTY}
2923b3a7ecaSSushil Singh    HMCID-01       WriteCase17     ${EMPTY}
2933b3a7ecaSSushil Singh    HMCID-01       WriteCase18     ${EMPTY}
2943b3a7ecaSSushil Singh
2953b3a7ecaSSushil Singh
296bace3005SSushil SinghGet Empty Lock Records For Session Where No Locks Acquired
297bace3005SSushil Singh    [Documentation]  If session does not acquire locks then get lock should return
298bace3005SSushil Singh    ...              empty lock records.
299bace3005SSushil Singh    [Tags]  Get_Empty_Lock_Records_For_Session_Where_No_Locks_Acquired
300bace3005SSushil Singh    [Template]  Verify No Locks Records For Session With No Acquired Lock
301bace3005SSushil Singh
302bace3005SSushil Singh    # client_id
303bace3005SSushil Singh    HMCID-01
304bace3005SSushil Singh
305728ef9c9SSushil Singh
306f9a536caSSushil SinghGet Lock Records Empty For Invalid Session
307f9a536caSSushil Singh    [Documentation]  Record of lock list is empty for invalid session.
308f9a536caSSushil Singh    [Tags]  Get_Lock_Records_Empty_For_Invalid_Session
309f9a536caSSushil Singh    [Template]  Verify Empty Lock Records For Invalid Session
310f9a536caSSushil Singh
311f9a536caSSushil Singh    # client_id
312f9a536caSSushil Singh    HMCID-01
313f9a536caSSushil Singh
314f9a536caSSushil Singh
315728ef9c9SSushil SinghGet Lock Records For Multiple Session
316728ef9c9SSushil Singh    [Documentation]  Get lock records of multiple session.
317728ef9c9SSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Session
318728ef9c9SSushil Singh    [Template]  Verify Lock Records Of Multiple Session
319728ef9c9SSushil Singh
320728ef9c9SSushil Singh    # client_ids         lock_type
321728ef9c9SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
322728ef9c9SSushil Singh
323728ef9c9SSushil Singh
324f9a536caSSushil SinghGet Lock Records For Multiple Invalid Session
325f9a536caSSushil Singh    [Documentation]  Record of lock list is empty for list of invalid session.
326f9a536caSSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Invalid_Session
327f9a536caSSushil Singh    [Template]  Verify Lock Records For Multiple Invalid Session
328f9a536caSSushil Singh
329f9a536caSSushil Singh    # client_id
330f9a536caSSushil Singh    HMCID-01
331f9a536caSSushil Singh
33211949a2cSSushil Singh
33311949a2cSSushil SinghGet Lock Records For Multiple Invalid And Valid Session
33411949a2cSSushil Singh    [Documentation]  Get record of lock from invalid and valid session.
33511949a2cSSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Invalid_And_Valid_Session
33611949a2cSSushil Singh    [Template]  Verify Lock Records For Multiple Invalid And Valid Session
33711949a2cSSushil Singh
33811949a2cSSushil Singh    # client_id          lock_type
33911949a2cSSushil Singh    HMCID-01,HMCID-02    ReadCase1
34011949a2cSSushil Singh
341bc331e22SVijay*** Keywords ***
342bc331e22SVijay
343d03f2ce1SSushil SinghCreate Redfish Session With ClientID
344d03f2ce1SSushil Singh    [Documentation]  Create redifish session with client id.
345d03f2ce1SSushil Singh    [Arguments]  ${client_id}
34685610eeeSVijay
34785610eeeSVijay    # Description of argument(s):
348d03f2ce1SSushil Singh    # client_id    This client id can contain string value
349d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
35085610eeeSVijay
351d03f2ce1SSushil Singh    ${session_info}=  Create Dictionary
352d03f2ce1SSushil Singh    ${session}=  Redfish Login  kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
35385610eeeSVijay
354d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  SessionIDs  ${session['Id']}
355d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  ClientID  ${session["Oem"]["OpenBMC"]["ClientID"]}
35685610eeeSVijay
357d03f2ce1SSushil Singh    [Return]  ${session_info}
35885610eeeSVijay
35985610eeeSVijay
360d03f2ce1SSushil SinghRW General Dictionary
36116b3c7bfSGeorge Keishing    [Documentation]  Create dictionary of lock request.
362d03f2ce1SSushil Singh    [Arguments]  ${read_case}  ${res_id}
363bc331e22SVijay
364bc331e22SVijay    # Description of argument(s):
365d03f2ce1SSushil Singh    # read_case    Read or Write lock type.
366d03f2ce1SSushil Singh    # res_id       Resource id.
367bc331e22SVijay
368d03f2ce1SSushil Singh    ${request_dict}=  Create Dictionary
369566daaf3SGeorge Keishing
370d03f2ce1SSushil Singh    FOR  ${key}  IN  @{read_case.keys()}
371d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  LockType  ${key}
372d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  SegmentFlags  ${read_case["${key}"]}
373d03f2ce1SSushil Singh    END
374bc331e22SVijay
375d03f2ce1SSushil Singh    Set To Dictionary  ${request_dict}  ResourceID  ${res_id}
376d03f2ce1SSushil Singh
377d03f2ce1SSushil Singh    [Return]  ${request_dict}
378bc331e22SVijay
379bc331e22SVijay
380d03f2ce1SSushil SinghReturn Description Of Response
381d03f2ce1SSushil Singh    [Documentation]  Return description of REST response.
382bc331e22SVijay    [Arguments]  ${resp_text}
383bc331e22SVijay
384bc331e22SVijay    # Description of argument(s):
385d03f2ce1SSushil Singh    # resp_text    REST response body.
386bc331e22SVijay
387d03f2ce1SSushil Singh    # resp_text after successful partition file upload looks like:
388d03f2ce1SSushil Singh    # {
389d03f2ce1SSushil Singh    #    "Description": "File Created"
390d03f2ce1SSushil Singh    # }
391bc331e22SVijay
392d03f2ce1SSushil Singh    ${message}=  Evaluate  json.loads('''${resp_text}''')  json
393d03f2ce1SSushil Singh
394d03f2ce1SSushil Singh    [Return]  ${message}
395bc331e22SVijay
396bc331e22SVijay
397a7d71f02SSushil SinghVerify Redfish Session Deleted
398a7d71f02SSushil Singh    [Documentation]  Verify the redfish session is deleted.
399a7d71f02SSushil Singh    [Arguments]  ${session_info}
400a7d71f02SSushil Singh
401a7d71f02SSushil Singh    # Description of argument(s):
402a7d71f02SSushil Singh    # session_info    Session information are stored in dictionary.
403a7d71f02SSushil Singh
404a7d71f02SSushil Singh    # ${session_info} = {
405a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
406a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
407a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
408a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
409a7d71f02SSushil Singh    # }
410a7d71f02SSushil Singh
411a7d71f02SSushil Singh    # SessionIDs   : Session IDs
412a7d71f02SSushil Singh    # ClientID     : Client ID
413a7d71f02SSushil Singh    # SessionToken : Session token
414a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
415a7d71f02SSushil Singh
416a7d71f02SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions
417a7d71f02SSushil Singh
418a7d71f02SSushil Singh    FOR  ${session}  IN  @{sessions['Members']}
4198a3efe7cSSushil Singh      Should Not Be Equal As Strings
4208a3efe7cSSushil Singh      ...  session  ['/redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}']
421a7d71f02SSushil Singh    END
422a7d71f02SSushil Singh
423a7d71f02SSushil Singh
424a7d71f02SSushil SinghVerify Redfish List Of Session Deleted
425a7d71f02SSushil Singh    [Documentation]  Verify all the list of redfish session is deleted.
426a7d71f02SSushil Singh    [Arguments]  ${session_info_list}
427a7d71f02SSushil Singh
428a7d71f02SSushil Singh    # Description of argument(s):
429a7d71f02SSushil Singh    # session_info_list    List contains individual session record are stored in dictionary.
430a7d71f02SSushil Singh
431a7d71f02SSushil Singh    # ${session_info_list} = [{
432a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
433a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
434a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
435a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
436a7d71f02SSushil Singh    # }]
437a7d71f02SSushil Singh
438a7d71f02SSushil Singh    # SessionIDs   : Session IDs
439a7d71f02SSushil Singh    # ClientID     : Client ID
440a7d71f02SSushil Singh    # SessionToken : Session token
441a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
442a7d71f02SSushil Singh
443a7d71f02SSushil Singh    FOR  ${session_record}  IN  @{session_info_list}
444a7d71f02SSushil Singh      Verify Redfish Session Deleted  ${session_record}
445a7d71f02SSushil Singh    END
446a7d71f02SSushil Singh
447a7d71f02SSushil Singh
448d03f2ce1SSushil SinghRedfish Post Acquire Lock
449d03f2ce1SSushil Singh    [Documentation]  Acquire and release lock.
450d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
451bc331e22SVijay
452bc331e22SVijay    # Description of argument(s):
453d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
454d03f2ce1SSushil Singh    # status_code    HTTP status code.
455bc331e22SVijay
456e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Lock  ${lock_type}
4578a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
4588a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
459d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
460df390b61SSushil Singh
461df390b61SSushil Singh    Run Keyword If  ${status_code} == ${HTTP_BAD_REQUEST}
462df390b61SSushil Singh    ...    Valid Value  ${BAD_REQUEST}  ['${resp.content}']
463df390b61SSushil Singh    ...  ELSE
464df390b61SSushil Singh    ...    Run Keyword And Return  Return Description Of Response  ${resp.content}
465bc331e22SVijay
466d03f2ce1SSushil Singh    [Return]  ${resp}
467bc331e22SVijay
468bc331e22SVijay
469977f8f58SSushil SinghRedfish Post Acquire List Lock
470977f8f58SSushil Singh    [Documentation]  Acquire and release lock.
471977f8f58SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
472977f8f58SSushil Singh
473977f8f58SSushil Singh    # Description of argument(s):
474977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
475977f8f58SSushil Singh    # status_code    HTTP status code.
476977f8f58SSushil Singh
477977f8f58SSushil Singh    ${lock_dict_param}=  Create Data To Acquire List Of Lock  ${lock_type}
4788a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
4798a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
480977f8f58SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
481977f8f58SSushil Singh
482*e3f2e3baSSushil Singh    Run Keyword If  ${status_code} == ${HTTP_CONFLICT}
483*e3f2e3baSSushil Singh    ...    Should Be Equal As Strings  ${CONFLICT_RQUEST}  ${resp.content}
484*e3f2e3baSSushil Singh    ...  ELSE
485*e3f2e3baSSushil Singh    ...    Run Keyword And Return  Return Description Of Response  ${resp.content}
486*e3f2e3baSSushil Singh
487977f8f58SSushil Singh    [Return]  ${resp}
488977f8f58SSushil Singh
489977f8f58SSushil Singh
490d03f2ce1SSushil SinghRedfish Post Acquire Invalid Lock
491d03f2ce1SSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock.
492d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${message}  ${status_code}=${HTTP_OK}
493bc331e22SVijay
494bc331e22SVijay    # Description of argument(s):
495d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
496d03f2ce1SSushil Singh    # message        Return message from URI.
497d03f2ce1SSushil Singh    # status_code    HTTP status code.
498bc331e22SVijay
499e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Invalid Lock  ${lock_type}
5008a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
5018a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
502d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
5033b3a7ecaSSushil Singh    Run Keyword If  '${message}' != '${EMPTY}'
5043b3a7ecaSSushil Singh    ...  Valid Value  message  ['${resp.content}']
505d03f2ce1SSushil Singh
506d03f2ce1SSushil Singh    [Return]  ${resp}
507bc331e22SVijay
508bc331e22SVijay
509e33c6e6aSSushil SinghRedfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
510e33c6e6aSSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock with invalid data type of resource id.
511e33c6e6aSSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
512e33c6e6aSSushil Singh
513e33c6e6aSSushil Singh    # Description of argument(s):
514e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
515e33c6e6aSSushil Singh    # status_code    HTTP status code.
516e33c6e6aSSushil Singh
5178a3efe7cSSushil Singh    ${lock_dict_param}=
5188a3efe7cSSushil Singh    ...  Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID  ${lock_type}
5198a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
5208a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
521e33c6e6aSSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
522e33c6e6aSSushil Singh
523e33c6e6aSSushil Singh    [Return]  ${resp}
524e33c6e6aSSushil Singh
525e33c6e6aSSushil Singh
526d03f2ce1SSushil SinghForm Data To Acquire Lock
52716b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for lock request.
528d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
529d03f2ce1SSushil Singh
530d03f2ce1SSushil Singh    # Description of argument(s):
531d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
532d03f2ce1SSushil Singh
533d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
534d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
535d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
536d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
537d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
538e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
539d03f2ce1SSushil Singh
540e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
541e33c6e6aSSushil Singh
542e33c6e6aSSushil Singh
543977f8f58SSushil SinghCreate Data To Acquire List Of Lock
54416b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for list of lock request.
545977f8f58SSushil Singh    [Arguments]  ${lock_type_list}
546977f8f58SSushil Singh
547977f8f58SSushil Singh    # Description of argument(s):
548977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
549977f8f58SSushil Singh
550977f8f58SSushil Singh    ${temp_list}=  Create List
551977f8f58SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
552977f8f58SSushil Singh
553977f8f58SSushil Singh    FOR  ${lock_type}  IN  @{lock_type_list}
554977f8f58SSushil Singh      ${resp}=  RW General Dictionary
555977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
556977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["ResourceID"]}
557977f8f58SSushil Singh      Append To List  ${temp_list}  ${resp}
558977f8f58SSushil Singh    END
559977f8f58SSushil Singh
560977f8f58SSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
561977f8f58SSushil Singh
562977f8f58SSushil Singh    [Return]  ${lock_request_dict}
563977f8f58SSushil Singh
564977f8f58SSushil Singh
565e33c6e6aSSushil SinghForm Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
56616b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for in-valid lock request.
567e33c6e6aSSushil Singh    [Arguments]  ${lock_type}
568e33c6e6aSSushil Singh
569e33c6e6aSSushil Singh    # Description of argument(s):
570e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
571e33c6e6aSSushil Singh
572e33c6e6aSSushil Singh    ${lock_res_info}=  Get Lock Resource Information
573e33c6e6aSSushil Singh    ${resp}=  RW General Dictionary
574e33c6e6aSSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
575e33c6e6aSSushil Singh    ...    ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
576e33c6e6aSSushil Singh    ${temp_list}=  Create List  ${resp}
577e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
578e33c6e6aSSushil Singh
579e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
580d03f2ce1SSushil Singh
581d03f2ce1SSushil Singh
582d03f2ce1SSushil SinghForm Data To Acquire Invalid Lock
58316b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for in-valid lock request.
584d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
585d03f2ce1SSushil Singh
586d03f2ce1SSushil Singh    # Description of argument(s):
587d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
588d03f2ce1SSushil Singh
589d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
590d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
591d03f2ce1SSushil Singh    ...    ${lock_res_info["Invalid Case"]["${lock_type}"]}
592d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
593d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
594e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
595d03f2ce1SSushil Singh
596e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
597d03f2ce1SSushil Singh
598d03f2ce1SSushil Singh
599d03f2ce1SSushil SinghGet Locks List On Resource
600bc331e22SVijay    [Documentation]  Get locks list.
601d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${exp_status_code}=${HTTP_OK}
602bc331e22SVijay
603bc331e22SVijay    # Description of argument(s):
604d03f2ce1SSushil Singh    # session_info       Session information in dict.
605d03f2ce1SSushil Singh    # exp_status_code    Expected HTTP status code.
606bc331e22SVijay
607d03f2ce1SSushil Singh    ${data}=  Set Variable  {"SessionIDs": ["${session_info['SessionIDs']}"]}
608566daaf3SGeorge Keishing    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
609566daaf3SGeorge Keishing    ...  data=${data}
610bc331e22SVijay    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
611bc331e22SVijay
612bc331e22SVijay    [Return]  ${locks["Records"]}
613bc331e22SVijay
614bc331e22SVijay
615d03f2ce1SSushil SinghVerify Lock On Resource
616d03f2ce1SSushil Singh    [Documentation]  Verify lock on resource.
617d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${transaction_id}
618bc331e22SVijay
619bc331e22SVijay    # Description of argument(s):
620d03f2ce1SSushil Singh    # session_info      Session information in dict.
621d03f2ce1SSushil Singh    # transaction_id    Transaction id in list stored in dict.
622bc331e22SVijay
623d03f2ce1SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
624d03f2ce1SSushil Singh    Rprint Vars  sessions
625d03f2ce1SSushil Singh    ${lock_list}=  Get Locks List On Resource  ${session_info}
626d03f2ce1SSushil Singh    ${lock_length}=  Get Length  ${lock_list}
627d03f2ce1SSushil Singh    ${tran_id_length}=  Get Length  ${transaction_id}
628d03f2ce1SSushil Singh    Should Be Equal As Integers  ${tran_id_length}  ${lock_length}
629afdd2a1dSVijay
630d03f2ce1SSushil Singh    FOR  ${tran_id}  ${lock}  IN ZIP  ${transaction_id}  ${lock_list}
631d03f2ce1SSushil Singh      Valid Value  session_info['ClientID']  ['${lock['HMCID']}']
632d03f2ce1SSushil Singh      Valid Value  session_info['SessionIDs']  ['${lock['SessionID']}']
633d03f2ce1SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock['TransactionID']}
634bc331e22SVijay    END
635bc331e22SVijay
636bc331e22SVijay
637d03f2ce1SSushil SinghAcquire Lock On Resource
638d03f2ce1SSushil Singh    [Documentation]  Acquire lock on resource.
639d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${reboot_flag}=False
640bc331e22SVijay
641bc331e22SVijay    # Description of argument(s):
642d03f2ce1SSushil Singh    # client_id    This client id can contain string value
643d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
644d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
645d03f2ce1SSushil Singh    # reboot_flag  Flag is used to run reboot the BMC code.
646d03f2ce1SSushil Singh    #               (e.g. True or False).
647bc331e22SVijay
6488a3efe7cSSushil Singh    ${trans_id_emptylist}=  Create List
649d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
6508a3efe7cSSushil Singh
651d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
652d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
653d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
6548a3efe7cSSushil Singh
655d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
656566daaf3SGeorge Keishing
657e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
658bc331e22SVijay
659d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'True'
6608a3efe7cSSushil Singh    ...  Run Keywords  Redfish BMC Reset Operation  AND
661e33c6e6aSSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
6628a3efe7cSSushil Singh    ...  Is BMC Standby  AND
6638a3efe7cSSushil Singh    ...  Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
664bc331e22SVijay
665d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'False'
666d03f2ce1SSushil Singh    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
667bc331e22SVijay
668d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
669d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
670d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
671bc331e22SVijay
672bc331e22SVijay
673d03f2ce1SSushil SinghForm Data To Release Lock
674d03f2ce1SSushil Singh    [Documentation]  Create a dictonay to release lock.
675d03f2ce1SSushil Singh    [Arguments]  ${trans_id_list}
676355daac7SVijay
677355daac7SVijay    # Description of argument(s):
678d03f2ce1SSushil Singh    # trans_id_list
679355daac7SVijay
680d03f2ce1SSushil Singh    @{tran_ids}=  Create List
681355daac7SVijay
682d03f2ce1SSushil Singh    FOR  ${item}  IN  @{trans_id_list}
683d03f2ce1SSushil Singh      Append To List  ${tran_ids}  ${item['TransactionID']}
684d03f2ce1SSushil Singh    END
685d03f2ce1SSushil Singh
686d03f2ce1SSushil Singh    [Return]  ${tran_ids}
687d03f2ce1SSushil Singh
688d03f2ce1SSushil Singh
689d03f2ce1SSushil SinghRelease Locks On Resource
690d03f2ce1SSushil Singh    [Documentation]  Redfish request to release a lock.
6918a3efe7cSSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}  ${release_lock_type}=Transaction
6928a3efe7cSSushil Singh    ...  ${status_code}=${HTTP_OK}
693d03f2ce1SSushil Singh
694d03f2ce1SSushil Singh    # Description of argument(s):
695d03f2ce1SSushil Singh    # session_info        Session information in dict.
696d03f2ce1SSushil Singh    # trans_id_list       Transaction id list.
697d03f2ce1SSushil Singh    # release_lock_type   Release lock by Transaction, Session.
698d03f2ce1SSushil Singh    # status_code         HTTP status code.
699d03f2ce1SSushil Singh
700d03f2ce1SSushil Singh    ${tran_ids}=  Form Data To Release Lock  ${trans_id_list}
701d03f2ce1SSushil Singh    ${data}=  Set Variable  {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
702d03f2ce1SSushil Singh    ${data}=  Evaluate  json.dumps(${data})  json
703d03f2ce1SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock  data=${data}
704d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
705d03f2ce1SSushil Singh
706d03f2ce1SSushil Singh
707df390b61SSushil SinghRelease locks And Delete Session
708df390b61SSushil Singh    [Documentation]  Release locks and delete redfish session.
709df390b61SSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}
710df390b61SSushil Singh
711df390b61SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}
712df390b61SSushil Singh
713df390b61SSushil Singh    ${trans_id_emptylist}=  Create List
714df390b61SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
715df390b61SSushil Singh
716df390b61SSushil Singh    Redfish Delete Session  ${session_info}
717df390b61SSushil Singh
718df390b61SSushil Singh
719d03f2ce1SSushil SinghAcquire Lock On Another Lock
720d03f2ce1SSushil Singh    [Documentation]  Acquire lock on another lock.
721d03f2ce1SSushil Singh    [Arguments]  ${client_id}
722d03f2ce1SSushil Singh
723d03f2ce1SSushil Singh    # Description of argument(s):
724d03f2ce1SSushil Singh    # client_id    This client id can contain string value
725d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
726d03f2ce1SSushil Singh
727d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
728d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
729d03f2ce1SSushil Singh
730d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
731d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
732d03f2ce1SSushil Singh
733d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
734d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
735d03f2ce1SSushil Singh
736d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
737d03f2ce1SSushil Singh
738df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
739d03f2ce1SSushil Singh
740d03f2ce1SSushil Singh
741977f8f58SSushil SinghVerify Fail To Acquire Read And Write In Single Request
742977f8f58SSushil Singh    [Documentation]  Verify fail to acquire read and write lock passed in single request.
743*e3f2e3baSSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${status_code}
744*e3f2e3baSSushil Singh
745*e3f2e3baSSushil Singh    # Description of argument(s):
746*e3f2e3baSSushil Singh    # client_id     This client id can contain string value
747*e3f2e3baSSushil Singh    #               (e.g. 12345, "HMCID").
748*e3f2e3baSSushil Singh    # lock_type     Read lock or Write lock.
749*e3f2e3baSSushil Singh    # status_code   HTTP status code
750*e3f2e3baSSushil Singh
751*e3f2e3baSSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
752*e3f2e3baSSushil Singh
753*e3f2e3baSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
754*e3f2e3baSSushil Singh    ${trans_id}=  Redfish Post Acquire List Lock  ${lock_type_list}  status_code=${status_code}
755*e3f2e3baSSushil Singh    Redfish Delete Session  ${session_info}
756*e3f2e3baSSushil Singh
757*e3f2e3baSSushil Singh
758*e3f2e3baSSushil SinghVerify Acquire Read In Single Request
759*e3f2e3baSSushil Singh    [Documentation]  Verify acquire read in single request.
760977f8f58SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
761977f8f58SSushil Singh
762977f8f58SSushil Singh    # Description of argument(s):
763977f8f58SSushil Singh    # client_id    This client id can contain string value
764977f8f58SSushil Singh    #              (e.g. 12345, "HMCID").
765977f8f58SSushil Singh    # lock_type    Read lock or Write lock.
766977f8f58SSushil Singh
767*e3f2e3baSSushil Singh    ${trans_id_list}=  Create List
768977f8f58SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
769977f8f58SSushil Singh
770977f8f58SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
771*e3f2e3baSSushil Singh    ${trans_id}=  Redfish Post Acquire List Lock  ${lock_type_list}
772*e3f2e3baSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
773*e3f2e3baSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
774*e3f2e3baSSushil Singh
775*e3f2e3baSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
776*e3f2e3baSSushil Singh    Remove From List  ${trans_id_list}  1
777*e3f2e3baSSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}
778*e3f2e3baSSushil Singh
779977f8f58SSushil Singh    Redfish Delete Session  ${session_info}
780977f8f58SSushil Singh
781977f8f58SSushil Singh
782d03f2ce1SSushil SinghVerify Empty Lock Records For Invalid Session
783d03f2ce1SSushil Singh    [Documentation]  Verify no lock record found for invalid session.
784d03f2ce1SSushil Singh    [Arguments]  ${client_id}
785d03f2ce1SSushil Singh
786d03f2ce1SSushil Singh    # Description of argument(s):
787d03f2ce1SSushil Singh    # client_id    This client id can contain string value
788d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
789d03f2ce1SSushil Singh
790d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_id}
791d03f2ce1SSushil Singh
792d03f2ce1SSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
793d03f2ce1SSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
794d03f2ce1SSushil Singh
795d03f2ce1SSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
796d03f2ce1SSushil Singh    set to dictionary  ${session_info2}  SessionIDs  xxyXyyYZZz
797d03f2ce1SSushil Singh
798d03f2ce1SSushil Singh    ${lock_list2}=  Get Locks List On Resource  ${session_info2}
799f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list2}
800d03f2ce1SSushil Singh
801f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
802d03f2ce1SSushil Singh
803d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
804d03f2ce1SSushil Singh
805d03f2ce1SSushil Singh
806d03f2ce1SSushil SinghVerify Acquire Lock Fails On Another Lock
807d03f2ce1SSushil Singh    [Documentation]  Verify acquire lock on another lock fails.
808d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
809d03f2ce1SSushil Singh
810d03f2ce1SSushil Singh    # Description of argument(s):
811d03f2ce1SSushil Singh    # client_id    This client id can contain string value
812d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
813d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
814d03f2ce1SSushil Singh
815d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
816d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
817d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
818d03f2ce1SSushil Singh
819d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
820d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
821d03f2ce1SSushil Singh
822d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
823d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
824d03f2ce1SSushil Singh
825df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
826d03f2ce1SSushil Singh
827d03f2ce1SSushil Singh
828e33c6e6aSSushil SinghVerify Acquire Lock After Reboot
829e33c6e6aSSushil Singh    [Documentation]  Acquire read and write lock after the reboot and release lock.
830e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
831e33c6e6aSSushil Singh
832e33c6e6aSSushil Singh    # Description of argument(s):
833e33c6e6aSSushil Singh    # client_id    This client id can contain string value
834e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
835e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
836e33c6e6aSSushil Singh
837e33c6e6aSSushil Singh    ${trans_id_list}=  Create List
838f9a536caSSushil Singh    ${session_info}=  Create Session With ClientID  ${client_id}
839ac229c79SSushil Singh
840e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
841ac229c79SSushil Singh    Redfish BMC Reset Operation
842e33c6e6aSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}
843ac229c79SSushil Singh    Is BMC Standby
844e33c6e6aSSushil Singh
845e33c6e6aSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
846e33c6e6aSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
847e33c6e6aSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
848e33c6e6aSSushil Singh
849df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
850df390b61SSushil Singh
851df390b61SSushil Singh
852df390b61SSushil SinghVerify Acquire Multiple Lock Request At CEC Level
853df390b61SSushil Singh    [Documentation]  Acquire lock in loop.
854df390b61SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
855df390b61SSushil Singh
856df390b61SSushil Singh    # Description of argument(s):
857df390b61SSushil Singh    # client_id    This client id can contain string value
858df390b61SSushil Singh    #              (e.g. 12345, "HMCID").
859df390b61SSushil Singh    # lock_type    Read lock or Write lock.
860df390b61SSushil Singh
861df390b61SSushil Singh    ${trans_id_list}=  Create List
862df390b61SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
863df390b61SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
864df390b61SSushil Singh
865df390b61SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
866df390b61SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
867df390b61SSushil Singh
868df390b61SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
869df390b61SSushil Singh
870df390b61SSushil Singh    Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
871df390b61SSushil Singh
872df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
873e33c6e6aSSushil Singh
874e33c6e6aSSushil Singh
8758d420bf6SSushil SinghPost Reboot Acquire Lock
8768d420bf6SSushil Singh    [Documentation]  Post reboot acquire lock and verify the transaction id is 1.
8778d420bf6SSushil Singh    [Arguments]  ${session_info}  ${lock_type}
8788d420bf6SSushil Singh
8798d420bf6SSushil Singh    # Description of argument(s):
8808d420bf6SSushil Singh    # session_info     Session information.
8818d420bf6SSushil Singh    # lock_type        Read lock or Write lock.
8828d420bf6SSushil Singh
8838d420bf6SSushil Singh    ${trans_id_list}=  Create List
8848d420bf6SSushil Singh    ${trans_id_list_var}=  Create List
8858d420bf6SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
8868d420bf6SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
8878d420bf6SSushil Singh    Append To List  ${trans_id_list_var}  ${default_trans_id}
8888d420bf6SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
8898d420bf6SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list_var}
8908d420bf6SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
8918d420bf6SSushil Singh    ${trans_id_emptylist}=  Create List
8928d420bf6SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
8938d420bf6SSushil Singh
8948d420bf6SSushil Singh
895d03f2ce1SSushil SinghVerify Acquire And Release Lock In Loop
896d03f2ce1SSushil Singh    [Documentation]  Acquire lock in loop.
8978d420bf6SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${reboot_flag}=False
898d03f2ce1SSushil Singh
899d03f2ce1SSushil Singh    # Description of argument(s):
900d03f2ce1SSushil Singh    # client_id    This client id can contain string value
901d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
902d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
9038d420bf6SSushil Singh    # reboot_flag  Flag is used to run reboot the BMC code.
9048d420bf6SSushil Singh    #               (e.g. True or False).
905d03f2ce1SSushil Singh
906d03f2ce1SSushil Singh    FOR  ${count}  IN RANGE  1  11
907d03f2ce1SSushil Singh      ${trans_id_list}=  Create List
908d03f2ce1SSushil Singh      ${session_info}=  Create Redfish Session With ClientID  ${client_id}
909d03f2ce1SSushil Singh      ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
910d03f2ce1SSushil Singh      Append To List  ${trans_id_list}  ${trans_id}
911d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_list}
912d03f2ce1SSushil Singh      Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
913d03f2ce1SSushil Singh      ${trans_id_emptylist}=  Create List
914d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
9158d420bf6SSushil Singh      Redfish Delete Session  ${session_info}
916d03f2ce1SSushil Singh    END
917d03f2ce1SSushil Singh
9188d420bf6SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
9198d420bf6SSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
9208d420bf6SSushil Singh
9218d420bf6SSushil Singh    Run Keyword If  '${reboot_flag}' == 'True'
9228d420bf6SSushil Singh    ...  Run Keywords  Redfish BMC Reset Operation  AND
9238d420bf6SSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
9248d420bf6SSushil Singh    ...  Is BMC Standby  AND
9258d420bf6SSushil Singh    ...  Post Reboot Acquire Lock  ${session_info}  ${lock_type}
926d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
927d03f2ce1SSushil Singh
928d03f2ce1SSushil Singh
929d03f2ce1SSushil SinghAcquire And Release Multiple Locks
930d03f2ce1SSushil Singh    [Documentation]  Acquire mutilple locks on resource.
931d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
932d03f2ce1SSushil Singh
933d03f2ce1SSushil Singh    # Description of argument(s):
934d03f2ce1SSushil Singh    # client_id          This client id can contain string value
935d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
936d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
937d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
938d03f2ce1SSushil Singh
939d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
940d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
941d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
942d03f2ce1SSushil Singh
943d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
944d03f2ce1SSushil Singh
945d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
946d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
947d03f2ce1SSushil Singh
948d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
949d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
950d03f2ce1SSushil Singh
951d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
952d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
953d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
954d03f2ce1SSushil Singh
955d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
956d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
957d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
958d03f2ce1SSushil Singh
959d03f2ce1SSushil Singh
96094116c61Ssusilsi7Verify Release Lock When Session Deleted
96194116c61Ssusilsi7    [Documentation]  Verify lock get released when session are deleted.
96294116c61Ssusilsi7    [Arguments]  ${client_id}  ${lock_type}
96394116c61Ssusilsi7
96494116c61Ssusilsi7    # Description of argument(s):
96594116c61Ssusilsi7    # client_ids    This client id can contain string value
96694116c61Ssusilsi7    #               (e.g. 12345, "HMCID").
96794116c61Ssusilsi7    # lock_type     Read lock or Write lock.
96894116c61Ssusilsi7
96994116c61Ssusilsi7    ${trans_id_list}=  Create List
97094116c61Ssusilsi7    @{lock_type_list}=  Split String  ${lock_type}  ,
97194116c61Ssusilsi7
97294116c61Ssusilsi7    ${pre_session_info}=  Create Redfish Session With ClientID  ${client_id}
97394116c61Ssusilsi7
97494116c61Ssusilsi7    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
97594116c61Ssusilsi7    Append To List  ${trans_id_list}  ${trans_id}
97694116c61Ssusilsi7    Verify Lock On Resource  ${pre_session_info}  ${trans_id_list}
97794116c61Ssusilsi7
97894116c61Ssusilsi7    Redfish Delete Session  ${pre_session_info}
97994116c61Ssusilsi7    ${post_session_info}=  Create Redfish Session With ClientID  ${client_id}
98094116c61Ssusilsi7    ${resp}=  Get Locks List On Resource With Session List  ${pre_session_info}  ${HTTP_BAD_REQUEST}
98194116c61Ssusilsi7
98294116c61Ssusilsi7    Redfish Delete Session  ${post_session_info}
98394116c61Ssusilsi7
98494116c61Ssusilsi7
98594116c61Ssusilsi7
98659011d08SSushil SinghVerify Fail To Release Lock With Invalid TransactionID
98716b3c7bfSGeorge Keishing    [Documentation]  Verify fail to be release lock with invalid transaction ID.
98859011d08SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
98959011d08SSushil Singh
99059011d08SSushil Singh    # Description of argument(s):
99159011d08SSushil Singh    # client_id          This client id can contain string value
99259011d08SSushil Singh    #                    (e.g. 12345, "HMCID").
99359011d08SSushil Singh    # lock_type          Read lock or Write lock.
99459011d08SSushil Singh    # release_lock_type  The value can be Transaction or Session.
99559011d08SSushil Singh
99659011d08SSushil Singh    ${trans_id_list}=  Create List
99759011d08SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
99859011d08SSushil Singh
99959011d08SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
100059011d08SSushil Singh
100159011d08SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
100259011d08SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
100359011d08SSushil Singh    ${value}=  Evaluate  ${value} + 10
100459011d08SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
100559011d08SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
100659011d08SSushil Singh
100759011d08SSushil Singh    Release Locks On Resource
100859011d08SSushil Singh    ...  ${session_info}  ${trans_id_list}
100959011d08SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
101059011d08SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
101159011d08SSushil Singh
101259011d08SSushil Singh    ${trans_id_emptylist}=  Create List
101359011d08SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
101459011d08SSushil Singh    Redfish Delete Session  ${session_info}
101559011d08SSushil Singh
101659011d08SSushil Singh
10171b59053dSSushil SinghVerify Fail To Release Multiple Lock With Invalid TransactionID
10181b59053dSSushil Singh    [Documentation]  Verify release multiple locks with invalid transaction ID fails.
1019d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
1020d03f2ce1SSushil Singh
1021d03f2ce1SSushil Singh    # Description of argument(s):
1022d03f2ce1SSushil Singh    # client_id          This client id can contain string value
1023d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
1024d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
1025d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
1026d03f2ce1SSushil Singh
1027d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
1028d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
1029d03f2ce1SSushil Singh
1030d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1031d03f2ce1SSushil Singh
1032d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1033d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
1034d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
1035d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
1036d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
1037d03f2ce1SSushil Singh
1038d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1039d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
1040d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
1041d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
1042d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
1043d03f2ce1SSushil Singh
1044d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
1045d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
1046d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
1047d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
1048d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
1049d03f2ce1SSushil Singh
1050d03f2ce1SSushil Singh    Release Locks On Resource
1051d03f2ce1SSushil Singh    ...  ${session_info}  ${trans_id_list}
1052d03f2ce1SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
1053d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
1054d03f2ce1SSushil Singh
1055d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
1056d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
1057d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
1058d03f2ce1SSushil Singh
1059d03f2ce1SSushil Singh
10608bee358fSSushil SinghVerify Fail To Release Multiple Lock With Valid And Invalid TransactionID
10619614383dSGeorge Keishing    [Documentation]  Verify fail to be release multiple lock with valid and invalid transaction ID.
10628bee358fSSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
10638bee358fSSushil Singh
10648bee358fSSushil Singh    # Description of argument(s):
10658bee358fSSushil Singh    # client_id          This client id can contain string value
10668bee358fSSushil Singh    #                    (e.g. 12345, "HMCID").
10678bee358fSSushil Singh    # lock_type          Read lock or Write lock.
10688bee358fSSushil Singh    # release_lock_type  The value can be Transaction or Session.
10698bee358fSSushil Singh
10708bee358fSSushil Singh    ${trans_id_list}=  Create List
10718bee358fSSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
10728bee358fSSushil Singh
10738bee358fSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
10748bee358fSSushil Singh
10758bee358fSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
10768bee358fSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
10778bee358fSSushil Singh
10788bee358fSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
10798bee358fSSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
10808bee358fSSushil Singh    ${value}=  Evaluate  ${value} + 10
10818bee358fSSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
10828bee358fSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
10838bee358fSSushil Singh
10848bee358fSSushil Singh    Release Locks On Resource
10858bee358fSSushil Singh    ...  ${session_info}  ${trans_id_list}
10868bee358fSSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
10878bee358fSSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
10888bee358fSSushil Singh
10898bee358fSSushil Singh    ${trans_id_emptylist}=  Create List
10908bee358fSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
10918bee358fSSushil Singh    Redfish Delete Session  ${session_info}
10928bee358fSSushil Singh
10938bee358fSSushil Singh
10941d7b996cSsusilsi7Verify Fail To Release Lock With TransactionID As String Type
10959614383dSGeorge Keishing    [Documentation]  Verify fail to be release lock with transaction ID as string data type.
10961d7b996cSsusilsi7    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
10971d7b996cSsusilsi7
10981d7b996cSsusilsi7    # Description of argument(s):
10991d7b996cSsusilsi7    # client_id          This client id can contain string value
11001d7b996cSsusilsi7    #                    (e.g. 12345, "HMCID").
11011d7b996cSsusilsi7    # lock_type          Read lock or Write lock.
11021d7b996cSsusilsi7    # release_lock_type  The value can be Transaction or Session.
11031d7b996cSsusilsi7
11041d7b996cSsusilsi7    ${trans_id_list}=  Create List
11051d7b996cSsusilsi7    @{lock_type_list}=  Split String  ${lock_type}  ,
11061d7b996cSsusilsi7
11071d7b996cSsusilsi7    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
11081d7b996cSsusilsi7
11091d7b996cSsusilsi7    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
11101d7b996cSsusilsi7
11111d7b996cSsusilsi7    Append To List  ${trans_id_list}  ${trans_id}
11121d7b996cSsusilsi7
11131d7b996cSsusilsi7    ${temp_trans_id_list}=  Copy Dictionary  ${trans_id_list}  deepcopy=True
11141d7b996cSsusilsi7
11151d7b996cSsusilsi7    ${value}=  Get From Dictionary  ${trans_id_list}[0]  TransactionID
11161d7b996cSsusilsi7    ${value}=  Set Variable  \'${value}\'
11171d7b996cSsusilsi7    Set To Dictionary  ${temp_trans_id_list}[0]  TransactionID  ${value}
11181d7b996cSsusilsi7
11191d7b996cSsusilsi7    Release Locks On Resource
11201d7b996cSsusilsi7    ...  ${session_info}  ${temp_trans_id_list}
11211d7b996cSsusilsi7    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
11221d7b996cSsusilsi7
11231d7b996cSsusilsi7    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
11241d7b996cSsusilsi7
11251d7b996cSsusilsi7    ${trans_id_emptylist}=  Create List
11261d7b996cSsusilsi7    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
11271d7b996cSsusilsi7    Redfish Delete Session  ${session_info}
11281d7b996cSsusilsi7
11291d7b996cSsusilsi7
1130d03f2ce1SSushil SinghVerify Fail To Release Lock For Another Session
1131d03f2ce1SSushil Singh    [Documentation]  Verify failed to release the lock form another session.
1132d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
1133d03f2ce1SSushil Singh
1134d03f2ce1SSushil Singh    # Description of argument(s):
1135d03f2ce1SSushil Singh    # client_id    This client id can contain string value
1136d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
1137d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
1138d03f2ce1SSushil Singh
1139d03f2ce1SSushil Singh    ${client_ids}=  Split String  ${client_id}  ,
1140d03f2ce1SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
1141d03f2ce1SSushil Singh    ${trans_id_list1}=  Create List
1142d03f2ce1SSushil Singh    ${trans_id_list2}=  Create List
1143d03f2ce1SSushil Singh
1144d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_ids}[0]
1145d03f2ce1SSushil Singh
1146d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1147d03f2ce1SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
1148d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
1149d03f2ce1SSushil Singh
1150d03f2ce1SSushil Singh    ${session_info2}=  Create Redfish Session With ClientID  ${client_ids}[1]
1151d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1152d03f2ce1SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
1153d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info2}  ${trans_id_list2}
1154d03f2ce1SSushil Singh
1155d03f2ce1SSushil Singh    Release Locks On Resource
1156*e3f2e3baSSushil Singh    ...  ${session_info1}  ${trans_id_list1}  Transaction  status_code=${HTTP_BAD_REQUEST}
1157d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
1158d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Session
1159d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Session
1160d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
1161d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info2}
1162d03f2ce1SSushil Singh
1163d03f2ce1SSushil Singh
1164e33c6e6aSSushil SinghVerify Fail To Acquire Lock For Invalid Resource ID Data Type
1165e33c6e6aSSushil Singh    [Documentation]  Verify fail to acquire the lock with invalid resource id data type.
1166e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
1167e33c6e6aSSushil Singh
1168e33c6e6aSSushil Singh    # Description of argument(s):
1169e33c6e6aSSushil Singh    # client_id    This client id can contain string value
1170e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
1171e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
1172e33c6e6aSSushil Singh
1173e33c6e6aSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1174e33c6e6aSSushil Singh    Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
1175e33c6e6aSSushil Singh    ...  ${lock_type}  status_code=${HTTP_BAD_REQUEST}
1176e33c6e6aSSushil Singh    Redfish Delete Session  ${session_info}
1177e33c6e6aSSushil Singh
1178e33c6e6aSSushil Singh
1179d03f2ce1SSushil SinghVerify Fail To Acquire Lock For Invalid Lock Data
118016b3c7bfSGeorge Keishing    [Documentation]  Verify fail to acquired lock with invalid lock types, lock flags, segment flags.
1181d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${message}
1182d03f2ce1SSushil Singh
1183d03f2ce1SSushil Singh    # Description of argument(s):
1184d03f2ce1SSushil Singh    # client_id    This client id can contain string value
1185d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
1186d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
1187d03f2ce1SSushil Singh    # message      Return message from URI.
1188d03f2ce1SSushil Singh
1189d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
11908a3efe7cSSushil Singh    ${trans_id}=  Redfish Post Acquire Invalid Lock
11918a3efe7cSSushil Singh    ...  ${lock_type}  message=${message}  status_code=${HTTP_BAD_REQUEST}
1192d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
1193bace3005SSushil Singh
1194bace3005SSushil Singh
1195bace3005SSushil SinghVerify No Locks Records For Session With No Acquired Lock
1196bace3005SSushil Singh    [Documentation]  Verify no records found for a session where no lock is acquired.
1197bace3005SSushil Singh    [Arguments]  ${client_id}
1198bace3005SSushil Singh
1199bace3005SSushil Singh    # Description of argument(s):
1200bace3005SSushil Singh    # client_id    This client id can contain string value
1201bace3005SSushil Singh    #              (e.g. 12345, "HMCID").
1202bace3005SSushil Singh
1203bace3005SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1204bace3005SSushil Singh    ${trans_id_emptylist}=  Create List
1205bace3005SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
1206bace3005SSushil Singh    Redfish Delete Session  ${session_info}
1207728ef9c9SSushil Singh
1208728ef9c9SSushil Singh
1209728ef9c9SSushil SinghCreate List Of Session ID
1210728ef9c9SSushil Singh    [Documentation]  Create session id list from session dict info.
1211728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}
1212728ef9c9SSushil Singh
1213728ef9c9SSushil Singh    # Description of argument(s):
1214728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
1215728ef9c9SSushil Singh
1216728ef9c9SSushil Singh    @{session_id_list}=  Create List
1217728ef9c9SSushil Singh
1218728ef9c9SSushil Singh    FOR  ${session}  IN  @{session_dict_info}
1219728ef9c9SSushil Singh      Append To List  ${session_id_list}  ${session["SessionIDs"]}
1220728ef9c9SSushil Singh    END
1221728ef9c9SSushil Singh
1222728ef9c9SSushil Singh    ${num_id}=  Get Length  ${session_id_list}
1223728ef9c9SSushil Singh    Should Not Be Equal As Integers  ${num_id}  ${0}
1224728ef9c9SSushil Singh
1225728ef9c9SSushil Singh    ${session_id_list}=  Evaluate  json.dumps(${session_id_list})  json
1226728ef9c9SSushil Singh
1227728ef9c9SSushil Singh    [Return]  ${session_id_list}
1228728ef9c9SSushil Singh
1229728ef9c9SSushil Singh
1230728ef9c9SSushil SinghGet Locks List On Resource With Session List
1231728ef9c9SSushil Singh    [Documentation]  Get locks list from session of list.
1232728ef9c9SSushil Singh    [Arguments]  ${session_id_list}  ${exp_status_code}=${HTTP_OK}
1233728ef9c9SSushil Singh
1234728ef9c9SSushil Singh    # Description of argument(s):
1235728ef9c9SSushil Singh    # session_id_list    Session ids list.
1236728ef9c9SSushil Singh    # exp_status_code    Expected HTTP status code.
1237728ef9c9SSushil Singh
1238728ef9c9SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
1239728ef9c9SSushil Singh    ...  data={"SessionIDs": ${session_id_list}}
124094116c61Ssusilsi7    Should Be Equal As Strings  ${resp.status_code}  ${exp_status_code}
1241728ef9c9SSushil Singh    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
1242728ef9c9SSushil Singh
1243728ef9c9SSushil Singh    [Return]  ${locks}
1244728ef9c9SSushil Singh
1245728ef9c9SSushil Singh
1246728ef9c9SSushil SinghVerify List Of Session Lock On Resource
1247728ef9c9SSushil Singh    [Documentation]  Verify list of lock record from list of sessions.
1248728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}  ${transaction_id_list}
1249728ef9c9SSushil Singh
1250728ef9c9SSushil Singh    # Description of argument(s):
1251728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
1252728ef9c9SSushil Singh    # transaction_id_list    Transaction id in list stored in dict.
1253728ef9c9SSushil Singh
1254728ef9c9SSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_info}
1255728ef9c9SSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1256728ef9c9SSushil Singh    ${lock_list}=  Set Variable  ${lock_list_resp['Records']}
1257728ef9c9SSushil Singh
12588a3efe7cSSushil Singh    FOR  ${session_id}  ${tran_id}  ${lock_record}  IN ZIP
12598a3efe7cSSushil Singh    ...  ${session_dict_info}  ${transaction_id_list}  ${lock_list}
1260728ef9c9SSushil Singh      Valid Value  session_id['SessionIDs']  ['${lock_record['SessionID']}']
1261728ef9c9SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock_record['TransactionID']}
1262728ef9c9SSushil Singh    END
1263728ef9c9SSushil Singh
1264728ef9c9SSushil Singh
1265728ef9c9SSushil SinghVerify Lock Records Of Multiple Session
1266728ef9c9SSushil Singh    [Documentation]  Verify all records found for a multiple sessions.
1267728ef9c9SSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
1268728ef9c9SSushil Singh
1269728ef9c9SSushil Singh    # Description of argument(s):
1270728ef9c9SSushil Singh    # client_ids    This client id can contain string value
1271728ef9c9SSushil Singh    #               (e.g. 12345, "HMCID").
1272728ef9c9SSushil Singh    # lock_type     Read lock or Write lock.
1273728ef9c9SSushil Singh
1274728ef9c9SSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
1275728ef9c9SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
1276728ef9c9SSushil Singh    ${trans_id_list1}=  Create List
1277728ef9c9SSushil Singh    ${trans_id_list2}=  Create List
1278728ef9c9SSushil Singh
1279728ef9c9SSushil Singh    ${session_dict_list}=  Create List
1280728ef9c9SSushil Singh    ${lock_list}=  Create List
1281728ef9c9SSushil Singh
1282728ef9c9SSushil Singh    ${client_id1}=  Create List
1283728ef9c9SSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
1284728ef9c9SSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
1285728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
1286728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
1287728ef9c9SSushil Singh
1288728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1289728ef9c9SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
1290728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
1291728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
1292728ef9c9SSushil Singh
1293728ef9c9SSushil Singh
1294728ef9c9SSushil Singh    ${client_id2}=  Create List
1295728ef9c9SSushil Singh    Append To List  ${client_id2}  ${client_id_list}[1]
1296728ef9c9SSushil Singh    ${session_info2}=  Create Session With List Of ClientID  ${client_id2}
1297728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
1298728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id2}  ${session_info2}
1299728ef9c9SSushil Singh
1300728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1301728ef9c9SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
1302728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
1303728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_list2}
1304728ef9c9SSushil Singh
1305728ef9c9SSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
1306728ef9c9SSushil Singh
1307728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
1308728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1309728ef9c9SSushil Singh
1310728ef9c9SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
1311728ef9c9SSushil Singh
1312728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info2}[0]  SessionToken
1313728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1314728ef9c9SSushil Singh
1315728ef9c9SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Transaction
1316728ef9c9SSushil Singh
1317728ef9c9SSushil Singh    ${trans_id_emptylist}=  Create List
1318728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
1319728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_emptylist}
1320728ef9c9SSushil Singh
1321728ef9c9SSushil Singh    Redfish Delete List Of Session  ${session_dict_list}
1322f9a536caSSushil Singh
1323f9a536caSSushil Singh
1324f9a536caSSushil SinghVerify Lock Records For Multiple Invalid Session
1325f9a536caSSushil Singh    [Documentation]  Verify no lock record found for multiple invalid session.
1326f9a536caSSushil Singh    [Arguments]  ${client_id}
1327f9a536caSSushil Singh
1328f9a536caSSushil Singh    # Description of argument(s):
1329f9a536caSSushil Singh    # client_id    This client id can contain string value
1330f9a536caSSushil Singh    #              (e.g. 12345, "HMCID").
1331f9a536caSSushil Singh
1332f9a536caSSushil Singh    ${session_dict_list}=  Create List
1333f9a536caSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz  xXyXYyYZzz
1334f9a536caSSushil Singh
1335f9a536caSSushil Singh    ${session_info1}=  Create Session With ClientID  ${client_id}
1336f9a536caSSushil Singh
1337f9a536caSSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
1338f9a536caSSushil Singh    set to dictionary  ${session_info2}  SessionIDs  ${invalid_session_ids}[0]
1339f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}
1340f9a536caSSushil Singh
1341f9a536caSSushil Singh    ${session_info3}=  Copy Dictionary  ${session_info1}  deepcopy=True
1342f9a536caSSushil Singh    set to dictionary  ${session_info3}  SessionIDs  ${invalid_session_ids}[0]
1343f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info3}
1344f9a536caSSushil Singh
1345f9a536caSSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
1346f9a536caSSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
1347f9a536caSSushil Singh
1348f9a536caSSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_list}
1349f9a536caSSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1350f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list_resp['Records']}
1351f9a536caSSushil Singh
1352f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
1353f9a536caSSushil Singh
1354f9a536caSSushil Singh    Redfish Delete Session  ${session_info1}
135511949a2cSSushil Singh
135611949a2cSSushil Singh
135711949a2cSSushil SinghVerify Lock Records For Multiple Invalid And Valid Session
135811949a2cSSushil Singh    [Documentation]  Verify all records found for a valid and invalid sessions.
135911949a2cSSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
136011949a2cSSushil Singh
136111949a2cSSushil Singh    # Description of argument(s):
136211949a2cSSushil Singh    # client_ids    This client id can contain string value
136311949a2cSSushil Singh    #               (e.g. 12345, "HMCID").
136411949a2cSSushil Singh    # lock_type     Read lock or Write lock.
136511949a2cSSushil Singh
136611949a2cSSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
136711949a2cSSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
136811949a2cSSushil Singh    ${trans_id_list1}=  Create List
136911949a2cSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz
137011949a2cSSushil Singh
137111949a2cSSushil Singh    ${session_dict_list}=  Create List
137211949a2cSSushil Singh    ${lock_list}=  Create List
137311949a2cSSushil Singh
137411949a2cSSushil Singh    ${client_id1}=  Create List
137511949a2cSSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
137611949a2cSSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
137711949a2cSSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
137811949a2cSSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
137911949a2cSSushil Singh
138011949a2cSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
138111949a2cSSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
138211949a2cSSushil Singh    Append To List  ${lock_list}  ${trans_id}
138311949a2cSSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
138411949a2cSSushil Singh
138511949a2cSSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
138611949a2cSSushil Singh    set to dictionary  ${session_info2}[0]  SessionIDs  ${invalid_session_ids}[0]
138711949a2cSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
138811949a2cSSushil Singh
138911949a2cSSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
139011949a2cSSushil Singh
139111949a2cSSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
139211949a2cSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
139311949a2cSSushil Singh
139411949a2cSSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
139511949a2cSSushil Singh
139611949a2cSSushil Singh    ${trans_id_emptylist}=  Create List
139711949a2cSSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
139811949a2cSSushil Singh
139911949a2cSSushil Singh    Redfish Delete Session  ${session_info1}[0]
1400