xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_lock_management.robot (revision 8a3efe7c514013dff7f83e36034c03879fc5fc8f)
1bc331e22SVijay*** Settings ***
2bc331e22SVijay
3d03f2ce1SSushil SinghDocumentation        Test lock management feature of management console on BMC.
4bc331e22SVijay
5bc331e22SVijayResource             ../../lib/resource.robot
6bc331e22SVijayResource             ../../lib/openbmc_ffdc.robot
7566daaf3SGeorge KeishingResource             ../../lib/bmc_redfish_utils.robot
8d03f2ce1SSushil SinghResource             ../../lib/external_intf/management_console_utils.robot
9977f8f58SSushil SinghResource             ../../lib/rest_response_code.robot
10728ef9c9SSushil SinghLibrary              ../../lib/bmc_network_utils.py
11bc331e22SVijay
1240ef0eb7SSushil SinghSuite Setup          Run Keyword And Ignore Error  Delete All Redfish Sessions
13df390b61SSushil SinghSuite Teardown       Run Keyword And Ignore Error  Delete All Redfish Sessions
14d03f2ce1SSushil SinghTest Setup           Printn
15d03f2ce1SSushil SinghTest Teardown        FFDC On Test Case Fail
16bc331e22SVijay
17bc331e22SVijay*** Variables ***
18bc331e22SVijay
19d03f2ce1SSushil Singh${BAD_REQUEST}       Bad Request
20bc331e22SVijay
21bc331e22SVijay*** Test Cases ***
22bc331e22SVijay
23d03f2ce1SSushil SinghAcquire Read Write Lock
24bc331e22SVijay    [Documentation]  Acquire and release different read locks.
25d03f2ce1SSushil Singh    [Tags]  Acquire_Read_Write_Lock
26d03f2ce1SSushil Singh    [Template]  Acquire Lock On Resource
27bc331e22SVijay
28d03f2ce1SSushil Singh    # client_id    lock_type     reboot_flag
29d03f2ce1SSushil Singh    HMCID-01       ReadCase1     False
30d03f2ce1SSushil Singh    HMCID-01       ReadCase2     False
31d03f2ce1SSushil Singh    HMCID-01       ReadCase3     False
32d03f2ce1SSushil Singh    HMCID-01       WriteCase1    False
33d03f2ce1SSushil Singh    HMCID-01       WriteCase2    False
34d03f2ce1SSushil Singh    HMCID-01       WriteCase3    False
35bc331e22SVijay
36bc331e22SVijay
37d03f2ce1SSushil SinghCheck Lock Persistency On BMC Reboot
38d03f2ce1SSushil Singh    [Documentation]  Acquire lock and check after reboot it remain same.
39d03f2ce1SSushil Singh    [Tags]  Check_Lock_Persistency_On_BMC_Reboot
40d03f2ce1SSushil Singh    [Template]  Acquire Lock On Resource
41bc331e22SVijay
42d03f2ce1SSushil Singh    # client_id    lock_type     reboot_flag
43d03f2ce1SSushil Singh    HMCID-01       ReadCase1     True
44d03f2ce1SSushil Singh    HMCID-01       ReadCase2     True
45d03f2ce1SSushil Singh    HMCID-01       ReadCase3     True
46d03f2ce1SSushil Singh    HMCID-01       WriteCase1    True
47d03f2ce1SSushil Singh    HMCID-01       WriteCase2    True
48d03f2ce1SSushil Singh    HMCID-01       WriteCase3    True
49bc331e22SVijay
50bc331e22SVijay
51d03f2ce1SSushil SinghAcquire Read Lock On Read Lock
52d03f2ce1SSushil Singh    [Documentation]  Acquire read lock on another read lock.
53d03f2ce1SSushil Singh    [Tags]  Acquire_Read_Lock_On_Read_Lock
54d03f2ce1SSushil Singh    [Template]  Acquire Lock On Another Lock
55bc331e22SVijay
56d03f2ce1SSushil Singh    # client_id
57d03f2ce1SSushil Singh    HMCID-01
58bc331e22SVijay
59bc331e22SVijay
60d03f2ce1SSushil SinghFail To Acquire Lock On Another Lock
61d03f2ce1SSushil Singh    [Documentation]  Fail to acquire another lock.
62d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_On_Another_Lock
63d03f2ce1SSushil Singh    [Template]  Verify Acquire Lock Fails On Another Lock
6485610eeeSVijay
65d03f2ce1SSushil Singh    # client_id    lock_type
66d03f2ce1SSushil Singh    HMCID-01       ReadCase2,WriteCase2
67d03f2ce1SSushil Singh    HMCID-01       WriteCase2,WriteCase2
68d03f2ce1SSushil Singh    HMCID-01       WriteCase2,ReadCase2
69566daaf3SGeorge Keishing
70566daaf3SGeorge Keishing
71e33c6e6aSSushil SinghAcquire Lock After Reboot
72e33c6e6aSSushil Singh    [Documentation]  Acquire and release read and write locks after reboot.
73e33c6e6aSSushil Singh    [Tags]  Acquire_Lock_After_Reboot
74e33c6e6aSSushil Singh    [Template]  Verify Acquire Lock After Reboot
75e33c6e6aSSushil Singh
76e33c6e6aSSushil Singh    # client_id    lock_type
77e33c6e6aSSushil Singh    HMCID-01       ReadCase1
78e33c6e6aSSushil Singh    HMCID-01       ReadCase2
79e33c6e6aSSushil Singh    HMCID-01       ReadCase3
80e33c6e6aSSushil Singh    HMCID-01       WriteCase1
81e33c6e6aSSushil Singh    HMCID-01       WriteCase2
82e33c6e6aSSushil Singh    HMCID-01       WriteCase3
83e33c6e6aSSushil Singh
84e33c6e6aSSushil Singh
85d03f2ce1SSushil SinghAcquire And Release Lock In Loop
86d03f2ce1SSushil Singh    [Documentation]  Acquire and release read, write locks in loop.
87d03f2ce1SSushil Singh    [Tags]  Acquire_And_Release_Lock_In_Loop
88d03f2ce1SSushil Singh    [Template]  Verify Acquire And Release Lock In Loop
89566daaf3SGeorge Keishing
90d03f2ce1SSushil Singh    # client_id    lock_type
91d03f2ce1SSushil Singh    HMCID-01       ReadCase1
92d03f2ce1SSushil Singh    HMCID-01       ReadCase2
93d03f2ce1SSushil Singh    HMCID-01       ReadCase3
94d03f2ce1SSushil Singh    HMCID-01       WriteCase1
95d03f2ce1SSushil Singh    HMCID-01       WriteCase2
96d03f2ce1SSushil Singh    HMCID-01       WriteCase3
9785610eeeSVijay
9885610eeeSVijay
99977f8f58SSushil SinghFail To Acquire Read And Write In Single Request
100977f8f58SSushil Singh    [Documentation]  Fail to acquire read and write lock in single request.
101977f8f58SSushil Singh    [Tags]  Fail_To_Acquire_Read_And_Write_In_Single_Request
102977f8f58SSushil Singh    [Template]  Verify Fail To Acquire Read And Write In Single Request
103977f8f58SSushil Singh
104977f8f58SSushil Singh    # client_id    lock_type
105977f8f58SSushil Singh    HMCID-01       ReadCase1,WriteCase1
106977f8f58SSushil Singh    HMCID-01       WriteCase1,ReadCase1
107977f8f58SSushil Singh
108977f8f58SSushil Singh
109df390b61SSushil SinghAcquire Multiple Lock Request At CEC Level
110df390b61SSushil Singh    [Documentation]  Acquire write lock on read lock under CEC level.
111df390b61SSushil Singh    [Tags]  Acquire_Multiple_Lock_Request_At_CEC_Level
112df390b61SSushil Singh    [Template]  Verify Acquire Multiple Lock Request At CEC Level
113df390b61SSushil Singh
114df390b61SSushil Singh    # client_id    lock_type
115df390b61SSushil Singh    HMCID-01       ReadCase4,WriteCase4
116df390b61SSushil Singh    HMCID-01       WriteCase5,ReadCase5
117df390b61SSushil Singh    HMCID-01       ReadCase6,WriteCase6
118df390b61SSushil Singh    HMCID-01       WriteCase7,ReadCase7
119df390b61SSushil Singh
120df390b61SSushil Singh
121d03f2ce1SSushil SinghVerify Release Of Valid Locks
122d03f2ce1SSushil Singh    [Documentation]  Release all valid locks.
123d03f2ce1SSushil Singh    [Tags]  Verify_Release_Of_Valid_Locks
124d03f2ce1SSushil Singh    [Template]  Acquire And Release Multiple Locks
125afdd2a1dSVijay
126d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
127d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
128d03f2ce1SSushil Singh    HMCID-02       ReadCase1,ReadCase1,ReadCase1    Session
129afdd2a1dSVijay
130afdd2a1dSVijay
13194116c61Ssusilsi7Release Lock When Session Deleted
13294116c61Ssusilsi7    [Documentation]  Release lock when session gets deleted.
13394116c61Ssusilsi7    [Tags]  Release_Lock_When_Session_Deleted
13494116c61Ssusilsi7    [Template]  Verify Release Lock When Session Deleted
13594116c61Ssusilsi7
13694116c61Ssusilsi7    # client_id    lock_type
13794116c61Ssusilsi7    HMCID-01       ReadCase1
13894116c61Ssusilsi7    HMCID-01       WriteCase1
13994116c61Ssusilsi7
14094116c61Ssusilsi7
14159011d08SSushil SinghFail To Release Lock With Invalid TransactionID
14259011d08SSushil Singh    [Documentation]  Fail to release lock with invalid transaction id.
14359011d08SSushil Singh    [Tags]  Fail_To_Release_Lock_With_Invalid_TransactionID
14459011d08SSushil Singh    [Template]  Verify Fail To Release Lock With Invalid TransactionID
14559011d08SSushil Singh
14659011d08SSushil Singh    # client_id    lock_type     release_lock_type
14759011d08SSushil Singh    HMCID-01       ReadCase1     Transaction
14843b0c063Ssusilsi7    HMCID-01       WriteCase1    Transaction
14959011d08SSushil Singh
15059011d08SSushil Singh
1511b59053dSSushil SinghFail To Release Multiple Lock With Invalid TransactionID
152d03f2ce1SSushil Singh    [Documentation]  Release in-valid lock result in fail.
1531b59053dSSushil Singh    [Tags]  Fail_To_Release_Multiple_Lock_With_Invalid_TransactionID
1541b59053dSSushil Singh    [Template]  Verify Fail To Release Multiple Lock With Invalid TransactionID
155afdd2a1dSVijay
156d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
157d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
158d03f2ce1SSushil Singh    12345          ReadCase2,ReadCase2,ReadCase2    Transaction
159d03f2ce1SSushil Singh    HMCID          ReadCase3,ReadCase3,ReadCase3    Transaction
160afdd2a1dSVijay
161afdd2a1dSVijay
1628bee358fSSushil SinghFail To Release Multiple Lock With Valid And Invalid TransactionID
1639614383dSGeorge Keishing    [Documentation]  Release multiple lock with valid and invalid transaction.
1648bee358fSSushil Singh    [Tags]  Fail_To_Release_Multiple_Lock_With_Valid_And_Invalid_TransactionID
1658bee358fSSushil Singh    [Template]  Verify Fail To Release Multiple Lock With Valid And Invalid TransactionID
1668bee358fSSushil Singh
1678bee358fSSushil Singh    # client_id    lock_type              release_lock_type
1688bee358fSSushil Singh    HMCID-01       ReadCase1,ReadCase1    Transaction
1698bee358fSSushil Singh
1708bee358fSSushil Singh
1711d7b996cSsusilsi7Fail To Release Lock With String As TransactionID Data Type
1721d7b996cSsusilsi7    [Documentation]  Fail to release lock with string as transaction id data type.
1731d7b996cSsusilsi7    [Tags]  Fail_To_Release_Lock_With_String_As_TransactionID_Data_Type
1741d7b996cSsusilsi7    [Template]  Verify Fail To Release Lock With TransactionID As String Type
1751d7b996cSsusilsi7
1761d7b996cSsusilsi7    # client_id    lock_type     release_lock_type
1771d7b996cSsusilsi7    HMCID-01       ReadCase1     Transaction
1781d7b996cSsusilsi7    HMCID-01       WriteCase1    Transaction
1791d7b996cSsusilsi7
1801d7b996cSsusilsi7
181d03f2ce1SSushil SinghFail To Release Lock For Another Session
182d03f2ce1SSushil Singh    [Documentation]  Failed to release locks from another session.
183d03f2ce1SSushil Singh    [Tags]  Fail_To_Release_Lock_For_Another_Session
184d03f2ce1SSushil Singh    [Template]  Verify Fail To Release Lock For Another Session
185afdd2a1dSVijay
186d03f2ce1SSushil Singh    # client_id          lock_type
187d03f2ce1SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
188afdd2a1dSVijay
189afdd2a1dSVijay
190e33c6e6aSSushil SinghTest Invalid Resource ID Data Type Locking
191e33c6e6aSSushil Singh    [Documentation]  Failed to acquire lock for invalid resource id data type.
192e33c6e6aSSushil Singh    [Tags]  Test_Invalid_Resource_ID_Data_Type_Locking
193e33c6e6aSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Resource ID Data Type
194e33c6e6aSSushil Singh
195e33c6e6aSSushil Singh    # client_id    lock_type
196e33c6e6aSSushil Singh    HMCID-01       ReadCase1
197e33c6e6aSSushil Singh    HMCID-01       ReadCase2
198e33c6e6aSSushil Singh    HMCID-01       ReadCase3
199e33c6e6aSSushil Singh    HMCID-01       WriteCase1
200e33c6e6aSSushil Singh    HMCID-01       WriteCase2
201e33c6e6aSSushil Singh    HMCID-01       WriteCase3
202e33c6e6aSSushil Singh
203e33c6e6aSSushil Singh
204d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Type
205d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read, write lock for invalid lock data passed.
206d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Type
207d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
208afdd2a1dSVijay
209d03f2ce1SSushil Singh    # client_id    lock_type      message
210d03f2ce1SSushil Singh    HMCID-01       ReadCase1      ${BAD_REQUEST}
211d03f2ce1SSushil Singh    HMCID-01       ReadCase2      ${BAD_REQUEST}
212d03f2ce1SSushil Singh    HMCID-01       ReadCase3      ${BAD_REQUEST}
213d03f2ce1SSushil Singh    HMCID-01       ReadCase4      ${BAD_REQUEST}
214d03f2ce1SSushil Singh    HMCID-01       ReadCase5      ${BAD_REQUEST}
215d03f2ce1SSushil Singh    HMCID-01       WriteCase1     ${BAD_REQUEST}
216d03f2ce1SSushil Singh    HMCID-01       WriteCase2     ${BAD_REQUEST}
217d03f2ce1SSushil Singh    HMCID-01       WriteCase3     ${BAD_REQUEST}
218d03f2ce1SSushil Singh    HMCID-01       WriteCase4     ${BAD_REQUEST}
219d03f2ce1SSushil Singh    HMCID-01       WriteCase5     ${BAD_REQUEST}
220afdd2a1dSVijay
221afdd2a1dSVijay
222d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Flag
223d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid lock flag passed.
224d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
225d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
226afdd2a1dSVijay
227d03f2ce1SSushil Singh    # client_id    lock_type       message
228d03f2ce1SSushil Singh    HMCID-01       ReadCase6       ${BAD_REQUEST}
229d03f2ce1SSushil Singh    HMCID-01       ReadCase7       ${BAD_REQUEST}
230d03f2ce1SSushil Singh    HMCID-01       ReadCase8       ${BAD_REQUEST}
231d03f2ce1SSushil Singh    HMCID-01       ReadCase9       ${BAD_REQUEST}
232d03f2ce1SSushil Singh    HMCID-01       ReadCase10      ${BAD_REQUEST}
233d03f2ce1SSushil Singh    HMCID-01       ReadCase11      ${BAD_REQUEST}
234d03f2ce1SSushil Singh    HMCID-01       WriteCase6      ${BAD_REQUEST}
235d03f2ce1SSushil Singh    HMCID-01       WriteCase7      ${BAD_REQUEST}
236d03f2ce1SSushil Singh    HMCID-01       WriteCase8      ${BAD_REQUEST}
237d03f2ce1SSushil Singh    HMCID-01       WriteCase9      ${BAD_REQUEST}
238d03f2ce1SSushil Singh    HMCID-01       WriteCase10     ${BAD_REQUEST}
239d03f2ce1SSushil Singh    HMCID-01       WriteCase11     ${BAD_REQUEST}
240afdd2a1dSVijay
241afdd2a1dSVijay
242d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Segment Flag
243d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
244d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Flag
245d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
246d03f2ce1SSushil Singh
247d03f2ce1SSushil Singh    # client_id    lock_type       message
248d03f2ce1SSushil Singh    HMCID-01       ReadCase12      ${BAD_REQUEST}
249d03f2ce1SSushil Singh    HMCID-01       ReadCase13      ${BAD_REQUEST}
250d03f2ce1SSushil Singh    HMCID-01       ReadCase14      ${BAD_REQUEST}
251d03f2ce1SSushil Singh    HMCID-01       WriteCase12     ${BAD_REQUEST}
252d03f2ce1SSushil Singh    HMCID-01       WriteCase13     ${BAD_REQUEST}
253d03f2ce1SSushil Singh    HMCID-01       WriteCase14     ${BAD_REQUEST}
254afdd2a1dSVijay
255bace3005SSushil Singh
2563b3a7ecaSSushil SinghFail To Acquire Lock For Invalid Segment Data Type Flag
2573b3a7ecaSSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
2583b3a7ecaSSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Data_Type_Flag
2593b3a7ecaSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
2603b3a7ecaSSushil Singh
2613b3a7ecaSSushil Singh    # client_id    lock_type       message
2623b3a7ecaSSushil Singh    HMCID-01       ReadCase15      ${EMPTY}
2633b3a7ecaSSushil Singh    HMCID-01       ReadCase16      ${EMPTY}
2643b3a7ecaSSushil Singh    HMCID-01       ReadCase17      ${EMPTY}
2653b3a7ecaSSushil Singh    HMCID-01       ReadCase18      ${EMPTY}
2663b3a7ecaSSushil Singh    HMCID-01       WriteCase15     ${EMPTY}
2673b3a7ecaSSushil Singh    HMCID-01       WriteCase16     ${EMPTY}
2683b3a7ecaSSushil Singh    HMCID-01       WriteCase17     ${EMPTY}
2693b3a7ecaSSushil Singh    HMCID-01       WriteCase18     ${EMPTY}
2703b3a7ecaSSushil Singh
2713b3a7ecaSSushil Singh
272bace3005SSushil SinghGet Empty Lock Records For Session Where No Locks Acquired
273bace3005SSushil Singh    [Documentation]  If session does not acquire locks then get lock should return
274bace3005SSushil Singh    ...              empty lock records.
275bace3005SSushil Singh    [Tags]  Get_Empty_Lock_Records_For_Session_Where_No_Locks_Acquired
276bace3005SSushil Singh    [Template]  Verify No Locks Records For Session With No Acquired Lock
277bace3005SSushil Singh
278bace3005SSushil Singh    # client_id
279bace3005SSushil Singh    HMCID-01
280bace3005SSushil Singh
281728ef9c9SSushil Singh
282f9a536caSSushil SinghGet Lock Records Empty For Invalid Session
283f9a536caSSushil Singh    [Documentation]  Record of lock list is empty for invalid session.
284f9a536caSSushil Singh    [Tags]  Get_Lock_Records_Empty_For_Invalid_Session
285f9a536caSSushil Singh    [Template]  Verify Empty Lock Records For Invalid Session
286f9a536caSSushil Singh
287f9a536caSSushil Singh    # client_id
288f9a536caSSushil Singh    HMCID-01
289f9a536caSSushil Singh
290f9a536caSSushil Singh
291728ef9c9SSushil SinghGet Lock Records For Multiple Session
292728ef9c9SSushil Singh    [Documentation]  Get lock records of multiple session.
293728ef9c9SSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Session
294728ef9c9SSushil Singh    [Template]  Verify Lock Records Of Multiple Session
295728ef9c9SSushil Singh
296728ef9c9SSushil Singh    # client_ids         lock_type
297728ef9c9SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
298728ef9c9SSushil Singh
299728ef9c9SSushil Singh
300f9a536caSSushil SinghGet Lock Records For Multiple Invalid Session
301f9a536caSSushil Singh    [Documentation]  Record of lock list is empty for list of invalid session.
302f9a536caSSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Invalid_Session
303f9a536caSSushil Singh    [Template]  Verify Lock Records For Multiple Invalid Session
304f9a536caSSushil Singh
305f9a536caSSushil Singh    # client_id
306f9a536caSSushil Singh    HMCID-01
307f9a536caSSushil Singh
30811949a2cSSushil Singh
30911949a2cSSushil SinghGet Lock Records For Multiple Invalid And Valid Session
31011949a2cSSushil Singh    [Documentation]  Get record of lock from invalid and valid session.
31111949a2cSSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Invalid_And_Valid_Session
31211949a2cSSushil Singh    [Template]  Verify Lock Records For Multiple Invalid And Valid Session
31311949a2cSSushil Singh
31411949a2cSSushil Singh    # client_id          lock_type
31511949a2cSSushil Singh    HMCID-01,HMCID-02    ReadCase1
31611949a2cSSushil Singh
317bc331e22SVijay*** Keywords ***
318bc331e22SVijay
319d03f2ce1SSushil SinghCreate Redfish Session With ClientID
320d03f2ce1SSushil Singh    [Documentation]  Create redifish session with client id.
321d03f2ce1SSushil Singh    [Arguments]  ${client_id}
32285610eeeSVijay
32385610eeeSVijay    # Description of argument(s):
324d03f2ce1SSushil Singh    # client_id    This client id can contain string value
325d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
32685610eeeSVijay
327d03f2ce1SSushil Singh    ${session_info}=  Create Dictionary
328d03f2ce1SSushil Singh    ${session}=  Redfish Login  kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
32985610eeeSVijay
330d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  SessionIDs  ${session['Id']}
331d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  ClientID  ${session["Oem"]["OpenBMC"]["ClientID"]}
33285610eeeSVijay
333d03f2ce1SSushil Singh    [Return]  ${session_info}
33485610eeeSVijay
33585610eeeSVijay
336d03f2ce1SSushil SinghRW General Dictionary
33716b3c7bfSGeorge Keishing    [Documentation]  Create dictionary of lock request.
338d03f2ce1SSushil Singh    [Arguments]  ${read_case}  ${res_id}
339bc331e22SVijay
340bc331e22SVijay    # Description of argument(s):
341d03f2ce1SSushil Singh    # read_case    Read or Write lock type.
342d03f2ce1SSushil Singh    # res_id       Resource id.
343bc331e22SVijay
344d03f2ce1SSushil Singh    ${request_dict}=  Create Dictionary
345566daaf3SGeorge Keishing
346d03f2ce1SSushil Singh    FOR  ${key}  IN  @{read_case.keys()}
347d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  LockType  ${key}
348d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  SegmentFlags  ${read_case["${key}"]}
349d03f2ce1SSushil Singh    END
350bc331e22SVijay
351d03f2ce1SSushil Singh    Set To Dictionary  ${request_dict}  ResourceID  ${res_id}
352d03f2ce1SSushil Singh
353d03f2ce1SSushil Singh    [Return]  ${request_dict}
354bc331e22SVijay
355bc331e22SVijay
356d03f2ce1SSushil SinghReturn Description Of Response
357d03f2ce1SSushil Singh    [Documentation]  Return description of REST response.
358bc331e22SVijay    [Arguments]  ${resp_text}
359bc331e22SVijay
360bc331e22SVijay    # Description of argument(s):
361d03f2ce1SSushil Singh    # resp_text    REST response body.
362bc331e22SVijay
363d03f2ce1SSushil Singh    # resp_text after successful partition file upload looks like:
364d03f2ce1SSushil Singh    # {
365d03f2ce1SSushil Singh    #    "Description": "File Created"
366d03f2ce1SSushil Singh    # }
367bc331e22SVijay
368d03f2ce1SSushil Singh    ${message}=  Evaluate  json.loads('''${resp_text}''')  json
369d03f2ce1SSushil Singh
370d03f2ce1SSushil Singh    [Return]  ${message}
371bc331e22SVijay
372bc331e22SVijay
373a7d71f02SSushil SinghVerify Redfish Session Deleted
374a7d71f02SSushil Singh    [Documentation]  Verify the redfish session is deleted.
375a7d71f02SSushil Singh    [Arguments]  ${session_info}
376a7d71f02SSushil Singh
377a7d71f02SSushil Singh    # Description of argument(s):
378a7d71f02SSushil Singh    # session_info    Session information are stored in dictionary.
379a7d71f02SSushil Singh
380a7d71f02SSushil Singh    # ${session_info} = {
381a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
382a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
383a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
384a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
385a7d71f02SSushil Singh    # }
386a7d71f02SSushil Singh
387a7d71f02SSushil Singh    # SessionIDs   : Session IDs
388a7d71f02SSushil Singh    # ClientID     : Client ID
389a7d71f02SSushil Singh    # SessionToken : Session token
390a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
391a7d71f02SSushil Singh
392a7d71f02SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions
393a7d71f02SSushil Singh
394a7d71f02SSushil Singh    FOR  ${session}  IN  @{sessions['Members']}
395*8a3efe7cSSushil Singh      Should Not Be Equal As Strings
396*8a3efe7cSSushil Singh      ...  session  ['/redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}']
397a7d71f02SSushil Singh    END
398a7d71f02SSushil Singh
399a7d71f02SSushil Singh
400a7d71f02SSushil SinghVerify Redfish List Of Session Deleted
401a7d71f02SSushil Singh    [Documentation]  Verify all the list of redfish session is deleted.
402a7d71f02SSushil Singh    [Arguments]  ${session_info_list}
403a7d71f02SSushil Singh
404a7d71f02SSushil Singh    # Description of argument(s):
405a7d71f02SSushil Singh    # session_info_list    List contains individual session record are stored in dictionary.
406a7d71f02SSushil Singh
407a7d71f02SSushil Singh    # ${session_info_list} = [{
408a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
409a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
410a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
411a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
412a7d71f02SSushil Singh    # }]
413a7d71f02SSushil Singh
414a7d71f02SSushil Singh    # SessionIDs   : Session IDs
415a7d71f02SSushil Singh    # ClientID     : Client ID
416a7d71f02SSushil Singh    # SessionToken : Session token
417a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
418a7d71f02SSushil Singh
419a7d71f02SSushil Singh    FOR  ${session_record}  IN  @{session_info_list}
420a7d71f02SSushil Singh      Verify Redfish Session Deleted  ${session_record}
421a7d71f02SSushil Singh    END
422a7d71f02SSushil Singh
423a7d71f02SSushil Singh
424d03f2ce1SSushil SinghRedfish Post Acquire Lock
425d03f2ce1SSushil Singh    [Documentation]  Acquire and release lock.
426d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
427bc331e22SVijay
428bc331e22SVijay    # Description of argument(s):
429d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
430d03f2ce1SSushil Singh    # status_code    HTTP status code.
431bc331e22SVijay
432e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Lock  ${lock_type}
433*8a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
434*8a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
435d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
436df390b61SSushil Singh
437df390b61SSushil Singh    Run Keyword If  ${status_code} == ${HTTP_BAD_REQUEST}
438df390b61SSushil Singh    ...    Valid Value  ${BAD_REQUEST}  ['${resp.content}']
439df390b61SSushil Singh    ...  ELSE
440df390b61SSushil Singh    ...    Run Keyword And Return  Return Description Of Response  ${resp.content}
441bc331e22SVijay
442d03f2ce1SSushil Singh    [Return]  ${resp}
443bc331e22SVijay
444bc331e22SVijay
445977f8f58SSushil SinghRedfish Post Acquire List Lock
446977f8f58SSushil Singh    [Documentation]  Acquire and release lock.
447977f8f58SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
448977f8f58SSushil Singh
449977f8f58SSushil Singh    # Description of argument(s):
450977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
451977f8f58SSushil Singh    # status_code    HTTP status code.
452977f8f58SSushil Singh
453977f8f58SSushil Singh    ${lock_dict_param}=  Create Data To Acquire List Of Lock  ${lock_type}
454*8a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
455*8a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
456977f8f58SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
457977f8f58SSushil Singh
458977f8f58SSushil Singh    [Return]  ${resp}
459977f8f58SSushil Singh
460977f8f58SSushil Singh
461d03f2ce1SSushil SinghRedfish Post Acquire Invalid Lock
462d03f2ce1SSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock.
463d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${message}  ${status_code}=${HTTP_OK}
464bc331e22SVijay
465bc331e22SVijay    # Description of argument(s):
466d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
467d03f2ce1SSushil Singh    # message        Return message from URI.
468d03f2ce1SSushil Singh    # status_code    HTTP status code.
469bc331e22SVijay
470e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Invalid Lock  ${lock_type}
471*8a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
472*8a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
473d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
4743b3a7ecaSSushil Singh    Run Keyword If  '${message}' != '${EMPTY}'
4753b3a7ecaSSushil Singh    ...  Valid Value  message  ['${resp.content}']
476d03f2ce1SSushil Singh
477d03f2ce1SSushil Singh    [Return]  ${resp}
478bc331e22SVijay
479bc331e22SVijay
480e33c6e6aSSushil SinghRedfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
481e33c6e6aSSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock with invalid data type of resource id.
482e33c6e6aSSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
483e33c6e6aSSushil Singh
484e33c6e6aSSushil Singh    # Description of argument(s):
485e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
486e33c6e6aSSushil Singh    # status_code    HTTP status code.
487e33c6e6aSSushil Singh
488*8a3efe7cSSushil Singh    ${lock_dict_param}=
489*8a3efe7cSSushil Singh    ...  Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID  ${lock_type}
490*8a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
491*8a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
492e33c6e6aSSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
493e33c6e6aSSushil Singh
494e33c6e6aSSushil Singh    [Return]  ${resp}
495e33c6e6aSSushil Singh
496e33c6e6aSSushil Singh
497d03f2ce1SSushil SinghForm Data To Acquire Lock
49816b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for lock request.
499d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
500d03f2ce1SSushil Singh
501d03f2ce1SSushil Singh    # Description of argument(s):
502d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
503d03f2ce1SSushil Singh
504d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
505d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
506d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
507d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
508d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
509e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
510d03f2ce1SSushil Singh
511e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
512e33c6e6aSSushil Singh
513e33c6e6aSSushil Singh
514977f8f58SSushil SinghCreate Data To Acquire List Of Lock
51516b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for list of lock request.
516977f8f58SSushil Singh    [Arguments]  ${lock_type_list}
517977f8f58SSushil Singh
518977f8f58SSushil Singh    # Description of argument(s):
519977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
520977f8f58SSushil Singh
521977f8f58SSushil Singh    ${temp_list}=  Create List
522977f8f58SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
523977f8f58SSushil Singh
524977f8f58SSushil Singh    FOR  ${lock_type}  IN  @{lock_type_list}
525977f8f58SSushil Singh      ${resp}=  RW General Dictionary
526977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
527977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["ResourceID"]}
528977f8f58SSushil Singh      Append To List  ${temp_list}  ${resp}
529977f8f58SSushil Singh    END
530977f8f58SSushil Singh
531977f8f58SSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
532977f8f58SSushil Singh
533977f8f58SSushil Singh    [Return]  ${lock_request_dict}
534977f8f58SSushil Singh
535977f8f58SSushil Singh
536e33c6e6aSSushil SinghForm Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
53716b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for in-valid lock request.
538e33c6e6aSSushil Singh    [Arguments]  ${lock_type}
539e33c6e6aSSushil Singh
540e33c6e6aSSushil Singh    # Description of argument(s):
541e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
542e33c6e6aSSushil Singh
543e33c6e6aSSushil Singh    ${lock_res_info}=  Get Lock Resource Information
544e33c6e6aSSushil Singh    ${resp}=  RW General Dictionary
545e33c6e6aSSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
546e33c6e6aSSushil Singh    ...    ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
547e33c6e6aSSushil Singh    ${temp_list}=  Create List  ${resp}
548e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
549e33c6e6aSSushil Singh
550e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
551d03f2ce1SSushil Singh
552d03f2ce1SSushil Singh
553d03f2ce1SSushil SinghForm Data To Acquire Invalid Lock
55416b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for in-valid lock request.
555d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
556d03f2ce1SSushil Singh
557d03f2ce1SSushil Singh    # Description of argument(s):
558d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
559d03f2ce1SSushil Singh
560d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
561d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
562d03f2ce1SSushil Singh    ...    ${lock_res_info["Invalid Case"]["${lock_type}"]}
563d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
564d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
565e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
566d03f2ce1SSushil Singh
567e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
568d03f2ce1SSushil Singh
569d03f2ce1SSushil Singh
570d03f2ce1SSushil SinghGet Locks List On Resource
571bc331e22SVijay    [Documentation]  Get locks list.
572d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${exp_status_code}=${HTTP_OK}
573bc331e22SVijay
574bc331e22SVijay    # Description of argument(s):
575d03f2ce1SSushil Singh    # session_info       Session information in dict.
576d03f2ce1SSushil Singh    # exp_status_code    Expected HTTP status code.
577bc331e22SVijay
578d03f2ce1SSushil Singh    ${data}=  Set Variable  {"SessionIDs": ["${session_info['SessionIDs']}"]}
579566daaf3SGeorge Keishing    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
580566daaf3SGeorge Keishing    ...  data=${data}
581bc331e22SVijay    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
582bc331e22SVijay
583bc331e22SVijay    [Return]  ${locks["Records"]}
584bc331e22SVijay
585bc331e22SVijay
586d03f2ce1SSushil SinghVerify Lock On Resource
587d03f2ce1SSushil Singh    [Documentation]  Verify lock on resource.
588d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${transaction_id}
589bc331e22SVijay
590bc331e22SVijay    # Description of argument(s):
591d03f2ce1SSushil Singh    # session_info      Session information in dict.
592d03f2ce1SSushil Singh    # transaction_id    Transaction id in list stored in dict.
593bc331e22SVijay
594d03f2ce1SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
595d03f2ce1SSushil Singh    Rprint Vars  sessions
596d03f2ce1SSushil Singh    ${lock_list}=  Get Locks List On Resource  ${session_info}
597d03f2ce1SSushil Singh    ${lock_length}=  Get Length  ${lock_list}
598d03f2ce1SSushil Singh    ${tran_id_length}=  Get Length  ${transaction_id}
599d03f2ce1SSushil Singh    Should Be Equal As Integers  ${tran_id_length}  ${lock_length}
600afdd2a1dSVijay
601d03f2ce1SSushil Singh    FOR  ${tran_id}  ${lock}  IN ZIP  ${transaction_id}  ${lock_list}
602d03f2ce1SSushil Singh      Valid Value  session_info['ClientID']  ['${lock['HMCID']}']
603d03f2ce1SSushil Singh      Valid Value  session_info['SessionIDs']  ['${lock['SessionID']}']
604d03f2ce1SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock['TransactionID']}
605bc331e22SVijay    END
606bc331e22SVijay
607bc331e22SVijay
608d03f2ce1SSushil SinghAcquire Lock On Resource
609d03f2ce1SSushil Singh    [Documentation]  Acquire lock on resource.
610d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${reboot_flag}=False
611bc331e22SVijay
612bc331e22SVijay    # Description of argument(s):
613d03f2ce1SSushil Singh    # client_id    This client id can contain string value
614d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
615d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
616d03f2ce1SSushil Singh    # reboot_flag  Flag is used to run reboot the BMC code.
617d03f2ce1SSushil Singh    #               (e.g. True or False).
618bc331e22SVijay
619*8a3efe7cSSushil Singh    ${trans_id_emptylist}=  Create List
620d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
621*8a3efe7cSSushil Singh
622d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
623d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
624d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
625*8a3efe7cSSushil Singh
626d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
627566daaf3SGeorge Keishing
628e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
629bc331e22SVijay
630d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'True'
631*8a3efe7cSSushil Singh    ...  Run Keywords  Redfish BMC Reset Operation  AND
632e33c6e6aSSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
633*8a3efe7cSSushil Singh    ...  Is BMC Standby  AND
634*8a3efe7cSSushil Singh    ...  Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
635bc331e22SVijay
636d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'False'
637d03f2ce1SSushil Singh    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
638bc331e22SVijay
639d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
640d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
641d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
642bc331e22SVijay
643bc331e22SVijay
644d03f2ce1SSushil SinghForm Data To Release Lock
645d03f2ce1SSushil Singh    [Documentation]  Create a dictonay to release lock.
646d03f2ce1SSushil Singh    [Arguments]  ${trans_id_list}
647355daac7SVijay
648355daac7SVijay    # Description of argument(s):
649d03f2ce1SSushil Singh    # trans_id_list
650355daac7SVijay
651d03f2ce1SSushil Singh    @{tran_ids}=  Create List
652355daac7SVijay
653d03f2ce1SSushil Singh    FOR  ${item}  IN  @{trans_id_list}
654d03f2ce1SSushil Singh      Append To List  ${tran_ids}  ${item['TransactionID']}
655d03f2ce1SSushil Singh    END
656d03f2ce1SSushil Singh
657d03f2ce1SSushil Singh    [Return]  ${tran_ids}
658d03f2ce1SSushil Singh
659d03f2ce1SSushil Singh
660d03f2ce1SSushil SinghRelease Locks On Resource
661d03f2ce1SSushil Singh    [Documentation]  Redfish request to release a lock.
662*8a3efe7cSSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}  ${release_lock_type}=Transaction
663*8a3efe7cSSushil Singh    ...  ${status_code}=${HTTP_OK}
664d03f2ce1SSushil Singh
665d03f2ce1SSushil Singh    # Description of argument(s):
666d03f2ce1SSushil Singh    # session_info        Session information in dict.
667d03f2ce1SSushil Singh    # trans_id_list       Transaction id list.
668d03f2ce1SSushil Singh    # release_lock_type   Release lock by Transaction, Session.
669d03f2ce1SSushil Singh    # status_code         HTTP status code.
670d03f2ce1SSushil Singh
671d03f2ce1SSushil Singh    ${tran_ids}=  Form Data To Release Lock  ${trans_id_list}
672d03f2ce1SSushil Singh    ${data}=  Set Variable  {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
673d03f2ce1SSushil Singh    ${data}=  Evaluate  json.dumps(${data})  json
674d03f2ce1SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock  data=${data}
675d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
676d03f2ce1SSushil Singh
677d03f2ce1SSushil Singh
678df390b61SSushil SinghRelease locks And Delete Session
679df390b61SSushil Singh    [Documentation]  Release locks and delete redfish session.
680df390b61SSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}
681df390b61SSushil Singh
682df390b61SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}
683df390b61SSushil Singh
684df390b61SSushil Singh    ${trans_id_emptylist}=  Create List
685df390b61SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
686df390b61SSushil Singh
687df390b61SSushil Singh    Redfish Delete Session  ${session_info}
688df390b61SSushil Singh
689df390b61SSushil Singh
690d03f2ce1SSushil SinghAcquire Lock On Another Lock
691d03f2ce1SSushil Singh    [Documentation]  Acquire lock on another lock.
692d03f2ce1SSushil Singh    [Arguments]  ${client_id}
693d03f2ce1SSushil Singh
694d03f2ce1SSushil Singh    # Description of argument(s):
695d03f2ce1SSushil Singh    # client_id    This client id can contain string value
696d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
697d03f2ce1SSushil Singh
698d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
699d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
700d03f2ce1SSushil Singh
701d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
702d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
703d03f2ce1SSushil Singh
704d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
705d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
706d03f2ce1SSushil Singh
707d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
708d03f2ce1SSushil Singh
709df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
710d03f2ce1SSushil Singh
711d03f2ce1SSushil Singh
712977f8f58SSushil SinghVerify Fail To Acquire Read And Write In Single Request
713977f8f58SSushil Singh    [Documentation]  Verify fail to acquire read and write lock passed in single request.
714977f8f58SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
715977f8f58SSushil Singh
716977f8f58SSushil Singh    # Description of argument(s):
717977f8f58SSushil Singh    # client_id    This client id can contain string value
718977f8f58SSushil Singh    #              (e.g. 12345, "HMCID").
719977f8f58SSushil Singh    # lock_type    Read lock or Write lock.
720977f8f58SSushil Singh
721977f8f58SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
722977f8f58SSushil Singh
723977f8f58SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
724977f8f58SSushil Singh    ${trans_id}=  Redfish Post Acquire List Lock  ${lock_type_list}  status_code=${HTTP_BAD_REQUEST}
725977f8f58SSushil Singh    Redfish Delete Session  ${session_info}
726977f8f58SSushil Singh
727977f8f58SSushil Singh
728d03f2ce1SSushil SinghVerify Empty Lock Records For Invalid Session
729d03f2ce1SSushil Singh    [Documentation]  Verify no lock record found for invalid session.
730d03f2ce1SSushil Singh    [Arguments]  ${client_id}
731d03f2ce1SSushil Singh
732d03f2ce1SSushil Singh    # Description of argument(s):
733d03f2ce1SSushil Singh    # client_id    This client id can contain string value
734d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
735d03f2ce1SSushil Singh
736d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_id}
737d03f2ce1SSushil Singh
738d03f2ce1SSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
739d03f2ce1SSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
740d03f2ce1SSushil Singh
741d03f2ce1SSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
742d03f2ce1SSushil Singh    set to dictionary  ${session_info2}  SessionIDs  xxyXyyYZZz
743d03f2ce1SSushil Singh
744d03f2ce1SSushil Singh    ${lock_list2}=  Get Locks List On Resource  ${session_info2}
745f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list2}
746d03f2ce1SSushil Singh
747f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
748d03f2ce1SSushil Singh
749d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
750d03f2ce1SSushil Singh
751d03f2ce1SSushil Singh
752d03f2ce1SSushil SinghVerify Acquire Lock Fails On Another Lock
753d03f2ce1SSushil Singh    [Documentation]  Verify acquire lock on another lock fails.
754d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
755d03f2ce1SSushil Singh
756d03f2ce1SSushil Singh    # Description of argument(s):
757d03f2ce1SSushil Singh    # client_id    This client id can contain string value
758d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
759d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
760d03f2ce1SSushil Singh
761d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
762d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
763d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
764d03f2ce1SSushil Singh
765d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
766d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
767d03f2ce1SSushil Singh
768d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
769d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
770d03f2ce1SSushil Singh
771df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
772d03f2ce1SSushil Singh
773d03f2ce1SSushil Singh
774e33c6e6aSSushil SinghVerify Acquire Lock After Reboot
775e33c6e6aSSushil Singh    [Documentation]  Acquire read and write lock after the reboot and release lock.
776e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
777e33c6e6aSSushil Singh
778e33c6e6aSSushil Singh    # Description of argument(s):
779e33c6e6aSSushil Singh    # client_id    This client id can contain string value
780e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
781e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
782e33c6e6aSSushil Singh
783e33c6e6aSSushil Singh    ${trans_id_list}=  Create List
784f9a536caSSushil Singh    ${session_info}=  Create Session With ClientID  ${client_id}
785e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
786e33c6e6aSSushil Singh    Redfish OBMC Reboot (off)
787e33c6e6aSSushil Singh    Redfish Login
788e33c6e6aSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}
789e33c6e6aSSushil Singh
790e33c6e6aSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
791e33c6e6aSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
792e33c6e6aSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
793e33c6e6aSSushil Singh
794df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
795df390b61SSushil Singh
796df390b61SSushil Singh
797df390b61SSushil SinghVerify Acquire Multiple Lock Request At CEC Level
798df390b61SSushil Singh    [Documentation]  Acquire lock in loop.
799df390b61SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
800df390b61SSushil Singh
801df390b61SSushil Singh    # Description of argument(s):
802df390b61SSushil Singh    # client_id    This client id can contain string value
803df390b61SSushil Singh    #              (e.g. 12345, "HMCID").
804df390b61SSushil Singh    # lock_type    Read lock or Write lock.
805df390b61SSushil Singh
806df390b61SSushil Singh    ${trans_id_list}=  Create List
807df390b61SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
808df390b61SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
809df390b61SSushil Singh
810df390b61SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
811df390b61SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
812df390b61SSushil Singh
813df390b61SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
814df390b61SSushil Singh
815df390b61SSushil Singh    Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
816df390b61SSushil Singh
817df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
818e33c6e6aSSushil Singh
819e33c6e6aSSushil Singh
820d03f2ce1SSushil SinghVerify Acquire And Release Lock In Loop
821d03f2ce1SSushil Singh    [Documentation]  Acquire lock in loop.
822d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
823d03f2ce1SSushil Singh
824d03f2ce1SSushil Singh    # Description of argument(s):
825d03f2ce1SSushil Singh    # client_id    This client id can contain string value
826d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
827d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
828d03f2ce1SSushil Singh
829d03f2ce1SSushil Singh    FOR  ${count}  IN RANGE  1  11
830d03f2ce1SSushil Singh      ${trans_id_list}=  Create List
831d03f2ce1SSushil Singh      ${session_info}=  Create Redfish Session With ClientID  ${client_id}
832d03f2ce1SSushil Singh      ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
833d03f2ce1SSushil Singh      Append To List  ${trans_id_list}  ${trans_id}
834d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_list}
835d03f2ce1SSushil Singh      Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
836d03f2ce1SSushil Singh      ${trans_id_emptylist}=  Create List
837d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
838d03f2ce1SSushil Singh    END
839d03f2ce1SSushil Singh
840d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
841d03f2ce1SSushil Singh
842d03f2ce1SSushil Singh
843d03f2ce1SSushil SinghAcquire And Release Multiple Locks
844d03f2ce1SSushil Singh    [Documentation]  Acquire mutilple locks on resource.
845d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
846d03f2ce1SSushil Singh
847d03f2ce1SSushil Singh    # Description of argument(s):
848d03f2ce1SSushil Singh    # client_id          This client id can contain string value
849d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
850d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
851d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
852d03f2ce1SSushil Singh
853d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
854d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
855d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
856d03f2ce1SSushil Singh
857d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
858d03f2ce1SSushil Singh
859d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
860d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
861d03f2ce1SSushil Singh
862d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
863d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
864d03f2ce1SSushil Singh
865d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
866d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
867d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
868d03f2ce1SSushil Singh
869d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
870d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
871d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
872d03f2ce1SSushil Singh
873d03f2ce1SSushil Singh
87494116c61Ssusilsi7Verify Release Lock When Session Deleted
87594116c61Ssusilsi7    [Documentation]  Verify lock get released when session are deleted.
87694116c61Ssusilsi7    [Arguments]  ${client_id}  ${lock_type}
87794116c61Ssusilsi7
87894116c61Ssusilsi7    # Description of argument(s):
87994116c61Ssusilsi7    # client_ids    This client id can contain string value
88094116c61Ssusilsi7    #               (e.g. 12345, "HMCID").
88194116c61Ssusilsi7    # lock_type     Read lock or Write lock.
88294116c61Ssusilsi7
88394116c61Ssusilsi7    ${trans_id_list}=  Create List
88494116c61Ssusilsi7    @{lock_type_list}=  Split String  ${lock_type}  ,
88594116c61Ssusilsi7
88694116c61Ssusilsi7    ${pre_session_info}=  Create Redfish Session With ClientID  ${client_id}
88794116c61Ssusilsi7
88894116c61Ssusilsi7    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
88994116c61Ssusilsi7    Append To List  ${trans_id_list}  ${trans_id}
89094116c61Ssusilsi7    Verify Lock On Resource  ${pre_session_info}  ${trans_id_list}
89194116c61Ssusilsi7
89294116c61Ssusilsi7    Redfish Delete Session  ${pre_session_info}
89394116c61Ssusilsi7    ${post_session_info}=  Create Redfish Session With ClientID  ${client_id}
89494116c61Ssusilsi7    ${resp}=  Get Locks List On Resource With Session List  ${pre_session_info}  ${HTTP_BAD_REQUEST}
89594116c61Ssusilsi7
89694116c61Ssusilsi7    Redfish Delete Session  ${post_session_info}
89794116c61Ssusilsi7
89894116c61Ssusilsi7
89994116c61Ssusilsi7
90059011d08SSushil SinghVerify Fail To Release Lock With Invalid TransactionID
90116b3c7bfSGeorge Keishing    [Documentation]  Verify fail to be release lock with invalid transaction ID.
90259011d08SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
90359011d08SSushil Singh
90459011d08SSushil Singh    # Description of argument(s):
90559011d08SSushil Singh    # client_id          This client id can contain string value
90659011d08SSushil Singh    #                    (e.g. 12345, "HMCID").
90759011d08SSushil Singh    # lock_type          Read lock or Write lock.
90859011d08SSushil Singh    # release_lock_type  The value can be Transaction or Session.
90959011d08SSushil Singh
91059011d08SSushil Singh    ${trans_id_list}=  Create List
91159011d08SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
91259011d08SSushil Singh
91359011d08SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
91459011d08SSushil Singh
91559011d08SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
91659011d08SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
91759011d08SSushil Singh    ${value}=  Evaluate  ${value} + 10
91859011d08SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
91959011d08SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
92059011d08SSushil Singh
92159011d08SSushil Singh    Release Locks On Resource
92259011d08SSushil Singh    ...  ${session_info}  ${trans_id_list}
92359011d08SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
92459011d08SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
92559011d08SSushil Singh
92659011d08SSushil Singh    ${trans_id_emptylist}=  Create List
92759011d08SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
92859011d08SSushil Singh    Redfish Delete Session  ${session_info}
92959011d08SSushil Singh
93059011d08SSushil Singh
9311b59053dSSushil SinghVerify Fail To Release Multiple Lock With Invalid TransactionID
9321b59053dSSushil Singh    [Documentation]  Verify release multiple locks with invalid transaction ID fails.
933d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
934d03f2ce1SSushil Singh
935d03f2ce1SSushil Singh    # Description of argument(s):
936d03f2ce1SSushil Singh    # client_id          This client id can contain string value
937d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
938d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
939d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
940d03f2ce1SSushil Singh
941d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
942d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
943d03f2ce1SSushil Singh
944d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
945d03f2ce1SSushil Singh
946d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
947d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
948d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
949d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
950d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
951d03f2ce1SSushil Singh
952d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
953d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
954d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
955d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
956d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
957d03f2ce1SSushil Singh
958d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
959d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
960d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
961d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
962d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
963d03f2ce1SSushil Singh
964d03f2ce1SSushil Singh    Release Locks On Resource
965d03f2ce1SSushil Singh    ...  ${session_info}  ${trans_id_list}
966d03f2ce1SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
967d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
968d03f2ce1SSushil Singh
969d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
970d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
971d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
972d03f2ce1SSushil Singh
973d03f2ce1SSushil Singh
9748bee358fSSushil SinghVerify Fail To Release Multiple Lock With Valid And Invalid TransactionID
9759614383dSGeorge Keishing    [Documentation]  Verify fail to be release multiple lock with valid and invalid transaction ID.
9768bee358fSSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
9778bee358fSSushil Singh
9788bee358fSSushil Singh    # Description of argument(s):
9798bee358fSSushil Singh    # client_id          This client id can contain string value
9808bee358fSSushil Singh    #                    (e.g. 12345, "HMCID").
9818bee358fSSushil Singh    # lock_type          Read lock or Write lock.
9828bee358fSSushil Singh    # release_lock_type  The value can be Transaction or Session.
9838bee358fSSushil Singh
9848bee358fSSushil Singh    ${trans_id_list}=  Create List
9858bee358fSSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
9868bee358fSSushil Singh
9878bee358fSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
9888bee358fSSushil Singh
9898bee358fSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
9908bee358fSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
9918bee358fSSushil Singh
9928bee358fSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
9938bee358fSSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
9948bee358fSSushil Singh    ${value}=  Evaluate  ${value} + 10
9958bee358fSSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
9968bee358fSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
9978bee358fSSushil Singh
9988bee358fSSushil Singh    Release Locks On Resource
9998bee358fSSushil Singh    ...  ${session_info}  ${trans_id_list}
10008bee358fSSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
10018bee358fSSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
10028bee358fSSushil Singh
10038bee358fSSushil Singh    ${trans_id_emptylist}=  Create List
10048bee358fSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
10058bee358fSSushil Singh    Redfish Delete Session  ${session_info}
10068bee358fSSushil Singh
10078bee358fSSushil Singh
10081d7b996cSsusilsi7Verify Fail To Release Lock With TransactionID As String Type
10099614383dSGeorge Keishing    [Documentation]  Verify fail to be release lock with transaction ID as string data type.
10101d7b996cSsusilsi7    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
10111d7b996cSsusilsi7
10121d7b996cSsusilsi7    # Description of argument(s):
10131d7b996cSsusilsi7    # client_id          This client id can contain string value
10141d7b996cSsusilsi7    #                    (e.g. 12345, "HMCID").
10151d7b996cSsusilsi7    # lock_type          Read lock or Write lock.
10161d7b996cSsusilsi7    # release_lock_type  The value can be Transaction or Session.
10171d7b996cSsusilsi7
10181d7b996cSsusilsi7    ${trans_id_list}=  Create List
10191d7b996cSsusilsi7    @{lock_type_list}=  Split String  ${lock_type}  ,
10201d7b996cSsusilsi7
10211d7b996cSsusilsi7    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
10221d7b996cSsusilsi7
10231d7b996cSsusilsi7    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
10241d7b996cSsusilsi7
10251d7b996cSsusilsi7    Append To List  ${trans_id_list}  ${trans_id}
10261d7b996cSsusilsi7
10271d7b996cSsusilsi7    ${temp_trans_id_list}=  Copy Dictionary  ${trans_id_list}  deepcopy=True
10281d7b996cSsusilsi7
10291d7b996cSsusilsi7    ${value}=  Get From Dictionary  ${trans_id_list}[0]  TransactionID
10301d7b996cSsusilsi7    ${value}=  Set Variable  \'${value}\'
10311d7b996cSsusilsi7    Set To Dictionary  ${temp_trans_id_list}[0]  TransactionID  ${value}
10321d7b996cSsusilsi7
10331d7b996cSsusilsi7    Release Locks On Resource
10341d7b996cSsusilsi7    ...  ${session_info}  ${temp_trans_id_list}
10351d7b996cSsusilsi7    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
10361d7b996cSsusilsi7
10371d7b996cSsusilsi7    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
10381d7b996cSsusilsi7
10391d7b996cSsusilsi7    ${trans_id_emptylist}=  Create List
10401d7b996cSsusilsi7    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
10411d7b996cSsusilsi7    Redfish Delete Session  ${session_info}
10421d7b996cSsusilsi7
10431d7b996cSsusilsi7
1044d03f2ce1SSushil SinghVerify Fail To Release Lock For Another Session
1045d03f2ce1SSushil Singh    [Documentation]  Verify failed to release the lock form another session.
1046d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
1047d03f2ce1SSushil Singh
1048d03f2ce1SSushil Singh    # Description of argument(s):
1049d03f2ce1SSushil Singh    # client_id    This client id can contain string value
1050d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
1051d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
1052d03f2ce1SSushil Singh
1053d03f2ce1SSushil Singh    ${client_ids}=  Split String  ${client_id}  ,
1054d03f2ce1SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
1055d03f2ce1SSushil Singh    ${trans_id_list1}=  Create List
1056d03f2ce1SSushil Singh    ${trans_id_list2}=  Create List
1057d03f2ce1SSushil Singh
1058d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_ids}[0]
1059d03f2ce1SSushil Singh
1060d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1061d03f2ce1SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
1062d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
1063d03f2ce1SSushil Singh
1064d03f2ce1SSushil Singh    ${session_info2}=  Create Redfish Session With ClientID  ${client_ids}[1]
1065d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1066d03f2ce1SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
1067d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info2}  ${trans_id_list2}
1068d03f2ce1SSushil Singh
1069d03f2ce1SSushil Singh    Release Locks On Resource
1070d03f2ce1SSushil Singh    ...  ${session_info1}  ${trans_id_list1}  Transaction  status_code=${HTTP_UNAUTHORIZED}
1071d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
1072d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Session
1073d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Session
1074d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
1075d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info2}
1076d03f2ce1SSushil Singh
1077d03f2ce1SSushil Singh
1078e33c6e6aSSushil SinghVerify Fail To Acquire Lock For Invalid Resource ID Data Type
1079e33c6e6aSSushil Singh    [Documentation]  Verify fail to acquire the lock with invalid resource id data type.
1080e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
1081e33c6e6aSSushil Singh
1082e33c6e6aSSushil Singh    # Description of argument(s):
1083e33c6e6aSSushil Singh    # client_id    This client id can contain string value
1084e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
1085e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
1086e33c6e6aSSushil Singh
1087e33c6e6aSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1088e33c6e6aSSushil Singh    Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
1089e33c6e6aSSushil Singh    ...  ${lock_type}  status_code=${HTTP_BAD_REQUEST}
1090e33c6e6aSSushil Singh    Redfish Delete Session  ${session_info}
1091e33c6e6aSSushil Singh
1092e33c6e6aSSushil Singh
1093d03f2ce1SSushil SinghVerify Fail To Acquire Lock For Invalid Lock Data
109416b3c7bfSGeorge Keishing    [Documentation]  Verify fail to acquired lock with invalid lock types, lock flags, segment flags.
1095d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${message}
1096d03f2ce1SSushil Singh
1097d03f2ce1SSushil Singh    # Description of argument(s):
1098d03f2ce1SSushil Singh    # client_id    This client id can contain string value
1099d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
1100d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
1101d03f2ce1SSushil Singh    # message      Return message from URI.
1102d03f2ce1SSushil Singh
1103d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1104*8a3efe7cSSushil Singh    ${trans_id}=  Redfish Post Acquire Invalid Lock
1105*8a3efe7cSSushil Singh    ...  ${lock_type}  message=${message}  status_code=${HTTP_BAD_REQUEST}
1106d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
1107bace3005SSushil Singh
1108bace3005SSushil Singh
1109bace3005SSushil SinghVerify No Locks Records For Session With No Acquired Lock
1110bace3005SSushil Singh    [Documentation]  Verify no records found for a session where no lock is acquired.
1111bace3005SSushil Singh    [Arguments]  ${client_id}
1112bace3005SSushil Singh
1113bace3005SSushil Singh    # Description of argument(s):
1114bace3005SSushil Singh    # client_id    This client id can contain string value
1115bace3005SSushil Singh    #              (e.g. 12345, "HMCID").
1116bace3005SSushil Singh
1117bace3005SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1118bace3005SSushil Singh    ${trans_id_emptylist}=  Create List
1119bace3005SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
1120bace3005SSushil Singh    Redfish Delete Session  ${session_info}
1121728ef9c9SSushil Singh
1122728ef9c9SSushil Singh
1123728ef9c9SSushil SinghCreate List Of Session ID
1124728ef9c9SSushil Singh    [Documentation]  Create session id list from session dict info.
1125728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}
1126728ef9c9SSushil Singh
1127728ef9c9SSushil Singh    # Description of argument(s):
1128728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
1129728ef9c9SSushil Singh
1130728ef9c9SSushil Singh    @{session_id_list}=  Create List
1131728ef9c9SSushil Singh
1132728ef9c9SSushil Singh    FOR  ${session}  IN  @{session_dict_info}
1133728ef9c9SSushil Singh      Append To List  ${session_id_list}  ${session["SessionIDs"]}
1134728ef9c9SSushil Singh    END
1135728ef9c9SSushil Singh
1136728ef9c9SSushil Singh    ${num_id}=  Get Length  ${session_id_list}
1137728ef9c9SSushil Singh    Should Not Be Equal As Integers  ${num_id}  ${0}
1138728ef9c9SSushil Singh
1139728ef9c9SSushil Singh    ${session_id_list}=  Evaluate  json.dumps(${session_id_list})  json
1140728ef9c9SSushil Singh
1141728ef9c9SSushil Singh    [Return]  ${session_id_list}
1142728ef9c9SSushil Singh
1143728ef9c9SSushil Singh
1144728ef9c9SSushil SinghGet Locks List On Resource With Session List
1145728ef9c9SSushil Singh    [Documentation]  Get locks list from session of list.
1146728ef9c9SSushil Singh    [Arguments]  ${session_id_list}  ${exp_status_code}=${HTTP_OK}
1147728ef9c9SSushil Singh
1148728ef9c9SSushil Singh    # Description of argument(s):
1149728ef9c9SSushil Singh    # session_id_list    Session ids list.
1150728ef9c9SSushil Singh    # exp_status_code    Expected HTTP status code.
1151728ef9c9SSushil Singh
1152728ef9c9SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
1153728ef9c9SSushil Singh    ...  data={"SessionIDs": ${session_id_list}}
115494116c61Ssusilsi7    Should Be Equal As Strings  ${resp.status_code}  ${exp_status_code}
1155728ef9c9SSushil Singh    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
1156728ef9c9SSushil Singh
1157728ef9c9SSushil Singh    [Return]  ${locks}
1158728ef9c9SSushil Singh
1159728ef9c9SSushil Singh
1160728ef9c9SSushil SinghVerify List Of Session Lock On Resource
1161728ef9c9SSushil Singh    [Documentation]  Verify list of lock record from list of sessions.
1162728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}  ${transaction_id_list}
1163728ef9c9SSushil Singh
1164728ef9c9SSushil Singh    # Description of argument(s):
1165728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
1166728ef9c9SSushil Singh    # transaction_id_list    Transaction id in list stored in dict.
1167728ef9c9SSushil Singh
1168728ef9c9SSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_info}
1169728ef9c9SSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1170728ef9c9SSushil Singh    ${lock_list}=  Set Variable  ${lock_list_resp['Records']}
1171728ef9c9SSushil Singh
1172*8a3efe7cSSushil Singh    FOR  ${session_id}  ${tran_id}  ${lock_record}  IN ZIP
1173*8a3efe7cSSushil Singh    ...  ${session_dict_info}  ${transaction_id_list}  ${lock_list}
1174728ef9c9SSushil Singh      Valid Value  session_id['SessionIDs']  ['${lock_record['SessionID']}']
1175728ef9c9SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock_record['TransactionID']}
1176728ef9c9SSushil Singh    END
1177728ef9c9SSushil Singh
1178728ef9c9SSushil Singh
1179728ef9c9SSushil SinghVerify Lock Records Of Multiple Session
1180728ef9c9SSushil Singh    [Documentation]  Verify all records found for a multiple sessions.
1181728ef9c9SSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
1182728ef9c9SSushil Singh
1183728ef9c9SSushil Singh    # Description of argument(s):
1184728ef9c9SSushil Singh    # client_ids    This client id can contain string value
1185728ef9c9SSushil Singh    #               (e.g. 12345, "HMCID").
1186728ef9c9SSushil Singh    # lock_type     Read lock or Write lock.
1187728ef9c9SSushil Singh
1188728ef9c9SSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
1189728ef9c9SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
1190728ef9c9SSushil Singh    ${trans_id_list1}=  Create List
1191728ef9c9SSushil Singh    ${trans_id_list2}=  Create List
1192728ef9c9SSushil Singh
1193728ef9c9SSushil Singh    ${session_dict_list}=  Create List
1194728ef9c9SSushil Singh    ${lock_list}=  Create List
1195728ef9c9SSushil Singh
1196728ef9c9SSushil Singh    ${client_id1}=  Create List
1197728ef9c9SSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
1198728ef9c9SSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
1199728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
1200728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
1201728ef9c9SSushil Singh
1202728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1203728ef9c9SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
1204728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
1205728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
1206728ef9c9SSushil Singh
1207728ef9c9SSushil Singh
1208728ef9c9SSushil Singh    ${client_id2}=  Create List
1209728ef9c9SSushil Singh    Append To List  ${client_id2}  ${client_id_list}[1]
1210728ef9c9SSushil Singh    ${session_info2}=  Create Session With List Of ClientID  ${client_id2}
1211728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
1212728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id2}  ${session_info2}
1213728ef9c9SSushil Singh
1214728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1215728ef9c9SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
1216728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
1217728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_list2}
1218728ef9c9SSushil Singh
1219728ef9c9SSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
1220728ef9c9SSushil Singh
1221728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
1222728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1223728ef9c9SSushil Singh
1224728ef9c9SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
1225728ef9c9SSushil Singh
1226728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info2}[0]  SessionToken
1227728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1228728ef9c9SSushil Singh
1229728ef9c9SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Transaction
1230728ef9c9SSushil Singh
1231728ef9c9SSushil Singh    ${trans_id_emptylist}=  Create List
1232728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
1233728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_emptylist}
1234728ef9c9SSushil Singh
1235728ef9c9SSushil Singh    Redfish Delete List Of Session  ${session_dict_list}
1236f9a536caSSushil Singh
1237f9a536caSSushil Singh
1238f9a536caSSushil SinghVerify Lock Records For Multiple Invalid Session
1239f9a536caSSushil Singh    [Documentation]  Verify no lock record found for multiple invalid session.
1240f9a536caSSushil Singh    [Arguments]  ${client_id}
1241f9a536caSSushil Singh
1242f9a536caSSushil Singh    # Description of argument(s):
1243f9a536caSSushil Singh    # client_id    This client id can contain string value
1244f9a536caSSushil Singh    #              (e.g. 12345, "HMCID").
1245f9a536caSSushil Singh
1246f9a536caSSushil Singh    ${session_dict_list}=  Create List
1247f9a536caSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz  xXyXYyYZzz
1248f9a536caSSushil Singh
1249f9a536caSSushil Singh    ${session_info1}=  Create Session With ClientID  ${client_id}
1250f9a536caSSushil Singh
1251f9a536caSSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
1252f9a536caSSushil Singh    set to dictionary  ${session_info2}  SessionIDs  ${invalid_session_ids}[0]
1253f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}
1254f9a536caSSushil Singh
1255f9a536caSSushil Singh    ${session_info3}=  Copy Dictionary  ${session_info1}  deepcopy=True
1256f9a536caSSushil Singh    set to dictionary  ${session_info3}  SessionIDs  ${invalid_session_ids}[0]
1257f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info3}
1258f9a536caSSushil Singh
1259f9a536caSSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
1260f9a536caSSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
1261f9a536caSSushil Singh
1262f9a536caSSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_list}
1263f9a536caSSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1264f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list_resp['Records']}
1265f9a536caSSushil Singh
1266f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
1267f9a536caSSushil Singh
1268f9a536caSSushil Singh    Redfish Delete Session  ${session_info1}
126911949a2cSSushil Singh
127011949a2cSSushil Singh
127111949a2cSSushil SinghVerify Lock Records For Multiple Invalid And Valid Session
127211949a2cSSushil Singh    [Documentation]  Verify all records found for a valid and invalid sessions.
127311949a2cSSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
127411949a2cSSushil Singh
127511949a2cSSushil Singh    # Description of argument(s):
127611949a2cSSushil Singh    # client_ids    This client id can contain string value
127711949a2cSSushil Singh    #               (e.g. 12345, "HMCID").
127811949a2cSSushil Singh    # lock_type     Read lock or Write lock.
127911949a2cSSushil Singh
128011949a2cSSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
128111949a2cSSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
128211949a2cSSushil Singh    ${trans_id_list1}=  Create List
128311949a2cSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz
128411949a2cSSushil Singh
128511949a2cSSushil Singh    ${session_dict_list}=  Create List
128611949a2cSSushil Singh    ${lock_list}=  Create List
128711949a2cSSushil Singh
128811949a2cSSushil Singh    ${client_id1}=  Create List
128911949a2cSSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
129011949a2cSSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
129111949a2cSSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
129211949a2cSSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
129311949a2cSSushil Singh
129411949a2cSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
129511949a2cSSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
129611949a2cSSushil Singh    Append To List  ${lock_list}  ${trans_id}
129711949a2cSSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
129811949a2cSSushil Singh
129911949a2cSSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
130011949a2cSSushil Singh    set to dictionary  ${session_info2}[0]  SessionIDs  ${invalid_session_ids}[0]
130111949a2cSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
130211949a2cSSushil Singh
130311949a2cSSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
130411949a2cSSushil Singh
130511949a2cSSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
130611949a2cSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
130711949a2cSSushil Singh
130811949a2cSSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
130911949a2cSSushil Singh
131011949a2cSSushil Singh    ${trans_id_emptylist}=  Create List
131111949a2cSSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
131211949a2cSSushil Singh
131311949a2cSSushil Singh    Redfish Delete Session  ${session_info1}[0]
1314