xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_lock_management.robot (revision 1b59053d6b213653b951e0c1234d53943aff5159)
1bc331e22SVijay*** Settings ***
2bc331e22SVijay
3d03f2ce1SSushil SinghDocumentation        Test lock management feature of management console on BMC.
4bc331e22SVijay
5bc331e22SVijayResource             ../../lib/resource.robot
6bc331e22SVijayResource             ../../lib/openbmc_ffdc.robot
7566daaf3SGeorge KeishingResource             ../../lib/bmc_redfish_utils.robot
8d03f2ce1SSushil SinghResource             ../../lib/external_intf/management_console_utils.robot
9977f8f58SSushil SinghResource             ../../lib/rest_response_code.robot
10728ef9c9SSushil SinghLibrary              ../../lib/bmc_network_utils.py
11bc331e22SVijay
1240ef0eb7SSushil SinghSuite Setup          Run Keyword And Ignore Error  Delete All Redfish Sessions
13df390b61SSushil SinghSuite Teardown       Run Keyword And Ignore Error  Delete All Redfish Sessions
14d03f2ce1SSushil SinghTest Setup           Printn
15d03f2ce1SSushil SinghTest Teardown        FFDC On Test Case Fail
16bc331e22SVijay
17bc331e22SVijay*** Variables ***
18bc331e22SVijay
19d03f2ce1SSushil Singh${BAD_REQUEST}       Bad Request
20bc331e22SVijay
21bc331e22SVijay*** Test Cases ***
22bc331e22SVijay
23d03f2ce1SSushil SinghAcquire Read Write Lock
24bc331e22SVijay    [Documentation]  Acquire and release different read locks.
25d03f2ce1SSushil Singh    [Tags]  Acquire_Read_Write_Lock
26d03f2ce1SSushil Singh    [Template]  Acquire Lock On Resource
27bc331e22SVijay
28d03f2ce1SSushil Singh    # client_id    lock_type     reboot_flag
29d03f2ce1SSushil Singh    HMCID-01       ReadCase1     False
30d03f2ce1SSushil Singh    HMCID-01       ReadCase2     False
31d03f2ce1SSushil Singh    HMCID-01       ReadCase3     False
32d03f2ce1SSushil Singh    HMCID-01       WriteCase1    False
33d03f2ce1SSushil Singh    HMCID-01       WriteCase2    False
34d03f2ce1SSushil Singh    HMCID-01       WriteCase3    False
35bc331e22SVijay
36bc331e22SVijay
37d03f2ce1SSushil SinghCheck Lock Persistency On BMC Reboot
38d03f2ce1SSushil Singh    [Documentation]  Acquire lock and check after reboot it remain same.
39d03f2ce1SSushil Singh    [Tags]  Check_Lock_Persistency_On_BMC_Reboot
40d03f2ce1SSushil Singh    [Template]  Acquire Lock On Resource
41bc331e22SVijay
42d03f2ce1SSushil Singh    # client_id    lock_type     reboot_flag
43d03f2ce1SSushil Singh    HMCID-01       ReadCase1     True
44d03f2ce1SSushil Singh    HMCID-01       ReadCase2     True
45d03f2ce1SSushil Singh    HMCID-01       ReadCase3     True
46d03f2ce1SSushil Singh    HMCID-01       WriteCase1    True
47d03f2ce1SSushil Singh    HMCID-01       WriteCase2    True
48d03f2ce1SSushil Singh    HMCID-01       WriteCase3    True
49bc331e22SVijay
50bc331e22SVijay
51d03f2ce1SSushil SinghAcquire Read Lock On Read Lock
52d03f2ce1SSushil Singh    [Documentation]  Acquire read lock on another read lock.
53d03f2ce1SSushil Singh    [Tags]  Acquire_Read_Lock_On_Read_Lock
54d03f2ce1SSushil Singh    [Template]  Acquire Lock On Another Lock
55bc331e22SVijay
56d03f2ce1SSushil Singh    # client_id
57d03f2ce1SSushil Singh    HMCID-01
58bc331e22SVijay
59bc331e22SVijay
60d03f2ce1SSushil SinghFail To Acquire Lock On Another Lock
61d03f2ce1SSushil Singh    [Documentation]  Fail to acquire another lock.
62d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_On_Another_Lock
63d03f2ce1SSushil Singh    [Template]  Verify Acquire Lock Fails On Another Lock
6485610eeeSVijay
65d03f2ce1SSushil Singh    # client_id    lock_type
66d03f2ce1SSushil Singh    HMCID-01       ReadCase2,WriteCase2
67d03f2ce1SSushil Singh    HMCID-01       WriteCase2,WriteCase2
68d03f2ce1SSushil Singh    HMCID-01       WriteCase2,ReadCase2
69566daaf3SGeorge Keishing
70566daaf3SGeorge Keishing
71e33c6e6aSSushil SinghAcquire Lock After Reboot
72e33c6e6aSSushil Singh    [Documentation]  Acquire and release read and write locks after reboot.
73e33c6e6aSSushil Singh    [Tags]  Acquire_Lock_After_Reboot
74e33c6e6aSSushil Singh    [Template]  Verify Acquire Lock After Reboot
75e33c6e6aSSushil Singh
76e33c6e6aSSushil Singh    # client_id    lock_type
77e33c6e6aSSushil Singh    HMCID-01       ReadCase1
78e33c6e6aSSushil Singh    HMCID-01       ReadCase2
79e33c6e6aSSushil Singh    HMCID-01       ReadCase3
80e33c6e6aSSushil Singh    HMCID-01       WriteCase1
81e33c6e6aSSushil Singh    HMCID-01       WriteCase2
82e33c6e6aSSushil Singh    HMCID-01       WriteCase3
83e33c6e6aSSushil Singh
84e33c6e6aSSushil Singh
85d03f2ce1SSushil SinghAcquire And Release Lock In Loop
86d03f2ce1SSushil Singh    [Documentation]  Acquire and release read, write locks in loop.
87d03f2ce1SSushil Singh    [Tags]  Acquire_And_Release_Lock_In_Loop
88d03f2ce1SSushil Singh    [Template]  Verify Acquire And Release Lock In Loop
89566daaf3SGeorge Keishing
90d03f2ce1SSushil Singh    # client_id    lock_type
91d03f2ce1SSushil Singh    HMCID-01       ReadCase1
92d03f2ce1SSushil Singh    HMCID-01       ReadCase2
93d03f2ce1SSushil Singh    HMCID-01       ReadCase3
94d03f2ce1SSushil Singh    HMCID-01       WriteCase1
95d03f2ce1SSushil Singh    HMCID-01       WriteCase2
96d03f2ce1SSushil Singh    HMCID-01       WriteCase3
9785610eeeSVijay
9885610eeeSVijay
99977f8f58SSushil SinghFail To Acquire Read And Write In Single Request
100977f8f58SSushil Singh    [Documentation]  Fail to acquire read and write lock in single request.
101977f8f58SSushil Singh    [Tags]  Fail_To_Acquire_Read_And_Write_In_Single_Request
102977f8f58SSushil Singh    [Template]  Verify Fail To Acquire Read And Write In Single Request
103977f8f58SSushil Singh
104977f8f58SSushil Singh    # client_id    lock_type
105977f8f58SSushil Singh    HMCID-01       ReadCase1,WriteCase1
106977f8f58SSushil Singh    HMCID-01       WriteCase1,ReadCase1
107977f8f58SSushil Singh
108977f8f58SSushil Singh
109df390b61SSushil SinghAcquire Multiple Lock Request At CEC Level
110df390b61SSushil Singh    [Documentation]  Acquire write lock on read lock under CEC level.
111df390b61SSushil Singh    [Tags]  Acquire_Multiple_Lock_Request_At_CEC_Level
112df390b61SSushil Singh    [Template]  Verify Acquire Multiple Lock Request At CEC Level
113df390b61SSushil Singh
114df390b61SSushil Singh    # client_id    lock_type
115df390b61SSushil Singh    HMCID-01       ReadCase4,WriteCase4
116df390b61SSushil Singh    HMCID-01       WriteCase5,ReadCase5
117df390b61SSushil Singh    HMCID-01       ReadCase6,WriteCase6
118df390b61SSushil Singh    HMCID-01       WriteCase7,ReadCase7
119df390b61SSushil Singh
120df390b61SSushil Singh
121d03f2ce1SSushil SinghVerify Release Of Valid Locks
122d03f2ce1SSushil Singh    [Documentation]  Release all valid locks.
123d03f2ce1SSushil Singh    [Tags]  Verify_Release_Of_Valid_Locks
124d03f2ce1SSushil Singh    [Template]  Acquire And Release Multiple Locks
125afdd2a1dSVijay
126d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
127d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
128d03f2ce1SSushil Singh    HMCID-02       ReadCase1,ReadCase1,ReadCase1    Session
129afdd2a1dSVijay
130afdd2a1dSVijay
131*1b59053dSSushil SinghFail To Release Multiple Lock With Invalid TransactionID
132d03f2ce1SSushil Singh    [Documentation]  Release in-valid lock result in fail.
133*1b59053dSSushil Singh    [Tags]  Fail_To_Release_Multiple_Lock_With_Invalid_TransactionID
134*1b59053dSSushil Singh    [Template]  Verify Fail To Release Multiple Lock With Invalid TransactionID
135afdd2a1dSVijay
136d03f2ce1SSushil Singh    # client_id    lock_type                        release_lock_type
137d03f2ce1SSushil Singh    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
138d03f2ce1SSushil Singh    12345          ReadCase2,ReadCase2,ReadCase2    Transaction
139d03f2ce1SSushil Singh    HMCID          ReadCase3,ReadCase3,ReadCase3    Transaction
140afdd2a1dSVijay
141afdd2a1dSVijay
142d03f2ce1SSushil SinghFail To Release Lock For Another Session
143d03f2ce1SSushil Singh    [Documentation]  Failed to release locks from another session.
144d03f2ce1SSushil Singh    [Tags]  Fail_To_Release_Lock_For_Another_Session
145d03f2ce1SSushil Singh    [Template]  Verify Fail To Release Lock For Another Session
146afdd2a1dSVijay
147d03f2ce1SSushil Singh    # client_id          lock_type
148d03f2ce1SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
149afdd2a1dSVijay
150afdd2a1dSVijay
151e33c6e6aSSushil SinghTest Invalid Resource ID Data Type Locking
152e33c6e6aSSushil Singh    [Documentation]  Failed to acquire lock for invalid resource id data type.
153e33c6e6aSSushil Singh    [Tags]  Test_Invalid_Resource_ID_Data_Type_Locking
154e33c6e6aSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Resource ID Data Type
155e33c6e6aSSushil Singh
156e33c6e6aSSushil Singh    # client_id    lock_type
157e33c6e6aSSushil Singh    HMCID-01       ReadCase1
158e33c6e6aSSushil Singh    HMCID-01       ReadCase2
159e33c6e6aSSushil Singh    HMCID-01       ReadCase3
160e33c6e6aSSushil Singh    HMCID-01       WriteCase1
161e33c6e6aSSushil Singh    HMCID-01       WriteCase2
162e33c6e6aSSushil Singh    HMCID-01       WriteCase3
163e33c6e6aSSushil Singh
164e33c6e6aSSushil Singh
165d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Type
166d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read, write lock for invalid lock data passed.
167d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Type
168d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
169afdd2a1dSVijay
170d03f2ce1SSushil Singh    # client_id    lock_type      message
171d03f2ce1SSushil Singh    HMCID-01       ReadCase1      ${BAD_REQUEST}
172d03f2ce1SSushil Singh    HMCID-01       ReadCase2      ${BAD_REQUEST}
173d03f2ce1SSushil Singh    HMCID-01       ReadCase3      ${BAD_REQUEST}
174d03f2ce1SSushil Singh    HMCID-01       ReadCase4      ${BAD_REQUEST}
175d03f2ce1SSushil Singh    HMCID-01       ReadCase5      ${BAD_REQUEST}
176d03f2ce1SSushil Singh    HMCID-01       WriteCase1     ${BAD_REQUEST}
177d03f2ce1SSushil Singh    HMCID-01       WriteCase2     ${BAD_REQUEST}
178d03f2ce1SSushil Singh    HMCID-01       WriteCase3     ${BAD_REQUEST}
179d03f2ce1SSushil Singh    HMCID-01       WriteCase4     ${BAD_REQUEST}
180d03f2ce1SSushil Singh    HMCID-01       WriteCase5     ${BAD_REQUEST}
181afdd2a1dSVijay
182afdd2a1dSVijay
183d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Lock Flag
184d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid lock flag passed.
185d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
186d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
187afdd2a1dSVijay
188d03f2ce1SSushil Singh    # client_id    lock_type       message
189d03f2ce1SSushil Singh    HMCID-01       ReadCase6       ${BAD_REQUEST}
190d03f2ce1SSushil Singh    HMCID-01       ReadCase7       ${BAD_REQUEST}
191d03f2ce1SSushil Singh    HMCID-01       ReadCase8       ${BAD_REQUEST}
192d03f2ce1SSushil Singh    HMCID-01       ReadCase9       ${BAD_REQUEST}
193d03f2ce1SSushil Singh    HMCID-01       ReadCase10      ${BAD_REQUEST}
194d03f2ce1SSushil Singh    HMCID-01       ReadCase11      ${BAD_REQUEST}
195d03f2ce1SSushil Singh    HMCID-01       WriteCase6      ${BAD_REQUEST}
196d03f2ce1SSushil Singh    HMCID-01       WriteCase7      ${BAD_REQUEST}
197d03f2ce1SSushil Singh    HMCID-01       WriteCase8      ${BAD_REQUEST}
198d03f2ce1SSushil Singh    HMCID-01       WriteCase9      ${BAD_REQUEST}
199d03f2ce1SSushil Singh    HMCID-01       WriteCase10     ${BAD_REQUEST}
200d03f2ce1SSushil Singh    HMCID-01       WriteCase11     ${BAD_REQUEST}
201afdd2a1dSVijay
202afdd2a1dSVijay
203d03f2ce1SSushil SinghFail To Acquire Lock For Invalid Segment Flag
204d03f2ce1SSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
205d03f2ce1SSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Flag
206d03f2ce1SSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
207d03f2ce1SSushil Singh
208d03f2ce1SSushil Singh    # client_id    lock_type       message
209d03f2ce1SSushil Singh    HMCID-01       ReadCase12      ${BAD_REQUEST}
210d03f2ce1SSushil Singh    HMCID-01       ReadCase13      ${BAD_REQUEST}
211d03f2ce1SSushil Singh    HMCID-01       ReadCase14      ${BAD_REQUEST}
212d03f2ce1SSushil Singh    HMCID-01       WriteCase12     ${BAD_REQUEST}
213d03f2ce1SSushil Singh    HMCID-01       WriteCase13     ${BAD_REQUEST}
214d03f2ce1SSushil Singh    HMCID-01       WriteCase14     ${BAD_REQUEST}
215afdd2a1dSVijay
216bace3005SSushil Singh
2173b3a7ecaSSushil SinghFail To Acquire Lock For Invalid Segment Data Type Flag
2183b3a7ecaSSushil Singh    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
2193b3a7ecaSSushil Singh    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Data_Type_Flag
2203b3a7ecaSSushil Singh    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
2213b3a7ecaSSushil Singh
2223b3a7ecaSSushil Singh    # client_id    lock_type       message
2233b3a7ecaSSushil Singh    HMCID-01       ReadCase15      ${EMPTY}
2243b3a7ecaSSushil Singh    HMCID-01       ReadCase16      ${EMPTY}
2253b3a7ecaSSushil Singh    HMCID-01       ReadCase17      ${EMPTY}
2263b3a7ecaSSushil Singh    HMCID-01       ReadCase18      ${EMPTY}
2273b3a7ecaSSushil Singh    HMCID-01       WriteCase15     ${EMPTY}
2283b3a7ecaSSushil Singh    HMCID-01       WriteCase16     ${EMPTY}
2293b3a7ecaSSushil Singh    HMCID-01       WriteCase17     ${EMPTY}
2303b3a7ecaSSushil Singh    HMCID-01       WriteCase18     ${EMPTY}
2313b3a7ecaSSushil Singh
2323b3a7ecaSSushil Singh
233bace3005SSushil SinghGet Empty Lock Records For Session Where No Locks Acquired
234bace3005SSushil Singh    [Documentation]  If session does not acquire locks then get lock should return
235bace3005SSushil Singh    ...              empty lock records.
236bace3005SSushil Singh    [Tags]  Get_Empty_Lock_Records_For_Session_Where_No_Locks_Acquired
237bace3005SSushil Singh    [Template]  Verify No Locks Records For Session With No Acquired Lock
238bace3005SSushil Singh
239bace3005SSushil Singh    # client_id
240bace3005SSushil Singh    HMCID-01
241bace3005SSushil Singh
242728ef9c9SSushil Singh
243f9a536caSSushil SinghGet Lock Records Empty For Invalid Session
244f9a536caSSushil Singh    [Documentation]  Record of lock list is empty for invalid session.
245f9a536caSSushil Singh    [Tags]  Get_Lock_Records_Empty_For_Invalid_Session
246f9a536caSSushil Singh    [Template]  Verify Empty Lock Records For Invalid Session
247f9a536caSSushil Singh
248f9a536caSSushil Singh    # client_id
249f9a536caSSushil Singh    HMCID-01
250f9a536caSSushil Singh
251f9a536caSSushil Singh
252728ef9c9SSushil SinghGet Lock Records For Multiple Session
253728ef9c9SSushil Singh    [Documentation]  Get lock records of multiple session.
254728ef9c9SSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Session
255728ef9c9SSushil Singh    [Template]  Verify Lock Records Of Multiple Session
256728ef9c9SSushil Singh
257728ef9c9SSushil Singh    # client_ids         lock_type
258728ef9c9SSushil Singh    HMCID-01,HMCID-02    ReadCase1,ReadCase1
259728ef9c9SSushil Singh
260728ef9c9SSushil Singh
261f9a536caSSushil SinghGet Lock Records For Multiple Invalid Session
262f9a536caSSushil Singh    [Documentation]  Record of lock list is empty for list of invalid session.
263f9a536caSSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Invalid_Session
264f9a536caSSushil Singh    [Template]  Verify Lock Records For Multiple Invalid Session
265f9a536caSSushil Singh
266f9a536caSSushil Singh    # client_id
267f9a536caSSushil Singh    HMCID-01
268f9a536caSSushil Singh
26911949a2cSSushil Singh
27011949a2cSSushil SinghGet Lock Records For Multiple Invalid And Valid Session
27111949a2cSSushil Singh    [Documentation]  Get record of lock from invalid and valid session.
27211949a2cSSushil Singh    [Tags]  Get_Lock_Records_For_Multiple_Invalid_And_Valid_Session
27311949a2cSSushil Singh    [Template]  Verify Lock Records For Multiple Invalid And Valid Session
27411949a2cSSushil Singh
27511949a2cSSushil Singh    # client_id          lock_type
27611949a2cSSushil Singh    HMCID-01,HMCID-02    ReadCase1
27711949a2cSSushil Singh
278bc331e22SVijay*** Keywords ***
279bc331e22SVijay
280d03f2ce1SSushil SinghCreate Redfish Session With ClientID
281d03f2ce1SSushil Singh    [Documentation]  Create redifish session with client id.
282d03f2ce1SSushil Singh    [Arguments]  ${client_id}
28385610eeeSVijay
28485610eeeSVijay    # Description of argument(s):
285d03f2ce1SSushil Singh    # client_id    This client id can contain string value
286d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
28785610eeeSVijay
288d03f2ce1SSushil Singh    ${session_info}=  Create Dictionary
289d03f2ce1SSushil Singh    ${session}=  Redfish Login  kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
29085610eeeSVijay
291d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  SessionIDs  ${session['Id']}
292d03f2ce1SSushil Singh    Set To Dictionary  ${session_info}  ClientID  ${session["Oem"]["OpenBMC"]["ClientID"]}
29385610eeeSVijay
294d03f2ce1SSushil Singh    [Return]  ${session_info}
29585610eeeSVijay
29685610eeeSVijay
297d03f2ce1SSushil SinghRW General Dictionary
298d03f2ce1SSushil Singh    [Documentation]  Create dictionay of lock request.
299d03f2ce1SSushil Singh    [Arguments]  ${read_case}  ${res_id}
300bc331e22SVijay
301bc331e22SVijay    # Description of argument(s):
302d03f2ce1SSushil Singh    # read_case    Read or Write lock type.
303d03f2ce1SSushil Singh    # res_id       Resource id.
304bc331e22SVijay
305d03f2ce1SSushil Singh    ${request_dict}=  Create Dictionary
306566daaf3SGeorge Keishing
307d03f2ce1SSushil Singh    FOR  ${key}  IN  @{read_case.keys()}
308d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  LockType  ${key}
309d03f2ce1SSushil Singh      Set To Dictionary  ${request_dict}  SegmentFlags  ${read_case["${key}"]}
310d03f2ce1SSushil Singh    END
311bc331e22SVijay
312d03f2ce1SSushil Singh    Set To Dictionary  ${request_dict}  ResourceID  ${res_id}
313d03f2ce1SSushil Singh
314d03f2ce1SSushil Singh    [Return]  ${request_dict}
315bc331e22SVijay
316bc331e22SVijay
317d03f2ce1SSushil SinghReturn Description Of Response
318d03f2ce1SSushil Singh    [Documentation]  Return description of REST response.
319bc331e22SVijay    [Arguments]  ${resp_text}
320bc331e22SVijay
321bc331e22SVijay    # Description of argument(s):
322d03f2ce1SSushil Singh    # resp_text    REST response body.
323bc331e22SVijay
324d03f2ce1SSushil Singh    # resp_text after successful partition file upload looks like:
325d03f2ce1SSushil Singh    # {
326d03f2ce1SSushil Singh    #    "Description": "File Created"
327d03f2ce1SSushil Singh    # }
328bc331e22SVijay
329d03f2ce1SSushil Singh    ${message}=  Evaluate  json.loads('''${resp_text}''')  json
330d03f2ce1SSushil Singh
331d03f2ce1SSushil Singh    [Return]  ${message}
332bc331e22SVijay
333bc331e22SVijay
334a7d71f02SSushil SinghVerify Redfish Session Deleted
335a7d71f02SSushil Singh    [Documentation]  Verify the redfish session is deleted.
336a7d71f02SSushil Singh    [Arguments]  ${session_info}
337a7d71f02SSushil Singh
338a7d71f02SSushil Singh    # Description of argument(s):
339a7d71f02SSushil Singh    # session_info    Session information are stored in dictionary.
340a7d71f02SSushil Singh
341a7d71f02SSushil Singh    # ${session_info} = {
342a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
343a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
344a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
345a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
346a7d71f02SSushil Singh    # }
347a7d71f02SSushil Singh
348a7d71f02SSushil Singh    # SessionIDs   : Session IDs
349a7d71f02SSushil Singh    # ClientID     : Client ID
350a7d71f02SSushil Singh    # SessionToken : Session token
351a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
352a7d71f02SSushil Singh
353a7d71f02SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions
354a7d71f02SSushil Singh
355a7d71f02SSushil Singh    FOR  ${session}  IN  @{sessions['Members']}
356a7d71f02SSushil Singh      Should Not Be Equal As Strings  session  ['/redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}']
357a7d71f02SSushil Singh    END
358a7d71f02SSushil Singh
359a7d71f02SSushil Singh
360a7d71f02SSushil SinghVerify Redfish List Of Session Deleted
361a7d71f02SSushil Singh    [Documentation]  Verify all the list of redfish session is deleted.
362a7d71f02SSushil Singh    [Arguments]  ${session_info_list}
363a7d71f02SSushil Singh
364a7d71f02SSushil Singh    # Description of argument(s):
365a7d71f02SSushil Singh    # session_info_list    List contains individual session record are stored in dictionary.
366a7d71f02SSushil Singh
367a7d71f02SSushil Singh    # ${session_info_list} = [{
368a7d71f02SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
369a7d71f02SSushil Singh    #     'ClientID': 'XXXXXX',
370a7d71f02SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
371a7d71f02SSushil Singh    #     'SessionResp': session response from redfish login
372a7d71f02SSushil Singh    # }]
373a7d71f02SSushil Singh
374a7d71f02SSushil Singh    # SessionIDs   : Session IDs
375a7d71f02SSushil Singh    # ClientID     : Client ID
376a7d71f02SSushil Singh    # SessionToken : Session token
377a7d71f02SSushil Singh    # SessionResp  : Response of creating an redfish login session
378a7d71f02SSushil Singh
379a7d71f02SSushil Singh    FOR  ${session_record}  IN  @{session_info_list}
380a7d71f02SSushil Singh      Verify Redfish Session Deleted  ${session_record}
381a7d71f02SSushil Singh    END
382a7d71f02SSushil Singh
383a7d71f02SSushil Singh
384d03f2ce1SSushil SinghRedfish Post Acquire Lock
385d03f2ce1SSushil Singh    [Documentation]  Acquire and release lock.
386d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
387bc331e22SVijay
388bc331e22SVijay    # Description of argument(s):
389d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
390d03f2ce1SSushil Singh    # status_code    HTTP status code.
391bc331e22SVijay
392e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Lock  ${lock_type}
393e33c6e6aSSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
394d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
395df390b61SSushil Singh
396df390b61SSushil Singh    Run Keyword If  ${status_code} == ${HTTP_BAD_REQUEST}
397df390b61SSushil Singh    ...    Valid Value  ${BAD_REQUEST}  ['${resp.content}']
398df390b61SSushil Singh    ...  ELSE
399df390b61SSushil Singh    ...    Run Keyword And Return  Return Description Of Response  ${resp.content}
400bc331e22SVijay
401d03f2ce1SSushil Singh    [Return]  ${resp}
402bc331e22SVijay
403bc331e22SVijay
404977f8f58SSushil SinghRedfish Post Acquire List Lock
405977f8f58SSushil Singh    [Documentation]  Acquire and release lock.
406977f8f58SSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
407977f8f58SSushil Singh
408977f8f58SSushil Singh    # Description of argument(s):
409977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
410977f8f58SSushil Singh    # status_code    HTTP status code.
411977f8f58SSushil Singh
412977f8f58SSushil Singh    ${lock_dict_param}=  Create Data To Acquire List Of Lock  ${lock_type}
413977f8f58SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
414977f8f58SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
415977f8f58SSushil Singh
416977f8f58SSushil Singh    [Return]  ${resp}
417977f8f58SSushil Singh
418977f8f58SSushil Singh
419d03f2ce1SSushil SinghRedfish Post Acquire Invalid Lock
420d03f2ce1SSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock.
421d03f2ce1SSushil Singh    [Arguments]  ${lock_type}  ${message}  ${status_code}=${HTTP_OK}
422bc331e22SVijay
423bc331e22SVijay    # Description of argument(s):
424d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
425d03f2ce1SSushil Singh    # message        Return message from URI.
426d03f2ce1SSushil Singh    # status_code    HTTP status code.
427bc331e22SVijay
428e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Invalid Lock  ${lock_type}
429e33c6e6aSSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
430d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
4313b3a7ecaSSushil Singh    Run Keyword If  '${message}' != '${EMPTY}'
4323b3a7ecaSSushil Singh    ...  Valid Value  message  ['${resp.content}']
433d03f2ce1SSushil Singh
434d03f2ce1SSushil Singh    [Return]  ${resp}
435bc331e22SVijay
436bc331e22SVijay
437e33c6e6aSSushil SinghRedfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
438e33c6e6aSSushil Singh    [Documentation]  Redfish to post request to acquire in-valid lock with invalid data type of resource id.
439e33c6e6aSSushil Singh    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
440e33c6e6aSSushil Singh
441e33c6e6aSSushil Singh    # Description of argument(s):
442e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
443e33c6e6aSSushil Singh    # status_code    HTTP status code.
444e33c6e6aSSushil Singh
445e33c6e6aSSushil Singh    ${lock_dict_param}=  Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID  ${lock_type}
446e33c6e6aSSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
447e33c6e6aSSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
448e33c6e6aSSushil Singh
449e33c6e6aSSushil Singh    [Return]  ${resp}
450e33c6e6aSSushil Singh
451e33c6e6aSSushil Singh
452d03f2ce1SSushil SinghForm Data To Acquire Lock
453d03f2ce1SSushil Singh    [Documentation]  Create a dictionay for lock request.
454d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
455d03f2ce1SSushil Singh
456d03f2ce1SSushil Singh    # Description of argument(s):
457d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
458d03f2ce1SSushil Singh
459d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
460d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
461d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
462d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
463d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
464e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
465d03f2ce1SSushil Singh
466e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
467e33c6e6aSSushil Singh
468e33c6e6aSSushil Singh
469977f8f58SSushil SinghCreate Data To Acquire List Of Lock
470977f8f58SSushil Singh    [Documentation]  Create a dictionay for list of lock request.
471977f8f58SSushil Singh    [Arguments]  ${lock_type_list}
472977f8f58SSushil Singh
473977f8f58SSushil Singh    # Description of argument(s):
474977f8f58SSushil Singh    # lock_type      Read lock or Write lock.
475977f8f58SSushil Singh
476977f8f58SSushil Singh    ${temp_list}=  Create List
477977f8f58SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
478977f8f58SSushil Singh
479977f8f58SSushil Singh    FOR  ${lock_type}  IN  @{lock_type_list}
480977f8f58SSushil Singh      ${resp}=  RW General Dictionary
481977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
482977f8f58SSushil Singh      ...    ${lock_res_info["Valid Case"]["ResourceID"]}
483977f8f58SSushil Singh      Append To List  ${temp_list}  ${resp}
484977f8f58SSushil Singh    END
485977f8f58SSushil Singh
486977f8f58SSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
487977f8f58SSushil Singh
488977f8f58SSushil Singh    [Return]  ${lock_request_dict}
489977f8f58SSushil Singh
490977f8f58SSushil Singh
491e33c6e6aSSushil SinghForm Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
492e33c6e6aSSushil Singh    [Documentation]  Create a dictionay for in-valid lock request.
493e33c6e6aSSushil Singh    [Arguments]  ${lock_type}
494e33c6e6aSSushil Singh
495e33c6e6aSSushil Singh    # Description of argument(s):
496e33c6e6aSSushil Singh    # lock_type      Read lock or Write lock.
497e33c6e6aSSushil Singh
498e33c6e6aSSushil Singh    ${lock_res_info}=  Get Lock Resource Information
499e33c6e6aSSushil Singh    ${resp}=  RW General Dictionary
500e33c6e6aSSushil Singh    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
501e33c6e6aSSushil Singh    ...    ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
502e33c6e6aSSushil Singh    ${temp_list}=  Create List  ${resp}
503e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
504e33c6e6aSSushil Singh
505e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
506d03f2ce1SSushil Singh
507d03f2ce1SSushil Singh
508d03f2ce1SSushil SinghForm Data To Acquire Invalid Lock
509d03f2ce1SSushil Singh    [Documentation]  Create a dictionay for in-valid lock request.
510d03f2ce1SSushil Singh    [Arguments]  ${lock_type}
511d03f2ce1SSushil Singh
512d03f2ce1SSushil Singh    # Description of argument(s):
513d03f2ce1SSushil Singh    # lock_type      Read lock or Write lock.
514d03f2ce1SSushil Singh
515d03f2ce1SSushil Singh    ${lock_res_info}=  Get Lock Resource Information
516d03f2ce1SSushil Singh    ${resp}=  RW General Dictionary
517d03f2ce1SSushil Singh    ...    ${lock_res_info["Invalid Case"]["${lock_type}"]}
518d03f2ce1SSushil Singh    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
519d03f2ce1SSushil Singh    ${temp_list}=  Create List  ${resp}
520e33c6e6aSSushil Singh    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
521d03f2ce1SSushil Singh
522e33c6e6aSSushil Singh    [Return]  ${lock_request_dict}
523d03f2ce1SSushil Singh
524d03f2ce1SSushil Singh
525d03f2ce1SSushil SinghGet Locks List On Resource
526bc331e22SVijay    [Documentation]  Get locks list.
527d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${exp_status_code}=${HTTP_OK}
528bc331e22SVijay
529bc331e22SVijay    # Description of argument(s):
530d03f2ce1SSushil Singh    # session_info       Session information in dict.
531d03f2ce1SSushil Singh    # exp_status_code    Expected HTTP status code.
532bc331e22SVijay
533d03f2ce1SSushil Singh    ${data}=  Set Variable  {"SessionIDs": ["${session_info['SessionIDs']}"]}
534566daaf3SGeorge Keishing    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
535566daaf3SGeorge Keishing    ...  data=${data}
536bc331e22SVijay    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
537bc331e22SVijay
538bc331e22SVijay    [Return]  ${locks["Records"]}
539bc331e22SVijay
540bc331e22SVijay
541d03f2ce1SSushil SinghVerify Lock On Resource
542d03f2ce1SSushil Singh    [Documentation]  Verify lock on resource.
543d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${transaction_id}
544bc331e22SVijay
545bc331e22SVijay    # Description of argument(s):
546d03f2ce1SSushil Singh    # session_info      Session information in dict.
547d03f2ce1SSushil Singh    # transaction_id    Transaction id in list stored in dict.
548bc331e22SVijay
549d03f2ce1SSushil Singh    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
550d03f2ce1SSushil Singh    Rprint Vars  sessions
551d03f2ce1SSushil Singh    ${lock_list}=  Get Locks List On Resource  ${session_info}
552d03f2ce1SSushil Singh    ${lock_length}=  Get Length  ${lock_list}
553d03f2ce1SSushil Singh    ${tran_id_length}=  Get Length  ${transaction_id}
554d03f2ce1SSushil Singh    Should Be Equal As Integers  ${tran_id_length}  ${lock_length}
555afdd2a1dSVijay
556d03f2ce1SSushil Singh    FOR  ${tran_id}  ${lock}  IN ZIP  ${transaction_id}  ${lock_list}
557d03f2ce1SSushil Singh      Valid Value  session_info['ClientID']  ['${lock['HMCID']}']
558d03f2ce1SSushil Singh      Valid Value  session_info['SessionIDs']  ['${lock['SessionID']}']
559d03f2ce1SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock['TransactionID']}
560bc331e22SVijay    END
561bc331e22SVijay
562bc331e22SVijay
563d03f2ce1SSushil SinghAcquire Lock On Resource
564d03f2ce1SSushil Singh    [Documentation]  Acquire lock on resource.
565d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${reboot_flag}=False
566bc331e22SVijay
567bc331e22SVijay    # Description of argument(s):
568d03f2ce1SSushil Singh    # client_id    This client id can contain string value
569d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
570d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
571d03f2ce1SSushil Singh    # reboot_flag  Flag is used to run reboot the BMC code.
572d03f2ce1SSushil Singh    #               (e.g. True or False).
573bc331e22SVijay
574d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
575d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
576d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
577d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
578d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
579566daaf3SGeorge Keishing
580e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
581bc331e22SVijay
582d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'True'
583d03f2ce1SSushil Singh    ...  Run Keywords  Redfish OBMC Reboot (off)  AND
584d03f2ce1SSushil Singh    ...  Redfish Login  AND
585e33c6e6aSSushil Singh    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
586d03f2ce1SSushil Singh    ...  Verify Lock On Resource  ${session_info}  ${trans_id_list}  AND
587d03f2ce1SSushil Singh    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
588bc331e22SVijay
589d03f2ce1SSushil Singh    Run Keyword If  '${reboot_flag}' == 'False'
590d03f2ce1SSushil Singh    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
591bc331e22SVijay
592d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
593d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
594d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
595bc331e22SVijay
596bc331e22SVijay
597d03f2ce1SSushil SinghForm Data To Release Lock
598d03f2ce1SSushil Singh    [Documentation]  Create a dictonay to release lock.
599d03f2ce1SSushil Singh    [Arguments]  ${trans_id_list}
600355daac7SVijay
601355daac7SVijay    # Description of argument(s):
602d03f2ce1SSushil Singh    # trans_id_list
603355daac7SVijay
604d03f2ce1SSushil Singh    @{tran_ids}=  Create List
605355daac7SVijay
606d03f2ce1SSushil Singh    FOR  ${item}  IN  @{trans_id_list}
607d03f2ce1SSushil Singh      Append To List  ${tran_ids}  ${item['TransactionID']}
608d03f2ce1SSushil Singh    END
609d03f2ce1SSushil Singh
610d03f2ce1SSushil Singh    [Return]  ${tran_ids}
611d03f2ce1SSushil Singh
612d03f2ce1SSushil Singh
613d03f2ce1SSushil SinghRelease Locks On Resource
614d03f2ce1SSushil Singh    [Documentation]  Redfish request to release a lock.
615d03f2ce1SSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}  ${release_lock_type}=Transaction  ${status_code}=${HTTP_OK}
616d03f2ce1SSushil Singh
617d03f2ce1SSushil Singh    # Description of argument(s):
618d03f2ce1SSushil Singh    # session_info        Session information in dict.
619d03f2ce1SSushil Singh    # trans_id_list       Transaction id list.
620d03f2ce1SSushil Singh    # release_lock_type   Release lock by Transaction, Session.
621d03f2ce1SSushil Singh    # status_code         HTTP status code.
622d03f2ce1SSushil Singh
623d03f2ce1SSushil Singh    ${tran_ids}=  Form Data To Release Lock  ${trans_id_list}
624d03f2ce1SSushil Singh    ${data}=  Set Variable  {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
625d03f2ce1SSushil Singh    ${data}=  Evaluate  json.dumps(${data})  json
626d03f2ce1SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock  data=${data}
627d03f2ce1SSushil Singh    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
628d03f2ce1SSushil Singh
629d03f2ce1SSushil Singh
630df390b61SSushil SinghRelease locks And Delete Session
631df390b61SSushil Singh    [Documentation]  Release locks and delete redfish session.
632df390b61SSushil Singh    [Arguments]  ${session_info}  ${trans_id_list}
633df390b61SSushil Singh
634df390b61SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}
635df390b61SSushil Singh
636df390b61SSushil Singh    ${trans_id_emptylist}=  Create List
637df390b61SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
638df390b61SSushil Singh
639df390b61SSushil Singh    Redfish Delete Session  ${session_info}
640df390b61SSushil Singh
641df390b61SSushil Singh
642d03f2ce1SSushil SinghAcquire Lock On Another Lock
643d03f2ce1SSushil Singh    [Documentation]  Acquire lock on another lock.
644d03f2ce1SSushil Singh    [Arguments]  ${client_id}
645d03f2ce1SSushil Singh
646d03f2ce1SSushil Singh    # Description of argument(s):
647d03f2ce1SSushil Singh    # client_id    This client id can contain string value
648d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
649d03f2ce1SSushil Singh
650d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
651d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
652d03f2ce1SSushil Singh
653d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
654d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
655d03f2ce1SSushil Singh
656d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
657d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
658d03f2ce1SSushil Singh
659d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
660d03f2ce1SSushil Singh
661df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
662d03f2ce1SSushil Singh
663d03f2ce1SSushil Singh
664977f8f58SSushil SinghVerify Fail To Acquire Read And Write In Single Request
665977f8f58SSushil Singh    [Documentation]  Verify fail to acquire read and write lock passed in single request.
666977f8f58SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
667977f8f58SSushil Singh
668977f8f58SSushil Singh    # Description of argument(s):
669977f8f58SSushil Singh    # client_id    This client id can contain string value
670977f8f58SSushil Singh    #              (e.g. 12345, "HMCID").
671977f8f58SSushil Singh    # lock_type    Read lock or Write lock.
672977f8f58SSushil Singh
673977f8f58SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
674977f8f58SSushil Singh
675977f8f58SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
676977f8f58SSushil Singh    ${trans_id}=  Redfish Post Acquire List Lock  ${lock_type_list}  status_code=${HTTP_BAD_REQUEST}
677977f8f58SSushil Singh    Redfish Delete Session  ${session_info}
678977f8f58SSushil Singh
679977f8f58SSushil Singh
680d03f2ce1SSushil SinghVerify Empty Lock Records For Invalid Session
681d03f2ce1SSushil Singh    [Documentation]  Verify no lock record found for invalid session.
682d03f2ce1SSushil Singh    [Arguments]  ${client_id}
683d03f2ce1SSushil Singh
684d03f2ce1SSushil Singh    # Description of argument(s):
685d03f2ce1SSushil Singh    # client_id    This client id can contain string value
686d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
687d03f2ce1SSushil Singh
688d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_id}
689d03f2ce1SSushil Singh
690d03f2ce1SSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
691d03f2ce1SSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
692d03f2ce1SSushil Singh
693d03f2ce1SSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
694d03f2ce1SSushil Singh    set to dictionary  ${session_info2}  SessionIDs  xxyXyyYZZz
695d03f2ce1SSushil Singh
696d03f2ce1SSushil Singh    ${lock_list2}=  Get Locks List On Resource  ${session_info2}
697f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list2}
698d03f2ce1SSushil Singh
699f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
700d03f2ce1SSushil Singh
701d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
702d03f2ce1SSushil Singh
703d03f2ce1SSushil Singh
704d03f2ce1SSushil SinghVerify Acquire Lock Fails On Another Lock
705d03f2ce1SSushil Singh    [Documentation]  Verify acquire lock on another lock fails.
706d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
707d03f2ce1SSushil Singh
708d03f2ce1SSushil Singh    # Description of argument(s):
709d03f2ce1SSushil Singh    # client_id    This client id can contain string value
710d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
711d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
712d03f2ce1SSushil Singh
713d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
714d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
715d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
716d03f2ce1SSushil Singh
717d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
718d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
719d03f2ce1SSushil Singh
720d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
721d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
722d03f2ce1SSushil Singh
723df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
724d03f2ce1SSushil Singh
725d03f2ce1SSushil Singh
726e33c6e6aSSushil SinghVerify Acquire Lock After Reboot
727e33c6e6aSSushil Singh    [Documentation]  Acquire read and write lock after the reboot and release lock.
728e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
729e33c6e6aSSushil Singh
730e33c6e6aSSushil Singh    # Description of argument(s):
731e33c6e6aSSushil Singh    # client_id    This client id can contain string value
732e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
733e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
734e33c6e6aSSushil Singh
735e33c6e6aSSushil Singh    ${trans_id_list}=  Create List
736f9a536caSSushil Singh    ${session_info}=  Create Session With ClientID  ${client_id}
737e33c6e6aSSushil Singh    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
738e33c6e6aSSushil Singh    Redfish OBMC Reboot (off)
739e33c6e6aSSushil Singh    Redfish Login
740e33c6e6aSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}
741e33c6e6aSSushil Singh
742e33c6e6aSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
743e33c6e6aSSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
744e33c6e6aSSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
745e33c6e6aSSushil Singh
746df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
747df390b61SSushil Singh
748df390b61SSushil Singh
749df390b61SSushil SinghVerify Acquire Multiple Lock Request At CEC Level
750df390b61SSushil Singh    [Documentation]  Acquire lock in loop.
751df390b61SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
752df390b61SSushil Singh
753df390b61SSushil Singh    # Description of argument(s):
754df390b61SSushil Singh    # client_id    This client id can contain string value
755df390b61SSushil Singh    #              (e.g. 12345, "HMCID").
756df390b61SSushil Singh    # lock_type    Read lock or Write lock.
757df390b61SSushil Singh
758df390b61SSushil Singh    ${trans_id_list}=  Create List
759df390b61SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
760df390b61SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
761df390b61SSushil Singh
762df390b61SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
763df390b61SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
764df390b61SSushil Singh
765df390b61SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
766df390b61SSushil Singh
767df390b61SSushil Singh    Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
768df390b61SSushil Singh
769df390b61SSushil Singh    Release locks And Delete Session  ${session_info}  ${trans_id_list}
770e33c6e6aSSushil Singh
771e33c6e6aSSushil Singh
772d03f2ce1SSushil SinghVerify Acquire And Release Lock In Loop
773d03f2ce1SSushil Singh    [Documentation]  Acquire lock in loop.
774d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
775d03f2ce1SSushil Singh
776d03f2ce1SSushil Singh    # Description of argument(s):
777d03f2ce1SSushil Singh    # client_id    This client id can contain string value
778d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
779d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
780d03f2ce1SSushil Singh
781d03f2ce1SSushil Singh    FOR  ${count}  IN RANGE  1  11
782d03f2ce1SSushil Singh      ${trans_id_list}=  Create List
783d03f2ce1SSushil Singh      ${session_info}=  Create Redfish Session With ClientID  ${client_id}
784d03f2ce1SSushil Singh      ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
785d03f2ce1SSushil Singh      Append To List  ${trans_id_list}  ${trans_id}
786d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_list}
787d03f2ce1SSushil Singh      Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
788d03f2ce1SSushil Singh      ${trans_id_emptylist}=  Create List
789d03f2ce1SSushil Singh      Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
790d03f2ce1SSushil Singh    END
791d03f2ce1SSushil Singh
792d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
793d03f2ce1SSushil Singh
794d03f2ce1SSushil Singh
795d03f2ce1SSushil SinghAcquire And Release Multiple Locks
796d03f2ce1SSushil Singh    [Documentation]  Acquire mutilple locks on resource.
797d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
798d03f2ce1SSushil Singh
799d03f2ce1SSushil Singh    # Description of argument(s):
800d03f2ce1SSushil Singh    # client_id          This client id can contain string value
801d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
802d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
803d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
804d03f2ce1SSushil Singh
805d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
806d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
807d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
808d03f2ce1SSushil Singh
809d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
810d03f2ce1SSushil Singh
811d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
812d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
813d03f2ce1SSushil Singh
814d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
815d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
816d03f2ce1SSushil Singh
817d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
818d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_list}
819d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
820d03f2ce1SSushil Singh
821d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
822d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
823d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
824d03f2ce1SSushil Singh
825d03f2ce1SSushil Singh
826*1b59053dSSushil SinghVerify Fail To Release Multiple Lock With Invalid TransactionID
827*1b59053dSSushil Singh    [Documentation]  Verify release multiple locks with invalid transaction ID fails.
828d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
829d03f2ce1SSushil Singh
830d03f2ce1SSushil Singh    # Description of argument(s):
831d03f2ce1SSushil Singh    # client_id          This client id can contain string value
832d03f2ce1SSushil Singh    #                    (e.g. 12345, "HMCID").
833d03f2ce1SSushil Singh    # lock_type          Read lock or Write lock.
834d03f2ce1SSushil Singh    # release_lock_type  The value can be Transaction or Session.
835d03f2ce1SSushil Singh
836d03f2ce1SSushil Singh    ${trans_id_list}=  Create List
837d03f2ce1SSushil Singh    @{lock_type_list}=  Split String  ${lock_type}  ,
838d03f2ce1SSushil Singh
839d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
840d03f2ce1SSushil Singh
841d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
842d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
843d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
844d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
845d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
846d03f2ce1SSushil Singh
847d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
848d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
849d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
850d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
851d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
852d03f2ce1SSushil Singh
853d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
854d03f2ce1SSushil Singh    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
855d03f2ce1SSushil Singh    ${value}=  Evaluate  ${value} + 10
856d03f2ce1SSushil Singh    Set To Dictionary  ${trans_id}  TransactionID  ${value}
857d03f2ce1SSushil Singh    Append To List  ${trans_id_list}  ${trans_id}
858d03f2ce1SSushil Singh
859d03f2ce1SSushil Singh    Release Locks On Resource
860d03f2ce1SSushil Singh    ...  ${session_info}  ${trans_id_list}
861d03f2ce1SSushil Singh    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
862d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
863d03f2ce1SSushil Singh
864d03f2ce1SSushil Singh    ${trans_id_emptylist}=  Create List
865d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
866d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
867d03f2ce1SSushil Singh
868d03f2ce1SSushil Singh
869d03f2ce1SSushil SinghVerify Fail To Release Lock For Another Session
870d03f2ce1SSushil Singh    [Documentation]  Verify failed to release the lock form another session.
871d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}
872d03f2ce1SSushil Singh
873d03f2ce1SSushil Singh    # Description of argument(s):
874d03f2ce1SSushil Singh    # client_id    This client id can contain string value
875d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
876d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
877d03f2ce1SSushil Singh
878d03f2ce1SSushil Singh    ${client_ids}=  Split String  ${client_id}  ,
879d03f2ce1SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
880d03f2ce1SSushil Singh    ${trans_id_list1}=  Create List
881d03f2ce1SSushil Singh    ${trans_id_list2}=  Create List
882d03f2ce1SSushil Singh
883d03f2ce1SSushil Singh    ${session_info1}=  Create Redfish Session With ClientID  ${client_ids}[0]
884d03f2ce1SSushil Singh
885d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
886d03f2ce1SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
887d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
888d03f2ce1SSushil Singh
889d03f2ce1SSushil Singh    ${session_info2}=  Create Redfish Session With ClientID  ${client_ids}[1]
890d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
891d03f2ce1SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
892d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info2}  ${trans_id_list2}
893d03f2ce1SSushil Singh
894d03f2ce1SSushil Singh    Release Locks On Resource
895d03f2ce1SSushil Singh    ...  ${session_info1}  ${trans_id_list1}  Transaction  status_code=${HTTP_UNAUTHORIZED}
896d03f2ce1SSushil Singh    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
897d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Session
898d03f2ce1SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Session
899d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info1}
900d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info2}
901d03f2ce1SSushil Singh
902d03f2ce1SSushil Singh
903e33c6e6aSSushil SinghVerify Fail To Acquire Lock For Invalid Resource ID Data Type
904e33c6e6aSSushil Singh    [Documentation]  Verify fail to acquire the lock with invalid resource id data type.
905e33c6e6aSSushil Singh    [Arguments]  ${client_id}  ${lock_type}
906e33c6e6aSSushil Singh
907e33c6e6aSSushil Singh    # Description of argument(s):
908e33c6e6aSSushil Singh    # client_id    This client id can contain string value
909e33c6e6aSSushil Singh    #              (e.g. 12345, "HMCID").
910e33c6e6aSSushil Singh    # lock_type    Read lock or Write lock.
911e33c6e6aSSushil Singh
912e33c6e6aSSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
913e33c6e6aSSushil Singh    Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
914e33c6e6aSSushil Singh    ...  ${lock_type}  status_code=${HTTP_BAD_REQUEST}
915e33c6e6aSSushil Singh    Redfish Delete Session  ${session_info}
916e33c6e6aSSushil Singh
917e33c6e6aSSushil Singh
918d03f2ce1SSushil SinghVerify Fail To Acquire Lock For Invalid Lock Data
919e33c6e6aSSushil Singh    [Documentation]  Verify fail to acquired lock with invalid lock types, lock flags, segement flags.
920d03f2ce1SSushil Singh    [Arguments]  ${client_id}  ${lock_type}  ${message}
921d03f2ce1SSushil Singh
922d03f2ce1SSushil Singh    # Description of argument(s):
923d03f2ce1SSushil Singh    # client_id    This client id can contain string value
924d03f2ce1SSushil Singh    #              (e.g. 12345, "HMCID").
925d03f2ce1SSushil Singh    # lock_type    Read lock or Write lock.
926d03f2ce1SSushil Singh    # message      Return message from URI.
927d03f2ce1SSushil Singh
928d03f2ce1SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
929d03f2ce1SSushil Singh    ${trans_id}=  Redfish Post Acquire Invalid Lock  ${lock_type}  message=${message}  status_code=${HTTP_BAD_REQUEST}
930d03f2ce1SSushil Singh    Redfish Delete Session  ${session_info}
931bace3005SSushil Singh
932bace3005SSushil Singh
933bace3005SSushil SinghVerify No Locks Records For Session With No Acquired Lock
934bace3005SSushil Singh    [Documentation]  Verify no records found for a session where no lock is acquired.
935bace3005SSushil Singh    [Arguments]  ${client_id}
936bace3005SSushil Singh
937bace3005SSushil Singh    # Description of argument(s):
938bace3005SSushil Singh    # client_id    This client id can contain string value
939bace3005SSushil Singh    #              (e.g. 12345, "HMCID").
940bace3005SSushil Singh
941bace3005SSushil Singh    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
942bace3005SSushil Singh    ${trans_id_emptylist}=  Create List
943bace3005SSushil Singh    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
944bace3005SSushil Singh    Redfish Delete Session  ${session_info}
945728ef9c9SSushil Singh
946728ef9c9SSushil Singh
947728ef9c9SSushil SinghCreate List Of Session ID
948728ef9c9SSushil Singh    [Documentation]  Create session id list from session dict info.
949728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}
950728ef9c9SSushil Singh
951728ef9c9SSushil Singh    # Description of argument(s):
952728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
953728ef9c9SSushil Singh
954728ef9c9SSushil Singh    @{session_id_list}=  Create List
955728ef9c9SSushil Singh
956728ef9c9SSushil Singh    FOR  ${session}  IN  @{session_dict_info}
957728ef9c9SSushil Singh      Append To List  ${session_id_list}  ${session["SessionIDs"]}
958728ef9c9SSushil Singh    END
959728ef9c9SSushil Singh
960728ef9c9SSushil Singh    ${num_id}=  Get Length  ${session_id_list}
961728ef9c9SSushil Singh    Should Not Be Equal As Integers  ${num_id}  ${0}
962728ef9c9SSushil Singh
963728ef9c9SSushil Singh    ${session_id_list}=  Evaluate  json.dumps(${session_id_list})  json
964728ef9c9SSushil Singh
965728ef9c9SSushil Singh    [Return]  ${session_id_list}
966728ef9c9SSushil Singh
967728ef9c9SSushil Singh
968728ef9c9SSushil SinghGet Locks List On Resource With Session List
969728ef9c9SSushil Singh    [Documentation]  Get locks list from session of list.
970728ef9c9SSushil Singh    [Arguments]  ${session_id_list}  ${exp_status_code}=${HTTP_OK}
971728ef9c9SSushil Singh
972728ef9c9SSushil Singh    # Description of argument(s):
973728ef9c9SSushil Singh    # session_id_list    Session ids list.
974728ef9c9SSushil Singh    # exp_status_code    Expected HTTP status code.
975728ef9c9SSushil Singh
976728ef9c9SSushil Singh    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
977728ef9c9SSushil Singh    ...  data={"SessionIDs": ${session_id_list}}
978728ef9c9SSushil Singh    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
979728ef9c9SSushil Singh
980728ef9c9SSushil Singh    [Return]  ${locks}
981728ef9c9SSushil Singh
982728ef9c9SSushil Singh
983728ef9c9SSushil SinghVerify List Of Session Lock On Resource
984728ef9c9SSushil Singh    [Documentation]  Verify list of lock record from list of sessions.
985728ef9c9SSushil Singh    [Arguments]  ${session_dict_info}  ${transaction_id_list}
986728ef9c9SSushil Singh
987728ef9c9SSushil Singh    # Description of argument(s):
988728ef9c9SSushil Singh    # session_dict_info      Session information in dict.
989728ef9c9SSushil Singh    # transaction_id_list    Transaction id in list stored in dict.
990728ef9c9SSushil Singh
991728ef9c9SSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_info}
992728ef9c9SSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
993728ef9c9SSushil Singh    ${lock_list}=  Set Variable  ${lock_list_resp['Records']}
994728ef9c9SSushil Singh
995728ef9c9SSushil Singh    FOR  ${session_id}  ${tran_id}  ${lock_record}  IN ZIP  ${session_dict_info}  ${transaction_id_list}  ${lock_list}
996728ef9c9SSushil Singh      Valid Value  session_id['SessionIDs']  ['${lock_record['SessionID']}']
997728ef9c9SSushil Singh      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock_record['TransactionID']}
998728ef9c9SSushil Singh    END
999728ef9c9SSushil Singh
1000728ef9c9SSushil Singh
1001728ef9c9SSushil SinghVerify Lock Records Of Multiple Session
1002728ef9c9SSushil Singh    [Documentation]  Verify all records found for a multiple sessions.
1003728ef9c9SSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
1004728ef9c9SSushil Singh
1005728ef9c9SSushil Singh    # Description of argument(s):
1006728ef9c9SSushil Singh    # client_ids    This client id can contain string value
1007728ef9c9SSushil Singh    #               (e.g. 12345, "HMCID").
1008728ef9c9SSushil Singh    # lock_type     Read lock or Write lock.
1009728ef9c9SSushil Singh
1010728ef9c9SSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
1011728ef9c9SSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
1012728ef9c9SSushil Singh    ${trans_id_list1}=  Create List
1013728ef9c9SSushil Singh    ${trans_id_list2}=  Create List
1014728ef9c9SSushil Singh
1015728ef9c9SSushil Singh    ${session_dict_list}=  Create List
1016728ef9c9SSushil Singh    ${lock_list}=  Create List
1017728ef9c9SSushil Singh
1018728ef9c9SSushil Singh    ${client_id1}=  Create List
1019728ef9c9SSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
1020728ef9c9SSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
1021728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
1022728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
1023728ef9c9SSushil Singh
1024728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1025728ef9c9SSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
1026728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
1027728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
1028728ef9c9SSushil Singh
1029728ef9c9SSushil Singh
1030728ef9c9SSushil Singh    ${client_id2}=  Create List
1031728ef9c9SSushil Singh    Append To List  ${client_id2}  ${client_id_list}[1]
1032728ef9c9SSushil Singh    ${session_info2}=  Create Session With List Of ClientID  ${client_id2}
1033728ef9c9SSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
1034728ef9c9SSushil Singh    Verify A Session Created With ClientID  ${client_id2}  ${session_info2}
1035728ef9c9SSushil Singh
1036728ef9c9SSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1037728ef9c9SSushil Singh    Append To List  ${trans_id_list2}  ${trans_id}
1038728ef9c9SSushil Singh    Append To List  ${lock_list}  ${trans_id}
1039728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_list2}
1040728ef9c9SSushil Singh
1041728ef9c9SSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
1042728ef9c9SSushil Singh
1043728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
1044728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1045728ef9c9SSushil Singh
1046728ef9c9SSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
1047728ef9c9SSushil Singh
1048728ef9c9SSushil Singh    ${session_token}=  Get From Dictionary  ${session_info2}[0]  SessionToken
1049728ef9c9SSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1050728ef9c9SSushil Singh
1051728ef9c9SSushil Singh    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Transaction
1052728ef9c9SSushil Singh
1053728ef9c9SSushil Singh    ${trans_id_emptylist}=  Create List
1054728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
1055728ef9c9SSushil Singh    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_emptylist}
1056728ef9c9SSushil Singh
1057728ef9c9SSushil Singh    Redfish Delete List Of Session  ${session_dict_list}
1058f9a536caSSushil Singh
1059f9a536caSSushil Singh
1060f9a536caSSushil SinghVerify Lock Records For Multiple Invalid Session
1061f9a536caSSushil Singh    [Documentation]  Verify no lock record found for multiple invalid session.
1062f9a536caSSushil Singh    [Arguments]  ${client_id}
1063f9a536caSSushil Singh
1064f9a536caSSushil Singh    # Description of argument(s):
1065f9a536caSSushil Singh    # client_id    This client id can contain string value
1066f9a536caSSushil Singh    #              (e.g. 12345, "HMCID").
1067f9a536caSSushil Singh
1068f9a536caSSushil Singh    ${session_dict_list}=  Create List
1069f9a536caSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz  xXyXYyYZzz
1070f9a536caSSushil Singh
1071f9a536caSSushil Singh    ${session_info1}=  Create Session With ClientID  ${client_id}
1072f9a536caSSushil Singh
1073f9a536caSSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
1074f9a536caSSushil Singh    set to dictionary  ${session_info2}  SessionIDs  ${invalid_session_ids}[0]
1075f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}
1076f9a536caSSushil Singh
1077f9a536caSSushil Singh    ${session_info3}=  Copy Dictionary  ${session_info1}  deepcopy=True
1078f9a536caSSushil Singh    set to dictionary  ${session_info3}  SessionIDs  ${invalid_session_ids}[0]
1079f9a536caSSushil Singh    Append To List  ${session_dict_list}  ${session_info3}
1080f9a536caSSushil Singh
1081f9a536caSSushil Singh    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
1082f9a536caSSushil Singh    ${lock_length1}=  Get Length  ${lock_list1}
1083f9a536caSSushil Singh
1084f9a536caSSushil Singh    ${session_id_list}=  Create List Of Session ID  ${session_dict_list}
1085f9a536caSSushil Singh    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1086f9a536caSSushil Singh    ${lock_length2}=  Get Length  ${lock_list_resp['Records']}
1087f9a536caSSushil Singh
1088f9a536caSSushil Singh    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
1089f9a536caSSushil Singh
1090f9a536caSSushil Singh    Redfish Delete Session  ${session_info1}
109111949a2cSSushil Singh
109211949a2cSSushil Singh
109311949a2cSSushil SinghVerify Lock Records For Multiple Invalid And Valid Session
109411949a2cSSushil Singh    [Documentation]  Verify all records found for a valid and invalid sessions.
109511949a2cSSushil Singh    [Arguments]  ${client_ids}  ${lock_type}
109611949a2cSSushil Singh
109711949a2cSSushil Singh    # Description of argument(s):
109811949a2cSSushil Singh    # client_ids    This client id can contain string value
109911949a2cSSushil Singh    #               (e.g. 12345, "HMCID").
110011949a2cSSushil Singh    # lock_type     Read lock or Write lock.
110111949a2cSSushil Singh
110211949a2cSSushil Singh    ${client_id_list}=  Split String  ${client_ids}  ,
110311949a2cSSushil Singh    ${lock_type_list}=  Split String  ${lock_type}  ,
110411949a2cSSushil Singh    ${trans_id_list1}=  Create List
110511949a2cSSushil Singh    ${invalid_session_ids}=  Create List  xxyXyyYZZz
110611949a2cSSushil Singh
110711949a2cSSushil Singh    ${session_dict_list}=  Create List
110811949a2cSSushil Singh    ${lock_list}=  Create List
110911949a2cSSushil Singh
111011949a2cSSushil Singh    ${client_id1}=  Create List
111111949a2cSSushil Singh    Append To List  ${client_id1}  ${client_id_list}[0]
111211949a2cSSushil Singh    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
111311949a2cSSushil Singh    Append To List  ${session_dict_list}  ${session_info1}[0]
111411949a2cSSushil Singh    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
111511949a2cSSushil Singh
111611949a2cSSushil Singh    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
111711949a2cSSushil Singh    Append To List  ${trans_id_list1}  ${trans_id}
111811949a2cSSushil Singh    Append To List  ${lock_list}  ${trans_id}
111911949a2cSSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
112011949a2cSSushil Singh
112111949a2cSSushil Singh    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
112211949a2cSSushil Singh    set to dictionary  ${session_info2}[0]  SessionIDs  ${invalid_session_ids}[0]
112311949a2cSSushil Singh    Append To List  ${session_dict_list}  ${session_info2}[0]
112411949a2cSSushil Singh
112511949a2cSSushil Singh    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
112611949a2cSSushil Singh
112711949a2cSSushil Singh    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
112811949a2cSSushil Singh    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
112911949a2cSSushil Singh
113011949a2cSSushil Singh    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
113111949a2cSSushil Singh
113211949a2cSSushil Singh    ${trans_id_emptylist}=  Create List
113311949a2cSSushil Singh    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
113411949a2cSSushil Singh
113511949a2cSSushil Singh    Redfish Delete Session  ${session_info1}[0]
1136