blob: 4d561ecdbae7f02233a31935695849c7c8b187c3 [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 Singh728ef9c2020-10-28 04:25:39 -05009Library ../../lib/bmc_network_utils.py
Vijaybc331e22020-02-27 04:17:37 -060010
Sushil Singhd03f2ce2020-09-17 08:54:41 -050011Suite Setup Run Keyword And Ignore Error Delete All Redfish Sessions
12Suite Teardown Redfish.Logout
13Test Setup Printn
14Test Teardown FFDC On Test Case Fail
Vijaybc331e22020-02-27 04:17:37 -060015
16*** Variables ***
17
Sushil Singhd03f2ce2020-09-17 08:54:41 -050018${BAD_REQUEST} Bad Request
Vijaybc331e22020-02-27 04:17:37 -060019
20*** Test Cases ***
21
Sushil Singhd03f2ce2020-09-17 08:54:41 -050022Acquire Read Write Lock
Vijaybc331e22020-02-27 04:17:37 -060023 [Documentation] Acquire and release different read locks.
Sushil Singhd03f2ce2020-09-17 08:54:41 -050024 [Tags] Acquire_Read_Write_Lock
25 [Template] Acquire Lock On Resource
Vijaybc331e22020-02-27 04:17:37 -060026
Sushil Singhd03f2ce2020-09-17 08:54:41 -050027 # client_id lock_type reboot_flag
28 HMCID-01 ReadCase1 False
29 HMCID-01 ReadCase2 False
30 HMCID-01 ReadCase3 False
31 HMCID-01 WriteCase1 False
32 HMCID-01 WriteCase2 False
33 HMCID-01 WriteCase3 False
Vijaybc331e22020-02-27 04:17:37 -060034
35
Sushil Singhd03f2ce2020-09-17 08:54:41 -050036Check Lock Persistency On BMC Reboot
37 [Documentation] Acquire lock and check after reboot it remain same.
38 [Tags] Check_Lock_Persistency_On_BMC_Reboot
39 [Template] Acquire Lock On Resource
Vijaybc331e22020-02-27 04:17:37 -060040
Sushil Singhd03f2ce2020-09-17 08:54:41 -050041 # client_id lock_type reboot_flag
42 HMCID-01 ReadCase1 True
43 HMCID-01 ReadCase2 True
44 HMCID-01 ReadCase3 True
45 HMCID-01 WriteCase1 True
46 HMCID-01 WriteCase2 True
47 HMCID-01 WriteCase3 True
Vijaybc331e22020-02-27 04:17:37 -060048
49
Sushil Singhd03f2ce2020-09-17 08:54:41 -050050Acquire Read Lock On Read Lock
51 [Documentation] Acquire read lock on another read lock.
52 [Tags] Acquire_Read_Lock_On_Read_Lock
53 [Template] Acquire Lock On Another Lock
Vijaybc331e22020-02-27 04:17:37 -060054
Sushil Singhd03f2ce2020-09-17 08:54:41 -050055 # client_id
56 HMCID-01
Vijaybc331e22020-02-27 04:17:37 -060057
58
Sushil Singhd03f2ce2020-09-17 08:54:41 -050059Get Lock Records Empty For Invalid Session
60 [Documentation] Record of lock list is empty for invalid session.
61 [Tags] Get_Lock_Records_Empty_For_Invalid_Session
62 [Template] Verify Empty Lock Records For Invalid Session
Vijay355daac2020-03-26 12:06:08 -050063
Sushil Singhd03f2ce2020-09-17 08:54:41 -050064 # client_id
65 HMCID-01
Vijay355daac2020-03-26 12:06:08 -050066
67
Sushil Singhd03f2ce2020-09-17 08:54:41 -050068Fail To Acquire Lock On Another Lock
69 [Documentation] Fail to acquire another lock.
70 [Tags] Fail_To_Acquire_Lock_On_Another_Lock
71 [Template] Verify Acquire Lock Fails On Another Lock
Vijay85610ee2020-04-03 05:30:28 -050072
Sushil Singhd03f2ce2020-09-17 08:54:41 -050073 # client_id lock_type
74 HMCID-01 ReadCase2,WriteCase2
75 HMCID-01 WriteCase2,WriteCase2
76 HMCID-01 WriteCase2,ReadCase2
George Keishing566daaf2020-07-02 06:18:50 -050077
78
Sushil Singhe33c6e62020-09-29 06:34:35 -050079Acquire Lock After Reboot
80 [Documentation] Acquire and release read and write locks after reboot.
81 [Tags] Acquire_Lock_After_Reboot
82 [Template] Verify Acquire Lock After Reboot
83
84 # client_id lock_type
85 HMCID-01 ReadCase1
86 HMCID-01 ReadCase2
87 HMCID-01 ReadCase3
88 HMCID-01 WriteCase1
89 HMCID-01 WriteCase2
90 HMCID-01 WriteCase3
91
92
Sushil Singhd03f2ce2020-09-17 08:54:41 -050093Acquire And Release Lock In Loop
94 [Documentation] Acquire and release read, write locks in loop.
95 [Tags] Acquire_And_Release_Lock_In_Loop
96 [Template] Verify Acquire And Release Lock In Loop
George Keishing566daaf2020-07-02 06:18:50 -050097
Sushil Singhd03f2ce2020-09-17 08:54:41 -050098 # client_id lock_type
99 HMCID-01 ReadCase1
100 HMCID-01 ReadCase2
101 HMCID-01 ReadCase3
102 HMCID-01 WriteCase1
103 HMCID-01 WriteCase2
104 HMCID-01 WriteCase3
Vijay85610ee2020-04-03 05:30:28 -0500105
106
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500107Verify Release Of Valid Locks
108 [Documentation] Release all valid locks.
109 [Tags] Verify_Release_Of_Valid_Locks
110 [Template] Acquire And Release Multiple Locks
Vijayafdd2a12020-04-09 02:03:20 -0500111
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500112 # client_id lock_type release_lock_type
113 HMCID-01 ReadCase1,ReadCase1,ReadCase1 Transaction
114 HMCID-02 ReadCase1,ReadCase1,ReadCase1 Session
Vijayafdd2a12020-04-09 02:03:20 -0500115
116
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500117Invalid Locks Fail To Release
118 [Documentation] Release in-valid lock result in fail.
119 [Tags] Invalid_Locks_Fail_To_Release
120 [Template] Verify Invalid Locks Fail To Release
Vijayafdd2a12020-04-09 02:03:20 -0500121
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500122 # client_id lock_type release_lock_type
123 HMCID-01 ReadCase1,ReadCase1,ReadCase1 Transaction
124 12345 ReadCase2,ReadCase2,ReadCase2 Transaction
125 HMCID ReadCase3,ReadCase3,ReadCase3 Transaction
Vijayafdd2a12020-04-09 02:03:20 -0500126
127
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500128Fail To Release Lock For Another Session
129 [Documentation] Failed to release locks from another session.
130 [Tags] Fail_To_Release_Lock_For_Another_Session
131 [Template] Verify Fail To Release Lock For Another Session
Vijayafdd2a12020-04-09 02:03:20 -0500132
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500133 # client_id lock_type
134 HMCID-01,HMCID-02 ReadCase1,ReadCase1
Vijayafdd2a12020-04-09 02:03:20 -0500135
136
Sushil Singhe33c6e62020-09-29 06:34:35 -0500137Test Invalid Resource ID Data Type Locking
138 [Documentation] Failed to acquire lock for invalid resource id data type.
139 [Tags] Test_Invalid_Resource_ID_Data_Type_Locking
140 [Template] Verify Fail To Acquire Lock For Invalid Resource ID Data Type
141
142 # client_id lock_type
143 HMCID-01 ReadCase1
144 HMCID-01 ReadCase2
145 HMCID-01 ReadCase3
146 HMCID-01 WriteCase1
147 HMCID-01 WriteCase2
148 HMCID-01 WriteCase3
149
150
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500151Fail To Acquire Lock For Invalid Lock Type
152 [Documentation] Failed to acquire read, write lock for invalid lock data passed.
153 [Tags] Fail_To_Acquire_Lock_For_Invalid_Lock_Type
154 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
Vijayafdd2a12020-04-09 02:03:20 -0500155
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500156 # client_id lock_type message
157 HMCID-01 ReadCase1 ${BAD_REQUEST}
158 HMCID-01 ReadCase2 ${BAD_REQUEST}
159 HMCID-01 ReadCase3 ${BAD_REQUEST}
160 HMCID-01 ReadCase4 ${BAD_REQUEST}
161 HMCID-01 ReadCase5 ${BAD_REQUEST}
162 HMCID-01 WriteCase1 ${BAD_REQUEST}
163 HMCID-01 WriteCase2 ${BAD_REQUEST}
164 HMCID-01 WriteCase3 ${BAD_REQUEST}
165 HMCID-01 WriteCase4 ${BAD_REQUEST}
166 HMCID-01 WriteCase5 ${BAD_REQUEST}
Vijayafdd2a12020-04-09 02:03:20 -0500167
Vijayafdd2a12020-04-09 02:03:20 -0500168
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500169Fail To Acquire Lock For Invalid Lock Flag
170 [Documentation] Failed to acquire read write lock for invalid lock flag passed.
171 [Tags] Fail_To_Acquire_Lock_For_Invalid_Lock_Flag
172 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
Vijayafdd2a12020-04-09 02:03:20 -0500173
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500174 # client_id lock_type message
175 HMCID-01 ReadCase6 ${BAD_REQUEST}
176 HMCID-01 ReadCase7 ${BAD_REQUEST}
177 HMCID-01 ReadCase8 ${BAD_REQUEST}
178 HMCID-01 ReadCase9 ${BAD_REQUEST}
179 HMCID-01 ReadCase10 ${BAD_REQUEST}
180 HMCID-01 ReadCase11 ${BAD_REQUEST}
181 HMCID-01 WriteCase6 ${BAD_REQUEST}
182 HMCID-01 WriteCase7 ${BAD_REQUEST}
183 HMCID-01 WriteCase8 ${BAD_REQUEST}
184 HMCID-01 WriteCase9 ${BAD_REQUEST}
185 HMCID-01 WriteCase10 ${BAD_REQUEST}
186 HMCID-01 WriteCase11 ${BAD_REQUEST}
Vijayafdd2a12020-04-09 02:03:20 -0500187
Vijayafdd2a12020-04-09 02:03:20 -0500188
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500189Fail To Acquire Lock For Invalid Segment Flag
190 [Documentation] Failed to acquire read write lock for invalid segment flag passed.
191 [Tags] Fail_To_Acquire_Lock_For_Invalid_Segment_Flag
192 [Template] Verify Fail To Acquire Lock For Invalid Lock Data
193
194 # client_id lock_type message
195 HMCID-01 ReadCase12 ${BAD_REQUEST}
196 HMCID-01 ReadCase13 ${BAD_REQUEST}
197 HMCID-01 ReadCase14 ${BAD_REQUEST}
198 HMCID-01 WriteCase12 ${BAD_REQUEST}
199 HMCID-01 WriteCase13 ${BAD_REQUEST}
200 HMCID-01 WriteCase14 ${BAD_REQUEST}
Vijayafdd2a12020-04-09 02:03:20 -0500201
Sushil Singhbace3002020-10-08 08:12:58 -0500202
203Get Empty Lock Records For Session Where No Locks Acquired
204 [Documentation] If session does not acquire locks then get lock should return
205 ... empty lock records.
206 [Tags] Get_Empty_Lock_Records_For_Session_Where_No_Locks_Acquired
207 [Template] Verify No Locks Records For Session With No Acquired Lock
208
209 # client_id
210 HMCID-01
211
Sushil Singh728ef9c2020-10-28 04:25:39 -0500212
213Get Lock Records For Multiple Session
214 [Documentation] Get lock records of multiple session.
215 [Tags] Get_Lock_Records_For_Multiple_Session
216 [Template] Verify Lock Records Of Multiple Session
217
218 # client_ids lock_type
219 HMCID-01,HMCID-02 ReadCase1,ReadCase1
220
221
Vijaybc331e22020-02-27 04:17:37 -0600222*** Keywords ***
223
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500224Create Redfish Session With ClientID
225 [Documentation] Create redifish session with client id.
226 [Arguments] ${client_id}
Vijay85610ee2020-04-03 05:30:28 -0500227
228 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500229 # client_id This client id can contain string value
230 # (e.g. 12345, "HMCID").
Vijay85610ee2020-04-03 05:30:28 -0500231
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500232 ${session_info}= Create Dictionary
233 ${session}= Redfish Login kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
Vijay85610ee2020-04-03 05:30:28 -0500234
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500235 Set To Dictionary ${session_info} SessionIDs ${session['Id']}
236 Set To Dictionary ${session_info} ClientID ${session["Oem"]["OpenBMC"]["ClientID"]}
Vijay85610ee2020-04-03 05:30:28 -0500237
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500238 [Return] ${session_info}
Vijay85610ee2020-04-03 05:30:28 -0500239
240
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500241RW General Dictionary
242 [Documentation] Create dictionay of lock request.
243 [Arguments] ${read_case} ${res_id}
Vijaybc331e22020-02-27 04:17:37 -0600244
245 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500246 # read_case Read or Write lock type.
247 # res_id Resource id.
Vijaybc331e22020-02-27 04:17:37 -0600248
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500249 ${request_dict}= Create Dictionary
George Keishing566daaf2020-07-02 06:18:50 -0500250
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500251 FOR ${key} IN @{read_case.keys()}
252 Set To Dictionary ${request_dict} LockType ${key}
253 Set To Dictionary ${request_dict} SegmentFlags ${read_case["${key}"]}
254 END
Vijaybc331e22020-02-27 04:17:37 -0600255
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500256 Set To Dictionary ${request_dict} ResourceID ${res_id}
257
258 [Return] ${request_dict}
Vijaybc331e22020-02-27 04:17:37 -0600259
260
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500261Return Description Of Response
262 [Documentation] Return description of REST response.
Vijaybc331e22020-02-27 04:17:37 -0600263 [Arguments] ${resp_text}
264
265 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500266 # resp_text REST response body.
Vijaybc331e22020-02-27 04:17:37 -0600267
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500268 # resp_text after successful partition file upload looks like:
269 # {
270 # "Description": "File Created"
271 # }
Vijaybc331e22020-02-27 04:17:37 -0600272
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500273 ${message}= Evaluate json.loads('''${resp_text}''') json
274
275 [Return] ${message}
Vijaybc331e22020-02-27 04:17:37 -0600276
277
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500278Redfish Post Acquire Lock
279 [Documentation] Acquire and release lock.
280 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600281
282 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500283 # lock_type Read lock or Write lock.
284 # status_code HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600285
Sushil Singhe33c6e62020-09-29 06:34:35 -0500286 ${lock_dict_param}= Form Data To Acquire Lock ${lock_type}
287 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500288 Should Be Equal As Strings ${resp.status_code} ${status_code}
289 ${resp}= Return Description Of Response ${resp.content}
Vijaybc331e22020-02-27 04:17:37 -0600290
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500291 [Return] ${resp}
Vijaybc331e22020-02-27 04:17:37 -0600292
293
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500294Redfish Post Acquire Invalid Lock
295 [Documentation] Redfish to post request to acquire in-valid lock.
296 [Arguments] ${lock_type} ${message} ${status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600297
298 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500299 # lock_type Read lock or Write lock.
300 # message Return message from URI.
301 # status_code HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600302
Sushil Singhe33c6e62020-09-29 06:34:35 -0500303 ${lock_dict_param}= Form Data To Acquire Invalid Lock ${lock_type}
304 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500305 Should Be Equal As Strings ${resp.status_code} ${status_code}
306 Valid Value message ['${resp.content}']
307
308 [Return] ${resp}
Vijaybc331e22020-02-27 04:17:37 -0600309
310
Sushil Singhe33c6e62020-09-29 06:34:35 -0500311Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
312 [Documentation] Redfish to post request to acquire in-valid lock with invalid data type of resource id.
313 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
314
315 # Description of argument(s):
316 # lock_type Read lock or Write lock.
317 # status_code HTTP status code.
318
319 ${lock_dict_param}= Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID ${lock_type}
320 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
321 Should Be Equal As Strings ${resp.status_code} ${status_code}
322
323 [Return] ${resp}
324
325
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500326Form Data To Acquire Lock
327 [Documentation] Create a dictionay for lock request.
328 [Arguments] ${lock_type}
329
330 # Description of argument(s):
331 # lock_type Read lock or Write lock.
332
333 ${lock_res_info}= Get Lock Resource Information
334 ${resp}= RW General Dictionary
335 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
336 ... ${lock_res_info["Valid Case"]["ResourceID"]}
337 ${temp_list}= Create List ${resp}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500338 ${lock_request_dict}= Create Dictionary Request=${temp_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500339
Sushil Singhe33c6e62020-09-29 06:34:35 -0500340 [Return] ${lock_request_dict}
341
342
343Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
344 [Documentation] Create a dictionay for in-valid lock request.
345 [Arguments] ${lock_type}
346
347 # Description of argument(s):
348 # lock_type Read lock or Write lock.
349
350 ${lock_res_info}= Get Lock Resource Information
351 ${resp}= RW General Dictionary
352 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
353 ... ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
354 ${temp_list}= Create List ${resp}
355 ${lock_request_dict}= Create Dictionary Request=${temp_list}
356
357 [Return] ${lock_request_dict}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500358
359
360Form Data To Acquire Invalid Lock
361 [Documentation] Create a dictionay for in-valid lock request.
362 [Arguments] ${lock_type}
363
364 # Description of argument(s):
365 # lock_type Read lock or Write lock.
366
367 ${lock_res_info}= Get Lock Resource Information
368 ${resp}= RW General Dictionary
369 ... ${lock_res_info["Invalid Case"]["${lock_type}"]}
370 ... ${lock_res_info["Valid Case"]["ResourceID"]}
371 ${temp_list}= Create List ${resp}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500372 ${lock_request_dict}= Create Dictionary Request=${temp_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500373
Sushil Singhe33c6e62020-09-29 06:34:35 -0500374 [Return] ${lock_request_dict}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500375
376
377Get Locks List On Resource
Vijaybc331e22020-02-27 04:17:37 -0600378 [Documentation] Get locks list.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500379 [Arguments] ${session_info} ${exp_status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600380
381 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500382 # session_info Session information in dict.
383 # exp_status_code Expected HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600384
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500385 ${data}= Set Variable {"SessionIDs": ["${session_info['SessionIDs']}"]}
George Keishing566daaf2020-07-02 06:18:50 -0500386 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
387 ... data=${data}
Vijaybc331e22020-02-27 04:17:37 -0600388 ${locks}= Evaluate json.loads('''${resp.text}''') json
389
390 [Return] ${locks["Records"]}
391
392
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500393Verify Lock On Resource
394 [Documentation] Verify lock on resource.
395 [Arguments] ${session_info} ${transaction_id}
Vijaybc331e22020-02-27 04:17:37 -0600396
397 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500398 # session_info Session information in dict.
399 # transaction_id Transaction id in list stored in dict.
Vijaybc331e22020-02-27 04:17:37 -0600400
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500401 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
402 Rprint Vars sessions
403 ${lock_list}= Get Locks List On Resource ${session_info}
404 ${lock_length}= Get Length ${lock_list}
405 ${tran_id_length}= Get Length ${transaction_id}
406 Should Be Equal As Integers ${tran_id_length} ${lock_length}
Vijayafdd2a12020-04-09 02:03:20 -0500407
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500408 FOR ${tran_id} ${lock} IN ZIP ${transaction_id} ${lock_list}
409 Valid Value session_info['ClientID'] ['${lock['HMCID']}']
410 Valid Value session_info['SessionIDs'] ['${lock['SessionID']}']
411 Should Be Equal As Integers ${tran_id['TransactionID']} ${lock['TransactionID']}
Vijaybc331e22020-02-27 04:17:37 -0600412 END
413
Vijaybc331e22020-02-27 04:17:37 -0600414
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500415Acquire Lock On Resource
416 [Documentation] Acquire lock on resource.
417 [Arguments] ${client_id} ${lock_type} ${reboot_flag}=False
Vijaybc331e22020-02-27 04:17:37 -0600418
419 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500420 # client_id This client id can contain string value
421 # (e.g. 12345, "HMCID").
422 # lock_type Read lock or Write lock.
423 # reboot_flag Flag is used to run reboot the BMC code.
424 # (e.g. True or False).
Vijaybc331e22020-02-27 04:17:37 -0600425
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500426 ${trans_id_list}= Create List
427 ${session_info}= Create Redfish Session With ClientID ${client_id}
428 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
429 Append To List ${trans_id_list} ${trans_id}
430 Verify Lock On Resource ${session_info} ${trans_id_list}
George Keishing566daaf2020-07-02 06:18:50 -0500431
Sushil Singhe33c6e62020-09-29 06:34:35 -0500432 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
Vijaybc331e22020-02-27 04:17:37 -0600433
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500434 Run Keyword If '${reboot_flag}' == 'True'
435 ... Run Keywords Redfish OBMC Reboot (off) AND
436 ... Redfish Login AND
Sushil Singhe33c6e62020-09-29 06:34:35 -0500437 ... Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} AND
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500438 ... Verify Lock On Resource ${session_info} ${trans_id_list} AND
439 ... Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600440
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500441 Run Keyword If '${reboot_flag}' == 'False'
442 ... Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600443
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500444 ${trans_id_emptylist}= Create List
445 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
446 Redfish Delete Session ${session_info}
Vijaybc331e22020-02-27 04:17:37 -0600447
Vijaybc331e22020-02-27 04:17:37 -0600448
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500449Form Data To Release Lock
450 [Documentation] Create a dictonay to release lock.
451 [Arguments] ${trans_id_list}
Vijay355daac2020-03-26 12:06:08 -0500452
453 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500454 # trans_id_list
Vijay355daac2020-03-26 12:06:08 -0500455
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500456 @{tran_ids}= Create List
Vijay355daac2020-03-26 12:06:08 -0500457
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500458 FOR ${item} IN @{trans_id_list}
459 Append To List ${tran_ids} ${item['TransactionID']}
460 END
461
462 [Return] ${tran_ids}
463
464
465Release Locks On Resource
466 [Documentation] Redfish request to release a lock.
467 [Arguments] ${session_info} ${trans_id_list} ${release_lock_type}=Transaction ${status_code}=${HTTP_OK}
468
469 # Description of argument(s):
470 # session_info Session information in dict.
471 # trans_id_list Transaction id list.
472 # release_lock_type Release lock by Transaction, Session.
473 # status_code HTTP status code.
474
475 ${tran_ids}= Form Data To Release Lock ${trans_id_list}
476 ${data}= Set Variable {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
477 ${data}= Evaluate json.dumps(${data}) json
478 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock data=${data}
479 Should Be Equal As Strings ${resp.status_code} ${status_code}
480
481
482Acquire Lock On Another Lock
483 [Documentation] Acquire lock on another lock.
484 [Arguments] ${client_id}
485
486 # Description of argument(s):
487 # client_id This client id can contain string value
488 # (e.g. 12345, "HMCID").
489
490 ${trans_id_list}= Create List
491 ${session_info}= Create Redfish Session With ClientID ${client_id}
492
493 ${trans_id}= Redfish Post Acquire Lock ReadCase1
494 Append To List ${trans_id_list} ${trans_id}
495
496 ${trans_id}= Redfish Post Acquire Lock ReadCase1
497 Append To List ${trans_id_list} ${trans_id}
498
499 Verify Lock On Resource ${session_info} ${trans_id_list}
500 Release Locks On Resource ${session_info} ${trans_id_list}
501
502 ${trans_id_emptylist}= Create List
503 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
504 Redfish Delete Session ${session_info}
505
506
507Verify Empty Lock Records For Invalid Session
508 [Documentation] Verify no lock record found for invalid session.
509 [Arguments] ${client_id}
510
511 # Description of argument(s):
512 # client_id This client id can contain string value
513 # (e.g. 12345, "HMCID").
514
515 ${session_info1}= Create Redfish Session With ClientID ${client_id}
516
517 ${lock_list1}= Get Locks List On Resource ${session_info1}
518 ${lock_length1}= Get Length ${lock_list1}
519
520 ${session_info2}= Copy Dictionary ${session_info1} deepcopy=True
521 set to dictionary ${session_info2} SessionIDs xxyXyyYZZz
522
523 ${lock_list2}= Get Locks List On Resource ${session_info2}
524 ${lock_length2}= Get Length ${lock_list1}
525
526 Valid Value lock_length1 ${lock_list2}
527
528 Redfish Delete Session ${session_info1}
529
530
531Verify Acquire Lock Fails On Another Lock
532 [Documentation] Verify acquire lock on another lock fails.
533 [Arguments] ${client_id} ${lock_type}
534
535 # Description of argument(s):
536 # client_id This client id can contain string value
537 # (e.g. 12345, "HMCID").
538 # lock_type Read lock or Write lock.
539
540 @{lock_type_list}= Split String ${lock_type} ,
541 ${session_info}= Create Redfish Session With ClientID ${client_id}
542 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
543
544 ${trans_id_list}= Create List
545 Append To List ${trans_id_list} ${trans_id}
546
547 Verify Lock On Resource ${session_info} ${trans_id_list}
548 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1] status_code=${HTTP_CONFLICT}
549 Release Locks On Resource ${session_info} ${trans_id_list}
550
551 ${trans_id_emptylist}= Create List
552 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
553
554 Redfish Delete Session ${session_info}
555
556
Sushil Singhe33c6e62020-09-29 06:34:35 -0500557Verify Acquire Lock After Reboot
558 [Documentation] Acquire read and write lock after the reboot and release lock.
559 [Arguments] ${client_id} ${lock_type}
560
561 # Description of argument(s):
562 # client_id This client id can contain string value
563 # (e.g. 12345, "HMCID").
564 # lock_type Read lock or Write lock.
565
566 ${trans_id_list}= Create List
567 ${session_info}= Create Redfish Session With ClientID ${client_id}
568 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
569 Redfish OBMC Reboot (off)
570 Redfish Login
571 Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token}
572
573 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
574 Append To List ${trans_id_list} ${trans_id}
575 Verify Lock On Resource ${session_info} ${trans_id_list}
576 Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
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
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500583Verify Acquire And Release Lock In Loop
584 [Documentation] Acquire lock in loop.
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 FOR ${count} IN RANGE 1 11
593 ${trans_id_list}= Create List
594 ${session_info}= Create Redfish Session With ClientID ${client_id}
595 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
596 Append To List ${trans_id_list} ${trans_id}
597 Verify Lock On Resource ${session_info} ${trans_id_list}
598 Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
599 ${trans_id_emptylist}= Create List
600 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
601 END
602
603 Redfish Delete Session ${session_info}
604
605
606Acquire And Release Multiple Locks
607 [Documentation] Acquire mutilple locks on resource.
608 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
609
610 # Description of argument(s):
611 # client_id This client id can contain string value
612 # (e.g. 12345, "HMCID").
613 # lock_type Read lock or Write lock.
614 # release_lock_type The value can be Transaction or Session.
615
616 @{lock_type_list}= Split String ${lock_type} ,
617 ${session_info}= Create Redfish Session With ClientID ${client_id}
618 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
619
620 ${trans_id_list}= Create List
621
622 Append To List ${trans_id_list} ${trans_id}
623 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
624
625 Append To List ${trans_id_list} ${trans_id}
626 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2]
627
628 Append To List ${trans_id_list} ${trans_id}
629 Verify Lock On Resource ${session_info} ${trans_id_list}
630 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=${release_lock_type}
631
632 ${trans_id_emptylist}= Create List
633 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
634 Redfish Delete Session ${session_info}
635
636
637Verify Invalid Locks Fail To Release
638 [Documentation] Verify invalid locks fails to be released.
639 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
640
641 # Description of argument(s):
642 # client_id This client id can contain string value
643 # (e.g. 12345, "HMCID").
644 # lock_type Read lock or Write lock.
645 # release_lock_type The value can be Transaction or Session.
646
647 ${trans_id_list}= Create List
648 @{lock_type_list}= Split String ${lock_type} ,
649
650 ${session_info}= Create Redfish Session With ClientID ${client_id}
651
652 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
653 ${value}= Get From Dictionary ${trans_id} TransactionID
654 ${value}= Evaluate ${value} + 10
655 Set To Dictionary ${trans_id} TransactionID ${value}
656 Append To List ${trans_id_list} ${trans_id}
657
658 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
659 ${value}= Get From Dictionary ${trans_id} TransactionID
660 ${value}= Evaluate ${value} + 10
661 Set To Dictionary ${trans_id} TransactionID ${value}
662 Append To List ${trans_id_list} ${trans_id}
663
664 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2]
665 ${value}= Get From Dictionary ${trans_id} TransactionID
666 ${value}= Evaluate ${value} + 10
667 Set To Dictionary ${trans_id} TransactionID ${value}
668 Append To List ${trans_id_list} ${trans_id}
669
670 Release Locks On Resource
671 ... ${session_info} ${trans_id_list}
672 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
673 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session
674
675 ${trans_id_emptylist}= Create List
676 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
677 Redfish Delete Session ${session_info}
678
679
680Verify Fail To Release Lock For Another Session
681 [Documentation] Verify failed to release the lock form another session.
682 [Arguments] ${client_id} ${lock_type}
683
684 # Description of argument(s):
685 # client_id This client id can contain string value
686 # (e.g. 12345, "HMCID").
687 # lock_type Read lock or Write lock.
688
689 ${client_ids}= Split String ${client_id} ,
690 ${lock_type_list}= Split String ${lock_type} ,
691 ${trans_id_list1}= Create List
692 ${trans_id_list2}= Create List
693
694 ${session_info1}= Create Redfish Session With ClientID ${client_ids}[0]
695
696 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
697 Append To List ${trans_id_list1} ${trans_id}
698 Verify Lock On Resource ${session_info1} ${trans_id_list1}
699
700 ${session_info2}= Create Redfish Session With ClientID ${client_ids}[1]
701 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
702 Append To List ${trans_id_list2} ${trans_id}
703 Verify Lock On Resource ${session_info2} ${trans_id_list2}
704
705 Release Locks On Resource
706 ... ${session_info1} ${trans_id_list1} Transaction status_code=${HTTP_UNAUTHORIZED}
707 Verify Lock On Resource ${session_info1} ${trans_id_list1}
708 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Session
709 Release Locks On Resource ${session_info2} ${trans_id_list2} release_lock_type=Session
710 Redfish Delete Session ${session_info1}
711 Redfish Delete Session ${session_info2}
712
713
Sushil Singhe33c6e62020-09-29 06:34:35 -0500714Verify Fail To Acquire Lock For Invalid Resource ID Data Type
715 [Documentation] Verify fail to acquire the lock with invalid resource id data type.
716 [Arguments] ${client_id} ${lock_type}
717
718 # Description of argument(s):
719 # client_id This client id can contain string value
720 # (e.g. 12345, "HMCID").
721 # lock_type Read lock or Write lock.
722
723 ${session_info}= Create Redfish Session With ClientID ${client_id}
724 Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
725 ... ${lock_type} status_code=${HTTP_BAD_REQUEST}
726 Redfish Delete Session ${session_info}
727
728
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500729Verify Fail To Acquire Lock For Invalid Lock Data
Sushil Singhe33c6e62020-09-29 06:34:35 -0500730 [Documentation] Verify fail to acquired lock with invalid lock types, lock flags, segement flags.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500731 [Arguments] ${client_id} ${lock_type} ${message}
732
733 # Description of argument(s):
734 # client_id This client id can contain string value
735 # (e.g. 12345, "HMCID").
736 # lock_type Read lock or Write lock.
737 # message Return message from URI.
738
739 ${session_info}= Create Redfish Session With ClientID ${client_id}
740 ${trans_id}= Redfish Post Acquire Invalid Lock ${lock_type} message=${message} status_code=${HTTP_BAD_REQUEST}
741 Redfish Delete Session ${session_info}
Sushil Singhbace3002020-10-08 08:12:58 -0500742
743
744Verify No Locks Records For Session With No Acquired Lock
745 [Documentation] Verify no records found for a session where no lock is acquired.
746 [Arguments] ${client_id}
747
748 # Description of argument(s):
749 # client_id This client id can contain string value
750 # (e.g. 12345, "HMCID").
751
752 ${session_info}= Create Redfish Session With ClientID ${client_id}
753 ${trans_id_emptylist}= Create List
754 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
755 Redfish Delete Session ${session_info}
Sushil Singh728ef9c2020-10-28 04:25:39 -0500756
757
758Create List Of Session ID
759 [Documentation] Create session id list from session dict info.
760 [Arguments] ${session_dict_info}
761
762 # Description of argument(s):
763 # session_dict_info Session information in dict.
764
765 @{session_id_list}= Create List
766
767 FOR ${session} IN @{session_dict_info}
768 Append To List ${session_id_list} ${session["SessionIDs"]}
769 END
770
771 ${num_id}= Get Length ${session_id_list}
772 Should Not Be Equal As Integers ${num_id} ${0}
773
774 ${session_id_list}= Evaluate json.dumps(${session_id_list}) json
775
776 [Return] ${session_id_list}
777
778
779Get Locks List On Resource With Session List
780 [Documentation] Get locks list from session of list.
781 [Arguments] ${session_id_list} ${exp_status_code}=${HTTP_OK}
782
783 # Description of argument(s):
784 # session_id_list Session ids list.
785 # exp_status_code Expected HTTP status code.
786
787 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
788 ... data={"SessionIDs": ${session_id_list}}
789 ${locks}= Evaluate json.loads('''${resp.text}''') json
790
791 [Return] ${locks}
792
793
794Verify List Of Session Lock On Resource
795 [Documentation] Verify list of lock record from list of sessions.
796 [Arguments] ${session_dict_info} ${transaction_id_list}
797
798 # Description of argument(s):
799 # session_dict_info Session information in dict.
800 # transaction_id_list Transaction id in list stored in dict.
801
802 ${session_id_list}= Create List Of Session ID ${session_dict_info}
803 ${lock_list_resp}= Get Locks List On Resource With Session List ${session_id_list}
804 ${lock_list}= Set Variable ${lock_list_resp['Records']}
805
806 FOR ${session_id} ${tran_id} ${lock_record} IN ZIP ${session_dict_info} ${transaction_id_list} ${lock_list}
807 Valid Value session_id['SessionIDs'] ['${lock_record['SessionID']}']
808 Should Be Equal As Integers ${tran_id['TransactionID']} ${lock_record['TransactionID']}
809 END
810
811
812Verify Lock Records Of Multiple Session
813 [Documentation] Verify all records found for a multiple sessions.
814 [Arguments] ${client_ids} ${lock_type}
815
816 # Description of argument(s):
817 # client_ids This client id can contain string value
818 # (e.g. 12345, "HMCID").
819 # lock_type Read lock or Write lock.
820
821 ${client_id_list}= Split String ${client_ids} ,
822 ${lock_type_list}= Split String ${lock_type} ,
823 ${trans_id_list1}= Create List
824 ${trans_id_list2}= Create List
825
826 ${session_dict_list}= Create List
827 ${lock_list}= Create List
828
829 ${client_id1}= Create List
830 Append To List ${client_id1} ${client_id_list}[0]
831 ${session_info1}= Create Session With List Of ClientID ${client_id1}
832 Append To List ${session_dict_list} ${session_info1}[0]
833 Verify A Session Created With ClientID ${client_id1} ${session_info1}
834
835 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
836 Append To List ${trans_id_list1} ${trans_id}
837 Append To List ${lock_list} ${trans_id}
838 Verify Lock On Resource ${session_info1}[0] ${trans_id_list1}
839
840
841 ${client_id2}= Create List
842 Append To List ${client_id2} ${client_id_list}[1]
843 ${session_info2}= Create Session With List Of ClientID ${client_id2}
844 Append To List ${session_dict_list} ${session_info2}[0]
845 Verify A Session Created With ClientID ${client_id2} ${session_info2}
846
847 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
848 Append To List ${trans_id_list2} ${trans_id}
849 Append To List ${lock_list} ${trans_id}
850 Verify Lock On Resource ${session_info2}[0] ${trans_id_list2}
851
852 Verify List Of Session Lock On Resource ${session_dict_list} ${lock_list}
853
854 ${session_token}= Get From Dictionary ${session_info1}[0] SessionToken
855 Set Global Variable ${XAUTH_TOKEN} ${session_token}
856
857 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Transaction
858
859 ${session_token}= Get From Dictionary ${session_info2}[0] SessionToken
860 Set Global Variable ${XAUTH_TOKEN} ${session_token}
861
862 Release Locks On Resource ${session_info2} ${trans_id_list2} release_lock_type=Transaction
863
864 ${trans_id_emptylist}= Create List
865 Verify Lock On Resource ${session_info1}[0] ${trans_id_emptylist}
866 Verify Lock On Resource ${session_info2}[0] ${trans_id_emptylist}
867
868 Redfish Delete List Of Session ${session_dict_list}