blob: e2393efa451d0970e2838103470f89f0859933af [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
Vijaybc331e22020-02-27 04:17:37 -06009
Sushil Singhd03f2ce2020-09-17 08:54:41 -050010Suite Setup Run Keyword And Ignore Error Delete All Redfish Sessions
11Suite Teardown Redfish.Logout
12Test Setup Printn
13Test Teardown FFDC On Test Case Fail
Vijaybc331e22020-02-27 04:17:37 -060014
15*** Variables ***
16
Sushil Singhd03f2ce2020-09-17 08:54:41 -050017${BAD_REQUEST} Bad Request
Vijaybc331e22020-02-27 04:17:37 -060018
19*** Test Cases ***
20
Sushil Singhd03f2ce2020-09-17 08:54:41 -050021Acquire Read Write Lock
Vijaybc331e22020-02-27 04:17:37 -060022 [Documentation] Acquire and release different read locks.
Sushil Singhd03f2ce2020-09-17 08:54:41 -050023 [Tags] Acquire_Read_Write_Lock
24 [Template] Acquire Lock On Resource
Vijaybc331e22020-02-27 04:17:37 -060025
Sushil Singhd03f2ce2020-09-17 08:54:41 -050026 # client_id lock_type reboot_flag
27 HMCID-01 ReadCase1 False
28 HMCID-01 ReadCase2 False
29 HMCID-01 ReadCase3 False
30 HMCID-01 WriteCase1 False
31 HMCID-01 WriteCase2 False
32 HMCID-01 WriteCase3 False
Vijaybc331e22020-02-27 04:17:37 -060033
34
Sushil Singhd03f2ce2020-09-17 08:54:41 -050035Check Lock Persistency On BMC Reboot
36 [Documentation] Acquire lock and check after reboot it remain same.
37 [Tags] Check_Lock_Persistency_On_BMC_Reboot
38 [Template] Acquire Lock On Resource
Vijaybc331e22020-02-27 04:17:37 -060039
Sushil Singhd03f2ce2020-09-17 08:54:41 -050040 # client_id lock_type reboot_flag
41 HMCID-01 ReadCase1 True
42 HMCID-01 ReadCase2 True
43 HMCID-01 ReadCase3 True
44 HMCID-01 WriteCase1 True
45 HMCID-01 WriteCase2 True
46 HMCID-01 WriteCase3 True
Vijaybc331e22020-02-27 04:17:37 -060047
48
Sushil Singhd03f2ce2020-09-17 08:54:41 -050049Acquire Read Lock On Read Lock
50 [Documentation] Acquire read lock on another read lock.
51 [Tags] Acquire_Read_Lock_On_Read_Lock
52 [Template] Acquire Lock On Another Lock
Vijaybc331e22020-02-27 04:17:37 -060053
Sushil Singhd03f2ce2020-09-17 08:54:41 -050054 # client_id
55 HMCID-01
Vijaybc331e22020-02-27 04:17:37 -060056
57
Sushil Singhd03f2ce2020-09-17 08:54:41 -050058Get Lock Records Empty For Invalid Session
59 [Documentation] Record of lock list is empty for invalid session.
60 [Tags] Get_Lock_Records_Empty_For_Invalid_Session
61 [Template] Verify Empty Lock Records For Invalid Session
Vijay355daac2020-03-26 12:06:08 -050062
Sushil Singhd03f2ce2020-09-17 08:54:41 -050063 # client_id
64 HMCID-01
Vijay355daac2020-03-26 12:06:08 -050065
66
Sushil Singhd03f2ce2020-09-17 08:54:41 -050067Fail To Acquire Lock On Another Lock
68 [Documentation] Fail to acquire another lock.
69 [Tags] Fail_To_Acquire_Lock_On_Another_Lock
70 [Template] Verify Acquire Lock Fails On Another Lock
Vijay85610ee2020-04-03 05:30:28 -050071
Sushil Singhd03f2ce2020-09-17 08:54:41 -050072 # client_id lock_type
73 HMCID-01 ReadCase2,WriteCase2
74 HMCID-01 WriteCase2,WriteCase2
75 HMCID-01 WriteCase2,ReadCase2
George Keishing566daaf2020-07-02 06:18:50 -050076
77
Sushil Singhd03f2ce2020-09-17 08:54:41 -050078Acquire And Release Lock In Loop
79 [Documentation] Acquire and release read, write locks in loop.
80 [Tags] Acquire_And_Release_Lock_In_Loop
81 [Template] Verify Acquire And Release Lock In Loop
George Keishing566daaf2020-07-02 06:18:50 -050082
Sushil Singhd03f2ce2020-09-17 08:54:41 -050083 # client_id lock_type
84 HMCID-01 ReadCase1
85 HMCID-01 ReadCase2
86 HMCID-01 ReadCase3
87 HMCID-01 WriteCase1
88 HMCID-01 WriteCase2
89 HMCID-01 WriteCase3
Vijay85610ee2020-04-03 05:30:28 -050090
91
Sushil Singhd03f2ce2020-09-17 08:54:41 -050092Verify Release Of Valid Locks
93 [Documentation] Release all valid locks.
94 [Tags] Verify_Release_Of_Valid_Locks
95 [Template] Acquire And Release Multiple Locks
Vijayafdd2a12020-04-09 02:03:20 -050096
Sushil Singhd03f2ce2020-09-17 08:54:41 -050097 # client_id lock_type release_lock_type
98 HMCID-01 ReadCase1,ReadCase1,ReadCase1 Transaction
99 HMCID-02 ReadCase1,ReadCase1,ReadCase1 Session
Vijayafdd2a12020-04-09 02:03:20 -0500100
101
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500102Invalid Locks Fail To Release
103 [Documentation] Release in-valid lock result in fail.
104 [Tags] Invalid_Locks_Fail_To_Release
105 [Template] Verify Invalid Locks Fail To Release
Vijayafdd2a12020-04-09 02:03:20 -0500106
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500107 # client_id lock_type release_lock_type
108 HMCID-01 ReadCase1,ReadCase1,ReadCase1 Transaction
109 12345 ReadCase2,ReadCase2,ReadCase2 Transaction
110 HMCID ReadCase3,ReadCase3,ReadCase3 Transaction
Vijayafdd2a12020-04-09 02:03:20 -0500111
112
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500113Fail To Release Lock For Another Session
114 [Documentation] Failed to release locks from another session.
115 [Tags] Fail_To_Release_Lock_For_Another_Session
116 [Template] Verify Fail To Release Lock For Another Session
Vijayafdd2a12020-04-09 02:03:20 -0500117
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500118 # client_id lock_type
119 HMCID-01,HMCID-02 ReadCase1,ReadCase1
Vijayafdd2a12020-04-09 02:03:20 -0500120
121
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500122Fail To Acquire Lock For Invalid Lock Type
123 [Documentation] Failed to acquire read, write lock for invalid lock data passed.
124 [Tags] Fail_To_Acquire_Lock_For_Invalid_Lock_Type
125 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
Vijayafdd2a12020-04-09 02:03:20 -0500126
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500127 # client_id lock_type message
128 HMCID-01 ReadCase1 ${BAD_REQUEST}
129 HMCID-01 ReadCase2 ${BAD_REQUEST}
130 HMCID-01 ReadCase3 ${BAD_REQUEST}
131 HMCID-01 ReadCase4 ${BAD_REQUEST}
132 HMCID-01 ReadCase5 ${BAD_REQUEST}
133 HMCID-01 WriteCase1 ${BAD_REQUEST}
134 HMCID-01 WriteCase2 ${BAD_REQUEST}
135 HMCID-01 WriteCase3 ${BAD_REQUEST}
136 HMCID-01 WriteCase4 ${BAD_REQUEST}
137 HMCID-01 WriteCase5 ${BAD_REQUEST}
Vijayafdd2a12020-04-09 02:03:20 -0500138
Vijayafdd2a12020-04-09 02:03:20 -0500139
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500140Fail To Acquire Lock For Invalid Lock Flag
141 [Documentation] Failed to acquire read write lock for invalid lock flag passed.
142 [Tags] Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
143 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
Vijayafdd2a12020-04-09 02:03:20 -0500144
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500145 # client_id lock_type message
146 HMCID-01 ReadCase6 ${BAD_REQUEST}
147 HMCID-01 ReadCase7 ${BAD_REQUEST}
148 HMCID-01 ReadCase8 ${BAD_REQUEST}
149 HMCID-01 ReadCase9 ${BAD_REQUEST}
150 HMCID-01 ReadCase10 ${BAD_REQUEST}
151 HMCID-01 ReadCase11 ${BAD_REQUEST}
152 HMCID-01 WriteCase6 ${BAD_REQUEST}
153 HMCID-01 WriteCase7 ${BAD_REQUEST}
154 HMCID-01 WriteCase8 ${BAD_REQUEST}
155 HMCID-01 WriteCase9 ${BAD_REQUEST}
156 HMCID-01 WriteCase10 ${BAD_REQUEST}
157 HMCID-01 WriteCase11 ${BAD_REQUEST}
Vijayafdd2a12020-04-09 02:03:20 -0500158
Vijayafdd2a12020-04-09 02:03:20 -0500159
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500160Fail To Acquire Lock For Invalid Segment Flag
161 [Documentation] Failed to acquire read write lock for invalid segment flag passed.
162 [Tags] Fail_To_Acquire_Lock_For_Invalid_Segment_Flag
163 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
164
165 # client_id lock_type message
166 HMCID-01 ReadCase12 ${BAD_REQUEST}
167 HMCID-01 ReadCase13 ${BAD_REQUEST}
168 HMCID-01 ReadCase14 ${BAD_REQUEST}
169 HMCID-01 WriteCase12 ${BAD_REQUEST}
170 HMCID-01 WriteCase13 ${BAD_REQUEST}
171 HMCID-01 WriteCase14 ${BAD_REQUEST}
Vijayafdd2a12020-04-09 02:03:20 -0500172
Vijaybc331e22020-02-27 04:17:37 -0600173*** Keywords ***
174
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500175Create Redfish Session With ClientID
176 [Documentation] Create redifish session with client id.
177 [Arguments] ${client_id}
Vijay85610ee2020-04-03 05:30:28 -0500178
179 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500180 # client_id This client id can contain string value
181 # (e.g. 12345, "HMCID").
Vijay85610ee2020-04-03 05:30:28 -0500182
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500183 ${session_info}= Create Dictionary
184 ${session}= Redfish Login kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
Vijay85610ee2020-04-03 05:30:28 -0500185
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500186 Set To Dictionary ${session_info} SessionIDs ${session['Id']}
187 Set To Dictionary ${session_info} ClientID ${session["Oem"]["OpenBMC"]["ClientID"]}
Vijay85610ee2020-04-03 05:30:28 -0500188
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500189 [Return] ${session_info}
Vijay85610ee2020-04-03 05:30:28 -0500190
191
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500192RW General Dictionary
193 [Documentation] Create dictionay of lock request.
194 [Arguments] ${read_case} ${res_id}
Vijaybc331e22020-02-27 04:17:37 -0600195
196 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500197 # read_case Read or Write lock type.
198 # res_id Resource id.
Vijaybc331e22020-02-27 04:17:37 -0600199
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500200 ${request_dict}= Create Dictionary
George Keishing566daaf2020-07-02 06:18:50 -0500201
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500202 FOR ${key} IN @{read_case.keys()}
203 Set To Dictionary ${request_dict} LockType ${key}
204 Set To Dictionary ${request_dict} SegmentFlags ${read_case["${key}"]}
205 END
Vijaybc331e22020-02-27 04:17:37 -0600206
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500207 Set To Dictionary ${request_dict} ResourceID ${res_id}
208
209 [Return] ${request_dict}
Vijaybc331e22020-02-27 04:17:37 -0600210
211
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500212Return Description Of Response
213 [Documentation] Return description of REST response.
Vijaybc331e22020-02-27 04:17:37 -0600214 [Arguments] ${resp_text}
215
216 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500217 # resp_text REST response body.
Vijaybc331e22020-02-27 04:17:37 -0600218
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500219 # resp_text after successful partition file upload looks like:
220 # {
221 # "Description": "File Created"
222 # }
Vijaybc331e22020-02-27 04:17:37 -0600223
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500224 ${message}= Evaluate json.loads('''${resp_text}''') json
225
226 [Return] ${message}
Vijaybc331e22020-02-27 04:17:37 -0600227
228
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500229Redfish Post Acquire Lock
230 [Documentation] Acquire and release lock.
231 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600232
233 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500234 # lock_type Read lock or Write lock.
235 # status_code HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600236
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500237 ${resp}= Form Data To Acquire Lock ${lock_type}
238 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${resp}
239 Should Be Equal As Strings ${resp.status_code} ${status_code}
240 ${resp}= Return Description Of Response ${resp.content}
Vijaybc331e22020-02-27 04:17:37 -0600241
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500242 [Return] ${resp}
Vijaybc331e22020-02-27 04:17:37 -0600243
244
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500245Redfish Post Acquire Invalid Lock
246 [Documentation] Redfish to post request to acquire in-valid lock.
247 [Arguments] ${lock_type} ${message} ${status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600248
249 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500250 # lock_type Read lock or Write lock.
251 # message Return message from URI.
252 # status_code HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600253
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500254 ${resp}= Form Data To Acquire Invalid Lock ${lock_type}
255 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${resp}
256 Should Be Equal As Strings ${resp.status_code} ${status_code}
257 Valid Value message ['${resp.content}']
258
259 [Return] ${resp}
Vijaybc331e22020-02-27 04:17:37 -0600260
261
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500262Form Data To Acquire Lock
263 [Documentation] Create a dictionay for lock request.
264 [Arguments] ${lock_type}
265
266 # Description of argument(s):
267 # lock_type Read lock or Write lock.
268
269 ${lock_res_info}= Get Lock Resource Information
270 ${resp}= RW General Dictionary
271 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
272 ... ${lock_res_info["Valid Case"]["ResourceID"]}
273 ${temp_list}= Create List ${resp}
274 ${lock_request}= Create Dictionary Request=${temp_list}
275
276 [Return] ${lock_request}
277
278
279Form Data To Acquire Invalid Lock
280 [Documentation] Create a dictionay for in-valid lock request.
281 [Arguments] ${lock_type}
282
283 # Description of argument(s):
284 # lock_type Read lock or Write lock.
285
286 ${lock_res_info}= Get Lock Resource Information
287 ${resp}= RW General Dictionary
288 ... ${lock_res_info["Invalid Case"]["${lock_type}"]}
289 ... ${lock_res_info["Valid Case"]["ResourceID"]}
290 ${temp_list}= Create List ${resp}
291 ${lock_request}= Create Dictionary Request=${temp_list}
292
293 [Return] ${lock_request}
294
295
296Get Locks List On Resource
Vijaybc331e22020-02-27 04:17:37 -0600297 [Documentation] Get locks list.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500298 [Arguments] ${session_info} ${exp_status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600299
300 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500301 # session_info Session information in dict.
302 # exp_status_code Expected HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600303
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500304 ${data}= Set Variable {"SessionIDs": ["${session_info['SessionIDs']}"]}
George Keishing566daaf2020-07-02 06:18:50 -0500305 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
306 ... data=${data}
Vijaybc331e22020-02-27 04:17:37 -0600307 ${locks}= Evaluate json.loads('''${resp.text}''') json
308
309 [Return] ${locks["Records"]}
310
311
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500312Verify Lock On Resource
313 [Documentation] Verify lock on resource.
314 [Arguments] ${session_info} ${transaction_id}
Vijaybc331e22020-02-27 04:17:37 -0600315
316 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500317 # session_info Session information in dict.
318 # transaction_id Transaction id in list stored in dict.
Vijaybc331e22020-02-27 04:17:37 -0600319
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500320 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
321 Rprint Vars sessions
322 ${lock_list}= Get Locks List On Resource ${session_info}
323 ${lock_length}= Get Length ${lock_list}
324 ${tran_id_length}= Get Length ${transaction_id}
325 Should Be Equal As Integers ${tran_id_length} ${lock_length}
Vijayafdd2a12020-04-09 02:03:20 -0500326
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500327 FOR ${tran_id} ${lock} IN ZIP ${transaction_id} ${lock_list}
328 Valid Value session_info['ClientID'] ['${lock['HMCID']}']
329 Valid Value session_info['SessionIDs'] ['${lock['SessionID']}']
330 Should Be Equal As Integers ${tran_id['TransactionID']} ${lock['TransactionID']}
Vijaybc331e22020-02-27 04:17:37 -0600331 END
332
Vijaybc331e22020-02-27 04:17:37 -0600333
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500334Redfish Delete Session
335 [Documentation] Redfish delete session.
336 [Arguments] ${session_info}
Vijay355daac2020-03-26 12:06:08 -0500337
338 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500339 # session_info Session information in dict.
Vijay355daac2020-03-26 12:06:08 -0500340
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500341 Redfish.Delete /redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}
Vijay355daac2020-03-26 12:06:08 -0500342
343
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500344Acquire Lock On Resource
345 [Documentation] Acquire lock on resource.
346 [Arguments] ${client_id} ${lock_type} ${reboot_flag}=False
Vijaybc331e22020-02-27 04:17:37 -0600347
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").
351 # lock_type Read lock or Write lock.
352 # reboot_flag Flag is used to run reboot the BMC code.
353 # (e.g. True or False).
Vijaybc331e22020-02-27 04:17:37 -0600354
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500355 ${trans_id_list}= Create List
356 ${session_info}= Create Redfish Session With ClientID ${client_id}
357 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
358 Append To List ${trans_id_list} ${trans_id}
359 Verify Lock On Resource ${session_info} ${trans_id_list}
George Keishing566daaf2020-07-02 06:18:50 -0500360
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500361 ${BEROFE_REBOOT_XAUTH_TOKEN}= Set Variable ${XAUTH_TOKEN}
Vijaybc331e22020-02-27 04:17:37 -0600362
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500363 Run Keyword If '${reboot_flag}' == 'True'
364 ... Run Keywords Redfish OBMC Reboot (off) AND
365 ... Redfish Login AND
366 ... Set Global Variable ${XAUTH_TOKEN} ${BEROFE_REBOOT_XAUTH_TOKEN} AND
367 ... Verify Lock On Resource ${session_info} ${trans_id_list} AND
368 ... Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600369
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500370 Run Keyword If '${reboot_flag}' == 'False'
371 ... Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600372
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500373 ${trans_id_emptylist}= Create List
374 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
375 Redfish Delete Session ${session_info}
Vijaybc331e22020-02-27 04:17:37 -0600376
Vijaybc331e22020-02-27 04:17:37 -0600377
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500378Form Data To Release Lock
379 [Documentation] Create a dictonay to release lock.
380 [Arguments] ${trans_id_list}
Vijay355daac2020-03-26 12:06:08 -0500381
382 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500383 # trans_id_list
Vijay355daac2020-03-26 12:06:08 -0500384
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500385 @{tran_ids}= Create List
Vijay355daac2020-03-26 12:06:08 -0500386
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500387 FOR ${item} IN @{trans_id_list}
388 Append To List ${tran_ids} ${item['TransactionID']}
389 END
390
391 [Return] ${tran_ids}
392
393
394Release Locks On Resource
395 [Documentation] Redfish request to release a lock.
396 [Arguments] ${session_info} ${trans_id_list} ${release_lock_type}=Transaction ${status_code}=${HTTP_OK}
397
398 # Description of argument(s):
399 # session_info Session information in dict.
400 # trans_id_list Transaction id list.
401 # release_lock_type Release lock by Transaction, Session.
402 # status_code HTTP status code.
403
404 ${tran_ids}= Form Data To Release Lock ${trans_id_list}
405 ${data}= Set Variable {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
406 ${data}= Evaluate json.dumps(${data}) json
407 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock data=${data}
408 Should Be Equal As Strings ${resp.status_code} ${status_code}
409
410
411Acquire Lock On Another Lock
412 [Documentation] Acquire lock on another lock.
413 [Arguments] ${client_id}
414
415 # Description of argument(s):
416 # client_id This client id can contain string value
417 # (e.g. 12345, "HMCID").
418
419 ${trans_id_list}= Create List
420 ${session_info}= Create Redfish Session With ClientID ${client_id}
421
422 ${trans_id}= Redfish Post Acquire Lock ReadCase1
423 Append To List ${trans_id_list} ${trans_id}
424
425 ${trans_id}= Redfish Post Acquire Lock ReadCase1
426 Append To List ${trans_id_list} ${trans_id}
427
428 Verify Lock On Resource ${session_info} ${trans_id_list}
429 Release Locks On Resource ${session_info} ${trans_id_list}
430
431 ${trans_id_emptylist}= Create List
432 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
433 Redfish Delete Session ${session_info}
434
435
436Verify Empty Lock Records For Invalid Session
437 [Documentation] Verify no lock record found for invalid session.
438 [Arguments] ${client_id}
439
440 # Description of argument(s):
441 # client_id This client id can contain string value
442 # (e.g. 12345, "HMCID").
443
444 ${session_info1}= Create Redfish Session With ClientID ${client_id}
445
446 ${lock_list1}= Get Locks List On Resource ${session_info1}
447 ${lock_length1}= Get Length ${lock_list1}
448
449 ${session_info2}= Copy Dictionary ${session_info1} deepcopy=True
450 set to dictionary ${session_info2} SessionIDs xxyXyyYZZz
451
452 ${lock_list2}= Get Locks List On Resource ${session_info2}
453 ${lock_length2}= Get Length ${lock_list1}
454
455 Valid Value lock_length1 ${lock_list2}
456
457 Redfish Delete Session ${session_info1}
458
459
460Verify Acquire Lock Fails On Another Lock
461 [Documentation] Verify acquire lock on another lock fails.
462 [Arguments] ${client_id} ${lock_type}
463
464 # Description of argument(s):
465 # client_id This client id can contain string value
466 # (e.g. 12345, "HMCID").
467 # lock_type Read lock or Write lock.
468
469 @{lock_type_list}= Split String ${lock_type} ,
470 ${session_info}= Create Redfish Session With ClientID ${client_id}
471 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
472
473 ${trans_id_list}= Create List
474 Append To List ${trans_id_list} ${trans_id}
475
476 Verify Lock On Resource ${session_info} ${trans_id_list}
477 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1] status_code=${HTTP_CONFLICT}
478 Release Locks On Resource ${session_info} ${trans_id_list}
479
480 ${trans_id_emptylist}= Create List
481 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
482
483 Redfish Delete Session ${session_info}
484
485
486Verify Acquire And Release Lock In Loop
487 [Documentation] Acquire lock in loop.
488 [Arguments] ${client_id} ${lock_type}
489
490 # Description of argument(s):
491 # client_id This client id can contain string value
492 # (e.g. 12345, "HMCID").
493 # lock_type Read lock or Write lock.
494
495 FOR ${count} IN RANGE 1 11
496 ${trans_id_list}= Create List
497 ${session_info}= Create Redfish Session With ClientID ${client_id}
498 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
499 Append To List ${trans_id_list} ${trans_id}
500 Verify Lock On Resource ${session_info} ${trans_id_list}
501 Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
502 ${trans_id_emptylist}= Create List
503 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
504 END
505
506 Redfish Delete Session ${session_info}
507
508
509Acquire And Release Multiple Locks
510 [Documentation] Acquire mutilple locks on resource.
511 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
512
513 # Description of argument(s):
514 # client_id This client id can contain string value
515 # (e.g. 12345, "HMCID").
516 # lock_type Read lock or Write lock.
517 # release_lock_type The value can be Transaction or Session.
518
519 @{lock_type_list}= Split String ${lock_type} ,
520 ${session_info}= Create Redfish Session With ClientID ${client_id}
521 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
522
523 ${trans_id_list}= Create List
524
525 Append To List ${trans_id_list} ${trans_id}
526 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
527
528 Append To List ${trans_id_list} ${trans_id}
529 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2]
530
531 Append To List ${trans_id_list} ${trans_id}
532 Verify Lock On Resource ${session_info} ${trans_id_list}
533 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=${release_lock_type}
534
535 ${trans_id_emptylist}= Create List
536 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
537 Redfish Delete Session ${session_info}
538
539
540Verify Invalid Locks Fail To Release
541 [Documentation] Verify invalid locks fails to be released.
542 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
543
544 # Description of argument(s):
545 # client_id This client id can contain string value
546 # (e.g. 12345, "HMCID").
547 # lock_type Read lock or Write lock.
548 # release_lock_type The value can be Transaction or Session.
549
550 ${trans_id_list}= Create List
551 @{lock_type_list}= Split String ${lock_type} ,
552
553 ${session_info}= Create Redfish Session With ClientID ${client_id}
554
555 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
556 ${value}= Get From Dictionary ${trans_id} TransactionID
557 ${value}= Evaluate ${value} + 10
558 Set To Dictionary ${trans_id} TransactionID ${value}
559 Append To List ${trans_id_list} ${trans_id}
560
561 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
562 ${value}= Get From Dictionary ${trans_id} TransactionID
563 ${value}= Evaluate ${value} + 10
564 Set To Dictionary ${trans_id} TransactionID ${value}
565 Append To List ${trans_id_list} ${trans_id}
566
567 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2]
568 ${value}= Get From Dictionary ${trans_id} TransactionID
569 ${value}= Evaluate ${value} + 10
570 Set To Dictionary ${trans_id} TransactionID ${value}
571 Append To List ${trans_id_list} ${trans_id}
572
573 Release Locks On Resource
574 ... ${session_info} ${trans_id_list}
575 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
576 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session
577
578 ${trans_id_emptylist}= Create List
579 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
580 Redfish Delete Session ${session_info}
581
582
583Verify Fail To Release Lock For Another Session
584 [Documentation] Verify failed to release the lock form another session.
585 [Arguments] ${client_id} ${lock_type}
586
587 # Description of argument(s):
588 # client_id This client id can contain string value
589 # (e.g. 12345, "HMCID").
590 # lock_type Read lock or Write lock.
591
592 ${client_ids}= Split String ${client_id} ,
593 ${lock_type_list}= Split String ${lock_type} ,
594 ${trans_id_list1}= Create List
595 ${trans_id_list2}= Create List
596
597 ${session_info1}= Create Redfish Session With ClientID ${client_ids}[0]
598
599 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
600 Append To List ${trans_id_list1} ${trans_id}
601 Verify Lock On Resource ${session_info1} ${trans_id_list1}
602
603 ${session_info2}= Create Redfish Session With ClientID ${client_ids}[1]
604 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
605 Append To List ${trans_id_list2} ${trans_id}
606 Verify Lock On Resource ${session_info2} ${trans_id_list2}
607
608 Release Locks On Resource
609 ... ${session_info1} ${trans_id_list1} Transaction status_code=${HTTP_UNAUTHORIZED}
610 Verify Lock On Resource ${session_info1} ${trans_id_list1}
611 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Session
612 Release Locks On Resource ${session_info2} ${trans_id_list2} release_lock_type=Session
613 Redfish Delete Session ${session_info1}
614 Redfish Delete Session ${session_info2}
615
616
617Verify Fail To Acquire Lock For Invalid Lock Data
618 [Documentation] Verify fail to quired lock with invalid lock types, lock flags, segement flags.
619 [Arguments] ${client_id} ${lock_type} ${message}
620
621 # Description of argument(s):
622 # client_id This client id can contain string value
623 # (e.g. 12345, "HMCID").
624 # lock_type Read lock or Write lock.
625 # message Return message from URI.
626
627 ${session_info}= Create Redfish Session With ClientID ${client_id}
628 ${trans_id}= Redfish Post Acquire Invalid Lock ${lock_type} message=${message} status_code=${HTTP_BAD_REQUEST}
629 Redfish Delete Session ${session_info}