blob: 399a75ffaef49be0a1a02fb1439b4bffabd09eb5 [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
George Keishing7e49fd52022-12-22 03:11:37 -060013Suite Setup Run Keyword And Ignore Error Delete All Redfish And HMC Sessions
14Suite Teardown Run Keyword And Ignore Error Delete All Redfish And HMC Sessions
15Test Setup Delete All Redfish And HMC Sessions
16Test Teardown Run Keywords FFDC On Test Case Fail AND Restart Bmcweb On Failure
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 Singhd8bf1422021-09-06 05:19:09 -050040Verify Lock Is Not Persistent On BMC Reboot
41 [Documentation] Acquire lock and after reboot the locks are removed as no persistency
42 ... maintained.
43 [Tags] Verify_Lock_Is_Not_Persistent_On_BMC_Reboot
Sushil Singhd03f2ce2020-09-17 08:54:41 -050044 [Template] Acquire Lock On Resource
Vijaybc331e22020-02-27 04:17:37 -060045
Sushil Singhd03f2ce2020-09-17 08:54:41 -050046 # client_id lock_type reboot_flag
47 HMCID-01 ReadCase1 True
48 HMCID-01 ReadCase2 True
49 HMCID-01 ReadCase3 True
50 HMCID-01 WriteCase1 True
51 HMCID-01 WriteCase2 True
52 HMCID-01 WriteCase3 True
Vijaybc331e22020-02-27 04:17:37 -060053
54
Sushil Singh8d420bf2021-09-06 08:27:41 -050055Check After Reboot Transaction ID Set To Default
56 [Documentation] After reboot, the transaction id starts with default i.e. 1,
George Keishing7fd1ac02021-09-23 08:10:33 -050057 ... if any lock is acquired.
Sushil Singh8d420bf2021-09-06 08:27:41 -050058 [Tags] Check_After_Reboot_Transaction_ID_Set_To_Default
59 [Template] Verify Acquire And Release Lock In Loop
60
61 # client_id lock_type reboot_flag
62 HMCID-01 ReadCase1 True
63 HMCID-01 WriteCase1 True
64
65
Sushil Singhd03f2ce2020-09-17 08:54:41 -050066Acquire Read Lock On Read Lock
67 [Documentation] Acquire read lock on another read lock.
68 [Tags] Acquire_Read_Lock_On_Read_Lock
69 [Template] Acquire Lock On Another Lock
Vijaybc331e22020-02-27 04:17:37 -060070
Sushil Singhd03f2ce2020-09-17 08:54:41 -050071 # client_id
72 HMCID-01
Vijaybc331e22020-02-27 04:17:37 -060073
74
Sushil Singhd03f2ce2020-09-17 08:54:41 -050075Fail To Acquire Lock On Another Lock
76 [Documentation] Fail to acquire another lock.
77 [Tags] Fail_To_Acquire_Lock_On_Another_Lock
78 [Template] Verify Acquire Lock Fails On Another Lock
Vijay85610ee2020-04-03 05:30:28 -050079
Sushil Singhd03f2ce2020-09-17 08:54:41 -050080 # client_id lock_type
Sushil Singh5d059942021-09-27 08:41:38 -050081 HMCID-01 ReadCase7,WriteCase6
82 HMCID-01 WriteCase6,WriteCase6
83 HMCID-01 WriteCase6,ReadCase7
George Keishing566daaf2020-07-02 06:18:50 -050084
85
Sushil Singhe33c6e62020-09-29 06:34:35 -050086Acquire Lock After Reboot
87 [Documentation] Acquire and release read and write locks after reboot.
88 [Tags] Acquire_Lock_After_Reboot
89 [Template] Verify Acquire Lock After Reboot
90
91 # client_id lock_type
92 HMCID-01 ReadCase1
93 HMCID-01 ReadCase2
94 HMCID-01 ReadCase3
95 HMCID-01 WriteCase1
96 HMCID-01 WriteCase2
97 HMCID-01 WriteCase3
98
99
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500100Acquire And Release Lock In Loop
101 [Documentation] Acquire and release read, write locks in loop.
102 [Tags] Acquire_And_Release_Lock_In_Loop
103 [Template] Verify Acquire And Release Lock In Loop
George Keishing566daaf2020-07-02 06:18:50 -0500104
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500105 # client_id lock_type
106 HMCID-01 ReadCase1
107 HMCID-01 ReadCase2
108 HMCID-01 ReadCase3
109 HMCID-01 WriteCase1
110 HMCID-01 WriteCase2
111 HMCID-01 WriteCase3
Vijay85610ee2020-04-03 05:30:28 -0500112
113
Sushil Singh977f8f52020-11-20 06:32:50 -0600114Fail To Acquire Read And Write In Single Request
115 [Documentation] Fail to acquire read and write lock in single request.
116 [Tags] Fail_To_Acquire_Read_And_Write_In_Single_Request
117 [Template] Verify Fail To Acquire Read And Write In Single Request
118
Sushil Singhe3f2e3b2022-07-28 05:15:43 -0500119 # client_id lock_type status_code
120 HMCID-01 ReadCase1,WriteCase1 ${HTTP_CONFLICT}
121 HMCID-01 WriteCase1,ReadCase1 ${HTTP_CONFLICT}
122 HMCID-01 WriteCase1,WriteCase1 ${HTTP_CONFLICT}
123
124
125Acquire Read In Single Request
126 [Documentation] Acquire read in single request.
127 [Tags] Acquire_Read_In_Single_Request
128 [Template] Verify Acquire Read In Single Request
129
Sushil Singh977f8f52020-11-20 06:32:50 -0600130 # client_id lock_type
Sushil Singhe3f2e3b2022-07-28 05:15:43 -0500131 HMCID-01 ReadCase1,ReadCase1
Sushil Singh977f8f52020-11-20 06:32:50 -0600132
133
Sushil Singhdf390b62021-01-19 00:50:05 -0600134Acquire Multiple Lock Request At CEC Level
135 [Documentation] Acquire write lock on read lock under CEC level.
136 [Tags] Acquire_Multiple_Lock_Request_At_CEC_Level
137 [Template] Verify Acquire Multiple Lock Request At CEC Level
138
139 # client_id lock_type
140 HMCID-01 ReadCase4,WriteCase4
141 HMCID-01 WriteCase5,ReadCase5
142 HMCID-01 ReadCase6,WriteCase6
143 HMCID-01 WriteCase7,ReadCase7
144
145
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500146Verify Release Of Valid Locks
147 [Documentation] Release all valid locks.
148 [Tags] Verify_Release_Of_Valid_Locks
149 [Template] Acquire And Release Multiple Locks
Vijayafdd2a12020-04-09 02:03:20 -0500150
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500151 # client_id lock_type release_lock_type
152 HMCID-01 ReadCase1,ReadCase1,ReadCase1 Transaction
153 HMCID-02 ReadCase1,ReadCase1,ReadCase1 Session
Vijayafdd2a12020-04-09 02:03:20 -0500154
155
susilsi794116c62021-03-04 07:57:51 -0600156Release Lock When Session Deleted
157 [Documentation] Release lock when session gets deleted.
158 [Tags] Release_Lock_When_Session_Deleted
159 [Template] Verify Release Lock When Session Deleted
160
161 # client_id lock_type
162 HMCID-01 ReadCase1
163 HMCID-01 WriteCase1
164
165
Sushil Singh59011d02021-01-27 23:00:20 -0600166Fail To Release Lock With Invalid TransactionID
167 [Documentation] Fail to release lock with invalid transaction id.
168 [Tags] Fail_To_Release_Lock_With_Invalid_TransactionID
169 [Template] Verify Fail To Release Lock With Invalid TransactionID
170
susilsi743b0c062021-03-02 04:24:19 -0600171 # client_id lock_type release_lock_type
172 HMCID-01 ReadCase1 Transaction
173 HMCID-01 WriteCase1 Transaction
Sushil Singh59011d02021-01-27 23:00:20 -0600174
175
Sushil Singh1b590532021-01-20 05:13:54 -0600176Fail To Release Multiple Lock With Invalid TransactionID
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500177 [Documentation] Release in-valid lock result in fail.
Sushil Singh1b590532021-01-20 05:13:54 -0600178 [Tags] Fail_To_Release_Multiple_Lock_With_Invalid_TransactionID
179 [Template] Verify Fail To Release Multiple Lock With Invalid TransactionID
Vijayafdd2a12020-04-09 02:03:20 -0500180
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500181 # client_id lock_type release_lock_type
182 HMCID-01 ReadCase1,ReadCase1,ReadCase1 Transaction
183 12345 ReadCase2,ReadCase2,ReadCase2 Transaction
184 HMCID ReadCase3,ReadCase3,ReadCase3 Transaction
Vijayafdd2a12020-04-09 02:03:20 -0500185
186
Sushil Singh8bee3582021-01-27 23:46:48 -0600187Fail To Release Multiple Lock With Valid And Invalid TransactionID
George Keishing96143832021-03-23 07:55:08 -0500188 [Documentation] Release multiple lock with valid and invalid transaction.
Sushil Singh8bee3582021-01-27 23:46:48 -0600189 [Tags] Fail_To_Release_Multiple_Lock_With_Valid_And_Invalid_TransactionID
190 [Template] Verify Fail To Release Multiple Lock With Valid And Invalid TransactionID
191
192 # client_id lock_type release_lock_type
193 HMCID-01 ReadCase1,ReadCase1 Transaction
194
195
susilsi71d7b9962021-03-02 03:06:18 -0600196Fail To Release Lock With String As TransactionID Data Type
197 [Documentation] Fail to release lock with string as transaction id data type.
198 [Tags] Fail_To_Release_Lock_With_String_As_TransactionID_Data_Type
199 [Template] Verify Fail To Release Lock With TransactionID As String Type
200
201 # client_id lock_type release_lock_type
202 HMCID-01 ReadCase1 Transaction
203 HMCID-01 WriteCase1 Transaction
204
205
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500206Fail To Release Lock For Another Session
207 [Documentation] Failed to release locks from another session.
208 [Tags] Fail_To_Release_Lock_For_Another_Session
209 [Template] Verify Fail To Release Lock For Another Session
Vijayafdd2a12020-04-09 02:03:20 -0500210
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500211 # client_id lock_type
212 HMCID-01,HMCID-02 ReadCase1,ReadCase1
Vijayafdd2a12020-04-09 02:03:20 -0500213
214
Sushil Singhe33c6e62020-09-29 06:34:35 -0500215Test Invalid Resource ID Data Type Locking
216 [Documentation] Failed to acquire lock for invalid resource id data type.
217 [Tags] Test_Invalid_Resource_ID_Data_Type_Locking
218 [Template] Verify Fail To Acquire Lock For Invalid Resource ID Data Type
219
220 # client_id lock_type
221 HMCID-01 ReadCase1
222 HMCID-01 ReadCase2
223 HMCID-01 ReadCase3
224 HMCID-01 WriteCase1
225 HMCID-01 WriteCase2
226 HMCID-01 WriteCase3
227
228
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500229Fail To Acquire Lock For Invalid Lock Type
230 [Documentation] Failed to acquire read, write lock for invalid lock data passed.
231 [Tags] Fail_To_Acquire_Lock_For_Invalid_Lock_Type
232 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
Vijayafdd2a12020-04-09 02:03:20 -0500233
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500234 # client_id lock_type message
235 HMCID-01 ReadCase1 ${BAD_REQUEST}
236 HMCID-01 ReadCase2 ${BAD_REQUEST}
237 HMCID-01 ReadCase3 ${BAD_REQUEST}
238 HMCID-01 ReadCase4 ${BAD_REQUEST}
239 HMCID-01 ReadCase5 ${BAD_REQUEST}
240 HMCID-01 WriteCase1 ${BAD_REQUEST}
241 HMCID-01 WriteCase2 ${BAD_REQUEST}
242 HMCID-01 WriteCase3 ${BAD_REQUEST}
243 HMCID-01 WriteCase4 ${BAD_REQUEST}
244 HMCID-01 WriteCase5 ${BAD_REQUEST}
Vijayafdd2a12020-04-09 02:03:20 -0500245
Vijayafdd2a12020-04-09 02:03:20 -0500246
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500247Fail To Acquire Lock For Invalid Lock Flag
248 [Documentation] Failed to acquire read write lock for invalid lock flag passed.
249 [Tags] Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
250 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
Vijayafdd2a12020-04-09 02:03:20 -0500251
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500252 # client_id lock_type message
253 HMCID-01 ReadCase6 ${BAD_REQUEST}
254 HMCID-01 ReadCase7 ${BAD_REQUEST}
255 HMCID-01 ReadCase8 ${BAD_REQUEST}
256 HMCID-01 ReadCase9 ${BAD_REQUEST}
257 HMCID-01 ReadCase10 ${BAD_REQUEST}
258 HMCID-01 ReadCase11 ${BAD_REQUEST}
259 HMCID-01 WriteCase6 ${BAD_REQUEST}
260 HMCID-01 WriteCase7 ${BAD_REQUEST}
261 HMCID-01 WriteCase8 ${BAD_REQUEST}
262 HMCID-01 WriteCase9 ${BAD_REQUEST}
263 HMCID-01 WriteCase10 ${BAD_REQUEST}
264 HMCID-01 WriteCase11 ${BAD_REQUEST}
Vijayafdd2a12020-04-09 02:03:20 -0500265
Vijayafdd2a12020-04-09 02:03:20 -0500266
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
George Keishing7e49fd52022-12-22 03:11:37 -0600353 ${session}= Redfish Login kwargs="Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
Vijay85610ee2020-04-03 05:30:28 -0500354
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500355 Set To Dictionary ${session_info} SessionIDs ${session['Id']}
356 Set To Dictionary ${session_info} ClientID ${session["Oem"]["OpenBMC"]["ClientID"]}
Vijay85610ee2020-04-03 05:30:28 -0500357
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500358 [Return] ${session_info}
Vijay85610ee2020-04-03 05:30:28 -0500359
360
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500361RW General Dictionary
George Keishing16b3c7b2021-01-28 09:23:37 -0600362 [Documentation] Create dictionary of lock request.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500363 [Arguments] ${read_case} ${res_id}
Vijaybc331e22020-02-27 04:17:37 -0600364
365 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500366 # read_case Read or Write lock type.
367 # res_id Resource id.
Vijaybc331e22020-02-27 04:17:37 -0600368
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500369 ${request_dict}= Create Dictionary
George Keishing566daaf2020-07-02 06:18:50 -0500370
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500371 FOR ${key} IN @{read_case.keys()}
372 Set To Dictionary ${request_dict} LockType ${key}
373 Set To Dictionary ${request_dict} SegmentFlags ${read_case["${key}"]}
374 END
Vijaybc331e22020-02-27 04:17:37 -0600375
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500376 Set To Dictionary ${request_dict} ResourceID ${res_id}
377
378 [Return] ${request_dict}
Vijaybc331e22020-02-27 04:17:37 -0600379
380
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500381Return Description Of Response
382 [Documentation] Return description of REST response.
Vijaybc331e22020-02-27 04:17:37 -0600383 [Arguments] ${resp_text}
384
385 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500386 # resp_text REST response body.
Vijaybc331e22020-02-27 04:17:37 -0600387
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500388 # resp_text after successful partition file upload looks like:
389 # {
390 # "Description": "File Created"
391 # }
Vijaybc331e22020-02-27 04:17:37 -0600392
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500393 ${message}= Evaluate json.loads('''${resp_text}''') json
394
395 [Return] ${message}
Vijaybc331e22020-02-27 04:17:37 -0600396
397
Sushil Singha7d71f02020-11-02 05:24:22 -0600398Verify Redfish Session Deleted
399 [Documentation] Verify the redfish session is deleted.
400 [Arguments] ${session_info}
401
402 # Description of argument(s):
403 # session_info Session information are stored in dictionary.
404
405 # ${session_info} = {
406 # 'SessionIDs': 'XXXXXXXXX',
407 # 'ClientID': 'XXXXXX',
408 # 'SessionToken': 'XXXXXXXXX',
409 # 'SessionResp': session response from redfish login
410 # }
411
412 # SessionIDs : Session IDs
413 # ClientID : Client ID
414 # SessionToken : Session token
415 # SessionResp : Response of creating an redfish login session
416
417 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions
418
419 FOR ${session} IN @{sessions['Members']}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500420 Should Not Be Equal As Strings
421 ... session ['/redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}']
Sushil Singha7d71f02020-11-02 05:24:22 -0600422 END
423
424
425Verify Redfish List Of Session Deleted
426 [Documentation] Verify all the list of redfish session is deleted.
427 [Arguments] ${session_info_list}
428
429 # Description of argument(s):
430 # session_info_list List contains individual session record are stored in dictionary.
431
432 # ${session_info_list} = [{
433 # 'SessionIDs': 'XXXXXXXXX',
434 # 'ClientID': 'XXXXXX',
435 # 'SessionToken': 'XXXXXXXXX',
436 # 'SessionResp': session response from redfish login
437 # }]
438
439 # SessionIDs : Session IDs
440 # ClientID : Client ID
441 # SessionToken : Session token
442 # SessionResp : Response of creating an redfish login session
443
444 FOR ${session_record} IN @{session_info_list}
445 Verify Redfish Session Deleted ${session_record}
446 END
447
448
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500449Redfish Post Acquire Lock
450 [Documentation] Acquire and release lock.
451 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600452
453 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500454 # lock_type Read lock or Write lock.
455 # status_code HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600456
Sushil Singhe33c6e62020-09-29 06:34:35 -0500457 ${lock_dict_param}= Form Data To Acquire Lock ${lock_type}
George Keishingfbd67002022-08-01 11:24:03 -0500458 ${lock_dict_param}= Convert JSON To String ${lock_dict_param}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500459 ${resp}= Redfish Post Request
460 ... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
George Keishingfbd67002022-08-01 11:24:03 -0500461 ... expected_status=any
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500462 Should Be Equal As Strings ${resp.status_code} ${status_code}
Sushil Singhdf390b62021-01-19 00:50:05 -0600463
464 Run Keyword If ${status_code} == ${HTTP_BAD_REQUEST}
465 ... Valid Value ${BAD_REQUEST} ['${resp.content}']
466 ... ELSE
467 ... Run Keyword And Return Return Description Of Response ${resp.content}
Vijaybc331e22020-02-27 04:17:37 -0600468
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500469 [Return] ${resp}
Vijaybc331e22020-02-27 04:17:37 -0600470
471
Sushil Singh977f8f52020-11-20 06:32:50 -0600472Redfish Post Acquire List Lock
473 [Documentation] Acquire and release lock.
474 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
475
476 # Description of argument(s):
477 # lock_type Read lock or Write lock.
478 # status_code HTTP status code.
479
480 ${lock_dict_param}= Create Data To Acquire List Of Lock ${lock_type}
George Keishingfbd67002022-08-01 11:24:03 -0500481 ${lock_dict_param}= Convert JSON To String ${lock_dict_param}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500482 ${resp}= Redfish Post Request
483 ... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
George Keishingfbd67002022-08-01 11:24:03 -0500484 ... expected_status=any
Sushil Singh977f8f52020-11-20 06:32:50 -0600485 Should Be Equal As Strings ${resp.status_code} ${status_code}
486
Sushil Singhe3f2e3b2022-07-28 05:15:43 -0500487 Run Keyword If ${status_code} == ${HTTP_CONFLICT}
488 ... Should Be Equal As Strings ${CONFLICT_RQUEST} ${resp.content}
489 ... ELSE
490 ... Run Keyword And Return Return Description Of Response ${resp.content}
491
Sushil Singh977f8f52020-11-20 06:32:50 -0600492 [Return] ${resp}
493
494
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500495Redfish Post Acquire Invalid Lock
496 [Documentation] Redfish to post request to acquire in-valid lock.
497 [Arguments] ${lock_type} ${message} ${status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600498
499 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500500 # lock_type Read lock or Write lock.
501 # message Return message from URI.
502 # status_code HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600503
Sushil Singhe33c6e62020-09-29 06:34:35 -0500504 ${lock_dict_param}= Form Data To Acquire Invalid Lock ${lock_type}
George Keishingfbd67002022-08-01 11:24:03 -0500505 ${lock_dict_param}= Convert JSON To String ${lock_dict_param}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500506 ${resp}= Redfish Post Request
507 ... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500508 Should Be Equal As Strings ${resp.status_code} ${status_code}
Sushil Singh3b3a7ec2020-11-23 03:54:06 -0600509 Run Keyword If '${message}' != '${EMPTY}'
510 ... Valid Value message ['${resp.content}']
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500511
512 [Return] ${resp}
Vijaybc331e22020-02-27 04:17:37 -0600513
514
Sushil Singhe33c6e62020-09-29 06:34:35 -0500515Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
516 [Documentation] Redfish to post request to acquire in-valid lock with invalid data type of resource id.
517 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
518
519 # Description of argument(s):
520 # lock_type Read lock or Write lock.
521 # status_code HTTP status code.
522
Sushil Singh8a3efe72021-08-26 08:16:41 -0500523 ${lock_dict_param}=
524 ... Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID ${lock_type}
George Keishingfbd67002022-08-01 11:24:03 -0500525 ${lock_dict_param}= Convert JSON To String ${lock_dict_param}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500526 ${resp}= Redfish Post Request
527 ... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500528 Should Be Equal As Strings ${resp.status_code} ${status_code}
529
530 [Return] ${resp}
531
532
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500533Form Data To Acquire Lock
George Keishing16b3c7b2021-01-28 09:23:37 -0600534 [Documentation] Create a dictionary for lock request.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500535 [Arguments] ${lock_type}
536
537 # Description of argument(s):
538 # lock_type Read lock or Write lock.
539
540 ${lock_res_info}= Get Lock Resource Information
541 ${resp}= RW General Dictionary
542 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
543 ... ${lock_res_info["Valid Case"]["ResourceID"]}
544 ${temp_list}= Create List ${resp}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500545 ${lock_request_dict}= Create Dictionary Request=${temp_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500546
Sushil Singhe33c6e62020-09-29 06:34:35 -0500547 [Return] ${lock_request_dict}
548
549
Sushil Singh977f8f52020-11-20 06:32:50 -0600550Create Data To Acquire List Of Lock
George Keishing16b3c7b2021-01-28 09:23:37 -0600551 [Documentation] Create a dictionary for list of lock request.
Sushil Singh977f8f52020-11-20 06:32:50 -0600552 [Arguments] ${lock_type_list}
553
554 # Description of argument(s):
555 # lock_type Read lock or Write lock.
556
557 ${temp_list}= Create List
558 ${lock_res_info}= Get Lock Resource Information
559
560 FOR ${lock_type} IN @{lock_type_list}
561 ${resp}= RW General Dictionary
562 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
563 ... ${lock_res_info["Valid Case"]["ResourceID"]}
564 Append To List ${temp_list} ${resp}
565 END
566
567 ${lock_request_dict}= Create Dictionary Request=${temp_list}
568
569 [Return] ${lock_request_dict}
570
571
Sushil Singhe33c6e62020-09-29 06:34:35 -0500572Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
George Keishing16b3c7b2021-01-28 09:23:37 -0600573 [Documentation] Create a dictionary for in-valid lock request.
Sushil Singhe33c6e62020-09-29 06:34:35 -0500574 [Arguments] ${lock_type}
575
576 # Description of argument(s):
577 # lock_type Read lock or Write lock.
578
579 ${lock_res_info}= Get Lock Resource Information
580 ${resp}= RW General Dictionary
581 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
582 ... ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
583 ${temp_list}= Create List ${resp}
584 ${lock_request_dict}= Create Dictionary Request=${temp_list}
585
586 [Return] ${lock_request_dict}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500587
588
589Form Data To Acquire Invalid Lock
George Keishing16b3c7b2021-01-28 09:23:37 -0600590 [Documentation] Create a dictionary for in-valid lock request.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500591 [Arguments] ${lock_type}
592
593 # Description of argument(s):
594 # lock_type Read lock or Write lock.
595
596 ${lock_res_info}= Get Lock Resource Information
597 ${resp}= RW General Dictionary
598 ... ${lock_res_info["Invalid Case"]["${lock_type}"]}
599 ... ${lock_res_info["Valid Case"]["ResourceID"]}
600 ${temp_list}= Create List ${resp}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500601 ${lock_request_dict}= Create Dictionary Request=${temp_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500602
Sushil Singhe33c6e62020-09-29 06:34:35 -0500603 [Return] ${lock_request_dict}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500604
605
606Get Locks List On Resource
Vijaybc331e22020-02-27 04:17:37 -0600607 [Documentation] Get locks list.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500608 [Arguments] ${session_info} ${exp_status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600609
610 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500611 # session_info Session information in dict.
612 # exp_status_code Expected HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600613
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500614 ${data}= Set Variable {"SessionIDs": ["${session_info['SessionIDs']}"]}
George Keishing566daaf2020-07-02 06:18:50 -0500615 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
616 ... data=${data}
Vijaybc331e22020-02-27 04:17:37 -0600617 ${locks}= Evaluate json.loads('''${resp.text}''') json
618
619 [Return] ${locks["Records"]}
620
621
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500622Verify Lock On Resource
623 [Documentation] Verify lock on resource.
624 [Arguments] ${session_info} ${transaction_id}
Vijaybc331e22020-02-27 04:17:37 -0600625
626 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500627 # session_info Session information in dict.
628 # transaction_id Transaction id in list stored in dict.
Vijaybc331e22020-02-27 04:17:37 -0600629
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500630 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
631 Rprint Vars sessions
632 ${lock_list}= Get Locks List On Resource ${session_info}
633 ${lock_length}= Get Length ${lock_list}
634 ${tran_id_length}= Get Length ${transaction_id}
635 Should Be Equal As Integers ${tran_id_length} ${lock_length}
Vijayafdd2a12020-04-09 02:03:20 -0500636
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500637 FOR ${tran_id} ${lock} IN ZIP ${transaction_id} ${lock_list}
638 Valid Value session_info['ClientID'] ['${lock['HMCID']}']
639 Valid Value session_info['SessionIDs'] ['${lock['SessionID']}']
640 Should Be Equal As Integers ${tran_id['TransactionID']} ${lock['TransactionID']}
Vijaybc331e22020-02-27 04:17:37 -0600641 END
642
Vijaybc331e22020-02-27 04:17:37 -0600643
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500644Acquire Lock On Resource
645 [Documentation] Acquire lock on resource.
646 [Arguments] ${client_id} ${lock_type} ${reboot_flag}=False
Vijaybc331e22020-02-27 04:17:37 -0600647
648 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500649 # client_id This client id can contain string value
650 # (e.g. 12345, "HMCID").
651 # lock_type Read lock or Write lock.
652 # reboot_flag Flag is used to run reboot the BMC code.
653 # (e.g. True or False).
Vijaybc331e22020-02-27 04:17:37 -0600654
Sushil Singh8a3efe72021-08-26 08:16:41 -0500655 ${trans_id_emptylist}= Create List
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500656 ${trans_id_list}= Create List
Sushil Singh8a3efe72021-08-26 08:16:41 -0500657
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500658 ${session_info}= Create Redfish Session With ClientID ${client_id}
659 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
660 Append To List ${trans_id_list} ${trans_id}
Sushil Singh8a3efe72021-08-26 08:16:41 -0500661
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500662 Verify Lock On Resource ${session_info} ${trans_id_list}
George Keishing566daaf2020-07-02 06:18:50 -0500663
Sushil Singhe33c6e62020-09-29 06:34:35 -0500664 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
Vijaybc331e22020-02-27 04:17:37 -0600665
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500666 Run Keyword If '${reboot_flag}' == 'True'
Sushil Singh8a3efe72021-08-26 08:16:41 -0500667 ... Run Keywords Redfish BMC Reset Operation AND
Sushil Singhe33c6e62020-09-29 06:34:35 -0500668 ... Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} AND
Sushil Singh07b25342022-09-20 09:29:07 -0500669 ... Wait Until Keyword Succeeds 3 min 10 sec Redfish BMC Match States match_state=Enabled AND
Sushil Singh8a3efe72021-08-26 08:16:41 -0500670 ... Is BMC Standby AND
671 ... Verify Lock On Resource ${session_info} ${trans_id_emptylist}
Vijaybc331e22020-02-27 04:17:37 -0600672
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500673 Run Keyword If '${reboot_flag}' == 'False'
674 ... Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600675
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500676 ${trans_id_emptylist}= Create List
677 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
678 Redfish Delete Session ${session_info}
Vijaybc331e22020-02-27 04:17:37 -0600679
Vijaybc331e22020-02-27 04:17:37 -0600680
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500681Form Data To Release Lock
682 [Documentation] Create a dictonay to release lock.
683 [Arguments] ${trans_id_list}
Vijay355daac2020-03-26 12:06:08 -0500684
685 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500686 # trans_id_list
Vijay355daac2020-03-26 12:06:08 -0500687
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500688 @{tran_ids}= Create List
Vijay355daac2020-03-26 12:06:08 -0500689
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500690 FOR ${item} IN @{trans_id_list}
691 Append To List ${tran_ids} ${item['TransactionID']}
692 END
693
694 [Return] ${tran_ids}
695
696
697Release Locks On Resource
698 [Documentation] Redfish request to release a lock.
Sushil Singh8a3efe72021-08-26 08:16:41 -0500699 [Arguments] ${session_info} ${trans_id_list} ${release_lock_type}=Transaction
700 ... ${status_code}=${HTTP_OK}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500701
702 # Description of argument(s):
703 # session_info Session information in dict.
704 # trans_id_list Transaction id list.
705 # release_lock_type Release lock by Transaction, Session.
706 # status_code HTTP status code.
707
708 ${tran_ids}= Form Data To Release Lock ${trans_id_list}
709 ${data}= Set Variable {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
710 ${data}= Evaluate json.dumps(${data}) json
711 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock data=${data}
712 Should Be Equal As Strings ${resp.status_code} ${status_code}
713
714
Sushil Singhdf390b62021-01-19 00:50:05 -0600715Release locks And Delete Session
716 [Documentation] Release locks and delete redfish session.
717 [Arguments] ${session_info} ${trans_id_list}
718
719 Release Locks On Resource ${session_info} ${trans_id_list}
720
721 ${trans_id_emptylist}= Create List
722 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
723
724 Redfish Delete Session ${session_info}
725
726
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500727Acquire Lock On Another Lock
728 [Documentation] Acquire lock on another lock.
729 [Arguments] ${client_id}
730
731 # Description of argument(s):
732 # client_id This client id can contain string value
733 # (e.g. 12345, "HMCID").
734
735 ${trans_id_list}= Create List
736 ${session_info}= Create Redfish Session With ClientID ${client_id}
737
738 ${trans_id}= Redfish Post Acquire Lock ReadCase1
739 Append To List ${trans_id_list} ${trans_id}
740
741 ${trans_id}= Redfish Post Acquire Lock ReadCase1
742 Append To List ${trans_id_list} ${trans_id}
743
744 Verify Lock On Resource ${session_info} ${trans_id_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500745
Sushil Singhdf390b62021-01-19 00:50:05 -0600746 Release locks And Delete Session ${session_info} ${trans_id_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500747
748
Sushil Singh977f8f52020-11-20 06:32:50 -0600749Verify Fail To Acquire Read And Write In Single Request
750 [Documentation] Verify fail to acquire read and write lock passed in single request.
Sushil Singhe3f2e3b2022-07-28 05:15:43 -0500751 [Arguments] ${client_id} ${lock_type} ${status_code}
752
753 # Description of argument(s):
754 # client_id This client id can contain string value
755 # (e.g. 12345, "HMCID").
756 # lock_type Read lock or Write lock.
757 # status_code HTTP status code
758
759 ${lock_type_list}= Split String ${lock_type} ,
760
761 ${session_info}= Create Redfish Session With ClientID ${client_id}
762 ${trans_id}= Redfish Post Acquire List Lock ${lock_type_list} status_code=${status_code}
763 Redfish Delete Session ${session_info}
764
765
766Verify Acquire Read In Single Request
767 [Documentation] Verify acquire read in single request.
Sushil Singh977f8f52020-11-20 06:32:50 -0600768 [Arguments] ${client_id} ${lock_type}
769
770 # Description of argument(s):
771 # client_id This client id can contain string value
772 # (e.g. 12345, "HMCID").
773 # lock_type Read lock or Write lock.
774
Sushil Singhe3f2e3b2022-07-28 05:15:43 -0500775 ${trans_id_list}= Create List
Sushil Singh977f8f52020-11-20 06:32:50 -0600776 ${lock_type_list}= Split String ${lock_type} ,
777
778 ${session_info}= Create Redfish Session With ClientID ${client_id}
Sushil Singhe3f2e3b2022-07-28 05:15:43 -0500779 ${trans_id}= Redfish Post Acquire List Lock ${lock_type_list}
780 Append To List ${trans_id_list} ${trans_id}
781 Append To List ${trans_id_list} ${trans_id}
782
783 Verify Lock On Resource ${session_info} ${trans_id_list}
784 Remove From List ${trans_id_list} 1
785 Release Locks On Resource ${session_info} ${trans_id_list}
786
Sushil Singh977f8f52020-11-20 06:32:50 -0600787 Redfish Delete Session ${session_info}
788
789
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500790Verify Empty Lock Records For Invalid Session
791 [Documentation] Verify no lock record found for invalid session.
792 [Arguments] ${client_id}
793
794 # Description of argument(s):
795 # client_id This client id can contain string value
796 # (e.g. 12345, "HMCID").
797
798 ${session_info1}= Create Redfish Session With ClientID ${client_id}
799
800 ${lock_list1}= Get Locks List On Resource ${session_info1}
801 ${lock_length1}= Get Length ${lock_list1}
802
803 ${session_info2}= Copy Dictionary ${session_info1} deepcopy=True
804 set to dictionary ${session_info2} SessionIDs xxyXyyYZZz
805
806 ${lock_list2}= Get Locks List On Resource ${session_info2}
Sushil Singhf9a536c2020-11-09 07:33:17 -0600807 ${lock_length2}= Get Length ${lock_list2}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500808
Sushil Singhf9a536c2020-11-09 07:33:17 -0600809 Should Be Equal As Integers ${lock_length1} ${lock_length2}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500810
811 Redfish Delete Session ${session_info1}
812
813
814Verify Acquire Lock Fails On Another Lock
815 [Documentation] Verify acquire lock on another lock fails.
816 [Arguments] ${client_id} ${lock_type}
817
818 # Description of argument(s):
819 # client_id This client id can contain string value
820 # (e.g. 12345, "HMCID").
821 # lock_type Read lock or Write lock.
822
823 @{lock_type_list}= Split String ${lock_type} ,
824 ${session_info}= Create Redfish Session With ClientID ${client_id}
825 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
826
827 ${trans_id_list}= Create List
828 Append To List ${trans_id_list} ${trans_id}
829
830 Verify Lock On Resource ${session_info} ${trans_id_list}
831 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1] status_code=${HTTP_CONFLICT}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500832
Sushil Singhdf390b62021-01-19 00:50:05 -0600833 Release locks And Delete Session ${session_info} ${trans_id_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500834
835
Sushil Singhe33c6e62020-09-29 06:34:35 -0500836Verify Acquire Lock After Reboot
837 [Documentation] Acquire read and write lock after the reboot and release lock.
838 [Arguments] ${client_id} ${lock_type}
839
840 # Description of argument(s):
841 # client_id This client id can contain string value
842 # (e.g. 12345, "HMCID").
843 # lock_type Read lock or Write lock.
844
845 ${trans_id_list}= Create List
Sushil Singhf9a536c2020-11-09 07:33:17 -0600846 ${session_info}= Create Session With ClientID ${client_id}
Sushil Singhac229c72021-09-13 02:26:51 -0500847
Sushil Singhe33c6e62020-09-29 06:34:35 -0500848 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
Sushil Singhac229c72021-09-13 02:26:51 -0500849 Redfish BMC Reset Operation
Sushil Singhe33c6e62020-09-29 06:34:35 -0500850 Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token}
Sushil Singh07b25342022-09-20 09:29:07 -0500851 Wait Until Keyword Succeeds 3 min 10 sec Redfish BMC Match States match_state=Enabled
Sushil Singhac229c72021-09-13 02:26:51 -0500852 Is BMC Standby
Sushil Singhe33c6e62020-09-29 06:34:35 -0500853
854 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
855 Append To List ${trans_id_list} ${trans_id}
856 Verify Lock On Resource ${session_info} ${trans_id_list}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500857
Sushil Singhdf390b62021-01-19 00:50:05 -0600858 Release locks And Delete Session ${session_info} ${trans_id_list}
859
860
861Verify Acquire Multiple Lock Request At CEC Level
862 [Documentation] Acquire lock in loop.
863 [Arguments] ${client_id} ${lock_type}
864
865 # Description of argument(s):
866 # client_id This client id can contain string value
867 # (e.g. 12345, "HMCID").
868 # lock_type Read lock or Write lock.
869
870 ${trans_id_list}= Create List
871 @{lock_type_list}= Split String ${lock_type} ,
872 ${session_info}= Create Redfish Session With ClientID ${client_id}
873
874 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
875 Append To List ${trans_id_list} ${trans_id}
876
877 Verify Lock On Resource ${session_info} ${trans_id_list}
878
879 Redfish Post Acquire Lock ${lock_type_list}[1] status_code=${HTTP_CONFLICT}
880
881 Release locks And Delete Session ${session_info} ${trans_id_list}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500882
883
Sushil Singh8d420bf2021-09-06 08:27:41 -0500884Post Reboot Acquire Lock
885 [Documentation] Post reboot acquire lock and verify the transaction id is 1.
886 [Arguments] ${session_info} ${lock_type}
887
888 # Description of argument(s):
889 # session_info Session information.
890 # lock_type Read lock or Write lock.
891
892 ${trans_id_list}= Create List
893 ${trans_id_list_var}= Create List
894 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
895 Append To List ${trans_id_list} ${trans_id}
896 Append To List ${trans_id_list_var} ${default_trans_id}
897 Verify Lock On Resource ${session_info} ${trans_id_list}
898 Verify Lock On Resource ${session_info} ${trans_id_list_var}
899 Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
900 ${trans_id_emptylist}= Create List
901 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
902
903
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500904Verify Acquire And Release Lock In Loop
905 [Documentation] Acquire lock in loop.
Sushil Singh8d420bf2021-09-06 08:27:41 -0500906 [Arguments] ${client_id} ${lock_type} ${reboot_flag}=False
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500907
908 # Description of argument(s):
909 # client_id This client id can contain string value
910 # (e.g. 12345, "HMCID").
911 # lock_type Read lock or Write lock.
Sushil Singh8d420bf2021-09-06 08:27:41 -0500912 # reboot_flag Flag is used to run reboot the BMC code.
913 # (e.g. True or False).
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500914
915 FOR ${count} IN RANGE 1 11
916 ${trans_id_list}= Create List
917 ${session_info}= Create Redfish Session With ClientID ${client_id}
918 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
919 Append To List ${trans_id_list} ${trans_id}
920 Verify Lock On Resource ${session_info} ${trans_id_list}
921 Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
922 ${trans_id_emptylist}= Create List
923 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
Sushil Singh8d420bf2021-09-06 08:27:41 -0500924 Redfish Delete Session ${session_info}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500925 END
926
Sushil Singh8d420bf2021-09-06 08:27:41 -0500927 ${session_info}= Create Redfish Session With ClientID ${client_id}
928 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
929
930 Run Keyword If '${reboot_flag}' == 'True'
931 ... Run Keywords Redfish BMC Reset Operation AND
932 ... Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} AND
Sushil Singh07b25342022-09-20 09:29:07 -0500933 ... Wait Until Keyword Succeeds 3 min 10 sec Redfish BMC Match States match_state=Enabled AND
Sushil Singh8d420bf2021-09-06 08:27:41 -0500934 ... Is BMC Standby AND
935 ... Post Reboot Acquire Lock ${session_info} ${lock_type}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500936 Redfish Delete Session ${session_info}
937
938
939Acquire And Release Multiple Locks
940 [Documentation] Acquire mutilple locks on resource.
941 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
942
943 # Description of argument(s):
944 # client_id This client id can contain string value
945 # (e.g. 12345, "HMCID").
946 # lock_type Read lock or Write lock.
947 # release_lock_type The value can be Transaction or Session.
948
949 @{lock_type_list}= Split String ${lock_type} ,
950 ${session_info}= Create Redfish Session With ClientID ${client_id}
951 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
952
953 ${trans_id_list}= Create List
954
955 Append To List ${trans_id_list} ${trans_id}
956 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
957
958 Append To List ${trans_id_list} ${trans_id}
959 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2]
960
961 Append To List ${trans_id_list} ${trans_id}
962 Verify Lock On Resource ${session_info} ${trans_id_list}
963 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=${release_lock_type}
964
965 ${trans_id_emptylist}= Create List
966 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
967 Redfish Delete Session ${session_info}
968
969
susilsi794116c62021-03-04 07:57:51 -0600970Verify Release Lock When Session Deleted
971 [Documentation] Verify lock get released when session are deleted.
972 [Arguments] ${client_id} ${lock_type}
973
974 # Description of argument(s):
975 # client_ids This client id can contain string value
976 # (e.g. 12345, "HMCID").
977 # lock_type Read lock or Write lock.
978
979 ${trans_id_list}= Create List
980 @{lock_type_list}= Split String ${lock_type} ,
981
982 ${pre_session_info}= Create Redfish Session With ClientID ${client_id}
983
984 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
985 Append To List ${trans_id_list} ${trans_id}
986 Verify Lock On Resource ${pre_session_info} ${trans_id_list}
987
988 Redfish Delete Session ${pre_session_info}
989 ${post_session_info}= Create Redfish Session With ClientID ${client_id}
990 ${resp}= Get Locks List On Resource With Session List ${pre_session_info} ${HTTP_BAD_REQUEST}
991
992 Redfish Delete Session ${post_session_info}
993
994
995
Sushil Singh59011d02021-01-27 23:00:20 -0600996Verify Fail To Release Lock With Invalid TransactionID
George Keishing16b3c7b2021-01-28 09:23:37 -0600997 [Documentation] Verify fail to be release lock with invalid transaction ID.
Sushil Singh59011d02021-01-27 23:00:20 -0600998 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
999
1000 # Description of argument(s):
1001 # client_id This client id can contain string value
1002 # (e.g. 12345, "HMCID").
1003 # lock_type Read lock or Write lock.
1004 # release_lock_type The value can be Transaction or Session.
1005
1006 ${trans_id_list}= Create List
1007 @{lock_type_list}= Split String ${lock_type} ,
1008
1009 ${session_info}= Create Redfish Session With ClientID ${client_id}
1010
1011 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1012 ${value}= Get From Dictionary ${trans_id} TransactionID
1013 ${value}= Evaluate ${value} + 10
1014 Set To Dictionary ${trans_id} TransactionID ${value}
1015 Append To List ${trans_id_list} ${trans_id}
1016
1017 Release Locks On Resource
1018 ... ${session_info} ${trans_id_list}
1019 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
1020 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session
1021
1022 ${trans_id_emptylist}= Create List
1023 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1024 Redfish Delete Session ${session_info}
1025
1026
Sushil Singh1b590532021-01-20 05:13:54 -06001027Verify Fail To Release Multiple Lock With Invalid TransactionID
1028 [Documentation] Verify release multiple locks with invalid transaction ID fails.
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001029 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
1030
1031 # Description of argument(s):
1032 # client_id This client id can contain string value
1033 # (e.g. 12345, "HMCID").
1034 # lock_type Read lock or Write lock.
1035 # release_lock_type The value can be Transaction or Session.
1036
1037 ${trans_id_list}= Create List
1038 @{lock_type_list}= Split String ${lock_type} ,
1039
1040 ${session_info}= Create Redfish Session With ClientID ${client_id}
1041
1042 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1043 ${value}= Get From Dictionary ${trans_id} TransactionID
1044 ${value}= Evaluate ${value} + 10
1045 Set To Dictionary ${trans_id} TransactionID ${value}
1046 Append To List ${trans_id_list} ${trans_id}
1047
1048 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
1049 ${value}= Get From Dictionary ${trans_id} TransactionID
1050 ${value}= Evaluate ${value} + 10
1051 Set To Dictionary ${trans_id} TransactionID ${value}
1052 Append To List ${trans_id_list} ${trans_id}
1053
1054 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2]
1055 ${value}= Get From Dictionary ${trans_id} TransactionID
1056 ${value}= Evaluate ${value} + 10
1057 Set To Dictionary ${trans_id} TransactionID ${value}
1058 Append To List ${trans_id_list} ${trans_id}
1059
1060 Release Locks On Resource
1061 ... ${session_info} ${trans_id_list}
1062 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
1063 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session
1064
1065 ${trans_id_emptylist}= Create List
1066 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1067 Redfish Delete Session ${session_info}
1068
1069
Sushil Singh8bee3582021-01-27 23:46:48 -06001070Verify Fail To Release Multiple Lock With Valid And Invalid TransactionID
George Keishing96143832021-03-23 07:55:08 -05001071 [Documentation] Verify fail to be release multiple lock with valid and invalid transaction ID.
Sushil Singh8bee3582021-01-27 23:46:48 -06001072 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
1073
1074 # Description of argument(s):
1075 # client_id This client id can contain string value
1076 # (e.g. 12345, "HMCID").
1077 # lock_type Read lock or Write lock.
1078 # release_lock_type The value can be Transaction or Session.
1079
1080 ${trans_id_list}= Create List
1081 @{lock_type_list}= Split String ${lock_type} ,
1082
1083 ${session_info}= Create Redfish Session With ClientID ${client_id}
1084
1085 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1086 Append To List ${trans_id_list} ${trans_id}
1087
1088 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
1089 ${value}= Get From Dictionary ${trans_id} TransactionID
1090 ${value}= Evaluate ${value} + 10
1091 Set To Dictionary ${trans_id} TransactionID ${value}
1092 Append To List ${trans_id_list} ${trans_id}
1093
1094 Release Locks On Resource
1095 ... ${session_info} ${trans_id_list}
1096 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
1097 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session
1098
1099 ${trans_id_emptylist}= Create List
1100 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1101 Redfish Delete Session ${session_info}
1102
1103
susilsi71d7b9962021-03-02 03:06:18 -06001104Verify Fail To Release Lock With TransactionID As String Type
George Keishing96143832021-03-23 07:55:08 -05001105 [Documentation] Verify fail to be release lock with transaction ID as string data type.
susilsi71d7b9962021-03-02 03:06:18 -06001106 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
1107
1108 # Description of argument(s):
1109 # client_id This client id can contain string value
1110 # (e.g. 12345, "HMCID").
1111 # lock_type Read lock or Write lock.
1112 # release_lock_type The value can be Transaction or Session.
1113
1114 ${trans_id_list}= Create List
1115 @{lock_type_list}= Split String ${lock_type} ,
1116
1117 ${session_info}= Create Redfish Session With ClientID ${client_id}
1118
1119 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1120
1121 Append To List ${trans_id_list} ${trans_id}
1122
1123 ${temp_trans_id_list}= Copy Dictionary ${trans_id_list} deepcopy=True
1124
1125 ${value}= Get From Dictionary ${trans_id_list}[0] TransactionID
1126 ${value}= Set Variable \'${value}\'
1127 Set To Dictionary ${temp_trans_id_list}[0] TransactionID ${value}
1128
1129 Release Locks On Resource
1130 ... ${session_info} ${temp_trans_id_list}
1131 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
1132
1133 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=${release_lock_type}
1134
1135 ${trans_id_emptylist}= Create List
1136 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1137 Redfish Delete Session ${session_info}
1138
1139
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001140Verify Fail To Release Lock For Another Session
1141 [Documentation] Verify failed to release the lock form another session.
1142 [Arguments] ${client_id} ${lock_type}
1143
1144 # Description of argument(s):
1145 # client_id This client id can contain string value
1146 # (e.g. 12345, "HMCID").
1147 # lock_type Read lock or Write lock.
1148
1149 ${client_ids}= Split String ${client_id} ,
1150 ${lock_type_list}= Split String ${lock_type} ,
1151 ${trans_id_list1}= Create List
1152 ${trans_id_list2}= Create List
1153
1154 ${session_info1}= Create Redfish Session With ClientID ${client_ids}[0]
1155
1156 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1157 Append To List ${trans_id_list1} ${trans_id}
1158 Verify Lock On Resource ${session_info1} ${trans_id_list1}
1159
1160 ${session_info2}= Create Redfish Session With ClientID ${client_ids}[1]
1161 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
1162 Append To List ${trans_id_list2} ${trans_id}
1163 Verify Lock On Resource ${session_info2} ${trans_id_list2}
1164
1165 Release Locks On Resource
Sushil Singhe3f2e3b2022-07-28 05:15:43 -05001166 ... ${session_info1} ${trans_id_list1} Transaction status_code=${HTTP_BAD_REQUEST}
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001167 Verify Lock On Resource ${session_info1} ${trans_id_list1}
1168 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Session
1169 Release Locks On Resource ${session_info2} ${trans_id_list2} release_lock_type=Session
1170 Redfish Delete Session ${session_info1}
1171 Redfish Delete Session ${session_info2}
1172
1173
Sushil Singhe33c6e62020-09-29 06:34:35 -05001174Verify Fail To Acquire Lock For Invalid Resource ID Data Type
1175 [Documentation] Verify fail to acquire the lock with invalid resource id data type.
1176 [Arguments] ${client_id} ${lock_type}
1177
1178 # Description of argument(s):
1179 # client_id This client id can contain string value
1180 # (e.g. 12345, "HMCID").
1181 # lock_type Read lock or Write lock.
1182
1183 ${session_info}= Create Redfish Session With ClientID ${client_id}
1184 Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
1185 ... ${lock_type} status_code=${HTTP_BAD_REQUEST}
1186 Redfish Delete Session ${session_info}
1187
1188
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001189Verify Fail To Acquire Lock For Invalid Lock Data
George Keishing16b3c7b2021-01-28 09:23:37 -06001190 [Documentation] Verify fail to acquired lock with invalid lock types, lock flags, segment flags.
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001191 [Arguments] ${client_id} ${lock_type} ${message}
1192
1193 # Description of argument(s):
1194 # client_id This client id can contain string value
1195 # (e.g. 12345, "HMCID").
1196 # lock_type Read lock or Write lock.
1197 # message Return message from URI.
1198
1199 ${session_info}= Create Redfish Session With ClientID ${client_id}
Sushil Singh8a3efe72021-08-26 08:16:41 -05001200 ${trans_id}= Redfish Post Acquire Invalid Lock
1201 ... ${lock_type} message=${message} status_code=${HTTP_BAD_REQUEST}
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001202 Redfish Delete Session ${session_info}
Sushil Singhbace3002020-10-08 08:12:58 -05001203
1204
1205Verify No Locks Records For Session With No Acquired Lock
1206 [Documentation] Verify no records found for a session where no lock is acquired.
1207 [Arguments] ${client_id}
1208
1209 # Description of argument(s):
1210 # client_id This client id can contain string value
1211 # (e.g. 12345, "HMCID").
1212
1213 ${session_info}= Create Redfish Session With ClientID ${client_id}
1214 ${trans_id_emptylist}= Create List
1215 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1216 Redfish Delete Session ${session_info}
Sushil Singh728ef9c2020-10-28 04:25:39 -05001217
1218
1219Create List Of Session ID
1220 [Documentation] Create session id list from session dict info.
1221 [Arguments] ${session_dict_info}
1222
1223 # Description of argument(s):
1224 # session_dict_info Session information in dict.
1225
1226 @{session_id_list}= Create List
1227
1228 FOR ${session} IN @{session_dict_info}
1229 Append To List ${session_id_list} ${session["SessionIDs"]}
1230 END
1231
1232 ${num_id}= Get Length ${session_id_list}
1233 Should Not Be Equal As Integers ${num_id} ${0}
1234
1235 ${session_id_list}= Evaluate json.dumps(${session_id_list}) json
1236
1237 [Return] ${session_id_list}
1238
1239
1240Get Locks List On Resource With Session List
1241 [Documentation] Get locks list from session of list.
1242 [Arguments] ${session_id_list} ${exp_status_code}=${HTTP_OK}
1243
1244 # Description of argument(s):
1245 # session_id_list Session ids list.
1246 # exp_status_code Expected HTTP status code.
1247
1248 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
George Keishingfbd67002022-08-01 11:24:03 -05001249 ... data={"SessionIDs":${session_id_list}} expected_status=any
susilsi794116c62021-03-04 07:57:51 -06001250 Should Be Equal As Strings ${resp.status_code} ${exp_status_code}
Sushil Singh728ef9c2020-10-28 04:25:39 -05001251 ${locks}= Evaluate json.loads('''${resp.text}''') json
1252
1253 [Return] ${locks}
1254
1255
1256Verify List Of Session Lock On Resource
1257 [Documentation] Verify list of lock record from list of sessions.
1258 [Arguments] ${session_dict_info} ${transaction_id_list}
1259
1260 # Description of argument(s):
1261 # session_dict_info Session information in dict.
1262 # transaction_id_list Transaction id in list stored in dict.
1263
1264 ${session_id_list}= Create List Of Session ID ${session_dict_info}
1265 ${lock_list_resp}= Get Locks List On Resource With Session List ${session_id_list}
1266 ${lock_list}= Set Variable ${lock_list_resp['Records']}
1267
Sushil Singh8a3efe72021-08-26 08:16:41 -05001268 FOR ${session_id} ${tran_id} ${lock_record} IN ZIP
1269 ... ${session_dict_info} ${transaction_id_list} ${lock_list}
Sushil Singh728ef9c2020-10-28 04:25:39 -05001270 Valid Value session_id['SessionIDs'] ['${lock_record['SessionID']}']
1271 Should Be Equal As Integers ${tran_id['TransactionID']} ${lock_record['TransactionID']}
1272 END
1273
1274
1275Verify Lock Records Of Multiple Session
1276 [Documentation] Verify all records found for a multiple sessions.
1277 [Arguments] ${client_ids} ${lock_type}
1278
1279 # Description of argument(s):
1280 # client_ids This client id can contain string value
1281 # (e.g. 12345, "HMCID").
1282 # lock_type Read lock or Write lock.
1283
1284 ${client_id_list}= Split String ${client_ids} ,
1285 ${lock_type_list}= Split String ${lock_type} ,
1286 ${trans_id_list1}= Create List
1287 ${trans_id_list2}= Create List
1288
1289 ${session_dict_list}= Create List
1290 ${lock_list}= Create List
1291
1292 ${client_id1}= Create List
1293 Append To List ${client_id1} ${client_id_list}[0]
1294 ${session_info1}= Create Session With List Of ClientID ${client_id1}
1295 Append To List ${session_dict_list} ${session_info1}[0]
1296 Verify A Session Created With ClientID ${client_id1} ${session_info1}
1297
1298 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1299 Append To List ${trans_id_list1} ${trans_id}
1300 Append To List ${lock_list} ${trans_id}
1301 Verify Lock On Resource ${session_info1}[0] ${trans_id_list1}
1302
1303
1304 ${client_id2}= Create List
1305 Append To List ${client_id2} ${client_id_list}[1]
1306 ${session_info2}= Create Session With List Of ClientID ${client_id2}
1307 Append To List ${session_dict_list} ${session_info2}[0]
1308 Verify A Session Created With ClientID ${client_id2} ${session_info2}
1309
1310 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
1311 Append To List ${trans_id_list2} ${trans_id}
1312 Append To List ${lock_list} ${trans_id}
1313 Verify Lock On Resource ${session_info2}[0] ${trans_id_list2}
1314
1315 Verify List Of Session Lock On Resource ${session_dict_list} ${lock_list}
1316
1317 ${session_token}= Get From Dictionary ${session_info1}[0] SessionToken
1318 Set Global Variable ${XAUTH_TOKEN} ${session_token}
1319
1320 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Transaction
1321
1322 ${session_token}= Get From Dictionary ${session_info2}[0] SessionToken
1323 Set Global Variable ${XAUTH_TOKEN} ${session_token}
1324
1325 Release Locks On Resource ${session_info2} ${trans_id_list2} release_lock_type=Transaction
1326
1327 ${trans_id_emptylist}= Create List
1328 Verify Lock On Resource ${session_info1}[0] ${trans_id_emptylist}
1329 Verify Lock On Resource ${session_info2}[0] ${trans_id_emptylist}
1330
1331 Redfish Delete List Of Session ${session_dict_list}
Sushil Singhf9a536c2020-11-09 07:33:17 -06001332
1333
1334Verify Lock Records For Multiple Invalid Session
1335 [Documentation] Verify no lock record found for multiple invalid session.
1336 [Arguments] ${client_id}
1337
1338 # Description of argument(s):
1339 # client_id This client id can contain string value
1340 # (e.g. 12345, "HMCID").
1341
1342 ${session_dict_list}= Create List
1343 ${invalid_session_ids}= Create List xxyXyyYZZz xXyXYyYZzz
1344
1345 ${session_info1}= Create Session With ClientID ${client_id}
1346
1347 ${session_info2}= Copy Dictionary ${session_info1} deepcopy=True
1348 set to dictionary ${session_info2} SessionIDs ${invalid_session_ids}[0]
1349 Append To List ${session_dict_list} ${session_info2}
1350
1351 ${session_info3}= Copy Dictionary ${session_info1} deepcopy=True
1352 set to dictionary ${session_info3} SessionIDs ${invalid_session_ids}[0]
1353 Append To List ${session_dict_list} ${session_info3}
1354
1355 ${lock_list1}= Get Locks List On Resource ${session_info1}
1356 ${lock_length1}= Get Length ${lock_list1}
1357
1358 ${session_id_list}= Create List Of Session ID ${session_dict_list}
1359 ${lock_list_resp}= Get Locks List On Resource With Session List ${session_id_list}
1360 ${lock_length2}= Get Length ${lock_list_resp['Records']}
1361
1362 Should Be Equal As Integers ${lock_length1} ${lock_length2}
1363
1364 Redfish Delete Session ${session_info1}
Sushil Singh11949a22020-11-13 06:12:16 -06001365
1366
1367Verify Lock Records For Multiple Invalid And Valid Session
1368 [Documentation] Verify all records found for a valid and invalid sessions.
1369 [Arguments] ${client_ids} ${lock_type}
1370
1371 # Description of argument(s):
1372 # client_ids This client id can contain string value
1373 # (e.g. 12345, "HMCID").
1374 # lock_type Read lock or Write lock.
1375
1376 ${client_id_list}= Split String ${client_ids} ,
1377 ${lock_type_list}= Split String ${lock_type} ,
1378 ${trans_id_list1}= Create List
1379 ${invalid_session_ids}= Create List xxyXyyYZZz
1380
1381 ${session_dict_list}= Create List
1382 ${lock_list}= Create List
1383
1384 ${client_id1}= Create List
1385 Append To List ${client_id1} ${client_id_list}[0]
1386 ${session_info1}= Create Session With List Of ClientID ${client_id1}
1387 Append To List ${session_dict_list} ${session_info1}[0]
1388 Verify A Session Created With ClientID ${client_id1} ${session_info1}
1389
1390 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1391 Append To List ${trans_id_list1} ${trans_id}
1392 Append To List ${lock_list} ${trans_id}
1393 Verify Lock On Resource ${session_info1}[0] ${trans_id_list1}
1394
1395 ${session_info2}= Copy Dictionary ${session_info1} deepcopy=True
1396 set to dictionary ${session_info2}[0] SessionIDs ${invalid_session_ids}[0]
1397 Append To List ${session_dict_list} ${session_info2}[0]
1398
1399 Verify List Of Session Lock On Resource ${session_dict_list} ${lock_list}
1400
1401 ${session_token}= Get From Dictionary ${session_info1}[0] SessionToken
1402 Set Global Variable ${XAUTH_TOKEN} ${session_token}
1403
1404 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Transaction
1405
1406 ${trans_id_emptylist}= Create List
1407 Verify Lock On Resource ${session_info1}[0] ${trans_id_emptylist}
1408
1409 Redfish Delete Session ${session_info1}[0]
George Keishing7e49fd52022-12-22 03:11:37 -06001410
1411
1412Delete All Redfish and HMC Sessions
1413 [Documentation] Delete all active redfish sessions.
1414
1415 ${saved_session_info}= Get Redfish Session Info
1416
1417 ${resp_list}= Redfish_Utils.Get Member List
1418 ... /redfish/v1/SessionService/Sessions
1419
1420 # Remove the current login session from the list.
1421 Remove Values From List ${resp_list} ${saved_session_info["location"]}
1422
1423 FOR ${session} IN @{resp_list}
1424 Run Keyword And Ignore Error Redfish.Delete ${session}
1425 END
1426
1427
1428Restart Bmcweb On Failure
1429 [Documentation] Restart bmcweb only if test failed.
1430
1431 Return From Keyword If "${TEST_STATUS}" == "PASS"
1432
1433 # This procedure is needs to be corrected or removed, when we figure out
1434 # what is causing the real failure here.
1435
1436 Log To Console Likely ConnectionResetError: Restarting bmcweb
1437
1438 ${stdout} ${stderr} ${rc}= BMC Execute Command
1439 ... systemctl restart bmcweb print_out=1
1440
1441 Should Be Empty ${stderr}
1442
1443 Sleep 10s reason=Wait for service to restart properly.