blob: 6db1281bf4231a06f17f067ec7b63a52b711593b [file] [log] [blame]
Vijaybc331e22020-02-27 04:17:37 -06001*** Settings ***
2
Sushil Singhd03f2ce2020-09-17 08:54:41 -05003Documentation Test lock management feature of management console on BMC.
Vijaybc331e22020-02-27 04:17:37 -06004
Sushil Singhd03f2ce2020-09-17 08:54:41 -05005Resource ../../lib/resource.robot
6Resource ../../lib/openbmc_ffdc.robot
7Resource ../../lib/bmc_redfish_utils.robot
8Resource ../../lib/external_intf/management_console_utils.robot
Sushil Singh977f8f52020-11-20 06:32:50 -06009Resource ../../lib/rest_response_code.robot
Sushil Singh728ef9c2020-10-28 04:25:39 -050010Library ../../lib/bmc_network_utils.py
Vijaybc331e22020-02-27 04:17:37 -060011
Sushil Singhd03f2ce2020-09-17 08:54:41 -050012Suite Setup Run Keyword And Ignore Error Delete All Redfish Sessions
Sushil Singhdf390b62021-01-19 00:50:05 -060013Suite Teardown Run Keyword And Ignore Error Delete All Redfish Sessions
Sushil Singhd03f2ce2020-09-17 08:54:41 -050014Test Setup Printn
15Test Teardown FFDC On Test Case Fail
Vijaybc331e22020-02-27 04:17:37 -060016
17*** Variables ***
18
Sushil Singhd03f2ce2020-09-17 08:54:41 -050019${BAD_REQUEST} Bad Request
Vijaybc331e22020-02-27 04:17:37 -060020
21*** Test Cases ***
22
Sushil Singhd03f2ce2020-09-17 08:54:41 -050023Acquire Read Write Lock
Vijaybc331e22020-02-27 04:17:37 -060024 [Documentation] Acquire and release different read locks.
Sushil Singhd03f2ce2020-09-17 08:54:41 -050025 [Tags] Acquire_Read_Write_Lock
26 [Template] Acquire Lock On Resource
Vijaybc331e22020-02-27 04:17:37 -060027
Sushil Singhd03f2ce2020-09-17 08:54:41 -050028 # 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
Vijaybc331e22020-02-27 04:17:37 -060035
36
Sushil Singhd03f2ce2020-09-17 08:54:41 -050037Check 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
Vijaybc331e22020-02-27 04:17:37 -060041
Sushil Singhd03f2ce2020-09-17 08:54:41 -050042 # 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
Vijaybc331e22020-02-27 04:17:37 -060049
50
Sushil Singhd03f2ce2020-09-17 08:54:41 -050051Acquire 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
Vijaybc331e22020-02-27 04:17:37 -060055
Sushil Singhd03f2ce2020-09-17 08:54:41 -050056 # client_id
57 HMCID-01
Vijaybc331e22020-02-27 04:17:37 -060058
59
Sushil Singhd03f2ce2020-09-17 08:54:41 -050060Fail 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
Vijay85610ee2020-04-03 05:30:28 -050064
Sushil Singhd03f2ce2020-09-17 08:54:41 -050065 # client_id lock_type
66 HMCID-01 ReadCase2,WriteCase2
67 HMCID-01 WriteCase2,WriteCase2
68 HMCID-01 WriteCase2,ReadCase2
George Keishing566daaf2020-07-02 06:18:50 -050069
70
Sushil Singhe33c6e62020-09-29 06:34:35 -050071Acquire 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
Sushil Singhd03f2ce2020-09-17 08:54:41 -050085Acquire 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
George Keishing566daaf2020-07-02 06:18:50 -050089
Sushil Singhd03f2ce2020-09-17 08:54:41 -050090 # 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
Vijay85610ee2020-04-03 05:30:28 -050097
98
Sushil Singh977f8f52020-11-20 06:32:50 -060099Fail 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
Sushil Singhdf390b62021-01-19 00:50:05 -0600109Acquire 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
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500121Verify Release Of Valid Locks
122 [Documentation] Release all valid locks.
123 [Tags] Verify_Release_Of_Valid_Locks
124 [Template] Acquire And Release Multiple Locks
Vijayafdd2a12020-04-09 02:03:20 -0500125
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500126 # client_id lock_type release_lock_type
127 HMCID-01 ReadCase1,ReadCase1,ReadCase1 Transaction
128 HMCID-02 ReadCase1,ReadCase1,ReadCase1 Session
Vijayafdd2a12020-04-09 02:03:20 -0500129
130
Sushil Singh59011d02021-01-27 23:00:20 -0600131Fail 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
Sushil Singh1b590532021-01-20 05:13:54 -0600140Fail To Release Multiple Lock With Invalid TransactionID
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500141 [Documentation] Release in-valid lock result in fail.
Sushil Singh1b590532021-01-20 05:13:54 -0600142 [Tags] Fail_To_Release_Multiple_Lock_With_Invalid_TransactionID
143 [Template] Verify Fail To Release Multiple Lock With Invalid TransactionID
Vijayafdd2a12020-04-09 02:03:20 -0500144
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500145 # 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
Vijayafdd2a12020-04-09 02:03:20 -0500149
150
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500151Fail 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
Vijayafdd2a12020-04-09 02:03:20 -0500155
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500156 # client_id lock_type
157 HMCID-01,HMCID-02 ReadCase1,ReadCase1
Vijayafdd2a12020-04-09 02:03:20 -0500158
159
Sushil Singhe33c6e62020-09-29 06:34:35 -0500160Test 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
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500174Fail 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
Vijayafdd2a12020-04-09 02:03:20 -0500178
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500179 # 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}
Vijayafdd2a12020-04-09 02:03:20 -0500190
Vijayafdd2a12020-04-09 02:03:20 -0500191
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500192Fail 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
Vijayafdd2a12020-04-09 02:03:20 -0500196
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500197 # 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}
Vijayafdd2a12020-04-09 02:03:20 -0500210
Vijayafdd2a12020-04-09 02:03:20 -0500211
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500212Fail 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}
Vijayafdd2a12020-04-09 02:03:20 -0500224
Sushil Singhbace3002020-10-08 08:12:58 -0500225
Sushil Singh3b3a7ec2020-11-23 03:54:06 -0600226Fail 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
Sushil Singhbace3002020-10-08 08:12:58 -0500242Get 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
Sushil Singh728ef9c2020-10-28 04:25:39 -0500251
Sushil Singhf9a536c2020-11-09 07:33:17 -0600252Get 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
Sushil Singh728ef9c2020-10-28 04:25:39 -0500261Get 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
Sushil Singhf9a536c2020-11-09 07:33:17 -0600270Get 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
Sushil Singh11949a22020-11-13 06:12:16 -0600278
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
Vijaybc331e22020-02-27 04:17:37 -0600287*** Keywords ***
288
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500289Create Redfish Session With ClientID
290 [Documentation] Create redifish session with client id.
291 [Arguments] ${client_id}
Vijay85610ee2020-04-03 05:30:28 -0500292
293 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500294 # client_id This client id can contain string value
295 # (e.g. 12345, "HMCID").
Vijay85610ee2020-04-03 05:30:28 -0500296
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500297 ${session_info}= Create Dictionary
298 ${session}= Redfish Login kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
Vijay85610ee2020-04-03 05:30:28 -0500299
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500300 Set To Dictionary ${session_info} SessionIDs ${session['Id']}
301 Set To Dictionary ${session_info} ClientID ${session["Oem"]["OpenBMC"]["ClientID"]}
Vijay85610ee2020-04-03 05:30:28 -0500302
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500303 [Return] ${session_info}
Vijay85610ee2020-04-03 05:30:28 -0500304
305
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500306RW General Dictionary
George Keishing16b3c7b2021-01-28 09:23:37 -0600307 [Documentation] Create dictionary of lock request.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500308 [Arguments] ${read_case} ${res_id}
Vijaybc331e22020-02-27 04:17:37 -0600309
310 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500311 # read_case Read or Write lock type.
312 # res_id Resource id.
Vijaybc331e22020-02-27 04:17:37 -0600313
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500314 ${request_dict}= Create Dictionary
George Keishing566daaf2020-07-02 06:18:50 -0500315
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500316 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
Vijaybc331e22020-02-27 04:17:37 -0600320
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500321 Set To Dictionary ${request_dict} ResourceID ${res_id}
322
323 [Return] ${request_dict}
Vijaybc331e22020-02-27 04:17:37 -0600324
325
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500326Return Description Of Response
327 [Documentation] Return description of REST response.
Vijaybc331e22020-02-27 04:17:37 -0600328 [Arguments] ${resp_text}
329
330 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500331 # resp_text REST response body.
Vijaybc331e22020-02-27 04:17:37 -0600332
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500333 # resp_text after successful partition file upload looks like:
334 # {
335 # "Description": "File Created"
336 # }
Vijaybc331e22020-02-27 04:17:37 -0600337
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500338 ${message}= Evaluate json.loads('''${resp_text}''') json
339
340 [Return] ${message}
Vijaybc331e22020-02-27 04:17:37 -0600341
342
Sushil Singha7d71f02020-11-02 05:24:22 -0600343Verify 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
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500393Redfish Post Acquire Lock
394 [Documentation] Acquire and release lock.
395 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600396
397 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500398 # lock_type Read lock or Write lock.
399 # status_code HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600400
Sushil Singhe33c6e62020-09-29 06:34:35 -0500401 ${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}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500403 Should Be Equal As Strings ${resp.status_code} ${status_code}
Sushil Singhdf390b62021-01-19 00:50:05 -0600404
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}
Vijaybc331e22020-02-27 04:17:37 -0600409
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500410 [Return] ${resp}
Vijaybc331e22020-02-27 04:17:37 -0600411
412
Sushil Singh977f8f52020-11-20 06:32:50 -0600413Redfish 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
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500428Redfish Post Acquire Invalid Lock
429 [Documentation] Redfish to post request to acquire in-valid lock.
430 [Arguments] ${lock_type} ${message} ${status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600431
432 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500433 # lock_type Read lock or Write lock.
434 # message Return message from URI.
435 # status_code HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600436
Sushil Singhe33c6e62020-09-29 06:34:35 -0500437 ${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}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500439 Should Be Equal As Strings ${resp.status_code} ${status_code}
Sushil Singh3b3a7ec2020-11-23 03:54:06 -0600440 Run Keyword If '${message}' != '${EMPTY}'
441 ... Valid Value message ['${resp.content}']
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500442
443 [Return] ${resp}
Vijaybc331e22020-02-27 04:17:37 -0600444
445
Sushil Singhe33c6e62020-09-29 06:34:35 -0500446Redfish 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
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500461Form Data To Acquire Lock
George Keishing16b3c7b2021-01-28 09:23:37 -0600462 [Documentation] Create a dictionary for lock request.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500463 [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}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500473 ${lock_request_dict}= Create Dictionary Request=${temp_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500474
Sushil Singhe33c6e62020-09-29 06:34:35 -0500475 [Return] ${lock_request_dict}
476
477
Sushil Singh977f8f52020-11-20 06:32:50 -0600478Create Data To Acquire List Of Lock
George Keishing16b3c7b2021-01-28 09:23:37 -0600479 [Documentation] Create a dictionary for list of lock request.
Sushil Singh977f8f52020-11-20 06:32:50 -0600480 [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
Sushil Singhe33c6e62020-09-29 06:34:35 -0500500Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
George Keishing16b3c7b2021-01-28 09:23:37 -0600501 [Documentation] Create a dictionary for in-valid lock request.
Sushil Singhe33c6e62020-09-29 06:34:35 -0500502 [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}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500515
516
517Form Data To Acquire Invalid Lock
George Keishing16b3c7b2021-01-28 09:23:37 -0600518 [Documentation] Create a dictionary for in-valid lock request.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500519 [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}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500529 ${lock_request_dict}= Create Dictionary Request=${temp_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500530
Sushil Singhe33c6e62020-09-29 06:34:35 -0500531 [Return] ${lock_request_dict}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500532
533
534Get Locks List On Resource
Vijaybc331e22020-02-27 04:17:37 -0600535 [Documentation] Get locks list.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500536 [Arguments] ${session_info} ${exp_status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600537
538 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500539 # session_info Session information in dict.
540 # exp_status_code Expected HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600541
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500542 ${data}= Set Variable {"SessionIDs": ["${session_info['SessionIDs']}"]}
George Keishing566daaf2020-07-02 06:18:50 -0500543 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
544 ... data=${data}
Vijaybc331e22020-02-27 04:17:37 -0600545 ${locks}= Evaluate json.loads('''${resp.text}''') json
546
547 [Return] ${locks["Records"]}
548
549
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500550Verify Lock On Resource
551 [Documentation] Verify lock on resource.
552 [Arguments] ${session_info} ${transaction_id}
Vijaybc331e22020-02-27 04:17:37 -0600553
554 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500555 # session_info Session information in dict.
556 # transaction_id Transaction id in list stored in dict.
Vijaybc331e22020-02-27 04:17:37 -0600557
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500558 ${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}
Vijayafdd2a12020-04-09 02:03:20 -0500564
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500565 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']}
Vijaybc331e22020-02-27 04:17:37 -0600569 END
570
Vijaybc331e22020-02-27 04:17:37 -0600571
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500572Acquire Lock On Resource
573 [Documentation] Acquire lock on resource.
574 [Arguments] ${client_id} ${lock_type} ${reboot_flag}=False
Vijaybc331e22020-02-27 04:17:37 -0600575
576 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500577 # 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).
Vijaybc331e22020-02-27 04:17:37 -0600582
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500583 ${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}
George Keishing566daaf2020-07-02 06:18:50 -0500588
Sushil Singhe33c6e62020-09-29 06:34:35 -0500589 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
Vijaybc331e22020-02-27 04:17:37 -0600590
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500591 Run Keyword If '${reboot_flag}' == 'True'
592 ... Run Keywords Redfish OBMC Reboot (off) AND
593 ... Redfish Login AND
Sushil Singhe33c6e62020-09-29 06:34:35 -0500594 ... Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} AND
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500595 ... Verify Lock On Resource ${session_info} ${trans_id_list} AND
596 ... Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600597
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500598 Run Keyword If '${reboot_flag}' == 'False'
599 ... Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600600
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500601 ${trans_id_emptylist}= Create List
602 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
603 Redfish Delete Session ${session_info}
Vijaybc331e22020-02-27 04:17:37 -0600604
Vijaybc331e22020-02-27 04:17:37 -0600605
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500606Form Data To Release Lock
607 [Documentation] Create a dictonay to release lock.
608 [Arguments] ${trans_id_list}
Vijay355daac2020-03-26 12:06:08 -0500609
610 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500611 # trans_id_list
Vijay355daac2020-03-26 12:06:08 -0500612
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500613 @{tran_ids}= Create List
Vijay355daac2020-03-26 12:06:08 -0500614
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500615 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
Sushil Singhdf390b62021-01-19 00:50:05 -0600639Release 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
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500651Acquire 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}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500669
Sushil Singhdf390b62021-01-19 00:50:05 -0600670 Release locks And Delete Session ${session_info} ${trans_id_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500671
672
Sushil Singh977f8f52020-11-20 06:32:50 -0600673Verify 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
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500689Verify 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}
Sushil Singhf9a536c2020-11-09 07:33:17 -0600706 ${lock_length2}= Get Length ${lock_list2}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500707
Sushil Singhf9a536c2020-11-09 07:33:17 -0600708 Should Be Equal As Integers ${lock_length1} ${lock_length2}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500709
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}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500731
Sushil Singhdf390b62021-01-19 00:50:05 -0600732 Release locks And Delete Session ${session_info} ${trans_id_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500733
734
Sushil Singhe33c6e62020-09-29 06:34:35 -0500735Verify 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
Sushil Singhf9a536c2020-11-09 07:33:17 -0600745 ${session_info}= Create Session With ClientID ${client_id}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500746 ${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}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500754
Sushil Singhdf390b62021-01-19 00:50:05 -0600755 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}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500779
780
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500781Verify 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
Sushil Singh59011d02021-01-27 23:00:20 -0600835Verify Fail To Release Lock With Invalid TransactionID
George Keishing16b3c7b2021-01-28 09:23:37 -0600836 [Documentation] Verify fail to be release lock with invalid transaction ID.
Sushil Singh59011d02021-01-27 23:00:20 -0600837 [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
Sushil Singh1b590532021-01-20 05:13:54 -0600866Verify Fail To Release Multiple Lock With Invalid TransactionID
867 [Documentation] Verify release multiple locks with invalid transaction ID fails.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500868 [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
Sushil Singhe33c6e62020-09-29 06:34:35 -0500943Verify 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
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500958Verify Fail To Acquire Lock For Invalid Lock Data
George Keishing16b3c7b2021-01-28 09:23:37 -0600959 [Documentation] Verify fail to acquired lock with invalid lock types, lock flags, segment flags.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500960 [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}
Sushil Singhbace3002020-10-08 08:12:58 -0500971
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}
Sushil Singh728ef9c2020-10-28 04:25:39 -0500985
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}
Sushil Singhf9a536c2020-11-09 07:33:17 -06001098
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}
Sushil Singh11949a22020-11-13 06:12:16 -06001131
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]