blob: 0e9b6ab8240ad71b85d69f3de8ee2375ceed8adc [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
18*** Variables ***
19
Sushil Singhe3f2e3b2022-07-28 05:15:43 -050020${CONFLICT_RQUEST} Conflict
Sushil Singh8d420bf2021-09-06 08:27:41 -050021${BAD_REQUEST} Bad Request
22&{default_trans_id} TransactionID=${1}
Vijaybc331e22020-02-27 04:17:37 -060023
24*** Test Cases ***
25
Sushil Singhd03f2ce2020-09-17 08:54:41 -050026Acquire Read Write Lock
Vijaybc331e22020-02-27 04:17:37 -060027 [Documentation] Acquire and release different read locks.
Sushil Singhd03f2ce2020-09-17 08:54:41 -050028 [Tags] Acquire_Read_Write_Lock
29 [Template] Acquire Lock On Resource
Vijaybc331e22020-02-27 04:17:37 -060030
Sushil Singhd03f2ce2020-09-17 08:54:41 -050031 # client_id lock_type reboot_flag
32 HMCID-01 ReadCase1 False
33 HMCID-01 ReadCase2 False
34 HMCID-01 ReadCase3 False
35 HMCID-01 WriteCase1 False
36 HMCID-01 WriteCase2 False
37 HMCID-01 WriteCase3 False
Vijaybc331e22020-02-27 04:17:37 -060038
39
Sushil Singhd03f2ce2020-09-17 08:54:41 -050040Acquire Read Lock On Read Lock
41 [Documentation] Acquire read lock on another read lock.
42 [Tags] Acquire_Read_Lock_On_Read_Lock
43 [Template] Acquire Lock On Another Lock
Vijaybc331e22020-02-27 04:17:37 -060044
Sushil Singhd03f2ce2020-09-17 08:54:41 -050045 # client_id
46 HMCID-01
Vijaybc331e22020-02-27 04:17:37 -060047
48
Sushil Singhd03f2ce2020-09-17 08:54:41 -050049Fail To Acquire Lock On Another Lock
50 [Documentation] Fail to acquire another lock.
51 [Tags] Fail_To_Acquire_Lock_On_Another_Lock
52 [Template] Verify Acquire Lock Fails On Another Lock
Vijay85610ee2020-04-03 05:30:28 -050053
Sushil Singhd03f2ce2020-09-17 08:54:41 -050054 # client_id lock_type
Sushil Singh5d059942021-09-27 08:41:38 -050055 HMCID-01 ReadCase7,WriteCase6
56 HMCID-01 WriteCase6,WriteCase6
57 HMCID-01 WriteCase6,ReadCase7
George Keishing566daaf2020-07-02 06:18:50 -050058
59
Sushil Singhe33c6e62020-09-29 06:34:35 -050060Acquire Lock After Reboot
61 [Documentation] Acquire and release read and write locks after reboot.
62 [Tags] Acquire_Lock_After_Reboot
63 [Template] Verify Acquire Lock After Reboot
64
65 # client_id lock_type
66 HMCID-01 ReadCase1
67 HMCID-01 ReadCase2
68 HMCID-01 ReadCase3
69 HMCID-01 WriteCase1
70 HMCID-01 WriteCase2
71 HMCID-01 WriteCase3
72
73
Sushil Singhd03f2ce2020-09-17 08:54:41 -050074Acquire And Release Lock In Loop
75 [Documentation] Acquire and release read, write locks in loop.
76 [Tags] Acquire_And_Release_Lock_In_Loop
77 [Template] Verify Acquire And Release Lock In Loop
George Keishing566daaf2020-07-02 06:18:50 -050078
Sushil Singhd03f2ce2020-09-17 08:54:41 -050079 # client_id lock_type
80 HMCID-01 ReadCase1
81 HMCID-01 ReadCase2
82 HMCID-01 ReadCase3
83 HMCID-01 WriteCase1
84 HMCID-01 WriteCase2
85 HMCID-01 WriteCase3
Vijay85610ee2020-04-03 05:30:28 -050086
87
Sushil Singh977f8f52020-11-20 06:32:50 -060088Fail To Acquire Read And Write In Single Request
89 [Documentation] Fail to acquire read and write lock in single request.
90 [Tags] Fail_To_Acquire_Read_And_Write_In_Single_Request
91 [Template] Verify Fail To Acquire Read And Write In Single Request
92
Sushil Singhe3f2e3b2022-07-28 05:15:43 -050093 # client_id lock_type status_code
94 HMCID-01 ReadCase1,WriteCase1 ${HTTP_CONFLICT}
95 HMCID-01 WriteCase1,ReadCase1 ${HTTP_CONFLICT}
96 HMCID-01 WriteCase1,WriteCase1 ${HTTP_CONFLICT}
97
98
99Acquire Read In Single Request
100 [Documentation] Acquire read in single request.
101 [Tags] Acquire_Read_In_Single_Request
102 [Template] Verify Acquire Read In Single Request
103
Sushil Singh977f8f52020-11-20 06:32:50 -0600104 # client_id lock_type
Sushil Singhe3f2e3b2022-07-28 05:15:43 -0500105 HMCID-01 ReadCase1,ReadCase1
Sushil Singh977f8f52020-11-20 06:32:50 -0600106
107
Sushil Singhdf390b62021-01-19 00:50:05 -0600108Acquire Multiple Lock Request At CEC Level
109 [Documentation] Acquire write lock on read lock under CEC level.
110 [Tags] Acquire_Multiple_Lock_Request_At_CEC_Level
111 [Template] Verify Acquire Multiple Lock Request At CEC Level
112
113 # client_id lock_type
114 HMCID-01 ReadCase4,WriteCase4
115 HMCID-01 WriteCase5,ReadCase5
116 HMCID-01 ReadCase6,WriteCase6
117 HMCID-01 WriteCase7,ReadCase7
118
119
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500120Verify Release Of Valid Locks
121 [Documentation] Release all valid locks.
122 [Tags] Verify_Release_Of_Valid_Locks
123 [Template] Acquire And Release Multiple Locks
Vijayafdd2a12020-04-09 02:03:20 -0500124
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500125 # client_id lock_type release_lock_type
126 HMCID-01 ReadCase1,ReadCase1,ReadCase1 Transaction
127 HMCID-02 ReadCase1,ReadCase1,ReadCase1 Session
Vijayafdd2a12020-04-09 02:03:20 -0500128
129
susilsi794116c62021-03-04 07:57:51 -0600130Release Lock When Session Deleted
131 [Documentation] Release lock when session gets deleted.
132 [Tags] Release_Lock_When_Session_Deleted
133 [Template] Verify Release Lock When Session Deleted
134
135 # client_id lock_type
136 HMCID-01 ReadCase1
137 HMCID-01 WriteCase1
138
139
Sushil Singh59011d02021-01-27 23:00:20 -0600140Fail To Release Lock With Invalid TransactionID
141 [Documentation] Fail to release lock with invalid transaction id.
142 [Tags] Fail_To_Release_Lock_With_Invalid_TransactionID
143 [Template] Verify Fail To Release Lock With Invalid TransactionID
144
susilsi743b0c062021-03-02 04:24:19 -0600145 # client_id lock_type release_lock_type
146 HMCID-01 ReadCase1 Transaction
147 HMCID-01 WriteCase1 Transaction
Sushil Singh59011d02021-01-27 23:00:20 -0600148
149
Sushil Singh1b590532021-01-20 05:13:54 -0600150Fail To Release Multiple Lock With Invalid TransactionID
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500151 [Documentation] Release in-valid lock result in fail.
Sushil Singh1b590532021-01-20 05:13:54 -0600152 [Tags] Fail_To_Release_Multiple_Lock_With_Invalid_TransactionID
153 [Template] Verify Fail To Release Multiple Lock With Invalid TransactionID
Vijayafdd2a12020-04-09 02:03:20 -0500154
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500155 # client_id lock_type release_lock_type
156 HMCID-01 ReadCase1,ReadCase1,ReadCase1 Transaction
157 12345 ReadCase2,ReadCase2,ReadCase2 Transaction
158 HMCID ReadCase3,ReadCase3,ReadCase3 Transaction
Vijayafdd2a12020-04-09 02:03:20 -0500159
160
Sushil Singh8bee3582021-01-27 23:46:48 -0600161Fail To Release Multiple Lock With Valid And Invalid TransactionID
George Keishing96143832021-03-23 07:55:08 -0500162 [Documentation] Release multiple lock with valid and invalid transaction.
Sushil Singh8bee3582021-01-27 23:46:48 -0600163 [Tags] Fail_To_Release_Multiple_Lock_With_Valid_And_Invalid_TransactionID
164 [Template] Verify Fail To Release Multiple Lock With Valid And Invalid TransactionID
165
166 # client_id lock_type release_lock_type
167 HMCID-01 ReadCase1,ReadCase1 Transaction
168
169
susilsi71d7b9962021-03-02 03:06:18 -0600170Fail To Release Lock With String As TransactionID Data Type
171 [Documentation] Fail to release lock with string as transaction id data type.
172 [Tags] Fail_To_Release_Lock_With_String_As_TransactionID_Data_Type
173 [Template] Verify Fail To Release Lock With TransactionID As String Type
174
175 # client_id lock_type release_lock_type
176 HMCID-01 ReadCase1 Transaction
177 HMCID-01 WriteCase1 Transaction
178
179
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500180Fail To Release Lock For Another Session
181 [Documentation] Failed to release locks from another session.
182 [Tags] Fail_To_Release_Lock_For_Another_Session
183 [Template] Verify Fail To Release Lock For Another Session
Vijayafdd2a12020-04-09 02:03:20 -0500184
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500185 # client_id lock_type
186 HMCID-01,HMCID-02 ReadCase1,ReadCase1
Vijayafdd2a12020-04-09 02:03:20 -0500187
188
Sushil Singh76806df2022-12-23 07:19:02 -0600189Verify Lock Is Not Persistent On BMC Reboot
190 [Documentation] Acquire lock and after reboot the locks are removed as no persistency
191 ... maintained.
192 [Tags] Verify_Lock_Is_Not_Persistent_On_BMC_Reboot
193 [Template] Acquire Lock On Resource
194
195 # client_id lock_type reboot_flag
196 HMCID-01 ReadCase1 True
197 HMCID-01 ReadCase2 True
198 HMCID-01 ReadCase3 True
199 HMCID-01 WriteCase1 True
200 HMCID-01 WriteCase2 True
201 HMCID-01 WriteCase3 True
202
203
Sushil Singhe33c6e62020-09-29 06:34:35 -0500204Test Invalid Resource ID Data Type Locking
205 [Documentation] Failed to acquire lock for invalid resource id data type.
206 [Tags] Test_Invalid_Resource_ID_Data_Type_Locking
207 [Template] Verify Fail To Acquire Lock For Invalid Resource ID Data Type
208
209 # client_id lock_type
210 HMCID-01 ReadCase1
211 HMCID-01 ReadCase2
212 HMCID-01 ReadCase3
213 HMCID-01 WriteCase1
214 HMCID-01 WriteCase2
215 HMCID-01 WriteCase3
216
217
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500218Fail To Acquire Lock For Invalid Lock Type
219 [Documentation] Failed to acquire read, write lock for invalid lock data passed.
220 [Tags] Fail_To_Acquire_Lock_For_Invalid_Lock_Type
221 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
Vijayafdd2a12020-04-09 02:03:20 -0500222
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500223 # client_id lock_type message
224 HMCID-01 ReadCase1 ${BAD_REQUEST}
225 HMCID-01 ReadCase2 ${BAD_REQUEST}
226 HMCID-01 ReadCase3 ${BAD_REQUEST}
227 HMCID-01 ReadCase4 ${BAD_REQUEST}
228 HMCID-01 ReadCase5 ${BAD_REQUEST}
229 HMCID-01 WriteCase1 ${BAD_REQUEST}
230 HMCID-01 WriteCase2 ${BAD_REQUEST}
231 HMCID-01 WriteCase3 ${BAD_REQUEST}
232 HMCID-01 WriteCase4 ${BAD_REQUEST}
233 HMCID-01 WriteCase5 ${BAD_REQUEST}
Vijayafdd2a12020-04-09 02:03:20 -0500234
Vijayafdd2a12020-04-09 02:03:20 -0500235
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500236Fail To Acquire Lock For Invalid Lock Flag
237 [Documentation] Failed to acquire read write lock for invalid lock flag passed.
238 [Tags] Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
239 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
Vijayafdd2a12020-04-09 02:03:20 -0500240
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500241 # client_id lock_type message
242 HMCID-01 ReadCase6 ${BAD_REQUEST}
243 HMCID-01 ReadCase7 ${BAD_REQUEST}
244 HMCID-01 ReadCase8 ${BAD_REQUEST}
245 HMCID-01 ReadCase9 ${BAD_REQUEST}
246 HMCID-01 ReadCase10 ${BAD_REQUEST}
247 HMCID-01 ReadCase11 ${BAD_REQUEST}
248 HMCID-01 WriteCase6 ${BAD_REQUEST}
249 HMCID-01 WriteCase7 ${BAD_REQUEST}
250 HMCID-01 WriteCase8 ${BAD_REQUEST}
251 HMCID-01 WriteCase9 ${BAD_REQUEST}
252 HMCID-01 WriteCase10 ${BAD_REQUEST}
253 HMCID-01 WriteCase11 ${BAD_REQUEST}
Vijayafdd2a12020-04-09 02:03:20 -0500254
Vijayafdd2a12020-04-09 02:03:20 -0500255
Sushil Singh76806df2022-12-23 07:19:02 -0600256Check After Reboot Transaction ID Set To Default
257 [Documentation] After reboot, the transaction id starts with default i.e. 1,
258 ... if any lock is acquired.
259 [Tags] Check_After_Reboot_Transaction_ID_Set_To_Default
260 [Template] Verify Acquire And Release Lock In Loop
261
262 # client_id lock_type reboot_flag
263 HMCID-01 ReadCase1 True
264 HMCID-01 WriteCase1 True
265
266
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500267Fail To Acquire Lock For Invalid Segment Flag
268 [Documentation] Failed to acquire read write lock for invalid segment flag passed.
269 [Tags] Fail_To_Acquire_Lock_For_Invalid_Segment_Flag
270 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
271
272 # client_id lock_type message
273 HMCID-01 ReadCase12 ${BAD_REQUEST}
274 HMCID-01 ReadCase13 ${BAD_REQUEST}
275 HMCID-01 ReadCase14 ${BAD_REQUEST}
276 HMCID-01 WriteCase12 ${BAD_REQUEST}
277 HMCID-01 WriteCase13 ${BAD_REQUEST}
278 HMCID-01 WriteCase14 ${BAD_REQUEST}
Vijayafdd2a12020-04-09 02:03:20 -0500279
Sushil Singhbace3002020-10-08 08:12:58 -0500280
Sushil Singh3b3a7ec2020-11-23 03:54:06 -0600281Fail To Acquire Lock For Invalid Segment Data Type Flag
282 [Documentation] Failed to acquire read write lock for invalid segment flag passed.
283 [Tags] Fail_To_Acquire_Lock_For_Invalid_Segment_Data_Type_Flag
284 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
285
286 # client_id lock_type message
287 HMCID-01 ReadCase15 ${EMPTY}
288 HMCID-01 ReadCase16 ${EMPTY}
289 HMCID-01 ReadCase17 ${EMPTY}
290 HMCID-01 ReadCase18 ${EMPTY}
291 HMCID-01 WriteCase15 ${EMPTY}
292 HMCID-01 WriteCase16 ${EMPTY}
293 HMCID-01 WriteCase17 ${EMPTY}
294 HMCID-01 WriteCase18 ${EMPTY}
295
296
Sushil Singhbace3002020-10-08 08:12:58 -0500297Get Empty Lock Records For Session Where No Locks Acquired
298 [Documentation] If session does not acquire locks then get lock should return
299 ... empty lock records.
300 [Tags] Get_Empty_Lock_Records_For_Session_Where_No_Locks_Acquired
301 [Template] Verify No Locks Records For Session With No Acquired Lock
302
303 # client_id
304 HMCID-01
305
Sushil Singh728ef9c2020-10-28 04:25:39 -0500306
Sushil Singhf9a536c2020-11-09 07:33:17 -0600307Get Lock Records Empty For Invalid Session
308 [Documentation] Record of lock list is empty for invalid session.
309 [Tags] Get_Lock_Records_Empty_For_Invalid_Session
310 [Template] Verify Empty Lock Records For Invalid Session
311
312 # client_id
313 HMCID-01
314
315
Sushil Singh728ef9c2020-10-28 04:25:39 -0500316Get Lock Records For Multiple Session
317 [Documentation] Get lock records of multiple session.
318 [Tags] Get_Lock_Records_For_Multiple_Session
319 [Template] Verify Lock Records Of Multiple Session
320
321 # client_ids lock_type
322 HMCID-01,HMCID-02 ReadCase1,ReadCase1
323
324
Sushil Singhf9a536c2020-11-09 07:33:17 -0600325Get Lock Records For Multiple Invalid Session
326 [Documentation] Record of lock list is empty for list of invalid session.
327 [Tags] Get_Lock_Records_For_Multiple_Invalid_Session
328 [Template] Verify Lock Records For Multiple Invalid Session
329
330 # client_id
331 HMCID-01
332
Sushil Singh11949a22020-11-13 06:12:16 -0600333
334Get Lock Records For Multiple Invalid And Valid Session
335 [Documentation] Get record of lock from invalid and valid session.
336 [Tags] Get_Lock_Records_For_Multiple_Invalid_And_Valid_Session
337 [Template] Verify Lock Records For Multiple Invalid And Valid Session
338
339 # client_id lock_type
340 HMCID-01,HMCID-02 ReadCase1
341
Vijaybc331e22020-02-27 04:17:37 -0600342*** Keywords ***
343
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500344Create Redfish Session With ClientID
345 [Documentation] Create redifish session with client id.
346 [Arguments] ${client_id}
Vijay85610ee2020-04-03 05:30:28 -0500347
348 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500349 # client_id This client id can contain string value
350 # (e.g. 12345, "HMCID").
Vijay85610ee2020-04-03 05:30:28 -0500351
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500352 ${session_info}= Create Dictionary
Sushil Singhf4de7d72023-07-21 08:59:20 -0500353
354 ${session}= Redfish Login kwargs="Context": "${client_id}"
Vijay85610ee2020-04-03 05:30:28 -0500355
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500356 Set To Dictionary ${session_info} SessionIDs ${session['Id']}
Sushil Singhf4de7d72023-07-21 08:59:20 -0500357 Set To Dictionary ${session_info} ClientID ${session["Context"]}
Vijay85610ee2020-04-03 05:30:28 -0500358
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500359 [Return] ${session_info}
Vijay85610ee2020-04-03 05:30:28 -0500360
361
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500362RW General Dictionary
George Keishing16b3c7b2021-01-28 09:23:37 -0600363 [Documentation] Create dictionary of lock request.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500364 [Arguments] ${read_case} ${res_id}
Vijaybc331e22020-02-27 04:17:37 -0600365
366 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500367 # read_case Read or Write lock type.
368 # res_id Resource id.
Vijaybc331e22020-02-27 04:17:37 -0600369
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500370 ${request_dict}= Create Dictionary
George Keishing566daaf2020-07-02 06:18:50 -0500371
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500372 FOR ${key} IN @{read_case.keys()}
373 Set To Dictionary ${request_dict} LockType ${key}
374 Set To Dictionary ${request_dict} SegmentFlags ${read_case["${key}"]}
375 END
Vijaybc331e22020-02-27 04:17:37 -0600376
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500377 Set To Dictionary ${request_dict} ResourceID ${res_id}
378
379 [Return] ${request_dict}
Vijaybc331e22020-02-27 04:17:37 -0600380
381
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500382Return Description Of Response
383 [Documentation] Return description of REST response.
Vijaybc331e22020-02-27 04:17:37 -0600384 [Arguments] ${resp_text}
385
386 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500387 # resp_text REST response body.
Vijaybc331e22020-02-27 04:17:37 -0600388
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500389 # resp_text after successful partition file upload looks like:
390 # {
391 # "Description": "File Created"
392 # }
Vijaybc331e22020-02-27 04:17:37 -0600393
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500394 ${message}= Evaluate json.loads('''${resp_text}''') json
395
396 [Return] ${message}
Vijaybc331e22020-02-27 04:17:37 -0600397
398
Sushil Singha7d71f02020-11-02 05:24:22 -0600399Verify Redfish Session Deleted
400 [Documentation] Verify the redfish session is deleted.
401 [Arguments] ${session_info}
402
403 # Description of argument(s):
404 # session_info Session information are stored in dictionary.
405
406 # ${session_info} = {
407 # 'SessionIDs': 'XXXXXXXXX',
408 # 'ClientID': 'XXXXXX',
409 # 'SessionToken': 'XXXXXXXXX',
410 # 'SessionResp': session response from redfish login
411 # }
412
413 # SessionIDs : Session IDs
414 # ClientID : Client ID
415 # SessionToken : Session token
416 # SessionResp : Response of creating an redfish login session
417
418 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions
419
420 FOR ${session} IN @{sessions['Members']}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500421 Should Not Be Equal As Strings
422 ... session ['/redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}']
Sushil Singha7d71f02020-11-02 05:24:22 -0600423 END
424
425
426Verify Redfish List Of Session Deleted
427 [Documentation] Verify all the list of redfish session is deleted.
428 [Arguments] ${session_info_list}
429
430 # Description of argument(s):
431 # session_info_list List contains individual session record are stored in dictionary.
432
433 # ${session_info_list} = [{
434 # 'SessionIDs': 'XXXXXXXXX',
435 # 'ClientID': 'XXXXXX',
436 # 'SessionToken': 'XXXXXXXXX',
437 # 'SessionResp': session response from redfish login
438 # }]
439
440 # SessionIDs : Session IDs
441 # ClientID : Client ID
442 # SessionToken : Session token
443 # SessionResp : Response of creating an redfish login session
444
445 FOR ${session_record} IN @{session_info_list}
446 Verify Redfish Session Deleted ${session_record}
447 END
448
449
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500450Redfish Post Acquire Lock
451 [Documentation] Acquire and release lock.
452 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600453
454 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500455 # lock_type Read lock or Write lock.
456 # status_code HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600457
Sushil Singhe33c6e62020-09-29 06:34:35 -0500458 ${lock_dict_param}= Form Data To Acquire Lock ${lock_type}
George Keishingfbd67002022-08-01 11:24:03 -0500459 ${lock_dict_param}= Convert JSON To String ${lock_dict_param}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500460 ${resp}= Redfish Post Request
461 ... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
George Keishingfbd67002022-08-01 11:24:03 -0500462 ... expected_status=any
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500463 Should Be Equal As Strings ${resp.status_code} ${status_code}
Sushil Singhdf390b62021-01-19 00:50:05 -0600464
465 Run Keyword If ${status_code} == ${HTTP_BAD_REQUEST}
466 ... Valid Value ${BAD_REQUEST} ['${resp.content}']
467 ... ELSE
468 ... Run Keyword And Return Return Description Of Response ${resp.content}
Vijaybc331e22020-02-27 04:17:37 -0600469
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500470 [Return] ${resp}
Vijaybc331e22020-02-27 04:17:37 -0600471
472
Sushil Singh977f8f52020-11-20 06:32:50 -0600473Redfish Post Acquire List Lock
474 [Documentation] Acquire and release lock.
475 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
476
477 # Description of argument(s):
478 # lock_type Read lock or Write lock.
479 # status_code HTTP status code.
480
481 ${lock_dict_param}= Create Data To Acquire List Of Lock ${lock_type}
George Keishingfbd67002022-08-01 11:24:03 -0500482 ${lock_dict_param}= Convert JSON To String ${lock_dict_param}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500483 ${resp}= Redfish Post Request
484 ... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
George Keishingfbd67002022-08-01 11:24:03 -0500485 ... expected_status=any
Sushil Singh977f8f52020-11-20 06:32:50 -0600486 Should Be Equal As Strings ${resp.status_code} ${status_code}
487
Sushil Singhe3f2e3b2022-07-28 05:15:43 -0500488 Run Keyword If ${status_code} == ${HTTP_CONFLICT}
489 ... Should Be Equal As Strings ${CONFLICT_RQUEST} ${resp.content}
490 ... ELSE
491 ... Run Keyword And Return Return Description Of Response ${resp.content}
492
Sushil Singh977f8f52020-11-20 06:32:50 -0600493 [Return] ${resp}
494
495
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500496Redfish Post Acquire Invalid Lock
497 [Documentation] Redfish to post request to acquire in-valid lock.
498 [Arguments] ${lock_type} ${message} ${status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600499
500 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500501 # lock_type Read lock or Write lock.
502 # message Return message from URI.
503 # status_code HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600504
Sushil Singhe33c6e62020-09-29 06:34:35 -0500505 ${lock_dict_param}= Form Data To Acquire Invalid Lock ${lock_type}
George Keishingfbd67002022-08-01 11:24:03 -0500506 ${lock_dict_param}= Convert JSON To String ${lock_dict_param}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500507 ${resp}= Redfish Post Request
508 ... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500509 Should Be Equal As Strings ${resp.status_code} ${status_code}
Sushil Singh3b3a7ec2020-11-23 03:54:06 -0600510 Run Keyword If '${message}' != '${EMPTY}'
511 ... Valid Value message ['${resp.content}']
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500512
513 [Return] ${resp}
Vijaybc331e22020-02-27 04:17:37 -0600514
515
Sushil Singhe33c6e62020-09-29 06:34:35 -0500516Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
517 [Documentation] Redfish to post request to acquire in-valid lock with invalid data type of resource id.
518 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
519
520 # Description of argument(s):
521 # lock_type Read lock or Write lock.
522 # status_code HTTP status code.
523
Sushil Singh8a3efe72021-08-26 08:16:41 -0500524 ${lock_dict_param}=
525 ... Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID ${lock_type}
George Keishingfbd67002022-08-01 11:24:03 -0500526 ${lock_dict_param}= Convert JSON To String ${lock_dict_param}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500527 ${resp}= Redfish Post Request
528 ... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500529 Should Be Equal As Strings ${resp.status_code} ${status_code}
530
531 [Return] ${resp}
532
533
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500534Form Data To Acquire Lock
George Keishing16b3c7b2021-01-28 09:23:37 -0600535 [Documentation] Create a dictionary for lock request.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500536 [Arguments] ${lock_type}
537
538 # Description of argument(s):
539 # lock_type Read lock or Write lock.
540
541 ${lock_res_info}= Get Lock Resource Information
542 ${resp}= RW General Dictionary
543 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
544 ... ${lock_res_info["Valid Case"]["ResourceID"]}
545 ${temp_list}= Create List ${resp}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500546 ${lock_request_dict}= Create Dictionary Request=${temp_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500547
Sushil Singhe33c6e62020-09-29 06:34:35 -0500548 [Return] ${lock_request_dict}
549
550
Sushil Singh977f8f52020-11-20 06:32:50 -0600551Create Data To Acquire List Of Lock
George Keishing16b3c7b2021-01-28 09:23:37 -0600552 [Documentation] Create a dictionary for list of lock request.
Sushil Singh977f8f52020-11-20 06:32:50 -0600553 [Arguments] ${lock_type_list}
554
555 # Description of argument(s):
556 # lock_type Read lock or Write lock.
557
558 ${temp_list}= Create List
559 ${lock_res_info}= Get Lock Resource Information
560
561 FOR ${lock_type} IN @{lock_type_list}
562 ${resp}= RW General Dictionary
563 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
564 ... ${lock_res_info["Valid Case"]["ResourceID"]}
565 Append To List ${temp_list} ${resp}
566 END
567
568 ${lock_request_dict}= Create Dictionary Request=${temp_list}
569
570 [Return] ${lock_request_dict}
571
572
Sushil Singhe33c6e62020-09-29 06:34:35 -0500573Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
George Keishing16b3c7b2021-01-28 09:23:37 -0600574 [Documentation] Create a dictionary for in-valid lock request.
Sushil Singhe33c6e62020-09-29 06:34:35 -0500575 [Arguments] ${lock_type}
576
577 # Description of argument(s):
578 # lock_type Read lock or Write lock.
579
580 ${lock_res_info}= Get Lock Resource Information
581 ${resp}= RW General Dictionary
582 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
583 ... ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
584 ${temp_list}= Create List ${resp}
585 ${lock_request_dict}= Create Dictionary Request=${temp_list}
586
587 [Return] ${lock_request_dict}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500588
589
590Form Data To Acquire Invalid Lock
George Keishing16b3c7b2021-01-28 09:23:37 -0600591 [Documentation] Create a dictionary for in-valid lock request.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500592 [Arguments] ${lock_type}
593
594 # Description of argument(s):
595 # lock_type Read lock or Write lock.
596
597 ${lock_res_info}= Get Lock Resource Information
598 ${resp}= RW General Dictionary
599 ... ${lock_res_info["Invalid Case"]["${lock_type}"]}
600 ... ${lock_res_info["Valid Case"]["ResourceID"]}
601 ${temp_list}= Create List ${resp}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500602 ${lock_request_dict}= Create Dictionary Request=${temp_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500603
Sushil Singhe33c6e62020-09-29 06:34:35 -0500604 [Return] ${lock_request_dict}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500605
606
607Get Locks List On Resource
Vijaybc331e22020-02-27 04:17:37 -0600608 [Documentation] Get locks list.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500609 [Arguments] ${session_info} ${exp_status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600610
611 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500612 # session_info Session information in dict.
613 # exp_status_code Expected HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600614
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500615 ${data}= Set Variable {"SessionIDs": ["${session_info['SessionIDs']}"]}
George Keishing566daaf2020-07-02 06:18:50 -0500616 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
617 ... data=${data}
Vijaybc331e22020-02-27 04:17:37 -0600618 ${locks}= Evaluate json.loads('''${resp.text}''') json
619
620 [Return] ${locks["Records"]}
621
622
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500623Verify Lock On Resource
624 [Documentation] Verify lock on resource.
625 [Arguments] ${session_info} ${transaction_id}
Vijaybc331e22020-02-27 04:17:37 -0600626
627 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500628 # session_info Session information in dict.
629 # transaction_id Transaction id in list stored in dict.
Vijaybc331e22020-02-27 04:17:37 -0600630
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500631 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
632 Rprint Vars sessions
633 ${lock_list}= Get Locks List On Resource ${session_info}
634 ${lock_length}= Get Length ${lock_list}
635 ${tran_id_length}= Get Length ${transaction_id}
636 Should Be Equal As Integers ${tran_id_length} ${lock_length}
Vijayafdd2a12020-04-09 02:03:20 -0500637
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500638 FOR ${tran_id} ${lock} IN ZIP ${transaction_id} ${lock_list}
639 Valid Value session_info['ClientID'] ['${lock['HMCID']}']
640 Valid Value session_info['SessionIDs'] ['${lock['SessionID']}']
641 Should Be Equal As Integers ${tran_id['TransactionID']} ${lock['TransactionID']}
Vijaybc331e22020-02-27 04:17:37 -0600642 END
643
Vijaybc331e22020-02-27 04:17:37 -0600644
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500645Acquire Lock On Resource
646 [Documentation] Acquire lock on resource.
647 [Arguments] ${client_id} ${lock_type} ${reboot_flag}=False
Vijaybc331e22020-02-27 04:17:37 -0600648
649 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500650 # client_id This client id can contain string value
651 # (e.g. 12345, "HMCID").
652 # lock_type Read lock or Write lock.
653 # reboot_flag Flag is used to run reboot the BMC code.
654 # (e.g. True or False).
Vijaybc331e22020-02-27 04:17:37 -0600655
Sushil Singh8a3efe72021-08-26 08:16:41 -0500656 ${trans_id_emptylist}= Create List
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500657 ${trans_id_list}= Create List
Sushil Singh8a3efe72021-08-26 08:16:41 -0500658
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500659 ${session_info}= Create Redfish Session With ClientID ${client_id}
660 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
661 Append To List ${trans_id_list} ${trans_id}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500662
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500663 Verify Lock On Resource ${session_info} ${trans_id_list}
George Keishing566daaf2020-07-02 06:18:50 -0500664
Sushil Singhe33c6e62020-09-29 06:34:35 -0500665 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
Vijaybc331e22020-02-27 04:17:37 -0600666
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500667 Run Keyword If '${reboot_flag}' == 'True'
Sushil Singh8a3efe72021-08-26 08:16:41 -0500668 ... Run Keywords Redfish BMC Reset Operation AND
Sushil Singhe33c6e62020-09-29 06:34:35 -0500669 ... Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} AND
Sushil Singh07b25342022-09-20 09:29:07 -0500670 ... Wait Until Keyword Succeeds 3 min 10 sec Redfish BMC Match States match_state=Enabled AND
Sushil Singh8a3efe72021-08-26 08:16:41 -0500671 ... Is BMC Standby AND
672 ... Verify Lock On Resource ${session_info} ${trans_id_emptylist}
Vijaybc331e22020-02-27 04:17:37 -0600673
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500674 Run Keyword If '${reboot_flag}' == 'False'
675 ... Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600676
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500677 ${trans_id_emptylist}= Create List
678 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
679 Redfish Delete Session ${session_info}
Vijaybc331e22020-02-27 04:17:37 -0600680
Vijaybc331e22020-02-27 04:17:37 -0600681
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500682Form Data To Release Lock
683 [Documentation] Create a dictonay to release lock.
684 [Arguments] ${trans_id_list}
Vijay355daac2020-03-26 12:06:08 -0500685
686 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500687 # trans_id_list
Vijay355daac2020-03-26 12:06:08 -0500688
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500689 @{tran_ids}= Create List
Vijay355daac2020-03-26 12:06:08 -0500690
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500691 FOR ${item} IN @{trans_id_list}
692 Append To List ${tran_ids} ${item['TransactionID']}
693 END
694
695 [Return] ${tran_ids}
696
697
698Release Locks On Resource
699 [Documentation] Redfish request to release a lock.
Sushil Singh8a3efe72021-08-26 08:16:41 -0500700 [Arguments] ${session_info} ${trans_id_list} ${release_lock_type}=Transaction
701 ... ${status_code}=${HTTP_OK}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500702
703 # Description of argument(s):
704 # session_info Session information in dict.
705 # trans_id_list Transaction id list.
706 # release_lock_type Release lock by Transaction, Session.
707 # status_code HTTP status code.
708
709 ${tran_ids}= Form Data To Release Lock ${trans_id_list}
710 ${data}= Set Variable {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
711 ${data}= Evaluate json.dumps(${data}) json
712 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock data=${data}
713 Should Be Equal As Strings ${resp.status_code} ${status_code}
714
715
Sushil Singhdf390b62021-01-19 00:50:05 -0600716Release locks And Delete Session
717 [Documentation] Release locks and delete redfish session.
718 [Arguments] ${session_info} ${trans_id_list}
719
720 Release Locks On Resource ${session_info} ${trans_id_list}
721
722 ${trans_id_emptylist}= Create List
723 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
724
725 Redfish Delete Session ${session_info}
726
727
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500728Acquire Lock On Another Lock
729 [Documentation] Acquire lock on another lock.
730 [Arguments] ${client_id}
731
732 # Description of argument(s):
733 # client_id This client id can contain string value
734 # (e.g. 12345, "HMCID").
735
736 ${trans_id_list}= Create List
737 ${session_info}= Create Redfish Session With ClientID ${client_id}
738
739 ${trans_id}= Redfish Post Acquire Lock ReadCase1
740 Append To List ${trans_id_list} ${trans_id}
741
742 ${trans_id}= Redfish Post Acquire Lock ReadCase1
743 Append To List ${trans_id_list} ${trans_id}
744
745 Verify Lock On Resource ${session_info} ${trans_id_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500746
Sushil Singhdf390b62021-01-19 00:50:05 -0600747 Release locks And Delete Session ${session_info} ${trans_id_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500748
749
Sushil Singh977f8f52020-11-20 06:32:50 -0600750Verify Fail To Acquire Read And Write In Single Request
751 [Documentation] Verify fail to acquire read and write lock passed in single request.
Sushil Singhe3f2e3b2022-07-28 05:15:43 -0500752 [Arguments] ${client_id} ${lock_type} ${status_code}
753
754 # Description of argument(s):
755 # client_id This client id can contain string value
756 # (e.g. 12345, "HMCID").
757 # lock_type Read lock or Write lock.
758 # status_code HTTP status code
759
760 ${lock_type_list}= Split String ${lock_type} ,
761
762 ${session_info}= Create Redfish Session With ClientID ${client_id}
763 ${trans_id}= Redfish Post Acquire List Lock ${lock_type_list} status_code=${status_code}
764 Redfish Delete Session ${session_info}
765
766
767Verify Acquire Read In Single Request
768 [Documentation] Verify acquire read in single request.
Sushil Singh977f8f52020-11-20 06:32:50 -0600769 [Arguments] ${client_id} ${lock_type}
770
771 # Description of argument(s):
772 # client_id This client id can contain string value
773 # (e.g. 12345, "HMCID").
774 # lock_type Read lock or Write lock.
775
Sushil Singhe3f2e3b2022-07-28 05:15:43 -0500776 ${trans_id_list}= Create List
Sushil Singh977f8f52020-11-20 06:32:50 -0600777 ${lock_type_list}= Split String ${lock_type} ,
778
779 ${session_info}= Create Redfish Session With ClientID ${client_id}
Sushil Singhe3f2e3b2022-07-28 05:15:43 -0500780 ${trans_id}= Redfish Post Acquire List Lock ${lock_type_list}
781 Append To List ${trans_id_list} ${trans_id}
782 Append To List ${trans_id_list} ${trans_id}
783
784 Verify Lock On Resource ${session_info} ${trans_id_list}
785 Remove From List ${trans_id_list} 1
786 Release Locks On Resource ${session_info} ${trans_id_list}
787
Sushil Singh977f8f52020-11-20 06:32:50 -0600788 Redfish Delete Session ${session_info}
789
790
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500791Verify Empty Lock Records For Invalid Session
792 [Documentation] Verify no lock record found for invalid session.
793 [Arguments] ${client_id}
794
795 # Description of argument(s):
796 # client_id This client id can contain string value
797 # (e.g. 12345, "HMCID").
798
799 ${session_info1}= Create Redfish Session With ClientID ${client_id}
800
801 ${lock_list1}= Get Locks List On Resource ${session_info1}
802 ${lock_length1}= Get Length ${lock_list1}
803
804 ${session_info2}= Copy Dictionary ${session_info1} deepcopy=True
805 set to dictionary ${session_info2} SessionIDs xxyXyyYZZz
806
807 ${lock_list2}= Get Locks List On Resource ${session_info2}
Sushil Singhf9a536c2020-11-09 07:33:17 -0600808 ${lock_length2}= Get Length ${lock_list2}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500809
Sushil Singhf9a536c2020-11-09 07:33:17 -0600810 Should Be Equal As Integers ${lock_length1} ${lock_length2}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500811
812 Redfish Delete Session ${session_info1}
813
814
815Verify Acquire Lock Fails On Another Lock
816 [Documentation] Verify acquire lock on another lock fails.
817 [Arguments] ${client_id} ${lock_type}
818
819 # Description of argument(s):
820 # client_id This client id can contain string value
821 # (e.g. 12345, "HMCID").
822 # lock_type Read lock or Write lock.
823
824 @{lock_type_list}= Split String ${lock_type} ,
825 ${session_info}= Create Redfish Session With ClientID ${client_id}
826 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
827
828 ${trans_id_list}= Create List
829 Append To List ${trans_id_list} ${trans_id}
830
831 Verify Lock On Resource ${session_info} ${trans_id_list}
832 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1] status_code=${HTTP_CONFLICT}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500833
Sushil Singhdf390b62021-01-19 00:50:05 -0600834 Release locks And Delete Session ${session_info} ${trans_id_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500835
836
Sushil Singhe33c6e62020-09-29 06:34:35 -0500837Verify Acquire Lock After Reboot
838 [Documentation] Acquire read and write lock after the reboot and release lock.
839 [Arguments] ${client_id} ${lock_type}
840
841 # Description of argument(s):
842 # client_id This client id can contain string value
843 # (e.g. 12345, "HMCID").
844 # lock_type Read lock or Write lock.
845
846 ${trans_id_list}= Create List
Sushil Singhf9a536c2020-11-09 07:33:17 -0600847 ${session_info}= Create Session With ClientID ${client_id}
Sushil Singhac229c72021-09-13 02:26:51 -0500848
Sushil Singhe33c6e62020-09-29 06:34:35 -0500849 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
Sushil Singhac229c72021-09-13 02:26:51 -0500850 Redfish BMC Reset Operation
Sushil Singhe33c6e62020-09-29 06:34:35 -0500851 Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token}
Sushil Singh07b25342022-09-20 09:29:07 -0500852 Wait Until Keyword Succeeds 3 min 10 sec Redfish BMC Match States match_state=Enabled
Sushil Singhac229c72021-09-13 02:26:51 -0500853 Is BMC Standby
Sushil Singhe33c6e62020-09-29 06:34:35 -0500854
855 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
856 Append To List ${trans_id_list} ${trans_id}
857 Verify Lock On Resource ${session_info} ${trans_id_list}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500858
Sushil Singhdf390b62021-01-19 00:50:05 -0600859 Release locks And Delete Session ${session_info} ${trans_id_list}
860
861
862Verify Acquire Multiple Lock Request At CEC Level
863 [Documentation] Acquire lock in loop.
864 [Arguments] ${client_id} ${lock_type}
865
866 # Description of argument(s):
867 # client_id This client id can contain string value
868 # (e.g. 12345, "HMCID").
869 # lock_type Read lock or Write lock.
870
871 ${trans_id_list}= Create List
872 @{lock_type_list}= Split String ${lock_type} ,
873 ${session_info}= Create Redfish Session With ClientID ${client_id}
874
875 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
876 Append To List ${trans_id_list} ${trans_id}
877
878 Verify Lock On Resource ${session_info} ${trans_id_list}
879
880 Redfish Post Acquire Lock ${lock_type_list}[1] status_code=${HTTP_CONFLICT}
881
882 Release locks And Delete Session ${session_info} ${trans_id_list}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500883
884
Sushil Singh8d420bf2021-09-06 08:27:41 -0500885Post Reboot Acquire Lock
886 [Documentation] Post reboot acquire lock and verify the transaction id is 1.
887 [Arguments] ${session_info} ${lock_type}
888
889 # Description of argument(s):
890 # session_info Session information.
891 # lock_type Read lock or Write lock.
892
893 ${trans_id_list}= Create List
894 ${trans_id_list_var}= Create List
895 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
896 Append To List ${trans_id_list} ${trans_id}
897 Append To List ${trans_id_list_var} ${default_trans_id}
898 Verify Lock On Resource ${session_info} ${trans_id_list}
899 Verify Lock On Resource ${session_info} ${trans_id_list_var}
900 Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
901 ${trans_id_emptylist}= Create List
902 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
903
904
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500905Verify Acquire And Release Lock In Loop
906 [Documentation] Acquire lock in loop.
Sushil Singh8d420bf2021-09-06 08:27:41 -0500907 [Arguments] ${client_id} ${lock_type} ${reboot_flag}=False
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500908
909 # Description of argument(s):
910 # client_id This client id can contain string value
911 # (e.g. 12345, "HMCID").
912 # lock_type Read lock or Write lock.
Sushil Singh8d420bf2021-09-06 08:27:41 -0500913 # reboot_flag Flag is used to run reboot the BMC code.
914 # (e.g. True or False).
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500915
916 FOR ${count} IN RANGE 1 11
917 ${trans_id_list}= Create List
918 ${session_info}= Create Redfish Session With ClientID ${client_id}
919 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
920 Append To List ${trans_id_list} ${trans_id}
921 Verify Lock On Resource ${session_info} ${trans_id_list}
922 Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
923 ${trans_id_emptylist}= Create List
924 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
Sushil Singh8d420bf2021-09-06 08:27:41 -0500925 Redfish Delete Session ${session_info}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500926 END
927
Sushil Singh8d420bf2021-09-06 08:27:41 -0500928 ${session_info}= Create Redfish Session With ClientID ${client_id}
929 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
930
931 Run Keyword If '${reboot_flag}' == 'True'
932 ... Run Keywords Redfish BMC Reset Operation AND
933 ... Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} AND
Sushil Singh07b25342022-09-20 09:29:07 -0500934 ... Wait Until Keyword Succeeds 3 min 10 sec Redfish BMC Match States match_state=Enabled AND
Sushil Singh8d420bf2021-09-06 08:27:41 -0500935 ... Is BMC Standby AND
936 ... Post Reboot Acquire Lock ${session_info} ${lock_type}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500937 Redfish Delete Session ${session_info}
938
939
940Acquire And Release Multiple Locks
941 [Documentation] Acquire mutilple locks on resource.
942 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
943
944 # Description of argument(s):
945 # client_id This client id can contain string value
946 # (e.g. 12345, "HMCID").
947 # lock_type Read lock or Write lock.
948 # release_lock_type The value can be Transaction or Session.
949
950 @{lock_type_list}= Split String ${lock_type} ,
951 ${session_info}= Create Redfish Session With ClientID ${client_id}
952 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
953
954 ${trans_id_list}= Create List
955
956 Append To List ${trans_id_list} ${trans_id}
957 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
958
959 Append To List ${trans_id_list} ${trans_id}
960 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2]
961
962 Append To List ${trans_id_list} ${trans_id}
963 Verify Lock On Resource ${session_info} ${trans_id_list}
964 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=${release_lock_type}
965
966 ${trans_id_emptylist}= Create List
967 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
968 Redfish Delete Session ${session_info}
969
970
susilsi794116c62021-03-04 07:57:51 -0600971Verify Release Lock When Session Deleted
972 [Documentation] Verify lock get released when session are deleted.
973 [Arguments] ${client_id} ${lock_type}
974
975 # Description of argument(s):
976 # client_ids This client id can contain string value
977 # (e.g. 12345, "HMCID").
978 # lock_type Read lock or Write lock.
979
980 ${trans_id_list}= Create List
981 @{lock_type_list}= Split String ${lock_type} ,
982
983 ${pre_session_info}= Create Redfish Session With ClientID ${client_id}
984
985 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
986 Append To List ${trans_id_list} ${trans_id}
987 Verify Lock On Resource ${pre_session_info} ${trans_id_list}
988
989 Redfish Delete Session ${pre_session_info}
990 ${post_session_info}= Create Redfish Session With ClientID ${client_id}
991 ${resp}= Get Locks List On Resource With Session List ${pre_session_info} ${HTTP_BAD_REQUEST}
992
993 Redfish Delete Session ${post_session_info}
994
995
996
Sushil Singh59011d02021-01-27 23:00:20 -0600997Verify Fail To Release Lock With Invalid TransactionID
George Keishing16b3c7b2021-01-28 09:23:37 -0600998 [Documentation] Verify fail to be release lock with invalid transaction ID.
Sushil Singh59011d02021-01-27 23:00:20 -0600999 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
1000
1001 # Description of argument(s):
1002 # client_id This client id can contain string value
1003 # (e.g. 12345, "HMCID").
1004 # lock_type Read lock or Write lock.
1005 # release_lock_type The value can be Transaction or Session.
1006
1007 ${trans_id_list}= Create List
1008 @{lock_type_list}= Split String ${lock_type} ,
1009
1010 ${session_info}= Create Redfish Session With ClientID ${client_id}
1011
1012 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1013 ${value}= Get From Dictionary ${trans_id} TransactionID
1014 ${value}= Evaluate ${value} + 10
1015 Set To Dictionary ${trans_id} TransactionID ${value}
1016 Append To List ${trans_id_list} ${trans_id}
1017
1018 Release Locks On Resource
1019 ... ${session_info} ${trans_id_list}
1020 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
1021 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session
1022
1023 ${trans_id_emptylist}= Create List
1024 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1025 Redfish Delete Session ${session_info}
1026
1027
Sushil Singh1b590532021-01-20 05:13:54 -06001028Verify Fail To Release Multiple Lock With Invalid TransactionID
1029 [Documentation] Verify release multiple locks with invalid transaction ID fails.
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001030 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
1031
1032 # Description of argument(s):
1033 # client_id This client id can contain string value
1034 # (e.g. 12345, "HMCID").
1035 # lock_type Read lock or Write lock.
1036 # release_lock_type The value can be Transaction or Session.
1037
1038 ${trans_id_list}= Create List
1039 @{lock_type_list}= Split String ${lock_type} ,
1040
1041 ${session_info}= Create Redfish Session With ClientID ${client_id}
1042
1043 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1044 ${value}= Get From Dictionary ${trans_id} TransactionID
1045 ${value}= Evaluate ${value} + 10
1046 Set To Dictionary ${trans_id} TransactionID ${value}
1047 Append To List ${trans_id_list} ${trans_id}
1048
1049 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
1050 ${value}= Get From Dictionary ${trans_id} TransactionID
1051 ${value}= Evaluate ${value} + 10
1052 Set To Dictionary ${trans_id} TransactionID ${value}
1053 Append To List ${trans_id_list} ${trans_id}
1054
1055 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2]
1056 ${value}= Get From Dictionary ${trans_id} TransactionID
1057 ${value}= Evaluate ${value} + 10
1058 Set To Dictionary ${trans_id} TransactionID ${value}
1059 Append To List ${trans_id_list} ${trans_id}
1060
1061 Release Locks On Resource
1062 ... ${session_info} ${trans_id_list}
1063 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
1064 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session
1065
1066 ${trans_id_emptylist}= Create List
1067 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1068 Redfish Delete Session ${session_info}
1069
1070
Sushil Singh8bee3582021-01-27 23:46:48 -06001071Verify Fail To Release Multiple Lock With Valid And Invalid TransactionID
George Keishing96143832021-03-23 07:55:08 -05001072 [Documentation] Verify fail to be release multiple lock with valid and invalid transaction ID.
Sushil Singh8bee3582021-01-27 23:46:48 -06001073 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
1074
1075 # Description of argument(s):
1076 # client_id This client id can contain string value
1077 # (e.g. 12345, "HMCID").
1078 # lock_type Read lock or Write lock.
1079 # release_lock_type The value can be Transaction or Session.
1080
1081 ${trans_id_list}= Create List
1082 @{lock_type_list}= Split String ${lock_type} ,
1083
1084 ${session_info}= Create Redfish Session With ClientID ${client_id}
1085
1086 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1087 Append To List ${trans_id_list} ${trans_id}
1088
1089 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
1090 ${value}= Get From Dictionary ${trans_id} TransactionID
1091 ${value}= Evaluate ${value} + 10
1092 Set To Dictionary ${trans_id} TransactionID ${value}
1093 Append To List ${trans_id_list} ${trans_id}
1094
1095 Release Locks On Resource
1096 ... ${session_info} ${trans_id_list}
1097 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
1098 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session
1099
1100 ${trans_id_emptylist}= Create List
1101 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1102 Redfish Delete Session ${session_info}
1103
1104
susilsi71d7b9962021-03-02 03:06:18 -06001105Verify Fail To Release Lock With TransactionID As String Type
George Keishing96143832021-03-23 07:55:08 -05001106 [Documentation] Verify fail to be release lock with transaction ID as string data type.
susilsi71d7b9962021-03-02 03:06:18 -06001107 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
1108
1109 # Description of argument(s):
1110 # client_id This client id can contain string value
1111 # (e.g. 12345, "HMCID").
1112 # lock_type Read lock or Write lock.
1113 # release_lock_type The value can be Transaction or Session.
1114
1115 ${trans_id_list}= Create List
1116 @{lock_type_list}= Split String ${lock_type} ,
1117
1118 ${session_info}= Create Redfish Session With ClientID ${client_id}
1119
1120 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1121
1122 Append To List ${trans_id_list} ${trans_id}
1123
Sushil Singhf4de7d72023-07-21 08:59:20 -05001124 ${temp_trans_id_list}= Copy List ${trans_id_list} deepcopy=True
susilsi71d7b9962021-03-02 03:06:18 -06001125
1126 ${value}= Get From Dictionary ${trans_id_list}[0] TransactionID
1127 ${value}= Set Variable \'${value}\'
1128 Set To Dictionary ${temp_trans_id_list}[0] TransactionID ${value}
1129
1130 Release Locks On Resource
1131 ... ${session_info} ${temp_trans_id_list}
1132 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
1133
1134 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=${release_lock_type}
1135
1136 ${trans_id_emptylist}= Create List
1137 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1138 Redfish Delete Session ${session_info}
1139
1140
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001141Verify Fail To Release Lock For Another Session
1142 [Documentation] Verify failed to release the lock form another session.
1143 [Arguments] ${client_id} ${lock_type}
1144
1145 # Description of argument(s):
1146 # client_id This client id can contain string value
1147 # (e.g. 12345, "HMCID").
1148 # lock_type Read lock or Write lock.
1149
1150 ${client_ids}= Split String ${client_id} ,
1151 ${lock_type_list}= Split String ${lock_type} ,
1152 ${trans_id_list1}= Create List
1153 ${trans_id_list2}= Create List
1154
1155 ${session_info1}= Create Redfish Session With ClientID ${client_ids}[0]
1156
1157 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1158 Append To List ${trans_id_list1} ${trans_id}
1159 Verify Lock On Resource ${session_info1} ${trans_id_list1}
1160
1161 ${session_info2}= Create Redfish Session With ClientID ${client_ids}[1]
1162 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
1163 Append To List ${trans_id_list2} ${trans_id}
1164 Verify Lock On Resource ${session_info2} ${trans_id_list2}
1165
1166 Release Locks On Resource
Sushil Singhe3f2e3b2022-07-28 05:15:43 -05001167 ... ${session_info1} ${trans_id_list1} Transaction status_code=${HTTP_BAD_REQUEST}
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001168 Verify Lock On Resource ${session_info1} ${trans_id_list1}
1169 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Session
1170 Release Locks On Resource ${session_info2} ${trans_id_list2} release_lock_type=Session
1171 Redfish Delete Session ${session_info1}
1172 Redfish Delete Session ${session_info2}
1173
1174
Sushil Singhe33c6e62020-09-29 06:34:35 -05001175Verify Fail To Acquire Lock For Invalid Resource ID Data Type
1176 [Documentation] Verify fail to acquire the lock with invalid resource id data type.
1177 [Arguments] ${client_id} ${lock_type}
1178
1179 # Description of argument(s):
1180 # client_id This client id can contain string value
1181 # (e.g. 12345, "HMCID").
1182 # lock_type Read lock or Write lock.
1183
1184 ${session_info}= Create Redfish Session With ClientID ${client_id}
1185 Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
1186 ... ${lock_type} status_code=${HTTP_BAD_REQUEST}
1187 Redfish Delete Session ${session_info}
1188
1189
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001190Verify Fail To Acquire Lock For Invalid Lock Data
George Keishing16b3c7b2021-01-28 09:23:37 -06001191 [Documentation] Verify fail to acquired lock with invalid lock types, lock flags, segment flags.
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001192 [Arguments] ${client_id} ${lock_type} ${message}
1193
1194 # Description of argument(s):
1195 # client_id This client id can contain string value
1196 # (e.g. 12345, "HMCID").
1197 # lock_type Read lock or Write lock.
1198 # message Return message from URI.
1199
1200 ${session_info}= Create Redfish Session With ClientID ${client_id}
Sushil Singh8a3efe72021-08-26 08:16:41 -05001201 ${trans_id}= Redfish Post Acquire Invalid Lock
1202 ... ${lock_type} message=${message} status_code=${HTTP_BAD_REQUEST}
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001203 Redfish Delete Session ${session_info}
Sushil Singhbace3002020-10-08 08:12:58 -05001204
1205
1206Verify No Locks Records For Session With No Acquired Lock
1207 [Documentation] Verify no records found for a session where no lock is acquired.
1208 [Arguments] ${client_id}
1209
1210 # Description of argument(s):
1211 # client_id This client id can contain string value
1212 # (e.g. 12345, "HMCID").
1213
1214 ${session_info}= Create Redfish Session With ClientID ${client_id}
1215 ${trans_id_emptylist}= Create List
1216 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1217 Redfish Delete Session ${session_info}
Sushil Singh728ef9c2020-10-28 04:25:39 -05001218
1219
1220Create List Of Session ID
1221 [Documentation] Create session id list from session dict info.
1222 [Arguments] ${session_dict_info}
1223
1224 # Description of argument(s):
1225 # session_dict_info Session information in dict.
1226
1227 @{session_id_list}= Create List
1228
1229 FOR ${session} IN @{session_dict_info}
1230 Append To List ${session_id_list} ${session["SessionIDs"]}
1231 END
1232
1233 ${num_id}= Get Length ${session_id_list}
1234 Should Not Be Equal As Integers ${num_id} ${0}
1235
1236 ${session_id_list}= Evaluate json.dumps(${session_id_list}) json
1237
1238 [Return] ${session_id_list}
1239
1240
1241Get Locks List On Resource With Session List
1242 [Documentation] Get locks list from session of list.
1243 [Arguments] ${session_id_list} ${exp_status_code}=${HTTP_OK}
1244
1245 # Description of argument(s):
1246 # session_id_list Session ids list.
1247 # exp_status_code Expected HTTP status code.
1248
1249 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
George Keishingfbd67002022-08-01 11:24:03 -05001250 ... data={"SessionIDs":${session_id_list}} expected_status=any
susilsi794116c62021-03-04 07:57:51 -06001251 Should Be Equal As Strings ${resp.status_code} ${exp_status_code}
Sushil Singh728ef9c2020-10-28 04:25:39 -05001252 ${locks}= Evaluate json.loads('''${resp.text}''') json
1253
1254 [Return] ${locks}
1255
1256
1257Verify List Of Session Lock On Resource
1258 [Documentation] Verify list of lock record from list of sessions.
1259 [Arguments] ${session_dict_info} ${transaction_id_list}
1260
1261 # Description of argument(s):
1262 # session_dict_info Session information in dict.
1263 # transaction_id_list Transaction id in list stored in dict.
1264
1265 ${session_id_list}= Create List Of Session ID ${session_dict_info}
1266 ${lock_list_resp}= Get Locks List On Resource With Session List ${session_id_list}
1267 ${lock_list}= Set Variable ${lock_list_resp['Records']}
1268
Sushil Singh8a3efe72021-08-26 08:16:41 -05001269 FOR ${session_id} ${tran_id} ${lock_record} IN ZIP
1270 ... ${session_dict_info} ${transaction_id_list} ${lock_list}
Sushil Singh728ef9c2020-10-28 04:25:39 -05001271 Valid Value session_id['SessionIDs'] ['${lock_record['SessionID']}']
1272 Should Be Equal As Integers ${tran_id['TransactionID']} ${lock_record['TransactionID']}
1273 END
1274
1275
1276Verify Lock Records Of Multiple Session
1277 [Documentation] Verify all records found for a multiple sessions.
1278 [Arguments] ${client_ids} ${lock_type}
1279
1280 # Description of argument(s):
1281 # client_ids This client id can contain string value
1282 # (e.g. 12345, "HMCID").
1283 # lock_type Read lock or Write lock.
1284
1285 ${client_id_list}= Split String ${client_ids} ,
1286 ${lock_type_list}= Split String ${lock_type} ,
1287 ${trans_id_list1}= Create List
1288 ${trans_id_list2}= Create List
1289
1290 ${session_dict_list}= Create List
1291 ${lock_list}= Create List
1292
1293 ${client_id1}= Create List
1294 Append To List ${client_id1} ${client_id_list}[0]
1295 ${session_info1}= Create Session With List Of ClientID ${client_id1}
1296 Append To List ${session_dict_list} ${session_info1}[0]
1297 Verify A Session Created With ClientID ${client_id1} ${session_info1}
1298
1299 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1300 Append To List ${trans_id_list1} ${trans_id}
1301 Append To List ${lock_list} ${trans_id}
1302 Verify Lock On Resource ${session_info1}[0] ${trans_id_list1}
1303
1304
1305 ${client_id2}= Create List
1306 Append To List ${client_id2} ${client_id_list}[1]
1307 ${session_info2}= Create Session With List Of ClientID ${client_id2}
1308 Append To List ${session_dict_list} ${session_info2}[0]
1309 Verify A Session Created With ClientID ${client_id2} ${session_info2}
1310
1311 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
1312 Append To List ${trans_id_list2} ${trans_id}
1313 Append To List ${lock_list} ${trans_id}
1314 Verify Lock On Resource ${session_info2}[0] ${trans_id_list2}
1315
1316 Verify List Of Session Lock On Resource ${session_dict_list} ${lock_list}
1317
1318 ${session_token}= Get From Dictionary ${session_info1}[0] SessionToken
1319 Set Global Variable ${XAUTH_TOKEN} ${session_token}
1320
1321 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Transaction
1322
1323 ${session_token}= Get From Dictionary ${session_info2}[0] SessionToken
1324 Set Global Variable ${XAUTH_TOKEN} ${session_token}
1325
1326 Release Locks On Resource ${session_info2} ${trans_id_list2} release_lock_type=Transaction
1327
1328 ${trans_id_emptylist}= Create List
1329 Verify Lock On Resource ${session_info1}[0] ${trans_id_emptylist}
1330 Verify Lock On Resource ${session_info2}[0] ${trans_id_emptylist}
1331
1332 Redfish Delete List Of Session ${session_dict_list}
Sushil Singhf9a536c2020-11-09 07:33:17 -06001333
1334
1335Verify Lock Records For Multiple Invalid Session
1336 [Documentation] Verify no lock record found for multiple invalid session.
1337 [Arguments] ${client_id}
1338
1339 # Description of argument(s):
1340 # client_id This client id can contain string value
1341 # (e.g. 12345, "HMCID").
1342
1343 ${session_dict_list}= Create List
1344 ${invalid_session_ids}= Create List xxyXyyYZZz xXyXYyYZzz
1345
1346 ${session_info1}= Create Session With ClientID ${client_id}
1347
1348 ${session_info2}= Copy Dictionary ${session_info1} deepcopy=True
1349 set to dictionary ${session_info2} SessionIDs ${invalid_session_ids}[0]
1350 Append To List ${session_dict_list} ${session_info2}
1351
1352 ${session_info3}= Copy Dictionary ${session_info1} deepcopy=True
1353 set to dictionary ${session_info3} SessionIDs ${invalid_session_ids}[0]
1354 Append To List ${session_dict_list} ${session_info3}
1355
1356 ${lock_list1}= Get Locks List On Resource ${session_info1}
1357 ${lock_length1}= Get Length ${lock_list1}
1358
1359 ${session_id_list}= Create List Of Session ID ${session_dict_list}
1360 ${lock_list_resp}= Get Locks List On Resource With Session List ${session_id_list}
1361 ${lock_length2}= Get Length ${lock_list_resp['Records']}
1362
1363 Should Be Equal As Integers ${lock_length1} ${lock_length2}
1364
1365 Redfish Delete Session ${session_info1}
Sushil Singh11949a22020-11-13 06:12:16 -06001366
1367
1368Verify Lock Records For Multiple Invalid And Valid Session
1369 [Documentation] Verify all records found for a valid and invalid sessions.
1370 [Arguments] ${client_ids} ${lock_type}
1371
1372 # Description of argument(s):
1373 # client_ids This client id can contain string value
1374 # (e.g. 12345, "HMCID").
1375 # lock_type Read lock or Write lock.
1376
1377 ${client_id_list}= Split String ${client_ids} ,
1378 ${lock_type_list}= Split String ${lock_type} ,
1379 ${trans_id_list1}= Create List
1380 ${invalid_session_ids}= Create List xxyXyyYZZz
1381
1382 ${session_dict_list}= Create List
1383 ${lock_list}= Create List
1384
1385 ${client_id1}= Create List
1386 Append To List ${client_id1} ${client_id_list}[0]
1387 ${session_info1}= Create Session With List Of ClientID ${client_id1}
1388 Append To List ${session_dict_list} ${session_info1}[0]
1389 Verify A Session Created With ClientID ${client_id1} ${session_info1}
1390
1391 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1392 Append To List ${trans_id_list1} ${trans_id}
1393 Append To List ${lock_list} ${trans_id}
1394 Verify Lock On Resource ${session_info1}[0] ${trans_id_list1}
1395
Sushil Singhf4de7d72023-07-21 08:59:20 -05001396 ${session_info2}= Copy List ${session_info1} deepcopy=True
Sushil Singh11949a22020-11-13 06:12:16 -06001397 set to dictionary ${session_info2}[0] SessionIDs ${invalid_session_ids}[0]
1398 Append To List ${session_dict_list} ${session_info2}[0]
1399
1400 Verify List Of Session Lock On Resource ${session_dict_list} ${lock_list}
1401
1402 ${session_token}= Get From Dictionary ${session_info1}[0] SessionToken
1403 Set Global Variable ${XAUTH_TOKEN} ${session_token}
1404
1405 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Transaction
1406
1407 ${trans_id_emptylist}= Create List
1408 Verify Lock On Resource ${session_info1}[0] ${trans_id_emptylist}
1409
1410 Redfish Delete Session ${session_info1}[0]
George Keishing7e49fd52022-12-22 03:11:37 -06001411
1412
1413Delete All Redfish and HMC Sessions
1414 [Documentation] Delete all active redfish sessions.
1415
1416 ${saved_session_info}= Get Redfish Session Info
1417
1418 ${resp_list}= Redfish_Utils.Get Member List
1419 ... /redfish/v1/SessionService/Sessions
1420
1421 # Remove the current login session from the list.
1422 Remove Values From List ${resp_list} ${saved_session_info["location"]}
1423
1424 FOR ${session} IN @{resp_list}
1425 Run Keyword And Ignore Error Redfish.Delete ${session}
1426 END
1427
1428
1429Restart Bmcweb On Failure
1430 [Documentation] Restart bmcweb only if test failed.
1431
1432 Return From Keyword If "${TEST_STATUS}" == "PASS"
1433
1434 # This procedure is needs to be corrected or removed, when we figure out
1435 # what is causing the real failure here.
1436
1437 Log To Console Likely ConnectionResetError: Restarting bmcweb
1438
1439 ${stdout} ${stderr} ${rc}= BMC Execute Command
1440 ... systemctl restart bmcweb print_out=1
1441
1442 Should Be Empty ${stderr}
1443
1444 Sleep 10s reason=Wait for service to restart properly.