xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_lock_management.robot (revision d8bf1424c1adbfc9d9a2c14b40226df1cae9da06)
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
37*d8bf1424SSushil SinghVerify Lock Is Not Persistent On BMC Reboot
38*d8bf1424SSushil Singh    [Documentation]  Acquire lock and after reboot the locks are removed as no persistency
39*d8bf1424SSushil Singh    ...  maintained.
40*d8bf1424SSushil Singh    [Tags]  Verify_Lock_Is_Not_Persistent_On_BMC_Reboot
41d03f2ce1SSushil Singh    [Template]  Acquire Lock On Resource
42bc331e22SVijay
43d03f2ce1SSushil Singh    # client_id    lock_type     reboot_flag
44d03f2ce1SSushil Singh    HMCID-01       ReadCase1     True
45d03f2ce1SSushil Singh    HMCID-01       ReadCase2     True
46d03f2ce1SSushil Singh    HMCID-01       ReadCase3     True
47d03f2ce1SSushil Singh    HMCID-01       WriteCase1    True
48d03f2ce1SSushil Singh    HMCID-01       WriteCase2    True
49d03f2ce1SSushil Singh    HMCID-01       WriteCase3    True
50bc331e22SVijay
51bc331e22SVijay
52d03f2ce1SSushil SinghAcquire Read Lock On Read Lock
53d03f2ce1SSushil Singh    [Documentation]  Acquire read lock on another read lock.
54d03f2ce1SSushil Singh    [Tags]  Acquire_Read_Lock_On_Read_Lock
55d03f2ce1SSushil Singh    [Template]  Acquire Lock On Another Lock
56bc331e22SVijay
57d03f2ce1SSushil Singh    # client_id
58d03f2ce1SSushil Singh    HMCID-01
59bc331e22SVijay
60bc331e22SVijay
61d03f2ce1SSushil SinghFail To Acquire Lock On Another Lock
62d03f2ce1SSushil Singh    [Documentation]  Fail to acquire another lock.
63d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_On_Another_Lock
64d03f2ce1SSushil Singh    [Template]  Verify Acquire Lock Fails On Another Lock
6585610eeeSVijay
66d03f2ce1SSushil Singh    # client_id    lock_type
67d03f2ce1SSushil Singh    HMCID-01       ReadCase2,WriteCase2
68d03f2ce1SSushil Singh    HMCID-01       WriteCase2,WriteCase2
69d03f2ce1SSushil Singh    HMCID-01       WriteCase2,ReadCase2
70566daaf3SGeorge Keishing
71566daaf3SGeorge Keishing
72e33c6e6aSSushil SinghAcquire Lock After Reboot
73e33c6e6aSSushil Singh    [Documentation]  Acquire and release read and write locks after reboot.
74e33c6e6aSSushil Singh    [Tags]  Acquire_Lock_After_Reboot
75e33c6e6aSSushil Singh    [Template]  Verify Acquire Lock After Reboot
76e33c6e6aSSushil Singh
77e33c6e6aSSushil Singh    # client_id    lock_type
78e33c6e6aSSushil Singh    HMCID-01       ReadCase1
79e33c6e6aSSushil Singh    HMCID-01       ReadCase2
80e33c6e6aSSushil Singh    HMCID-01       ReadCase3
81e33c6e6aSSushil Singh    HMCID-01       WriteCase1
82e33c6e6aSSushil Singh    HMCID-01       WriteCase2
83e33c6e6aSSushil Singh    HMCID-01       WriteCase3
84e33c6e6aSSushil Singh
85e33c6e6aSSushil Singh
86d03f2ce1SSushil SinghAcquire And Release Lock In Loop
87d03f2ce1SSushil Singh    [Documentation]  Acquire and release read, write locks in loop.
88d03f2ce1SSushil Singh    [Tags]  Acquire_And_Release_Lock_In_Loop
89d03f2ce1SSushil Singh    [Template]  Verify Acquire And Release Lock In Loop
90566daaf3SGeorge Keishing
91d03f2ce1SSushil Singh    # client_id    lock_type
92d03f2ce1SSushil Singh    HMCID-01       ReadCase1
93d03f2ce1SSushil Singh    HMCID-01       ReadCase2
94d03f2ce1SSushil Singh    HMCID-01       ReadCase3
95d03f2ce1SSushil Singh    HMCID-01       WriteCase1
96d03f2ce1SSushil Singh    HMCID-01       WriteCase2
97d03f2ce1SSushil Singh    HMCID-01       WriteCase3
9885610eeeSVijay
9985610eeeSVijay
100977f8f58SSushil SinghFail To Acquire Read And Write In Single Request
101977f8f58SSushil Singh    [Documentation]  Fail to acquire read and write lock in single request.
102977f8f58SSushil Singh    [Tags]  Fail_To_Acquire_Read_And_Write_In_Single_Request
103977f8f58SSushil Singh    [Template]  Verify Fail To Acquire Read And Write In Single Request
104977f8f58SSushil Singh
105977f8f58SSushil Singh    # client_id    lock_type
106977f8f58SSushil Singh    HMCID-01       ReadCase1,WriteCase1
107977f8f58SSushil Singh    HMCID-01       WriteCase1,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
191e33c6e6aSSushil SinghTest Invalid Resource ID Data Type Locking
192e33c6e6aSSushil Singh    [Documentation]  Failed to acquire lock for invalid resource id data type.
193e33c6e6aSSushil Singh    [Tags]  Test_Invalid_Resource_ID_Data_Type_Locking
194e33c6e6aSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Resource ID Data Type
195e33c6e6aSSushil Singh
196e33c6e6aSSushil Singh    # client_id    lock_type
197e33c6e6aSSushil Singh    HMCID-01       ReadCase1
198e33c6e6aSSushil Singh    HMCID-01       ReadCase2
199e33c6e6aSSushil Singh    HMCID-01       ReadCase3
200e33c6e6aSSushil Singh    HMCID-01       WriteCase1
201e33c6e6aSSushil Singh    HMCID-01       WriteCase2
202e33c6e6aSSushil Singh    HMCID-01       WriteCase3
203e33c6e6aSSushil Singh
204e33c6e6aSSushil Singh
205d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Type
206d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read, write lock for invalid lock data passed.
207d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Type
208d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
209afdd2a1dSVijay
210d03f2ce1SSushil Singh    # client_id    lock_type      message
211d03f2ce1SSushil Singh    HMCID-01       ReadCase1      ${BAD_REQUEST}
212d03f2ce1SSushil Singh    HMCID-01       ReadCase2      ${BAD_REQUEST}
213d03f2ce1SSushil Singh    HMCID-01       ReadCase3      ${BAD_REQUEST}
214d03f2ce1SSushil Singh    HMCID-01       ReadCase4      ${BAD_REQUEST}
215d03f2ce1SSushil Singh    HMCID-01       ReadCase5      ${BAD_REQUEST}
216d03f2ce1SSushil Singh    HMCID-01       WriteCase1     ${BAD_REQUEST}
217d03f2ce1SSushil Singh    HMCID-01       WriteCase2     ${BAD_REQUEST}
218d03f2ce1SSushil Singh    HMCID-01       WriteCase3     ${BAD_REQUEST}
219d03f2ce1SSushil Singh    HMCID-01       WriteCase4     ${BAD_REQUEST}
220d03f2ce1SSushil Singh    HMCID-01       WriteCase5     ${BAD_REQUEST}
221afdd2a1dSVijay
222afdd2a1dSVijay
223d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Flag
224d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid lock flag passed.
225d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
226d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
227afdd2a1dSVijay
228d03f2ce1SSushil Singh    # client_id    lock_type       message
229d03f2ce1SSushil Singh    HMCID-01       ReadCase6       ${BAD_REQUEST}
230d03f2ce1SSushil Singh    HMCID-01       ReadCase7       ${BAD_REQUEST}
231d03f2ce1SSushil Singh    HMCID-01       ReadCase8       ${BAD_REQUEST}
232d03f2ce1SSushil Singh    HMCID-01       ReadCase9       ${BAD_REQUEST}
233d03f2ce1SSushil Singh    HMCID-01       ReadCase10      ${BAD_REQUEST}
234d03f2ce1SSushil Singh    HMCID-01       ReadCase11      ${BAD_REQUEST}
235d03f2ce1SSushil Singh    HMCID-01       WriteCase6      ${BAD_REQUEST}
236d03f2ce1SSushil Singh    HMCID-01       WriteCase7      ${BAD_REQUEST}
237d03f2ce1SSushil Singh    HMCID-01       WriteCase8      ${BAD_REQUEST}
238d03f2ce1SSushil Singh    HMCID-01       WriteCase9      ${BAD_REQUEST}
239d03f2ce1SSushil Singh    HMCID-01       WriteCase10     ${BAD_REQUEST}
240d03f2ce1SSushil Singh    HMCID-01       WriteCase11     ${BAD_REQUEST}
241afdd2a1dSVijay
242afdd2a1dSVijay
243d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Segment Flag
244d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
245d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Flag
246d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
247d03f2ce1SSushil Singh
248d03f2ce1SSushil Singh    # client_id    lock_type       message
249d03f2ce1SSushil Singh    HMCID-01       ReadCase12      ${BAD_REQUEST}
250d03f2ce1SSushil Singh    HMCID-01       ReadCase13      ${BAD_REQUEST}
251d03f2ce1SSushil Singh    HMCID-01       ReadCase14      ${BAD_REQUEST}
252d03f2ce1SSushil Singh    HMCID-01       WriteCase12     ${BAD_REQUEST}
253d03f2ce1SSushil Singh    HMCID-01       WriteCase13     ${BAD_REQUEST}
254d03f2ce1SSushil Singh    HMCID-01       WriteCase14     ${BAD_REQUEST}
255afdd2a1dSVijay
256bace3005SSushil Singh
2573b3a7ecaSSushil SinghFail To Acquire Lock For Invalid Segment Data Type Flag
2583b3a7ecaSSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
2593b3a7ecaSSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Data_Type_Flag
2603b3a7ecaSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
2613b3a7ecaSSushil Singh
2623b3a7ecaSSushil Singh    # client_id    lock_type       message
2633b3a7ecaSSushil Singh    HMCID-01       ReadCase15      ${EMPTY}
2643b3a7ecaSSushil Singh    HMCID-01       ReadCase16      ${EMPTY}
2653b3a7ecaSSushil Singh    HMCID-01       ReadCase17      ${EMPTY}
2663b3a7ecaSSushil Singh    HMCID-01       ReadCase18      ${EMPTY}
2673b3a7ecaSSushil Singh    HMCID-01       WriteCase15     ${EMPTY}
2683b3a7ecaSSushil Singh    HMCID-01       WriteCase16     ${EMPTY}
2693b3a7ecaSSushil Singh    HMCID-01       WriteCase17     ${EMPTY}
2703b3a7ecaSSushil Singh    HMCID-01       WriteCase18     ${EMPTY}
2713b3a7ecaSSushil Singh
2723b3a7ecaSSushil Singh
273bace3005SSushil SinghGet Empty Lock Records For Session Where No Locks Acquired
274bace3005SSushil Singh    [Documentation]  If session does not acquire locks then get lock should return
275bace3005SSushil Singh    ...              empty lock records.
276bace3005SSushil Singh    [Tags]  Get_Empty_Lock_Records_For_Session_Where_No_Locks_Acquired
277bace3005SSushil Singh    [Template]  Verify No Locks Records For Session With No Acquired Lock
278bace3005SSushil Singh
279bace3005SSushil Singh    # client_id
280bace3005SSushil Singh    HMCID-01
281bace3005SSushil Singh
282728ef9c9SSushil Singh
283f9a536caSSushil SinghGet Lock Records Empty For Invalid Session
284f9a536caSSushil Singh    [Documentation]  Record of lock list is empty for invalid session.
285f9a536caSSushil Singh    [Tags]  Get_Lock_Records_Empty_For_Invalid_Session
286f9a536caSSushil Singh    [Template]  Verify Empty Lock Records For Invalid Session
287f9a536caSSushil Singh
288f9a536caSSushil Singh    # client_id
289f9a536caSSushil Singh    HMCID-01
290f9a536caSSushil Singh
291f9a536caSSushil Singh
292728ef9c9SSushil SinghGet Lock Records For Multiple Session
293728ef9c9SSushil Singh    [Documentation]  Get lock records of multiple session.
294728ef9c9SSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Session
295728ef9c9SSushil Singh    [Template]  Verify Lock Records Of Multiple Session
296728ef9c9SSushil Singh
297728ef9c9SSushil Singh    # client_ids         lock_type
298728ef9c9SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
299728ef9c9SSushil Singh
300728ef9c9SSushil Singh
301f9a536caSSushil SinghGet Lock Records For Multiple Invalid Session
302f9a536caSSushil Singh    [Documentation]  Record of lock list is empty for list of invalid session.
303f9a536caSSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Invalid_Session
304f9a536caSSushil Singh    [Template]  Verify Lock Records For Multiple Invalid Session
305f9a536caSSushil Singh
306f9a536caSSushil Singh    # client_id
307f9a536caSSushil Singh    HMCID-01
308f9a536caSSushil Singh
30911949a2cSSushil Singh
31011949a2cSSushil SinghGet Lock Records For Multiple Invalid And Valid Session
31111949a2cSSushil Singh    [Documentation]  Get record of lock from invalid and valid session.
31211949a2cSSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Invalid_And_Valid_Session
31311949a2cSSushil Singh    [Template]  Verify Lock Records For Multiple Invalid And Valid Session
31411949a2cSSushil Singh
31511949a2cSSushil Singh    # client_id          lock_type
31611949a2cSSushil Singh    HMCID-01,HMCID-02    ReadCase1
31711949a2cSSushil Singh
318bc331e22SVijay*** Keywords ***
319bc331e22SVijay
320d03f2ce1SSushil SinghCreate Redfish Session With ClientID
321d03f2ce1SSushil Singh    [Documentation]  Create redifish session with client id.
322d03f2ce1SSushil Singh    [Arguments]  ${client_id}
32385610eeeSVijay
32485610eeeSVijay    # Description of argument(s):
325d03f2ce1SSushil Singh    # client_id    This client id can contain string value
326d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
32785610eeeSVijay
328d03f2ce1SSushil Singh    ${session_info}=  Create Dictionary
329d03f2ce1SSushil Singh    ${session}=  Redfish Login  kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
33085610eeeSVijay
331d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  SessionIDs  ${session['Id']}
332d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  ClientID  ${session["Oem"]["OpenBMC"]["ClientID"]}
33385610eeeSVijay
334d03f2ce1SSushil Singh    [Return]  ${session_info}
33585610eeeSVijay
33685610eeeSVijay
337d03f2ce1SSushil SinghRW General Dictionary
33816b3c7bfSGeorge Keishing    [Documentation]  Create dictionary of lock request.
339d03f2ce1SSushil Singh    [Arguments]  ${read_case}  ${res_id}
340bc331e22SVijay
341bc331e22SVijay    # Description of argument(s):
342d03f2ce1SSushil Singh    # read_case    Read or Write lock type.
343d03f2ce1SSushil Singh    # res_id       Resource id.
344bc331e22SVijay
345d03f2ce1SSushil Singh    ${request_dict}=  Create Dictionary
346566daaf3SGeorge Keishing
347d03f2ce1SSushil Singh    FOR  ${key}  IN  @{read_case.keys()}
348d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  LockType  ${key}
349d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  SegmentFlags  ${read_case["${key}"]}
350d03f2ce1SSushil Singh    END
351bc331e22SVijay
352d03f2ce1SSushil Singh    Set To Dictionary  ${request_dict}  ResourceID  ${res_id}
353d03f2ce1SSushil Singh
354d03f2ce1SSushil Singh    [Return]  ${request_dict}
355bc331e22SVijay
356bc331e22SVijay
357d03f2ce1SSushil SinghReturn Description Of Response
358d03f2ce1SSushil Singh    [Documentation]  Return description of REST response.
359bc331e22SVijay    [Arguments]  ${resp_text}
360bc331e22SVijay
361bc331e22SVijay    # Description of argument(s):
362d03f2ce1SSushil Singh    # resp_text    REST response body.
363bc331e22SVijay
364d03f2ce1SSushil Singh    # resp_text after successful partition file upload looks like:
365d03f2ce1SSushil Singh    # {
366d03f2ce1SSushil Singh    #    "Description": "File Created"
367d03f2ce1SSushil Singh    # }
368bc331e22SVijay
369d03f2ce1SSushil Singh    ${message}=  Evaluate  json.loads('''${resp_text}''')  json
370d03f2ce1SSushil Singh
371d03f2ce1SSushil Singh    [Return]  ${message}
372bc331e22SVijay
373bc331e22SVijay
374a7d71f02SSushil SinghVerify Redfish Session Deleted
375a7d71f02SSushil Singh    [Documentation]  Verify the redfish session is deleted.
376a7d71f02SSushil Singh    [Arguments]  ${session_info}
377a7d71f02SSushil Singh
378a7d71f02SSushil Singh    # Description of argument(s):
379a7d71f02SSushil Singh    # session_info    Session information are stored in dictionary.
380a7d71f02SSushil Singh
381a7d71f02SSushil Singh    # ${session_info} = {
382a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
383a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
384a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
385a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
386a7d71f02SSushil Singh    # }
387a7d71f02SSushil Singh
388a7d71f02SSushil Singh    # SessionIDs   : Session IDs
389a7d71f02SSushil Singh    # ClientID     : Client ID
390a7d71f02SSushil Singh    # SessionToken : Session token
391a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
392a7d71f02SSushil Singh
393a7d71f02SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions
394a7d71f02SSushil Singh
395a7d71f02SSushil Singh    FOR  ${session}  IN  @{sessions['Members']}
3968a3efe7cSSushil Singh      Should Not Be Equal As Strings
3978a3efe7cSSushil Singh      ...  session  ['/redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}']
398a7d71f02SSushil Singh    END
399a7d71f02SSushil Singh
400a7d71f02SSushil Singh
401a7d71f02SSushil SinghVerify Redfish List Of Session Deleted
402a7d71f02SSushil Singh    [Documentation]  Verify all the list of redfish session is deleted.
403a7d71f02SSushil Singh    [Arguments]  ${session_info_list}
404a7d71f02SSushil Singh
405a7d71f02SSushil Singh    # Description of argument(s):
406a7d71f02SSushil Singh    # session_info_list    List contains individual session record are stored in dictionary.
407a7d71f02SSushil Singh
408a7d71f02SSushil Singh    # ${session_info_list} = [{
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    FOR  ${session_record}  IN  @{session_info_list}
421a7d71f02SSushil Singh      Verify Redfish Session Deleted  ${session_record}
422a7d71f02SSushil Singh    END
423a7d71f02SSushil Singh
424a7d71f02SSushil Singh
425d03f2ce1SSushil SinghRedfish Post Acquire Lock
426d03f2ce1SSushil Singh    [Documentation]  Acquire and release lock.
427d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
428bc331e22SVijay
429bc331e22SVijay    # Description of argument(s):
430d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
431d03f2ce1SSushil Singh    # status_code    HTTP status code.
432bc331e22SVijay
433e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Lock  ${lock_type}
4348a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
4358a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
436d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
437df390b61SSushil Singh
438df390b61SSushil Singh    Run Keyword If  ${status_code} == ${HTTP_BAD_REQUEST}
439df390b61SSushil Singh    ...    Valid Value  ${BAD_REQUEST}  ['${resp.content}']
440df390b61SSushil Singh    ...  ELSE
441df390b61SSushil Singh    ...    Run Keyword And Return  Return Description Of Response  ${resp.content}
442bc331e22SVijay
443d03f2ce1SSushil Singh    [Return]  ${resp}
444bc331e22SVijay
445bc331e22SVijay
446977f8f58SSushil SinghRedfish Post Acquire List Lock
447977f8f58SSushil Singh    [Documentation]  Acquire and release lock.
448977f8f58SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
449977f8f58SSushil Singh
450977f8f58SSushil Singh    # Description of argument(s):
451977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
452977f8f58SSushil Singh    # status_code    HTTP status code.
453977f8f58SSushil Singh
454977f8f58SSushil Singh    ${lock_dict_param}=  Create Data To Acquire List Of Lock  ${lock_type}
4558a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
4568a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
457977f8f58SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
458977f8f58SSushil Singh
459977f8f58SSushil Singh    [Return]  ${resp}
460977f8f58SSushil Singh
461977f8f58SSushil Singh
462d03f2ce1SSushil SinghRedfish Post Acquire Invalid Lock
463d03f2ce1SSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock.
464d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${message}  ${status_code}=${HTTP_OK}
465bc331e22SVijay
466bc331e22SVijay    # Description of argument(s):
467d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
468d03f2ce1SSushil Singh    # message        Return message from URI.
469d03f2ce1SSushil Singh    # status_code    HTTP status code.
470bc331e22SVijay
471e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Invalid Lock  ${lock_type}
4728a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
4738a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
474d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
4753b3a7ecaSSushil Singh    Run Keyword If  '${message}' != '${EMPTY}'
4763b3a7ecaSSushil Singh    ...  Valid Value  message  ['${resp.content}']
477d03f2ce1SSushil Singh
478d03f2ce1SSushil Singh    [Return]  ${resp}
479bc331e22SVijay
480bc331e22SVijay
481e33c6e6aSSushil SinghRedfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
482e33c6e6aSSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock with invalid data type of resource id.
483e33c6e6aSSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
484e33c6e6aSSushil Singh
485e33c6e6aSSushil Singh    # Description of argument(s):
486e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
487e33c6e6aSSushil Singh    # status_code    HTTP status code.
488e33c6e6aSSushil Singh
4898a3efe7cSSushil Singh    ${lock_dict_param}=
4908a3efe7cSSushil Singh    ...  Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID  ${lock_type}
4918a3efe7cSSushil Singh    ${resp}=  Redfish Post Request
4928a3efe7cSSushil Singh    ...  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
493e33c6e6aSSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
494e33c6e6aSSushil Singh
495e33c6e6aSSushil Singh    [Return]  ${resp}
496e33c6e6aSSushil Singh
497e33c6e6aSSushil Singh
498d03f2ce1SSushil SinghForm Data To Acquire Lock
49916b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for lock request.
500d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
501d03f2ce1SSushil Singh
502d03f2ce1SSushil Singh    # Description of argument(s):
503d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
504d03f2ce1SSushil Singh
505d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
506d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
507d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
508d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
509d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
510e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
511d03f2ce1SSushil Singh
512e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
513e33c6e6aSSushil Singh
514e33c6e6aSSushil Singh
515977f8f58SSushil SinghCreate Data To Acquire List Of Lock
51616b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for list of lock request.
517977f8f58SSushil Singh    [Arguments]  ${lock_type_list}
518977f8f58SSushil Singh
519977f8f58SSushil Singh    # Description of argument(s):
520977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
521977f8f58SSushil Singh
522977f8f58SSushil Singh    ${temp_list}=  Create List
523977f8f58SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
524977f8f58SSushil Singh
525977f8f58SSushil Singh    FOR  ${lock_type}  IN  @{lock_type_list}
526977f8f58SSushil Singh      ${resp}=  RW General Dictionary
527977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
528977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["ResourceID"]}
529977f8f58SSushil Singh      Append To List  ${temp_list}  ${resp}
530977f8f58SSushil Singh    END
531977f8f58SSushil Singh
532977f8f58SSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
533977f8f58SSushil Singh
534977f8f58SSushil Singh    [Return]  ${lock_request_dict}
535977f8f58SSushil Singh
536977f8f58SSushil Singh
537e33c6e6aSSushil SinghForm Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
53816b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for in-valid lock request.
539e33c6e6aSSushil Singh    [Arguments]  ${lock_type}
540e33c6e6aSSushil Singh
541e33c6e6aSSushil Singh    # Description of argument(s):
542e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
543e33c6e6aSSushil Singh
544e33c6e6aSSushil Singh    ${lock_res_info}=  Get Lock Resource Information
545e33c6e6aSSushil Singh    ${resp}=  RW General Dictionary
546e33c6e6aSSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
547e33c6e6aSSushil Singh    ...    ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
548e33c6e6aSSushil Singh    ${temp_list}=  Create List  ${resp}
549e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
550e33c6e6aSSushil Singh
551e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
552d03f2ce1SSushil Singh
553d03f2ce1SSushil Singh
554d03f2ce1SSushil SinghForm Data To Acquire Invalid Lock
55516b3c7bfSGeorge Keishing    [Documentation]  Create a dictionary for in-valid lock request.
556d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
557d03f2ce1SSushil Singh
558d03f2ce1SSushil Singh    # Description of argument(s):
559d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
560d03f2ce1SSushil Singh
561d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
562d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
563d03f2ce1SSushil Singh    ...    ${lock_res_info["Invalid Case"]["${lock_type}"]}
564d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
565d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
566e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
567d03f2ce1SSushil Singh
568e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
569d03f2ce1SSushil Singh
570d03f2ce1SSushil Singh
571d03f2ce1SSushil SinghGet Locks List On Resource
572bc331e22SVijay    [Documentation]  Get locks list.
573d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${exp_status_code}=${HTTP_OK}
574bc331e22SVijay
575bc331e22SVijay    # Description of argument(s):
576d03f2ce1SSushil Singh    # session_info       Session information in dict.
577d03f2ce1SSushil Singh    # exp_status_code    Expected HTTP status code.
578bc331e22SVijay
579d03f2ce1SSushil Singh    ${data}=  Set Variable  {"SessionIDs": ["${session_info['SessionIDs']}"]}
580566daaf3SGeorge Keishing    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
581566daaf3SGeorge Keishing    ...  data=${data}
582bc331e22SVijay    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
583bc331e22SVijay
584bc331e22SVijay    [Return]  ${locks["Records"]}
585bc331e22SVijay
586bc331e22SVijay
587d03f2ce1SSushil SinghVerify Lock On Resource
588d03f2ce1SSushil Singh    [Documentation]  Verify lock on resource.
589d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${transaction_id}
590bc331e22SVijay
591bc331e22SVijay    # Description of argument(s):
592d03f2ce1SSushil Singh    # session_info      Session information in dict.
593d03f2ce1SSushil Singh    # transaction_id    Transaction id in list stored in dict.
594bc331e22SVijay
595d03f2ce1SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
596d03f2ce1SSushil Singh    Rprint Vars  sessions
597d03f2ce1SSushil Singh    ${lock_list}=  Get Locks List On Resource  ${session_info}
598d03f2ce1SSushil Singh    ${lock_length}=  Get Length  ${lock_list}
599d03f2ce1SSushil Singh    ${tran_id_length}=  Get Length  ${transaction_id}
600d03f2ce1SSushil Singh    Should Be Equal As Integers  ${tran_id_length}  ${lock_length}
601afdd2a1dSVijay
602d03f2ce1SSushil Singh    FOR  ${tran_id}  ${lock}  IN ZIP  ${transaction_id}  ${lock_list}
603d03f2ce1SSushil Singh      Valid Value  session_info['ClientID']  ['${lock['HMCID']}']
604d03f2ce1SSushil Singh      Valid Value  session_info['SessionIDs']  ['${lock['SessionID']}']
605d03f2ce1SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock['TransactionID']}
606bc331e22SVijay    END
607bc331e22SVijay
608bc331e22SVijay
609d03f2ce1SSushil SinghAcquire Lock On Resource
610d03f2ce1SSushil Singh    [Documentation]  Acquire lock on resource.
611d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${reboot_flag}=False
612bc331e22SVijay
613bc331e22SVijay    # Description of argument(s):
614d03f2ce1SSushil Singh    # client_id    This client id can contain string value
615d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
616d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
617d03f2ce1SSushil Singh    # reboot_flag  Flag is used to run reboot the BMC code.
618d03f2ce1SSushil Singh    #               (e.g. True or False).
619bc331e22SVijay
6208a3efe7cSSushil Singh    ${trans_id_emptylist}=  Create List
621d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
6228a3efe7cSSushil Singh
623d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
624d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
625d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
6268a3efe7cSSushil Singh
627d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
628566daaf3SGeorge Keishing
629e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
630bc331e22SVijay
631d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'True'
6328a3efe7cSSushil Singh    ...  Run Keywords  Redfish BMC Reset Operation  AND
633e33c6e6aSSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
6348a3efe7cSSushil Singh    ...  Is BMC Standby  AND
6358a3efe7cSSushil Singh    ...  Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
636bc331e22SVijay
637d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'False'
638d03f2ce1SSushil Singh    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
639bc331e22SVijay
640d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
641d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
642d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
643bc331e22SVijay
644bc331e22SVijay
645d03f2ce1SSushil SinghForm Data To Release Lock
646d03f2ce1SSushil Singh    [Documentation]  Create a dictonay to release lock.
647d03f2ce1SSushil Singh    [Arguments]  ${trans_id_list}
648355daac7SVijay
649355daac7SVijay    # Description of argument(s):
650d03f2ce1SSushil Singh    # trans_id_list
651355daac7SVijay
652d03f2ce1SSushil Singh    @{tran_ids}=  Create List
653355daac7SVijay
654d03f2ce1SSushil Singh    FOR  ${item}  IN  @{trans_id_list}
655d03f2ce1SSushil Singh      Append To List  ${tran_ids}  ${item['TransactionID']}
656d03f2ce1SSushil Singh    END
657d03f2ce1SSushil Singh
658d03f2ce1SSushil Singh    [Return]  ${tran_ids}
659d03f2ce1SSushil Singh
660d03f2ce1SSushil Singh
661d03f2ce1SSushil SinghRelease Locks On Resource
662d03f2ce1SSushil Singh    [Documentation]  Redfish request to release a lock.
6638a3efe7cSSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}  ${release_lock_type}=Transaction
6648a3efe7cSSushil Singh    ...  ${status_code}=${HTTP_OK}
665d03f2ce1SSushil Singh
666d03f2ce1SSushil Singh    # Description of argument(s):
667d03f2ce1SSushil Singh    # session_info        Session information in dict.
668d03f2ce1SSushil Singh    # trans_id_list       Transaction id list.
669d03f2ce1SSushil Singh    # release_lock_type   Release lock by Transaction, Session.
670d03f2ce1SSushil Singh    # status_code         HTTP status code.
671d03f2ce1SSushil Singh
672d03f2ce1SSushil Singh    ${tran_ids}=  Form Data To Release Lock  ${trans_id_list}
673d03f2ce1SSushil Singh    ${data}=  Set Variable  {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
674d03f2ce1SSushil Singh    ${data}=  Evaluate  json.dumps(${data})  json
675d03f2ce1SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock  data=${data}
676d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
677d03f2ce1SSushil Singh
678d03f2ce1SSushil Singh
679df390b61SSushil SinghRelease locks And Delete Session
680df390b61SSushil Singh    [Documentation]  Release locks and delete redfish session.
681df390b61SSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}
682df390b61SSushil Singh
683df390b61SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}
684df390b61SSushil Singh
685df390b61SSushil Singh    ${trans_id_emptylist}=  Create List
686df390b61SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
687df390b61SSushil Singh
688df390b61SSushil Singh    Redfish Delete Session  ${session_info}
689df390b61SSushil Singh
690df390b61SSushil Singh
691d03f2ce1SSushil SinghAcquire Lock On Another Lock
692d03f2ce1SSushil Singh    [Documentation]  Acquire lock on another lock.
693d03f2ce1SSushil Singh    [Arguments]  ${client_id}
694d03f2ce1SSushil Singh
695d03f2ce1SSushil Singh    # Description of argument(s):
696d03f2ce1SSushil Singh    # client_id    This client id can contain string value
697d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
698d03f2ce1SSushil Singh
699d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
700d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
701d03f2ce1SSushil Singh
702d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
703d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
704d03f2ce1SSushil Singh
705d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
706d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
707d03f2ce1SSushil Singh
708d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
709d03f2ce1SSushil Singh
710df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
711d03f2ce1SSushil Singh
712d03f2ce1SSushil Singh
713977f8f58SSushil SinghVerify Fail To Acquire Read And Write In Single Request
714977f8f58SSushil Singh    [Documentation]  Verify fail to acquire read and write lock passed in single request.
715977f8f58SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
716977f8f58SSushil Singh
717977f8f58SSushil Singh    # Description of argument(s):
718977f8f58SSushil Singh    # client_id    This client id can contain string value
719977f8f58SSushil Singh    #              (e.g. 12345, "HMCID").
720977f8f58SSushil Singh    # lock_type    Read lock or Write lock.
721977f8f58SSushil Singh
722977f8f58SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
723977f8f58SSushil Singh
724977f8f58SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
725977f8f58SSushil Singh    ${trans_id}=  Redfish Post Acquire List Lock  ${lock_type_list}  status_code=${HTTP_BAD_REQUEST}
726977f8f58SSushil Singh    Redfish Delete Session  ${session_info}
727977f8f58SSushil Singh
728977f8f58SSushil Singh
729d03f2ce1SSushil SinghVerify Empty Lock Records For Invalid Session
730d03f2ce1SSushil Singh    [Documentation]  Verify no lock record found for invalid session.
731d03f2ce1SSushil Singh    [Arguments]  ${client_id}
732d03f2ce1SSushil Singh
733d03f2ce1SSushil Singh    # Description of argument(s):
734d03f2ce1SSushil Singh    # client_id    This client id can contain string value
735d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
736d03f2ce1SSushil Singh
737d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_id}
738d03f2ce1SSushil Singh
739d03f2ce1SSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
740d03f2ce1SSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
741d03f2ce1SSushil Singh
742d03f2ce1SSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
743d03f2ce1SSushil Singh    set to dictionary  ${session_info2}  SessionIDs  xxyXyyYZZz
744d03f2ce1SSushil Singh
745d03f2ce1SSushil Singh    ${lock_list2}=  Get Locks List On Resource  ${session_info2}
746f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list2}
747d03f2ce1SSushil Singh
748f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
749d03f2ce1SSushil Singh
750d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
751d03f2ce1SSushil Singh
752d03f2ce1SSushil Singh
753d03f2ce1SSushil SinghVerify Acquire Lock Fails On Another Lock
754d03f2ce1SSushil Singh    [Documentation]  Verify acquire lock on another lock fails.
755d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
756d03f2ce1SSushil Singh
757d03f2ce1SSushil Singh    # Description of argument(s):
758d03f2ce1SSushil Singh    # client_id    This client id can contain string value
759d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
760d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
761d03f2ce1SSushil Singh
762d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
763d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
764d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
765d03f2ce1SSushil Singh
766d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
767d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
768d03f2ce1SSushil Singh
769d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
770d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
771d03f2ce1SSushil Singh
772df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
773d03f2ce1SSushil Singh
774d03f2ce1SSushil Singh
775e33c6e6aSSushil SinghVerify Acquire Lock After Reboot
776e33c6e6aSSushil Singh    [Documentation]  Acquire read and write lock after the reboot and release lock.
777e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
778e33c6e6aSSushil Singh
779e33c6e6aSSushil Singh    # Description of argument(s):
780e33c6e6aSSushil Singh    # client_id    This client id can contain string value
781e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
782e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
783e33c6e6aSSushil Singh
784e33c6e6aSSushil Singh    ${trans_id_list}=  Create List
785f9a536caSSushil Singh    ${session_info}=  Create Session With ClientID  ${client_id}
786e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
787e33c6e6aSSushil Singh    Redfish OBMC Reboot (off)
788e33c6e6aSSushil Singh    Redfish Login
789e33c6e6aSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}
790e33c6e6aSSushil Singh
791e33c6e6aSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
792e33c6e6aSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
793e33c6e6aSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
794e33c6e6aSSushil Singh
795df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
796df390b61SSushil Singh
797df390b61SSushil Singh
798df390b61SSushil SinghVerify Acquire Multiple Lock Request At CEC Level
799df390b61SSushil Singh    [Documentation]  Acquire lock in loop.
800df390b61SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
801df390b61SSushil Singh
802df390b61SSushil Singh    # Description of argument(s):
803df390b61SSushil Singh    # client_id    This client id can contain string value
804df390b61SSushil Singh    #              (e.g. 12345, "HMCID").
805df390b61SSushil Singh    # lock_type    Read lock or Write lock.
806df390b61SSushil Singh
807df390b61SSushil Singh    ${trans_id_list}=  Create List
808df390b61SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
809df390b61SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
810df390b61SSushil Singh
811df390b61SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
812df390b61SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
813df390b61SSushil Singh
814df390b61SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
815df390b61SSushil Singh
816df390b61SSushil Singh    Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
817df390b61SSushil Singh
818df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
819e33c6e6aSSushil Singh
820e33c6e6aSSushil Singh
821d03f2ce1SSushil SinghVerify Acquire And Release Lock In Loop
822d03f2ce1SSushil Singh    [Documentation]  Acquire lock in loop.
823d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
824d03f2ce1SSushil Singh
825d03f2ce1SSushil Singh    # Description of argument(s):
826d03f2ce1SSushil Singh    # client_id    This client id can contain string value
827d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
828d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
829d03f2ce1SSushil Singh
830d03f2ce1SSushil Singh    FOR  ${count}  IN RANGE  1  11
831d03f2ce1SSushil Singh      ${trans_id_list}=  Create List
832d03f2ce1SSushil Singh      ${session_info}=  Create Redfish Session With ClientID  ${client_id}
833d03f2ce1SSushil Singh      ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
834d03f2ce1SSushil Singh      Append To List  ${trans_id_list}  ${trans_id}
835d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_list}
836d03f2ce1SSushil Singh      Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
837d03f2ce1SSushil Singh      ${trans_id_emptylist}=  Create List
838d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
839d03f2ce1SSushil Singh    END
840d03f2ce1SSushil Singh
841d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
842d03f2ce1SSushil Singh
843d03f2ce1SSushil Singh
844d03f2ce1SSushil SinghAcquire And Release Multiple Locks
845d03f2ce1SSushil Singh    [Documentation]  Acquire mutilple locks on resource.
846d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
847d03f2ce1SSushil Singh
848d03f2ce1SSushil Singh    # Description of argument(s):
849d03f2ce1SSushil Singh    # client_id          This client id can contain string value
850d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
851d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
852d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
853d03f2ce1SSushil Singh
854d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
855d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
856d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
857d03f2ce1SSushil Singh
858d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
859d03f2ce1SSushil Singh
860d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
861d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
862d03f2ce1SSushil Singh
863d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
864d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
865d03f2ce1SSushil Singh
866d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
867d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
868d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
869d03f2ce1SSushil Singh
870d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
871d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
872d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
873d03f2ce1SSushil Singh
874d03f2ce1SSushil Singh
87594116c61Ssusilsi7Verify Release Lock When Session Deleted
87694116c61Ssusilsi7    [Documentation]  Verify lock get released when session are deleted.
87794116c61Ssusilsi7    [Arguments]  ${client_id}  ${lock_type}
87894116c61Ssusilsi7
87994116c61Ssusilsi7    # Description of argument(s):
88094116c61Ssusilsi7    # client_ids    This client id can contain string value
88194116c61Ssusilsi7    #               (e.g. 12345, "HMCID").
88294116c61Ssusilsi7    # lock_type     Read lock or Write lock.
88394116c61Ssusilsi7
88494116c61Ssusilsi7    ${trans_id_list}=  Create List
88594116c61Ssusilsi7    @{lock_type_list}=  Split String  ${lock_type}  ,
88694116c61Ssusilsi7
88794116c61Ssusilsi7    ${pre_session_info}=  Create Redfish Session With ClientID  ${client_id}
88894116c61Ssusilsi7
88994116c61Ssusilsi7    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
89094116c61Ssusilsi7    Append To List  ${trans_id_list}  ${trans_id}
89194116c61Ssusilsi7    Verify Lock On Resource  ${pre_session_info}  ${trans_id_list}
89294116c61Ssusilsi7
89394116c61Ssusilsi7    Redfish Delete Session  ${pre_session_info}
89494116c61Ssusilsi7    ${post_session_info}=  Create Redfish Session With ClientID  ${client_id}
89594116c61Ssusilsi7    ${resp}=  Get Locks List On Resource With Session List  ${pre_session_info}  ${HTTP_BAD_REQUEST}
89694116c61Ssusilsi7
89794116c61Ssusilsi7    Redfish Delete Session  ${post_session_info}
89894116c61Ssusilsi7
89994116c61Ssusilsi7
90094116c61Ssusilsi7
90159011d08SSushil SinghVerify Fail To Release Lock With Invalid TransactionID
90216b3c7bfSGeorge Keishing    [Documentation]  Verify fail to be release lock with invalid transaction ID.
90359011d08SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
90459011d08SSushil Singh
90559011d08SSushil Singh    # Description of argument(s):
90659011d08SSushil Singh    # client_id          This client id can contain string value
90759011d08SSushil Singh    #                    (e.g. 12345, "HMCID").
90859011d08SSushil Singh    # lock_type          Read lock or Write lock.
90959011d08SSushil Singh    # release_lock_type  The value can be Transaction or Session.
91059011d08SSushil Singh
91159011d08SSushil Singh    ${trans_id_list}=  Create List
91259011d08SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
91359011d08SSushil Singh
91459011d08SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
91559011d08SSushil Singh
91659011d08SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
91759011d08SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
91859011d08SSushil Singh    ${value}=  Evaluate  ${value} + 10
91959011d08SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
92059011d08SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
92159011d08SSushil Singh
92259011d08SSushil Singh    Release Locks On Resource
92359011d08SSushil Singh    ...  ${session_info}  ${trans_id_list}
92459011d08SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
92559011d08SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
92659011d08SSushil Singh
92759011d08SSushil Singh    ${trans_id_emptylist}=  Create List
92859011d08SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
92959011d08SSushil Singh    Redfish Delete Session  ${session_info}
93059011d08SSushil Singh
93159011d08SSushil Singh
9321b59053dSSushil SinghVerify Fail To Release Multiple Lock With Invalid TransactionID
9331b59053dSSushil Singh    [Documentation]  Verify release multiple locks with invalid transaction ID fails.
934d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
935d03f2ce1SSushil Singh
936d03f2ce1SSushil Singh    # Description of argument(s):
937d03f2ce1SSushil Singh    # client_id          This client id can contain string value
938d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
939d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
940d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
941d03f2ce1SSushil Singh
942d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
943d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
944d03f2ce1SSushil Singh
945d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
946d03f2ce1SSushil Singh
947d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
948d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
949d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
950d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
951d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
952d03f2ce1SSushil Singh
953d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
954d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
955d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
956d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
957d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
958d03f2ce1SSushil Singh
959d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
960d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
961d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
962d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
963d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
964d03f2ce1SSushil Singh
965d03f2ce1SSushil Singh    Release Locks On Resource
966d03f2ce1SSushil Singh    ...  ${session_info}  ${trans_id_list}
967d03f2ce1SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
968d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
969d03f2ce1SSushil Singh
970d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
971d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
972d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
973d03f2ce1SSushil Singh
974d03f2ce1SSushil Singh
9758bee358fSSushil SinghVerify Fail To Release Multiple Lock With Valid And Invalid TransactionID
9769614383dSGeorge Keishing    [Documentation]  Verify fail to be release multiple lock with valid and invalid transaction ID.
9778bee358fSSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
9788bee358fSSushil Singh
9798bee358fSSushil Singh    # Description of argument(s):
9808bee358fSSushil Singh    # client_id          This client id can contain string value
9818bee358fSSushil Singh    #                    (e.g. 12345, "HMCID").
9828bee358fSSushil Singh    # lock_type          Read lock or Write lock.
9838bee358fSSushil Singh    # release_lock_type  The value can be Transaction or Session.
9848bee358fSSushil Singh
9858bee358fSSushil Singh    ${trans_id_list}=  Create List
9868bee358fSSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
9878bee358fSSushil Singh
9888bee358fSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
9898bee358fSSushil Singh
9908bee358fSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
9918bee358fSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
9928bee358fSSushil Singh
9938bee358fSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
9948bee358fSSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
9958bee358fSSushil Singh    ${value}=  Evaluate  ${value} + 10
9968bee358fSSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
9978bee358fSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
9988bee358fSSushil Singh
9998bee358fSSushil Singh    Release Locks On Resource
10008bee358fSSushil Singh    ...  ${session_info}  ${trans_id_list}
10018bee358fSSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
10028bee358fSSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
10038bee358fSSushil Singh
10048bee358fSSushil Singh    ${trans_id_emptylist}=  Create List
10058bee358fSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
10068bee358fSSushil Singh    Redfish Delete Session  ${session_info}
10078bee358fSSushil Singh
10088bee358fSSushil Singh
10091d7b996cSsusilsi7Verify Fail To Release Lock With TransactionID As String Type
10109614383dSGeorge Keishing    [Documentation]  Verify fail to be release lock with transaction ID as string data type.
10111d7b996cSsusilsi7    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
10121d7b996cSsusilsi7
10131d7b996cSsusilsi7    # Description of argument(s):
10141d7b996cSsusilsi7    # client_id          This client id can contain string value
10151d7b996cSsusilsi7    #                    (e.g. 12345, "HMCID").
10161d7b996cSsusilsi7    # lock_type          Read lock or Write lock.
10171d7b996cSsusilsi7    # release_lock_type  The value can be Transaction or Session.
10181d7b996cSsusilsi7
10191d7b996cSsusilsi7    ${trans_id_list}=  Create List
10201d7b996cSsusilsi7    @{lock_type_list}=  Split String  ${lock_type}  ,
10211d7b996cSsusilsi7
10221d7b996cSsusilsi7    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
10231d7b996cSsusilsi7
10241d7b996cSsusilsi7    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
10251d7b996cSsusilsi7
10261d7b996cSsusilsi7    Append To List  ${trans_id_list}  ${trans_id}
10271d7b996cSsusilsi7
10281d7b996cSsusilsi7    ${temp_trans_id_list}=  Copy Dictionary  ${trans_id_list}  deepcopy=True
10291d7b996cSsusilsi7
10301d7b996cSsusilsi7    ${value}=  Get From Dictionary  ${trans_id_list}[0]  TransactionID
10311d7b996cSsusilsi7    ${value}=  Set Variable  \'${value}\'
10321d7b996cSsusilsi7    Set To Dictionary  ${temp_trans_id_list}[0]  TransactionID  ${value}
10331d7b996cSsusilsi7
10341d7b996cSsusilsi7    Release Locks On Resource
10351d7b996cSsusilsi7    ...  ${session_info}  ${temp_trans_id_list}
10361d7b996cSsusilsi7    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
10371d7b996cSsusilsi7
10381d7b996cSsusilsi7    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
10391d7b996cSsusilsi7
10401d7b996cSsusilsi7    ${trans_id_emptylist}=  Create List
10411d7b996cSsusilsi7    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
10421d7b996cSsusilsi7    Redfish Delete Session  ${session_info}
10431d7b996cSsusilsi7
10441d7b996cSsusilsi7
1045d03f2ce1SSushil SinghVerify Fail To Release Lock For Another Session
1046d03f2ce1SSushil Singh    [Documentation]  Verify failed to release the lock form another session.
1047d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
1048d03f2ce1SSushil Singh
1049d03f2ce1SSushil Singh    # Description of argument(s):
1050d03f2ce1SSushil Singh    # client_id    This client id can contain string value
1051d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
1052d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
1053d03f2ce1SSushil Singh
1054d03f2ce1SSushil Singh    ${client_ids}=  Split String  ${client_id}  ,
1055d03f2ce1SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
1056d03f2ce1SSushil Singh    ${trans_id_list1}=  Create List
1057d03f2ce1SSushil Singh    ${trans_id_list2}=  Create List
1058d03f2ce1SSushil Singh
1059d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_ids}[0]
1060d03f2ce1SSushil Singh
1061d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1062d03f2ce1SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
1063d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
1064d03f2ce1SSushil Singh
1065d03f2ce1SSushil Singh    ${session_info2}=  Create Redfish Session With ClientID  ${client_ids}[1]
1066d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1067d03f2ce1SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
1068d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info2}  ${trans_id_list2}
1069d03f2ce1SSushil Singh
1070d03f2ce1SSushil Singh    Release Locks On Resource
1071d03f2ce1SSushil Singh    ...  ${session_info1}  ${trans_id_list1}  Transaction  status_code=${HTTP_UNAUTHORIZED}
1072d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
1073d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Session
1074d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Session
1075d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
1076d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info2}
1077d03f2ce1SSushil Singh
1078d03f2ce1SSushil Singh
1079e33c6e6aSSushil SinghVerify Fail To Acquire Lock For Invalid Resource ID Data Type
1080e33c6e6aSSushil Singh    [Documentation]  Verify fail to acquire the lock with invalid resource id data type.
1081e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
1082e33c6e6aSSushil Singh
1083e33c6e6aSSushil Singh    # Description of argument(s):
1084e33c6e6aSSushil Singh    # client_id    This client id can contain string value
1085e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
1086e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
1087e33c6e6aSSushil Singh
1088e33c6e6aSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1089e33c6e6aSSushil Singh    Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
1090e33c6e6aSSushil Singh    ...  ${lock_type}  status_code=${HTTP_BAD_REQUEST}
1091e33c6e6aSSushil Singh    Redfish Delete Session  ${session_info}
1092e33c6e6aSSushil Singh
1093e33c6e6aSSushil Singh
1094d03f2ce1SSushil SinghVerify Fail To Acquire Lock For Invalid Lock Data
109516b3c7bfSGeorge Keishing    [Documentation]  Verify fail to acquired lock with invalid lock types, lock flags, segment flags.
1096d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${message}
1097d03f2ce1SSushil Singh
1098d03f2ce1SSushil Singh    # Description of argument(s):
1099d03f2ce1SSushil Singh    # client_id    This client id can contain string value
1100d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
1101d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
1102d03f2ce1SSushil Singh    # message      Return message from URI.
1103d03f2ce1SSushil Singh
1104d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
11058a3efe7cSSushil Singh    ${trans_id}=  Redfish Post Acquire Invalid Lock
11068a3efe7cSSushil Singh    ...  ${lock_type}  message=${message}  status_code=${HTTP_BAD_REQUEST}
1107d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
1108bace3005SSushil Singh
1109bace3005SSushil Singh
1110bace3005SSushil SinghVerify No Locks Records For Session With No Acquired Lock
1111bace3005SSushil Singh    [Documentation]  Verify no records found for a session where no lock is acquired.
1112bace3005SSushil Singh    [Arguments]  ${client_id}
1113bace3005SSushil Singh
1114bace3005SSushil Singh    # Description of argument(s):
1115bace3005SSushil Singh    # client_id    This client id can contain string value
1116bace3005SSushil Singh    #              (e.g. 12345, "HMCID").
1117bace3005SSushil Singh
1118bace3005SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
1119bace3005SSushil Singh    ${trans_id_emptylist}=  Create List
1120bace3005SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
1121bace3005SSushil Singh    Redfish Delete Session  ${session_info}
1122728ef9c9SSushil Singh
1123728ef9c9SSushil Singh
1124728ef9c9SSushil SinghCreate List Of Session ID
1125728ef9c9SSushil Singh    [Documentation]  Create session id list from session dict info.
1126728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}
1127728ef9c9SSushil Singh
1128728ef9c9SSushil Singh    # Description of argument(s):
1129728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
1130728ef9c9SSushil Singh
1131728ef9c9SSushil Singh    @{session_id_list}=  Create List
1132728ef9c9SSushil Singh
1133728ef9c9SSushil Singh    FOR  ${session}  IN  @{session_dict_info}
1134728ef9c9SSushil Singh      Append To List  ${session_id_list}  ${session["SessionIDs"]}
1135728ef9c9SSushil Singh    END
1136728ef9c9SSushil Singh
1137728ef9c9SSushil Singh    ${num_id}=  Get Length  ${session_id_list}
1138728ef9c9SSushil Singh    Should Not Be Equal As Integers  ${num_id}  ${0}
1139728ef9c9SSushil Singh
1140728ef9c9SSushil Singh    ${session_id_list}=  Evaluate  json.dumps(${session_id_list})  json
1141728ef9c9SSushil Singh
1142728ef9c9SSushil Singh    [Return]  ${session_id_list}
1143728ef9c9SSushil Singh
1144728ef9c9SSushil Singh
1145728ef9c9SSushil SinghGet Locks List On Resource With Session List
1146728ef9c9SSushil Singh    [Documentation]  Get locks list from session of list.
1147728ef9c9SSushil Singh    [Arguments]  ${session_id_list}  ${exp_status_code}=${HTTP_OK}
1148728ef9c9SSushil Singh
1149728ef9c9SSushil Singh    # Description of argument(s):
1150728ef9c9SSushil Singh    # session_id_list    Session ids list.
1151728ef9c9SSushil Singh    # exp_status_code    Expected HTTP status code.
1152728ef9c9SSushil Singh
1153728ef9c9SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
1154728ef9c9SSushil Singh    ...  data={"SessionIDs": ${session_id_list}}
115594116c61Ssusilsi7    Should Be Equal As Strings  ${resp.status_code}  ${exp_status_code}
1156728ef9c9SSushil Singh    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
1157728ef9c9SSushil Singh
1158728ef9c9SSushil Singh    [Return]  ${locks}
1159728ef9c9SSushil Singh
1160728ef9c9SSushil Singh
1161728ef9c9SSushil SinghVerify List Of Session Lock On Resource
1162728ef9c9SSushil Singh    [Documentation]  Verify list of lock record from list of sessions.
1163728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}  ${transaction_id_list}
1164728ef9c9SSushil Singh
1165728ef9c9SSushil Singh    # Description of argument(s):
1166728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
1167728ef9c9SSushil Singh    # transaction_id_list    Transaction id in list stored in dict.
1168728ef9c9SSushil Singh
1169728ef9c9SSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_info}
1170728ef9c9SSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1171728ef9c9SSushil Singh    ${lock_list}=  Set Variable  ${lock_list_resp['Records']}
1172728ef9c9SSushil Singh
11738a3efe7cSSushil Singh    FOR  ${session_id}  ${tran_id}  ${lock_record}  IN ZIP
11748a3efe7cSSushil Singh    ...  ${session_dict_info}  ${transaction_id_list}  ${lock_list}
1175728ef9c9SSushil Singh      Valid Value  session_id['SessionIDs']  ['${lock_record['SessionID']}']
1176728ef9c9SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock_record['TransactionID']}
1177728ef9c9SSushil Singh    END
1178728ef9c9SSushil Singh
1179728ef9c9SSushil Singh
1180728ef9c9SSushil SinghVerify Lock Records Of Multiple Session
1181728ef9c9SSushil Singh    [Documentation]  Verify all records found for a multiple sessions.
1182728ef9c9SSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
1183728ef9c9SSushil Singh
1184728ef9c9SSushil Singh    # Description of argument(s):
1185728ef9c9SSushil Singh    # client_ids    This client id can contain string value
1186728ef9c9SSushil Singh    #               (e.g. 12345, "HMCID").
1187728ef9c9SSushil Singh    # lock_type     Read lock or Write lock.
1188728ef9c9SSushil Singh
1189728ef9c9SSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
1190728ef9c9SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
1191728ef9c9SSushil Singh    ${trans_id_list1}=  Create List
1192728ef9c9SSushil Singh    ${trans_id_list2}=  Create List
1193728ef9c9SSushil Singh
1194728ef9c9SSushil Singh    ${session_dict_list}=  Create List
1195728ef9c9SSushil Singh    ${lock_list}=  Create List
1196728ef9c9SSushil Singh
1197728ef9c9SSushil Singh    ${client_id1}=  Create List
1198728ef9c9SSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
1199728ef9c9SSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
1200728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
1201728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
1202728ef9c9SSushil Singh
1203728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1204728ef9c9SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
1205728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
1206728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
1207728ef9c9SSushil Singh
1208728ef9c9SSushil Singh
1209728ef9c9SSushil Singh    ${client_id2}=  Create List
1210728ef9c9SSushil Singh    Append To List  ${client_id2}  ${client_id_list}[1]
1211728ef9c9SSushil Singh    ${session_info2}=  Create Session With List Of ClientID  ${client_id2}
1212728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
1213728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id2}  ${session_info2}
1214728ef9c9SSushil Singh
1215728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1216728ef9c9SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
1217728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
1218728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_list2}
1219728ef9c9SSushil Singh
1220728ef9c9SSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
1221728ef9c9SSushil Singh
1222728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
1223728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1224728ef9c9SSushil Singh
1225728ef9c9SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
1226728ef9c9SSushil Singh
1227728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info2}[0]  SessionToken
1228728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1229728ef9c9SSushil Singh
1230728ef9c9SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Transaction
1231728ef9c9SSushil Singh
1232728ef9c9SSushil Singh    ${trans_id_emptylist}=  Create List
1233728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
1234728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_emptylist}
1235728ef9c9SSushil Singh
1236728ef9c9SSushil Singh    Redfish Delete List Of Session  ${session_dict_list}
1237f9a536caSSushil Singh
1238f9a536caSSushil Singh
1239f9a536caSSushil SinghVerify Lock Records For Multiple Invalid Session
1240f9a536caSSushil Singh    [Documentation]  Verify no lock record found for multiple invalid session.
1241f9a536caSSushil Singh    [Arguments]  ${client_id}
1242f9a536caSSushil Singh
1243f9a536caSSushil Singh    # Description of argument(s):
1244f9a536caSSushil Singh    # client_id    This client id can contain string value
1245f9a536caSSushil Singh    #              (e.g. 12345, "HMCID").
1246f9a536caSSushil Singh
1247f9a536caSSushil Singh    ${session_dict_list}=  Create List
1248f9a536caSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz  xXyXYyYZzz
1249f9a536caSSushil Singh
1250f9a536caSSushil Singh    ${session_info1}=  Create Session With ClientID  ${client_id}
1251f9a536caSSushil Singh
1252f9a536caSSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
1253f9a536caSSushil Singh    set to dictionary  ${session_info2}  SessionIDs  ${invalid_session_ids}[0]
1254f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}
1255f9a536caSSushil Singh
1256f9a536caSSushil Singh    ${session_info3}=  Copy Dictionary  ${session_info1}  deepcopy=True
1257f9a536caSSushil Singh    set to dictionary  ${session_info3}  SessionIDs  ${invalid_session_ids}[0]
1258f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info3}
1259f9a536caSSushil Singh
1260f9a536caSSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
1261f9a536caSSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
1262f9a536caSSushil Singh
1263f9a536caSSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_list}
1264f9a536caSSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1265f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list_resp['Records']}
1266f9a536caSSushil Singh
1267f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
1268f9a536caSSushil Singh
1269f9a536caSSushil Singh    Redfish Delete Session  ${session_info1}
127011949a2cSSushil Singh
127111949a2cSSushil Singh
127211949a2cSSushil SinghVerify Lock Records For Multiple Invalid And Valid Session
127311949a2cSSushil Singh    [Documentation]  Verify all records found for a valid and invalid sessions.
127411949a2cSSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
127511949a2cSSushil Singh
127611949a2cSSushil Singh    # Description of argument(s):
127711949a2cSSushil Singh    # client_ids    This client id can contain string value
127811949a2cSSushil Singh    #               (e.g. 12345, "HMCID").
127911949a2cSSushil Singh    # lock_type     Read lock or Write lock.
128011949a2cSSushil Singh
128111949a2cSSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
128211949a2cSSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
128311949a2cSSushil Singh    ${trans_id_list1}=  Create List
128411949a2cSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz
128511949a2cSSushil Singh
128611949a2cSSushil Singh    ${session_dict_list}=  Create List
128711949a2cSSushil Singh    ${lock_list}=  Create List
128811949a2cSSushil Singh
128911949a2cSSushil Singh    ${client_id1}=  Create List
129011949a2cSSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
129111949a2cSSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
129211949a2cSSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
129311949a2cSSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
129411949a2cSSushil Singh
129511949a2cSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
129611949a2cSSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
129711949a2cSSushil Singh    Append To List  ${lock_list}  ${trans_id}
129811949a2cSSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
129911949a2cSSushil Singh
130011949a2cSSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
130111949a2cSSushil Singh    set to dictionary  ${session_info2}[0]  SessionIDs  ${invalid_session_ids}[0]
130211949a2cSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
130311949a2cSSushil Singh
130411949a2cSSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
130511949a2cSSushil Singh
130611949a2cSSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
130711949a2cSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
130811949a2cSSushil Singh
130911949a2cSSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
131011949a2cSSushil Singh
131111949a2cSSushil Singh    ${trans_id_emptylist}=  Create List
131211949a2cSSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
131311949a2cSSushil Singh
131411949a2cSSushil Singh    Redfish Delete Session  ${session_info1}[0]
1315