blob: c96789ae84070f1ed2e096230a46339a828901fa [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
George Keishing365dd462023-10-12 18:56:00 +053018Force 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
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500361 [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
381 [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
398 [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
467 Run Keyword 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}
Vijaybc331e22020-02-27 04:17:37 -0600471
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500472 [Return] ${resp}
Vijaybc331e22020-02-27 04:17:37 -0600473
474
Sushil Singh977f8f52020-11-20 06:32:50 -0600475Redfish Post Acquire List Lock
476 [Documentation] Acquire and release lock.
477 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
478
479 # Description of argument(s):
480 # lock_type Read lock or Write lock.
481 # status_code HTTP status code.
482
483 ${lock_dict_param}= Create Data To Acquire List Of Lock ${lock_type}
George Keishingfbd67002022-08-01 11:24:03 -0500484 ${lock_dict_param}= Convert JSON To String ${lock_dict_param}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500485 ${resp}= Redfish Post Request
486 ... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
George Keishingfbd67002022-08-01 11:24:03 -0500487 ... expected_status=any
Sushil Singh977f8f52020-11-20 06:32:50 -0600488 Should Be Equal As Strings ${resp.status_code} ${status_code}
489
Sushil Singhe3f2e3b2022-07-28 05:15:43 -0500490 Run Keyword If ${status_code} == ${HTTP_CONFLICT}
491 ... Should Be Equal As Strings ${CONFLICT_RQUEST} ${resp.content}
492 ... ELSE
493 ... Run Keyword And Return Return Description Of Response ${resp.content}
494
Sushil Singh977f8f52020-11-20 06:32:50 -0600495 [Return] ${resp}
496
497
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500498Redfish Post Acquire Invalid Lock
499 [Documentation] Redfish to post request to acquire in-valid lock.
500 [Arguments] ${lock_type} ${message} ${status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600501
502 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500503 # lock_type Read lock or Write lock.
504 # message Return message from URI.
505 # status_code HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600506
Sushil Singhe33c6e62020-09-29 06:34:35 -0500507 ${lock_dict_param}= Form Data To Acquire Invalid Lock ${lock_type}
George Keishingfbd67002022-08-01 11:24:03 -0500508 ${lock_dict_param}= Convert JSON To String ${lock_dict_param}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500509 ${resp}= Redfish Post Request
510 ... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500511 Should Be Equal As Strings ${resp.status_code} ${status_code}
Sushil Singh3b3a7ec2020-11-23 03:54:06 -0600512 Run Keyword If '${message}' != '${EMPTY}'
513 ... Valid Value message ['${resp.content}']
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500514
515 [Return] ${resp}
Vijaybc331e22020-02-27 04:17:37 -0600516
517
Sushil Singhe33c6e62020-09-29 06:34:35 -0500518Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
519 [Documentation] Redfish to post request to acquire in-valid lock with invalid data type of resource id.
520 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
521
522 # Description of argument(s):
523 # lock_type Read lock or Write lock.
524 # status_code HTTP status code.
525
Sushil Singh8a3efe72021-08-26 08:16:41 -0500526 ${lock_dict_param}=
527 ... Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID ${lock_type}
George Keishingfbd67002022-08-01 11:24:03 -0500528 ${lock_dict_param}= Convert JSON To String ${lock_dict_param}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500529 ${resp}= Redfish Post Request
530 ... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500531 Should Be Equal As Strings ${resp.status_code} ${status_code}
532
533 [Return] ${resp}
534
535
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500536Form Data To Acquire Lock
George Keishing16b3c7b2021-01-28 09:23:37 -0600537 [Documentation] Create a dictionary for lock request.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500538 [Arguments] ${lock_type}
539
540 # Description of argument(s):
541 # lock_type Read lock or Write lock.
542
543 ${lock_res_info}= Get Lock Resource Information
544 ${resp}= RW General Dictionary
545 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
546 ... ${lock_res_info["Valid Case"]["ResourceID"]}
547 ${temp_list}= Create List ${resp}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500548 ${lock_request_dict}= Create Dictionary Request=${temp_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500549
Sushil Singhe33c6e62020-09-29 06:34:35 -0500550 [Return] ${lock_request_dict}
551
552
Sushil Singh977f8f52020-11-20 06:32:50 -0600553Create Data To Acquire List Of Lock
George Keishing16b3c7b2021-01-28 09:23:37 -0600554 [Documentation] Create a dictionary for list of lock request.
Sushil Singh977f8f52020-11-20 06:32:50 -0600555 [Arguments] ${lock_type_list}
556
557 # Description of argument(s):
558 # lock_type Read lock or Write lock.
559
560 ${temp_list}= Create List
561 ${lock_res_info}= Get Lock Resource Information
562
563 FOR ${lock_type} IN @{lock_type_list}
564 ${resp}= RW General Dictionary
565 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
566 ... ${lock_res_info["Valid Case"]["ResourceID"]}
567 Append To List ${temp_list} ${resp}
568 END
569
570 ${lock_request_dict}= Create Dictionary Request=${temp_list}
571
572 [Return] ${lock_request_dict}
573
574
Sushil Singhe33c6e62020-09-29 06:34:35 -0500575Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
George Keishing16b3c7b2021-01-28 09:23:37 -0600576 [Documentation] Create a dictionary for in-valid lock request.
Sushil Singhe33c6e62020-09-29 06:34:35 -0500577 [Arguments] ${lock_type}
578
579 # Description of argument(s):
580 # lock_type Read lock or Write lock.
581
582 ${lock_res_info}= Get Lock Resource Information
583 ${resp}= RW General Dictionary
584 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
585 ... ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
586 ${temp_list}= Create List ${resp}
587 ${lock_request_dict}= Create Dictionary Request=${temp_list}
588
589 [Return] ${lock_request_dict}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500590
591
592Form Data To Acquire Invalid Lock
George Keishing16b3c7b2021-01-28 09:23:37 -0600593 [Documentation] Create a dictionary for in-valid lock request.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500594 [Arguments] ${lock_type}
595
596 # Description of argument(s):
597 # lock_type Read lock or Write lock.
598
599 ${lock_res_info}= Get Lock Resource Information
600 ${resp}= RW General Dictionary
601 ... ${lock_res_info["Invalid Case"]["${lock_type}"]}
602 ... ${lock_res_info["Valid Case"]["ResourceID"]}
603 ${temp_list}= Create List ${resp}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500604 ${lock_request_dict}= Create Dictionary Request=${temp_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500605
Sushil Singhe33c6e62020-09-29 06:34:35 -0500606 [Return] ${lock_request_dict}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500607
608
609Get Locks List On Resource
Vijaybc331e22020-02-27 04:17:37 -0600610 [Documentation] Get locks list.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500611 [Arguments] ${session_info} ${exp_status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600612
613 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500614 # session_info Session information in dict.
615 # exp_status_code Expected HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600616
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500617 ${data}= Set Variable {"SessionIDs": ["${session_info['SessionIDs']}"]}
George Keishing566daaf2020-07-02 06:18:50 -0500618 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
619 ... data=${data}
Vijaybc331e22020-02-27 04:17:37 -0600620 ${locks}= Evaluate json.loads('''${resp.text}''') json
621
622 [Return] ${locks["Records"]}
623
624
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500625Verify Lock On Resource
626 [Documentation] Verify lock on resource.
627 [Arguments] ${session_info} ${transaction_id}
Vijaybc331e22020-02-27 04:17:37 -0600628
629 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500630 # session_info Session information in dict.
631 # transaction_id Transaction id in list stored in dict.
Vijaybc331e22020-02-27 04:17:37 -0600632
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500633 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
634 Rprint Vars sessions
635 ${lock_list}= Get Locks List On Resource ${session_info}
636 ${lock_length}= Get Length ${lock_list}
637 ${tran_id_length}= Get Length ${transaction_id}
638 Should Be Equal As Integers ${tran_id_length} ${lock_length}
Vijayafdd2a12020-04-09 02:03:20 -0500639
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500640 FOR ${tran_id} ${lock} IN ZIP ${transaction_id} ${lock_list}
641 Valid Value session_info['ClientID'] ['${lock['HMCID']}']
642 Valid Value session_info['SessionIDs'] ['${lock['SessionID']}']
643 Should Be Equal As Integers ${tran_id['TransactionID']} ${lock['TransactionID']}
Vijaybc331e22020-02-27 04:17:37 -0600644 END
645
Vijaybc331e22020-02-27 04:17:37 -0600646
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500647Acquire Lock On Resource
648 [Documentation] Acquire lock on resource.
649 [Arguments] ${client_id} ${lock_type} ${reboot_flag}=False
Vijaybc331e22020-02-27 04:17:37 -0600650
651 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500652 # client_id This client id can contain string value
653 # (e.g. 12345, "HMCID").
654 # lock_type Read lock or Write lock.
655 # reboot_flag Flag is used to run reboot the BMC code.
656 # (e.g. True or False).
Vijaybc331e22020-02-27 04:17:37 -0600657
Sushil Singh8a3efe72021-08-26 08:16:41 -0500658 ${trans_id_emptylist}= Create List
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500659 ${trans_id_list}= Create List
Sushil Singh8a3efe72021-08-26 08:16:41 -0500660
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500661 ${session_info}= Create Redfish Session With ClientID ${client_id}
662 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
663 Append To List ${trans_id_list} ${trans_id}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500664
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500665 Verify Lock On Resource ${session_info} ${trans_id_list}
George Keishing566daaf2020-07-02 06:18:50 -0500666
Sushil Singhe33c6e62020-09-29 06:34:35 -0500667 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
Vijaybc331e22020-02-27 04:17:37 -0600668
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500669 Run Keyword If '${reboot_flag}' == 'True'
Sushil Singh8a3efe72021-08-26 08:16:41 -0500670 ... Run Keywords Redfish BMC Reset Operation AND
Sushil Singhe33c6e62020-09-29 06:34:35 -0500671 ... Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} AND
Sushil Singh07b25342022-09-20 09:29:07 -0500672 ... Wait Until Keyword Succeeds 3 min 10 sec Redfish BMC Match States match_state=Enabled AND
Sushil Singh8a3efe72021-08-26 08:16:41 -0500673 ... Is BMC Standby AND
674 ... Verify Lock On Resource ${session_info} ${trans_id_emptylist}
Vijaybc331e22020-02-27 04:17:37 -0600675
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500676 Run Keyword If '${reboot_flag}' == 'False'
677 ... Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600678
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500679 ${trans_id_emptylist}= Create List
680 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
681 Redfish Delete Session ${session_info}
Vijaybc331e22020-02-27 04:17:37 -0600682
Vijaybc331e22020-02-27 04:17:37 -0600683
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500684Form Data To Release Lock
685 [Documentation] Create a dictonay to release lock.
686 [Arguments] ${trans_id_list}
Vijay355daac2020-03-26 12:06:08 -0500687
688 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500689 # trans_id_list
Vijay355daac2020-03-26 12:06:08 -0500690
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500691 @{tran_ids}= Create List
Vijay355daac2020-03-26 12:06:08 -0500692
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500693 FOR ${item} IN @{trans_id_list}
694 Append To List ${tran_ids} ${item['TransactionID']}
695 END
696
697 [Return] ${tran_ids}
698
699
700Release Locks On Resource
701 [Documentation] Redfish request to release a lock.
Sushil Singh8a3efe72021-08-26 08:16:41 -0500702 [Arguments] ${session_info} ${trans_id_list} ${release_lock_type}=Transaction
703 ... ${status_code}=${HTTP_OK}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500704
705 # Description of argument(s):
706 # session_info Session information in dict.
707 # trans_id_list Transaction id list.
708 # release_lock_type Release lock by Transaction, Session.
709 # status_code HTTP status code.
710
711 ${tran_ids}= Form Data To Release Lock ${trans_id_list}
712 ${data}= Set Variable {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
713 ${data}= Evaluate json.dumps(${data}) json
714 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock data=${data}
715 Should Be Equal As Strings ${resp.status_code} ${status_code}
716
717
Sushil Singhdf390b62021-01-19 00:50:05 -0600718Release locks And Delete Session
719 [Documentation] Release locks and delete redfish session.
720 [Arguments] ${session_info} ${trans_id_list}
721
722 Release Locks On Resource ${session_info} ${trans_id_list}
723
724 ${trans_id_emptylist}= Create List
725 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
726
727 Redfish Delete Session ${session_info}
728
729
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500730Acquire Lock On Another Lock
731 [Documentation] Acquire lock on another lock.
732 [Arguments] ${client_id}
733
734 # Description of argument(s):
735 # client_id This client id can contain string value
736 # (e.g. 12345, "HMCID").
737
738 ${trans_id_list}= Create List
739 ${session_info}= Create Redfish Session With ClientID ${client_id}
740
741 ${trans_id}= Redfish Post Acquire Lock ReadCase1
742 Append To List ${trans_id_list} ${trans_id}
743
744 ${trans_id}= Redfish Post Acquire Lock ReadCase1
745 Append To List ${trans_id_list} ${trans_id}
746
747 Verify Lock On Resource ${session_info} ${trans_id_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500748
Sushil Singhdf390b62021-01-19 00:50:05 -0600749 Release locks And Delete Session ${session_info} ${trans_id_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500750
751
Sushil Singh977f8f52020-11-20 06:32:50 -0600752Verify Fail To Acquire Read And Write In Single Request
753 [Documentation] Verify fail to acquire read and write lock passed in single request.
Sushil Singhe3f2e3b2022-07-28 05:15:43 -0500754 [Arguments] ${client_id} ${lock_type} ${status_code}
755
756 # Description of argument(s):
757 # client_id This client id can contain string value
758 # (e.g. 12345, "HMCID").
759 # lock_type Read lock or Write lock.
760 # status_code HTTP status code
761
762 ${lock_type_list}= Split String ${lock_type} ,
763
764 ${session_info}= Create Redfish Session With ClientID ${client_id}
765 ${trans_id}= Redfish Post Acquire List Lock ${lock_type_list} status_code=${status_code}
766 Redfish Delete Session ${session_info}
767
768
769Verify Acquire Read In Single Request
770 [Documentation] Verify acquire read in single request.
Sushil Singh977f8f52020-11-20 06:32:50 -0600771 [Arguments] ${client_id} ${lock_type}
772
773 # Description of argument(s):
774 # client_id This client id can contain string value
775 # (e.g. 12345, "HMCID").
776 # lock_type Read lock or Write lock.
777
Sushil Singhe3f2e3b2022-07-28 05:15:43 -0500778 ${trans_id_list}= Create List
Sushil Singh977f8f52020-11-20 06:32:50 -0600779 ${lock_type_list}= Split String ${lock_type} ,
780
781 ${session_info}= Create Redfish Session With ClientID ${client_id}
Sushil Singhe3f2e3b2022-07-28 05:15:43 -0500782 ${trans_id}= Redfish Post Acquire List Lock ${lock_type_list}
783 Append To List ${trans_id_list} ${trans_id}
784 Append To List ${trans_id_list} ${trans_id}
785
786 Verify Lock On Resource ${session_info} ${trans_id_list}
787 Remove From List ${trans_id_list} 1
788 Release Locks On Resource ${session_info} ${trans_id_list}
789
Sushil Singh977f8f52020-11-20 06:32:50 -0600790 Redfish Delete Session ${session_info}
791
792
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500793Verify Empty Lock Records For Invalid Session
794 [Documentation] Verify no lock record found for invalid session.
795 [Arguments] ${client_id}
796
797 # Description of argument(s):
798 # client_id This client id can contain string value
799 # (e.g. 12345, "HMCID").
800
801 ${session_info1}= Create Redfish Session With ClientID ${client_id}
802
803 ${lock_list1}= Get Locks List On Resource ${session_info1}
804 ${lock_length1}= Get Length ${lock_list1}
805
806 ${session_info2}= Copy Dictionary ${session_info1} deepcopy=True
807 set to dictionary ${session_info2} SessionIDs xxyXyyYZZz
808
809 ${lock_list2}= Get Locks List On Resource ${session_info2}
Sushil Singhf9a536c2020-11-09 07:33:17 -0600810 ${lock_length2}= Get Length ${lock_list2}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500811
Sushil Singhf9a536c2020-11-09 07:33:17 -0600812 Should Be Equal As Integers ${lock_length1} ${lock_length2}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500813
814 Redfish Delete Session ${session_info1}
815
816
817Verify Acquire Lock Fails On Another Lock
818 [Documentation] Verify acquire lock on another lock fails.
819 [Arguments] ${client_id} ${lock_type}
820
821 # Description of argument(s):
822 # client_id This client id can contain string value
823 # (e.g. 12345, "HMCID").
824 # lock_type Read lock or Write lock.
825
826 @{lock_type_list}= Split String ${lock_type} ,
827 ${session_info}= Create Redfish Session With ClientID ${client_id}
828 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
829
830 ${trans_id_list}= Create List
831 Append To List ${trans_id_list} ${trans_id}
832
833 Verify Lock On Resource ${session_info} ${trans_id_list}
834 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1] status_code=${HTTP_CONFLICT}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500835
Sushil Singhdf390b62021-01-19 00:50:05 -0600836 Release locks And Delete Session ${session_info} ${trans_id_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500837
838
Sushil Singhe33c6e62020-09-29 06:34:35 -0500839Verify Acquire Lock After Reboot
840 [Documentation] Acquire read and write lock after the reboot and release lock.
841 [Arguments] ${client_id} ${lock_type}
842
843 # Description of argument(s):
844 # client_id This client id can contain string value
845 # (e.g. 12345, "HMCID").
846 # lock_type Read lock or Write lock.
847
848 ${trans_id_list}= Create List
Sushil Singhf9a536c2020-11-09 07:33:17 -0600849 ${session_info}= Create Session With ClientID ${client_id}
Sushil Singhac229c72021-09-13 02:26:51 -0500850
Sushil Singhe33c6e62020-09-29 06:34:35 -0500851 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
Sushil Singhac229c72021-09-13 02:26:51 -0500852 Redfish BMC Reset Operation
Sushil Singhe33c6e62020-09-29 06:34:35 -0500853 Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token}
Sushil Singh07b25342022-09-20 09:29:07 -0500854 Wait Until Keyword Succeeds 3 min 10 sec Redfish BMC Match States match_state=Enabled
Sushil Singhac229c72021-09-13 02:26:51 -0500855 Is BMC Standby
Sushil Singhe33c6e62020-09-29 06:34:35 -0500856
857 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
858 Append To List ${trans_id_list} ${trans_id}
859 Verify Lock On Resource ${session_info} ${trans_id_list}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500860
Sushil Singhdf390b62021-01-19 00:50:05 -0600861 Release locks And Delete Session ${session_info} ${trans_id_list}
862
863
864Verify Acquire Multiple Lock Request At CEC Level
865 [Documentation] Acquire lock in loop.
866 [Arguments] ${client_id} ${lock_type}
867
868 # Description of argument(s):
869 # client_id This client id can contain string value
870 # (e.g. 12345, "HMCID").
871 # lock_type Read lock or Write lock.
872
873 ${trans_id_list}= Create List
874 @{lock_type_list}= Split String ${lock_type} ,
875 ${session_info}= Create Redfish Session With ClientID ${client_id}
876
877 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
878 Append To List ${trans_id_list} ${trans_id}
879
880 Verify Lock On Resource ${session_info} ${trans_id_list}
881
882 Redfish Post Acquire Lock ${lock_type_list}[1] status_code=${HTTP_CONFLICT}
883
884 Release locks And Delete Session ${session_info} ${trans_id_list}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500885
886
Sushil Singh8d420bf2021-09-06 08:27:41 -0500887Post Reboot Acquire Lock
888 [Documentation] Post reboot acquire lock and verify the transaction id is 1.
889 [Arguments] ${session_info} ${lock_type}
890
891 # Description of argument(s):
892 # session_info Session information.
893 # lock_type Read lock or Write lock.
894
895 ${trans_id_list}= Create List
896 ${trans_id_list_var}= Create List
897 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
898 Append To List ${trans_id_list} ${trans_id}
899 Append To List ${trans_id_list_var} ${default_trans_id}
900 Verify Lock On Resource ${session_info} ${trans_id_list}
901 Verify Lock On Resource ${session_info} ${trans_id_list_var}
902 Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
903 ${trans_id_emptylist}= Create List
904 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
905
906
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500907Verify Acquire And Release Lock In Loop
908 [Documentation] Acquire lock in loop.
Sushil Singh8d420bf2021-09-06 08:27:41 -0500909 [Arguments] ${client_id} ${lock_type} ${reboot_flag}=False
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500910
911 # Description of argument(s):
912 # client_id This client id can contain string value
913 # (e.g. 12345, "HMCID").
914 # lock_type Read lock or Write lock.
Sushil Singh8d420bf2021-09-06 08:27:41 -0500915 # reboot_flag Flag is used to run reboot the BMC code.
916 # (e.g. True or False).
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500917
918 FOR ${count} IN RANGE 1 11
919 ${trans_id_list}= Create List
920 ${session_info}= Create Redfish Session With ClientID ${client_id}
921 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
922 Append To List ${trans_id_list} ${trans_id}
923 Verify Lock On Resource ${session_info} ${trans_id_list}
924 Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
925 ${trans_id_emptylist}= Create List
926 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
Sushil Singh8d420bf2021-09-06 08:27:41 -0500927 Redfish Delete Session ${session_info}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500928 END
929
Sushil Singh8d420bf2021-09-06 08:27:41 -0500930 ${session_info}= Create Redfish Session With ClientID ${client_id}
931 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
932
933 Run Keyword If '${reboot_flag}' == 'True'
934 ... Run Keywords Redfish BMC Reset Operation AND
935 ... Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} AND
Sushil Singh07b25342022-09-20 09:29:07 -0500936 ... Wait Until Keyword Succeeds 3 min 10 sec Redfish BMC Match States match_state=Enabled AND
Sushil Singh8d420bf2021-09-06 08:27:41 -0500937 ... Is BMC Standby AND
938 ... Post Reboot Acquire Lock ${session_info} ${lock_type}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500939 Redfish Delete Session ${session_info}
940
941
942Acquire And Release Multiple Locks
George Keishing9bfdf8a2024-04-19 11:09:07 +0530943 [Documentation] Acquire multiple locks on resource.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500944 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
945
946 # Description of argument(s):
947 # client_id This client id can contain string value
948 # (e.g. 12345, "HMCID").
949 # lock_type Read lock or Write lock.
950 # release_lock_type The value can be Transaction or Session.
951
952 @{lock_type_list}= Split String ${lock_type} ,
953 ${session_info}= Create Redfish Session With ClientID ${client_id}
954 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
955
956 ${trans_id_list}= Create List
957
958 Append To List ${trans_id_list} ${trans_id}
959 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
960
961 Append To List ${trans_id_list} ${trans_id}
962 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2]
963
964 Append To List ${trans_id_list} ${trans_id}
965 Verify Lock On Resource ${session_info} ${trans_id_list}
966 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=${release_lock_type}
967
968 ${trans_id_emptylist}= Create List
969 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
970 Redfish Delete Session ${session_info}
971
972
susilsi794116c62021-03-04 07:57:51 -0600973Verify Release Lock When Session Deleted
974 [Documentation] Verify lock get released when session are deleted.
975 [Arguments] ${client_id} ${lock_type}
976
977 # Description of argument(s):
978 # client_ids This client id can contain string value
979 # (e.g. 12345, "HMCID").
980 # lock_type Read lock or Write lock.
981
982 ${trans_id_list}= Create List
983 @{lock_type_list}= Split String ${lock_type} ,
984
985 ${pre_session_info}= Create Redfish Session With ClientID ${client_id}
986
987 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
988 Append To List ${trans_id_list} ${trans_id}
989 Verify Lock On Resource ${pre_session_info} ${trans_id_list}
990
991 Redfish Delete Session ${pre_session_info}
992 ${post_session_info}= Create Redfish Session With ClientID ${client_id}
993 ${resp}= Get Locks List On Resource With Session List ${pre_session_info} ${HTTP_BAD_REQUEST}
994
995 Redfish Delete Session ${post_session_info}
996
997
998
Sushil Singh59011d02021-01-27 23:00:20 -0600999Verify Fail To Release Lock With Invalid TransactionID
George Keishing16b3c7b2021-01-28 09:23:37 -06001000 [Documentation] Verify fail to be release lock with invalid transaction ID.
Sushil Singh59011d02021-01-27 23:00:20 -06001001 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
1002
1003 # Description of argument(s):
1004 # client_id This client id can contain string value
1005 # (e.g. 12345, "HMCID").
1006 # lock_type Read lock or Write lock.
1007 # release_lock_type The value can be Transaction or Session.
1008
1009 ${trans_id_list}= Create List
1010 @{lock_type_list}= Split String ${lock_type} ,
1011
1012 ${session_info}= Create Redfish Session With ClientID ${client_id}
1013
1014 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1015 ${value}= Get From Dictionary ${trans_id} TransactionID
1016 ${value}= Evaluate ${value} + 10
1017 Set To Dictionary ${trans_id} TransactionID ${value}
1018 Append To List ${trans_id_list} ${trans_id}
1019
1020 Release Locks On Resource
1021 ... ${session_info} ${trans_id_list}
1022 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
1023 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session
1024
1025 ${trans_id_emptylist}= Create List
1026 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1027 Redfish Delete Session ${session_info}
1028
1029
Sushil Singh1b590532021-01-20 05:13:54 -06001030Verify Fail To Release Multiple Lock With Invalid TransactionID
1031 [Documentation] Verify release multiple locks with invalid transaction ID fails.
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001032 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
1033
1034 # Description of argument(s):
1035 # client_id This client id can contain string value
1036 # (e.g. 12345, "HMCID").
1037 # lock_type Read lock or Write lock.
1038 # release_lock_type The value can be Transaction or Session.
1039
1040 ${trans_id_list}= Create List
1041 @{lock_type_list}= Split String ${lock_type} ,
1042
1043 ${session_info}= Create Redfish Session With ClientID ${client_id}
1044
1045 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1046 ${value}= Get From Dictionary ${trans_id} TransactionID
1047 ${value}= Evaluate ${value} + 10
1048 Set To Dictionary ${trans_id} TransactionID ${value}
1049 Append To List ${trans_id_list} ${trans_id}
1050
1051 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
1052 ${value}= Get From Dictionary ${trans_id} TransactionID
1053 ${value}= Evaluate ${value} + 10
1054 Set To Dictionary ${trans_id} TransactionID ${value}
1055 Append To List ${trans_id_list} ${trans_id}
1056
1057 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2]
1058 ${value}= Get From Dictionary ${trans_id} TransactionID
1059 ${value}= Evaluate ${value} + 10
1060 Set To Dictionary ${trans_id} TransactionID ${value}
1061 Append To List ${trans_id_list} ${trans_id}
1062
1063 Release Locks On Resource
1064 ... ${session_info} ${trans_id_list}
1065 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
1066 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session
1067
1068 ${trans_id_emptylist}= Create List
1069 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1070 Redfish Delete Session ${session_info}
1071
1072
Sushil Singh8bee3582021-01-27 23:46:48 -06001073Verify Fail To Release Multiple Lock With Valid And Invalid TransactionID
George Keishing96143832021-03-23 07:55:08 -05001074 [Documentation] Verify fail to be release multiple lock with valid and invalid transaction ID.
Sushil Singh8bee3582021-01-27 23:46:48 -06001075 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
1076
1077 # Description of argument(s):
1078 # client_id This client id can contain string value
1079 # (e.g. 12345, "HMCID").
1080 # lock_type Read lock or Write lock.
1081 # release_lock_type The value can be Transaction or Session.
1082
1083 ${trans_id_list}= Create List
1084 @{lock_type_list}= Split String ${lock_type} ,
1085
1086 ${session_info}= Create Redfish Session With ClientID ${client_id}
1087
1088 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1089 Append To List ${trans_id_list} ${trans_id}
1090
1091 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
1092 ${value}= Get From Dictionary ${trans_id} TransactionID
1093 ${value}= Evaluate ${value} + 10
1094 Set To Dictionary ${trans_id} TransactionID ${value}
1095 Append To List ${trans_id_list} ${trans_id}
1096
1097 Release Locks On Resource
1098 ... ${session_info} ${trans_id_list}
1099 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
1100 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session
1101
1102 ${trans_id_emptylist}= Create List
1103 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1104 Redfish Delete Session ${session_info}
1105
1106
susilsi71d7b9962021-03-02 03:06:18 -06001107Verify Fail To Release Lock With TransactionID As String Type
George Keishing96143832021-03-23 07:55:08 -05001108 [Documentation] Verify fail to be release lock with transaction ID as string data type.
susilsi71d7b9962021-03-02 03:06:18 -06001109 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
1110
1111 # Description of argument(s):
1112 # client_id This client id can contain string value
1113 # (e.g. 12345, "HMCID").
1114 # lock_type Read lock or Write lock.
1115 # release_lock_type The value can be Transaction or Session.
1116
1117 ${trans_id_list}= Create List
1118 @{lock_type_list}= Split String ${lock_type} ,
1119
1120 ${session_info}= Create Redfish Session With ClientID ${client_id}
1121
1122 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1123
1124 Append To List ${trans_id_list} ${trans_id}
1125
Sushil Singhf4de7d72023-07-21 08:59:20 -05001126 ${temp_trans_id_list}= Copy List ${trans_id_list} deepcopy=True
susilsi71d7b9962021-03-02 03:06:18 -06001127
1128 ${value}= Get From Dictionary ${trans_id_list}[0] TransactionID
1129 ${value}= Set Variable \'${value}\'
1130 Set To Dictionary ${temp_trans_id_list}[0] TransactionID ${value}
1131
1132 Release Locks On Resource
1133 ... ${session_info} ${temp_trans_id_list}
1134 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
1135
1136 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=${release_lock_type}
1137
1138 ${trans_id_emptylist}= Create List
1139 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1140 Redfish Delete Session ${session_info}
1141
1142
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001143Verify Fail To Release Lock For Another Session
1144 [Documentation] Verify failed to release the lock form another session.
1145 [Arguments] ${client_id} ${lock_type}
1146
1147 # Description of argument(s):
1148 # client_id This client id can contain string value
1149 # (e.g. 12345, "HMCID").
1150 # lock_type Read lock or Write lock.
1151
1152 ${client_ids}= Split String ${client_id} ,
1153 ${lock_type_list}= Split String ${lock_type} ,
1154 ${trans_id_list1}= Create List
1155 ${trans_id_list2}= Create List
1156
1157 ${session_info1}= Create Redfish Session With ClientID ${client_ids}[0]
1158
1159 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1160 Append To List ${trans_id_list1} ${trans_id}
1161 Verify Lock On Resource ${session_info1} ${trans_id_list1}
1162
1163 ${session_info2}= Create Redfish Session With ClientID ${client_ids}[1]
1164 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
1165 Append To List ${trans_id_list2} ${trans_id}
1166 Verify Lock On Resource ${session_info2} ${trans_id_list2}
1167
1168 Release Locks On Resource
Sushil Singhe3f2e3b2022-07-28 05:15:43 -05001169 ... ${session_info1} ${trans_id_list1} Transaction status_code=${HTTP_BAD_REQUEST}
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001170 Verify Lock On Resource ${session_info1} ${trans_id_list1}
1171 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Session
1172 Release Locks On Resource ${session_info2} ${trans_id_list2} release_lock_type=Session
1173 Redfish Delete Session ${session_info1}
1174 Redfish Delete Session ${session_info2}
1175
1176
Sushil Singhe33c6e62020-09-29 06:34:35 -05001177Verify Fail To Acquire Lock For Invalid Resource ID Data Type
1178 [Documentation] Verify fail to acquire the lock with invalid resource id data type.
1179 [Arguments] ${client_id} ${lock_type}
1180
1181 # Description of argument(s):
1182 # client_id This client id can contain string value
1183 # (e.g. 12345, "HMCID").
1184 # lock_type Read lock or Write lock.
1185
1186 ${session_info}= Create Redfish Session With ClientID ${client_id}
1187 Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
1188 ... ${lock_type} status_code=${HTTP_BAD_REQUEST}
1189 Redfish Delete Session ${session_info}
1190
1191
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001192Verify Fail To Acquire Lock For Invalid Lock Data
George Keishing16b3c7b2021-01-28 09:23:37 -06001193 [Documentation] Verify fail to acquired lock with invalid lock types, lock flags, segment flags.
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001194 [Arguments] ${client_id} ${lock_type} ${message}
1195
1196 # Description of argument(s):
1197 # client_id This client id can contain string value
1198 # (e.g. 12345, "HMCID").
1199 # lock_type Read lock or Write lock.
1200 # message Return message from URI.
1201
1202 ${session_info}= Create Redfish Session With ClientID ${client_id}
Sushil Singh8a3efe72021-08-26 08:16:41 -05001203 ${trans_id}= Redfish Post Acquire Invalid Lock
1204 ... ${lock_type} message=${message} status_code=${HTTP_BAD_REQUEST}
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001205 Redfish Delete Session ${session_info}
Sushil Singhbace3002020-10-08 08:12:58 -05001206
1207
1208Verify No Locks Records For Session With No Acquired Lock
1209 [Documentation] Verify no records found for a session where no lock is acquired.
1210 [Arguments] ${client_id}
1211
1212 # Description of argument(s):
1213 # client_id This client id can contain string value
1214 # (e.g. 12345, "HMCID").
1215
1216 ${session_info}= Create Redfish Session With ClientID ${client_id}
1217 ${trans_id_emptylist}= Create List
1218 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1219 Redfish Delete Session ${session_info}
Sushil Singh728ef9c2020-10-28 04:25:39 -05001220
1221
1222Create List Of Session ID
1223 [Documentation] Create session id list from session dict info.
1224 [Arguments] ${session_dict_info}
1225
1226 # Description of argument(s):
1227 # session_dict_info Session information in dict.
1228
1229 @{session_id_list}= Create List
1230
1231 FOR ${session} IN @{session_dict_info}
1232 Append To List ${session_id_list} ${session["SessionIDs"]}
1233 END
1234
1235 ${num_id}= Get Length ${session_id_list}
1236 Should Not Be Equal As Integers ${num_id} ${0}
1237
1238 ${session_id_list}= Evaluate json.dumps(${session_id_list}) json
1239
1240 [Return] ${session_id_list}
1241
1242
1243Get Locks List On Resource With Session List
1244 [Documentation] Get locks list from session of list.
1245 [Arguments] ${session_id_list} ${exp_status_code}=${HTTP_OK}
1246
1247 # Description of argument(s):
1248 # session_id_list Session ids list.
1249 # exp_status_code Expected HTTP status code.
1250
1251 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
George Keishingfbd67002022-08-01 11:24:03 -05001252 ... data={"SessionIDs":${session_id_list}} expected_status=any
susilsi794116c62021-03-04 07:57:51 -06001253 Should Be Equal As Strings ${resp.status_code} ${exp_status_code}
Sushil Singh728ef9c2020-10-28 04:25:39 -05001254 ${locks}= Evaluate json.loads('''${resp.text}''') json
1255
1256 [Return] ${locks}
1257
1258
1259Verify List Of Session Lock On Resource
1260 [Documentation] Verify list of lock record from list of sessions.
1261 [Arguments] ${session_dict_info} ${transaction_id_list}
1262
1263 # Description of argument(s):
1264 # session_dict_info Session information in dict.
1265 # transaction_id_list Transaction id in list stored in dict.
1266
1267 ${session_id_list}= Create List Of Session ID ${session_dict_info}
1268 ${lock_list_resp}= Get Locks List On Resource With Session List ${session_id_list}
1269 ${lock_list}= Set Variable ${lock_list_resp['Records']}
1270
Sushil Singh8a3efe72021-08-26 08:16:41 -05001271 FOR ${session_id} ${tran_id} ${lock_record} IN ZIP
1272 ... ${session_dict_info} ${transaction_id_list} ${lock_list}
Sushil Singh728ef9c2020-10-28 04:25:39 -05001273 Valid Value session_id['SessionIDs'] ['${lock_record['SessionID']}']
1274 Should Be Equal As Integers ${tran_id['TransactionID']} ${lock_record['TransactionID']}
1275 END
1276
1277
1278Verify Lock Records Of Multiple Session
1279 [Documentation] Verify all records found for a multiple sessions.
1280 [Arguments] ${client_ids} ${lock_type}
1281
1282 # Description of argument(s):
1283 # client_ids This client id can contain string value
1284 # (e.g. 12345, "HMCID").
1285 # lock_type Read lock or Write lock.
1286
1287 ${client_id_list}= Split String ${client_ids} ,
1288 ${lock_type_list}= Split String ${lock_type} ,
1289 ${trans_id_list1}= Create List
1290 ${trans_id_list2}= Create List
1291
1292 ${session_dict_list}= Create List
1293 ${lock_list}= Create List
1294
1295 ${client_id1}= Create List
1296 Append To List ${client_id1} ${client_id_list}[0]
1297 ${session_info1}= Create Session With List Of ClientID ${client_id1}
1298 Append To List ${session_dict_list} ${session_info1}[0]
1299 Verify A Session Created With ClientID ${client_id1} ${session_info1}
1300
1301 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1302 Append To List ${trans_id_list1} ${trans_id}
1303 Append To List ${lock_list} ${trans_id}
1304 Verify Lock On Resource ${session_info1}[0] ${trans_id_list1}
1305
1306
1307 ${client_id2}= Create List
1308 Append To List ${client_id2} ${client_id_list}[1]
1309 ${session_info2}= Create Session With List Of ClientID ${client_id2}
1310 Append To List ${session_dict_list} ${session_info2}[0]
1311 Verify A Session Created With ClientID ${client_id2} ${session_info2}
1312
1313 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
1314 Append To List ${trans_id_list2} ${trans_id}
1315 Append To List ${lock_list} ${trans_id}
1316 Verify Lock On Resource ${session_info2}[0] ${trans_id_list2}
1317
1318 Verify List Of Session Lock On Resource ${session_dict_list} ${lock_list}
1319
1320 ${session_token}= Get From Dictionary ${session_info1}[0] SessionToken
1321 Set Global Variable ${XAUTH_TOKEN} ${session_token}
1322
1323 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Transaction
1324
1325 ${session_token}= Get From Dictionary ${session_info2}[0] SessionToken
1326 Set Global Variable ${XAUTH_TOKEN} ${session_token}
1327
1328 Release Locks On Resource ${session_info2} ${trans_id_list2} release_lock_type=Transaction
1329
1330 ${trans_id_emptylist}= Create List
1331 Verify Lock On Resource ${session_info1}[0] ${trans_id_emptylist}
1332 Verify Lock On Resource ${session_info2}[0] ${trans_id_emptylist}
1333
1334 Redfish Delete List Of Session ${session_dict_list}
Sushil Singhf9a536c2020-11-09 07:33:17 -06001335
1336
1337Verify Lock Records For Multiple Invalid Session
1338 [Documentation] Verify no lock record found for multiple invalid session.
1339 [Arguments] ${client_id}
1340
1341 # Description of argument(s):
1342 # client_id This client id can contain string value
1343 # (e.g. 12345, "HMCID").
1344
1345 ${session_dict_list}= Create List
1346 ${invalid_session_ids}= Create List xxyXyyYZZz xXyXYyYZzz
1347
1348 ${session_info1}= Create Session With ClientID ${client_id}
1349
1350 ${session_info2}= Copy Dictionary ${session_info1} deepcopy=True
1351 set to dictionary ${session_info2} SessionIDs ${invalid_session_ids}[0]
1352 Append To List ${session_dict_list} ${session_info2}
1353
1354 ${session_info3}= Copy Dictionary ${session_info1} deepcopy=True
1355 set to dictionary ${session_info3} SessionIDs ${invalid_session_ids}[0]
1356 Append To List ${session_dict_list} ${session_info3}
1357
1358 ${lock_list1}= Get Locks List On Resource ${session_info1}
1359 ${lock_length1}= Get Length ${lock_list1}
1360
1361 ${session_id_list}= Create List Of Session ID ${session_dict_list}
1362 ${lock_list_resp}= Get Locks List On Resource With Session List ${session_id_list}
1363 ${lock_length2}= Get Length ${lock_list_resp['Records']}
1364
1365 Should Be Equal As Integers ${lock_length1} ${lock_length2}
1366
1367 Redfish Delete Session ${session_info1}
Sushil Singh11949a22020-11-13 06:12:16 -06001368
1369
1370Verify Lock Records For Multiple Invalid And Valid Session
1371 [Documentation] Verify all records found for a valid and invalid sessions.
1372 [Arguments] ${client_ids} ${lock_type}
1373
1374 # Description of argument(s):
1375 # client_ids This client id can contain string value
1376 # (e.g. 12345, "HMCID").
1377 # lock_type Read lock or Write lock.
1378
1379 ${client_id_list}= Split String ${client_ids} ,
1380 ${lock_type_list}= Split String ${lock_type} ,
1381 ${trans_id_list1}= Create List
1382 ${invalid_session_ids}= Create List xxyXyyYZZz
1383
1384 ${session_dict_list}= Create List
1385 ${lock_list}= Create List
1386
1387 ${client_id1}= Create List
1388 Append To List ${client_id1} ${client_id_list}[0]
1389 ${session_info1}= Create Session With List Of ClientID ${client_id1}
1390 Append To List ${session_dict_list} ${session_info1}[0]
1391 Verify A Session Created With ClientID ${client_id1} ${session_info1}
1392
1393 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1394 Append To List ${trans_id_list1} ${trans_id}
1395 Append To List ${lock_list} ${trans_id}
1396 Verify Lock On Resource ${session_info1}[0] ${trans_id_list1}
1397
Sushil Singhf4de7d72023-07-21 08:59:20 -05001398 ${session_info2}= Copy List ${session_info1} deepcopy=True
Sushil Singh11949a22020-11-13 06:12:16 -06001399 set to dictionary ${session_info2}[0] SessionIDs ${invalid_session_ids}[0]
1400 Append To List ${session_dict_list} ${session_info2}[0]
1401
1402 Verify List Of Session Lock On Resource ${session_dict_list} ${lock_list}
1403
1404 ${session_token}= Get From Dictionary ${session_info1}[0] SessionToken
1405 Set Global Variable ${XAUTH_TOKEN} ${session_token}
1406
1407 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Transaction
1408
1409 ${trans_id_emptylist}= Create List
1410 Verify Lock On Resource ${session_info1}[0] ${trans_id_emptylist}
1411
1412 Redfish Delete Session ${session_info1}[0]
George Keishing7e49fd52022-12-22 03:11:37 -06001413
1414
1415Delete All Redfish and HMC Sessions
1416 [Documentation] Delete all active redfish sessions.
1417
1418 ${saved_session_info}= Get Redfish Session Info
1419
1420 ${resp_list}= Redfish_Utils.Get Member List
1421 ... /redfish/v1/SessionService/Sessions
1422
1423 # Remove the current login session from the list.
1424 Remove Values From List ${resp_list} ${saved_session_info["location"]}
1425
1426 FOR ${session} IN @{resp_list}
1427 Run Keyword And Ignore Error Redfish.Delete ${session}
1428 END
1429
1430
1431Restart Bmcweb On Failure
1432 [Documentation] Restart bmcweb only if test failed.
1433
1434 Return From Keyword If "${TEST_STATUS}" == "PASS"
1435
1436 # This procedure is needs to be corrected or removed, when we figure out
1437 # what is causing the real failure here.
1438
1439 Log To Console Likely ConnectionResetError: Restarting bmcweb
1440
1441 ${stdout} ${stderr} ${rc}= BMC Execute Command
1442 ... systemctl restart bmcweb print_out=1
1443
1444 Should Be Empty ${stderr}
1445
1446 Sleep 10s reason=Wait for service to restart properly.