blob: 931bb148bb4e7a56a2121bb28d213bec114ec0ce [file] [log] [blame]
Vijaybc331e22020-02-27 04:17:37 -06001*** Settings ***
2
Sushil Singhd03f2ce2020-09-17 08:54:41 -05003Documentation Test lock management feature of management console on BMC.
Vijaybc331e22020-02-27 04:17:37 -06004
Sushil Singhd03f2ce2020-09-17 08:54:41 -05005Resource ../../lib/resource.robot
6Resource ../../lib/openbmc_ffdc.robot
7Resource ../../lib/bmc_redfish_utils.robot
8Resource ../../lib/external_intf/management_console_utils.robot
Sushil Singh977f8f52020-11-20 06:32:50 -06009Resource ../../lib/rest_response_code.robot
Sushil Singh728ef9c2020-10-28 04:25:39 -050010Library ../../lib/bmc_network_utils.py
Vijaybc331e22020-02-27 04:17:37 -060011
Sushil Singhd03f2ce2020-09-17 08:54:41 -050012Suite Setup Run Keyword And Ignore Error Delete All Redfish Sessions
Sushil Singhdf390b62021-01-19 00:50:05 -060013Suite Teardown Run Keyword And Ignore Error Delete All Redfish Sessions
Sushil Singhd03f2ce2020-09-17 08:54:41 -050014Test Setup Printn
15Test Teardown FFDC On Test Case Fail
Vijaybc331e22020-02-27 04:17:37 -060016
17*** Variables ***
18
Sushil Singhd03f2ce2020-09-17 08:54:41 -050019${BAD_REQUEST} Bad Request
Vijaybc331e22020-02-27 04:17:37 -060020
21*** Test Cases ***
22
Sushil Singhd03f2ce2020-09-17 08:54:41 -050023Acquire Read Write Lock
Vijaybc331e22020-02-27 04:17:37 -060024 [Documentation] Acquire and release different read locks.
Sushil Singhd03f2ce2020-09-17 08:54:41 -050025 [Tags] Acquire_Read_Write_Lock
26 [Template] Acquire Lock On Resource
Vijaybc331e22020-02-27 04:17:37 -060027
Sushil Singhd03f2ce2020-09-17 08:54:41 -050028 # client_id lock_type reboot_flag
29 HMCID-01 ReadCase1 False
30 HMCID-01 ReadCase2 False
31 HMCID-01 ReadCase3 False
32 HMCID-01 WriteCase1 False
33 HMCID-01 WriteCase2 False
34 HMCID-01 WriteCase3 False
Vijaybc331e22020-02-27 04:17:37 -060035
36
Sushil Singhd03f2ce2020-09-17 08:54:41 -050037Check Lock Persistency On BMC Reboot
38 [Documentation] Acquire lock and check after reboot it remain same.
39 [Tags] Check_Lock_Persistency_On_BMC_Reboot
40 [Template] Acquire Lock On Resource
Vijaybc331e22020-02-27 04:17:37 -060041
Sushil Singhd03f2ce2020-09-17 08:54:41 -050042 # client_id lock_type reboot_flag
43 HMCID-01 ReadCase1 True
44 HMCID-01 ReadCase2 True
45 HMCID-01 ReadCase3 True
46 HMCID-01 WriteCase1 True
47 HMCID-01 WriteCase2 True
48 HMCID-01 WriteCase3 True
Vijaybc331e22020-02-27 04:17:37 -060049
50
Sushil Singhd03f2ce2020-09-17 08:54:41 -050051Acquire Read Lock On Read Lock
52 [Documentation] Acquire read lock on another read lock.
53 [Tags] Acquire_Read_Lock_On_Read_Lock
54 [Template] Acquire Lock On Another Lock
Vijaybc331e22020-02-27 04:17:37 -060055
Sushil Singhd03f2ce2020-09-17 08:54:41 -050056 # client_id
57 HMCID-01
Vijaybc331e22020-02-27 04:17:37 -060058
59
Sushil Singhd03f2ce2020-09-17 08:54:41 -050060Fail To Acquire Lock On Another Lock
61 [Documentation] Fail to acquire another lock.
62 [Tags] Fail_To_Acquire_Lock_On_Another_Lock
63 [Template] Verify Acquire Lock Fails On Another Lock
Vijay85610ee2020-04-03 05:30:28 -050064
Sushil Singhd03f2ce2020-09-17 08:54:41 -050065 # client_id lock_type
66 HMCID-01 ReadCase2,WriteCase2
67 HMCID-01 WriteCase2,WriteCase2
68 HMCID-01 WriteCase2,ReadCase2
George Keishing566daaf2020-07-02 06:18:50 -050069
70
Sushil Singhe33c6e62020-09-29 06:34:35 -050071Acquire Lock After Reboot
72 [Documentation] Acquire and release read and write locks after reboot.
73 [Tags] Acquire_Lock_After_Reboot
74 [Template] Verify Acquire Lock After Reboot
75
76 # client_id lock_type
77 HMCID-01 ReadCase1
78 HMCID-01 ReadCase2
79 HMCID-01 ReadCase3
80 HMCID-01 WriteCase1
81 HMCID-01 WriteCase2
82 HMCID-01 WriteCase3
83
84
Sushil Singhd03f2ce2020-09-17 08:54:41 -050085Acquire And Release Lock In Loop
86 [Documentation] Acquire and release read, write locks in loop.
87 [Tags] Acquire_And_Release_Lock_In_Loop
88 [Template] Verify Acquire And Release Lock In Loop
George Keishing566daaf2020-07-02 06:18:50 -050089
Sushil Singhd03f2ce2020-09-17 08:54:41 -050090 # client_id lock_type
91 HMCID-01 ReadCase1
92 HMCID-01 ReadCase2
93 HMCID-01 ReadCase3
94 HMCID-01 WriteCase1
95 HMCID-01 WriteCase2
96 HMCID-01 WriteCase3
Vijay85610ee2020-04-03 05:30:28 -050097
98
Sushil Singh977f8f52020-11-20 06:32:50 -060099Fail To Acquire Read And Write In Single Request
100 [Documentation] Fail to acquire read and write lock in single request.
101 [Tags] Fail_To_Acquire_Read_And_Write_In_Single_Request
102 [Template] Verify Fail To Acquire Read And Write In Single Request
103
104 # client_id lock_type
105 HMCID-01 ReadCase1,WriteCase1
106 HMCID-01 WriteCase1,ReadCase1
107
108
Sushil Singhdf390b62021-01-19 00:50:05 -0600109Acquire Multiple Lock Request At CEC Level
110 [Documentation] Acquire write lock on read lock under CEC level.
111 [Tags] Acquire_Multiple_Lock_Request_At_CEC_Level
112 [Template] Verify Acquire Multiple Lock Request At CEC Level
113
114 # client_id lock_type
115 HMCID-01 ReadCase4,WriteCase4
116 HMCID-01 WriteCase5,ReadCase5
117 HMCID-01 ReadCase6,WriteCase6
118 HMCID-01 WriteCase7,ReadCase7
119
120
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500121Verify Release Of Valid Locks
122 [Documentation] Release all valid locks.
123 [Tags] Verify_Release_Of_Valid_Locks
124 [Template] Acquire And Release Multiple Locks
Vijayafdd2a12020-04-09 02:03:20 -0500125
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500126 # client_id lock_type release_lock_type
127 HMCID-01 ReadCase1,ReadCase1,ReadCase1 Transaction
128 HMCID-02 ReadCase1,ReadCase1,ReadCase1 Session
Vijayafdd2a12020-04-09 02:03:20 -0500129
130
susilsi794116c62021-03-04 07:57:51 -0600131Release Lock When Session Deleted
132 [Documentation] Release lock when session gets deleted.
133 [Tags] Release_Lock_When_Session_Deleted
134 [Template] Verify Release Lock When Session Deleted
135
136 # client_id lock_type
137 HMCID-01 ReadCase1
138 HMCID-01 WriteCase1
139
140
Sushil Singh59011d02021-01-27 23:00:20 -0600141Fail To Release Lock With Invalid TransactionID
142 [Documentation] Fail to release lock with invalid transaction id.
143 [Tags] Fail_To_Release_Lock_With_Invalid_TransactionID
144 [Template] Verify Fail To Release Lock With Invalid TransactionID
145
susilsi743b0c062021-03-02 04:24:19 -0600146 # client_id lock_type release_lock_type
147 HMCID-01 ReadCase1 Transaction
148 HMCID-01 WriteCase1 Transaction
Sushil Singh59011d02021-01-27 23:00:20 -0600149
150
Sushil Singh1b590532021-01-20 05:13:54 -0600151Fail To Release Multiple Lock With Invalid TransactionID
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500152 [Documentation] Release in-valid lock result in fail.
Sushil Singh1b590532021-01-20 05:13:54 -0600153 [Tags] Fail_To_Release_Multiple_Lock_With_Invalid_TransactionID
154 [Template] Verify Fail To Release Multiple Lock With Invalid TransactionID
Vijayafdd2a12020-04-09 02:03:20 -0500155
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500156 # client_id lock_type release_lock_type
157 HMCID-01 ReadCase1,ReadCase1,ReadCase1 Transaction
158 12345 ReadCase2,ReadCase2,ReadCase2 Transaction
159 HMCID ReadCase3,ReadCase3,ReadCase3 Transaction
Vijayafdd2a12020-04-09 02:03:20 -0500160
161
Sushil Singh8bee3582021-01-27 23:46:48 -0600162Fail To Release Multiple Lock With Valid And Invalid TransactionID
George Keishing96143832021-03-23 07:55:08 -0500163 [Documentation] Release multiple lock with valid and invalid transaction.
Sushil Singh8bee3582021-01-27 23:46:48 -0600164 [Tags] Fail_To_Release_Multiple_Lock_With_Valid_And_Invalid_TransactionID
165 [Template] Verify Fail To Release Multiple Lock With Valid And Invalid TransactionID
166
167 # client_id lock_type release_lock_type
168 HMCID-01 ReadCase1,ReadCase1 Transaction
169
170
susilsi71d7b9962021-03-02 03:06:18 -0600171Fail To Release Lock With String As TransactionID Data Type
172 [Documentation] Fail to release lock with string as transaction id data type.
173 [Tags] Fail_To_Release_Lock_With_String_As_TransactionID_Data_Type
174 [Template] Verify Fail To Release Lock With TransactionID As String Type
175
176 # client_id lock_type release_lock_type
177 HMCID-01 ReadCase1 Transaction
178 HMCID-01 WriteCase1 Transaction
179
180
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500181Fail To Release Lock For Another Session
182 [Documentation] Failed to release locks from another session.
183 [Tags] Fail_To_Release_Lock_For_Another_Session
184 [Template] Verify Fail To Release Lock For Another Session
Vijayafdd2a12020-04-09 02:03:20 -0500185
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500186 # client_id lock_type
187 HMCID-01,HMCID-02 ReadCase1,ReadCase1
Vijayafdd2a12020-04-09 02:03:20 -0500188
189
Sushil Singhe33c6e62020-09-29 06:34:35 -0500190Test Invalid Resource ID Data Type Locking
191 [Documentation] Failed to acquire lock for invalid resource id data type.
192 [Tags] Test_Invalid_Resource_ID_Data_Type_Locking
193 [Template] Verify Fail To Acquire Lock For Invalid Resource ID Data Type
194
195 # client_id lock_type
196 HMCID-01 ReadCase1
197 HMCID-01 ReadCase2
198 HMCID-01 ReadCase3
199 HMCID-01 WriteCase1
200 HMCID-01 WriteCase2
201 HMCID-01 WriteCase3
202
203
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500204Fail To Acquire Lock For Invalid Lock Type
205 [Documentation] Failed to acquire read, write lock for invalid lock data passed.
206 [Tags] Fail_To_Acquire_Lock_For_Invalid_Lock_Type
207 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
Vijayafdd2a12020-04-09 02:03:20 -0500208
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500209 # client_id lock_type message
210 HMCID-01 ReadCase1 ${BAD_REQUEST}
211 HMCID-01 ReadCase2 ${BAD_REQUEST}
212 HMCID-01 ReadCase3 ${BAD_REQUEST}
213 HMCID-01 ReadCase4 ${BAD_REQUEST}
214 HMCID-01 ReadCase5 ${BAD_REQUEST}
215 HMCID-01 WriteCase1 ${BAD_REQUEST}
216 HMCID-01 WriteCase2 ${BAD_REQUEST}
217 HMCID-01 WriteCase3 ${BAD_REQUEST}
218 HMCID-01 WriteCase4 ${BAD_REQUEST}
219 HMCID-01 WriteCase5 ${BAD_REQUEST}
Vijayafdd2a12020-04-09 02:03:20 -0500220
Vijayafdd2a12020-04-09 02:03:20 -0500221
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500222Fail To Acquire Lock For Invalid Lock Flag
223 [Documentation] Failed to acquire read write lock for invalid lock flag passed.
224 [Tags] Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
225 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
Vijayafdd2a12020-04-09 02:03:20 -0500226
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500227 # client_id lock_type message
228 HMCID-01 ReadCase6 ${BAD_REQUEST}
229 HMCID-01 ReadCase7 ${BAD_REQUEST}
230 HMCID-01 ReadCase8 ${BAD_REQUEST}
231 HMCID-01 ReadCase9 ${BAD_REQUEST}
232 HMCID-01 ReadCase10 ${BAD_REQUEST}
233 HMCID-01 ReadCase11 ${BAD_REQUEST}
234 HMCID-01 WriteCase6 ${BAD_REQUEST}
235 HMCID-01 WriteCase7 ${BAD_REQUEST}
236 HMCID-01 WriteCase8 ${BAD_REQUEST}
237 HMCID-01 WriteCase9 ${BAD_REQUEST}
238 HMCID-01 WriteCase10 ${BAD_REQUEST}
239 HMCID-01 WriteCase11 ${BAD_REQUEST}
Vijayafdd2a12020-04-09 02:03:20 -0500240
Vijayafdd2a12020-04-09 02:03:20 -0500241
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500242Fail To Acquire Lock For Invalid Segment Flag
243 [Documentation] Failed to acquire read write lock for invalid segment flag passed.
244 [Tags] Fail_To_Acquire_Lock_For_Invalid_Segment_Flag
245 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
246
247 # client_id lock_type message
248 HMCID-01 ReadCase12 ${BAD_REQUEST}
249 HMCID-01 ReadCase13 ${BAD_REQUEST}
250 HMCID-01 ReadCase14 ${BAD_REQUEST}
251 HMCID-01 WriteCase12 ${BAD_REQUEST}
252 HMCID-01 WriteCase13 ${BAD_REQUEST}
253 HMCID-01 WriteCase14 ${BAD_REQUEST}
Vijayafdd2a12020-04-09 02:03:20 -0500254
Sushil Singhbace3002020-10-08 08:12:58 -0500255
Sushil Singh3b3a7ec2020-11-23 03:54:06 -0600256Fail To Acquire Lock For Invalid Segment Data Type Flag
257 [Documentation] Failed to acquire read write lock for invalid segment flag passed.
258 [Tags] Fail_To_Acquire_Lock_For_Invalid_Segment_Data_Type_Flag
259 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
260
261 # client_id lock_type message
262 HMCID-01 ReadCase15 ${EMPTY}
263 HMCID-01 ReadCase16 ${EMPTY}
264 HMCID-01 ReadCase17 ${EMPTY}
265 HMCID-01 ReadCase18 ${EMPTY}
266 HMCID-01 WriteCase15 ${EMPTY}
267 HMCID-01 WriteCase16 ${EMPTY}
268 HMCID-01 WriteCase17 ${EMPTY}
269 HMCID-01 WriteCase18 ${EMPTY}
270
271
Sushil Singhbace3002020-10-08 08:12:58 -0500272Get Empty Lock Records For Session Where No Locks Acquired
273 [Documentation] If session does not acquire locks then get lock should return
274 ... empty lock records.
275 [Tags] Get_Empty_Lock_Records_For_Session_Where_No_Locks_Acquired
276 [Template] Verify No Locks Records For Session With No Acquired Lock
277
278 # client_id
279 HMCID-01
280
Sushil Singh728ef9c2020-10-28 04:25:39 -0500281
Sushil Singhf9a536c2020-11-09 07:33:17 -0600282Get Lock Records Empty For Invalid Session
283 [Documentation] Record of lock list is empty for invalid session.
284 [Tags] Get_Lock_Records_Empty_For_Invalid_Session
285 [Template] Verify Empty Lock Records For Invalid Session
286
287 # client_id
288 HMCID-01
289
290
Sushil Singh728ef9c2020-10-28 04:25:39 -0500291Get Lock Records For Multiple Session
292 [Documentation] Get lock records of multiple session.
293 [Tags] Get_Lock_Records_For_Multiple_Session
294 [Template] Verify Lock Records Of Multiple Session
295
296 # client_ids lock_type
297 HMCID-01,HMCID-02 ReadCase1,ReadCase1
298
299
Sushil Singhf9a536c2020-11-09 07:33:17 -0600300Get Lock Records For Multiple Invalid Session
301 [Documentation] Record of lock list is empty for list of invalid session.
302 [Tags] Get_Lock_Records_For_Multiple_Invalid_Session
303 [Template] Verify Lock Records For Multiple Invalid Session
304
305 # client_id
306 HMCID-01
307
Sushil Singh11949a22020-11-13 06:12:16 -0600308
309Get Lock Records For Multiple Invalid And Valid Session
310 [Documentation] Get record of lock from invalid and valid session.
311 [Tags] Get_Lock_Records_For_Multiple_Invalid_And_Valid_Session
312 [Template] Verify Lock Records For Multiple Invalid And Valid Session
313
314 # client_id lock_type
315 HMCID-01,HMCID-02 ReadCase1
316
Vijaybc331e22020-02-27 04:17:37 -0600317*** Keywords ***
318
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500319Create Redfish Session With ClientID
320 [Documentation] Create redifish session with client id.
321 [Arguments] ${client_id}
Vijay85610ee2020-04-03 05:30:28 -0500322
323 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500324 # client_id This client id can contain string value
325 # (e.g. 12345, "HMCID").
Vijay85610ee2020-04-03 05:30:28 -0500326
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500327 ${session_info}= Create Dictionary
328 ${session}= Redfish Login kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
Vijay85610ee2020-04-03 05:30:28 -0500329
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500330 Set To Dictionary ${session_info} SessionIDs ${session['Id']}
331 Set To Dictionary ${session_info} ClientID ${session["Oem"]["OpenBMC"]["ClientID"]}
Vijay85610ee2020-04-03 05:30:28 -0500332
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500333 [Return] ${session_info}
Vijay85610ee2020-04-03 05:30:28 -0500334
335
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500336RW General Dictionary
George Keishing16b3c7b2021-01-28 09:23:37 -0600337 [Documentation] Create dictionary of lock request.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500338 [Arguments] ${read_case} ${res_id}
Vijaybc331e22020-02-27 04:17:37 -0600339
340 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500341 # read_case Read or Write lock type.
342 # res_id Resource id.
Vijaybc331e22020-02-27 04:17:37 -0600343
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500344 ${request_dict}= Create Dictionary
George Keishing566daaf2020-07-02 06:18:50 -0500345
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500346 FOR ${key} IN @{read_case.keys()}
347 Set To Dictionary ${request_dict} LockType ${key}
348 Set To Dictionary ${request_dict} SegmentFlags ${read_case["${key}"]}
349 END
Vijaybc331e22020-02-27 04:17:37 -0600350
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500351 Set To Dictionary ${request_dict} ResourceID ${res_id}
352
353 [Return] ${request_dict}
Vijaybc331e22020-02-27 04:17:37 -0600354
355
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500356Return Description Of Response
357 [Documentation] Return description of REST response.
Vijaybc331e22020-02-27 04:17:37 -0600358 [Arguments] ${resp_text}
359
360 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500361 # resp_text REST response body.
Vijaybc331e22020-02-27 04:17:37 -0600362
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500363 # resp_text after successful partition file upload looks like:
364 # {
365 # "Description": "File Created"
366 # }
Vijaybc331e22020-02-27 04:17:37 -0600367
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500368 ${message}= Evaluate json.loads('''${resp_text}''') json
369
370 [Return] ${message}
Vijaybc331e22020-02-27 04:17:37 -0600371
372
Sushil Singha7d71f02020-11-02 05:24:22 -0600373Verify Redfish Session Deleted
374 [Documentation] Verify the redfish session is deleted.
375 [Arguments] ${session_info}
376
377 # Description of argument(s):
378 # session_info Session information are stored in dictionary.
379
380 # ${session_info} = {
381 # 'SessionIDs': 'XXXXXXXXX',
382 # 'ClientID': 'XXXXXX',
383 # 'SessionToken': 'XXXXXXXXX',
384 # 'SessionResp': session response from redfish login
385 # }
386
387 # SessionIDs : Session IDs
388 # ClientID : Client ID
389 # SessionToken : Session token
390 # SessionResp : Response of creating an redfish login session
391
392 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions
393
394 FOR ${session} IN @{sessions['Members']}
395 Should Not Be Equal As Strings session ['/redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}']
396 END
397
398
399Verify Redfish List Of Session Deleted
400 [Documentation] Verify all the list of redfish session is deleted.
401 [Arguments] ${session_info_list}
402
403 # Description of argument(s):
404 # session_info_list List contains individual session record are stored in dictionary.
405
406 # ${session_info_list} = [{
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 FOR ${session_record} IN @{session_info_list}
419 Verify Redfish Session Deleted ${session_record}
420 END
421
422
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500423Redfish Post Acquire Lock
424 [Documentation] Acquire and release lock.
425 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600426
427 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500428 # lock_type Read lock or Write lock.
429 # status_code HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600430
Sushil Singhe33c6e62020-09-29 06:34:35 -0500431 ${lock_dict_param}= Form Data To Acquire Lock ${lock_type}
432 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500433 Should Be Equal As Strings ${resp.status_code} ${status_code}
Sushil Singhdf390b62021-01-19 00:50:05 -0600434
435 Run Keyword If ${status_code} == ${HTTP_BAD_REQUEST}
436 ... Valid Value ${BAD_REQUEST} ['${resp.content}']
437 ... ELSE
438 ... Run Keyword And Return Return Description Of Response ${resp.content}
Vijaybc331e22020-02-27 04:17:37 -0600439
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500440 [Return] ${resp}
Vijaybc331e22020-02-27 04:17:37 -0600441
442
Sushil Singh977f8f52020-11-20 06:32:50 -0600443Redfish Post Acquire List Lock
444 [Documentation] Acquire and release lock.
445 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
446
447 # Description of argument(s):
448 # lock_type Read lock or Write lock.
449 # status_code HTTP status code.
450
451 ${lock_dict_param}= Create Data To Acquire List Of Lock ${lock_type}
452 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
453 Should Be Equal As Strings ${resp.status_code} ${status_code}
454
455 [Return] ${resp}
456
457
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500458Redfish Post Acquire Invalid Lock
459 [Documentation] Redfish to post request to acquire in-valid lock.
460 [Arguments] ${lock_type} ${message} ${status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600461
462 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500463 # lock_type Read lock or Write lock.
464 # message Return message from URI.
465 # status_code HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600466
Sushil Singhe33c6e62020-09-29 06:34:35 -0500467 ${lock_dict_param}= Form Data To Acquire Invalid Lock ${lock_type}
468 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500469 Should Be Equal As Strings ${resp.status_code} ${status_code}
Sushil Singh3b3a7ec2020-11-23 03:54:06 -0600470 Run Keyword If '${message}' != '${EMPTY}'
471 ... Valid Value message ['${resp.content}']
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500472
473 [Return] ${resp}
Vijaybc331e22020-02-27 04:17:37 -0600474
475
Sushil Singhe33c6e62020-09-29 06:34:35 -0500476Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
477 [Documentation] Redfish to post request to acquire in-valid lock with invalid data type of resource id.
478 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
479
480 # Description of argument(s):
481 # lock_type Read lock or Write lock.
482 # status_code HTTP status code.
483
484 ${lock_dict_param}= Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID ${lock_type}
485 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
486 Should Be Equal As Strings ${resp.status_code} ${status_code}
487
488 [Return] ${resp}
489
490
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500491Form Data To Acquire Lock
George Keishing16b3c7b2021-01-28 09:23:37 -0600492 [Documentation] Create a dictionary for lock request.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500493 [Arguments] ${lock_type}
494
495 # Description of argument(s):
496 # lock_type Read lock or Write lock.
497
498 ${lock_res_info}= Get Lock Resource Information
499 ${resp}= RW General Dictionary
500 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
501 ... ${lock_res_info["Valid Case"]["ResourceID"]}
502 ${temp_list}= Create List ${resp}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500503 ${lock_request_dict}= Create Dictionary Request=${temp_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500504
Sushil Singhe33c6e62020-09-29 06:34:35 -0500505 [Return] ${lock_request_dict}
506
507
Sushil Singh977f8f52020-11-20 06:32:50 -0600508Create Data To Acquire List Of Lock
George Keishing16b3c7b2021-01-28 09:23:37 -0600509 [Documentation] Create a dictionary for list of lock request.
Sushil Singh977f8f52020-11-20 06:32:50 -0600510 [Arguments] ${lock_type_list}
511
512 # Description of argument(s):
513 # lock_type Read lock or Write lock.
514
515 ${temp_list}= Create List
516 ${lock_res_info}= Get Lock Resource Information
517
518 FOR ${lock_type} IN @{lock_type_list}
519 ${resp}= RW General Dictionary
520 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
521 ... ${lock_res_info["Valid Case"]["ResourceID"]}
522 Append To List ${temp_list} ${resp}
523 END
524
525 ${lock_request_dict}= Create Dictionary Request=${temp_list}
526
527 [Return] ${lock_request_dict}
528
529
Sushil Singhe33c6e62020-09-29 06:34:35 -0500530Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
George Keishing16b3c7b2021-01-28 09:23:37 -0600531 [Documentation] Create a dictionary for in-valid lock request.
Sushil Singhe33c6e62020-09-29 06:34:35 -0500532 [Arguments] ${lock_type}
533
534 # Description of argument(s):
535 # lock_type Read lock or Write lock.
536
537 ${lock_res_info}= Get Lock Resource Information
538 ${resp}= RW General Dictionary
539 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
540 ... ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
541 ${temp_list}= Create List ${resp}
542 ${lock_request_dict}= Create Dictionary Request=${temp_list}
543
544 [Return] ${lock_request_dict}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500545
546
547Form Data To Acquire Invalid Lock
George Keishing16b3c7b2021-01-28 09:23:37 -0600548 [Documentation] Create a dictionary for in-valid lock request.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500549 [Arguments] ${lock_type}
550
551 # Description of argument(s):
552 # lock_type Read lock or Write lock.
553
554 ${lock_res_info}= Get Lock Resource Information
555 ${resp}= RW General Dictionary
556 ... ${lock_res_info["Invalid Case"]["${lock_type}"]}
557 ... ${lock_res_info["Valid Case"]["ResourceID"]}
558 ${temp_list}= Create List ${resp}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500559 ${lock_request_dict}= Create Dictionary Request=${temp_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500560
Sushil Singhe33c6e62020-09-29 06:34:35 -0500561 [Return] ${lock_request_dict}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500562
563
564Get Locks List On Resource
Vijaybc331e22020-02-27 04:17:37 -0600565 [Documentation] Get locks list.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500566 [Arguments] ${session_info} ${exp_status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600567
568 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500569 # session_info Session information in dict.
570 # exp_status_code Expected HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600571
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500572 ${data}= Set Variable {"SessionIDs": ["${session_info['SessionIDs']}"]}
George Keishing566daaf2020-07-02 06:18:50 -0500573 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
574 ... data=${data}
Vijaybc331e22020-02-27 04:17:37 -0600575 ${locks}= Evaluate json.loads('''${resp.text}''') json
576
577 [Return] ${locks["Records"]}
578
579
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500580Verify Lock On Resource
581 [Documentation] Verify lock on resource.
582 [Arguments] ${session_info} ${transaction_id}
Vijaybc331e22020-02-27 04:17:37 -0600583
584 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500585 # session_info Session information in dict.
586 # transaction_id Transaction id in list stored in dict.
Vijaybc331e22020-02-27 04:17:37 -0600587
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500588 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
589 Rprint Vars sessions
590 ${lock_list}= Get Locks List On Resource ${session_info}
591 ${lock_length}= Get Length ${lock_list}
592 ${tran_id_length}= Get Length ${transaction_id}
593 Should Be Equal As Integers ${tran_id_length} ${lock_length}
Vijayafdd2a12020-04-09 02:03:20 -0500594
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500595 FOR ${tran_id} ${lock} IN ZIP ${transaction_id} ${lock_list}
596 Valid Value session_info['ClientID'] ['${lock['HMCID']}']
597 Valid Value session_info['SessionIDs'] ['${lock['SessionID']}']
598 Should Be Equal As Integers ${tran_id['TransactionID']} ${lock['TransactionID']}
Vijaybc331e22020-02-27 04:17:37 -0600599 END
600
Vijaybc331e22020-02-27 04:17:37 -0600601
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500602Acquire Lock On Resource
603 [Documentation] Acquire lock on resource.
604 [Arguments] ${client_id} ${lock_type} ${reboot_flag}=False
Vijaybc331e22020-02-27 04:17:37 -0600605
606 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500607 # client_id This client id can contain string value
608 # (e.g. 12345, "HMCID").
609 # lock_type Read lock or Write lock.
610 # reboot_flag Flag is used to run reboot the BMC code.
611 # (e.g. True or False).
Vijaybc331e22020-02-27 04:17:37 -0600612
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500613 ${trans_id_list}= Create List
614 ${session_info}= Create Redfish Session With ClientID ${client_id}
615 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
616 Append To List ${trans_id_list} ${trans_id}
617 Verify Lock On Resource ${session_info} ${trans_id_list}
George Keishing566daaf2020-07-02 06:18:50 -0500618
Sushil Singhe33c6e62020-09-29 06:34:35 -0500619 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
Vijaybc331e22020-02-27 04:17:37 -0600620
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500621 Run Keyword If '${reboot_flag}' == 'True'
622 ... Run Keywords Redfish OBMC Reboot (off) AND
623 ... Redfish Login AND
Sushil Singhe33c6e62020-09-29 06:34:35 -0500624 ... Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} AND
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500625 ... Verify Lock On Resource ${session_info} ${trans_id_list} AND
626 ... Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600627
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500628 Run Keyword If '${reboot_flag}' == 'False'
629 ... Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600630
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500631 ${trans_id_emptylist}= Create List
632 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
633 Redfish Delete Session ${session_info}
Vijaybc331e22020-02-27 04:17:37 -0600634
Vijaybc331e22020-02-27 04:17:37 -0600635
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500636Form Data To Release Lock
637 [Documentation] Create a dictonay to release lock.
638 [Arguments] ${trans_id_list}
Vijay355daac2020-03-26 12:06:08 -0500639
640 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500641 # trans_id_list
Vijay355daac2020-03-26 12:06:08 -0500642
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500643 @{tran_ids}= Create List
Vijay355daac2020-03-26 12:06:08 -0500644
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500645 FOR ${item} IN @{trans_id_list}
646 Append To List ${tran_ids} ${item['TransactionID']}
647 END
648
649 [Return] ${tran_ids}
650
651
652Release Locks On Resource
653 [Documentation] Redfish request to release a lock.
654 [Arguments] ${session_info} ${trans_id_list} ${release_lock_type}=Transaction ${status_code}=${HTTP_OK}
655
656 # Description of argument(s):
657 # session_info Session information in dict.
658 # trans_id_list Transaction id list.
659 # release_lock_type Release lock by Transaction, Session.
660 # status_code HTTP status code.
661
662 ${tran_ids}= Form Data To Release Lock ${trans_id_list}
663 ${data}= Set Variable {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
664 ${data}= Evaluate json.dumps(${data}) json
665 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock data=${data}
666 Should Be Equal As Strings ${resp.status_code} ${status_code}
667
668
Sushil Singhdf390b62021-01-19 00:50:05 -0600669Release locks And Delete Session
670 [Documentation] Release locks and delete redfish session.
671 [Arguments] ${session_info} ${trans_id_list}
672
673 Release Locks On Resource ${session_info} ${trans_id_list}
674
675 ${trans_id_emptylist}= Create List
676 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
677
678 Redfish Delete Session ${session_info}
679
680
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500681Acquire Lock On Another Lock
682 [Documentation] Acquire lock on another lock.
683 [Arguments] ${client_id}
684
685 # Description of argument(s):
686 # client_id This client id can contain string value
687 # (e.g. 12345, "HMCID").
688
689 ${trans_id_list}= Create List
690 ${session_info}= Create Redfish Session With ClientID ${client_id}
691
692 ${trans_id}= Redfish Post Acquire Lock ReadCase1
693 Append To List ${trans_id_list} ${trans_id}
694
695 ${trans_id}= Redfish Post Acquire Lock ReadCase1
696 Append To List ${trans_id_list} ${trans_id}
697
698 Verify Lock On Resource ${session_info} ${trans_id_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500699
Sushil Singhdf390b62021-01-19 00:50:05 -0600700 Release locks And Delete Session ${session_info} ${trans_id_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500701
702
Sushil Singh977f8f52020-11-20 06:32:50 -0600703Verify Fail To Acquire Read And Write In Single Request
704 [Documentation] Verify fail to acquire read and write lock passed in single request.
705 [Arguments] ${client_id} ${lock_type}
706
707 # Description of argument(s):
708 # client_id This client id can contain string value
709 # (e.g. 12345, "HMCID").
710 # lock_type Read lock or Write lock.
711
712 ${lock_type_list}= Split String ${lock_type} ,
713
714 ${session_info}= Create Redfish Session With ClientID ${client_id}
715 ${trans_id}= Redfish Post Acquire List Lock ${lock_type_list} status_code=${HTTP_BAD_REQUEST}
716 Redfish Delete Session ${session_info}
717
718
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500719Verify Empty Lock Records For Invalid Session
720 [Documentation] Verify no lock record found for invalid session.
721 [Arguments] ${client_id}
722
723 # Description of argument(s):
724 # client_id This client id can contain string value
725 # (e.g. 12345, "HMCID").
726
727 ${session_info1}= Create Redfish Session With ClientID ${client_id}
728
729 ${lock_list1}= Get Locks List On Resource ${session_info1}
730 ${lock_length1}= Get Length ${lock_list1}
731
732 ${session_info2}= Copy Dictionary ${session_info1} deepcopy=True
733 set to dictionary ${session_info2} SessionIDs xxyXyyYZZz
734
735 ${lock_list2}= Get Locks List On Resource ${session_info2}
Sushil Singhf9a536c2020-11-09 07:33:17 -0600736 ${lock_length2}= Get Length ${lock_list2}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500737
Sushil Singhf9a536c2020-11-09 07:33:17 -0600738 Should Be Equal As Integers ${lock_length1} ${lock_length2}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500739
740 Redfish Delete Session ${session_info1}
741
742
743Verify Acquire Lock Fails On Another Lock
744 [Documentation] Verify acquire lock on another lock fails.
745 [Arguments] ${client_id} ${lock_type}
746
747 # Description of argument(s):
748 # client_id This client id can contain string value
749 # (e.g. 12345, "HMCID").
750 # lock_type Read lock or Write lock.
751
752 @{lock_type_list}= Split String ${lock_type} ,
753 ${session_info}= Create Redfish Session With ClientID ${client_id}
754 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
755
756 ${trans_id_list}= Create List
757 Append To List ${trans_id_list} ${trans_id}
758
759 Verify Lock On Resource ${session_info} ${trans_id_list}
760 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1] status_code=${HTTP_CONFLICT}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500761
Sushil Singhdf390b62021-01-19 00:50:05 -0600762 Release locks And Delete Session ${session_info} ${trans_id_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500763
764
Sushil Singhe33c6e62020-09-29 06:34:35 -0500765Verify Acquire Lock After Reboot
766 [Documentation] Acquire read and write lock after the reboot and release lock.
767 [Arguments] ${client_id} ${lock_type}
768
769 # Description of argument(s):
770 # client_id This client id can contain string value
771 # (e.g. 12345, "HMCID").
772 # lock_type Read lock or Write lock.
773
774 ${trans_id_list}= Create List
Sushil Singhf9a536c2020-11-09 07:33:17 -0600775 ${session_info}= Create Session With ClientID ${client_id}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500776 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
777 Redfish OBMC Reboot (off)
778 Redfish Login
779 Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token}
780
781 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
782 Append To List ${trans_id_list} ${trans_id}
783 Verify Lock On Resource ${session_info} ${trans_id_list}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500784
Sushil Singhdf390b62021-01-19 00:50:05 -0600785 Release locks And Delete Session ${session_info} ${trans_id_list}
786
787
788Verify Acquire Multiple Lock Request At CEC Level
789 [Documentation] Acquire lock in loop.
790 [Arguments] ${client_id} ${lock_type}
791
792 # Description of argument(s):
793 # client_id This client id can contain string value
794 # (e.g. 12345, "HMCID").
795 # lock_type Read lock or Write lock.
796
797 ${trans_id_list}= Create List
798 @{lock_type_list}= Split String ${lock_type} ,
799 ${session_info}= Create Redfish Session With ClientID ${client_id}
800
801 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
802 Append To List ${trans_id_list} ${trans_id}
803
804 Verify Lock On Resource ${session_info} ${trans_id_list}
805
806 Redfish Post Acquire Lock ${lock_type_list}[1] status_code=${HTTP_CONFLICT}
807
808 Release locks And Delete Session ${session_info} ${trans_id_list}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500809
810
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500811Verify Acquire And Release Lock In Loop
812 [Documentation] Acquire lock in loop.
813 [Arguments] ${client_id} ${lock_type}
814
815 # Description of argument(s):
816 # client_id This client id can contain string value
817 # (e.g. 12345, "HMCID").
818 # lock_type Read lock or Write lock.
819
820 FOR ${count} IN RANGE 1 11
821 ${trans_id_list}= Create List
822 ${session_info}= Create Redfish Session With ClientID ${client_id}
823 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
824 Append To List ${trans_id_list} ${trans_id}
825 Verify Lock On Resource ${session_info} ${trans_id_list}
826 Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
827 ${trans_id_emptylist}= Create List
828 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
829 END
830
831 Redfish Delete Session ${session_info}
832
833
834Acquire And Release Multiple Locks
835 [Documentation] Acquire mutilple locks on resource.
836 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
837
838 # Description of argument(s):
839 # client_id This client id can contain string value
840 # (e.g. 12345, "HMCID").
841 # lock_type Read lock or Write lock.
842 # release_lock_type The value can be Transaction or Session.
843
844 @{lock_type_list}= Split String ${lock_type} ,
845 ${session_info}= Create Redfish Session With ClientID ${client_id}
846 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
847
848 ${trans_id_list}= Create List
849
850 Append To List ${trans_id_list} ${trans_id}
851 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
852
853 Append To List ${trans_id_list} ${trans_id}
854 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2]
855
856 Append To List ${trans_id_list} ${trans_id}
857 Verify Lock On Resource ${session_info} ${trans_id_list}
858 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=${release_lock_type}
859
860 ${trans_id_emptylist}= Create List
861 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
862 Redfish Delete Session ${session_info}
863
864
susilsi794116c62021-03-04 07:57:51 -0600865Verify Release Lock When Session Deleted
866 [Documentation] Verify lock get released when session are deleted.
867 [Arguments] ${client_id} ${lock_type}
868
869 # Description of argument(s):
870 # client_ids This client id can contain string value
871 # (e.g. 12345, "HMCID").
872 # lock_type Read lock or Write lock.
873
874 ${trans_id_list}= Create List
875 @{lock_type_list}= Split String ${lock_type} ,
876
877 ${pre_session_info}= Create Redfish Session With ClientID ${client_id}
878
879 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
880 Append To List ${trans_id_list} ${trans_id}
881 Verify Lock On Resource ${pre_session_info} ${trans_id_list}
882
883 Redfish Delete Session ${pre_session_info}
884 ${post_session_info}= Create Redfish Session With ClientID ${client_id}
885 ${resp}= Get Locks List On Resource With Session List ${pre_session_info} ${HTTP_BAD_REQUEST}
886
887 Redfish Delete Session ${post_session_info}
888
889
890
Sushil Singh59011d02021-01-27 23:00:20 -0600891Verify Fail To Release Lock With Invalid TransactionID
George Keishing16b3c7b2021-01-28 09:23:37 -0600892 [Documentation] Verify fail to be release lock with invalid transaction ID.
Sushil Singh59011d02021-01-27 23:00:20 -0600893 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
894
895 # Description of argument(s):
896 # client_id This client id can contain string value
897 # (e.g. 12345, "HMCID").
898 # lock_type Read lock or Write lock.
899 # release_lock_type The value can be Transaction or Session.
900
901 ${trans_id_list}= Create List
902 @{lock_type_list}= Split String ${lock_type} ,
903
904 ${session_info}= Create Redfish Session With ClientID ${client_id}
905
906 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
907 ${value}= Get From Dictionary ${trans_id} TransactionID
908 ${value}= Evaluate ${value} + 10
909 Set To Dictionary ${trans_id} TransactionID ${value}
910 Append To List ${trans_id_list} ${trans_id}
911
912 Release Locks On Resource
913 ... ${session_info} ${trans_id_list}
914 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
915 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session
916
917 ${trans_id_emptylist}= Create List
918 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
919 Redfish Delete Session ${session_info}
920
921
Sushil Singh1b590532021-01-20 05:13:54 -0600922Verify Fail To Release Multiple Lock With Invalid TransactionID
923 [Documentation] Verify release multiple locks with invalid transaction ID fails.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500924 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
925
926 # Description of argument(s):
927 # client_id This client id can contain string value
928 # (e.g. 12345, "HMCID").
929 # lock_type Read lock or Write lock.
930 # release_lock_type The value can be Transaction or Session.
931
932 ${trans_id_list}= Create List
933 @{lock_type_list}= Split String ${lock_type} ,
934
935 ${session_info}= Create Redfish Session With ClientID ${client_id}
936
937 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
938 ${value}= Get From Dictionary ${trans_id} TransactionID
939 ${value}= Evaluate ${value} + 10
940 Set To Dictionary ${trans_id} TransactionID ${value}
941 Append To List ${trans_id_list} ${trans_id}
942
943 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
944 ${value}= Get From Dictionary ${trans_id} TransactionID
945 ${value}= Evaluate ${value} + 10
946 Set To Dictionary ${trans_id} TransactionID ${value}
947 Append To List ${trans_id_list} ${trans_id}
948
949 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2]
950 ${value}= Get From Dictionary ${trans_id} TransactionID
951 ${value}= Evaluate ${value} + 10
952 Set To Dictionary ${trans_id} TransactionID ${value}
953 Append To List ${trans_id_list} ${trans_id}
954
955 Release Locks On Resource
956 ... ${session_info} ${trans_id_list}
957 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
958 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session
959
960 ${trans_id_emptylist}= Create List
961 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
962 Redfish Delete Session ${session_info}
963
964
Sushil Singh8bee3582021-01-27 23:46:48 -0600965Verify Fail To Release Multiple Lock With Valid And Invalid TransactionID
George Keishing96143832021-03-23 07:55:08 -0500966 [Documentation] Verify fail to be release multiple lock with valid and invalid transaction ID.
Sushil Singh8bee3582021-01-27 23:46:48 -0600967 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
968
969 # Description of argument(s):
970 # client_id This client id can contain string value
971 # (e.g. 12345, "HMCID").
972 # lock_type Read lock or Write lock.
973 # release_lock_type The value can be Transaction or Session.
974
975 ${trans_id_list}= Create List
976 @{lock_type_list}= Split String ${lock_type} ,
977
978 ${session_info}= Create Redfish Session With ClientID ${client_id}
979
980 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
981 Append To List ${trans_id_list} ${trans_id}
982
983 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
984 ${value}= Get From Dictionary ${trans_id} TransactionID
985 ${value}= Evaluate ${value} + 10
986 Set To Dictionary ${trans_id} TransactionID ${value}
987 Append To List ${trans_id_list} ${trans_id}
988
989 Release Locks On Resource
990 ... ${session_info} ${trans_id_list}
991 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
992 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session
993
994 ${trans_id_emptylist}= Create List
995 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
996 Redfish Delete Session ${session_info}
997
998
susilsi71d7b9962021-03-02 03:06:18 -0600999Verify Fail To Release Lock With TransactionID As String Type
George Keishing96143832021-03-23 07:55:08 -05001000 [Documentation] Verify fail to be release lock with transaction ID as string data type.
susilsi71d7b9962021-03-02 03:06:18 -06001001 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
1002
1003 # Description of argument(s):
1004 # client_id This client id can contain string value
1005 # (e.g. 12345, "HMCID").
1006 # lock_type Read lock or Write lock.
1007 # release_lock_type The value can be Transaction or Session.
1008
1009 ${trans_id_list}= Create List
1010 @{lock_type_list}= Split String ${lock_type} ,
1011
1012 ${session_info}= Create Redfish Session With ClientID ${client_id}
1013
1014 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1015
1016 Append To List ${trans_id_list} ${trans_id}
1017
1018 ${temp_trans_id_list}= Copy Dictionary ${trans_id_list} deepcopy=True
1019
1020 ${value}= Get From Dictionary ${trans_id_list}[0] TransactionID
1021 ${value}= Set Variable \'${value}\'
1022 Set To Dictionary ${temp_trans_id_list}[0] TransactionID ${value}
1023
1024 Release Locks On Resource
1025 ... ${session_info} ${temp_trans_id_list}
1026 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
1027
1028 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=${release_lock_type}
1029
1030 ${trans_id_emptylist}= Create List
1031 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1032 Redfish Delete Session ${session_info}
1033
1034
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001035Verify Fail To Release Lock For Another Session
1036 [Documentation] Verify failed to release the lock form another session.
1037 [Arguments] ${client_id} ${lock_type}
1038
1039 # Description of argument(s):
1040 # client_id This client id can contain string value
1041 # (e.g. 12345, "HMCID").
1042 # lock_type Read lock or Write lock.
1043
1044 ${client_ids}= Split String ${client_id} ,
1045 ${lock_type_list}= Split String ${lock_type} ,
1046 ${trans_id_list1}= Create List
1047 ${trans_id_list2}= Create List
1048
1049 ${session_info1}= Create Redfish Session With ClientID ${client_ids}[0]
1050
1051 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1052 Append To List ${trans_id_list1} ${trans_id}
1053 Verify Lock On Resource ${session_info1} ${trans_id_list1}
1054
1055 ${session_info2}= Create Redfish Session With ClientID ${client_ids}[1]
1056 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
1057 Append To List ${trans_id_list2} ${trans_id}
1058 Verify Lock On Resource ${session_info2} ${trans_id_list2}
1059
1060 Release Locks On Resource
1061 ... ${session_info1} ${trans_id_list1} Transaction status_code=${HTTP_UNAUTHORIZED}
1062 Verify Lock On Resource ${session_info1} ${trans_id_list1}
1063 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Session
1064 Release Locks On Resource ${session_info2} ${trans_id_list2} release_lock_type=Session
1065 Redfish Delete Session ${session_info1}
1066 Redfish Delete Session ${session_info2}
1067
1068
Sushil Singhe33c6e62020-09-29 06:34:35 -05001069Verify Fail To Acquire Lock For Invalid Resource ID Data Type
1070 [Documentation] Verify fail to acquire the lock with invalid resource id data type.
1071 [Arguments] ${client_id} ${lock_type}
1072
1073 # Description of argument(s):
1074 # client_id This client id can contain string value
1075 # (e.g. 12345, "HMCID").
1076 # lock_type Read lock or Write lock.
1077
1078 ${session_info}= Create Redfish Session With ClientID ${client_id}
1079 Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
1080 ... ${lock_type} status_code=${HTTP_BAD_REQUEST}
1081 Redfish Delete Session ${session_info}
1082
1083
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001084Verify Fail To Acquire Lock For Invalid Lock Data
George Keishing16b3c7b2021-01-28 09:23:37 -06001085 [Documentation] Verify fail to acquired lock with invalid lock types, lock flags, segment flags.
Sushil Singhd03f2ce2020-09-17 08:54:41 -05001086 [Arguments] ${client_id} ${lock_type} ${message}
1087
1088 # Description of argument(s):
1089 # client_id This client id can contain string value
1090 # (e.g. 12345, "HMCID").
1091 # lock_type Read lock or Write lock.
1092 # message Return message from URI.
1093
1094 ${session_info}= Create Redfish Session With ClientID ${client_id}
1095 ${trans_id}= Redfish Post Acquire Invalid Lock ${lock_type} message=${message} status_code=${HTTP_BAD_REQUEST}
1096 Redfish Delete Session ${session_info}
Sushil Singhbace3002020-10-08 08:12:58 -05001097
1098
1099Verify No Locks Records For Session With No Acquired Lock
1100 [Documentation] Verify no records found for a session where no lock is acquired.
1101 [Arguments] ${client_id}
1102
1103 # Description of argument(s):
1104 # client_id This client id can contain string value
1105 # (e.g. 12345, "HMCID").
1106
1107 ${session_info}= Create Redfish Session With ClientID ${client_id}
1108 ${trans_id_emptylist}= Create List
1109 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
1110 Redfish Delete Session ${session_info}
Sushil Singh728ef9c2020-10-28 04:25:39 -05001111
1112
1113Create List Of Session ID
1114 [Documentation] Create session id list from session dict info.
1115 [Arguments] ${session_dict_info}
1116
1117 # Description of argument(s):
1118 # session_dict_info Session information in dict.
1119
1120 @{session_id_list}= Create List
1121
1122 FOR ${session} IN @{session_dict_info}
1123 Append To List ${session_id_list} ${session["SessionIDs"]}
1124 END
1125
1126 ${num_id}= Get Length ${session_id_list}
1127 Should Not Be Equal As Integers ${num_id} ${0}
1128
1129 ${session_id_list}= Evaluate json.dumps(${session_id_list}) json
1130
1131 [Return] ${session_id_list}
1132
1133
1134Get Locks List On Resource With Session List
1135 [Documentation] Get locks list from session of list.
1136 [Arguments] ${session_id_list} ${exp_status_code}=${HTTP_OK}
1137
1138 # Description of argument(s):
1139 # session_id_list Session ids list.
1140 # exp_status_code Expected HTTP status code.
1141
1142 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
1143 ... data={"SessionIDs": ${session_id_list}}
susilsi794116c62021-03-04 07:57:51 -06001144 Should Be Equal As Strings ${resp.status_code} ${exp_status_code}
Sushil Singh728ef9c2020-10-28 04:25:39 -05001145 ${locks}= Evaluate json.loads('''${resp.text}''') json
1146
1147 [Return] ${locks}
1148
1149
1150Verify List Of Session Lock On Resource
1151 [Documentation] Verify list of lock record from list of sessions.
1152 [Arguments] ${session_dict_info} ${transaction_id_list}
1153
1154 # Description of argument(s):
1155 # session_dict_info Session information in dict.
1156 # transaction_id_list Transaction id in list stored in dict.
1157
1158 ${session_id_list}= Create List Of Session ID ${session_dict_info}
1159 ${lock_list_resp}= Get Locks List On Resource With Session List ${session_id_list}
1160 ${lock_list}= Set Variable ${lock_list_resp['Records']}
1161
1162 FOR ${session_id} ${tran_id} ${lock_record} IN ZIP ${session_dict_info} ${transaction_id_list} ${lock_list}
1163 Valid Value session_id['SessionIDs'] ['${lock_record['SessionID']}']
1164 Should Be Equal As Integers ${tran_id['TransactionID']} ${lock_record['TransactionID']}
1165 END
1166
1167
1168Verify Lock Records Of Multiple Session
1169 [Documentation] Verify all records found for a multiple sessions.
1170 [Arguments] ${client_ids} ${lock_type}
1171
1172 # Description of argument(s):
1173 # client_ids This client id can contain string value
1174 # (e.g. 12345, "HMCID").
1175 # lock_type Read lock or Write lock.
1176
1177 ${client_id_list}= Split String ${client_ids} ,
1178 ${lock_type_list}= Split String ${lock_type} ,
1179 ${trans_id_list1}= Create List
1180 ${trans_id_list2}= Create List
1181
1182 ${session_dict_list}= Create List
1183 ${lock_list}= Create List
1184
1185 ${client_id1}= Create List
1186 Append To List ${client_id1} ${client_id_list}[0]
1187 ${session_info1}= Create Session With List Of ClientID ${client_id1}
1188 Append To List ${session_dict_list} ${session_info1}[0]
1189 Verify A Session Created With ClientID ${client_id1} ${session_info1}
1190
1191 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1192 Append To List ${trans_id_list1} ${trans_id}
1193 Append To List ${lock_list} ${trans_id}
1194 Verify Lock On Resource ${session_info1}[0] ${trans_id_list1}
1195
1196
1197 ${client_id2}= Create List
1198 Append To List ${client_id2} ${client_id_list}[1]
1199 ${session_info2}= Create Session With List Of ClientID ${client_id2}
1200 Append To List ${session_dict_list} ${session_info2}[0]
1201 Verify A Session Created With ClientID ${client_id2} ${session_info2}
1202
1203 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
1204 Append To List ${trans_id_list2} ${trans_id}
1205 Append To List ${lock_list} ${trans_id}
1206 Verify Lock On Resource ${session_info2}[0] ${trans_id_list2}
1207
1208 Verify List Of Session Lock On Resource ${session_dict_list} ${lock_list}
1209
1210 ${session_token}= Get From Dictionary ${session_info1}[0] SessionToken
1211 Set Global Variable ${XAUTH_TOKEN} ${session_token}
1212
1213 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Transaction
1214
1215 ${session_token}= Get From Dictionary ${session_info2}[0] SessionToken
1216 Set Global Variable ${XAUTH_TOKEN} ${session_token}
1217
1218 Release Locks On Resource ${session_info2} ${trans_id_list2} release_lock_type=Transaction
1219
1220 ${trans_id_emptylist}= Create List
1221 Verify Lock On Resource ${session_info1}[0] ${trans_id_emptylist}
1222 Verify Lock On Resource ${session_info2}[0] ${trans_id_emptylist}
1223
1224 Redfish Delete List Of Session ${session_dict_list}
Sushil Singhf9a536c2020-11-09 07:33:17 -06001225
1226
1227Verify Lock Records For Multiple Invalid Session
1228 [Documentation] Verify no lock record found for multiple invalid session.
1229 [Arguments] ${client_id}
1230
1231 # Description of argument(s):
1232 # client_id This client id can contain string value
1233 # (e.g. 12345, "HMCID").
1234
1235 ${session_dict_list}= Create List
1236 ${invalid_session_ids}= Create List xxyXyyYZZz xXyXYyYZzz
1237
1238 ${session_info1}= Create Session With ClientID ${client_id}
1239
1240 ${session_info2}= Copy Dictionary ${session_info1} deepcopy=True
1241 set to dictionary ${session_info2} SessionIDs ${invalid_session_ids}[0]
1242 Append To List ${session_dict_list} ${session_info2}
1243
1244 ${session_info3}= Copy Dictionary ${session_info1} deepcopy=True
1245 set to dictionary ${session_info3} SessionIDs ${invalid_session_ids}[0]
1246 Append To List ${session_dict_list} ${session_info3}
1247
1248 ${lock_list1}= Get Locks List On Resource ${session_info1}
1249 ${lock_length1}= Get Length ${lock_list1}
1250
1251 ${session_id_list}= Create List Of Session ID ${session_dict_list}
1252 ${lock_list_resp}= Get Locks List On Resource With Session List ${session_id_list}
1253 ${lock_length2}= Get Length ${lock_list_resp['Records']}
1254
1255 Should Be Equal As Integers ${lock_length1} ${lock_length2}
1256
1257 Redfish Delete Session ${session_info1}
Sushil Singh11949a22020-11-13 06:12:16 -06001258
1259
1260Verify Lock Records For Multiple Invalid And Valid Session
1261 [Documentation] Verify all records found for a valid and invalid sessions.
1262 [Arguments] ${client_ids} ${lock_type}
1263
1264 # Description of argument(s):
1265 # client_ids This client id can contain string value
1266 # (e.g. 12345, "HMCID").
1267 # lock_type Read lock or Write lock.
1268
1269 ${client_id_list}= Split String ${client_ids} ,
1270 ${lock_type_list}= Split String ${lock_type} ,
1271 ${trans_id_list1}= Create List
1272 ${invalid_session_ids}= Create List xxyXyyYZZz
1273
1274 ${session_dict_list}= Create List
1275 ${lock_list}= Create List
1276
1277 ${client_id1}= Create List
1278 Append To List ${client_id1} ${client_id_list}[0]
1279 ${session_info1}= Create Session With List Of ClientID ${client_id1}
1280 Append To List ${session_dict_list} ${session_info1}[0]
1281 Verify A Session Created With ClientID ${client_id1} ${session_info1}
1282
1283 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
1284 Append To List ${trans_id_list1} ${trans_id}
1285 Append To List ${lock_list} ${trans_id}
1286 Verify Lock On Resource ${session_info1}[0] ${trans_id_list1}
1287
1288 ${session_info2}= Copy Dictionary ${session_info1} deepcopy=True
1289 set to dictionary ${session_info2}[0] SessionIDs ${invalid_session_ids}[0]
1290 Append To List ${session_dict_list} ${session_info2}[0]
1291
1292 Verify List Of Session Lock On Resource ${session_dict_list} ${lock_list}
1293
1294 ${session_token}= Get From Dictionary ${session_info1}[0] SessionToken
1295 Set Global Variable ${XAUTH_TOKEN} ${session_token}
1296
1297 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Transaction
1298
1299 ${trans_id_emptylist}= Create List
1300 Verify Lock On Resource ${session_info1}[0] ${trans_id_emptylist}
1301
1302 Redfish Delete Session ${session_info1}[0]