xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_lock_management.robot (revision 6fb70d98f2f1cb9273ba912deaa2cebe3c23ea86)
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
11fbd67007SGeorge KeishingLibrary                 JSONLibrary
12bc331e22SVijay
1376806df6SSushil SinghSuite Setup              Run Keyword And Ignore Error  Delete All Redfish Sessions
1476806df6SSushil SinghSuite Teardown           Run Keyword And Ignore Error  Delete All Redfish Sessions
1576806df6SSushil SinghTest Setup               Printn
1676806df6SSushil SinghTest Teardown            FFDC On Test Case Fail
17bc331e22SVijay
18*6fb70d98SMatt FischerTest Tags               Lock_Management
197c32f30fSGeorge Keishing
20bc331e22SVijay*** Variables ***
21bc331e22SVijay
22e3f2e3baSSushil Singh${CONFLICT_RQUEST}       Conflict
23d03f2ce1SSushil Singh${BAD_REQUEST}           Bad Request
248d420bf6SSushil Singh&{default_trans_id}      TransactionID=${1}
25bc331e22SVijay
26bc331e22SVijay*** Test Cases ***
27bc331e22SVijay
28d03f2ce1SSushil SinghAcquire Read Write Lock
29bc331e22SVijay    [Documentation]  Acquire and release different read locks.
30d03f2ce1SSushil Singh    [Tags]  Acquire_Read_Write_Lock
31d03f2ce1SSushil Singh    [Template]  Acquire Lock On Resource
32bc331e22SVijay
33d03f2ce1SSushil Singh    # client_id    lock_type     reboot_flag
34d03f2ce1SSushil Singh    HMCID-01       ReadCase1     False
35d03f2ce1SSushil Singh    HMCID-01       ReadCase2     False
36d03f2ce1SSushil Singh    HMCID-01       ReadCase3     False
37d03f2ce1SSushil Singh    HMCID-01       WriteCase1    False
38d03f2ce1SSushil Singh    HMCID-01       WriteCase2    False
39d03f2ce1SSushil Singh    HMCID-01       WriteCase3    False
40bc331e22SVijay
41bc331e22SVijay
42d03f2ce1SSushil SinghAcquire Read Lock On Read Lock
43d03f2ce1SSushil Singh    [Documentation]  Acquire read lock on another read lock.
44d03f2ce1SSushil Singh    [Tags]  Acquire_Read_Lock_On_Read_Lock
45d03f2ce1SSushil Singh    [Template]  Acquire Lock On Another Lock
46bc331e22SVijay
47d03f2ce1SSushil Singh    # client_id
48d03f2ce1SSushil Singh    HMCID-01
49bc331e22SVijay
50bc331e22SVijay
51d03f2ce1SSushil SinghFail To Acquire Lock On Another Lock
52d03f2ce1SSushil Singh    [Documentation]  Fail to acquire another lock.
53d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_On_Another_Lock
54d03f2ce1SSushil Singh    [Template]  Verify Acquire Lock Fails On Another Lock
5585610eeeSVijay
56d03f2ce1SSushil Singh    # client_id    lock_type
575d05994bSSushil Singh    HMCID-01       ReadCase7,WriteCase6
585d05994bSSushil Singh    HMCID-01       WriteCase6,WriteCase6
595d05994bSSushil Singh    HMCID-01       WriteCase6,ReadCase7
60566daaf3SGeorge Keishing
61566daaf3SGeorge Keishing
62e33c6e6aSSushil SinghAcquire Lock After Reboot
63e33c6e6aSSushil Singh    [Documentation]  Acquire and release read and write locks after reboot.
64e33c6e6aSSushil Singh    [Tags]  Acquire_Lock_After_Reboot
65e33c6e6aSSushil Singh    [Template]  Verify Acquire Lock After Reboot
66e33c6e6aSSushil Singh
67e33c6e6aSSushil Singh    # client_id    lock_type
68e33c6e6aSSushil Singh    HMCID-01       ReadCase1
69e33c6e6aSSushil Singh    HMCID-01       ReadCase2
70e33c6e6aSSushil Singh    HMCID-01       ReadCase3
71e33c6e6aSSushil Singh    HMCID-01       WriteCase1
72e33c6e6aSSushil Singh    HMCID-01       WriteCase2
73e33c6e6aSSushil Singh    HMCID-01       WriteCase3
74e33c6e6aSSushil Singh
75e33c6e6aSSushil Singh
76d03f2ce1SSushil SinghAcquire And Release Lock In Loop
77d03f2ce1SSushil Singh    [Documentation]  Acquire and release read, write locks in loop.
78d03f2ce1SSushil Singh    [Tags]  Acquire_And_Release_Lock_In_Loop
79d03f2ce1SSushil Singh    [Template]  Verify Acquire And Release Lock In Loop
80566daaf3SGeorge Keishing
81d03f2ce1SSushil Singh    # client_id    lock_type
82d03f2ce1SSushil Singh    HMCID-01       ReadCase1
83d03f2ce1SSushil Singh    HMCID-01       ReadCase2
84d03f2ce1SSushil Singh    HMCID-01       ReadCase3
85d03f2ce1SSushil Singh    HMCID-01       WriteCase1
86d03f2ce1SSushil Singh    HMCID-01       WriteCase2
87d03f2ce1SSushil Singh    HMCID-01       WriteCase3
8885610eeeSVijay
8985610eeeSVijay
90977f8f58SSushil SinghFail To Acquire Read And Write In Single Request
91977f8f58SSushil Singh    [Documentation]  Fail to acquire read and write lock in single request.
92977f8f58SSushil Singh    [Tags]  Fail_To_Acquire_Read_And_Write_In_Single_Request
93977f8f58SSushil Singh    [Template]  Verify Fail To Acquire Read And Write In Single Request
94977f8f58SSushil Singh
95e3f2e3baSSushil Singh    # client_id    lock_type               status_code
96e3f2e3baSSushil Singh    HMCID-01       ReadCase1,WriteCase1    ${HTTP_CONFLICT}
97e3f2e3baSSushil Singh    HMCID-01       WriteCase1,ReadCase1    ${HTTP_CONFLICT}
98e3f2e3baSSushil Singh    HMCID-01       WriteCase1,WriteCase1   ${HTTP_CONFLICT}
99e3f2e3baSSushil Singh
100e3f2e3baSSushil Singh
101e3f2e3baSSushil SinghAcquire Read In Single Request
102e3f2e3baSSushil Singh    [Documentation]  Acquire read in single request.
103e3f2e3baSSushil Singh    [Tags]  Acquire_Read_In_Single_Request
104e3f2e3baSSushil Singh    [Template]  Verify Acquire Read In Single Request
105e3f2e3baSSushil Singh
106977f8f58SSushil Singh    # client_id    lock_type
107e3f2e3baSSushil Singh    HMCID-01       ReadCase1,ReadCase1
108977f8f58SSushil Singh
109977f8f58SSushil Singh
110df390b61SSushil SinghAcquire Multiple Lock Request At CEC Level
111df390b61SSushil Singh    [Documentation]  Acquire write lock on read lock under CEC level.
112df390b61SSushil Singh    [Tags]  Acquire_Multiple_Lock_Request_At_CEC_Level
113df390b61SSushil Singh    [Template]  Verify Acquire Multiple Lock Request At CEC Level
114df390b61SSushil Singh
115df390b61SSushil Singh    # client_id    lock_type
116df390b61SSushil Singh    HMCID-01       ReadCase4,WriteCase4
117df390b61SSushil Singh    HMCID-01       WriteCase5,ReadCase5
118df390b61SSushil Singh    HMCID-01       ReadCase6,WriteCase6
119df390b61SSushil Singh    HMCID-01       WriteCase7,ReadCase7
120df390b61SSushil Singh
121df390b61SSushil Singh
122d03f2ce1SSushil SinghVerify Release Of Valid Locks
123d03f2ce1SSushil Singh    [Documentation]  Release all valid locks.
124d03f2ce1SSushil Singh    [Tags]  Verify_Release_Of_Valid_Locks
125d03f2ce1SSushil Singh    [Template]  Acquire And Release Multiple Locks
126afdd2a1dSVijay
127d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
128d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
129d03f2ce1SSushil Singh    HMCID-02       ReadCase1,ReadCase1,ReadCase1    Session
130afdd2a1dSVijay
131afdd2a1dSVijay
13294116c61Ssusilsi7Release Lock When Session Deleted
13394116c61Ssusilsi7    [Documentation]  Release lock when session gets deleted.
13494116c61Ssusilsi7    [Tags]  Release_Lock_When_Session_Deleted
13594116c61Ssusilsi7    [Template]  Verify Release Lock When Session Deleted
13694116c61Ssusilsi7
13794116c61Ssusilsi7    # client_id    lock_type
13894116c61Ssusilsi7    HMCID-01       ReadCase1
13994116c61Ssusilsi7    HMCID-01       WriteCase1
14094116c61Ssusilsi7
14194116c61Ssusilsi7
14259011d08SSushil SinghFail To Release Lock With Invalid TransactionID
14359011d08SSushil Singh    [Documentation]  Fail to release lock with invalid transaction id.
14459011d08SSushil Singh    [Tags]  Fail_To_Release_Lock_With_Invalid_TransactionID
14559011d08SSushil Singh    [Template]  Verify Fail To Release Lock With Invalid TransactionID
14659011d08SSushil Singh
14759011d08SSushil Singh    # client_id    lock_type     release_lock_type
14859011d08SSushil Singh    HMCID-01       ReadCase1     Transaction
14943b0c063Ssusilsi7    HMCID-01       WriteCase1    Transaction
15059011d08SSushil Singh
15159011d08SSushil Singh
1521b59053dSSushil SinghFail To Release Multiple Lock With Invalid TransactionID
153d03f2ce1SSushil Singh    [Documentation]  Release in-valid lock result in fail.
1541b59053dSSushil Singh    [Tags]  Fail_To_Release_Multiple_Lock_With_Invalid_TransactionID
1551b59053dSSushil Singh    [Template]  Verify Fail To Release Multiple Lock With Invalid TransactionID
156afdd2a1dSVijay
157d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
158d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
159d03f2ce1SSushil Singh    12345          ReadCase2,ReadCase2,ReadCase2    Transaction
160d03f2ce1SSushil Singh    HMCID          ReadCase3,ReadCase3,ReadCase3    Transaction
161afdd2a1dSVijay
162afdd2a1dSVijay
1638bee358fSSushil SinghFail To Release Multiple Lock With Valid And Invalid TransactionID
1649614383dSGeorge Keishing    [Documentation]  Release multiple lock with valid and invalid transaction.
1658bee358fSSushil Singh    [Tags]  Fail_To_Release_Multiple_Lock_With_Valid_And_Invalid_TransactionID
1668bee358fSSushil Singh    [Template]  Verify Fail To Release Multiple Lock With Valid And Invalid TransactionID
1678bee358fSSushil Singh
1688bee358fSSushil Singh    # client_id    lock_type              release_lock_type
1698bee358fSSushil Singh    HMCID-01       ReadCase1,ReadCase1    Transaction
1708bee358fSSushil Singh
1718bee358fSSushil Singh
1721d7b996cSsusilsi7Fail To Release Lock With String As TransactionID Data Type
1731d7b996cSsusilsi7    [Documentation]  Fail to release lock with string as transaction id data type.
1741d7b996cSsusilsi7    [Tags]  Fail_To_Release_Lock_With_String_As_TransactionID_Data_Type
1751d7b996cSsusilsi7    [Template]  Verify Fail To Release Lock With TransactionID As String Type
1761d7b996cSsusilsi7
1771d7b996cSsusilsi7    # client_id    lock_type     release_lock_type
1781d7b996cSsusilsi7    HMCID-01       ReadCase1     Transaction
1791d7b996cSsusilsi7    HMCID-01       WriteCase1    Transaction
1801d7b996cSsusilsi7
1811d7b996cSsusilsi7
182d03f2ce1SSushil SinghFail To Release Lock For Another Session
183d03f2ce1SSushil Singh    [Documentation]  Failed to release locks from another session.
184d03f2ce1SSushil Singh    [Tags]  Fail_To_Release_Lock_For_Another_Session
185d03f2ce1SSushil Singh    [Template]  Verify Fail To Release Lock For Another Session
186afdd2a1dSVijay
187d03f2ce1SSushil Singh    # client_id          lock_type
188d03f2ce1SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
189afdd2a1dSVijay
190afdd2a1dSVijay
19176806df6SSushil SinghVerify Lock Is Not Persistent On BMC Reboot
19276806df6SSushil Singh    [Documentation]  Acquire lock and after reboot the locks are removed as no persistency
19376806df6SSushil Singh    ...  maintained.
19476806df6SSushil Singh    [Tags]  Verify_Lock_Is_Not_Persistent_On_BMC_Reboot
19576806df6SSushil Singh    [Template]  Acquire Lock On Resource
19676806df6SSushil Singh
19776806df6SSushil Singh    # client_id    lock_type     reboot_flag
19876806df6SSushil Singh    HMCID-01       ReadCase1     True
19976806df6SSushil Singh    HMCID-01       ReadCase2     True
20076806df6SSushil Singh    HMCID-01       ReadCase3     True
20176806df6SSushil Singh    HMCID-01       WriteCase1    True
20276806df6SSushil Singh    HMCID-01       WriteCase2    True
20376806df6SSushil Singh    HMCID-01       WriteCase3    True
20476806df6SSushil Singh
20576806df6SSushil Singh
206e33c6e6aSSushil SinghTest Invalid Resource ID Data Type Locking
207e33c6e6aSSushil Singh    [Documentation]  Failed to acquire lock for invalid resource id data type.
208e33c6e6aSSushil Singh    [Tags]  Test_Invalid_Resource_ID_Data_Type_Locking
209e33c6e6aSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Resource ID Data Type
210e33c6e6aSSushil Singh
211e33c6e6aSSushil Singh    # client_id    lock_type
212e33c6e6aSSushil Singh    HMCID-01       ReadCase1
213e33c6e6aSSushil Singh    HMCID-01       ReadCase2
214e33c6e6aSSushil Singh    HMCID-01       ReadCase3
215e33c6e6aSSushil Singh    HMCID-01       WriteCase1
216e33c6e6aSSushil Singh    HMCID-01       WriteCase2
217e33c6e6aSSushil Singh    HMCID-01       WriteCase3
218e33c6e6aSSushil Singh
219e33c6e6aSSushil Singh
220d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Type
221d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read, write lock for invalid lock data passed.
222d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Type
223d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
224afdd2a1dSVijay
225d03f2ce1SSushil Singh    # client_id    lock_type      message
226d03f2ce1SSushil Singh    HMCID-01       ReadCase1      ${BAD_REQUEST}
227d03f2ce1SSushil Singh    HMCID-01       ReadCase2      ${BAD_REQUEST}
228d03f2ce1SSushil Singh    HMCID-01       ReadCase3      ${BAD_REQUEST}
229d03f2ce1SSushil Singh    HMCID-01       ReadCase4      ${BAD_REQUEST}
230d03f2ce1SSushil Singh    HMCID-01       ReadCase5      ${BAD_REQUEST}
231d03f2ce1SSushil Singh    HMCID-01       WriteCase1     ${BAD_REQUEST}
232d03f2ce1SSushil Singh    HMCID-01       WriteCase2     ${BAD_REQUEST}
233d03f2ce1SSushil Singh    HMCID-01       WriteCase3     ${BAD_REQUEST}
234d03f2ce1SSushil Singh    HMCID-01       WriteCase4     ${BAD_REQUEST}
235d03f2ce1SSushil Singh    HMCID-01       WriteCase5     ${BAD_REQUEST}
236afdd2a1dSVijay
237afdd2a1dSVijay
238d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Flag
239d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid lock flag passed.
240d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
241d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
242afdd2a1dSVijay
243d03f2ce1SSushil Singh    # client_id    lock_type       message
244d03f2ce1SSushil Singh    HMCID-01       ReadCase6       ${BAD_REQUEST}
245d03f2ce1SSushil Singh    HMCID-01       ReadCase7       ${BAD_REQUEST}
246d03f2ce1SSushil Singh    HMCID-01       ReadCase8       ${BAD_REQUEST}
247d03f2ce1SSushil Singh    HMCID-01       ReadCase9       ${BAD_REQUEST}
248d03f2ce1SSushil Singh    HMCID-01       ReadCase10      ${BAD_REQUEST}
249d03f2ce1SSushil Singh    HMCID-01       ReadCase11      ${BAD_REQUEST}
250d03f2ce1SSushil Singh    HMCID-01       WriteCase6      ${BAD_REQUEST}
251d03f2ce1SSushil Singh    HMCID-01       WriteCase7      ${BAD_REQUEST}
252d03f2ce1SSushil Singh    HMCID-01       WriteCase8      ${BAD_REQUEST}
253d03f2ce1SSushil Singh    HMCID-01       WriteCase9      ${BAD_REQUEST}
254d03f2ce1SSushil Singh    HMCID-01       WriteCase10     ${BAD_REQUEST}
255d03f2ce1SSushil Singh    HMCID-01       WriteCase11     ${BAD_REQUEST}
256afdd2a1dSVijay
257afdd2a1dSVijay
25876806df6SSushil SinghCheck After Reboot Transaction ID Set To Default
25976806df6SSushil Singh    [Documentation]  After reboot, the transaction id starts with default i.e. 1,
26076806df6SSushil Singh    ...  if any lock is acquired.
26176806df6SSushil Singh    [Tags]  Check_After_Reboot_Transaction_ID_Set_To_Default
26276806df6SSushil Singh    [Template]  Verify Acquire And Release Lock In Loop
26376806df6SSushil Singh
26476806df6SSushil Singh    # client_id    lock_type     reboot_flag
26576806df6SSushil Singh    HMCID-01       ReadCase1     True
26676806df6SSushil Singh    HMCID-01       WriteCase1    True
26776806df6SSushil Singh
26876806df6SSushil Singh
269d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Segment Flag
270d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
271d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Flag
272d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
273d03f2ce1SSushil Singh
274d03f2ce1SSushil Singh    # client_id    lock_type       message
275d03f2ce1SSushil Singh    HMCID-01       ReadCase12      ${BAD_REQUEST}
276d03f2ce1SSushil Singh    HMCID-01       ReadCase13      ${BAD_REQUEST}
277d03f2ce1SSushil Singh    HMCID-01       ReadCase14      ${BAD_REQUEST}
278d03f2ce1SSushil Singh    HMCID-01       WriteCase12     ${BAD_REQUEST}
279d03f2ce1SSushil Singh    HMCID-01       WriteCase13     ${BAD_REQUEST}
280d03f2ce1SSushil Singh    HMCID-01       WriteCase14     ${BAD_REQUEST}
281afdd2a1dSVijay
282bace3005SSushil Singh
2833b3a7ecaSSushil SinghFail To Acquire Lock For Invalid Segment Data Type Flag
2843b3a7ecaSSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
2853b3a7ecaSSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Data_Type_Flag
2863b3a7ecaSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
2873b3a7ecaSSushil Singh
2883b3a7ecaSSushil Singh    # client_id    lock_type       message
2893b3a7ecaSSushil Singh    HMCID-01       ReadCase15      ${EMPTY}
2903b3a7ecaSSushil Singh    HMCID-01       ReadCase16      ${EMPTY}
2913b3a7ecaSSushil Singh    HMCID-01       ReadCase17      ${EMPTY}
2923b3a7ecaSSushil Singh    HMCID-01       ReadCase18      ${EMPTY}
2933b3a7ecaSSushil Singh    HMCID-01       WriteCase15     ${EMPTY}
2943b3a7ecaSSushil Singh    HMCID-01       WriteCase16     ${EMPTY}
2953b3a7ecaSSushil Singh    HMCID-01       WriteCase17     ${EMPTY}
2963b3a7ecaSSushil Singh    HMCID-01       WriteCase18     ${EMPTY}
2973b3a7ecaSSushil Singh
2983b3a7ecaSSushil Singh
299bace3005SSushil SinghGet Empty Lock Records For Session Where No Locks Acquired
300bace3005SSushil Singh    [Documentation]  If session does not acquire locks then get lock should return
301bace3005SSushil Singh    ...              empty lock records.
302bace3005SSushil Singh    [Tags]  Get_Empty_Lock_Records_For_Session_Where_No_Locks_Acquired
303bace3005SSushil Singh    [Template]  Verify No Locks Records For Session With No Acquired Lock
304bace3005SSushil Singh
305bace3005SSushil Singh    # client_id
306bace3005SSushil Singh    HMCID-01
307bace3005SSushil Singh
308728ef9c9SSushil Singh
309f9a536caSSushil SinghGet Lock Records Empty For Invalid Session
310f9a536caSSushil Singh    [Documentation]  Record of lock list is empty for invalid session.
311f9a536caSSushil Singh    [Tags]  Get_Lock_Records_Empty_For_Invalid_Session
312f9a536caSSushil Singh    [Template]  Verify Empty Lock Records For Invalid Session
313f9a536caSSushil Singh
314f9a536caSSushil Singh    # client_id
315f9a536caSSushil Singh    HMCID-01
316f9a536caSSushil Singh
317f9a536caSSushil Singh
318728ef9c9SSushil SinghGet Lock Records For Multiple Session
319728ef9c9SSushil Singh    [Documentation]  Get lock records of multiple session.
320728ef9c9SSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Session
321728ef9c9SSushil Singh    [Template]  Verify Lock Records Of Multiple Session
322728ef9c9SSushil Singh
323728ef9c9SSushil Singh    # client_ids         lock_type
324728ef9c9SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
325728ef9c9SSushil Singh
326728ef9c9SSushil Singh
327f9a536caSSushil SinghGet Lock Records For Multiple Invalid Session
328f9a536caSSushil Singh    [Documentation]  Record of lock list is empty for list of invalid session.
329f9a536caSSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Invalid_Session
330f9a536caSSushil Singh    [Template]  Verify Lock Records For Multiple Invalid Session
331f9a536caSSushil Singh
332f9a536caSSushil Singh    # client_id
333f9a536caSSushil Singh    HMCID-01
334f9a536caSSushil Singh
33511949a2cSSushil Singh
33611949a2cSSushil SinghGet Lock Records For Multiple Invalid And Valid Session
33711949a2cSSushil Singh    [Documentation]  Get record of lock from invalid and valid session.
33811949a2cSSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Invalid_And_Valid_Session
33911949a2cSSushil Singh    [Template]  Verify Lock Records For Multiple Invalid And Valid Session
34011949a2cSSushil Singh
34111949a2cSSushil Singh    # client_id          lock_type
34211949a2cSSushil Singh    HMCID-01,HMCID-02    ReadCase1
34311949a2cSSushil Singh
344bc331e22SVijay*** Keywords ***
345bc331e22SVijay
346d03f2ce1SSushil SinghCreate Redfish Session With ClientID
347d03f2ce1SSushil Singh    [Documentation]  Create redifish session with client id.
348d03f2ce1SSushil Singh    [Arguments]  ${client_id}
34985610eeeSVijay
35085610eeeSVijay    # Description of argument(s):
351d03f2ce1SSushil Singh    # client_id    This client id can contain string value
352d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
35385610eeeSVijay
354d03f2ce1SSushil Singh    ${session_info}=  Create Dictionary
355f4de7d77SSushil Singh
356f4de7d77SSushil Singh    ${session}=  Redfish Login  kwargs="Context": "${client_id}"
35785610eeeSVijay
358d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  SessionIDs  ${session['Id']}
359f4de7d77SSushil Singh    Set To Dictionary  ${session_info}  ClientID  ${session["Context"]}
36085610eeeSVijay
361409df05dSGeorge Keishing    RETURN  ${session_info}
36285610eeeSVijay
36385610eeeSVijay
364d03f2ce1SSushil SinghRW General Dictionary
36516b3c7bfSGeorge Keishing    [Documentation]  Create dictionary of lock request.
366d03f2ce1SSushil Singh    [Arguments]  ${read_case}  ${res_id}
367bc331e22SVijay
368bc331e22SVijay    # Description of argument(s):
369d03f2ce1SSushil Singh    # read_case    Read or Write lock type.
370d03f2ce1SSushil Singh    # res_id       Resource id.
371bc331e22SVijay
372d03f2ce1SSushil Singh    ${request_dict}=  Create Dictionary
373566daaf3SGeorge Keishing
374d03f2ce1SSushil Singh    FOR  ${key}  IN  @{read_case.keys()}
375d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  LockType  ${key}
376d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  SegmentFlags  ${read_case["${key}"]}
377d03f2ce1SSushil Singh    END
378bc331e22SVijay
379d03f2ce1SSushil Singh    Set To Dictionary  ${request_dict}  ResourceID  ${res_id}
380d03f2ce1SSushil Singh
381409df05dSGeorge Keishing    RETURN  ${request_dict}
382bc331e22SVijay
383bc331e22SVijay
384d03f2ce1SSushil SinghReturn Description Of Response
385d03f2ce1SSushil Singh    [Documentation]  Return description of REST response.
386bc331e22SVijay    [Arguments]  ${resp_text}
387bc331e22SVijay
388bc331e22SVijay    # Description of argument(s):
389d03f2ce1SSushil Singh    # resp_text    REST response body.
390bc331e22SVijay
391d03f2ce1SSushil Singh    # resp_text after successful partition file upload looks like:
392d03f2ce1SSushil Singh    # {
393d03f2ce1SSushil Singh    #    "Description": "File Created"
394d03f2ce1SSushil Singh    # }
395bc331e22SVijay
396d03f2ce1SSushil Singh    ${message}=  Evaluate  json.loads('''${resp_text}''')  json
397d03f2ce1SSushil Singh
398409df05dSGeorge Keishing    RETURN  ${message}
399bc331e22SVijay
400bc331e22SVijay
401a7d71f02SSushil SinghVerify Redfish Session Deleted
402a7d71f02SSushil Singh    [Documentation]  Verify the redfish session is deleted.
403a7d71f02SSushil Singh    [Arguments]  ${session_info}
404a7d71f02SSushil Singh
405a7d71f02SSushil Singh    # Description of argument(s):
406a7d71f02SSushil Singh    # session_info    Session information are stored in dictionary.
407a7d71f02SSushil Singh
408a7d71f02SSushil Singh    # ${session_info} = {
409a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
410a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
411a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
412a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
413a7d71f02SSushil Singh    # }
414a7d71f02SSushil Singh
415a7d71f02SSushil Singh    # SessionIDs   : Session IDs
416a7d71f02SSushil Singh    # ClientID     : Client ID
417a7d71f02SSushil Singh    # SessionToken : Session token
418a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
419a7d71f02SSushil Singh
420a7d71f02SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions
421a7d71f02SSushil Singh
422a7d71f02SSushil Singh    FOR  ${session}  IN  @{sessions['Members']}
4238a3efe7cSSushil Singh      Should Not Be Equal As Strings
4248a3efe7cSSushil Singh      ...  session  ['/redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}']
425a7d71f02SSushil Singh    END
426a7d71f02SSushil Singh
427a7d71f02SSushil Singh
428a7d71f02SSushil SinghVerify Redfish List Of Session Deleted
429a7d71f02SSushil Singh    [Documentation]  Verify all the list of redfish session is deleted.
430a7d71f02SSushil Singh    [Arguments]  ${session_info_list}
431a7d71f02SSushil Singh
432a7d71f02SSushil Singh    # Description of argument(s):
433a7d71f02SSushil Singh    # session_info_list    List contains individual session record are stored in dictionary.
434a7d71f02SSushil Singh
435a7d71f02SSushil Singh    # ${session_info_list} = [{
436a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
437a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
438a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
439a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
440a7d71f02SSushil Singh    # }]
441a7d71f02SSushil Singh
442a7d71f02SSushil Singh    # SessionIDs   : Session IDs
443a7d71f02SSushil Singh    # ClientID     : Client ID
444a7d71f02SSushil Singh    # SessionToken : Session token
445a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
446a7d71f02SSushil Singh
447a7d71f02SSushil Singh    FOR  ${session_record}  IN  @{session_info_list}
448a7d71f02SSushil Singh      Verify Redfish Session Deleted  ${session_record}
449a7d71f02SSushil Singh    END
450a7d71f02SSushil Singh
451a7d71f02SSushil Singh
452d03f2ce1SSushil SinghRedfish Post Acquire Lock
453d03f2ce1SSushil Singh    [Documentation]  Acquire and release lock.
454d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
455bc331e22SVijay
456bc331e22SVijay    # Description of argument(s):
457d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
458d03f2ce1SSushil Singh    # status_code    HTTP status code.
459bc331e22SVijay
460e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Lock  ${lock_type}
461fbd67007SGeorge Keishing    ${lock_dict_param}=  Convert JSON To String  ${lock_dict_param}
4628a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
4638a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
464fbd67007SGeorge Keishing    ...  expected_status=any
465d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
466df390b61SSushil Singh
467df390b61SSushil Singh    Run Keyword If  ${status_code} == ${HTTP_BAD_REQUEST}
468df390b61SSushil Singh    ...    Valid Value  ${BAD_REQUEST}  ['${resp.content}']
469df390b61SSushil Singh    ...  ELSE
470df390b61SSushil Singh    ...    Run Keyword And Return  Return Description Of Response  ${resp.content}
471bc331e22SVijay
472409df05dSGeorge Keishing    RETURN  ${resp}
473bc331e22SVijay
474bc331e22SVijay
475977f8f58SSushil SinghRedfish Post Acquire List Lock
476977f8f58SSushil Singh    [Documentation]  Acquire and release lock.
477977f8f58SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
478977f8f58SSushil Singh
479977f8f58SSushil Singh    # Description of argument(s):
480977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
481977f8f58SSushil Singh    # status_code    HTTP status code.
482977f8f58SSushil Singh
483977f8f58SSushil Singh    ${lock_dict_param}=  Create Data To Acquire List Of Lock  ${lock_type}
484fbd67007SGeorge Keishing    ${lock_dict_param}=  Convert JSON To String  ${lock_dict_param}
4858a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
4868a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
487fbd67007SGeorge Keishing    ...   expected_status=any
488977f8f58SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
489977f8f58SSushil Singh
490e3f2e3baSSushil Singh    Run Keyword If  ${status_code} == ${HTTP_CONFLICT}
491e3f2e3baSSushil Singh    ...    Should Be Equal As Strings  ${CONFLICT_RQUEST}  ${resp.content}
492e3f2e3baSSushil Singh    ...  ELSE
493e3f2e3baSSushil Singh    ...    Run Keyword And Return  Return Description Of Response  ${resp.content}
494e3f2e3baSSushil Singh
495409df05dSGeorge Keishing    RETURN  ${resp}
496977f8f58SSushil Singh
497977f8f58SSushil Singh
498d03f2ce1SSushil SinghRedfish Post Acquire Invalid Lock
499d03f2ce1SSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock.
500d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${message}  ${status_code}=${HTTP_OK}
501bc331e22SVijay
502bc331e22SVijay    # Description of argument(s):
503d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
504d03f2ce1SSushil Singh    # message        Return message from URI.
505d03f2ce1SSushil Singh    # status_code    HTTP status code.
506bc331e22SVijay
507e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Invalid Lock  ${lock_type}
508fbd67007SGeorge Keishing    ${lock_dict_param}=  Convert JSON To String  ${lock_dict_param}
5098a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
5108a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
511d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
5123b3a7ecaSSushil Singh    Run Keyword If  '${message}' != '${EMPTY}'
5133b3a7ecaSSushil Singh    ...  Valid Value  message  ['${resp.content}']
514d03f2ce1SSushil Singh
515409df05dSGeorge Keishing    RETURN  ${resp}
516bc331e22SVijay
517bc331e22SVijay
518e33c6e6aSSushil SinghRedfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
519e33c6e6aSSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock with invalid data type of resource id.
520e33c6e6aSSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
521e33c6e6aSSushil Singh
522e33c6e6aSSushil Singh    # Description of argument(s):
523e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
524e33c6e6aSSushil Singh    # status_code    HTTP status code.
525e33c6e6aSSushil Singh
5268a3efe7cSSushil Singh    ${lock_dict_param}=
5278a3efe7cSSushil Singh    ...  Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID  ${lock_type}
528fbd67007SGeorge Keishing    ${lock_dict_param}=  Convert JSON To String  ${lock_dict_param}
5298a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
5308a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
531e33c6e6aSSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
532e33c6e6aSSushil Singh
533409df05dSGeorge Keishing    RETURN  ${resp}
534e33c6e6aSSushil Singh
535e33c6e6aSSushil Singh
536d03f2ce1SSushil SinghForm Data To Acquire Lock
53716b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for lock request.
538d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
539d03f2ce1SSushil Singh
540d03f2ce1SSushil Singh    # Description of argument(s):
541d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
542d03f2ce1SSushil Singh
543d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
544d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
545d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
546d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
547d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
548e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
549d03f2ce1SSushil Singh
550409df05dSGeorge Keishing    RETURN  ${lock_request_dict}
551e33c6e6aSSushil Singh
552e33c6e6aSSushil Singh
553977f8f58SSushil SinghCreate Data To Acquire List Of Lock
55416b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for list of lock request.
555977f8f58SSushil Singh    [Arguments]  ${lock_type_list}
556977f8f58SSushil Singh
557977f8f58SSushil Singh    # Description of argument(s):
558977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
559977f8f58SSushil Singh
560977f8f58SSushil Singh    ${temp_list}=  Create List
561977f8f58SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
562977f8f58SSushil Singh
563977f8f58SSushil Singh    FOR  ${lock_type}  IN  @{lock_type_list}
564977f8f58SSushil Singh      ${resp}=  RW General Dictionary
565977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
566977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["ResourceID"]}
567977f8f58SSushil Singh      Append To List  ${temp_list}  ${resp}
568977f8f58SSushil Singh    END
569977f8f58SSushil Singh
570977f8f58SSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
571977f8f58SSushil Singh
572409df05dSGeorge Keishing    RETURN  ${lock_request_dict}
573977f8f58SSushil Singh
574977f8f58SSushil Singh
575e33c6e6aSSushil SinghForm Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
57616b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for in-valid lock request.
577e33c6e6aSSushil Singh    [Arguments]  ${lock_type}
578e33c6e6aSSushil Singh
579e33c6e6aSSushil Singh    # Description of argument(s):
580e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
581e33c6e6aSSushil Singh
582e33c6e6aSSushil Singh    ${lock_res_info}=  Get Lock Resource Information
583e33c6e6aSSushil Singh    ${resp}=  RW General Dictionary
584e33c6e6aSSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
585e33c6e6aSSushil Singh    ...    ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
586e33c6e6aSSushil Singh    ${temp_list}=  Create List  ${resp}
587e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
588e33c6e6aSSushil Singh
589409df05dSGeorge Keishing    RETURN  ${lock_request_dict}
590d03f2ce1SSushil Singh
591d03f2ce1SSushil Singh
592d03f2ce1SSushil SinghForm Data To Acquire Invalid Lock
59316b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for in-valid lock request.
594d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
595d03f2ce1SSushil Singh
596d03f2ce1SSushil Singh    # Description of argument(s):
597d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
598d03f2ce1SSushil Singh
599d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
600d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
601d03f2ce1SSushil Singh    ...    ${lock_res_info["Invalid Case"]["${lock_type}"]}
602d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
603d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
604e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
605d03f2ce1SSushil Singh
606409df05dSGeorge Keishing    RETURN  ${lock_request_dict}
607d03f2ce1SSushil Singh
608d03f2ce1SSushil Singh
609d03f2ce1SSushil SinghGet Locks List On Resource
610bc331e22SVijay    [Documentation]  Get locks list.
611d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${exp_status_code}=${HTTP_OK}
612bc331e22SVijay
613bc331e22SVijay    # Description of argument(s):
614d03f2ce1SSushil Singh    # session_info       Session information in dict.
615d03f2ce1SSushil Singh    # exp_status_code    Expected HTTP status code.
616bc331e22SVijay
617d03f2ce1SSushil Singh    ${data}=  Set Variable  {"SessionIDs": ["${session_info['SessionIDs']}"]}
618566daaf3SGeorge Keishing    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
619566daaf3SGeorge Keishing    ...  data=${data}
620bc331e22SVijay    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
621bc331e22SVijay
622409df05dSGeorge Keishing    RETURN  ${locks["Records"]}
623bc331e22SVijay
624bc331e22SVijay
625d03f2ce1SSushil SinghVerify Lock On Resource
626d03f2ce1SSushil Singh    [Documentation]  Verify lock on resource.
627d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${transaction_id}
628bc331e22SVijay
629bc331e22SVijay    # Description of argument(s):
630d03f2ce1SSushil Singh    # session_info      Session information in dict.
631d03f2ce1SSushil Singh    # transaction_id    Transaction id in list stored in dict.
632bc331e22SVijay
633d03f2ce1SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
634d03f2ce1SSushil Singh    Rprint Vars  sessions
635d03f2ce1SSushil Singh    ${lock_list}=  Get Locks List On Resource  ${session_info}
636d03f2ce1SSushil Singh    ${lock_length}=  Get Length  ${lock_list}
637d03f2ce1SSushil Singh    ${tran_id_length}=  Get Length  ${transaction_id}
638d03f2ce1SSushil Singh    Should Be Equal As Integers  ${tran_id_length}  ${lock_length}
639afdd2a1dSVijay
640d03f2ce1SSushil Singh    FOR  ${tran_id}  ${lock}  IN ZIP  ${transaction_id}  ${lock_list}
641d03f2ce1SSushil Singh      Valid Value  session_info['ClientID']  ['${lock['HMCID']}']
642d03f2ce1SSushil Singh      Valid Value  session_info['SessionIDs']  ['${lock['SessionID']}']
643d03f2ce1SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock['TransactionID']}
644bc331e22SVijay    END
645bc331e22SVijay
646bc331e22SVijay
647d03f2ce1SSushil SinghAcquire Lock On Resource
648d03f2ce1SSushil Singh    [Documentation]  Acquire lock on resource.
649d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${reboot_flag}=False
650bc331e22SVijay
651bc331e22SVijay    # Description of argument(s):
652d03f2ce1SSushil Singh    # client_id    This client id can contain string value
653d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
654d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
655d03f2ce1SSushil Singh    # reboot_flag  Flag is used to run reboot the BMC code.
656d03f2ce1SSushil Singh    #               (e.g. True or False).
657bc331e22SVijay
6588a3efe7cSSushil Singh    ${trans_id_emptylist}=  Create List
659d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
6608a3efe7cSSushil Singh
661d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
662d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
663d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
6648a3efe7cSSushil Singh
665d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
666566daaf3SGeorge Keishing
667e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
668bc331e22SVijay
669d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'True'
6708a3efe7cSSushil Singh    ...  Run Keywords  Redfish BMC Reset Operation  AND
671e33c6e6aSSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
67207b25344SSushil Singh    ...  Wait Until Keyword Succeeds  3 min  10 sec  Redfish BMC Match States  match_state=Enabled  AND
6738a3efe7cSSushil Singh    ...  Is BMC Standby  AND
6748a3efe7cSSushil Singh    ...  Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
675bc331e22SVijay
676d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'False'
677d03f2ce1SSushil Singh    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
678bc331e22SVijay
679d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
680d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
681d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
682bc331e22SVijay
683bc331e22SVijay
684d03f2ce1SSushil SinghForm Data To Release Lock
685d03f2ce1SSushil Singh    [Documentation]  Create a dictonay to release lock.
686d03f2ce1SSushil Singh    [Arguments]  ${trans_id_list}
687355daac7SVijay
688355daac7SVijay    # Description of argument(s):
689d03f2ce1SSushil Singh    # trans_id_list
690355daac7SVijay
691d03f2ce1SSushil Singh    @{tran_ids}=  Create List
692355daac7SVijay
693d03f2ce1SSushil Singh    FOR  ${item}  IN  @{trans_id_list}
694d03f2ce1SSushil Singh      Append To List  ${tran_ids}  ${item['TransactionID']}
695d03f2ce1SSushil Singh    END
696d03f2ce1SSushil Singh
697409df05dSGeorge Keishing    RETURN  ${tran_ids}
698d03f2ce1SSushil Singh
699d03f2ce1SSushil Singh
700d03f2ce1SSushil SinghRelease Locks On Resource
701d03f2ce1SSushil Singh    [Documentation]  Redfish request to release a lock.
7028a3efe7cSSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}  ${release_lock_type}=Transaction
7038a3efe7cSSushil Singh    ...  ${status_code}=${HTTP_OK}
704d03f2ce1SSushil Singh
705d03f2ce1SSushil Singh    # Description of argument(s):
706d03f2ce1SSushil Singh    # session_info        Session information in dict.
707d03f2ce1SSushil Singh    # trans_id_list       Transaction id list.
708d03f2ce1SSushil Singh    # release_lock_type   Release lock by Transaction, Session.
709d03f2ce1SSushil Singh    # status_code         HTTP status code.
710d03f2ce1SSushil Singh
711d03f2ce1SSushil Singh    ${tran_ids}=  Form Data To Release Lock  ${trans_id_list}
712d03f2ce1SSushil Singh    ${data}=  Set Variable  {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
713d03f2ce1SSushil Singh    ${data}=  Evaluate  json.dumps(${data})  json
714d03f2ce1SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock  data=${data}
715d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
716d03f2ce1SSushil Singh
717d03f2ce1SSushil Singh
718df390b61SSushil SinghRelease locks And Delete Session
719df390b61SSushil Singh    [Documentation]  Release locks and delete redfish session.
720df390b61SSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}
721df390b61SSushil Singh
722df390b61SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}
723df390b61SSushil Singh
724df390b61SSushil Singh    ${trans_id_emptylist}=  Create List
725df390b61SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
726df390b61SSushil Singh
727df390b61SSushil Singh    Redfish Delete Session  ${session_info}
728df390b61SSushil Singh
729df390b61SSushil Singh
730d03f2ce1SSushil SinghAcquire Lock On Another Lock
731d03f2ce1SSushil Singh    [Documentation]  Acquire lock on another lock.
732d03f2ce1SSushil Singh    [Arguments]  ${client_id}
733d03f2ce1SSushil Singh
734d03f2ce1SSushil Singh    # Description of argument(s):
735d03f2ce1SSushil Singh    # client_id    This client id can contain string value
736d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
737d03f2ce1SSushil Singh
738d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
739d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
740d03f2ce1SSushil Singh
741d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
742d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
743d03f2ce1SSushil Singh
744d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
745d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
746d03f2ce1SSushil Singh
747d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
748d03f2ce1SSushil Singh
749df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
750d03f2ce1SSushil Singh
751d03f2ce1SSushil Singh
752977f8f58SSushil SinghVerify Fail To Acquire Read And Write In Single Request
753977f8f58SSushil Singh    [Documentation]  Verify fail to acquire read and write lock passed in single request.
754e3f2e3baSSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${status_code}
755e3f2e3baSSushil Singh
756e3f2e3baSSushil Singh    # Description of argument(s):
757e3f2e3baSSushil Singh    # client_id     This client id can contain string value
758e3f2e3baSSushil Singh    #               (e.g. 12345, "HMCID").
759e3f2e3baSSushil Singh    # lock_type     Read lock or Write lock.
760e3f2e3baSSushil Singh    # status_code   HTTP status code
761e3f2e3baSSushil Singh
762e3f2e3baSSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
763e3f2e3baSSushil Singh
764e3f2e3baSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
765e3f2e3baSSushil Singh    ${trans_id}=  Redfish Post Acquire List Lock  ${lock_type_list}  status_code=${status_code}
766e3f2e3baSSushil Singh    Redfish Delete Session  ${session_info}
767e3f2e3baSSushil Singh
768e3f2e3baSSushil Singh
769e3f2e3baSSushil SinghVerify Acquire Read In Single Request
770e3f2e3baSSushil Singh    [Documentation]  Verify acquire read in single request.
771977f8f58SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
772977f8f58SSushil Singh
773977f8f58SSushil Singh    # Description of argument(s):
774977f8f58SSushil Singh    # client_id    This client id can contain string value
775977f8f58SSushil Singh    #              (e.g. 12345, "HMCID").
776977f8f58SSushil Singh    # lock_type    Read lock or Write lock.
777977f8f58SSushil Singh
778e3f2e3baSSushil Singh    ${trans_id_list}=  Create List
779977f8f58SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
780977f8f58SSushil Singh
781977f8f58SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
782e3f2e3baSSushil Singh    ${trans_id}=  Redfish Post Acquire List Lock  ${lock_type_list}
783e3f2e3baSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
784e3f2e3baSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
785e3f2e3baSSushil Singh
786e3f2e3baSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
787e3f2e3baSSushil Singh    Remove From List  ${trans_id_list}  1
788e3f2e3baSSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}
789e3f2e3baSSushil Singh
790977f8f58SSushil Singh    Redfish Delete Session  ${session_info}
791977f8f58SSushil Singh
792977f8f58SSushil Singh
793d03f2ce1SSushil SinghVerify Empty Lock Records For Invalid Session
794d03f2ce1SSushil Singh    [Documentation]  Verify no lock record found for invalid session.
795d03f2ce1SSushil Singh    [Arguments]  ${client_id}
796d03f2ce1SSushil Singh
797d03f2ce1SSushil Singh    # Description of argument(s):
798d03f2ce1SSushil Singh    # client_id    This client id can contain string value
799d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
800d03f2ce1SSushil Singh
801d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_id}
802d03f2ce1SSushil Singh
803d03f2ce1SSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
804d03f2ce1SSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
805d03f2ce1SSushil Singh
806d03f2ce1SSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
807d03f2ce1SSushil Singh    set to dictionary  ${session_info2}  SessionIDs  xxyXyyYZZz
808d03f2ce1SSushil Singh
809d03f2ce1SSushil Singh    ${lock_list2}=  Get Locks List On Resource  ${session_info2}
810f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list2}
811d03f2ce1SSushil Singh
812f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
813d03f2ce1SSushil Singh
814d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
815d03f2ce1SSushil Singh
816d03f2ce1SSushil Singh
817d03f2ce1SSushil SinghVerify Acquire Lock Fails On Another Lock
818d03f2ce1SSushil Singh    [Documentation]  Verify acquire lock on another lock fails.
819d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
820d03f2ce1SSushil Singh
821d03f2ce1SSushil Singh    # Description of argument(s):
822d03f2ce1SSushil Singh    # client_id    This client id can contain string value
823d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
824d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
825d03f2ce1SSushil Singh
826d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
827d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
828d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
829d03f2ce1SSushil Singh
830d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
831d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
832d03f2ce1SSushil Singh
833d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
834d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
835d03f2ce1SSushil Singh
836df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
837d03f2ce1SSushil Singh
838d03f2ce1SSushil Singh
839e33c6e6aSSushil SinghVerify Acquire Lock After Reboot
840e33c6e6aSSushil Singh    [Documentation]  Acquire read and write lock after the reboot and release lock.
841e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
842e33c6e6aSSushil Singh
843e33c6e6aSSushil Singh    # Description of argument(s):
844e33c6e6aSSushil Singh    # client_id    This client id can contain string value
845e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
846e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
847e33c6e6aSSushil Singh
848e33c6e6aSSushil Singh    ${trans_id_list}=  Create List
849f9a536caSSushil Singh    ${session_info}=  Create Session With ClientID  ${client_id}
850ac229c79SSushil Singh
851e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
852ac229c79SSushil Singh    Redfish BMC Reset Operation
853e33c6e6aSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}
85407b25344SSushil Singh    Wait Until Keyword Succeeds  3 min  10 sec  Redfish BMC Match States  match_state=Enabled
855ac229c79SSushil Singh    Is BMC Standby
856e33c6e6aSSushil Singh
857e33c6e6aSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
858e33c6e6aSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
859e33c6e6aSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
860e33c6e6aSSushil Singh
861df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
862df390b61SSushil Singh
863df390b61SSushil Singh
864df390b61SSushil SinghVerify Acquire Multiple Lock Request At CEC Level
865df390b61SSushil Singh    [Documentation]  Acquire lock in loop.
866df390b61SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
867df390b61SSushil Singh
868df390b61SSushil Singh    # Description of argument(s):
869df390b61SSushil Singh    # client_id    This client id can contain string value
870df390b61SSushil Singh    #              (e.g. 12345, "HMCID").
871df390b61SSushil Singh    # lock_type    Read lock or Write lock.
872df390b61SSushil Singh
873df390b61SSushil Singh    ${trans_id_list}=  Create List
874df390b61SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
875df390b61SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
876df390b61SSushil Singh
877df390b61SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
878df390b61SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
879df390b61SSushil Singh
880df390b61SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
881df390b61SSushil Singh
882df390b61SSushil Singh    Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
883df390b61SSushil Singh
884df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
885e33c6e6aSSushil Singh
886e33c6e6aSSushil Singh
8878d420bf6SSushil SinghPost Reboot Acquire Lock
8888d420bf6SSushil Singh    [Documentation]  Post reboot acquire lock and verify the transaction id is 1.
8898d420bf6SSushil Singh    [Arguments]  ${session_info}  ${lock_type}
8908d420bf6SSushil Singh
8918d420bf6SSushil Singh    # Description of argument(s):
8928d420bf6SSushil Singh    # session_info     Session information.
8938d420bf6SSushil Singh    # lock_type        Read lock or Write lock.
8948d420bf6SSushil Singh
8958d420bf6SSushil Singh    ${trans_id_list}=  Create List
8968d420bf6SSushil Singh    ${trans_id_list_var}=  Create List
8978d420bf6SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
8988d420bf6SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
8998d420bf6SSushil Singh    Append To List  ${trans_id_list_var}  ${default_trans_id}
9008d420bf6SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
9018d420bf6SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list_var}
9028d420bf6SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
9038d420bf6SSushil Singh    ${trans_id_emptylist}=  Create List
9048d420bf6SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
9058d420bf6SSushil Singh
9068d420bf6SSushil Singh
907d03f2ce1SSushil SinghVerify Acquire And Release Lock In Loop
908d03f2ce1SSushil Singh    [Documentation]  Acquire lock in loop.
9098d420bf6SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${reboot_flag}=False
910d03f2ce1SSushil Singh
911d03f2ce1SSushil Singh    # Description of argument(s):
912d03f2ce1SSushil Singh    # client_id    This client id can contain string value
913d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
914d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
9158d420bf6SSushil Singh    # reboot_flag  Flag is used to run reboot the BMC code.
9168d420bf6SSushil Singh    #               (e.g. True or False).
917d03f2ce1SSushil Singh
918d03f2ce1SSushil Singh    FOR  ${count}  IN RANGE  1  11
919d03f2ce1SSushil Singh      ${trans_id_list}=  Create List
920d03f2ce1SSushil Singh      ${session_info}=  Create Redfish Session With ClientID  ${client_id}
921d03f2ce1SSushil Singh      ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
922d03f2ce1SSushil Singh      Append To List  ${trans_id_list}  ${trans_id}
923d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_list}
924d03f2ce1SSushil Singh      Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
925d03f2ce1SSushil Singh      ${trans_id_emptylist}=  Create List
926d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
9278d420bf6SSushil Singh      Redfish Delete Session  ${session_info}
928d03f2ce1SSushil Singh    END
929d03f2ce1SSushil Singh
9308d420bf6SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
9318d420bf6SSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
9328d420bf6SSushil Singh
9338d420bf6SSushil Singh    Run Keyword If  '${reboot_flag}' == 'True'
9348d420bf6SSushil Singh    ...  Run Keywords  Redfish BMC Reset Operation  AND
9358d420bf6SSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
93607b25344SSushil Singh    ...  Wait Until Keyword Succeeds  3 min  10 sec  Redfish BMC Match States  match_state=Enabled  AND
9378d420bf6SSushil Singh    ...  Is BMC Standby  AND
9388d420bf6SSushil Singh    ...  Post Reboot Acquire Lock  ${session_info}  ${lock_type}
939d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
940d03f2ce1SSushil Singh
941d03f2ce1SSushil Singh
942d03f2ce1SSushil SinghAcquire And Release Multiple Locks
9439bfdf8a7SGeorge Keishing    [Documentation]  Acquire multiple locks on resource.
944d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
945d03f2ce1SSushil Singh
946d03f2ce1SSushil Singh    # Description of argument(s):
947d03f2ce1SSushil Singh    # client_id          This client id can contain string value
948d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
949d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
950d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
951d03f2ce1SSushil Singh
952d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
953d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
954d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
955d03f2ce1SSushil Singh
956d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
957d03f2ce1SSushil Singh
958d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
959d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
960d03f2ce1SSushil Singh
961d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
962d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
963d03f2ce1SSushil Singh
964d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
965d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
966d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
967d03f2ce1SSushil Singh
968d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
969d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
970d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
971d03f2ce1SSushil Singh
972d03f2ce1SSushil Singh
97394116c61Ssusilsi7Verify Release Lock When Session Deleted
97494116c61Ssusilsi7    [Documentation]  Verify lock get released when session are deleted.
97594116c61Ssusilsi7    [Arguments]  ${client_id}  ${lock_type}
97694116c61Ssusilsi7
97794116c61Ssusilsi7    # Description of argument(s):
97894116c61Ssusilsi7    # client_ids    This client id can contain string value
97994116c61Ssusilsi7    #               (e.g. 12345, "HMCID").
98094116c61Ssusilsi7    # lock_type     Read lock or Write lock.
98194116c61Ssusilsi7
98294116c61Ssusilsi7    ${trans_id_list}=  Create List
98394116c61Ssusilsi7    @{lock_type_list}=  Split String  ${lock_type}  ,
98494116c61Ssusilsi7
98594116c61Ssusilsi7    ${pre_session_info}=  Create Redfish Session With ClientID  ${client_id}
98694116c61Ssusilsi7
98794116c61Ssusilsi7    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
98894116c61Ssusilsi7    Append To List  ${trans_id_list}  ${trans_id}
98994116c61Ssusilsi7    Verify Lock On Resource  ${pre_session_info}  ${trans_id_list}
99094116c61Ssusilsi7
99194116c61Ssusilsi7    Redfish Delete Session  ${pre_session_info}
99294116c61Ssusilsi7    ${post_session_info}=  Create Redfish Session With ClientID  ${client_id}
99394116c61Ssusilsi7    ${resp}=  Get Locks List On Resource With Session List  ${pre_session_info}  ${HTTP_BAD_REQUEST}
99494116c61Ssusilsi7
99594116c61Ssusilsi7    Redfish Delete Session  ${post_session_info}
99694116c61Ssusilsi7
99794116c61Ssusilsi7
99894116c61Ssusilsi7
99959011d08SSushil SinghVerify Fail To Release Lock With Invalid TransactionID
100016b3c7bfSGeorge Keishing    [Documentation]  Verify fail to be release lock with invalid transaction ID.
100159011d08SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
100259011d08SSushil Singh
100359011d08SSushil Singh    # Description of argument(s):
100459011d08SSushil Singh    # client_id          This client id can contain string value
100559011d08SSushil Singh    #                    (e.g. 12345, "HMCID").
100659011d08SSushil Singh    # lock_type          Read lock or Write lock.
100759011d08SSushil Singh    # release_lock_type  The value can be Transaction or Session.
100859011d08SSushil Singh
100959011d08SSushil Singh    ${trans_id_list}=  Create List
101059011d08SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
101159011d08SSushil Singh
101259011d08SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
101359011d08SSushil Singh
101459011d08SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
101559011d08SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
101659011d08SSushil Singh    ${value}=  Evaluate  ${value} + 10
101759011d08SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
101859011d08SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
101959011d08SSushil Singh
102059011d08SSushil Singh    Release Locks On Resource
102159011d08SSushil Singh    ...  ${session_info}  ${trans_id_list}
102259011d08SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
102359011d08SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
102459011d08SSushil Singh
102559011d08SSushil Singh    ${trans_id_emptylist}=  Create List
102659011d08SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
102759011d08SSushil Singh    Redfish Delete Session  ${session_info}
102859011d08SSushil Singh
102959011d08SSushil Singh
10301b59053dSSushil SinghVerify Fail To Release Multiple Lock With Invalid TransactionID
10311b59053dSSushil Singh    [Documentation]  Verify release multiple locks with invalid transaction ID fails.
1032d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
1033d03f2ce1SSushil Singh
1034d03f2ce1SSushil Singh    # Description of argument(s):
1035d03f2ce1SSushil Singh    # client_id          This client id can contain string value
1036d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
1037d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
1038d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
1039d03f2ce1SSushil Singh
1040d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
1041d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
1042d03f2ce1SSushil Singh
1043d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1044d03f2ce1SSushil Singh
1045d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1046d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
1047d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
1048d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
1049d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
1050d03f2ce1SSushil Singh
1051d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1052d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
1053d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
1054d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
1055d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
1056d03f2ce1SSushil Singh
1057d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
1058d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
1059d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
1060d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
1061d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
1062d03f2ce1SSushil Singh
1063d03f2ce1SSushil Singh    Release Locks On Resource
1064d03f2ce1SSushil Singh    ...  ${session_info}  ${trans_id_list}
1065d03f2ce1SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
1066d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
1067d03f2ce1SSushil Singh
1068d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
1069d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
1070d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
1071d03f2ce1SSushil Singh
1072d03f2ce1SSushil Singh
10738bee358fSSushil SinghVerify Fail To Release Multiple Lock With Valid And Invalid TransactionID
10749614383dSGeorge Keishing    [Documentation]  Verify fail to be release multiple lock with valid and invalid transaction ID.
10758bee358fSSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
10768bee358fSSushil Singh
10778bee358fSSushil Singh    # Description of argument(s):
10788bee358fSSushil Singh    # client_id          This client id can contain string value
10798bee358fSSushil Singh    #                    (e.g. 12345, "HMCID").
10808bee358fSSushil Singh    # lock_type          Read lock or Write lock.
10818bee358fSSushil Singh    # release_lock_type  The value can be Transaction or Session.
10828bee358fSSushil Singh
10838bee358fSSushil Singh    ${trans_id_list}=  Create List
10848bee358fSSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
10858bee358fSSushil Singh
10868bee358fSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
10878bee358fSSushil Singh
10888bee358fSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
10898bee358fSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
10908bee358fSSushil Singh
10918bee358fSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
10928bee358fSSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
10938bee358fSSushil Singh    ${value}=  Evaluate  ${value} + 10
10948bee358fSSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
10958bee358fSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
10968bee358fSSushil Singh
10978bee358fSSushil Singh    Release Locks On Resource
10988bee358fSSushil Singh    ...  ${session_info}  ${trans_id_list}
10998bee358fSSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
11008bee358fSSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
11018bee358fSSushil Singh
11028bee358fSSushil Singh    ${trans_id_emptylist}=  Create List
11038bee358fSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
11048bee358fSSushil Singh    Redfish Delete Session  ${session_info}
11058bee358fSSushil Singh
11068bee358fSSushil Singh
11071d7b996cSsusilsi7Verify Fail To Release Lock With TransactionID As String Type
11089614383dSGeorge Keishing    [Documentation]  Verify fail to be release lock with transaction ID as string data type.
11091d7b996cSsusilsi7    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
11101d7b996cSsusilsi7
11111d7b996cSsusilsi7    # Description of argument(s):
11121d7b996cSsusilsi7    # client_id          This client id can contain string value
11131d7b996cSsusilsi7    #                    (e.g. 12345, "HMCID").
11141d7b996cSsusilsi7    # lock_type          Read lock or Write lock.
11151d7b996cSsusilsi7    # release_lock_type  The value can be Transaction or Session.
11161d7b996cSsusilsi7
11171d7b996cSsusilsi7    ${trans_id_list}=  Create List
11181d7b996cSsusilsi7    @{lock_type_list}=  Split String  ${lock_type}  ,
11191d7b996cSsusilsi7
11201d7b996cSsusilsi7    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
11211d7b996cSsusilsi7
11221d7b996cSsusilsi7    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
11231d7b996cSsusilsi7
11241d7b996cSsusilsi7    Append To List  ${trans_id_list}  ${trans_id}
11251d7b996cSsusilsi7
1126f4de7d77SSushil Singh    ${temp_trans_id_list}=  Copy List  ${trans_id_list}  deepcopy=True
11271d7b996cSsusilsi7
11281d7b996cSsusilsi7    ${value}=  Get From Dictionary  ${trans_id_list}[0]  TransactionID
11291d7b996cSsusilsi7    ${value}=  Set Variable  \'${value}\'
11301d7b996cSsusilsi7    Set To Dictionary  ${temp_trans_id_list}[0]  TransactionID  ${value}
11311d7b996cSsusilsi7
11321d7b996cSsusilsi7    Release Locks On Resource
11331d7b996cSsusilsi7    ...  ${session_info}  ${temp_trans_id_list}
11341d7b996cSsusilsi7    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
11351d7b996cSsusilsi7
11361d7b996cSsusilsi7    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
11371d7b996cSsusilsi7
11381d7b996cSsusilsi7    ${trans_id_emptylist}=  Create List
11391d7b996cSsusilsi7    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
11401d7b996cSsusilsi7    Redfish Delete Session  ${session_info}
11411d7b996cSsusilsi7
11421d7b996cSsusilsi7
1143d03f2ce1SSushil SinghVerify Fail To Release Lock For Another Session
1144d03f2ce1SSushil Singh    [Documentation]  Verify failed to release the lock form another session.
1145d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
1146d03f2ce1SSushil Singh
1147d03f2ce1SSushil Singh    # Description of argument(s):
1148d03f2ce1SSushil Singh    # client_id    This client id can contain string value
1149d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
1150d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
1151d03f2ce1SSushil Singh
1152d03f2ce1SSushil Singh    ${client_ids}=  Split String  ${client_id}  ,
1153d03f2ce1SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
1154d03f2ce1SSushil Singh    ${trans_id_list1}=  Create List
1155d03f2ce1SSushil Singh    ${trans_id_list2}=  Create List
1156d03f2ce1SSushil Singh
1157d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_ids}[0]
1158d03f2ce1SSushil Singh
1159d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1160d03f2ce1SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
1161d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
1162d03f2ce1SSushil Singh
1163d03f2ce1SSushil Singh    ${session_info2}=  Create Redfish Session With ClientID  ${client_ids}[1]
1164d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1165d03f2ce1SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
1166d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info2}  ${trans_id_list2}
1167d03f2ce1SSushil Singh
1168d03f2ce1SSushil Singh    Release Locks On Resource
1169e3f2e3baSSushil Singh    ...  ${session_info1}  ${trans_id_list1}  Transaction  status_code=${HTTP_BAD_REQUEST}
1170d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
1171d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Session
1172d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Session
1173d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
1174d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info2}
1175d03f2ce1SSushil Singh
1176d03f2ce1SSushil Singh
1177e33c6e6aSSushil SinghVerify Fail To Acquire Lock For Invalid Resource ID Data Type
1178e33c6e6aSSushil Singh    [Documentation]  Verify fail to acquire the lock with invalid resource id data type.
1179e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
1180e33c6e6aSSushil Singh
1181e33c6e6aSSushil Singh    # Description of argument(s):
1182e33c6e6aSSushil Singh    # client_id    This client id can contain string value
1183e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
1184e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
1185e33c6e6aSSushil Singh
1186e33c6e6aSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1187e33c6e6aSSushil Singh    Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
1188e33c6e6aSSushil Singh    ...  ${lock_type}  status_code=${HTTP_BAD_REQUEST}
1189e33c6e6aSSushil Singh    Redfish Delete Session  ${session_info}
1190e33c6e6aSSushil Singh
1191e33c6e6aSSushil Singh
1192d03f2ce1SSushil SinghVerify Fail To Acquire Lock For Invalid Lock Data
119316b3c7bfSGeorge Keishing    [Documentation]  Verify fail to acquired lock with invalid lock types, lock flags, segment flags.
1194d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${message}
1195d03f2ce1SSushil Singh
1196d03f2ce1SSushil Singh    # Description of argument(s):
1197d03f2ce1SSushil Singh    # client_id    This client id can contain string value
1198d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
1199d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
1200d03f2ce1SSushil Singh    # message      Return message from URI.
1201d03f2ce1SSushil Singh
1202d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
12038a3efe7cSSushil Singh    ${trans_id}=  Redfish Post Acquire Invalid Lock
12048a3efe7cSSushil Singh    ...  ${lock_type}  message=${message}  status_code=${HTTP_BAD_REQUEST}
1205d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
1206bace3005SSushil Singh
1207bace3005SSushil Singh
1208bace3005SSushil SinghVerify No Locks Records For Session With No Acquired Lock
1209bace3005SSushil Singh    [Documentation]  Verify no records found for a session where no lock is acquired.
1210bace3005SSushil Singh    [Arguments]  ${client_id}
1211bace3005SSushil Singh
1212bace3005SSushil Singh    # Description of argument(s):
1213bace3005SSushil Singh    # client_id    This client id can contain string value
1214bace3005SSushil Singh    #              (e.g. 12345, "HMCID").
1215bace3005SSushil Singh
1216bace3005SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1217bace3005SSushil Singh    ${trans_id_emptylist}=  Create List
1218bace3005SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
1219bace3005SSushil Singh    Redfish Delete Session  ${session_info}
1220728ef9c9SSushil Singh
1221728ef9c9SSushil Singh
1222728ef9c9SSushil SinghCreate List Of Session ID
1223728ef9c9SSushil Singh    [Documentation]  Create session id list from session dict info.
1224728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}
1225728ef9c9SSushil Singh
1226728ef9c9SSushil Singh    # Description of argument(s):
1227728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
1228728ef9c9SSushil Singh
1229728ef9c9SSushil Singh    @{session_id_list}=  Create List
1230728ef9c9SSushil Singh
1231728ef9c9SSushil Singh    FOR  ${session}  IN  @{session_dict_info}
1232728ef9c9SSushil Singh      Append To List  ${session_id_list}  ${session["SessionIDs"]}
1233728ef9c9SSushil Singh    END
1234728ef9c9SSushil Singh
1235728ef9c9SSushil Singh    ${num_id}=  Get Length  ${session_id_list}
1236728ef9c9SSushil Singh    Should Not Be Equal As Integers  ${num_id}  ${0}
1237728ef9c9SSushil Singh
1238728ef9c9SSushil Singh    ${session_id_list}=  Evaluate  json.dumps(${session_id_list})  json
1239728ef9c9SSushil Singh
1240409df05dSGeorge Keishing    RETURN  ${session_id_list}
1241728ef9c9SSushil Singh
1242728ef9c9SSushil Singh
1243728ef9c9SSushil SinghGet Locks List On Resource With Session List
1244728ef9c9SSushil Singh    [Documentation]  Get locks list from session of list.
1245728ef9c9SSushil Singh    [Arguments]  ${session_id_list}  ${exp_status_code}=${HTTP_OK}
1246728ef9c9SSushil Singh
1247728ef9c9SSushil Singh    # Description of argument(s):
1248728ef9c9SSushil Singh    # session_id_list    Session ids list.
1249728ef9c9SSushil Singh    # exp_status_code    Expected HTTP status code.
1250728ef9c9SSushil Singh
1251728ef9c9SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
1252fbd67007SGeorge Keishing    ...  data={"SessionIDs":${session_id_list}}  expected_status=any
125394116c61Ssusilsi7    Should Be Equal As Strings  ${resp.status_code}  ${exp_status_code}
1254728ef9c9SSushil Singh    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
1255728ef9c9SSushil Singh
1256409df05dSGeorge Keishing    RETURN  ${locks}
1257728ef9c9SSushil Singh
1258728ef9c9SSushil Singh
1259728ef9c9SSushil SinghVerify List Of Session Lock On Resource
1260728ef9c9SSushil Singh    [Documentation]  Verify list of lock record from list of sessions.
1261728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}  ${transaction_id_list}
1262728ef9c9SSushil Singh
1263728ef9c9SSushil Singh    # Description of argument(s):
1264728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
1265728ef9c9SSushil Singh    # transaction_id_list    Transaction id in list stored in dict.
1266728ef9c9SSushil Singh
1267728ef9c9SSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_info}
1268728ef9c9SSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1269728ef9c9SSushil Singh    ${lock_list}=  Set Variable  ${lock_list_resp['Records']}
1270728ef9c9SSushil Singh
12718a3efe7cSSushil Singh    FOR  ${session_id}  ${tran_id}  ${lock_record}  IN ZIP
12728a3efe7cSSushil Singh    ...  ${session_dict_info}  ${transaction_id_list}  ${lock_list}
1273728ef9c9SSushil Singh      Valid Value  session_id['SessionIDs']  ['${lock_record['SessionID']}']
1274728ef9c9SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock_record['TransactionID']}
1275728ef9c9SSushil Singh    END
1276728ef9c9SSushil Singh
1277728ef9c9SSushil Singh
1278728ef9c9SSushil SinghVerify Lock Records Of Multiple Session
1279728ef9c9SSushil Singh    [Documentation]  Verify all records found for a multiple sessions.
1280728ef9c9SSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
1281728ef9c9SSushil Singh
1282728ef9c9SSushil Singh    # Description of argument(s):
1283728ef9c9SSushil Singh    # client_ids    This client id can contain string value
1284728ef9c9SSushil Singh    #               (e.g. 12345, "HMCID").
1285728ef9c9SSushil Singh    # lock_type     Read lock or Write lock.
1286728ef9c9SSushil Singh
1287728ef9c9SSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
1288728ef9c9SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
1289728ef9c9SSushil Singh    ${trans_id_list1}=  Create List
1290728ef9c9SSushil Singh    ${trans_id_list2}=  Create List
1291728ef9c9SSushil Singh
1292728ef9c9SSushil Singh    ${session_dict_list}=  Create List
1293728ef9c9SSushil Singh    ${lock_list}=  Create List
1294728ef9c9SSushil Singh
1295728ef9c9SSushil Singh    ${client_id1}=  Create List
1296728ef9c9SSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
1297728ef9c9SSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
1298728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
1299728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
1300728ef9c9SSushil Singh
1301728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1302728ef9c9SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
1303728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
1304728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
1305728ef9c9SSushil Singh
1306728ef9c9SSushil Singh
1307728ef9c9SSushil Singh    ${client_id2}=  Create List
1308728ef9c9SSushil Singh    Append To List  ${client_id2}  ${client_id_list}[1]
1309728ef9c9SSushil Singh    ${session_info2}=  Create Session With List Of ClientID  ${client_id2}
1310728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
1311728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id2}  ${session_info2}
1312728ef9c9SSushil Singh
1313728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1314728ef9c9SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
1315728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
1316728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_list2}
1317728ef9c9SSushil Singh
1318728ef9c9SSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
1319728ef9c9SSushil Singh
1320728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
1321728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1322728ef9c9SSushil Singh
1323728ef9c9SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
1324728ef9c9SSushil Singh
1325728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info2}[0]  SessionToken
1326728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1327728ef9c9SSushil Singh
1328728ef9c9SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Transaction
1329728ef9c9SSushil Singh
1330728ef9c9SSushil Singh    ${trans_id_emptylist}=  Create List
1331728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
1332728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_emptylist}
1333728ef9c9SSushil Singh
1334728ef9c9SSushil Singh    Redfish Delete List Of Session  ${session_dict_list}
1335f9a536caSSushil Singh
1336f9a536caSSushil Singh
1337f9a536caSSushil SinghVerify Lock Records For Multiple Invalid Session
1338f9a536caSSushil Singh    [Documentation]  Verify no lock record found for multiple invalid session.
1339f9a536caSSushil Singh    [Arguments]  ${client_id}
1340f9a536caSSushil Singh
1341f9a536caSSushil Singh    # Description of argument(s):
1342f9a536caSSushil Singh    # client_id    This client id can contain string value
1343f9a536caSSushil Singh    #              (e.g. 12345, "HMCID").
1344f9a536caSSushil Singh
1345f9a536caSSushil Singh    ${session_dict_list}=  Create List
1346f9a536caSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz  xXyXYyYZzz
1347f9a536caSSushil Singh
1348f9a536caSSushil Singh    ${session_info1}=  Create Session With ClientID  ${client_id}
1349f9a536caSSushil Singh
1350f9a536caSSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
1351f9a536caSSushil Singh    set to dictionary  ${session_info2}  SessionIDs  ${invalid_session_ids}[0]
1352f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}
1353f9a536caSSushil Singh
1354f9a536caSSushil Singh    ${session_info3}=  Copy Dictionary  ${session_info1}  deepcopy=True
1355f9a536caSSushil Singh    set to dictionary  ${session_info3}  SessionIDs  ${invalid_session_ids}[0]
1356f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info3}
1357f9a536caSSushil Singh
1358f9a536caSSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
1359f9a536caSSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
1360f9a536caSSushil Singh
1361f9a536caSSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_list}
1362f9a536caSSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1363f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list_resp['Records']}
1364f9a536caSSushil Singh
1365f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
1366f9a536caSSushil Singh
1367f9a536caSSushil Singh    Redfish Delete Session  ${session_info1}
136811949a2cSSushil Singh
136911949a2cSSushil Singh
137011949a2cSSushil SinghVerify Lock Records For Multiple Invalid And Valid Session
137111949a2cSSushil Singh    [Documentation]  Verify all records found for a valid and invalid sessions.
137211949a2cSSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
137311949a2cSSushil Singh
137411949a2cSSushil Singh    # Description of argument(s):
137511949a2cSSushil Singh    # client_ids    This client id can contain string value
137611949a2cSSushil Singh    #               (e.g. 12345, "HMCID").
137711949a2cSSushil Singh    # lock_type     Read lock or Write lock.
137811949a2cSSushil Singh
137911949a2cSSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
138011949a2cSSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
138111949a2cSSushil Singh    ${trans_id_list1}=  Create List
138211949a2cSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz
138311949a2cSSushil Singh
138411949a2cSSushil Singh    ${session_dict_list}=  Create List
138511949a2cSSushil Singh    ${lock_list}=  Create List
138611949a2cSSushil Singh
138711949a2cSSushil Singh    ${client_id1}=  Create List
138811949a2cSSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
138911949a2cSSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
139011949a2cSSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
139111949a2cSSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
139211949a2cSSushil Singh
139311949a2cSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
139411949a2cSSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
139511949a2cSSushil Singh    Append To List  ${lock_list}  ${trans_id}
139611949a2cSSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
139711949a2cSSushil Singh
1398f4de7d77SSushil Singh    ${session_info2}=  Copy List  ${session_info1}  deepcopy=True
139911949a2cSSushil Singh    set to dictionary  ${session_info2}[0]  SessionIDs  ${invalid_session_ids}[0]
140011949a2cSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
140111949a2cSSushil Singh
140211949a2cSSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
140311949a2cSSushil Singh
140411949a2cSSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
140511949a2cSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
140611949a2cSSushil Singh
140711949a2cSSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
140811949a2cSSushil Singh
140911949a2cSSushil Singh    ${trans_id_emptylist}=  Create List
141011949a2cSSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
141111949a2cSSushil Singh
141211949a2cSSushil Singh    Redfish Delete Session  ${session_info1}[0]
14137e49fd5dSGeorge Keishing
14147e49fd5dSGeorge Keishing
14157e49fd5dSGeorge KeishingDelete All Redfish and HMC Sessions
14167e49fd5dSGeorge Keishing    [Documentation]  Delete all active redfish sessions.
14177e49fd5dSGeorge Keishing
14187e49fd5dSGeorge Keishing    ${saved_session_info}=  Get Redfish Session Info
14197e49fd5dSGeorge Keishing
14207e49fd5dSGeorge Keishing    ${resp_list}=  Redfish_Utils.Get Member List
14217e49fd5dSGeorge Keishing    ...  /redfish/v1/SessionService/Sessions
14227e49fd5dSGeorge Keishing
14237e49fd5dSGeorge Keishing    # Remove the current login session from the list.
14247e49fd5dSGeorge Keishing    Remove Values From List  ${resp_list}  ${saved_session_info["location"]}
14257e49fd5dSGeorge Keishing
14267e49fd5dSGeorge Keishing    FOR  ${session}  IN  @{resp_list}
14277e49fd5dSGeorge Keishing        Run Keyword And Ignore Error  Redfish.Delete  ${session}
14287e49fd5dSGeorge Keishing    END
14297e49fd5dSGeorge Keishing
14307e49fd5dSGeorge Keishing
14317e49fd5dSGeorge KeishingRestart Bmcweb On Failure
14327e49fd5dSGeorge Keishing    [Documentation]  Restart bmcweb only if test failed.
14337e49fd5dSGeorge Keishing
14347e49fd5dSGeorge Keishing    Return From Keyword If  "${TEST_STATUS}" == "PASS"
14357e49fd5dSGeorge Keishing
14367e49fd5dSGeorge Keishing    # This procedure is needs to be corrected or removed, when we figure out
14377e49fd5dSGeorge Keishing    # what is causing the real failure here.
14387e49fd5dSGeorge Keishing
14397e49fd5dSGeorge Keishing    Log To Console  Likely ConnectionResetError: Restarting bmcweb
14407e49fd5dSGeorge Keishing
14417e49fd5dSGeorge Keishing    ${stdout}  ${stderr}  ${rc}=  BMC Execute Command
14427e49fd5dSGeorge Keishing    ...  systemctl restart bmcweb  print_out=1
14437e49fd5dSGeorge Keishing
14447e49fd5dSGeorge Keishing    Should Be Empty  ${stderr}
14457e49fd5dSGeorge Keishing
14467e49fd5dSGeorge Keishing    Sleep  10s  reason=Wait for service to restart properly.
1447