blob: 622a73b539e8d915176ac743f5f9e5d5abc2ab1b [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 Singhe33c6e62020-09-29 06:34:35 -050078Acquire Lock After Reboot
79 [Documentation] Acquire and release read and write locks after reboot.
80 [Tags] Acquire_Lock_After_Reboot
81 [Template] Verify Acquire Lock After Reboot
82
83 # 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
90
91
Sushil Singhd03f2ce2020-09-17 08:54:41 -050092Acquire And Release Lock In Loop
93 [Documentation] Acquire and release read, write locks in loop.
94 [Tags] Acquire_And_Release_Lock_In_Loop
95 [Template] Verify Acquire And Release Lock In Loop
George Keishing566daaf2020-07-02 06:18:50 -050096
Sushil Singhd03f2ce2020-09-17 08:54:41 -050097 # client_id lock_type
98 HMCID-01 ReadCase1
99 HMCID-01 ReadCase2
100 HMCID-01 ReadCase3
101 HMCID-01 WriteCase1
102 HMCID-01 WriteCase2
103 HMCID-01 WriteCase3
Vijay85610ee2020-04-03 05:30:28 -0500104
105
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500106Verify Release Of Valid Locks
107 [Documentation] Release all valid locks.
108 [Tags] Verify_Release_Of_Valid_Locks
109 [Template] Acquire And Release Multiple Locks
Vijayafdd2a12020-04-09 02:03:20 -0500110
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500111 # client_id lock_type release_lock_type
112 HMCID-01 ReadCase1,ReadCase1,ReadCase1 Transaction
113 HMCID-02 ReadCase1,ReadCase1,ReadCase1 Session
Vijayafdd2a12020-04-09 02:03:20 -0500114
115
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500116Invalid Locks Fail To Release
117 [Documentation] Release in-valid lock result in fail.
118 [Tags] Invalid_Locks_Fail_To_Release
119 [Template] Verify Invalid Locks Fail To Release
Vijayafdd2a12020-04-09 02:03:20 -0500120
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500121 # client_id lock_type release_lock_type
122 HMCID-01 ReadCase1,ReadCase1,ReadCase1 Transaction
123 12345 ReadCase2,ReadCase2,ReadCase2 Transaction
124 HMCID ReadCase3,ReadCase3,ReadCase3 Transaction
Vijayafdd2a12020-04-09 02:03:20 -0500125
126
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500127Fail To Release Lock For Another Session
128 [Documentation] Failed to release locks from another session.
129 [Tags] Fail_To_Release_Lock_For_Another_Session
130 [Template] Verify Fail To Release Lock For Another Session
Vijayafdd2a12020-04-09 02:03:20 -0500131
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500132 # client_id lock_type
133 HMCID-01,HMCID-02 ReadCase1,ReadCase1
Vijayafdd2a12020-04-09 02:03:20 -0500134
135
Sushil Singhe33c6e62020-09-29 06:34:35 -0500136Test Invalid Resource ID Data Type Locking
137 [Documentation] Failed to acquire lock for invalid resource id data type.
138 [Tags] Test_Invalid_Resource_ID_Data_Type_Locking
139 [Template] Verify Fail To Acquire Lock For Invalid Resource ID Data Type
140
141 # client_id lock_type
142 HMCID-01 ReadCase1
143 HMCID-01 ReadCase2
144 HMCID-01 ReadCase3
145 HMCID-01 WriteCase1
146 HMCID-01 WriteCase2
147 HMCID-01 WriteCase3
148
149
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500150Fail To Acquire Lock For Invalid Lock Type
151 [Documentation] Failed to acquire read, write lock for invalid lock data passed.
152 [Tags] Fail_To_Acquire_Lock_For_Invalid_Lock_Type
153 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
Vijayafdd2a12020-04-09 02:03:20 -0500154
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500155 # client_id lock_type message
156 HMCID-01 ReadCase1 ${BAD_REQUEST}
157 HMCID-01 ReadCase2 ${BAD_REQUEST}
158 HMCID-01 ReadCase3 ${BAD_REQUEST}
159 HMCID-01 ReadCase4 ${BAD_REQUEST}
160 HMCID-01 ReadCase5 ${BAD_REQUEST}
161 HMCID-01 WriteCase1 ${BAD_REQUEST}
162 HMCID-01 WriteCase2 ${BAD_REQUEST}
163 HMCID-01 WriteCase3 ${BAD_REQUEST}
164 HMCID-01 WriteCase4 ${BAD_REQUEST}
165 HMCID-01 WriteCase5 ${BAD_REQUEST}
Vijayafdd2a12020-04-09 02:03:20 -0500166
Vijayafdd2a12020-04-09 02:03:20 -0500167
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500168Fail To Acquire Lock For Invalid Lock Flag
169 [Documentation] Failed to acquire read write lock for invalid lock flag passed.
170 [Tags] Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
171 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
Vijayafdd2a12020-04-09 02:03:20 -0500172
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500173 # client_id lock_type message
174 HMCID-01 ReadCase6 ${BAD_REQUEST}
175 HMCID-01 ReadCase7 ${BAD_REQUEST}
176 HMCID-01 ReadCase8 ${BAD_REQUEST}
177 HMCID-01 ReadCase9 ${BAD_REQUEST}
178 HMCID-01 ReadCase10 ${BAD_REQUEST}
179 HMCID-01 ReadCase11 ${BAD_REQUEST}
180 HMCID-01 WriteCase6 ${BAD_REQUEST}
181 HMCID-01 WriteCase7 ${BAD_REQUEST}
182 HMCID-01 WriteCase8 ${BAD_REQUEST}
183 HMCID-01 WriteCase9 ${BAD_REQUEST}
184 HMCID-01 WriteCase10 ${BAD_REQUEST}
185 HMCID-01 WriteCase11 ${BAD_REQUEST}
Vijayafdd2a12020-04-09 02:03:20 -0500186
Vijayafdd2a12020-04-09 02:03:20 -0500187
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500188Fail To Acquire Lock For Invalid Segment Flag
189 [Documentation] Failed to acquire read write lock for invalid segment flag passed.
190 [Tags] Fail_To_Acquire_Lock_For_Invalid_Segment_Flag
191 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
192
193 # client_id lock_type message
194 HMCID-01 ReadCase12 ${BAD_REQUEST}
195 HMCID-01 ReadCase13 ${BAD_REQUEST}
196 HMCID-01 ReadCase14 ${BAD_REQUEST}
197 HMCID-01 WriteCase12 ${BAD_REQUEST}
198 HMCID-01 WriteCase13 ${BAD_REQUEST}
199 HMCID-01 WriteCase14 ${BAD_REQUEST}
Vijayafdd2a12020-04-09 02:03:20 -0500200
Vijaybc331e22020-02-27 04:17:37 -0600201*** Keywords ***
202
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500203Create Redfish Session With ClientID
204 [Documentation] Create redifish session with client id.
205 [Arguments] ${client_id}
Vijay85610ee2020-04-03 05:30:28 -0500206
207 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500208 # client_id This client id can contain string value
209 # (e.g. 12345, "HMCID").
Vijay85610ee2020-04-03 05:30:28 -0500210
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500211 ${session_info}= Create Dictionary
212 ${session}= Redfish Login kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
Vijay85610ee2020-04-03 05:30:28 -0500213
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500214 Set To Dictionary ${session_info} SessionIDs ${session['Id']}
215 Set To Dictionary ${session_info} ClientID ${session["Oem"]["OpenBMC"]["ClientID"]}
Vijay85610ee2020-04-03 05:30:28 -0500216
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500217 [Return] ${session_info}
Vijay85610ee2020-04-03 05:30:28 -0500218
219
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500220RW General Dictionary
221 [Documentation] Create dictionay of lock request.
222 [Arguments] ${read_case} ${res_id}
Vijaybc331e22020-02-27 04:17:37 -0600223
224 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500225 # read_case Read or Write lock type.
226 # res_id Resource id.
Vijaybc331e22020-02-27 04:17:37 -0600227
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500228 ${request_dict}= Create Dictionary
George Keishing566daaf2020-07-02 06:18:50 -0500229
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500230 FOR ${key} IN @{read_case.keys()}
231 Set To Dictionary ${request_dict} LockType ${key}
232 Set To Dictionary ${request_dict} SegmentFlags ${read_case["${key}"]}
233 END
Vijaybc331e22020-02-27 04:17:37 -0600234
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500235 Set To Dictionary ${request_dict} ResourceID ${res_id}
236
237 [Return] ${request_dict}
Vijaybc331e22020-02-27 04:17:37 -0600238
239
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500240Return Description Of Response
241 [Documentation] Return description of REST response.
Vijaybc331e22020-02-27 04:17:37 -0600242 [Arguments] ${resp_text}
243
244 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500245 # resp_text REST response body.
Vijaybc331e22020-02-27 04:17:37 -0600246
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500247 # resp_text after successful partition file upload looks like:
248 # {
249 # "Description": "File Created"
250 # }
Vijaybc331e22020-02-27 04:17:37 -0600251
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500252 ${message}= Evaluate json.loads('''${resp_text}''') json
253
254 [Return] ${message}
Vijaybc331e22020-02-27 04:17:37 -0600255
256
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500257Redfish Post Acquire Lock
258 [Documentation] Acquire and release lock.
259 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600260
261 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500262 # lock_type Read lock or Write lock.
263 # status_code HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600264
Sushil Singhe33c6e62020-09-29 06:34:35 -0500265 ${lock_dict_param}= Form Data To Acquire Lock ${lock_type}
266 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500267 Should Be Equal As Strings ${resp.status_code} ${status_code}
268 ${resp}= Return Description Of Response ${resp.content}
Vijaybc331e22020-02-27 04:17:37 -0600269
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500270 [Return] ${resp}
Vijaybc331e22020-02-27 04:17:37 -0600271
272
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500273Redfish Post Acquire Invalid Lock
274 [Documentation] Redfish to post request to acquire in-valid lock.
275 [Arguments] ${lock_type} ${message} ${status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600276
277 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500278 # lock_type Read lock or Write lock.
279 # message Return message from URI.
280 # status_code HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600281
Sushil Singhe33c6e62020-09-29 06:34:35 -0500282 ${lock_dict_param}= Form Data To Acquire Invalid Lock ${lock_type}
283 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500284 Should Be Equal As Strings ${resp.status_code} ${status_code}
285 Valid Value message ['${resp.content}']
286
287 [Return] ${resp}
Vijaybc331e22020-02-27 04:17:37 -0600288
289
Sushil Singhe33c6e62020-09-29 06:34:35 -0500290Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
291 [Documentation] Redfish to post request to acquire in-valid lock with invalid data type of resource id.
292 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
293
294 # Description of argument(s):
295 # lock_type Read lock or Write lock.
296 # status_code HTTP status code.
297
298 ${lock_dict_param}= Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID ${lock_type}
299 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
300 Should Be Equal As Strings ${resp.status_code} ${status_code}
301
302 [Return] ${resp}
303
304
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500305Form Data To Acquire Lock
306 [Documentation] Create a dictionay for lock request.
307 [Arguments] ${lock_type}
308
309 # Description of argument(s):
310 # lock_type Read lock or Write lock.
311
312 ${lock_res_info}= Get Lock Resource Information
313 ${resp}= RW General Dictionary
314 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
315 ... ${lock_res_info["Valid Case"]["ResourceID"]}
316 ${temp_list}= Create List ${resp}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500317 ${lock_request_dict}= Create Dictionary Request=${temp_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500318
Sushil Singhe33c6e62020-09-29 06:34:35 -0500319 [Return] ${lock_request_dict}
320
321
322Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
323 [Documentation] Create a dictionay for in-valid lock request.
324 [Arguments] ${lock_type}
325
326 # Description of argument(s):
327 # lock_type Read lock or Write lock.
328
329 ${lock_res_info}= Get Lock Resource Information
330 ${resp}= RW General Dictionary
331 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
332 ... ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
333 ${temp_list}= Create List ${resp}
334 ${lock_request_dict}= Create Dictionary Request=${temp_list}
335
336 [Return] ${lock_request_dict}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500337
338
339Form Data To Acquire Invalid Lock
340 [Documentation] Create a dictionay for in-valid lock request.
341 [Arguments] ${lock_type}
342
343 # Description of argument(s):
344 # lock_type Read lock or Write lock.
345
346 ${lock_res_info}= Get Lock Resource Information
347 ${resp}= RW General Dictionary
348 ... ${lock_res_info["Invalid Case"]["${lock_type}"]}
349 ... ${lock_res_info["Valid Case"]["ResourceID"]}
350 ${temp_list}= Create List ${resp}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500351 ${lock_request_dict}= Create Dictionary Request=${temp_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500352
Sushil Singhe33c6e62020-09-29 06:34:35 -0500353 [Return] ${lock_request_dict}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500354
355
356Get Locks List On Resource
Vijaybc331e22020-02-27 04:17:37 -0600357 [Documentation] Get locks list.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500358 [Arguments] ${session_info} ${exp_status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600359
360 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500361 # session_info Session information in dict.
362 # exp_status_code Expected HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600363
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500364 ${data}= Set Variable {"SessionIDs": ["${session_info['SessionIDs']}"]}
George Keishing566daaf2020-07-02 06:18:50 -0500365 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
366 ... data=${data}
Vijaybc331e22020-02-27 04:17:37 -0600367 ${locks}= Evaluate json.loads('''${resp.text}''') json
368
369 [Return] ${locks["Records"]}
370
371
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500372Verify Lock On Resource
373 [Documentation] Verify lock on resource.
374 [Arguments] ${session_info} ${transaction_id}
Vijaybc331e22020-02-27 04:17:37 -0600375
376 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500377 # session_info Session information in dict.
378 # transaction_id Transaction id in list stored in dict.
Vijaybc331e22020-02-27 04:17:37 -0600379
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500380 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
381 Rprint Vars sessions
382 ${lock_list}= Get Locks List On Resource ${session_info}
383 ${lock_length}= Get Length ${lock_list}
384 ${tran_id_length}= Get Length ${transaction_id}
385 Should Be Equal As Integers ${tran_id_length} ${lock_length}
Vijayafdd2a12020-04-09 02:03:20 -0500386
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500387 FOR ${tran_id} ${lock} IN ZIP ${transaction_id} ${lock_list}
388 Valid Value session_info['ClientID'] ['${lock['HMCID']}']
389 Valid Value session_info['SessionIDs'] ['${lock['SessionID']}']
390 Should Be Equal As Integers ${tran_id['TransactionID']} ${lock['TransactionID']}
Vijaybc331e22020-02-27 04:17:37 -0600391 END
392
Vijaybc331e22020-02-27 04:17:37 -0600393
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500394Redfish Delete Session
395 [Documentation] Redfish delete session.
396 [Arguments] ${session_info}
Vijay355daac2020-03-26 12:06:08 -0500397
398 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500399 # session_info Session information in dict.
Vijay355daac2020-03-26 12:06:08 -0500400
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500401 Redfish.Delete /redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}
Vijay355daac2020-03-26 12:06:08 -0500402
403
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500404Acquire Lock On Resource
405 [Documentation] Acquire lock on resource.
406 [Arguments] ${client_id} ${lock_type} ${reboot_flag}=False
Vijaybc331e22020-02-27 04:17:37 -0600407
408 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500409 # client_id This client id can contain string value
410 # (e.g. 12345, "HMCID").
411 # lock_type Read lock or Write lock.
412 # reboot_flag Flag is used to run reboot the BMC code.
413 # (e.g. True or False).
Vijaybc331e22020-02-27 04:17:37 -0600414
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500415 ${trans_id_list}= Create List
416 ${session_info}= Create Redfish Session With ClientID ${client_id}
417 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
418 Append To List ${trans_id_list} ${trans_id}
419 Verify Lock On Resource ${session_info} ${trans_id_list}
George Keishing566daaf2020-07-02 06:18:50 -0500420
Sushil Singhe33c6e62020-09-29 06:34:35 -0500421 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
Vijaybc331e22020-02-27 04:17:37 -0600422
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500423 Run Keyword If '${reboot_flag}' == 'True'
424 ... Run Keywords Redfish OBMC Reboot (off) AND
425 ... Redfish Login AND
Sushil Singhe33c6e62020-09-29 06:34:35 -0500426 ... Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} AND
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500427 ... Verify Lock On Resource ${session_info} ${trans_id_list} AND
428 ... Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600429
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500430 Run Keyword If '${reboot_flag}' == 'False'
431 ... Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600432
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500433 ${trans_id_emptylist}= Create List
434 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
435 Redfish Delete Session ${session_info}
Vijaybc331e22020-02-27 04:17:37 -0600436
Vijaybc331e22020-02-27 04:17:37 -0600437
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500438Form Data To Release Lock
439 [Documentation] Create a dictonay to release lock.
440 [Arguments] ${trans_id_list}
Vijay355daac2020-03-26 12:06:08 -0500441
442 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500443 # trans_id_list
Vijay355daac2020-03-26 12:06:08 -0500444
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500445 @{tran_ids}= Create List
Vijay355daac2020-03-26 12:06:08 -0500446
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500447 FOR ${item} IN @{trans_id_list}
448 Append To List ${tran_ids} ${item['TransactionID']}
449 END
450
451 [Return] ${tran_ids}
452
453
454Release Locks On Resource
455 [Documentation] Redfish request to release a lock.
456 [Arguments] ${session_info} ${trans_id_list} ${release_lock_type}=Transaction ${status_code}=${HTTP_OK}
457
458 # Description of argument(s):
459 # session_info Session information in dict.
460 # trans_id_list Transaction id list.
461 # release_lock_type Release lock by Transaction, Session.
462 # status_code HTTP status code.
463
464 ${tran_ids}= Form Data To Release Lock ${trans_id_list}
465 ${data}= Set Variable {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
466 ${data}= Evaluate json.dumps(${data}) json
467 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock data=${data}
468 Should Be Equal As Strings ${resp.status_code} ${status_code}
469
470
471Acquire Lock On Another Lock
472 [Documentation] Acquire lock on another lock.
473 [Arguments] ${client_id}
474
475 # Description of argument(s):
476 # client_id This client id can contain string value
477 # (e.g. 12345, "HMCID").
478
479 ${trans_id_list}= Create List
480 ${session_info}= Create Redfish Session With ClientID ${client_id}
481
482 ${trans_id}= Redfish Post Acquire Lock ReadCase1
483 Append To List ${trans_id_list} ${trans_id}
484
485 ${trans_id}= Redfish Post Acquire Lock ReadCase1
486 Append To List ${trans_id_list} ${trans_id}
487
488 Verify Lock On Resource ${session_info} ${trans_id_list}
489 Release Locks On Resource ${session_info} ${trans_id_list}
490
491 ${trans_id_emptylist}= Create List
492 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
493 Redfish Delete Session ${session_info}
494
495
496Verify Empty Lock Records For Invalid Session
497 [Documentation] Verify no lock record found for invalid session.
498 [Arguments] ${client_id}
499
500 # Description of argument(s):
501 # client_id This client id can contain string value
502 # (e.g. 12345, "HMCID").
503
504 ${session_info1}= Create Redfish Session With ClientID ${client_id}
505
506 ${lock_list1}= Get Locks List On Resource ${session_info1}
507 ${lock_length1}= Get Length ${lock_list1}
508
509 ${session_info2}= Copy Dictionary ${session_info1} deepcopy=True
510 set to dictionary ${session_info2} SessionIDs xxyXyyYZZz
511
512 ${lock_list2}= Get Locks List On Resource ${session_info2}
513 ${lock_length2}= Get Length ${lock_list1}
514
515 Valid Value lock_length1 ${lock_list2}
516
517 Redfish Delete Session ${session_info1}
518
519
520Verify Acquire Lock Fails On Another Lock
521 [Documentation] Verify acquire lock on another lock fails.
522 [Arguments] ${client_id} ${lock_type}
523
524 # Description of argument(s):
525 # client_id This client id can contain string value
526 # (e.g. 12345, "HMCID").
527 # lock_type Read lock or Write lock.
528
529 @{lock_type_list}= Split String ${lock_type} ,
530 ${session_info}= Create Redfish Session With ClientID ${client_id}
531 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
532
533 ${trans_id_list}= Create List
534 Append To List ${trans_id_list} ${trans_id}
535
536 Verify Lock On Resource ${session_info} ${trans_id_list}
537 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1] status_code=${HTTP_CONFLICT}
538 Release Locks On Resource ${session_info} ${trans_id_list}
539
540 ${trans_id_emptylist}= Create List
541 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
542
543 Redfish Delete Session ${session_info}
544
545
Sushil Singhe33c6e62020-09-29 06:34:35 -0500546Verify Acquire Lock After Reboot
547 [Documentation] Acquire read and write lock after the reboot and release lock.
548 [Arguments] ${client_id} ${lock_type}
549
550 # Description of argument(s):
551 # client_id This client id can contain string value
552 # (e.g. 12345, "HMCID").
553 # lock_type Read lock or Write lock.
554
555 ${trans_id_list}= Create List
556 ${session_info}= Create Redfish Session With ClientID ${client_id}
557 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
558 Redfish OBMC Reboot (off)
559 Redfish Login
560 Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token}
561
562 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
563 Append To List ${trans_id_list} ${trans_id}
564 Verify Lock On Resource ${session_info} ${trans_id_list}
565 Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
566
567 ${trans_id_emptylist}= Create List
568 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
569 Redfish Delete Session ${session_info}
570
571
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500572Verify Acquire And Release Lock In Loop
573 [Documentation] Acquire lock in loop.
574 [Arguments] ${client_id} ${lock_type}
575
576 # Description of argument(s):
577 # client_id This client id can contain string value
578 # (e.g. 12345, "HMCID").
579 # lock_type Read lock or Write lock.
580
581 FOR ${count} IN RANGE 1 11
582 ${trans_id_list}= Create List
583 ${session_info}= Create Redfish Session With ClientID ${client_id}
584 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
585 Append To List ${trans_id_list} ${trans_id}
586 Verify Lock On Resource ${session_info} ${trans_id_list}
587 Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
588 ${trans_id_emptylist}= Create List
589 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
590 END
591
592 Redfish Delete Session ${session_info}
593
594
595Acquire And Release Multiple Locks
596 [Documentation] Acquire mutilple locks on resource.
597 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
598
599 # Description of argument(s):
600 # client_id This client id can contain string value
601 # (e.g. 12345, "HMCID").
602 # lock_type Read lock or Write lock.
603 # release_lock_type The value can be Transaction or Session.
604
605 @{lock_type_list}= Split String ${lock_type} ,
606 ${session_info}= Create Redfish Session With ClientID ${client_id}
607 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
608
609 ${trans_id_list}= Create List
610
611 Append To List ${trans_id_list} ${trans_id}
612 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
613
614 Append To List ${trans_id_list} ${trans_id}
615 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2]
616
617 Append To List ${trans_id_list} ${trans_id}
618 Verify Lock On Resource ${session_info} ${trans_id_list}
619 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=${release_lock_type}
620
621 ${trans_id_emptylist}= Create List
622 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
623 Redfish Delete Session ${session_info}
624
625
626Verify Invalid Locks Fail To Release
627 [Documentation] Verify invalid locks fails to be released.
628 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
629
630 # Description of argument(s):
631 # client_id This client id can contain string value
632 # (e.g. 12345, "HMCID").
633 # lock_type Read lock or Write lock.
634 # release_lock_type The value can be Transaction or Session.
635
636 ${trans_id_list}= Create List
637 @{lock_type_list}= Split String ${lock_type} ,
638
639 ${session_info}= Create Redfish Session With ClientID ${client_id}
640
641 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
642 ${value}= Get From Dictionary ${trans_id} TransactionID
643 ${value}= Evaluate ${value} + 10
644 Set To Dictionary ${trans_id} TransactionID ${value}
645 Append To List ${trans_id_list} ${trans_id}
646
647 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
648 ${value}= Get From Dictionary ${trans_id} TransactionID
649 ${value}= Evaluate ${value} + 10
650 Set To Dictionary ${trans_id} TransactionID ${value}
651 Append To List ${trans_id_list} ${trans_id}
652
653 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2]
654 ${value}= Get From Dictionary ${trans_id} TransactionID
655 ${value}= Evaluate ${value} + 10
656 Set To Dictionary ${trans_id} TransactionID ${value}
657 Append To List ${trans_id_list} ${trans_id}
658
659 Release Locks On Resource
660 ... ${session_info} ${trans_id_list}
661 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
662 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session
663
664 ${trans_id_emptylist}= Create List
665 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
666 Redfish Delete Session ${session_info}
667
668
669Verify Fail To Release Lock For Another Session
670 [Documentation] Verify failed to release the lock form another session.
671 [Arguments] ${client_id} ${lock_type}
672
673 # Description of argument(s):
674 # client_id This client id can contain string value
675 # (e.g. 12345, "HMCID").
676 # lock_type Read lock or Write lock.
677
678 ${client_ids}= Split String ${client_id} ,
679 ${lock_type_list}= Split String ${lock_type} ,
680 ${trans_id_list1}= Create List
681 ${trans_id_list2}= Create List
682
683 ${session_info1}= Create Redfish Session With ClientID ${client_ids}[0]
684
685 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
686 Append To List ${trans_id_list1} ${trans_id}
687 Verify Lock On Resource ${session_info1} ${trans_id_list1}
688
689 ${session_info2}= Create Redfish Session With ClientID ${client_ids}[1]
690 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
691 Append To List ${trans_id_list2} ${trans_id}
692 Verify Lock On Resource ${session_info2} ${trans_id_list2}
693
694 Release Locks On Resource
695 ... ${session_info1} ${trans_id_list1} Transaction status_code=${HTTP_UNAUTHORIZED}
696 Verify Lock On Resource ${session_info1} ${trans_id_list1}
697 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Session
698 Release Locks On Resource ${session_info2} ${trans_id_list2} release_lock_type=Session
699 Redfish Delete Session ${session_info1}
700 Redfish Delete Session ${session_info2}
701
702
Sushil Singhe33c6e62020-09-29 06:34:35 -0500703Verify Fail To Acquire Lock For Invalid Resource ID Data Type
704 [Documentation] Verify fail to acquire the lock with invalid resource id data type.
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 ${session_info}= Create Redfish Session With ClientID ${client_id}
713 Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
714 ... ${lock_type} status_code=${HTTP_BAD_REQUEST}
715 Redfish Delete Session ${session_info}
716
717
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500718Verify Fail To Acquire Lock For Invalid Lock Data
Sushil Singhe33c6e62020-09-29 06:34:35 -0500719 [Documentation] Verify fail to acquired lock with invalid lock types, lock flags, segement flags.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500720 [Arguments] ${client_id} ${lock_type} ${message}
721
722 # Description of argument(s):
723 # client_id This client id can contain string value
724 # (e.g. 12345, "HMCID").
725 # lock_type Read lock or Write lock.
726 # message Return message from URI.
727
728 ${session_info}= Create Redfish Session With ClientID ${client_id}
729 ${trans_id}= Redfish Post Acquire Invalid Lock ${lock_type} message=${message} status_code=${HTTP_BAD_REQUEST}
730 Redfish Delete Session ${session_info}