blob: a540f236c578b487dbcd4f6eea63175e4f660f88 [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 Singha7d71f02020-11-02 05:24:22 -0600278Verify Redfish Session Deleted
279 [Documentation] Verify the redfish session is deleted.
280 [Arguments] ${session_info}
281
282 # Description of argument(s):
283 # session_info Session information are stored in dictionary.
284
285 # ${session_info} = {
286 # 'SessionIDs': 'XXXXXXXXX',
287 # 'ClientID': 'XXXXXX',
288 # 'SessionToken': 'XXXXXXXXX',
289 # 'SessionResp': session response from redfish login
290 # }
291
292 # SessionIDs : Session IDs
293 # ClientID : Client ID
294 # SessionToken : Session token
295 # SessionResp : Response of creating an redfish login session
296
297 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions
298
299 FOR ${session} IN @{sessions['Members']}
300 Should Not Be Equal As Strings session ['/redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}']
301 END
302
303
304Verify Redfish List Of Session Deleted
305 [Documentation] Verify all the list of redfish session is deleted.
306 [Arguments] ${session_info_list}
307
308 # Description of argument(s):
309 # session_info_list List contains individual session record are stored in dictionary.
310
311 # ${session_info_list} = [{
312 # 'SessionIDs': 'XXXXXXXXX',
313 # 'ClientID': 'XXXXXX',
314 # 'SessionToken': 'XXXXXXXXX',
315 # 'SessionResp': session response from redfish login
316 # }]
317
318 # SessionIDs : Session IDs
319 # ClientID : Client ID
320 # SessionToken : Session token
321 # SessionResp : Response of creating an redfish login session
322
323 FOR ${session_record} IN @{session_info_list}
324 Verify Redfish Session Deleted ${session_record}
325 END
326
327
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500328Redfish Post Acquire Lock
329 [Documentation] Acquire and release lock.
330 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600331
332 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500333 # lock_type Read lock or Write lock.
334 # status_code HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600335
Sushil Singhe33c6e62020-09-29 06:34:35 -0500336 ${lock_dict_param}= Form Data To Acquire Lock ${lock_type}
337 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500338 Should Be Equal As Strings ${resp.status_code} ${status_code}
339 ${resp}= Return Description Of Response ${resp.content}
Vijaybc331e22020-02-27 04:17:37 -0600340
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500341 [Return] ${resp}
Vijaybc331e22020-02-27 04:17:37 -0600342
343
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500344Redfish Post Acquire Invalid Lock
345 [Documentation] Redfish to post request to acquire in-valid lock.
346 [Arguments] ${lock_type} ${message} ${status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600347
348 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500349 # lock_type Read lock or Write lock.
350 # message Return message from URI.
351 # status_code HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600352
Sushil Singhe33c6e62020-09-29 06:34:35 -0500353 ${lock_dict_param}= Form Data To Acquire Invalid Lock ${lock_type}
354 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500355 Should Be Equal As Strings ${resp.status_code} ${status_code}
356 Valid Value message ['${resp.content}']
357
358 [Return] ${resp}
Vijaybc331e22020-02-27 04:17:37 -0600359
360
Sushil Singhe33c6e62020-09-29 06:34:35 -0500361Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
362 [Documentation] Redfish to post request to acquire in-valid lock with invalid data type of resource id.
363 [Arguments] ${lock_type} ${status_code}=${HTTP_OK}
364
365 # Description of argument(s):
366 # lock_type Read lock or Write lock.
367 # status_code HTTP status code.
368
369 ${lock_dict_param}= Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID ${lock_type}
370 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param}
371 Should Be Equal As Strings ${resp.status_code} ${status_code}
372
373 [Return] ${resp}
374
375
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500376Form Data To Acquire Lock
377 [Documentation] Create a dictionay for lock request.
378 [Arguments] ${lock_type}
379
380 # Description of argument(s):
381 # lock_type Read lock or Write lock.
382
383 ${lock_res_info}= Get Lock Resource Information
384 ${resp}= RW General Dictionary
385 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
386 ... ${lock_res_info["Valid Case"]["ResourceID"]}
387 ${temp_list}= Create List ${resp}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500388 ${lock_request_dict}= Create Dictionary Request=${temp_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500389
Sushil Singhe33c6e62020-09-29 06:34:35 -0500390 [Return] ${lock_request_dict}
391
392
393Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID
394 [Documentation] Create a dictionay for in-valid lock request.
395 [Arguments] ${lock_type}
396
397 # Description of argument(s):
398 # lock_type Read lock or Write lock.
399
400 ${lock_res_info}= Get Lock Resource Information
401 ${resp}= RW General Dictionary
402 ... ${lock_res_info["Valid Case"]["${lock_type}"]}
403 ... ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]}
404 ${temp_list}= Create List ${resp}
405 ${lock_request_dict}= Create Dictionary Request=${temp_list}
406
407 [Return] ${lock_request_dict}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500408
409
410Form Data To Acquire Invalid Lock
411 [Documentation] Create a dictionay for in-valid lock request.
412 [Arguments] ${lock_type}
413
414 # Description of argument(s):
415 # lock_type Read lock or Write lock.
416
417 ${lock_res_info}= Get Lock Resource Information
418 ${resp}= RW General Dictionary
419 ... ${lock_res_info["Invalid Case"]["${lock_type}"]}
420 ... ${lock_res_info["Valid Case"]["ResourceID"]}
421 ${temp_list}= Create List ${resp}
Sushil Singhe33c6e62020-09-29 06:34:35 -0500422 ${lock_request_dict}= Create Dictionary Request=${temp_list}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500423
Sushil Singhe33c6e62020-09-29 06:34:35 -0500424 [Return] ${lock_request_dict}
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500425
426
427Get Locks List On Resource
Vijaybc331e22020-02-27 04:17:37 -0600428 [Documentation] Get locks list.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500429 [Arguments] ${session_info} ${exp_status_code}=${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600430
431 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500432 # session_info Session information in dict.
433 # exp_status_code Expected HTTP status code.
Vijaybc331e22020-02-27 04:17:37 -0600434
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500435 ${data}= Set Variable {"SessionIDs": ["${session_info['SessionIDs']}"]}
George Keishing566daaf2020-07-02 06:18:50 -0500436 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
437 ... data=${data}
Vijaybc331e22020-02-27 04:17:37 -0600438 ${locks}= Evaluate json.loads('''${resp.text}''') json
439
440 [Return] ${locks["Records"]}
441
442
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500443Verify Lock On Resource
444 [Documentation] Verify lock on resource.
445 [Arguments] ${session_info} ${transaction_id}
Vijaybc331e22020-02-27 04:17:37 -0600446
447 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500448 # session_info Session information in dict.
449 # transaction_id Transaction id in list stored in dict.
Vijaybc331e22020-02-27 04:17:37 -0600450
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500451 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']}
452 Rprint Vars sessions
453 ${lock_list}= Get Locks List On Resource ${session_info}
454 ${lock_length}= Get Length ${lock_list}
455 ${tran_id_length}= Get Length ${transaction_id}
456 Should Be Equal As Integers ${tran_id_length} ${lock_length}
Vijayafdd2a12020-04-09 02:03:20 -0500457
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500458 FOR ${tran_id} ${lock} IN ZIP ${transaction_id} ${lock_list}
459 Valid Value session_info['ClientID'] ['${lock['HMCID']}']
460 Valid Value session_info['SessionIDs'] ['${lock['SessionID']}']
461 Should Be Equal As Integers ${tran_id['TransactionID']} ${lock['TransactionID']}
Vijaybc331e22020-02-27 04:17:37 -0600462 END
463
Vijaybc331e22020-02-27 04:17:37 -0600464
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500465Acquire Lock On Resource
466 [Documentation] Acquire lock on resource.
467 [Arguments] ${client_id} ${lock_type} ${reboot_flag}=False
Vijaybc331e22020-02-27 04:17:37 -0600468
469 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500470 # client_id This client id can contain string value
471 # (e.g. 12345, "HMCID").
472 # lock_type Read lock or Write lock.
473 # reboot_flag Flag is used to run reboot the BMC code.
474 # (e.g. True or False).
Vijaybc331e22020-02-27 04:17:37 -0600475
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500476 ${trans_id_list}= Create List
477 ${session_info}= Create Redfish Session With ClientID ${client_id}
478 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
479 Append To List ${trans_id_list} ${trans_id}
480 Verify Lock On Resource ${session_info} ${trans_id_list}
George Keishing566daaf2020-07-02 06:18:50 -0500481
Sushil Singhe33c6e62020-09-29 06:34:35 -0500482 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
Vijaybc331e22020-02-27 04:17:37 -0600483
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500484 Run Keyword If '${reboot_flag}' == 'True'
485 ... Run Keywords Redfish OBMC Reboot (off) AND
486 ... Redfish Login AND
Sushil Singhe33c6e62020-09-29 06:34:35 -0500487 ... Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} AND
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500488 ... Verify Lock On Resource ${session_info} ${trans_id_list} AND
489 ... Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600490
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500491 Run Keyword If '${reboot_flag}' == 'False'
492 ... Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
Vijaybc331e22020-02-27 04:17:37 -0600493
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500494 ${trans_id_emptylist}= Create List
495 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
496 Redfish Delete Session ${session_info}
Vijaybc331e22020-02-27 04:17:37 -0600497
Vijaybc331e22020-02-27 04:17:37 -0600498
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500499Form Data To Release Lock
500 [Documentation] Create a dictonay to release lock.
501 [Arguments] ${trans_id_list}
Vijay355daac2020-03-26 12:06:08 -0500502
503 # Description of argument(s):
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500504 # trans_id_list
Vijay355daac2020-03-26 12:06:08 -0500505
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500506 @{tran_ids}= Create List
Vijay355daac2020-03-26 12:06:08 -0500507
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500508 FOR ${item} IN @{trans_id_list}
509 Append To List ${tran_ids} ${item['TransactionID']}
510 END
511
512 [Return] ${tran_ids}
513
514
515Release Locks On Resource
516 [Documentation] Redfish request to release a lock.
517 [Arguments] ${session_info} ${trans_id_list} ${release_lock_type}=Transaction ${status_code}=${HTTP_OK}
518
519 # Description of argument(s):
520 # session_info Session information in dict.
521 # trans_id_list Transaction id list.
522 # release_lock_type Release lock by Transaction, Session.
523 # status_code HTTP status code.
524
525 ${tran_ids}= Form Data To Release Lock ${trans_id_list}
526 ${data}= Set Variable {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}}
527 ${data}= Evaluate json.dumps(${data}) json
528 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock data=${data}
529 Should Be Equal As Strings ${resp.status_code} ${status_code}
530
531
532Acquire Lock On Another Lock
533 [Documentation] Acquire lock on another lock.
534 [Arguments] ${client_id}
535
536 # Description of argument(s):
537 # client_id This client id can contain string value
538 # (e.g. 12345, "HMCID").
539
540 ${trans_id_list}= Create List
541 ${session_info}= Create Redfish Session With ClientID ${client_id}
542
543 ${trans_id}= Redfish Post Acquire Lock ReadCase1
544 Append To List ${trans_id_list} ${trans_id}
545
546 ${trans_id}= Redfish Post Acquire Lock ReadCase1
547 Append To List ${trans_id_list} ${trans_id}
548
549 Verify Lock On Resource ${session_info} ${trans_id_list}
550 Release Locks On Resource ${session_info} ${trans_id_list}
551
552 ${trans_id_emptylist}= Create List
553 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
554 Redfish Delete Session ${session_info}
555
556
557Verify Empty Lock Records For Invalid Session
558 [Documentation] Verify no lock record found for invalid session.
559 [Arguments] ${client_id}
560
561 # Description of argument(s):
562 # client_id This client id can contain string value
563 # (e.g. 12345, "HMCID").
564
565 ${session_info1}= Create Redfish Session With ClientID ${client_id}
566
567 ${lock_list1}= Get Locks List On Resource ${session_info1}
568 ${lock_length1}= Get Length ${lock_list1}
569
570 ${session_info2}= Copy Dictionary ${session_info1} deepcopy=True
571 set to dictionary ${session_info2} SessionIDs xxyXyyYZZz
572
573 ${lock_list2}= Get Locks List On Resource ${session_info2}
574 ${lock_length2}= Get Length ${lock_list1}
575
576 Valid Value lock_length1 ${lock_list2}
577
578 Redfish Delete Session ${session_info1}
579
580
581Verify Acquire Lock Fails On Another Lock
582 [Documentation] Verify acquire lock on another lock fails.
583 [Arguments] ${client_id} ${lock_type}
584
585 # Description of argument(s):
586 # client_id This client id can contain string value
587 # (e.g. 12345, "HMCID").
588 # lock_type Read lock or Write lock.
589
590 @{lock_type_list}= Split String ${lock_type} ,
591 ${session_info}= Create Redfish Session With ClientID ${client_id}
592 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
593
594 ${trans_id_list}= Create List
595 Append To List ${trans_id_list} ${trans_id}
596
597 Verify Lock On Resource ${session_info} ${trans_id_list}
598 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1] status_code=${HTTP_CONFLICT}
599 Release Locks On Resource ${session_info} ${trans_id_list}
600
601 ${trans_id_emptylist}= Create List
602 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
603
604 Redfish Delete Session ${session_info}
605
606
Sushil Singhe33c6e62020-09-29 06:34:35 -0500607Verify Acquire Lock After Reboot
608 [Documentation] Acquire read and write lock after the reboot and release lock.
609 [Arguments] ${client_id} ${lock_type}
610
611 # Description of argument(s):
612 # client_id This client id can contain string value
613 # (e.g. 12345, "HMCID").
614 # lock_type Read lock or Write lock.
615
616 ${trans_id_list}= Create List
617 ${session_info}= Create Redfish Session With ClientID ${client_id}
618 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN}
619 Redfish OBMC Reboot (off)
620 Redfish Login
621 Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token}
622
623 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
624 Append To List ${trans_id_list} ${trans_id}
625 Verify Lock On Resource ${session_info} ${trans_id_list}
626 Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
627
628 ${trans_id_emptylist}= Create List
629 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
630 Redfish Delete Session ${session_info}
631
632
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500633Verify Acquire And Release Lock In Loop
634 [Documentation] Acquire lock in loop.
635 [Arguments] ${client_id} ${lock_type}
636
637 # Description of argument(s):
638 # client_id This client id can contain string value
639 # (e.g. 12345, "HMCID").
640 # lock_type Read lock or Write lock.
641
642 FOR ${count} IN RANGE 1 11
643 ${trans_id_list}= Create List
644 ${session_info}= Create Redfish Session With ClientID ${client_id}
645 ${trans_id}= Redfish Post Acquire Lock ${lock_type}
646 Append To List ${trans_id_list} ${trans_id}
647 Verify Lock On Resource ${session_info} ${trans_id_list}
648 Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK}
649 ${trans_id_emptylist}= Create List
650 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
651 END
652
653 Redfish Delete Session ${session_info}
654
655
656Acquire And Release Multiple Locks
657 [Documentation] Acquire mutilple locks on resource.
658 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
659
660 # Description of argument(s):
661 # client_id This client id can contain string value
662 # (e.g. 12345, "HMCID").
663 # lock_type Read lock or Write lock.
664 # release_lock_type The value can be Transaction or Session.
665
666 @{lock_type_list}= Split String ${lock_type} ,
667 ${session_info}= Create Redfish Session With ClientID ${client_id}
668 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
669
670 ${trans_id_list}= Create List
671
672 Append To List ${trans_id_list} ${trans_id}
673 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
674
675 Append To List ${trans_id_list} ${trans_id}
676 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2]
677
678 Append To List ${trans_id_list} ${trans_id}
679 Verify Lock On Resource ${session_info} ${trans_id_list}
680 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=${release_lock_type}
681
682 ${trans_id_emptylist}= Create List
683 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
684 Redfish Delete Session ${session_info}
685
686
687Verify Invalid Locks Fail To Release
688 [Documentation] Verify invalid locks fails to be released.
689 [Arguments] ${client_id} ${lock_type} ${release_lock_type}
690
691 # Description of argument(s):
692 # client_id This client id can contain string value
693 # (e.g. 12345, "HMCID").
694 # lock_type Read lock or Write lock.
695 # release_lock_type The value can be Transaction or Session.
696
697 ${trans_id_list}= Create List
698 @{lock_type_list}= Split String ${lock_type} ,
699
700 ${session_info}= Create Redfish Session With ClientID ${client_id}
701
702 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
703 ${value}= Get From Dictionary ${trans_id} TransactionID
704 ${value}= Evaluate ${value} + 10
705 Set To Dictionary ${trans_id} TransactionID ${value}
706 Append To List ${trans_id_list} ${trans_id}
707
708 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
709 ${value}= Get From Dictionary ${trans_id} TransactionID
710 ${value}= Evaluate ${value} + 10
711 Set To Dictionary ${trans_id} TransactionID ${value}
712 Append To List ${trans_id_list} ${trans_id}
713
714 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2]
715 ${value}= Get From Dictionary ${trans_id} TransactionID
716 ${value}= Evaluate ${value} + 10
717 Set To Dictionary ${trans_id} TransactionID ${value}
718 Append To List ${trans_id_list} ${trans_id}
719
720 Release Locks On Resource
721 ... ${session_info} ${trans_id_list}
722 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST}
723 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session
724
725 ${trans_id_emptylist}= Create List
726 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
727 Redfish Delete Session ${session_info}
728
729
730Verify Fail To Release Lock For Another Session
731 [Documentation] Verify failed to release the lock form another session.
732 [Arguments] ${client_id} ${lock_type}
733
734 # Description of argument(s):
735 # client_id This client id can contain string value
736 # (e.g. 12345, "HMCID").
737 # lock_type Read lock or Write lock.
738
739 ${client_ids}= Split String ${client_id} ,
740 ${lock_type_list}= Split String ${lock_type} ,
741 ${trans_id_list1}= Create List
742 ${trans_id_list2}= Create List
743
744 ${session_info1}= Create Redfish Session With ClientID ${client_ids}[0]
745
746 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
747 Append To List ${trans_id_list1} ${trans_id}
748 Verify Lock On Resource ${session_info1} ${trans_id_list1}
749
750 ${session_info2}= Create Redfish Session With ClientID ${client_ids}[1]
751 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
752 Append To List ${trans_id_list2} ${trans_id}
753 Verify Lock On Resource ${session_info2} ${trans_id_list2}
754
755 Release Locks On Resource
756 ... ${session_info1} ${trans_id_list1} Transaction status_code=${HTTP_UNAUTHORIZED}
757 Verify Lock On Resource ${session_info1} ${trans_id_list1}
758 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Session
759 Release Locks On Resource ${session_info2} ${trans_id_list2} release_lock_type=Session
760 Redfish Delete Session ${session_info1}
761 Redfish Delete Session ${session_info2}
762
763
Sushil Singhe33c6e62020-09-29 06:34:35 -0500764Verify Fail To Acquire Lock For Invalid Resource ID Data Type
765 [Documentation] Verify fail to acquire the lock with invalid resource id data type.
766 [Arguments] ${client_id} ${lock_type}
767
768 # Description of argument(s):
769 # client_id This client id can contain string value
770 # (e.g. 12345, "HMCID").
771 # lock_type Read lock or Write lock.
772
773 ${session_info}= Create Redfish Session With ClientID ${client_id}
774 Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID
775 ... ${lock_type} status_code=${HTTP_BAD_REQUEST}
776 Redfish Delete Session ${session_info}
777
778
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500779Verify Fail To Acquire Lock For Invalid Lock Data
Sushil Singhe33c6e62020-09-29 06:34:35 -0500780 [Documentation] Verify fail to acquired lock with invalid lock types, lock flags, segement flags.
Sushil Singhd03f2ce2020-09-17 08:54:41 -0500781 [Arguments] ${client_id} ${lock_type} ${message}
782
783 # Description of argument(s):
784 # client_id This client id can contain string value
785 # (e.g. 12345, "HMCID").
786 # lock_type Read lock or Write lock.
787 # message Return message from URI.
788
789 ${session_info}= Create Redfish Session With ClientID ${client_id}
790 ${trans_id}= Redfish Post Acquire Invalid Lock ${lock_type} message=${message} status_code=${HTTP_BAD_REQUEST}
791 Redfish Delete Session ${session_info}
Sushil Singhbace3002020-10-08 08:12:58 -0500792
793
794Verify No Locks Records For Session With No Acquired Lock
795 [Documentation] Verify no records found for a session where no lock is acquired.
796 [Arguments] ${client_id}
797
798 # Description of argument(s):
799 # client_id This client id can contain string value
800 # (e.g. 12345, "HMCID").
801
802 ${session_info}= Create Redfish Session With ClientID ${client_id}
803 ${trans_id_emptylist}= Create List
804 Verify Lock On Resource ${session_info} ${trans_id_emptylist}
805 Redfish Delete Session ${session_info}
Sushil Singh728ef9c2020-10-28 04:25:39 -0500806
807
808Create List Of Session ID
809 [Documentation] Create session id list from session dict info.
810 [Arguments] ${session_dict_info}
811
812 # Description of argument(s):
813 # session_dict_info Session information in dict.
814
815 @{session_id_list}= Create List
816
817 FOR ${session} IN @{session_dict_info}
818 Append To List ${session_id_list} ${session["SessionIDs"]}
819 END
820
821 ${num_id}= Get Length ${session_id_list}
822 Should Not Be Equal As Integers ${num_id} ${0}
823
824 ${session_id_list}= Evaluate json.dumps(${session_id_list}) json
825
826 [Return] ${session_id_list}
827
828
829Get Locks List On Resource With Session List
830 [Documentation] Get locks list from session of list.
831 [Arguments] ${session_id_list} ${exp_status_code}=${HTTP_OK}
832
833 # Description of argument(s):
834 # session_id_list Session ids list.
835 # exp_status_code Expected HTTP status code.
836
837 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
838 ... data={"SessionIDs": ${session_id_list}}
839 ${locks}= Evaluate json.loads('''${resp.text}''') json
840
841 [Return] ${locks}
842
843
844Verify List Of Session Lock On Resource
845 [Documentation] Verify list of lock record from list of sessions.
846 [Arguments] ${session_dict_info} ${transaction_id_list}
847
848 # Description of argument(s):
849 # session_dict_info Session information in dict.
850 # transaction_id_list Transaction id in list stored in dict.
851
852 ${session_id_list}= Create List Of Session ID ${session_dict_info}
853 ${lock_list_resp}= Get Locks List On Resource With Session List ${session_id_list}
854 ${lock_list}= Set Variable ${lock_list_resp['Records']}
855
856 FOR ${session_id} ${tran_id} ${lock_record} IN ZIP ${session_dict_info} ${transaction_id_list} ${lock_list}
857 Valid Value session_id['SessionIDs'] ['${lock_record['SessionID']}']
858 Should Be Equal As Integers ${tran_id['TransactionID']} ${lock_record['TransactionID']}
859 END
860
861
862Verify Lock Records Of Multiple Session
863 [Documentation] Verify all records found for a multiple sessions.
864 [Arguments] ${client_ids} ${lock_type}
865
866 # Description of argument(s):
867 # client_ids This client id can contain string value
868 # (e.g. 12345, "HMCID").
869 # lock_type Read lock or Write lock.
870
871 ${client_id_list}= Split String ${client_ids} ,
872 ${lock_type_list}= Split String ${lock_type} ,
873 ${trans_id_list1}= Create List
874 ${trans_id_list2}= Create List
875
876 ${session_dict_list}= Create List
877 ${lock_list}= Create List
878
879 ${client_id1}= Create List
880 Append To List ${client_id1} ${client_id_list}[0]
881 ${session_info1}= Create Session With List Of ClientID ${client_id1}
882 Append To List ${session_dict_list} ${session_info1}[0]
883 Verify A Session Created With ClientID ${client_id1} ${session_info1}
884
885 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0]
886 Append To List ${trans_id_list1} ${trans_id}
887 Append To List ${lock_list} ${trans_id}
888 Verify Lock On Resource ${session_info1}[0] ${trans_id_list1}
889
890
891 ${client_id2}= Create List
892 Append To List ${client_id2} ${client_id_list}[1]
893 ${session_info2}= Create Session With List Of ClientID ${client_id2}
894 Append To List ${session_dict_list} ${session_info2}[0]
895 Verify A Session Created With ClientID ${client_id2} ${session_info2}
896
897 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1]
898 Append To List ${trans_id_list2} ${trans_id}
899 Append To List ${lock_list} ${trans_id}
900 Verify Lock On Resource ${session_info2}[0] ${trans_id_list2}
901
902 Verify List Of Session Lock On Resource ${session_dict_list} ${lock_list}
903
904 ${session_token}= Get From Dictionary ${session_info1}[0] SessionToken
905 Set Global Variable ${XAUTH_TOKEN} ${session_token}
906
907 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Transaction
908
909 ${session_token}= Get From Dictionary ${session_info2}[0] SessionToken
910 Set Global Variable ${XAUTH_TOKEN} ${session_token}
911
912 Release Locks On Resource ${session_info2} ${trans_id_list2} release_lock_type=Transaction
913
914 ${trans_id_emptylist}= Create List
915 Verify Lock On Resource ${session_info1}[0] ${trans_id_emptylist}
916 Verify Lock On Resource ${session_info2}[0] ${trans_id_emptylist}
917
918 Redfish Delete List Of Session ${session_dict_list}