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
9Resource             ../../lib/rest_response_code.robot
10Library              ../../lib/bmc_network_utils.py
11
12Suite Setup          Run Keyword And Ignore Error  Delete All Redfish Sessions
13Suite Teardown       Run Keyword And Ignore Error  Delete All Redfish Sessions
14Test Setup           Printn
15Test Teardown        FFDC On Test Case Fail
16
17*** Variables ***
18
19${BAD_REQUEST}       Bad Request
20
21*** Test Cases ***
22
23Acquire Read Write Lock
24    [Documentation]  Acquire and release different read locks.
25    [Tags]  Acquire_Read_Write_Lock
26    [Template]  Acquire Lock On Resource
27
28    # client_id    lock_type     reboot_flag
29    HMCID-01       ReadCase1     False
30    HMCID-01       ReadCase2     False
31    HMCID-01       ReadCase3     False
32    HMCID-01       WriteCase1    False
33    HMCID-01       WriteCase2    False
34    HMCID-01       WriteCase3    False
35
36
37Check Lock Persistency On BMC Reboot
38    [Documentation]  Acquire lock and check after reboot it remain same.
39    [Tags]  Check_Lock_Persistency_On_BMC_Reboot
40    [Template]  Acquire Lock On Resource
41
42    # client_id    lock_type     reboot_flag
43    HMCID-01       ReadCase1     True
44    HMCID-01       ReadCase2     True
45    HMCID-01       ReadCase3     True
46    HMCID-01       WriteCase1    True
47    HMCID-01       WriteCase2    True
48    HMCID-01       WriteCase3    True
49
50
51Acquire Read Lock On Read Lock
52    [Documentation]  Acquire read lock on another read lock.
53    [Tags]  Acquire_Read_Lock_On_Read_Lock
54    [Template]  Acquire Lock On Another Lock
55
56    # client_id
57    HMCID-01
58
59
60Fail To Acquire Lock On Another Lock
61    [Documentation]  Fail to acquire another lock.
62    [Tags]  Fail_To_Acquire_Lock_On_Another_Lock
63    [Template]  Verify Acquire Lock Fails On Another Lock
64
65    # client_id    lock_type
66    HMCID-01       ReadCase2,WriteCase2
67    HMCID-01       WriteCase2,WriteCase2
68    HMCID-01       WriteCase2,ReadCase2
69
70
71Acquire Lock After Reboot
72    [Documentation]  Acquire and release read and write locks after reboot.
73    [Tags]  Acquire_Lock_After_Reboot
74    [Template]  Verify Acquire Lock After Reboot
75
76    # client_id    lock_type
77    HMCID-01       ReadCase1
78    HMCID-01       ReadCase2
79    HMCID-01       ReadCase3
80    HMCID-01       WriteCase1
81    HMCID-01       WriteCase2
82    HMCID-01       WriteCase3
83
84
85Acquire And Release Lock In Loop
86    [Documentation]  Acquire and release read, write locks in loop.
87    [Tags]  Acquire_And_Release_Lock_In_Loop
88    [Template]  Verify Acquire And Release Lock In Loop
89
90    # client_id    lock_type
91    HMCID-01       ReadCase1
92    HMCID-01       ReadCase2
93    HMCID-01       ReadCase3
94    HMCID-01       WriteCase1
95    HMCID-01       WriteCase2
96    HMCID-01       WriteCase3
97
98
99Fail To Acquire Read And Write In Single Request
100    [Documentation]  Fail to acquire read and write lock in single request.
101    [Tags]  Fail_To_Acquire_Read_And_Write_In_Single_Request
102    [Template]  Verify Fail To Acquire Read And Write In Single Request
103
104    # client_id    lock_type
105    HMCID-01       ReadCase1,WriteCase1
106    HMCID-01       WriteCase1,ReadCase1
107
108
109Acquire Multiple Lock Request At CEC Level
110    [Documentation]  Acquire write lock on read lock under CEC level.
111    [Tags]  Acquire_Multiple_Lock_Request_At_CEC_Level
112    [Template]  Verify Acquire Multiple Lock Request At CEC Level
113
114    # client_id    lock_type
115    HMCID-01       ReadCase4,WriteCase4
116    HMCID-01       WriteCase5,ReadCase5
117    HMCID-01       ReadCase6,WriteCase6
118    HMCID-01       WriteCase7,ReadCase7
119
120
121Verify Release Of Valid Locks
122    [Documentation]  Release all valid locks.
123    [Tags]  Verify_Release_Of_Valid_Locks
124    [Template]  Acquire And Release Multiple Locks
125
126    # client_id    lock_type                        release_lock_type
127    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
128    HMCID-02       ReadCase1,ReadCase1,ReadCase1    Session
129
130
131Fail To Release Lock With Invalid TransactionID
132    [Documentation]  Fail to release lock with invalid transaction id.
133    [Tags]  Fail_To_Release_Lock_With_Invalid_TransactionID
134    [Template]  Verify Fail To Release Lock With Invalid TransactionID
135
136    # client_id    lock_type    release_lock_type
137    HMCID-01       ReadCase1    Transaction
138
139
140Fail To Release Multiple Lock With Invalid TransactionID
141    [Documentation]  Release in-valid lock result in fail.
142    [Tags]  Fail_To_Release_Multiple_Lock_With_Invalid_TransactionID
143    [Template]  Verify Fail To Release Multiple Lock With Invalid TransactionID
144
145    # client_id    lock_type                        release_lock_type
146    HMCID-01       ReadCase1,ReadCase1,ReadCase1    Transaction
147    12345          ReadCase2,ReadCase2,ReadCase2    Transaction
148    HMCID          ReadCase3,ReadCase3,ReadCase3    Transaction
149
150
151Fail To Release Lock For Another Session
152    [Documentation]  Failed to release locks from another session.
153    [Tags]  Fail_To_Release_Lock_For_Another_Session
154    [Template]  Verify Fail To Release Lock For Another Session
155
156    # client_id          lock_type
157    HMCID-01,HMCID-02    ReadCase1,ReadCase1
158
159
160Test Invalid Resource ID Data Type Locking
161    [Documentation]  Failed to acquire lock for invalid resource id data type.
162    [Tags]  Test_Invalid_Resource_ID_Data_Type_Locking
163    [Template]  Verify Fail To Acquire Lock For Invalid Resource ID Data Type
164
165    # client_id    lock_type
166    HMCID-01       ReadCase1
167    HMCID-01       ReadCase2
168    HMCID-01       ReadCase3
169    HMCID-01       WriteCase1
170    HMCID-01       WriteCase2
171    HMCID-01       WriteCase3
172
173
174Fail To Acquire Lock For Invalid Lock Type
175    [Documentation]  Failed to acquire read, write lock for invalid lock data passed.
176    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Type
177    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
178
179    # client_id    lock_type      message
180    HMCID-01       ReadCase1      ${BAD_REQUEST}
181    HMCID-01       ReadCase2      ${BAD_REQUEST}
182    HMCID-01       ReadCase3      ${BAD_REQUEST}
183    HMCID-01       ReadCase4      ${BAD_REQUEST}
184    HMCID-01       ReadCase5      ${BAD_REQUEST}
185    HMCID-01       WriteCase1     ${BAD_REQUEST}
186    HMCID-01       WriteCase2     ${BAD_REQUEST}
187    HMCID-01       WriteCase3     ${BAD_REQUEST}
188    HMCID-01       WriteCase4     ${BAD_REQUEST}
189    HMCID-01       WriteCase5     ${BAD_REQUEST}
190
191
192Fail To Acquire Lock For Invalid Lock Flag
193    [Documentation]  Failed to acquire read write lock for invalid lock flag passed.
194    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
195    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
196
197    # client_id    lock_type       message
198    HMCID-01       ReadCase6       ${BAD_REQUEST}
199    HMCID-01       ReadCase7       ${BAD_REQUEST}
200    HMCID-01       ReadCase8       ${BAD_REQUEST}
201    HMCID-01       ReadCase9       ${BAD_REQUEST}
202    HMCID-01       ReadCase10      ${BAD_REQUEST}
203    HMCID-01       ReadCase11      ${BAD_REQUEST}
204    HMCID-01       WriteCase6      ${BAD_REQUEST}
205    HMCID-01       WriteCase7      ${BAD_REQUEST}
206    HMCID-01       WriteCase8      ${BAD_REQUEST}
207    HMCID-01       WriteCase9      ${BAD_REQUEST}
208    HMCID-01       WriteCase10     ${BAD_REQUEST}
209    HMCID-01       WriteCase11     ${BAD_REQUEST}
210
211
212Fail To Acquire Lock For Invalid Segment Flag
213    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
214    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Flag
215    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
216
217    # client_id    lock_type       message
218    HMCID-01       ReadCase12      ${BAD_REQUEST}
219    HMCID-01       ReadCase13      ${BAD_REQUEST}
220    HMCID-01       ReadCase14      ${BAD_REQUEST}
221    HMCID-01       WriteCase12     ${BAD_REQUEST}
222    HMCID-01       WriteCase13     ${BAD_REQUEST}
223    HMCID-01       WriteCase14     ${BAD_REQUEST}
224
225
226Fail To Acquire Lock For Invalid Segment Data Type Flag
227    [Documentation]  Failed to acquire read write lock for invalid segment flag passed.
228    [Tags]  Fail_To_Acquire_Lock_For_Invalid_Segment_Data_Type_Flag
229    [Template]  Verify Fail To Acquire Lock For Invalid Lock Data
230
231    # client_id    lock_type       message
232    HMCID-01       ReadCase15      ${EMPTY}
233    HMCID-01       ReadCase16      ${EMPTY}
234    HMCID-01       ReadCase17      ${EMPTY}
235    HMCID-01       ReadCase18      ${EMPTY}
236    HMCID-01       WriteCase15     ${EMPTY}
237    HMCID-01       WriteCase16     ${EMPTY}
238    HMCID-01       WriteCase17     ${EMPTY}
239    HMCID-01       WriteCase18     ${EMPTY}
240
241
242Get Empty Lock Records For Session Where No Locks Acquired
243    [Documentation]  If session does not acquire locks then get lock should return
244    ...              empty lock records.
245    [Tags]  Get_Empty_Lock_Records_For_Session_Where_No_Locks_Acquired
246    [Template]  Verify No Locks Records For Session With No Acquired Lock
247
248    # client_id
249    HMCID-01
250
251
252Get Lock Records Empty For Invalid Session
253    [Documentation]  Record of lock list is empty for invalid session.
254    [Tags]  Get_Lock_Records_Empty_For_Invalid_Session
255    [Template]  Verify Empty Lock Records For Invalid Session
256
257    # client_id
258    HMCID-01
259
260
261Get Lock Records For Multiple Session
262    [Documentation]  Get lock records of multiple session.
263    [Tags]  Get_Lock_Records_For_Multiple_Session
264    [Template]  Verify Lock Records Of Multiple Session
265
266    # client_ids         lock_type
267    HMCID-01,HMCID-02    ReadCase1,ReadCase1
268
269
270Get Lock Records For Multiple Invalid Session
271    [Documentation]  Record of lock list is empty for list of invalid session.
272    [Tags]  Get_Lock_Records_For_Multiple_Invalid_Session
273    [Template]  Verify Lock Records For Multiple Invalid Session
274
275    # client_id
276    HMCID-01
277
278
279Get Lock Records For Multiple Invalid And Valid Session
280    [Documentation]  Get record of lock from invalid and valid session.
281    [Tags]  Get_Lock_Records_For_Multiple_Invalid_And_Valid_Session
282    [Template]  Verify Lock Records For Multiple Invalid And Valid Session
283
284    # client_id          lock_type
285    HMCID-01,HMCID-02    ReadCase1
286
287*** Keywords ***
288
289Create Redfish Session With ClientID
290    [Documentation]  Create redifish session with client id.
291    [Arguments]  ${client_id}
292
293    # Description of argument(s):
294    # client_id    This client id can contain string value
295    #              (e.g. 12345, "HMCID").
296
297    ${session_info}=  Create Dictionary
298    ${session}=  Redfish Login  kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
299
300    Set To Dictionary  ${session_info}  SessionIDs  ${session['Id']}
301    Set To Dictionary  ${session_info}  ClientID  ${session["Oem"]["OpenBMC"]["ClientID"]}
302
303    [Return]  ${session_info}
304
305
306RW General Dictionary
307    [Documentation]  Create dictionary of lock request.
308    [Arguments]  ${read_case}  ${res_id}
309
310    # Description of argument(s):
311    # read_case    Read or Write lock type.
312    # res_id       Resource id.
313
314    ${request_dict}=  Create Dictionary
315
316    FOR  ${key}  IN  @{read_case.keys()}
317      Set To Dictionary  ${request_dict}  LockType  ${key}
318      Set To Dictionary  ${request_dict}  SegmentFlags  ${read_case["${key}"]}
319    END
320
321    Set To Dictionary  ${request_dict}  ResourceID  ${res_id}
322
323    [Return]  ${request_dict}
324
325
326Return Description Of Response
327    [Documentation]  Return description of REST response.
328    [Arguments]  ${resp_text}
329
330    # Description of argument(s):
331    # resp_text    REST response body.
332
333    # resp_text after successful partition file upload looks like:
334    # {
335    #    "Description": "File Created"
336    # }
337
338    ${message}=  Evaluate  json.loads('''${resp_text}''')  json
339
340    [Return]  ${message}
341
342
343Verify Redfish Session Deleted
344    [Documentation]  Verify the redfish session is deleted.
345    [Arguments]  ${session_info}
346
347    # Description of argument(s):
348    # session_info    Session information are stored in dictionary.
349
350    # ${session_info} = {
351    #     'SessionIDs': 'XXXXXXXXX',
352    #     'ClientID': 'XXXXXX',
353    #     'SessionToken': 'XXXXXXXXX',
354    #     'SessionResp': session response from redfish login
355    # }
356
357    # SessionIDs   : Session IDs
358    # ClientID     : Client ID
359    # SessionToken : Session token
360    # SessionResp  : Response of creating an redfish login session
361
362    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions
363
364    FOR  ${session}  IN  @{sessions['Members']}
365      Should Not Be Equal As Strings  session  ['/redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}']
366    END
367
368
369Verify Redfish List Of Session Deleted
370    [Documentation]  Verify all the list of redfish session is deleted.
371    [Arguments]  ${session_info_list}
372
373    # Description of argument(s):
374    # session_info_list    List contains individual session record are stored in dictionary.
375
376    # ${session_info_list} = [{
377    #     'SessionIDs': 'XXXXXXXXX',
378    #     'ClientID': 'XXXXXX',
379    #     'SessionToken': 'XXXXXXXXX',
380    #     'SessionResp': session response from redfish login
381    # }]
382
383    # SessionIDs   : Session IDs
384    # ClientID     : Client ID
385    # SessionToken : Session token
386    # SessionResp  : Response of creating an redfish login session
387
388    FOR  ${session_record}  IN  @{session_info_list}
389      Verify Redfish Session Deleted  ${session_record}
390    END
391
392
393Redfish Post Acquire Lock
394    [Documentation]  Acquire and release lock.
395    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
396
397    # Description of argument(s):
398    # lock_type      Read lock or Write lock.
399    # status_code    HTTP status code.
400
401    ${lock_dict_param}=  Form Data To Acquire Lock  ${lock_type}
402    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
403    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
404
405    Run Keyword If  ${status_code} == ${HTTP_BAD_REQUEST}
406    ...    Valid Value  ${BAD_REQUEST}  ['${resp.content}']
407    ...  ELSE
408    ...    Run Keyword And Return  Return Description Of Response  ${resp.content}
409
410    [Return]  ${resp}
411
412
413Redfish Post Acquire List Lock
414    [Documentation]  Acquire and release lock.
415    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
416
417    # Description of argument(s):
418    # lock_type      Read lock or Write lock.
419    # status_code    HTTP status code.
420
421    ${lock_dict_param}=  Create Data To Acquire List Of Lock  ${lock_type}
422    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
423    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
424
425    [Return]  ${resp}
426
427
428Redfish Post Acquire Invalid Lock
429    [Documentation]  Redfish to post request to acquire in-valid lock.
430    [Arguments]  ${lock_type}  ${message}  ${status_code}=${HTTP_OK}
431
432    # Description of argument(s):
433    # lock_type      Read lock or Write lock.
434    # message        Return message from URI.
435    # status_code    HTTP status code.
436
437    ${lock_dict_param}=  Form Data To Acquire Invalid Lock  ${lock_type}
438    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
439    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
440    Run Keyword If  '${message}' != '${EMPTY}'
441    ...  Valid Value  message  ['${resp.content}']
442
443    [Return]  ${resp}
444
445
446Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
447    [Documentation]  Redfish to post request to acquire in-valid lock with invalid data type of resource id.
448    [Arguments]  ${lock_type}  ${status_code}=${HTTP_OK}
449
450    # Description of argument(s):
451    # lock_type      Read lock or Write lock.
452    # status_code    HTTP status code.
453
454    ${lock_dict_param}=  Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID  ${lock_type}
455    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock  data=${lock_dict_param}
456    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
457
458    [Return]  ${resp}
459
460
461Form Data To Acquire Lock
462    [Documentation]  Create a dictionary for lock request.
463    [Arguments]  ${lock_type}
464
465    # Description of argument(s):
466    # lock_type      Read lock or Write lock.
467
468    ${lock_res_info}=  Get Lock Resource Information
469    ${resp}=  RW General Dictionary
470    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
471    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
472    ${temp_list}=  Create List  ${resp}
473    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
474
475    [Return]  ${lock_request_dict}
476
477
478Create Data To Acquire List Of Lock
479    [Documentation]  Create a dictionary for list of lock request.
480    [Arguments]  ${lock_type_list}
481
482    # Description of argument(s):
483    # lock_type      Read lock or Write lock.
484
485    ${temp_list}=  Create List
486    ${lock_res_info}=  Get Lock Resource Information
487
488    FOR  ${lock_type}  IN  @{lock_type_list}
489      ${resp}=  RW General Dictionary
490      ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
491      ...    ${lock_res_info["Valid Case"]["ResourceID"]}
492      Append To List  ${temp_list}  ${resp}
493    END
494
495    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
496
497    [Return]  ${lock_request_dict}
498
499
500Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
501    [Documentation]  Create a dictionary for in-valid lock request.
502    [Arguments]  ${lock_type}
503
504    # Description of argument(s):
505    # lock_type      Read lock or Write lock.
506
507    ${lock_res_info}=  Get Lock Resource Information
508    ${resp}=  RW General Dictionary
509    ...    ${lock_res_info["Valid Case"]["${lock_type}"]}
510    ...    ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
511    ${temp_list}=  Create List  ${resp}
512    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
513
514    [Return]  ${lock_request_dict}
515
516
517Form Data To Acquire Invalid Lock
518    [Documentation]  Create a dictionary for in-valid lock request.
519    [Arguments]  ${lock_type}
520
521    # Description of argument(s):
522    # lock_type      Read lock or Write lock.
523
524    ${lock_res_info}=  Get Lock Resource Information
525    ${resp}=  RW General Dictionary
526    ...    ${lock_res_info["Invalid Case"]["${lock_type}"]}
527    ...    ${lock_res_info["Valid Case"]["ResourceID"]}
528    ${temp_list}=  Create List  ${resp}
529    ${lock_request_dict}=  Create Dictionary  Request=${temp_list}
530
531    [Return]  ${lock_request_dict}
532
533
534Get Locks List On Resource
535    [Documentation]  Get locks list.
536    [Arguments]  ${session_info}  ${exp_status_code}=${HTTP_OK}
537
538    # Description of argument(s):
539    # session_info       Session information in dict.
540    # exp_status_code    Expected HTTP status code.
541
542    ${data}=  Set Variable  {"SessionIDs": ["${session_info['SessionIDs']}"]}
543    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
544    ...  data=${data}
545    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
546
547    [Return]  ${locks["Records"]}
548
549
550Verify Lock On Resource
551    [Documentation]  Verify lock on resource.
552    [Arguments]  ${session_info}  ${transaction_id}
553
554    # Description of argument(s):
555    # session_info      Session information in dict.
556    # transaction_id    Transaction id in list stored in dict.
557
558    ${sessions}=  Redfish.Get Properties  /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
559    Rprint Vars  sessions
560    ${lock_list}=  Get Locks List On Resource  ${session_info}
561    ${lock_length}=  Get Length  ${lock_list}
562    ${tran_id_length}=  Get Length  ${transaction_id}
563    Should Be Equal As Integers  ${tran_id_length}  ${lock_length}
564
565    FOR  ${tran_id}  ${lock}  IN ZIP  ${transaction_id}  ${lock_list}
566      Valid Value  session_info['ClientID']  ['${lock['HMCID']}']
567      Valid Value  session_info['SessionIDs']  ['${lock['SessionID']}']
568      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock['TransactionID']}
569    END
570
571
572Acquire Lock On Resource
573    [Documentation]  Acquire lock on resource.
574    [Arguments]  ${client_id}  ${lock_type}  ${reboot_flag}=False
575
576    # Description of argument(s):
577    # client_id    This client id can contain string value
578    #              (e.g. 12345, "HMCID").
579    # lock_type    Read lock or Write lock.
580    # reboot_flag  Flag is used to run reboot the BMC code.
581    #               (e.g. True or False).
582
583    ${trans_id_list}=  Create List
584    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
585    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
586    Append To List  ${trans_id_list}  ${trans_id}
587    Verify Lock On Resource  ${session_info}  ${trans_id_list}
588
589    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
590
591    Run Keyword If  '${reboot_flag}' == 'True'
592    ...  Run Keywords  Redfish OBMC Reboot (off)  AND
593    ...  Redfish Login  AND
594    ...  Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}  AND
595    ...  Verify Lock On Resource  ${session_info}  ${trans_id_list}  AND
596    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
597
598    Run Keyword If  '${reboot_flag}' == 'False'
599    ...  Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
600
601    ${trans_id_emptylist}=  Create List
602    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
603    Redfish Delete Session  ${session_info}
604
605
606Form Data To Release Lock
607    [Documentation]  Create a dictonay to release lock.
608    [Arguments]  ${trans_id_list}
609
610    # Description of argument(s):
611    # trans_id_list
612
613    @{tran_ids}=  Create List
614
615    FOR  ${item}  IN  @{trans_id_list}
616      Append To List  ${tran_ids}  ${item['TransactionID']}
617    END
618
619    [Return]  ${tran_ids}
620
621
622Release Locks On Resource
623    [Documentation]  Redfish request to release a lock.
624    [Arguments]  ${session_info}  ${trans_id_list}  ${release_lock_type}=Transaction  ${status_code}=${HTTP_OK}
625
626    # Description of argument(s):
627    # session_info        Session information in dict.
628    # trans_id_list       Transaction id list.
629    # release_lock_type   Release lock by Transaction, Session.
630    # status_code         HTTP status code.
631
632    ${tran_ids}=  Form Data To Release Lock  ${trans_id_list}
633    ${data}=  Set Variable  {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
634    ${data}=  Evaluate  json.dumps(${data})  json
635    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock  data=${data}
636    Should Be Equal As Strings  ${resp.status_code}  ${status_code}
637
638
639Release locks And Delete Session
640    [Documentation]  Release locks and delete redfish session.
641    [Arguments]  ${session_info}  ${trans_id_list}
642
643    Release Locks On Resource  ${session_info}  ${trans_id_list}
644
645    ${trans_id_emptylist}=  Create List
646    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
647
648    Redfish Delete Session  ${session_info}
649
650
651Acquire Lock On Another Lock
652    [Documentation]  Acquire lock on another lock.
653    [Arguments]  ${client_id}
654
655    # Description of argument(s):
656    # client_id    This client id can contain string value
657    #              (e.g. 12345, "HMCID").
658
659    ${trans_id_list}=  Create List
660    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
661
662    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
663    Append To List  ${trans_id_list}  ${trans_id}
664
665    ${trans_id}=  Redfish Post Acquire Lock  ReadCase1
666    Append To List  ${trans_id_list}  ${trans_id}
667
668    Verify Lock On Resource  ${session_info}  ${trans_id_list}
669
670    Release locks And Delete Session  ${session_info}  ${trans_id_list}
671
672
673Verify Fail To Acquire Read And Write In Single Request
674    [Documentation]  Verify fail to acquire read and write lock passed in single request.
675    [Arguments]  ${client_id}  ${lock_type}
676
677    # Description of argument(s):
678    # client_id    This client id can contain string value
679    #              (e.g. 12345, "HMCID").
680    # lock_type    Read lock or Write lock.
681
682    ${lock_type_list}=  Split String  ${lock_type}  ,
683
684    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
685    ${trans_id}=  Redfish Post Acquire List Lock  ${lock_type_list}  status_code=${HTTP_BAD_REQUEST}
686    Redfish Delete Session  ${session_info}
687
688
689Verify Empty Lock Records For Invalid Session
690    [Documentation]  Verify no lock record found for invalid session.
691    [Arguments]  ${client_id}
692
693    # Description of argument(s):
694    # client_id    This client id can contain string value
695    #              (e.g. 12345, "HMCID").
696
697    ${session_info1}=  Create Redfish Session With ClientID  ${client_id}
698
699    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
700    ${lock_length1}=  Get Length  ${lock_list1}
701
702    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
703    set to dictionary  ${session_info2}  SessionIDs  xxyXyyYZZz
704
705    ${lock_list2}=  Get Locks List On Resource  ${session_info2}
706    ${lock_length2}=  Get Length  ${lock_list2}
707
708    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
709
710    Redfish Delete Session  ${session_info1}
711
712
713Verify Acquire Lock Fails On Another Lock
714    [Documentation]  Verify acquire lock on another lock fails.
715    [Arguments]  ${client_id}  ${lock_type}
716
717    # Description of argument(s):
718    # client_id    This client id can contain string value
719    #              (e.g. 12345, "HMCID").
720    # lock_type    Read lock or Write lock.
721
722    @{lock_type_list}=  Split String  ${lock_type}  ,
723    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
724    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
725
726    ${trans_id_list}=  Create List
727    Append To List  ${trans_id_list}  ${trans_id}
728
729    Verify Lock On Resource  ${session_info}  ${trans_id_list}
730    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
731
732    Release locks And Delete Session  ${session_info}  ${trans_id_list}
733
734
735Verify Acquire Lock After Reboot
736    [Documentation]  Acquire read and write lock after the reboot and release lock.
737    [Arguments]  ${client_id}  ${lock_type}
738
739    # Description of argument(s):
740    # client_id    This client id can contain string value
741    #              (e.g. 12345, "HMCID").
742    # lock_type    Read lock or Write lock.
743
744    ${trans_id_list}=  Create List
745    ${session_info}=  Create Session With ClientID  ${client_id}
746    ${before_reboot_xauth_token}=  Set Variable  ${XAUTH_TOKEN}
747    Redfish OBMC Reboot (off)
748    Redfish Login
749    Set Global Variable  ${XAUTH_TOKEN}  ${before_reboot_xauth_token}
750
751    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
752    Append To List  ${trans_id_list}  ${trans_id}
753    Verify Lock On Resource  ${session_info}  ${trans_id_list}
754
755    Release locks And Delete Session  ${session_info}  ${trans_id_list}
756
757
758Verify Acquire Multiple Lock Request At CEC Level
759    [Documentation]  Acquire lock in loop.
760    [Arguments]  ${client_id}  ${lock_type}
761
762    # Description of argument(s):
763    # client_id    This client id can contain string value
764    #              (e.g. 12345, "HMCID").
765    # lock_type    Read lock or Write lock.
766
767    ${trans_id_list}=  Create List
768    @{lock_type_list}=  Split String  ${lock_type}  ,
769    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
770
771    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
772    Append To List  ${trans_id_list}  ${trans_id}
773
774    Verify Lock On Resource  ${session_info}  ${trans_id_list}
775
776    Redfish Post Acquire Lock  ${lock_type_list}[1]  status_code=${HTTP_CONFLICT}
777
778    Release locks And Delete Session  ${session_info}  ${trans_id_list}
779
780
781Verify Acquire And Release Lock In Loop
782    [Documentation]  Acquire lock in loop.
783    [Arguments]  ${client_id}  ${lock_type}
784
785    # Description of argument(s):
786    # client_id    This client id can contain string value
787    #              (e.g. 12345, "HMCID").
788    # lock_type    Read lock or Write lock.
789
790    FOR  ${count}  IN RANGE  1  11
791      ${trans_id_list}=  Create List
792      ${session_info}=  Create Redfish Session With ClientID  ${client_id}
793      ${trans_id}=  Redfish Post Acquire Lock  ${lock_type}
794      Append To List  ${trans_id_list}  ${trans_id}
795      Verify Lock On Resource  ${session_info}  ${trans_id_list}
796      Release Locks On Resource  ${session_info}  ${trans_id_list}  Transaction  ${HTTP_OK}
797      ${trans_id_emptylist}=  Create List
798      Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
799    END
800
801    Redfish Delete Session  ${session_info}
802
803
804Acquire And Release Multiple Locks
805    [Documentation]  Acquire mutilple locks on resource.
806    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
807
808    # Description of argument(s):
809    # client_id          This client id can contain string value
810    #                    (e.g. 12345, "HMCID").
811    # lock_type          Read lock or Write lock.
812    # release_lock_type  The value can be Transaction or Session.
813
814    @{lock_type_list}=  Split String  ${lock_type}  ,
815    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
816    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
817
818    ${trans_id_list}=  Create List
819
820    Append To List  ${trans_id_list}  ${trans_id}
821    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
822
823    Append To List  ${trans_id_list}  ${trans_id}
824    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
825
826    Append To List  ${trans_id_list}  ${trans_id}
827    Verify Lock On Resource  ${session_info}  ${trans_id_list}
828    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=${release_lock_type}
829
830    ${trans_id_emptylist}=  Create List
831    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
832    Redfish Delete Session  ${session_info}
833
834
835Verify Fail To Release Lock With Invalid TransactionID
836    [Documentation]  Verify fail to be release lock with invalid transaction ID.
837    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
838
839    # Description of argument(s):
840    # client_id          This client id can contain string value
841    #                    (e.g. 12345, "HMCID").
842    # lock_type          Read lock or Write lock.
843    # release_lock_type  The value can be Transaction or Session.
844
845    ${trans_id_list}=  Create List
846    @{lock_type_list}=  Split String  ${lock_type}  ,
847
848    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
849
850    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
851    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
852    ${value}=  Evaluate  ${value} + 10
853    Set To Dictionary  ${trans_id}  TransactionID  ${value}
854    Append To List  ${trans_id_list}  ${trans_id}
855
856    Release Locks On Resource
857    ...  ${session_info}  ${trans_id_list}
858    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
859    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
860
861    ${trans_id_emptylist}=  Create List
862    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
863    Redfish Delete Session  ${session_info}
864
865
866Verify Fail To Release Multiple Lock With Invalid TransactionID
867    [Documentation]  Verify release multiple locks with invalid transaction ID fails.
868    [Arguments]  ${client_id}  ${lock_type}  ${release_lock_type}
869
870    # Description of argument(s):
871    # client_id          This client id can contain string value
872    #                    (e.g. 12345, "HMCID").
873    # lock_type          Read lock or Write lock.
874    # release_lock_type  The value can be Transaction or Session.
875
876    ${trans_id_list}=  Create List
877    @{lock_type_list}=  Split String  ${lock_type}  ,
878
879    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
880
881    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
882    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
883    ${value}=  Evaluate  ${value} + 10
884    Set To Dictionary  ${trans_id}  TransactionID  ${value}
885    Append To List  ${trans_id_list}  ${trans_id}
886
887    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
888    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
889    ${value}=  Evaluate  ${value} + 10
890    Set To Dictionary  ${trans_id}  TransactionID  ${value}
891    Append To List  ${trans_id_list}  ${trans_id}
892
893    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[2]
894    ${value}=  Get From Dictionary  ${trans_id}  TransactionID
895    ${value}=  Evaluate  ${value} + 10
896    Set To Dictionary  ${trans_id}  TransactionID  ${value}
897    Append To List  ${trans_id_list}  ${trans_id}
898
899    Release Locks On Resource
900    ...  ${session_info}  ${trans_id_list}
901    ...  release_lock_type=${release_lock_type}  status_code=${HTTP_BAD_REQUEST}
902    Release Locks On Resource  ${session_info}  ${trans_id_list}  release_lock_type=Session
903
904    ${trans_id_emptylist}=  Create List
905    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
906    Redfish Delete Session  ${session_info}
907
908
909Verify Fail To Release Lock For Another Session
910    [Documentation]  Verify failed to release the lock form another session.
911    [Arguments]  ${client_id}  ${lock_type}
912
913    # Description of argument(s):
914    # client_id    This client id can contain string value
915    #              (e.g. 12345, "HMCID").
916    # lock_type    Read lock or Write lock.
917
918    ${client_ids}=  Split String  ${client_id}  ,
919    ${lock_type_list}=  Split String  ${lock_type}  ,
920    ${trans_id_list1}=  Create List
921    ${trans_id_list2}=  Create List
922
923    ${session_info1}=  Create Redfish Session With ClientID  ${client_ids}[0]
924
925    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
926    Append To List  ${trans_id_list1}  ${trans_id}
927    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
928
929    ${session_info2}=  Create Redfish Session With ClientID  ${client_ids}[1]
930    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
931    Append To List  ${trans_id_list2}  ${trans_id}
932    Verify Lock On Resource  ${session_info2}  ${trans_id_list2}
933
934    Release Locks On Resource
935    ...  ${session_info1}  ${trans_id_list1}  Transaction  status_code=${HTTP_UNAUTHORIZED}
936    Verify Lock On Resource  ${session_info1}  ${trans_id_list1}
937    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Session
938    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Session
939    Redfish Delete Session  ${session_info1}
940    Redfish Delete Session  ${session_info2}
941
942
943Verify Fail To Acquire Lock For Invalid Resource ID Data Type
944    [Documentation]  Verify fail to acquire the lock with invalid resource id data type.
945    [Arguments]  ${client_id}  ${lock_type}
946
947    # Description of argument(s):
948    # client_id    This client id can contain string value
949    #              (e.g. 12345, "HMCID").
950    # lock_type    Read lock or Write lock.
951
952    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
953    Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
954    ...  ${lock_type}  status_code=${HTTP_BAD_REQUEST}
955    Redfish Delete Session  ${session_info}
956
957
958Verify Fail To Acquire Lock For Invalid Lock Data
959    [Documentation]  Verify fail to acquired lock with invalid lock types, lock flags, segment flags.
960    [Arguments]  ${client_id}  ${lock_type}  ${message}
961
962    # Description of argument(s):
963    # client_id    This client id can contain string value
964    #              (e.g. 12345, "HMCID").
965    # lock_type    Read lock or Write lock.
966    # message      Return message from URI.
967
968    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
969    ${trans_id}=  Redfish Post Acquire Invalid Lock  ${lock_type}  message=${message}  status_code=${HTTP_BAD_REQUEST}
970    Redfish Delete Session  ${session_info}
971
972
973Verify No Locks Records For Session With No Acquired Lock
974    [Documentation]  Verify no records found for a session where no lock is acquired.
975    [Arguments]  ${client_id}
976
977    # Description of argument(s):
978    # client_id    This client id can contain string value
979    #              (e.g. 12345, "HMCID").
980
981    ${session_info}=  Create Redfish Session With ClientID  ${client_id}
982    ${trans_id_emptylist}=  Create List
983    Verify Lock On Resource  ${session_info}  ${trans_id_emptylist}
984    Redfish Delete Session  ${session_info}
985
986
987Create List Of Session ID
988    [Documentation]  Create session id list from session dict info.
989    [Arguments]  ${session_dict_info}
990
991    # Description of argument(s):
992    # session_dict_info      Session information in dict.
993
994    @{session_id_list}=  Create List
995
996    FOR  ${session}  IN  @{session_dict_info}
997      Append To List  ${session_id_list}  ${session["SessionIDs"]}
998    END
999
1000    ${num_id}=  Get Length  ${session_id_list}
1001    Should Not Be Equal As Integers  ${num_id}  ${0}
1002
1003    ${session_id_list}=  Evaluate  json.dumps(${session_id_list})  json
1004
1005    [Return]  ${session_id_list}
1006
1007
1008Get Locks List On Resource With Session List
1009    [Documentation]  Get locks list from session of list.
1010    [Arguments]  ${session_id_list}  ${exp_status_code}=${HTTP_OK}
1011
1012    # Description of argument(s):
1013    # session_id_list    Session ids list.
1014    # exp_status_code    Expected HTTP status code.
1015
1016    ${resp}=  Redfish Post Request  /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
1017    ...  data={"SessionIDs": ${session_id_list}}
1018    ${locks}=  Evaluate  json.loads('''${resp.text}''')  json
1019
1020    [Return]  ${locks}
1021
1022
1023Verify List Of Session Lock On Resource
1024    [Documentation]  Verify list of lock record from list of sessions.
1025    [Arguments]  ${session_dict_info}  ${transaction_id_list}
1026
1027    # Description of argument(s):
1028    # session_dict_info      Session information in dict.
1029    # transaction_id_list    Transaction id in list stored in dict.
1030
1031    ${session_id_list}=  Create List Of Session ID  ${session_dict_info}
1032    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1033    ${lock_list}=  Set Variable  ${lock_list_resp['Records']}
1034
1035    FOR  ${session_id}  ${tran_id}  ${lock_record}  IN ZIP  ${session_dict_info}  ${transaction_id_list}  ${lock_list}
1036      Valid Value  session_id['SessionIDs']  ['${lock_record['SessionID']}']
1037      Should Be Equal As Integers  ${tran_id['TransactionID']}  ${lock_record['TransactionID']}
1038    END
1039
1040
1041Verify Lock Records Of Multiple Session
1042    [Documentation]  Verify all records found for a multiple sessions.
1043    [Arguments]  ${client_ids}  ${lock_type}
1044
1045    # Description of argument(s):
1046    # client_ids    This client id can contain string value
1047    #               (e.g. 12345, "HMCID").
1048    # lock_type     Read lock or Write lock.
1049
1050    ${client_id_list}=  Split String  ${client_ids}  ,
1051    ${lock_type_list}=  Split String  ${lock_type}  ,
1052    ${trans_id_list1}=  Create List
1053    ${trans_id_list2}=  Create List
1054
1055    ${session_dict_list}=  Create List
1056    ${lock_list}=  Create List
1057
1058    ${client_id1}=  Create List
1059    Append To List  ${client_id1}  ${client_id_list}[0]
1060    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
1061    Append To List  ${session_dict_list}  ${session_info1}[0]
1062    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
1063
1064    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1065    Append To List  ${trans_id_list1}  ${trans_id}
1066    Append To List  ${lock_list}  ${trans_id}
1067    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
1068
1069
1070    ${client_id2}=  Create List
1071    Append To List  ${client_id2}  ${client_id_list}[1]
1072    ${session_info2}=  Create Session With List Of ClientID  ${client_id2}
1073    Append To List  ${session_dict_list}  ${session_info2}[0]
1074    Verify A Session Created With ClientID  ${client_id2}  ${session_info2}
1075
1076    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[1]
1077    Append To List  ${trans_id_list2}  ${trans_id}
1078    Append To List  ${lock_list}  ${trans_id}
1079    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_list2}
1080
1081    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
1082
1083    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
1084    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1085
1086    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
1087
1088    ${session_token}=  Get From Dictionary  ${session_info2}[0]  SessionToken
1089    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1090
1091    Release Locks On Resource  ${session_info2}  ${trans_id_list2}  release_lock_type=Transaction
1092
1093    ${trans_id_emptylist}=  Create List
1094    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
1095    Verify Lock On Resource  ${session_info2}[0]  ${trans_id_emptylist}
1096
1097    Redfish Delete List Of Session  ${session_dict_list}
1098
1099
1100Verify Lock Records For Multiple Invalid Session
1101    [Documentation]  Verify no lock record found for multiple invalid session.
1102    [Arguments]  ${client_id}
1103
1104    # Description of argument(s):
1105    # client_id    This client id can contain string value
1106    #              (e.g. 12345, "HMCID").
1107
1108    ${session_dict_list}=  Create List
1109    ${invalid_session_ids}=  Create List  xxyXyyYZZz  xXyXYyYZzz
1110
1111    ${session_info1}=  Create Session With ClientID  ${client_id}
1112
1113    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
1114    set to dictionary  ${session_info2}  SessionIDs  ${invalid_session_ids}[0]
1115    Append To List  ${session_dict_list}  ${session_info2}
1116
1117    ${session_info3}=  Copy Dictionary  ${session_info1}  deepcopy=True
1118    set to dictionary  ${session_info3}  SessionIDs  ${invalid_session_ids}[0]
1119    Append To List  ${session_dict_list}  ${session_info3}
1120
1121    ${lock_list1}=  Get Locks List On Resource  ${session_info1}
1122    ${lock_length1}=  Get Length  ${lock_list1}
1123
1124    ${session_id_list}=  Create List Of Session ID  ${session_dict_list}
1125    ${lock_list_resp}=  Get Locks List On Resource With Session List  ${session_id_list}
1126    ${lock_length2}=  Get Length  ${lock_list_resp['Records']}
1127
1128    Should Be Equal As Integers  ${lock_length1}  ${lock_length2}
1129
1130    Redfish Delete Session  ${session_info1}
1131
1132
1133Verify Lock Records For Multiple Invalid And Valid Session
1134    [Documentation]  Verify all records found for a valid and invalid sessions.
1135    [Arguments]  ${client_ids}  ${lock_type}
1136
1137    # Description of argument(s):
1138    # client_ids    This client id can contain string value
1139    #               (e.g. 12345, "HMCID").
1140    # lock_type     Read lock or Write lock.
1141
1142    ${client_id_list}=  Split String  ${client_ids}  ,
1143    ${lock_type_list}=  Split String  ${lock_type}  ,
1144    ${trans_id_list1}=  Create List
1145    ${invalid_session_ids}=  Create List  xxyXyyYZZz
1146
1147    ${session_dict_list}=  Create List
1148    ${lock_list}=  Create List
1149
1150    ${client_id1}=  Create List
1151    Append To List  ${client_id1}  ${client_id_list}[0]
1152    ${session_info1}=  Create Session With List Of ClientID  ${client_id1}
1153    Append To List  ${session_dict_list}  ${session_info1}[0]
1154    Verify A Session Created With ClientID  ${client_id1}  ${session_info1}
1155
1156    ${trans_id}=  Redfish Post Acquire Lock  ${lock_type_list}[0]
1157    Append To List  ${trans_id_list1}  ${trans_id}
1158    Append To List  ${lock_list}  ${trans_id}
1159    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_list1}
1160
1161    ${session_info2}=  Copy Dictionary  ${session_info1}  deepcopy=True
1162    set to dictionary  ${session_info2}[0]  SessionIDs  ${invalid_session_ids}[0]
1163    Append To List  ${session_dict_list}  ${session_info2}[0]
1164
1165    Verify List Of Session Lock On Resource  ${session_dict_list}  ${lock_list}
1166
1167    ${session_token}=  Get From Dictionary  ${session_info1}[0]  SessionToken
1168    Set Global Variable  ${XAUTH_TOKEN}  ${session_token}
1169
1170    Release Locks On Resource  ${session_info1}  ${trans_id_list1}  release_lock_type=Transaction
1171
1172    ${trans_id_emptylist}=  Create List
1173    Verify Lock On Resource  ${session_info1}[0]  ${trans_id_emptylist}
1174
1175    Redfish Delete Session  ${session_info1}[0]
1176