1*** Settings ***
2
3Documentation        Test lock management feature of management console on BMC.
4
5Resource             ../../lib/resource.robot
6Resource             ../../lib/openbmc_ffdc.robot
7Resource             ../../lib/bmc_redfish_utils.robot
8Resource             ../../lib/external_intf/management_console_utils.robot
9
10Suite Setup          Run Keyword And Ignore Error  Delete All Redfish Sessions
11Suite Teardown       Redfish.Logout
12Test Setup           Printn
13Test Teardown        FFDC On Test Case Fail
14
15*** Variables ***
16
17${BAD_REQUEST}       Bad Request
18
19*** Test Cases ***
20
21Acquire Read Write Lock
22    [Documentation]  Acquire and release different read locks.
23    [Tags]  Acquire_Read_Write_Lock
24    [Template]  Acquire Lock On Resource
25
26    # client_id    lock_type     reboot_flag
27    HMCID-01       ReadCase1     False
28    HMCID-01       ReadCase2     False
29    HMCID-01       ReadCase3     False
30    HMCID-01       WriteCase1    False
31    HMCID-01       WriteCase2    False
32    HMCID-01       WriteCase3    False
33
34
35Check Lock Persistency On BMC Reboot
36    [Documentation]  Acquire lock and check after reboot it remain same.
37    [Tags]  Check_Lock_Persistency_On_BMC_Reboot
38    [Template]  Acquire Lock On Resource
39
40    # client_id    lock_type     reboot_flag
41    HMCID-01       ReadCase1     True
42    HMCID-01       ReadCase2     True
43    HMCID-01       ReadCase3     True
44    HMCID-01       WriteCase1    True
45    HMCID-01       WriteCase2    True
46    HMCID-01       WriteCase3    True
47
48
49Acquire Read Lock On Read Lock
50    [Documentation]  Acquire read lock on another read lock.
51    [Tags]  Acquire_Read_Lock_On_Read_Lock
52    [Template]  Acquire Lock On Another Lock
53
54    # client_id
55    HMCID-01
56
57
58Get Lock Records Empty For Invalid Session
59    [Documentation]  Record of lock list is empty for invalid session.
60    [Tags]  Get_Lock_Records_Empty_For_Invalid_Session
61    [Template]  Verify Empty Lock Records For Invalid Session
62
63    # client_id
64    HMCID-01
65
66
67Fail To Acquire Lock On Another Lock
68    [Documentation]  Fail to acquire another lock.
69    [Tags]  Fail_To_Acquire_Lock_On_Another_Lock
70    [Template]  Verify Acquire Lock Fails On Another Lock
71
72    # client_id    lock_type
73    HMCID-01       ReadCase2,WriteCase2
74    HMCID-01       WriteCase2,WriteCase2
75    HMCID-01       WriteCase2,ReadCase2
76
77
78Acquire And Release Lock In Loop
79    [Documentation]  Acquire and release read, write locks in loop.
80    [Tags]  Acquire_And_Release_Lock_In_Loop
81    [Template]  Verify Acquire And Release Lock In Loop
82
83    # client_id    lock_type
84    HMCID-01       ReadCase1
85    HMCID-01       ReadCase2
86    HMCID-01       ReadCase3
87    HMCID-01       WriteCase1
88    HMCID-01       WriteCase2
89    HMCID-01       WriteCase3
90
91
92Verify Release Of Valid Locks
93    [Documentation]  Release all valid locks.
94    [Tags]  Verify_Release_Of_Valid_Locks
95    [Template]  Acquire And Release Multiple Locks
96
97    # client_id    lock_type                        release_lock_type
98    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
99    HMCID-02       ReadCase1,ReadCase1,ReadCase1    Session
100
101
102Invalid Locks Fail To Release
103    [Documentation]  Release in-valid lock result in fail.
104    [Tags]  Invalid_Locks_Fail_To_Release
105    [Template]  Verify Invalid Locks Fail To Release
106
107    # client_id    lock_type                        release_lock_type
108    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
109    12345          ReadCase2,ReadCase2,ReadCase2    Transaction
110    HMCID          ReadCase3,ReadCase3,ReadCase3    Transaction
111
112
113Fail To Release Lock For Another Session
114    [Documentation]  Failed to release locks from another session.
115    [Tags]  Fail_To_Release_Lock_For_Another_Session
116    [Template]  Verify Fail To Release Lock For Another Session
117
118    # client_id          lock_type
119    HMCID-01,HMCID-02    ReadCase1,ReadCase1
120
121
122Fail To Acquire Lock For Invalid Lock Type
123    [Documentation]  Failed to acquire read, write lock for invalid lock data passed.
124    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Type
125    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
126
127    # client_id    lock_type      message
128    HMCID-01       ReadCase1      ${BAD_REQUEST}
129    HMCID-01       ReadCase2      ${BAD_REQUEST}
130    HMCID-01       ReadCase3      ${BAD_REQUEST}
131    HMCID-01       ReadCase4      ${BAD_REQUEST}
132    HMCID-01       ReadCase5      ${BAD_REQUEST}
133    HMCID-01       WriteCase1     ${BAD_REQUEST}
134    HMCID-01       WriteCase2     ${BAD_REQUEST}
135    HMCID-01       WriteCase3     ${BAD_REQUEST}
136    HMCID-01       WriteCase4     ${BAD_REQUEST}
137    HMCID-01       WriteCase5     ${BAD_REQUEST}
138
139
140Fail To Acquire Lock For Invalid Lock Flag
141    [Documentation]  Failed to acquire read write lock for invalid lock flag passed.
142    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
143    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
144
145    # client_id    lock_type       message
146    HMCID-01       ReadCase6       ${BAD_REQUEST}
147    HMCID-01       ReadCase7       ${BAD_REQUEST}
148    HMCID-01       ReadCase8       ${BAD_REQUEST}
149    HMCID-01       ReadCase9       ${BAD_REQUEST}
150    HMCID-01       ReadCase10      ${BAD_REQUEST}
151    HMCID-01       ReadCase11      ${BAD_REQUEST}
152    HMCID-01       WriteCase6      ${BAD_REQUEST}
153    HMCID-01       WriteCase7      ${BAD_REQUEST}
154    HMCID-01       WriteCase8      ${BAD_REQUEST}
155    HMCID-01       WriteCase9      ${BAD_REQUEST}
156    HMCID-01       WriteCase10     ${BAD_REQUEST}
157    HMCID-01       WriteCase11     ${BAD_REQUEST}
158
159
160Fail To Acquire Lock For Invalid Segment Flag
161    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
162    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Flag
163    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
164
165    # client_id    lock_type       message
166    HMCID-01       ReadCase12      ${BAD_REQUEST}
167    HMCID-01       ReadCase13      ${BAD_REQUEST}
168    HMCID-01       ReadCase14      ${BAD_REQUEST}
169    HMCID-01       WriteCase12     ${BAD_REQUEST}
170    HMCID-01       WriteCase13     ${BAD_REQUEST}
171    HMCID-01       WriteCase14     ${BAD_REQUEST}
172
173*** Keywords ***
174
175Create Redfish Session With ClientID
176    [Documentation]  Create redifish session with client id.
177    [Arguments]  ${client_id}
178
179    # Description of argument(s):
180    # client_id    This client id can contain string value
181    #              (e.g. 12345, "HMCID").
182
183    ${session_info}=  Create Dictionary
184    ${session}=  Redfish Login  kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
185
186    Set To Dictionary  ${session_info}  SessionIDs  ${session['Id']}
187    Set To Dictionary  ${session_info}  ClientID  ${session["Oem"]["OpenBMC"]["ClientID"]}
188
189    [Return]  ${session_info}
190
191
192RW General Dictionary
193    [Documentation]  Create dictionay of lock request.
194    [Arguments]  ${read_case}  ${res_id}
195
196    # Description of argument(s):
197    # read_case    Read or Write lock type.
198    # res_id       Resource id.
199
200    ${request_dict}=  Create Dictionary
201
202    FOR  ${key}  IN  @{read_case.keys()}
203      Set To Dictionary  ${request_dict}  LockType  ${key}
204      Set To Dictionary  ${request_dict}  SegmentFlags  ${read_case["${key}"]}
205    END
206
207    Set To Dictionary  ${request_dict}  ResourceID  ${res_id}
208
209    [Return]  ${request_dict}
210
211
212Return Description Of Response
213    [Documentation]  Return description of REST response.
214    [Arguments]  ${resp_text}
215
216    # Description of argument(s):
217    # resp_text    REST response body.
218
219    # resp_text after successful partition file upload looks like:
220    # {
221    #    "Description": "File Created"
222    # }
223
224    ${message}=  Evaluate  json.loads('''${resp_text}''')  json
225
226    [Return]  ${message}
227
228
229Redfish Post Acquire Lock
230    [Documentation]  Acquire and release lock.
231    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
232
233    # Description of argument(s):
234    # lock_type      Read lock or Write lock.
235    # status_code    HTTP status code.
236
237    ${resp}=  Form Data To Acquire Lock  ${lock_type}
238    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${resp}
239    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
240    ${resp}=  Return Description Of Response  ${resp.content}
241
242    [Return]  ${resp}
243
244
245Redfish Post Acquire Invalid Lock
246    [Documentation]  Redfish to post request to acquire in-valid lock.
247    [Arguments]  ${lock_type}  ${message}  ${status_code}=${HTTP_OK}
248
249    # Description of argument(s):
250    # lock_type      Read lock or Write lock.
251    # message        Return message from URI.
252    # status_code    HTTP status code.
253
254    ${resp}=  Form Data To Acquire Invalid Lock  ${lock_type}
255    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${resp}
256    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
257    Valid Value  message  ['${resp.content}']
258
259    [Return]  ${resp}
260
261
262Form Data To Acquire Lock
263    [Documentation]  Create a dictionay for lock request.
264    [Arguments]  ${lock_type}
265
266    # Description of argument(s):
267    # lock_type      Read lock or Write lock.
268
269    ${lock_res_info}=  Get Lock Resource Information
270    ${resp}=  RW General Dictionary
271    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
272    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
273    ${temp_list}=  Create List  ${resp}
274    ${lock_request}=  Create Dictionary  Request=${temp_list}
275
276    [Return]  ${lock_request}
277
278
279Form Data To Acquire Invalid Lock
280    [Documentation]  Create a dictionay for in-valid lock request.
281    [Arguments]  ${lock_type}
282
283    # Description of argument(s):
284    # lock_type      Read lock or Write lock.
285
286    ${lock_res_info}=  Get Lock Resource Information
287    ${resp}=  RW General Dictionary
288    ...    ${lock_res_info["Invalid Case"]["${lock_type}"]}
289    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
290    ${temp_list}=  Create List  ${resp}
291    ${lock_request}=  Create Dictionary  Request=${temp_list}
292
293    [Return]  ${lock_request}
294
295
296Get Locks List On Resource
297    [Documentation]  Get locks list.
298    [Arguments]  ${session_info}  ${exp_status_code}=${HTTP_OK}
299
300    # Description of argument(s):
301    # session_info       Session information in dict.
302    # exp_status_code    Expected HTTP status code.
303
304    ${data}=  Set Variable  {"SessionIDs": ["${session_info['SessionIDs']}"]}
305    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
306    ...  data=${data}
307    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
308
309    [Return]  ${locks["Records"]}
310
311
312Verify Lock On Resource
313    [Documentation]  Verify lock on resource.
314    [Arguments]  ${session_info}  ${transaction_id}
315
316    # Description of argument(s):
317    # session_info      Session information in dict.
318    # transaction_id    Transaction id in list stored in dict.
319
320    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
321    Rprint Vars  sessions
322    ${lock_list}=  Get Locks List On Resource  ${session_info}
323    ${lock_length}=  Get Length  ${lock_list}
324    ${tran_id_length}=  Get Length  ${transaction_id}
325    Should Be Equal As Integers  ${tran_id_length}  ${lock_length}
326
327    FOR  ${tran_id}  ${lock}  IN ZIP  ${transaction_id}  ${lock_list}
328      Valid Value  session_info['ClientID']  ['${lock['HMCID']}']
329      Valid Value  session_info['SessionIDs']  ['${lock['SessionID']}']
330      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock['TransactionID']}
331    END
332
333
334Redfish Delete Session
335    [Documentation]  Redfish delete session.
336    [Arguments]  ${session_info}
337
338    # Description of argument(s):
339    # session_info      Session information in dict.
340
341    Redfish.Delete  /redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}
342
343
344Acquire Lock On Resource
345    [Documentation]  Acquire lock on resource.
346    [Arguments]  ${client_id}  ${lock_type}  ${reboot_flag}=False
347
348    # Description of argument(s):
349    # client_id    This client id can contain string value
350    #              (e.g. 12345, "HMCID").
351    # lock_type    Read lock or Write lock.
352    # reboot_flag  Flag is used to run reboot the BMC code.
353    #               (e.g. True or False).
354
355    ${trans_id_list}=  Create List
356    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
357    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
358    Append To List  ${trans_id_list}  ${trans_id}
359    Verify Lock On Resource  ${session_info}  ${trans_id_list}
360
361    ${BEROFE_REBOOT_XAUTH_TOKEN}=  Set Variable  ${XAUTH_TOKEN}
362
363    Run Keyword If  '${reboot_flag}' == 'True'
364    ...  Run Keywords  Redfish OBMC Reboot (off)  AND
365    ...  Redfish Login  AND
366    ...  Set Global Variable  ${XAUTH_TOKEN}  ${BEROFE_REBOOT_XAUTH_TOKEN}  AND
367    ...  Verify Lock On Resource  ${session_info}  ${trans_id_list}  AND
368    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
369
370    Run Keyword If  '${reboot_flag}' == 'False'
371    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
372
373    ${trans_id_emptylist}=  Create List
374    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
375    Redfish Delete Session  ${session_info}
376
377
378Form Data To Release Lock
379    [Documentation]  Create a dictonay to release lock.
380    [Arguments]  ${trans_id_list}
381
382    # Description of argument(s):
383    # trans_id_list
384
385    @{tran_ids}=  Create List
386
387    FOR  ${item}  IN  @{trans_id_list}
388      Append To List  ${tran_ids}  ${item['TransactionID']}
389    END
390
391    [Return]  ${tran_ids}
392
393
394Release Locks On Resource
395    [Documentation]  Redfish request to release a lock.
396    [Arguments]  ${session_info}  ${trans_id_list}  ${release_lock_type}=Transaction  ${status_code}=${HTTP_OK}
397
398    # Description of argument(s):
399    # session_info        Session information in dict.
400    # trans_id_list       Transaction id list.
401    # release_lock_type   Release lock by Transaction, Session.
402    # status_code         HTTP status code.
403
404    ${tran_ids}=  Form Data To Release Lock  ${trans_id_list}
405    ${data}=  Set Variable  {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
406    ${data}=  Evaluate  json.dumps(${data})  json
407    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock  data=${data}
408    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
409
410
411Acquire Lock On Another Lock
412    [Documentation]  Acquire lock on another lock.
413    [Arguments]  ${client_id}
414
415    # Description of argument(s):
416    # client_id    This client id can contain string value
417    #              (e.g. 12345, "HMCID").
418
419    ${trans_id_list}=  Create List
420    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
421
422    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
423    Append To List  ${trans_id_list}  ${trans_id}
424
425    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
426    Append To List  ${trans_id_list}  ${trans_id}
427
428    Verify Lock On Resource  ${session_info}  ${trans_id_list}
429    Release Locks On Resource  ${session_info}  ${trans_id_list}
430
431    ${trans_id_emptylist}=  Create List
432    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
433    Redfish Delete Session  ${session_info}
434
435
436Verify Empty Lock Records For Invalid Session
437    [Documentation]  Verify no lock record found for invalid session.
438    [Arguments]  ${client_id}
439
440    # Description of argument(s):
441    # client_id    This client id can contain string value
442    #              (e.g. 12345, "HMCID").
443
444    ${session_info1}=  Create Redfish Session With ClientID  ${client_id}
445
446    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
447    ${lock_length1}=  Get Length  ${lock_list1}
448
449    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
450    set to dictionary  ${session_info2}  SessionIDs  xxyXyyYZZz
451
452    ${lock_list2}=  Get Locks List On Resource  ${session_info2}
453    ${lock_length2}=  Get Length  ${lock_list1}
454
455    Valid Value  lock_length1  ${lock_list2}
456
457    Redfish Delete Session  ${session_info1}
458
459
460Verify Acquire Lock Fails On Another Lock
461    [Documentation]  Verify acquire lock on another lock fails.
462    [Arguments]  ${client_id}  ${lock_type}
463
464    # Description of argument(s):
465    # client_id    This client id can contain string value
466    #              (e.g. 12345, "HMCID").
467    # lock_type    Read lock or Write lock.
468
469    @{lock_type_list}=  Split String  ${lock_type}  ,
470    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
471    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
472
473    ${trans_id_list}=  Create List
474    Append To List  ${trans_id_list}  ${trans_id}
475
476    Verify Lock On Resource  ${session_info}  ${trans_id_list}
477    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
478    Release Locks On Resource  ${session_info}  ${trans_id_list}
479
480    ${trans_id_emptylist}=  Create List
481    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
482
483    Redfish Delete Session  ${session_info}
484
485
486Verify Acquire And Release Lock In Loop
487    [Documentation]  Acquire lock in loop.
488    [Arguments]  ${client_id}  ${lock_type}
489
490    # Description of argument(s):
491    # client_id    This client id can contain string value
492    #              (e.g. 12345, "HMCID").
493    # lock_type    Read lock or Write lock.
494
495    FOR  ${count}  IN RANGE  1  11
496      ${trans_id_list}=  Create List
497      ${session_info}=  Create Redfish Session With ClientID  ${client_id}
498      ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
499      Append To List  ${trans_id_list}  ${trans_id}
500      Verify Lock On Resource  ${session_info}  ${trans_id_list}
501      Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
502      ${trans_id_emptylist}=  Create List
503      Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
504    END
505
506    Redfish Delete Session  ${session_info}
507
508
509Acquire And Release Multiple Locks
510    [Documentation]  Acquire mutilple locks on resource.
511    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
512
513    # Description of argument(s):
514    # client_id          This client id can contain string value
515    #                    (e.g. 12345, "HMCID").
516    # lock_type          Read lock or Write lock.
517    # release_lock_type  The value can be Transaction or Session.
518
519    @{lock_type_list}=  Split String  ${lock_type}  ,
520    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
521    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
522
523    ${trans_id_list}=  Create List
524
525    Append To List  ${trans_id_list}  ${trans_id}
526    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
527
528    Append To List  ${trans_id_list}  ${trans_id}
529    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
530
531    Append To List  ${trans_id_list}  ${trans_id}
532    Verify Lock On Resource  ${session_info}  ${trans_id_list}
533    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
534
535    ${trans_id_emptylist}=  Create List
536    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
537    Redfish Delete Session  ${session_info}
538
539
540Verify Invalid Locks Fail To Release
541    [Documentation]  Verify invalid locks fails to be released.
542    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
543
544    # Description of argument(s):
545    # client_id          This client id can contain string value
546    #                    (e.g. 12345, "HMCID").
547    # lock_type          Read lock or Write lock.
548    # release_lock_type  The value can be Transaction or Session.
549
550    ${trans_id_list}=  Create List
551    @{lock_type_list}=  Split String  ${lock_type}  ,
552
553    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
554
555    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
556    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
557    ${value}=  Evaluate  ${value} + 10
558    Set To Dictionary  ${trans_id}  TransactionID  ${value}
559    Append To List  ${trans_id_list}  ${trans_id}
560
561    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
562    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
563    ${value}=  Evaluate  ${value} + 10
564    Set To Dictionary  ${trans_id}  TransactionID  ${value}
565    Append To List  ${trans_id_list}  ${trans_id}
566
567    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
568    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
569    ${value}=  Evaluate  ${value} + 10
570    Set To Dictionary  ${trans_id}  TransactionID  ${value}
571    Append To List  ${trans_id_list}  ${trans_id}
572
573    Release Locks On Resource
574    ...  ${session_info}  ${trans_id_list}
575    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
576    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
577
578    ${trans_id_emptylist}=  Create List
579    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
580    Redfish Delete Session  ${session_info}
581
582
583Verify Fail To Release Lock For Another Session
584    [Documentation]  Verify failed to release the lock form another session.
585    [Arguments]  ${client_id}  ${lock_type}
586
587    # Description of argument(s):
588    # client_id    This client id can contain string value
589    #              (e.g. 12345, "HMCID").
590    # lock_type    Read lock or Write lock.
591
592    ${client_ids}=  Split String  ${client_id}  ,
593    ${lock_type_list}=  Split String  ${lock_type}  ,
594    ${trans_id_list1}=  Create List
595    ${trans_id_list2}=  Create List
596
597    ${session_info1}=  Create Redfish Session With ClientID  ${client_ids}[0]
598
599    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
600    Append To List  ${trans_id_list1}  ${trans_id}
601    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
602
603    ${session_info2}=  Create Redfish Session With ClientID  ${client_ids}[1]
604    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
605    Append To List  ${trans_id_list2}  ${trans_id}
606    Verify Lock On Resource  ${session_info2}  ${trans_id_list2}
607
608    Release Locks On Resource
609    ...  ${session_info1}  ${trans_id_list1}  Transaction  status_code=${HTTP_UNAUTHORIZED}
610    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
611    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Session
612    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Session
613    Redfish Delete Session  ${session_info1}
614    Redfish Delete Session  ${session_info2}
615
616
617Verify Fail To Acquire Lock For Invalid Lock Data
618    [Documentation]  Verify fail to quired lock with invalid lock types, lock flags, segement flags.
619    [Arguments]  ${client_id}  ${lock_type}  ${message}
620
621    # Description of argument(s):
622    # client_id    This client id can contain string value
623    #              (e.g. 12345, "HMCID").
624    # lock_type    Read lock or Write lock.
625    # message      Return message from URI.
626
627    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
628    ${trans_id}=  Redfish Post Acquire Invalid Lock  ${lock_type}  message=${message}  status_code=${HTTP_BAD_REQUEST}
629    Redfish Delete Session  ${session_info}
630