blob: 023e1a5364edc27592ab5409e4d97ea8fc3b173f [file] [log] [blame]
Vijaybc331e22020-02-27 04:17:37 -06001*** Settings ***
2
Sushil Singh8d420bf2021-09-06 08:27:41 -05003Documentation Test lock management feature of management console on BMC.
Vijaybc331e22020-02-27 04:17:37 -06004
Sushil Singh8d420bf2021-09-06 08:27:41 -05005Resource ../../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
George Keishingfbd67002022-08-01 11:24:03 -050011Library JSONLibrary
Vijaybc331e22020-02-27 04:17:37 -060012
Sushil Singh76806df2022-12-23 07:19:02 -060013Suite Setup Run Keyword And Ignore Error Delete All Redfish Sessions
14Suite Teardown Run Keyword And Ignore Error Delete All Redfish Sessions
15Test Setup Printn
16Test Teardown FFDC On Test Case Fail
Vijaybc331e22020-02-27 04:17:37 -060017
Matt Fischer6fb70d92023-10-24 19:06:33 -060018Test Tags Lock_Management
George Keishing7c32f302023-10-10 16:11:46 +053019
Vijaybc331e22020-02-27 04:17:37 -060020*** Variables ***
21
Sushil Singhe3f2e3b2022-07-28 05:15:43 -050022${CONFLICT_RQUEST} Conflict
Sushil Singh8d420bf2021-09-06 08:27:41 -050023${BAD_REQUEST} Bad Request
24&{default_trans_id} TransactionID=${1}
Vijaybc331e22020-02-27 04:17:37 -060025
26*** Test Cases ***
27
Sushil Singhd03f2ce2020-09-17 08:54:41 -050028Acquire Read Write Lock
Vijaybc331e22020-02-27 04:17:37 -060029 [Documentation] Acquire and release different read locks.
Sushil Singhd03f2ce2020-09-17 08:54:41 -050030 [Tags] Acquire_Read_Write_Lock
31 [Template] Acquire Lock On Resource
Vijaybc331e22020-02-27 04:17:37 -060032
Sushil Singhd03f2ce2020-09-17 08:54:41 -050033 # client_id lock_type reboot_flag
34 HMCID-01 ReadCase1 False
35 HMCID-01 ReadCase2 False
36 HMCID-01 ReadCase3 False
37 HMCID-01 WriteCase1 False
38 HMCID-01 WriteCase2 False
39 HMCID-01 WriteCase3 False
Vijaybc331e22020-02-27 04:17:37 -060040
41
Sushil Singhd03f2ce2020-09-17 08:54:41 -050042Acquire Read Lock On Read Lock
43 [Documentation] Acquire read lock on another read lock.
44 [Tags] Acquire_Read_Lock_On_Read_Lock
45 [Template] Acquire Lock On Another Lock
Vijaybc331e22020-02-27 04:17:37 -060046
Sushil Singhd03f2ce2020-09-17 08:54:41 -050047 # client_id
48 HMCID-01
Vijaybc331e22020-02-27 04:17:37 -060049
50
Sushil Singhd03f2ce2020-09-17 08:54:41 -050051Fail To Acquire Lock On Another Lock
52 [Documentation] Fail to acquire another lock.
53 [Tags] Fail_To_Acquire_Lock_On_Another_Lock
54 [Template] Verify Acquire Lock Fails On Another Lock
Vijay85610ee2020-04-03 05:30:28 -050055
Sushil Singhd03f2ce2020-09-17 08:54:41 -050056 # client_id lock_type
Sushil Singh5d059942021-09-27 08:41:38 -050057 HMCID-01 ReadCase7,WriteCase6
58 HMCID-01 WriteCase6,WriteCase6
59 HMCID-01 WriteCase6,ReadCase7
George Keishing566daaf2020-07-02 06:18:50 -050060
61
Sushil Singhe33c6e62020-09-29 06:34:35 -050062Acquire Lock After Reboot
63 [Documentation] Acquire and release read and write locks after reboot.
64 [Tags] Acquire_Lock_After_Reboot
65 [Template] Verify Acquire Lock After Reboot
66
67 # client_id lock_type
68 HMCID-01 ReadCase1
69 HMCID-01 ReadCase2
70 HMCID-01 ReadCase3
71 HMCID-01 WriteCase1
72 HMCID-01 WriteCase2
73 HMCID-01 WriteCase3
74
75
Sushil Singhd03f2ce2020-09-17 08:54:41 -050076Acquire And Release Lock In Loop
77 [Documentation] Acquire and release read, write locks in loop.
78 [Tags] Acquire_And_Release_Lock_In_Loop
79 [Template] Verify Acquire And Release Lock In Loop
George Keishing566daaf2020-07-02 06:18:50 -050080
Sushil Singhd03f2ce2020-09-17 08:54:41 -050081 # client_id lock_type
82 HMCID-01 ReadCase1
83 HMCID-01 ReadCase2
84 HMCID-01 ReadCase3
85 HMCID-01 WriteCase1
86 HMCID-01 WriteCase2
87 HMCID-01 WriteCase3
Vijay85610ee2020-04-03 05:30:28 -050088
89
Sushil Singh977f8f52020-11-20 06:32:50 -060090Fail To Acquire Read And Write In Single Request
91 [Documentation] Fail to acquire read and write lock in single request.
92 [Tags] Fail_To_Acquire_Read_And_Write_In_Single_Request
93 [Template] Verify Fail To Acquire Read And Write In Single Request
94
Sushil Singhe3f2e3b2022-07-28 05:15:43 -050095 # client_id lock_type status_code
96 HMCID-01 ReadCase1,WriteCase1 ${HTTP_CONFLICT}
97 HMCID-01 WriteCase1,ReadCase1 ${HTTP_CONFLICT}
98 HMCID-01 WriteCase1,WriteCase1 ${HTTP_CONFLICT}
99
100
101Acquire Read In Single Request
102 [Documentation] Acquire read in single request.
103 [Tags] Acquire_Read_In_Single_Request
104 [Template] Verify Acquire Read In Single Request
105
Sushil Singh977f8f52020-11-20 06:32:50 -0600106 # client_id lock_type
Sushil Singhe3f2e3b2022-07-28 05:15:43 -0500107 HMCID-01 ReadCase1,ReadCase1
Sushil Singh977f8f52020-11-20 06:32:50 -0600108
109
Sushil Singhdf390b62021-01-19 00:50:05 -0600110Acquire Multiple Lock Request At CEC Level
111 [Documentation] Acquire write lock on read lock under CEC level.
112 [Tags] Acquire_Multiple_Lock_Request_At_CEC_Level
113 [Template] Verify Acquire Multiple Lock Request At CEC Level
114
115 # client_id lock_type
116 HMCID-01 ReadCase4,WriteCase4
117 HMCID-01 WriteCase5,ReadCase5
118 HMCID-01 ReadCase6,WriteCase6
119 HMCID-01 WriteCase7,ReadCase7
120
121
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500122Verify Release Of Valid Locks
123 [Documentation] Release all valid locks.
124 [Tags] Verify_Release_Of_Valid_Locks
125 [Template] Acquire And Release Multiple Locks
Vijayafdd2a12020-04-09 02:03:20 -0500126
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500127 # client_id lock_type release_lock_type
128 HMCID-01 ReadCase1,ReadCase1,ReadCase1 Transaction
129 HMCID-02 ReadCase1,ReadCase1,ReadCase1 Session
Vijayafdd2a12020-04-09 02:03:20 -0500130
131
susilsi794116c62021-03-04 07:57:51 -0600132Release Lock When Session Deleted
133 [Documentation] Release lock when session gets deleted.
134 [Tags] Release_Lock_When_Session_Deleted
135 [Template] Verify Release Lock When Session Deleted
136
137 # client_id lock_type
138 HMCID-01 ReadCase1
139 HMCID-01 WriteCase1
140
141
Sushil Singh59011d02021-01-27 23:00:20 -0600142Fail To Release Lock With Invalid TransactionID
143 [Documentation] Fail to release lock with invalid transaction id.
144 [Tags] Fail_To_Release_Lock_With_Invalid_TransactionID
145 [Template] Verify Fail To Release Lock With Invalid TransactionID
146
susilsi743b0c062021-03-02 04:24:19 -0600147 # client_id lock_type release_lock_type
148 HMCID-01 ReadCase1 Transaction
149 HMCID-01 WriteCase1 Transaction
Sushil Singh59011d02021-01-27 23:00:20 -0600150
151
Sushil Singh1b590532021-01-20 05:13:54 -0600152Fail To Release Multiple Lock With Invalid TransactionID
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500153 [Documentation] Release in-valid lock result in fail.
Sushil Singh1b590532021-01-20 05:13:54 -0600154 [Tags] Fail_To_Release_Multiple_Lock_With_Invalid_TransactionID
155 [Template] Verify Fail To Release Multiple Lock With Invalid TransactionID
Vijayafdd2a12020-04-09 02:03:20 -0500156
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500157 # client_id lock_type release_lock_type
158 HMCID-01 ReadCase1,ReadCase1,ReadCase1 Transaction
159 12345 ReadCase2,ReadCase2,ReadCase2 Transaction
160 HMCID ReadCase3,ReadCase3,ReadCase3 Transaction
Vijayafdd2a12020-04-09 02:03:20 -0500161
162
Sushil Singh8bee3582021-01-27 23:46:48 -0600163Fail To Release Multiple Lock With Valid And Invalid TransactionID
George Keishing96143832021-03-23 07:55:08 -0500164 [Documentation] Release multiple lock with valid and invalid transaction.
Sushil Singh8bee3582021-01-27 23:46:48 -0600165 [Tags] Fail_To_Release_Multiple_Lock_With_Valid_And_Invalid_TransactionID
166 [Template] Verify Fail To Release Multiple Lock With Valid And Invalid TransactionID
167
168 # client_id lock_type release_lock_type
169 HMCID-01 ReadCase1,ReadCase1 Transaction
170
171
susilsi71d7b9962021-03-02 03:06:18 -0600172Fail To Release Lock With String As TransactionID Data Type
173 [Documentation] Fail to release lock with string as transaction id data type.
174 [Tags] Fail_To_Release_Lock_With_String_As_TransactionID_Data_Type
175 [Template] Verify Fail To Release Lock With TransactionID As String Type
176
177 # client_id lock_type release_lock_type
178 HMCID-01 ReadCase1 Transaction
179 HMCID-01 WriteCase1 Transaction
180
181
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500182Fail To Release Lock For Another Session
183 [Documentation] Failed to release locks from another session.
184 [Tags] Fail_To_Release_Lock_For_Another_Session
185 [Template] Verify Fail To Release Lock For Another Session
Vijayafdd2a12020-04-09 02:03:20 -0500186
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500187 # client_id lock_type
188 HMCID-01,HMCID-02 ReadCase1,ReadCase1
Vijayafdd2a12020-04-09 02:03:20 -0500189
190
Sushil Singh76806df2022-12-23 07:19:02 -0600191Verify Lock Is Not Persistent On BMC Reboot
192 [Documentation] Acquire lock and after reboot the locks are removed as no persistency
193 ... maintained.
194 [Tags] Verify_Lock_Is_Not_Persistent_On_BMC_Reboot
195 [Template] Acquire Lock On Resource
196
197 # client_id lock_type reboot_flag
198 HMCID-01 ReadCase1 True
199 HMCID-01 ReadCase2 True
200 HMCID-01 ReadCase3 True
201 HMCID-01 WriteCase1 True
202 HMCID-01 WriteCase2 True
203 HMCID-01 WriteCase3 True
204
205
Sushil Singhe33c6e62020-09-29 06:34:35 -0500206Test Invalid Resource ID Data Type Locking
207 [Documentation] Failed to acquire lock for invalid resource id data type.
208 [Tags] Test_Invalid_Resource_ID_Data_Type_Locking
209 [Template] Verify Fail To Acquire Lock For Invalid Resource ID Data Type
210
211 # client_id lock_type
212 HMCID-01 ReadCase1
213 HMCID-01 ReadCase2
214 HMCID-01 ReadCase3
215 HMCID-01 WriteCase1
216 HMCID-01 WriteCase2
217 HMCID-01 WriteCase3
218
219
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500220Fail To Acquire Lock For Invalid Lock Type
221 [Documentation] Failed to acquire read, write lock for invalid lock data passed.
222 [Tags] Fail_To_Acquire_Lock_For_Invalid_Lock_Type
223 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
Vijayafdd2a12020-04-09 02:03:20 -0500224
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500225 # client_id lock_type message
226 HMCID-01 ReadCase1 ${BAD_REQUEST}
227 HMCID-01 ReadCase2 ${BAD_REQUEST}
228 HMCID-01 ReadCase3 ${BAD_REQUEST}
229 HMCID-01 ReadCase4 ${BAD_REQUEST}
230 HMCID-01 ReadCase5 ${BAD_REQUEST}
231 HMCID-01 WriteCase1 ${BAD_REQUEST}
232 HMCID-01 WriteCase2 ${BAD_REQUEST}
233 HMCID-01 WriteCase3 ${BAD_REQUEST}
234 HMCID-01 WriteCase4 ${BAD_REQUEST}
235 HMCID-01 WriteCase5 ${BAD_REQUEST}
Vijayafdd2a12020-04-09 02:03:20 -0500236
Vijayafdd2a12020-04-09 02:03:20 -0500237
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500238Fail To Acquire Lock For Invalid Lock Flag
239 [Documentation] Failed to acquire read write lock for invalid lock flag passed.
240 [Tags] Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
241 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
Vijayafdd2a12020-04-09 02:03:20 -0500242
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500243 # client_id lock_type message
244 HMCID-01 ReadCase6 ${BAD_REQUEST}
245 HMCID-01 ReadCase7 ${BAD_REQUEST}
246 HMCID-01 ReadCase8 ${BAD_REQUEST}
247 HMCID-01 ReadCase9 ${BAD_REQUEST}
248 HMCID-01 ReadCase10 ${BAD_REQUEST}
249 HMCID-01 ReadCase11 ${BAD_REQUEST}
250 HMCID-01 WriteCase6 ${BAD_REQUEST}
251 HMCID-01 WriteCase7 ${BAD_REQUEST}
252 HMCID-01 WriteCase8 ${BAD_REQUEST}
253 HMCID-01 WriteCase9 ${BAD_REQUEST}
254 HMCID-01 WriteCase10 ${BAD_REQUEST}
255 HMCID-01 WriteCase11 ${BAD_REQUEST}
Vijayafdd2a12020-04-09 02:03:20 -0500256
Vijayafdd2a12020-04-09 02:03:20 -0500257
Sushil Singh76806df2022-12-23 07:19:02 -0600258Check After Reboot Transaction ID Set To Default
259 [Documentation] After reboot, the transaction id starts with default i.e. 1,
260 ... if any lock is acquired.
261 [Tags] Check_After_Reboot_Transaction_ID_Set_To_Default
262 [Template] Verify Acquire And Release Lock In Loop
263
264 # client_id lock_type reboot_flag
265 HMCID-01 ReadCase1 True
266 HMCID-01 WriteCase1 True
267
268
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500269Fail To Acquire Lock For Invalid Segment Flag
270 [Documentation] Failed to acquire read write lock for invalid segment flag passed.
271 [Tags] Fail_To_Acquire_Lock_For_Invalid_Segment_Flag
272 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
273
274 # client_id lock_type message
275 HMCID-01 ReadCase12 ${BAD_REQUEST}
276 HMCID-01 ReadCase13 ${BAD_REQUEST}
277 HMCID-01 ReadCase14 ${BAD_REQUEST}
278 HMCID-01 WriteCase12 ${BAD_REQUEST}
279 HMCID-01 WriteCase13 ${BAD_REQUEST}
280 HMCID-01 WriteCase14 ${BAD_REQUEST}
Vijayafdd2a12020-04-09 02:03:20 -0500281
Sushil Singhbace3002020-10-08 08:12:58 -0500282
Sushil Singh3b3a7ec2020-11-23 03:54:06 -0600283Fail To Acquire Lock For Invalid Segment Data Type Flag
284 [Documentation] Failed to acquire read write lock for invalid segment flag passed.
285 [Tags] Fail_To_Acquire_Lock_For_Invalid_Segment_Data_Type_Flag
286 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
287
288 # client_id lock_type message
289 HMCID-01 ReadCase15 ${EMPTY}
290 HMCID-01 ReadCase16 ${EMPTY}
291 HMCID-01 ReadCase17 ${EMPTY}
292 HMCID-01 ReadCase18 ${EMPTY}
293 HMCID-01 WriteCase15 ${EMPTY}
294 HMCID-01 WriteCase16 ${EMPTY}
295 HMCID-01 WriteCase17 ${EMPTY}
296 HMCID-01 WriteCase18 ${EMPTY}
297
298
Sushil Singhbace3002020-10-08 08:12:58 -0500299Get Empty Lock Records For Session Where No Locks Acquired
300 [Documentation] If session does not acquire locks then get lock should return
301 ... empty lock records.
302 [Tags] Get_Empty_Lock_Records_For_Session_Where_No_Locks_Acquired
303 [Template] Verify No Locks Records For Session With No Acquired Lock
304
305 # client_id
306 HMCID-01
307
Sushil Singh728ef9c2020-10-28 04:25:39 -0500308
Sushil Singhf9a536c2020-11-09 07:33:17 -0600309Get Lock Records Empty For Invalid Session
310 [Documentation] Record of lock list is empty for invalid session.
311 [Tags] Get_Lock_Records_Empty_For_Invalid_Session
312 [Template] Verify Empty Lock Records For Invalid Session
313
314 # client_id
315 HMCID-01
316
317
Sushil Singh728ef9c2020-10-28 04:25:39 -0500318Get Lock Records For Multiple Session
319 [Documentation] Get lock records of multiple session.
320 [Tags] Get_Lock_Records_For_Multiple_Session
321 [Template] Verify Lock Records Of Multiple Session
322
323 # client_ids lock_type
324 HMCID-01,HMCID-02 ReadCase1,ReadCase1
325
326
Sushil Singhf9a536c2020-11-09 07:33:17 -0600327Get Lock Records For Multiple Invalid Session
328 [Documentation] Record of lock list is empty for list of invalid session.
329 [Tags] Get_Lock_Records_For_Multiple_Invalid_Session
330 [Template] Verify Lock Records For Multiple Invalid Session
331
332 # client_id
333 HMCID-01
334
Sushil Singh11949a22020-11-13 06:12:16 -0600335
336Get Lock Records For Multiple Invalid And Valid Session
337 [Documentation] Get record of lock from invalid and valid session.
338 [Tags] Get_Lock_Records_For_Multiple_Invalid_And_Valid_Session
339 [Template] Verify Lock Records For Multiple Invalid And Valid Session
340
341 # client_id lock_type
342 HMCID-01,HMCID-02 ReadCase1
343
Vijaybc331e22020-02-27 04:17:37 -0600344*** Keywords ***
345
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500346Create Redfish Session With ClientID
347 [Documentation] Create redifish session with client id.
348 [Arguments] ${client_id}
Vijay85610ee2020-04-03 05:30:28 -0500349
350 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500351 # client_id This client id can contain string value
352 # (e.g. 12345, "HMCID").
Vijay85610ee2020-04-03 05:30:28 -0500353
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500354 ${session_info}= Create Dictionary
Sushil Singhf4de7d72023-07-21 08:59:20 -0500355
356 ${session}= Redfish Login kwargs="Context": "${client_id}"
Vijay85610ee2020-04-03 05:30:28 -0500357
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500358 Set To Dictionary ${session_info} SessionIDs ${session['Id']}
Sushil Singhf4de7d72023-07-21 08:59:20 -0500359 Set To Dictionary ${session_info} ClientID ${session["Context"]}
Vijay85610ee2020-04-03 05:30:28 -0500360
George Keishing409df052024-01-17 22:36:14 +0530361 RETURN ${session_info}
Vijay85610ee2020-04-03 05:30:28 -0500362
363
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500364RW General Dictionary
George Keishing16b3c7b2021-01-28 09:23:37 -0600365 [Documentation] Create dictionary of lock request.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500366 [Arguments] ${read_case} ${res_id}
Vijaybc331e22020-02-27 04:17:37 -0600367
368 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500369 # read_case Read or Write lock type.
370 # res_id Resource id.
Vijaybc331e22020-02-27 04:17:37 -0600371
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500372 ${request_dict}= Create Dictionary
George Keishing566daaf2020-07-02 06:18:50 -0500373
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500374 FOR ${key} IN @{read_case.keys()}
375 Set To Dictionary ${request_dict} LockType ${key}
376 Set To Dictionary ${request_dict} SegmentFlags ${read_case["${key}"]}
377 END
Vijaybc331e22020-02-27 04:17:37 -0600378
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500379 Set To Dictionary ${request_dict} ResourceID ${res_id}
380
George Keishing409df052024-01-17 22:36:14 +0530381 RETURN ${request_dict}
Vijaybc331e22020-02-27 04:17:37 -0600382
383
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500384Return Description Of Response
385 [Documentation] Return description of REST response.
Vijaybc331e22020-02-27 04:17:37 -0600386 [Arguments] ${resp_text}
387
388 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500389 # resp_text REST response body.
Vijaybc331e22020-02-27 04:17:37 -0600390
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500391 # resp_text after successful partition file upload looks like:
392 # {
393 # "Description": "File Created"
394 # }
Vijaybc331e22020-02-27 04:17:37 -0600395
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500396 ${message}= Evaluate json.loads('''${resp_text}''') json
397
George Keishing409df052024-01-17 22:36:14 +0530398 RETURN ${message}
Vijaybc331e22020-02-27 04:17:37 -0600399
400
Sushil Singha7d71f02020-11-02 05:24:22 -0600401Verify Redfish Session Deleted
402 [Documentation] Verify the redfish session is deleted.
403 [Arguments] ${session_info}
404
405 # Description of argument(s):
406 # session_info Session information are stored in dictionary.
407
408 # ${session_info} = {
409 # 'SessionIDs': 'XXXXXXXXX',
410 # 'ClientID': 'XXXXXX',
411 # 'SessionToken': 'XXXXXXXXX',
412 # 'SessionResp': session response from redfish login
413 # }
414
415 # SessionIDs : Session IDs
416 # ClientID : Client ID
417 # SessionToken : Session token
418 # SessionResp : Response of creating an redfish login session
419
420 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions
421
422 FOR ${session} IN @{sessions['Members']}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500423 Should Not Be Equal As Strings
424 ... session ['/redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}']
Sushil Singha7d71f02020-11-02 05:24:22 -0600425 END
426
427
428Verify Redfish List Of Session Deleted
429 [Documentation] Verify all the list of redfish session is deleted.
430 [Arguments] ${session_info_list}
431
432 # Description of argument(s):
433 # session_info_list List contains individual session record are stored in dictionary.
434
435 # ${session_info_list} = [{
436 # 'SessionIDs': 'XXXXXXXXX',
437 # 'ClientID': 'XXXXXX',
438 # 'SessionToken': 'XXXXXXXXX',
439 # 'SessionResp': session response from redfish login
440 # }]
441
442 # SessionIDs : Session IDs
443 # ClientID : Client ID
444 # SessionToken : Session token
445 # SessionResp : Response of creating an redfish login session
446
447 FOR ${session_record} IN @{session_info_list}
448 Verify Redfish Session Deleted ${session_record}
449 END
450
451
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500452Redfish Post Acquire Lock
453 [Documentation] Acquire and release lock.
454 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600455
456 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500457 # lock_type Read lock or Write lock.
458 # status_code HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600459
Sushil Singhe33c6e62020-09-29 06:34:35 -0500460 ${lock_dict_param}= Form Data To Acquire Lock ${lock_type}
George Keishingfbd67002022-08-01 11:24:03 -0500461 ${lock_dict_param}= Convert JSON To String ${lock_dict_param}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500462 ${resp}= Redfish Post Request
463 ... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
George Keishingfbd67002022-08-01 11:24:03 -0500464 ... expected_status=any
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500465 Should Be Equal As Strings ${resp.status_code} ${status_code}
Sushil Singhdf390b62021-01-19 00:50:05 -0600466
Sridevi Ramesh49c1b532025-05-09 04:32:43 -0500467 IF ${status_code} == ${HTTP_BAD_REQUEST}
468 Valid Value ${BAD_REQUEST} ['${resp.content}']
469 ELSE
470 Run Keyword And Return Return Description Of Response ${resp.content}
471 END
Vijaybc331e22020-02-27 04:17:37 -0600472
George Keishing409df052024-01-17 22:36:14 +0530473 RETURN ${resp}
Vijaybc331e22020-02-27 04:17:37 -0600474
475
Sushil Singh977f8f52020-11-20 06:32:50 -0600476Redfish Post Acquire List Lock
477 [Documentation] Acquire and release lock.
478 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
479
480 # Description of argument(s):
481 # lock_type Read lock or Write lock.
482 # status_code HTTP status code.
483
484 ${lock_dict_param}= Create Data To Acquire List Of Lock ${lock_type}
George Keishingfbd67002022-08-01 11:24:03 -0500485 ${lock_dict_param}= Convert JSON To String ${lock_dict_param}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500486 ${resp}= Redfish Post Request
487 ... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
George Keishingfbd67002022-08-01 11:24:03 -0500488 ... expected_status=any
Sushil Singh977f8f52020-11-20 06:32:50 -0600489 Should Be Equal As Strings ${resp.status_code} ${status_code}
490
Sridevi Ramesh49c1b532025-05-09 04:32:43 -0500491 IF ${status_code} == ${HTTP_CONFLICT}
492 Should Be Equal As Strings ${CONFLICT_RQUEST} ${resp.content}
493 ELSE
494 Run Keyword And Return Return Description Of Response ${resp.content}
495 END
Sushil Singhe3f2e3b2022-07-28 05:15:43 -0500496
George Keishing409df052024-01-17 22:36:14 +0530497 RETURN ${resp}
Sushil Singh977f8f52020-11-20 06:32:50 -0600498
499
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500500Redfish Post Acquire Invalid Lock
501 [Documentation] Redfish to post request to acquire in-valid lock.
502 [Arguments] ${lock_type} ${message} ${status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600503
504 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500505 # lock_type Read lock or Write lock.
506 # message Return message from URI.
507 # status_code HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600508
Sushil Singhe33c6e62020-09-29 06:34:35 -0500509 ${lock_dict_param}= Form Data To Acquire Invalid Lock ${lock_type}
George Keishingfbd67002022-08-01 11:24:03 -0500510 ${lock_dict_param}= Convert JSON To String ${lock_dict_param}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500511 ${resp}= Redfish Post Request
512 ... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500513 Should Be Equal As Strings ${resp.status_code} ${status_code}
Sridevi Ramesh49c1b532025-05-09 04:32:43 -0500514 IF '${message}' != '${EMPTY}'
515 Valid Value message ['${resp.content}']
516 END
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500517
George Keishing409df052024-01-17 22:36:14 +0530518 RETURN ${resp}
Vijaybc331e22020-02-27 04:17:37 -0600519
520
Sushil Singhe33c6e62020-09-29 06:34:35 -0500521Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
522 [Documentation] Redfish to post request to acquire in-valid lock with invalid data type of resource id.
523 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
524
525 # Description of argument(s):
526 # lock_type Read lock or Write lock.
527 # status_code HTTP status code.
528
Sushil Singh8a3efe72021-08-26 08:16:41 -0500529 ${lock_dict_param}=
530 ... Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID ${lock_type}
George Keishingfbd67002022-08-01 11:24:03 -0500531 ${lock_dict_param}= Convert JSON To String ${lock_dict_param}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500532 ${resp}= Redfish Post Request
533 ... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500534 Should Be Equal As Strings ${resp.status_code} ${status_code}
535
George Keishing409df052024-01-17 22:36:14 +0530536 RETURN ${resp}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500537
538
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500539Form Data To Acquire Lock
George Keishing16b3c7b2021-01-28 09:23:37 -0600540 [Documentation] Create a dictionary for lock request.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500541 [Arguments] ${lock_type}
542
543 # Description of argument(s):
544 # lock_type Read lock or Write lock.
545
546 ${lock_res_info}= Get Lock Resource Information
547 ${resp}= RW General Dictionary
548 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
549 ... ${lock_res_info["Valid Case"]["ResourceID"]}
550 ${temp_list}= Create List ${resp}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500551 ${lock_request_dict}= Create Dictionary Request=${temp_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500552
George Keishing409df052024-01-17 22:36:14 +0530553 RETURN ${lock_request_dict}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500554
555
Sushil Singh977f8f52020-11-20 06:32:50 -0600556Create Data To Acquire List Of Lock
George Keishing16b3c7b2021-01-28 09:23:37 -0600557 [Documentation] Create a dictionary for list of lock request.
Sushil Singh977f8f52020-11-20 06:32:50 -0600558 [Arguments] ${lock_type_list}
559
560 # Description of argument(s):
561 # lock_type Read lock or Write lock.
562
563 ${temp_list}= Create List
564 ${lock_res_info}= Get Lock Resource Information
565
566 FOR ${lock_type} IN @{lock_type_list}
567 ${resp}= RW General Dictionary
568 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
569 ... ${lock_res_info["Valid Case"]["ResourceID"]}
570 Append To List ${temp_list} ${resp}
571 END
572
573 ${lock_request_dict}= Create Dictionary Request=${temp_list}
574
George Keishing409df052024-01-17 22:36:14 +0530575 RETURN ${lock_request_dict}
Sushil Singh977f8f52020-11-20 06:32:50 -0600576
577
Sushil Singhe33c6e62020-09-29 06:34:35 -0500578Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
George Keishing16b3c7b2021-01-28 09:23:37 -0600579 [Documentation] Create a dictionary for in-valid lock request.
Sushil Singhe33c6e62020-09-29 06:34:35 -0500580 [Arguments] ${lock_type}
581
582 # Description of argument(s):
583 # lock_type Read lock or Write lock.
584
585 ${lock_res_info}= Get Lock Resource Information
586 ${resp}= RW General Dictionary
587 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
588 ... ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
589 ${temp_list}= Create List ${resp}
590 ${lock_request_dict}= Create Dictionary Request=${temp_list}
591
George Keishing409df052024-01-17 22:36:14 +0530592 RETURN ${lock_request_dict}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500593
594
595Form Data To Acquire Invalid Lock
George Keishing16b3c7b2021-01-28 09:23:37 -0600596 [Documentation] Create a dictionary for in-valid lock request.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500597 [Arguments] ${lock_type}
598
599 # Description of argument(s):
600 # lock_type Read lock or Write lock.
601
602 ${lock_res_info}= Get Lock Resource Information
603 ${resp}= RW General Dictionary
604 ... ${lock_res_info["Invalid Case"]["${lock_type}"]}
605 ... ${lock_res_info["Valid Case"]["ResourceID"]}
606 ${temp_list}= Create List ${resp}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500607 ${lock_request_dict}= Create Dictionary Request=${temp_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500608
George Keishing409df052024-01-17 22:36:14 +0530609 RETURN ${lock_request_dict}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500610
611
612Get Locks List On Resource
Vijaybc331e22020-02-27 04:17:37 -0600613 [Documentation] Get locks list.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500614 [Arguments] ${session_info} ${exp_status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600615
616 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500617 # session_info Session information in dict.
618 # exp_status_code Expected HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600619
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500620 ${data}= Set Variable {"SessionIDs": ["${session_info['SessionIDs']}"]}
George Keishing566daaf2020-07-02 06:18:50 -0500621 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
622 ... data=${data}
Vijaybc331e22020-02-27 04:17:37 -0600623 ${locks}= Evaluate json.loads('''${resp.text}''') json
624
George Keishing409df052024-01-17 22:36:14 +0530625 RETURN ${locks["Records"]}
Vijaybc331e22020-02-27 04:17:37 -0600626
627
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500628Verify Lock On Resource
629 [Documentation] Verify lock on resource.
630 [Arguments] ${session_info} ${transaction_id}
Vijaybc331e22020-02-27 04:17:37 -0600631
632 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500633 # session_info Session information in dict.
634 # transaction_id Transaction id in list stored in dict.
Vijaybc331e22020-02-27 04:17:37 -0600635
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500636 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
637 Rprint Vars sessions
638 ${lock_list}= Get Locks List On Resource ${session_info}
639 ${lock_length}= Get Length ${lock_list}
640 ${tran_id_length}= Get Length ${transaction_id}
641 Should Be Equal As Integers ${tran_id_length} ${lock_length}
Vijayafdd2a12020-04-09 02:03:20 -0500642
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500643 FOR ${tran_id} ${lock} IN ZIP ${transaction_id} ${lock_list}
644 Valid Value session_info['ClientID'] ['${lock['HMCID']}']
645 Valid Value session_info['SessionIDs'] ['${lock['SessionID']}']
646 Should Be Equal As Integers ${tran_id['TransactionID']} ${lock['TransactionID']}
Vijaybc331e22020-02-27 04:17:37 -0600647 END
648
Vijaybc331e22020-02-27 04:17:37 -0600649
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500650Acquire Lock On Resource
651 [Documentation] Acquire lock on resource.
652 [Arguments] ${client_id} ${lock_type} ${reboot_flag}=False
Vijaybc331e22020-02-27 04:17:37 -0600653
654 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500655 # client_id This client id can contain string value
656 # (e.g. 12345, "HMCID").
657 # lock_type Read lock or Write lock.
658 # reboot_flag Flag is used to run reboot the BMC code.
659 # (e.g. True or False).
Vijaybc331e22020-02-27 04:17:37 -0600660
Sushil Singh8a3efe72021-08-26 08:16:41 -0500661 ${trans_id_emptylist}= Create List
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500662 ${trans_id_list}= Create List
Sushil Singh8a3efe72021-08-26 08:16:41 -0500663
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500664 ${session_info}= Create Redfish Session With ClientID ${client_id}
665 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
666 Append To List ${trans_id_list} ${trans_id}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500667
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500668 Verify Lock On Resource ${session_info} ${trans_id_list}
George Keishing566daaf2020-07-02 06:18:50 -0500669
Sushil Singhe33c6e62020-09-29 06:34:35 -0500670 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
Vijaybc331e22020-02-27 04:17:37 -0600671
Sridevi Ramesh49c1b532025-05-09 04:32:43 -0500672 IF '${reboot_flag}' == 'True'
673 Redfish BMC Reset Operation
674 Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token}
675 Wait Until Keyword Succeeds 3 min 10 sec Redfish BMC Match States match_state=Enabled
676 Is BMC Standby
677 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
678 END
Vijaybc331e22020-02-27 04:17:37 -0600679
Sridevi Ramesh49c1b532025-05-09 04:32:43 -0500680 IF '${reboot_flag}' == 'False'
681 Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
682 END
Vijaybc331e22020-02-27 04:17:37 -0600683
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500684 ${trans_id_emptylist}= Create List
685 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
686 Redfish Delete Session ${session_info}
Vijaybc331e22020-02-27 04:17:37 -0600687
Vijaybc331e22020-02-27 04:17:37 -0600688
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500689Form Data To Release Lock
690 [Documentation] Create a dictonay to release lock.
691 [Arguments] ${trans_id_list}
Vijay355daac2020-03-26 12:06:08 -0500692
693 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500694 # trans_id_list
Vijay355daac2020-03-26 12:06:08 -0500695
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500696 @{tran_ids}= Create List
Vijay355daac2020-03-26 12:06:08 -0500697
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500698 FOR ${item} IN @{trans_id_list}
699 Append To List ${tran_ids} ${item['TransactionID']}
700 END
701
George Keishing409df052024-01-17 22:36:14 +0530702 RETURN ${tran_ids}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500703
704
705Release Locks On Resource
706 [Documentation] Redfish request to release a lock.
Sushil Singh8a3efe72021-08-26 08:16:41 -0500707 [Arguments] ${session_info} ${trans_id_list} ${release_lock_type}=Transaction
708 ... ${status_code}=${HTTP_OK}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500709
710 # Description of argument(s):
711 # session_info Session information in dict.
712 # trans_id_list Transaction id list.
713 # release_lock_type Release lock by Transaction, Session.
714 # status_code HTTP status code.
715
716 ${tran_ids}= Form Data To Release Lock ${trans_id_list}
717 ${data}= Set Variable {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
718 ${data}= Evaluate json.dumps(${data}) json
719 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock data=${data}
720 Should Be Equal As Strings ${resp.status_code} ${status_code}
721
722
Sushil Singhdf390b62021-01-19 00:50:05 -0600723Release locks And Delete Session
724 [Documentation] Release locks and delete redfish session.
725 [Arguments] ${session_info} ${trans_id_list}
726
727 Release Locks On Resource ${session_info} ${trans_id_list}
728
729 ${trans_id_emptylist}= Create List
730 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
731
732 Redfish Delete Session ${session_info}
733
734
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500735Acquire Lock On Another Lock
736 [Documentation] Acquire lock on another lock.
737 [Arguments] ${client_id}
738
739 # Description of argument(s):
740 # client_id This client id can contain string value
741 # (e.g. 12345, "HMCID").
742
743 ${trans_id_list}= Create List
744 ${session_info}= Create Redfish Session With ClientID ${client_id}
745
746 ${trans_id}= Redfish Post Acquire Lock ReadCase1
747 Append To List ${trans_id_list} ${trans_id}
748
749 ${trans_id}= Redfish Post Acquire Lock ReadCase1
750 Append To List ${trans_id_list} ${trans_id}
751
752 Verify Lock On Resource ${session_info} ${trans_id_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500753
Sushil Singhdf390b62021-01-19 00:50:05 -0600754 Release locks And Delete Session ${session_info} ${trans_id_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500755
756
Sushil Singh977f8f52020-11-20 06:32:50 -0600757Verify Fail To Acquire Read And Write In Single Request
758 [Documentation] Verify fail to acquire read and write lock passed in single request.
Sushil Singhe3f2e3b2022-07-28 05:15:43 -0500759 [Arguments] ${client_id} ${lock_type} ${status_code}
760
761 # Description of argument(s):
762 # client_id This client id can contain string value
763 # (e.g. 12345, "HMCID").
764 # lock_type Read lock or Write lock.
765 # status_code HTTP status code
766
767 ${lock_type_list}= Split String ${lock_type} ,
768
769 ${session_info}= Create Redfish Session With ClientID ${client_id}
770 ${trans_id}= Redfish Post Acquire List Lock ${lock_type_list} status_code=${status_code}
771 Redfish Delete Session ${session_info}
772
773
774Verify Acquire Read In Single Request
775 [Documentation] Verify acquire read in single request.
Sushil Singh977f8f52020-11-20 06:32:50 -0600776 [Arguments] ${client_id} ${lock_type}
777
778 # Description of argument(s):
779 # client_id This client id can contain string value
780 # (e.g. 12345, "HMCID").
781 # lock_type Read lock or Write lock.
782
Sushil Singhe3f2e3b2022-07-28 05:15:43 -0500783 ${trans_id_list}= Create List
Sushil Singh977f8f52020-11-20 06:32:50 -0600784 ${lock_type_list}= Split String ${lock_type} ,
785
786 ${session_info}= Create Redfish Session With ClientID ${client_id}
Sushil Singhe3f2e3b2022-07-28 05:15:43 -0500787 ${trans_id}= Redfish Post Acquire List Lock ${lock_type_list}
788 Append To List ${trans_id_list} ${trans_id}
789 Append To List ${trans_id_list} ${trans_id}
790
791 Verify Lock On Resource ${session_info} ${trans_id_list}
792 Remove From List ${trans_id_list} 1
793 Release Locks On Resource ${session_info} ${trans_id_list}
794
Sushil Singh977f8f52020-11-20 06:32:50 -0600795 Redfish Delete Session ${session_info}
796
797
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500798Verify Empty Lock Records For Invalid Session
799 [Documentation] Verify no lock record found for invalid session.
800 [Arguments] ${client_id}
801
802 # Description of argument(s):
803 # client_id This client id can contain string value
804 # (e.g. 12345, "HMCID").
805
806 ${session_info1}= Create Redfish Session With ClientID ${client_id}
807
808 ${lock_list1}= Get Locks List On Resource ${session_info1}
809 ${lock_length1}= Get Length ${lock_list1}
810
811 ${session_info2}= Copy Dictionary ${session_info1} deepcopy=True
812 set to dictionary ${session_info2} SessionIDs xxyXyyYZZz
813
814 ${lock_list2}= Get Locks List On Resource ${session_info2}
Sushil Singhf9a536c2020-11-09 07:33:17 -0600815 ${lock_length2}= Get Length ${lock_list2}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500816
Sushil Singhf9a536c2020-11-09 07:33:17 -0600817 Should Be Equal As Integers ${lock_length1} ${lock_length2}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500818
819 Redfish Delete Session ${session_info1}
820
821
822Verify Acquire Lock Fails On Another Lock
823 [Documentation] Verify acquire lock on another lock fails.
824 [Arguments] ${client_id} ${lock_type}
825
826 # Description of argument(s):
827 # client_id This client id can contain string value
828 # (e.g. 12345, "HMCID").
829 # lock_type Read lock or Write lock.
830
831 @{lock_type_list}= Split String ${lock_type} ,
832 ${session_info}= Create Redfish Session With ClientID ${client_id}
833 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
834
835 ${trans_id_list}= Create List
836 Append To List ${trans_id_list} ${trans_id}
837
838 Verify Lock On Resource ${session_info} ${trans_id_list}
839 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1] status_code=${HTTP_CONFLICT}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500840
Sushil Singhdf390b62021-01-19 00:50:05 -0600841 Release locks And Delete Session ${session_info} ${trans_id_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500842
843
Sushil Singhe33c6e62020-09-29 06:34:35 -0500844Verify Acquire Lock After Reboot
845 [Documentation] Acquire read and write lock after the reboot and release lock.
846 [Arguments] ${client_id} ${lock_type}
847
848 # Description of argument(s):
849 # client_id This client id can contain string value
850 # (e.g. 12345, "HMCID").
851 # lock_type Read lock or Write lock.
852
853 ${trans_id_list}= Create List
Sushil Singhf9a536c2020-11-09 07:33:17 -0600854 ${session_info}= Create Session With ClientID ${client_id}
Sushil Singhac229c72021-09-13 02:26:51 -0500855
Sushil Singhe33c6e62020-09-29 06:34:35 -0500856 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
Sushil Singhac229c72021-09-13 02:26:51 -0500857 Redfish BMC Reset Operation
Sushil Singhe33c6e62020-09-29 06:34:35 -0500858 Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token}
Sushil Singh07b25342022-09-20 09:29:07 -0500859 Wait Until Keyword Succeeds 3 min 10 sec Redfish BMC Match States match_state=Enabled
Sushil Singhac229c72021-09-13 02:26:51 -0500860 Is BMC Standby
Sushil Singhe33c6e62020-09-29 06:34:35 -0500861
862 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
863 Append To List ${trans_id_list} ${trans_id}
864 Verify Lock On Resource ${session_info} ${trans_id_list}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500865
Sushil Singhdf390b62021-01-19 00:50:05 -0600866 Release locks And Delete Session ${session_info} ${trans_id_list}
867
868
869Verify Acquire Multiple Lock Request At CEC Level
870 [Documentation] Acquire lock in loop.
871 [Arguments] ${client_id} ${lock_type}
872
873 # Description of argument(s):
874 # client_id This client id can contain string value
875 # (e.g. 12345, "HMCID").
876 # lock_type Read lock or Write lock.
877
878 ${trans_id_list}= Create List
879 @{lock_type_list}= Split String ${lock_type} ,
880 ${session_info}= Create Redfish Session With ClientID ${client_id}
881
882 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
883 Append To List ${trans_id_list} ${trans_id}
884
885 Verify Lock On Resource ${session_info} ${trans_id_list}
886
887 Redfish Post Acquire Lock ${lock_type_list}[1] status_code=${HTTP_CONFLICT}
888
889 Release locks And Delete Session ${session_info} ${trans_id_list}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500890
891
Sushil Singh8d420bf2021-09-06 08:27:41 -0500892Post Reboot Acquire Lock
893 [Documentation] Post reboot acquire lock and verify the transaction id is 1.
894 [Arguments] ${session_info} ${lock_type}
895
896 # Description of argument(s):
897 # session_info Session information.
898 # lock_type Read lock or Write lock.
899
900 ${trans_id_list}= Create List
901 ${trans_id_list_var}= Create List
902 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
903 Append To List ${trans_id_list} ${trans_id}
904 Append To List ${trans_id_list_var} ${default_trans_id}
905 Verify Lock On Resource ${session_info} ${trans_id_list}
906 Verify Lock On Resource ${session_info} ${trans_id_list_var}
907 Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
908 ${trans_id_emptylist}= Create List
909 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
910
911
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500912Verify Acquire And Release Lock In Loop
913 [Documentation] Acquire lock in loop.
Sushil Singh8d420bf2021-09-06 08:27:41 -0500914 [Arguments] ${client_id} ${lock_type} ${reboot_flag}=False
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500915
916 # Description of argument(s):
917 # client_id This client id can contain string value
918 # (e.g. 12345, "HMCID").
919 # lock_type Read lock or Write lock.
Sushil Singh8d420bf2021-09-06 08:27:41 -0500920 # reboot_flag Flag is used to run reboot the BMC code.
921 # (e.g. True or False).
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500922
923 FOR ${count} IN RANGE 1 11
924 ${trans_id_list}= Create List
925 ${session_info}= Create Redfish Session With ClientID ${client_id}
926 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
927 Append To List ${trans_id_list} ${trans_id}
928 Verify Lock On Resource ${session_info} ${trans_id_list}
929 Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
930 ${trans_id_emptylist}= Create List
931 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
Sushil Singh8d420bf2021-09-06 08:27:41 -0500932 Redfish Delete Session ${session_info}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500933 END
934
Sushil Singh8d420bf2021-09-06 08:27:41 -0500935 ${session_info}= Create Redfish Session With ClientID ${client_id}
936 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
937
Sridevi Ramesh49c1b532025-05-09 04:32:43 -0500938 IF '${reboot_flag}' == 'True'
939 Redfish BMC Reset Operation
940 Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token}
941 Wait Until Keyword Succeeds 3 min 10 sec Redfish BMC Match States match_state=Enabled
942 Is BMC Standby
943 Post Reboot Acquire Lock ${session_info} ${lock_type}
944 END
945
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500946 Redfish Delete Session ${session_info}
947
948
949Acquire And Release Multiple Locks
George Keishing9bfdf8a2024-04-19 11:09:07 +0530950 [Documentation] Acquire multiple locks on resource.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500951 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
952
953 # Description of argument(s):
954 # client_id This client id can contain string value
955 # (e.g. 12345, "HMCID").
956 # lock_type Read lock or Write lock.
957 # release_lock_type The value can be Transaction or Session.
958
959 @{lock_type_list}= Split String ${lock_type} ,
960 ${session_info}= Create Redfish Session With ClientID ${client_id}
961 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
962
963 ${trans_id_list}= Create List
964
965 Append To List ${trans_id_list} ${trans_id}
966 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
967
968 Append To List ${trans_id_list} ${trans_id}
969 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2]
970
971 Append To List ${trans_id_list} ${trans_id}
972 Verify Lock On Resource ${session_info} ${trans_id_list}
973 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=${release_lock_type}
974
975 ${trans_id_emptylist}= Create List
976 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
977 Redfish Delete Session ${session_info}
978
979
susilsi794116c62021-03-04 07:57:51 -0600980Verify Release Lock When Session Deleted
981 [Documentation] Verify lock get released when session are deleted.
982 [Arguments] ${client_id} ${lock_type}
983
984 # Description of argument(s):
985 # client_ids This client id can contain string value
986 # (e.g. 12345, "HMCID").
987 # lock_type Read lock or Write lock.
988
989 ${trans_id_list}= Create List
990 @{lock_type_list}= Split String ${lock_type} ,
991
992 ${pre_session_info}= Create Redfish Session With ClientID ${client_id}
993
994 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
995 Append To List ${trans_id_list} ${trans_id}
996 Verify Lock On Resource ${pre_session_info} ${trans_id_list}
997
998 Redfish Delete Session ${pre_session_info}
999 ${post_session_info}= Create Redfish Session With ClientID ${client_id}
1000 ${resp}= Get Locks List On Resource With Session List ${pre_session_info} ${HTTP_BAD_REQUEST}
1001
1002 Redfish Delete Session ${post_session_info}
1003
1004
1005
Sushil Singh59011d02021-01-27 23:00:20 -06001006Verify Fail To Release Lock With Invalid TransactionID
George Keishing16b3c7b2021-01-28 09:23:37 -06001007 [Documentation] Verify fail to be release lock with invalid transaction ID.
Sushil Singh59011d02021-01-27 23:00:20 -06001008 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
1009
1010 # Description of argument(s):
1011 # client_id This client id can contain string value
1012 # (e.g. 12345, "HMCID").
1013 # lock_type Read lock or Write lock.
1014 # release_lock_type The value can be Transaction or Session.
1015
1016 ${trans_id_list}= Create List
1017 @{lock_type_list}= Split String ${lock_type} ,
1018
1019 ${session_info}= Create Redfish Session With ClientID ${client_id}
1020
1021 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1022 ${value}= Get From Dictionary ${trans_id} TransactionID
1023 ${value}= Evaluate ${value} + 10
1024 Set To Dictionary ${trans_id} TransactionID ${value}
1025 Append To List ${trans_id_list} ${trans_id}
1026
1027 Release Locks On Resource
1028 ... ${session_info} ${trans_id_list}
1029 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
1030 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session
1031
1032 ${trans_id_emptylist}= Create List
1033 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1034 Redfish Delete Session ${session_info}
1035
1036
Sushil Singh1b590532021-01-20 05:13:54 -06001037Verify Fail To Release Multiple Lock With Invalid TransactionID
1038 [Documentation] Verify release multiple locks with invalid transaction ID fails.
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001039 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
1040
1041 # Description of argument(s):
1042 # client_id This client id can contain string value
1043 # (e.g. 12345, "HMCID").
1044 # lock_type Read lock or Write lock.
1045 # release_lock_type The value can be Transaction or Session.
1046
1047 ${trans_id_list}= Create List
1048 @{lock_type_list}= Split String ${lock_type} ,
1049
1050 ${session_info}= Create Redfish Session With ClientID ${client_id}
1051
1052 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1053 ${value}= Get From Dictionary ${trans_id} TransactionID
1054 ${value}= Evaluate ${value} + 10
1055 Set To Dictionary ${trans_id} TransactionID ${value}
1056 Append To List ${trans_id_list} ${trans_id}
1057
1058 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
1059 ${value}= Get From Dictionary ${trans_id} TransactionID
1060 ${value}= Evaluate ${value} + 10
1061 Set To Dictionary ${trans_id} TransactionID ${value}
1062 Append To List ${trans_id_list} ${trans_id}
1063
1064 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2]
1065 ${value}= Get From Dictionary ${trans_id} TransactionID
1066 ${value}= Evaluate ${value} + 10
1067 Set To Dictionary ${trans_id} TransactionID ${value}
1068 Append To List ${trans_id_list} ${trans_id}
1069
1070 Release Locks On Resource
1071 ... ${session_info} ${trans_id_list}
1072 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
1073 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session
1074
1075 ${trans_id_emptylist}= Create List
1076 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1077 Redfish Delete Session ${session_info}
1078
1079
Sushil Singh8bee3582021-01-27 23:46:48 -06001080Verify Fail To Release Multiple Lock With Valid And Invalid TransactionID
George Keishing96143832021-03-23 07:55:08 -05001081 [Documentation] Verify fail to be release multiple lock with valid and invalid transaction ID.
Sushil Singh8bee3582021-01-27 23:46:48 -06001082 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
1083
1084 # Description of argument(s):
1085 # client_id This client id can contain string value
1086 # (e.g. 12345, "HMCID").
1087 # lock_type Read lock or Write lock.
1088 # release_lock_type The value can be Transaction or Session.
1089
1090 ${trans_id_list}= Create List
1091 @{lock_type_list}= Split String ${lock_type} ,
1092
1093 ${session_info}= Create Redfish Session With ClientID ${client_id}
1094
1095 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1096 Append To List ${trans_id_list} ${trans_id}
1097
1098 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
1099 ${value}= Get From Dictionary ${trans_id} TransactionID
1100 ${value}= Evaluate ${value} + 10
1101 Set To Dictionary ${trans_id} TransactionID ${value}
1102 Append To List ${trans_id_list} ${trans_id}
1103
1104 Release Locks On Resource
1105 ... ${session_info} ${trans_id_list}
1106 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
1107 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session
1108
1109 ${trans_id_emptylist}= Create List
1110 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1111 Redfish Delete Session ${session_info}
1112
1113
susilsi71d7b9962021-03-02 03:06:18 -06001114Verify Fail To Release Lock With TransactionID As String Type
George Keishing96143832021-03-23 07:55:08 -05001115 [Documentation] Verify fail to be release lock with transaction ID as string data type.
susilsi71d7b9962021-03-02 03:06:18 -06001116 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
1117
1118 # Description of argument(s):
1119 # client_id This client id can contain string value
1120 # (e.g. 12345, "HMCID").
1121 # lock_type Read lock or Write lock.
1122 # release_lock_type The value can be Transaction or Session.
1123
1124 ${trans_id_list}= Create List
1125 @{lock_type_list}= Split String ${lock_type} ,
1126
1127 ${session_info}= Create Redfish Session With ClientID ${client_id}
1128
1129 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1130
1131 Append To List ${trans_id_list} ${trans_id}
1132
Sushil Singhf4de7d72023-07-21 08:59:20 -05001133 ${temp_trans_id_list}= Copy List ${trans_id_list} deepcopy=True
susilsi71d7b9962021-03-02 03:06:18 -06001134
1135 ${value}= Get From Dictionary ${trans_id_list}[0] TransactionID
1136 ${value}= Set Variable \'${value}\'
1137 Set To Dictionary ${temp_trans_id_list}[0] TransactionID ${value}
1138
1139 Release Locks On Resource
1140 ... ${session_info} ${temp_trans_id_list}
1141 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
1142
1143 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=${release_lock_type}
1144
1145 ${trans_id_emptylist}= Create List
1146 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1147 Redfish Delete Session ${session_info}
1148
1149
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001150Verify Fail To Release Lock For Another Session
1151 [Documentation] Verify failed to release the lock form another session.
1152 [Arguments] ${client_id} ${lock_type}
1153
1154 # Description of argument(s):
1155 # client_id This client id can contain string value
1156 # (e.g. 12345, "HMCID").
1157 # lock_type Read lock or Write lock.
1158
1159 ${client_ids}= Split String ${client_id} ,
1160 ${lock_type_list}= Split String ${lock_type} ,
1161 ${trans_id_list1}= Create List
1162 ${trans_id_list2}= Create List
1163
1164 ${session_info1}= Create Redfish Session With ClientID ${client_ids}[0]
1165
1166 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1167 Append To List ${trans_id_list1} ${trans_id}
1168 Verify Lock On Resource ${session_info1} ${trans_id_list1}
1169
1170 ${session_info2}= Create Redfish Session With ClientID ${client_ids}[1]
1171 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
1172 Append To List ${trans_id_list2} ${trans_id}
1173 Verify Lock On Resource ${session_info2} ${trans_id_list2}
1174
1175 Release Locks On Resource
Sushil Singhe3f2e3b2022-07-28 05:15:43 -05001176 ... ${session_info1} ${trans_id_list1} Transaction status_code=${HTTP_BAD_REQUEST}
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001177 Verify Lock On Resource ${session_info1} ${trans_id_list1}
1178 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Session
1179 Release Locks On Resource ${session_info2} ${trans_id_list2} release_lock_type=Session
1180 Redfish Delete Session ${session_info1}
1181 Redfish Delete Session ${session_info2}
1182
1183
Sushil Singhe33c6e62020-09-29 06:34:35 -05001184Verify Fail To Acquire Lock For Invalid Resource ID Data Type
1185 [Documentation] Verify fail to acquire the lock with invalid resource id data type.
1186 [Arguments] ${client_id} ${lock_type}
1187
1188 # Description of argument(s):
1189 # client_id This client id can contain string value
1190 # (e.g. 12345, "HMCID").
1191 # lock_type Read lock or Write lock.
1192
1193 ${session_info}= Create Redfish Session With ClientID ${client_id}
1194 Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
1195 ... ${lock_type} status_code=${HTTP_BAD_REQUEST}
1196 Redfish Delete Session ${session_info}
1197
1198
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001199Verify Fail To Acquire Lock For Invalid Lock Data
George Keishing16b3c7b2021-01-28 09:23:37 -06001200 [Documentation] Verify fail to acquired lock with invalid lock types, lock flags, segment flags.
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001201 [Arguments] ${client_id} ${lock_type} ${message}
1202
1203 # Description of argument(s):
1204 # client_id This client id can contain string value
1205 # (e.g. 12345, "HMCID").
1206 # lock_type Read lock or Write lock.
1207 # message Return message from URI.
1208
1209 ${session_info}= Create Redfish Session With ClientID ${client_id}
Sushil Singh8a3efe72021-08-26 08:16:41 -05001210 ${trans_id}= Redfish Post Acquire Invalid Lock
1211 ... ${lock_type} message=${message} status_code=${HTTP_BAD_REQUEST}
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001212 Redfish Delete Session ${session_info}
Sushil Singhbace3002020-10-08 08:12:58 -05001213
1214
1215Verify No Locks Records For Session With No Acquired Lock
1216 [Documentation] Verify no records found for a session where no lock is acquired.
1217 [Arguments] ${client_id}
1218
1219 # Description of argument(s):
1220 # client_id This client id can contain string value
1221 # (e.g. 12345, "HMCID").
1222
1223 ${session_info}= Create Redfish Session With ClientID ${client_id}
1224 ${trans_id_emptylist}= Create List
1225 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1226 Redfish Delete Session ${session_info}
Sushil Singh728ef9c2020-10-28 04:25:39 -05001227
1228
1229Create List Of Session ID
1230 [Documentation] Create session id list from session dict info.
1231 [Arguments] ${session_dict_info}
1232
1233 # Description of argument(s):
1234 # session_dict_info Session information in dict.
1235
1236 @{session_id_list}= Create List
1237
1238 FOR ${session} IN @{session_dict_info}
1239 Append To List ${session_id_list} ${session["SessionIDs"]}
1240 END
1241
1242 ${num_id}= Get Length ${session_id_list}
1243 Should Not Be Equal As Integers ${num_id} ${0}
1244
1245 ${session_id_list}= Evaluate json.dumps(${session_id_list}) json
1246
George Keishing409df052024-01-17 22:36:14 +05301247 RETURN ${session_id_list}
Sushil Singh728ef9c2020-10-28 04:25:39 -05001248
1249
1250Get Locks List On Resource With Session List
1251 [Documentation] Get locks list from session of list.
1252 [Arguments] ${session_id_list} ${exp_status_code}=${HTTP_OK}
1253
1254 # Description of argument(s):
1255 # session_id_list Session ids list.
1256 # exp_status_code Expected HTTP status code.
1257
1258 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
George Keishingfbd67002022-08-01 11:24:03 -05001259 ... data={"SessionIDs":${session_id_list}} expected_status=any
susilsi794116c62021-03-04 07:57:51 -06001260 Should Be Equal As Strings ${resp.status_code} ${exp_status_code}
Sushil Singh728ef9c2020-10-28 04:25:39 -05001261 ${locks}= Evaluate json.loads('''${resp.text}''') json
1262
George Keishing409df052024-01-17 22:36:14 +05301263 RETURN ${locks}
Sushil Singh728ef9c2020-10-28 04:25:39 -05001264
1265
1266Verify List Of Session Lock On Resource
1267 [Documentation] Verify list of lock record from list of sessions.
1268 [Arguments] ${session_dict_info} ${transaction_id_list}
1269
1270 # Description of argument(s):
1271 # session_dict_info Session information in dict.
1272 # transaction_id_list Transaction id in list stored in dict.
1273
1274 ${session_id_list}= Create List Of Session ID ${session_dict_info}
1275 ${lock_list_resp}= Get Locks List On Resource With Session List ${session_id_list}
1276 ${lock_list}= Set Variable ${lock_list_resp['Records']}
1277
Sushil Singh8a3efe72021-08-26 08:16:41 -05001278 FOR ${session_id} ${tran_id} ${lock_record} IN ZIP
1279 ... ${session_dict_info} ${transaction_id_list} ${lock_list}
Sushil Singh728ef9c2020-10-28 04:25:39 -05001280 Valid Value session_id['SessionIDs'] ['${lock_record['SessionID']}']
1281 Should Be Equal As Integers ${tran_id['TransactionID']} ${lock_record['TransactionID']}
1282 END
1283
1284
1285Verify Lock Records Of Multiple Session
1286 [Documentation] Verify all records found for a multiple sessions.
1287 [Arguments] ${client_ids} ${lock_type}
1288
1289 # Description of argument(s):
1290 # client_ids This client id can contain string value
1291 # (e.g. 12345, "HMCID").
1292 # lock_type Read lock or Write lock.
1293
1294 ${client_id_list}= Split String ${client_ids} ,
1295 ${lock_type_list}= Split String ${lock_type} ,
1296 ${trans_id_list1}= Create List
1297 ${trans_id_list2}= Create List
1298
1299 ${session_dict_list}= Create List
1300 ${lock_list}= Create List
1301
1302 ${client_id1}= Create List
1303 Append To List ${client_id1} ${client_id_list}[0]
1304 ${session_info1}= Create Session With List Of ClientID ${client_id1}
1305 Append To List ${session_dict_list} ${session_info1}[0]
1306 Verify A Session Created With ClientID ${client_id1} ${session_info1}
1307
1308 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1309 Append To List ${trans_id_list1} ${trans_id}
1310 Append To List ${lock_list} ${trans_id}
1311 Verify Lock On Resource ${session_info1}[0] ${trans_id_list1}
1312
1313
1314 ${client_id2}= Create List
1315 Append To List ${client_id2} ${client_id_list}[1]
1316 ${session_info2}= Create Session With List Of ClientID ${client_id2}
1317 Append To List ${session_dict_list} ${session_info2}[0]
1318 Verify A Session Created With ClientID ${client_id2} ${session_info2}
1319
1320 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
1321 Append To List ${trans_id_list2} ${trans_id}
1322 Append To List ${lock_list} ${trans_id}
1323 Verify Lock On Resource ${session_info2}[0] ${trans_id_list2}
1324
1325 Verify List Of Session Lock On Resource ${session_dict_list} ${lock_list}
1326
1327 ${session_token}= Get From Dictionary ${session_info1}[0] SessionToken
1328 Set Global Variable ${XAUTH_TOKEN} ${session_token}
1329
1330 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Transaction
1331
1332 ${session_token}= Get From Dictionary ${session_info2}[0] SessionToken
1333 Set Global Variable ${XAUTH_TOKEN} ${session_token}
1334
1335 Release Locks On Resource ${session_info2} ${trans_id_list2} release_lock_type=Transaction
1336
1337 ${trans_id_emptylist}= Create List
1338 Verify Lock On Resource ${session_info1}[0] ${trans_id_emptylist}
1339 Verify Lock On Resource ${session_info2}[0] ${trans_id_emptylist}
1340
1341 Redfish Delete List Of Session ${session_dict_list}
Sushil Singhf9a536c2020-11-09 07:33:17 -06001342
1343
1344Verify Lock Records For Multiple Invalid Session
1345 [Documentation] Verify no lock record found for multiple invalid session.
1346 [Arguments] ${client_id}
1347
1348 # Description of argument(s):
1349 # client_id This client id can contain string value
1350 # (e.g. 12345, "HMCID").
1351
1352 ${session_dict_list}= Create List
1353 ${invalid_session_ids}= Create List xxyXyyYZZz xXyXYyYZzz
1354
1355 ${session_info1}= Create Session With ClientID ${client_id}
1356
1357 ${session_info2}= Copy Dictionary ${session_info1} deepcopy=True
1358 set to dictionary ${session_info2} SessionIDs ${invalid_session_ids}[0]
1359 Append To List ${session_dict_list} ${session_info2}
1360
1361 ${session_info3}= Copy Dictionary ${session_info1} deepcopy=True
1362 set to dictionary ${session_info3} SessionIDs ${invalid_session_ids}[0]
1363 Append To List ${session_dict_list} ${session_info3}
1364
1365 ${lock_list1}= Get Locks List On Resource ${session_info1}
1366 ${lock_length1}= Get Length ${lock_list1}
1367
1368 ${session_id_list}= Create List Of Session ID ${session_dict_list}
1369 ${lock_list_resp}= Get Locks List On Resource With Session List ${session_id_list}
1370 ${lock_length2}= Get Length ${lock_list_resp['Records']}
1371
1372 Should Be Equal As Integers ${lock_length1} ${lock_length2}
1373
1374 Redfish Delete Session ${session_info1}
Sushil Singh11949a22020-11-13 06:12:16 -06001375
1376
1377Verify Lock Records For Multiple Invalid And Valid Session
1378 [Documentation] Verify all records found for a valid and invalid sessions.
1379 [Arguments] ${client_ids} ${lock_type}
1380
1381 # Description of argument(s):
1382 # client_ids This client id can contain string value
1383 # (e.g. 12345, "HMCID").
1384 # lock_type Read lock or Write lock.
1385
1386 ${client_id_list}= Split String ${client_ids} ,
1387 ${lock_type_list}= Split String ${lock_type} ,
1388 ${trans_id_list1}= Create List
1389 ${invalid_session_ids}= Create List xxyXyyYZZz
1390
1391 ${session_dict_list}= Create List
1392 ${lock_list}= Create List
1393
1394 ${client_id1}= Create List
1395 Append To List ${client_id1} ${client_id_list}[0]
1396 ${session_info1}= Create Session With List Of ClientID ${client_id1}
1397 Append To List ${session_dict_list} ${session_info1}[0]
1398 Verify A Session Created With ClientID ${client_id1} ${session_info1}
1399
1400 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1401 Append To List ${trans_id_list1} ${trans_id}
1402 Append To List ${lock_list} ${trans_id}
1403 Verify Lock On Resource ${session_info1}[0] ${trans_id_list1}
1404
Sushil Singhf4de7d72023-07-21 08:59:20 -05001405 ${session_info2}= Copy List ${session_info1} deepcopy=True
Sushil Singh11949a22020-11-13 06:12:16 -06001406 set to dictionary ${session_info2}[0] SessionIDs ${invalid_session_ids}[0]
1407 Append To List ${session_dict_list} ${session_info2}[0]
1408
1409 Verify List Of Session Lock On Resource ${session_dict_list} ${lock_list}
1410
1411 ${session_token}= Get From Dictionary ${session_info1}[0] SessionToken
1412 Set Global Variable ${XAUTH_TOKEN} ${session_token}
1413
1414 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Transaction
1415
1416 ${trans_id_emptylist}= Create List
1417 Verify Lock On Resource ${session_info1}[0] ${trans_id_emptylist}
1418
1419 Redfish Delete Session ${session_info1}[0]
George Keishing7e49fd52022-12-22 03:11:37 -06001420
1421
1422Delete All Redfish and HMC Sessions
1423 [Documentation] Delete all active redfish sessions.
1424
1425 ${saved_session_info}= Get Redfish Session Info
1426
1427 ${resp_list}= Redfish_Utils.Get Member List
1428 ... /redfish/v1/SessionService/Sessions
1429
1430 # Remove the current login session from the list.
1431 Remove Values From List ${resp_list} ${saved_session_info["location"]}
1432
1433 FOR ${session} IN @{resp_list}
1434 Run Keyword And Ignore Error Redfish.Delete ${session}
1435 END
1436
1437
1438Restart Bmcweb On Failure
1439 [Documentation] Restart bmcweb only if test failed.
1440
Sridevi Rameshe54be142025-05-05 00:52:45 -05001441 IF "${TEST_STATUS}" == "PASS" RETURN
George Keishing7e49fd52022-12-22 03:11:37 -06001442
1443 # This procedure is needs to be corrected or removed, when we figure out
1444 # what is causing the real failure here.
1445
1446 Log To Console Likely ConnectionResetError: Restarting bmcweb
1447
1448 ${stdout} ${stderr} ${rc}= BMC Execute Command
1449 ... systemctl restart bmcweb print_out=1
1450
1451 Should Be Empty ${stderr}
1452
1453 Sleep 10s reason=Wait for service to restart properly.