blob: 94d07941de2f888623662377ea76bf6bd8e9d39c [file] [log] [blame]
Vijaybc331e22020-02-27 04:17:37 -06001*** Settings ***
2
3Documentation Test Lock Management feature of Management Console on BMC.
4
5Resource ../../lib/resource.robot
6Resource ../../lib/bmc_redfish_resource.robot
7Resource ../../lib/openbmc_ffdc.robot
8
Vijay355daac2020-03-26 12:06:08 -05009Test Setup Test Setup Execution
Vijaybc331e22020-02-27 04:17:37 -060010Test Teardown Test Teardown Execution
11
12*** Variables ***
13
14# Data-sets for testing different test cases.
15&{LOCKALL_LEN1} LockFlag=LockAll SegmentLength=${1}
16&{LOCKALL_LEN2} LockFlag=LockAll SegmentLength=${2}
17&{LOCKALL_LEN3} LockFlag=LockAll SegmentLength=${3}
18&{LOCKALL_LEN4} LockFlag=LockAll SegmentLength=${4}
19&{LOCKALL_LEN5} LockFlag=LockAll SegmentLength=${5}
20
21&{LOCKALL_INVALID_LOCKFLAG1} LockFlag=LocAll SegmentLength=${2}
22&{LOCKALL_INVALID_LOCKFLAG2} LockFlag=LOCKALL SegmentLength=${3}
23&{LOCKALL_INVALID_LOCKFLAG3} LOCKFLAG=LockAll SegmentLength=${4}
24&{LOCKSAME_INVALID_LOCKFLAG3} Lock=LockSame SegmentLength=${1}
25&{LOCKSAME_INVALID_LOCKFLAG4} Lock=LockSame SegmentLength=${True}
26
27&{LOCKSAME_LEN1} LockFlag=LockSame SegmentLength=${1}
28&{LOCKSAME_LEN2} LockFlag=LockSame SegmentLength=${2}
29&{LOCKSAME_LEN3} LockFlag=LockSame SegmentLength=${3}
30&{LOCKSAME_LEN4} LockFlag=LockSame SegmentLength=${4}
31&{LOCKSAME_INVALID_LEN1} LockFlag=LockSame SegmentLength=${0}
32&{LOCKSAME_INVALID_LEN2} LockFlag=LockSame SegmentLength=${5}
33&{LOCKSAME_INVALID_LEN_STR} LockFlag=LockSame SegmentLength=2
34&{LOCKSAME_INVALID_LEN_NEG} LockFlag=LockSame SegmentLength=${-3}
35&{LOCKSAME_INVALID_LEN_BOOL} Lock=LockSame SegmentLength=${True}
36
37&{DONTLOCK_LEN1} LockFlag=DontLock SegmentLength=${1}
38&{DONTLOCK_LEN2} LockFlag=DontLock SegmentLength=${2}
39&{DONTLOCK_LEN3} LockFlag=DontLock SegmentLength=${3}
40&{DONTLOCK_LEN4} LockFlag=DontLock SegmentLength=${4}
41&{DONTLOCK_INVALID_LEN} LockFlag=DontLock SegmentLength=${5}
42&{DONTLOCK_INVALID_LEN_BOOL} LockFlag=DONTLOCK SegmentLength=${False}
43&{DONTLOCK_INVALID_LOCKFLAG} LOCKFLAG=LockAll SegmentLength=${4}
44
45@{ONE_SEG_FLAG_ALL} ${LOCKALL_LEN1}
46@{ONE_SEG_FLAG_SAME} ${LOCKSAME_LEN3}
47@{ONE_SEG_FLAG_DONT} ${DONTLOCK_LEN4}
48
49@{TWO_SEG_FLAG_1} ${LOCKALL_LEN1} ${LOCKSAME_LEN2}
50@{TWO_SEG_FLAG_2} ${DONTLOCK_LEN3} ${LOCKALL_LEN1}
51@{TWO_SEG_FLAG_3} ${DONTLOCK_LEN4} ${LOCKSAME_LEN3}
52@{TWO_SEG_FLAG_4} ${DONTLOCK_INVALID_LEN} ${LOCKSAME_LEN3}
53@{TWO_SEG_FLAG_5} ${DONTLOCK_LEN2} ${LOCKSAME_INVALID_LEN1}
54
55@{TWO_SEG_FLAG_INVALID1} ${DONTLOCK_LEN4} ${LOCKSAME_INVALID_LEN1}
56@{TWO_SEG_FLAG_INVALID2} ${LOCKALL_LEN5} ${DONTLOCK_LEN1}
57@{TWO_SEG_FLAG_INVALID3} ${DONTLOCK_LEN1} ${LOCKALL_INVALID_LOCKFLAG1}
58@{TWO_SEG_FLAG_INVALID4} ${DONTLOCK_LEN2} ${LOCKALL_INVALID_LOCKFLAG2}
59@{TWO_SEG_FLAG_INVALID5} ${DONTLOCK_LEN2} ${LOCKALL_INVALID_LOCKFLAG3}
60@{TWO_SEG_FLAG_INVALID6} ${LOCKALL_LEN3} ${LOCKSAME_INVALID_LOCKFLAG3}
61@{TWO_SEG_FLAG_INVALID7} ${DONTLOCK_LEN2} ${LOCKSAME_INVALID_LOCKFLAG4}
62@{TWO_SEG_FLAG_INVALID8} ${DONTLOCK_INVALID_LOCKFLAG} ${LOCKSAME_INVALID_LEN_BOOL}
63@{TWO_SEG_FLAG_INVALID9} ${DONTLOCK_LEN2} ${LOCKSAME_INVALID_LOCKFLAG4}
64
65@{THREE_SEG_FLAG_1} ${LOCKALL_LEN1} @{TWO_SEG_FLAG_3}
66@{THREE_SEG_FLAG_2} ${LOCKSAME_LEN4} @{TWO_SEG_FLAG_2}
67@{THREE_SEG_FLAG_3} ${DONTLOCK_LEN3} @{TWO_SEG_FLAG_1}
68
69@{FOUR_SEG_FLAG_1} ${LOCKALL_LEN1} @{THREE_SEG_FLAG_2}
70@{FOUR_SEG_FLAG_2} ${LOCKSAME_LEN4} @{THREE_SEG_FLAG_3}
71@{FOUR_SEG_FLAG_3} ${DONTLOCK_LEN3} @{THREE_SEG_FLAG_1}
72
73@{FIVE_SEG_FLAG_1} ${LOCKALL_LEN1} @{FOUR_SEG_FLAG_2}
74@{FIVE_SEG_FLAG_2} ${LOCKSAME_LEN4} @{FOUR_SEG_FLAG_3}
75@{FIVE_SEG_FLAG_3} ${DONTLOCK_LEN3} @{FOUR_SEG_FLAG_1}
76
77@{SIX_SEG_FLAG_1} ${LOCKALL_LEN1} @{FIVE_SEG_FLAG_2}
78@{SIX_SEG_FLAG_2} ${LOCKSAME_LEN4} @{FIVE_SEG_FLAG_3}
79@{SIX_SEG_FLAG_3} ${DONTLOCK_LEN3} @{FIVE_SEG_FLAG_1}
80
81@{SEVEN_SEG_FLAG_1} ${LOCKALL_LEN1} @{SIX_SEG_FLAG_2}
82@{SEVEN_SEG_FLAG_2} ${LOCKSAME_LEN4} @{SIX_SEG_FLAG_3}
83@{SEVEN_SEG_FLAG_3} ${DONTLOCK_LEN3} @{SIX_SEG_FLAG_1}
84
85# Different messages to be verified.
86${PROP_REQ_ERR} is a required property and must be included in the request.
87${PROP_ERR} is not in the list of valid properties for the resource.
88${PROP_TYPE_ERR} is of a different type than the property can accept.
89
90# Build error patterns list.
Vijay355daac2020-03-26 12:06:08 -050091@{EMPTY_LIST}
Vijaybc331e22020-02-27 04:17:37 -060092@{ERR_PATTERN1} ${PROP_REQ_ERR} ${PROP_ERR}
93@{ERR_PATTERN2} ${PROP_TYPE_ERR}
94@{ERR_PATTERN3} ${PROP_REQ_ERR} ${PROP_ERR} ${PROP_TYPE_ERR}
95
96# Dictionary of Locks with Transaction ID as key and Session ID as a value.
97&{LOCKS}
98
99
100*** Test Cases ***
101
102Acquire And Release Different Read Locks
103 [Documentation] Acquire and release different read locks.
104 [Tags] Acquire_And_Release_Different_Read_Locks
105 [Template] Acquire And Release Lock
106
107 # lock seg_flags resource_id hmc_id exp_status_code err_msgs new_sess
108 # type req
Vijay355daac2020-03-26 12:06:08 -0500109 Read ${ONE_SEG_FLAG_ALL} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
110 Read ${ONE_SEG_FLAG_SAME} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
111 Read ${ONE_SEG_FLAG_DONT} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
Vijay149ba762020-04-08 03:38:04 -0500112 Read ${TWO_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
Vijay355daac2020-03-26 12:06:08 -0500113 Read ${TWO_SEG_FLAG_2} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True}
114 Read ${TWO_SEG_FLAG_3} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True}
115 Read ${TWO_SEG_FLAG_4} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
116 Read ${TWO_SEG_FLAG_5} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
Vijay149ba762020-04-08 03:38:04 -0500117 Read ${THREE_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
118 Read ${THREE_SEG_FLAG_2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
119 Read ${THREE_SEG_FLAG_3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
120 Read ${FOUR_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
121 Read ${FOUR_SEG_FLAG_2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
122 Read ${FOUR_SEG_FLAG_3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
123 Read ${FIVE_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
124 Read ${FIVE_SEG_FLAG_2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
125 Read ${FIVE_SEG_FLAG_3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
126 Read ${SIX_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
127 Read ${SIX_SEG_FLAG_2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
128 Read ${SIX_SEG_FLAG_3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
Vijay355daac2020-03-26 12:06:08 -0500129 Read ${SEVEN_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
130 Read ${SEVEN_SEG_FLAG_2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
131 Read ${SEVEN_SEG_FLAG_3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
132 Read ${LOCKSAME_INVALID_LEN1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
Vijaybc331e22020-02-27 04:17:37 -0600133 Read ${LOCKSAME_INVALID_LEN_STR} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN2} ${True}
134 Read ${LOCKSAME_INVALID_LEN_NEG} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN2} ${True}
135 Read ${LOCKSAME_INVALID_LEN_BOOL} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN2} ${True}
136 Read ${DONTLOCK_INVALID_LEN_BOOL} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN2} ${True}
Vijay355daac2020-03-26 12:06:08 -0500137 Read ${TWO_SEG_FLAG_INVALID1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
138 Read ${TWO_SEG_FLAG_INVALID2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
139 Read ${TWO_SEG_FLAG_INVALID3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
140 Read ${TWO_SEG_FLAG_INVALID4} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
Vijaybc331e22020-02-27 04:17:37 -0600141 Read ${TWO_SEG_FLAG_INVALID5} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN1} ${True}
142 Read ${TWO_SEG_FLAG_INVALID6} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN1} ${True}
143 Read ${TWO_SEG_FLAG_INVALID7} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN3} ${True}
144 Read ${TWO_SEG_FLAG_INVALID8} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN1} ${True}
145 Read ${TWO_SEG_FLAG_INVALID9} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN2} ${True}
146 Read ${TWO_SEG_FLAG_3} 234 hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN2} ${True}
147
148
149Acquire And Release Different Write Locks
150 [Documentation] Acquire and release different write locks.
151 [Tags] Acquire_And_Release_Different_Write_Locks
152 [Template] Acquire And Release Lock
153
154 # lock seg_flags resource_id hmc_id exp_status_code err_msgs new_sess
155 # type req
Vijay355daac2020-03-26 12:06:08 -0500156 Write ${ONE_SEG_FLAG_ALL} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
157 Write ${ONE_SEG_FLAG_SAME} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
158 Write ${ONE_SEG_FLAG_DONT} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
159 Write ${TWO_SEG_FLAG_1} ${234} hmc-id ${HTTP_CONFLICT} ${EMPTY_LIST} ${True}
160 Write ${TWO_SEG_FLAG_2} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True}
161 Write ${TWO_SEG_FLAG_3} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True}
162 Write ${TWO_SEG_FLAG_INVALID4} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
163 Write ${THREE_SEG_FLAG_1} ${234} hmc-id ${HTTP_CONFLICT} ${EMPTY_LIST} ${True}
164 Write ${THREE_SEG_FLAG_2} ${234} hmc-id ${HTTP_CONFLICT} ${EMPTY_LIST} ${True}
165 Write ${THREE_SEG_FLAG_3} ${234} hmc-id ${HTTP_CONFLICT} ${EMPTY_LIST} ${True}
166 Write ${FOUR_SEG_FLAG_1} ${234} hmc-id ${HTTP_CONFLICT} ${EMPTY_LIST} ${True}
167 Write ${FOUR_SEG_FLAG_2} ${234} hmc-id ${HTTP_CONFLICT} ${EMPTY_LIST} ${True}
168 Write ${FOUR_SEG_FLAG_3} ${234} hmc-id ${HTTP_CONFLICT} ${EMPTY_LIST} ${True}
169 Write ${FIVE_SEG_FLAG_1} ${234} hmc-id ${HTTP_CONFLICT} ${EMPTY_LIST} ${True}
170 Write ${FIVE_SEG_FLAG_2} ${234} hmc-id ${HTTP_CONFLICT} ${EMPTY_LIST} ${True}
171 Write ${FIVE_SEG_FLAG_3} ${234} hmc-id ${HTTP_CONFLICT} ${EMPTY_LIST} ${True}
172 Write ${SIX_SEG_FLAG_1} ${234} hmc-id ${HTTP_CONFLICT} ${EMPTY_LIST} ${True}
173 Write ${SIX_SEG_FLAG_2} ${234} hmc-id ${HTTP_CONFLICT} ${EMPTY_LIST} ${True}
174 Write ${SIX_SEG_FLAG_3} ${234} hmc-id ${HTTP_CONFLICT} ${EMPTY_LIST} ${True}
175 Write ${SEVEN_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
176 Write ${SEVEN_SEG_FLAG_2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
177 Write ${SEVEN_SEG_FLAG_3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
178 Write ${LOCKSAME_INVALID_LEN1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
179 Write ${LOCKSAME_INVALID_LEN_STR} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
180 Write ${LOCKSAME_INVALID_LEN_NEG} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
181 Write ${LOCKSAME_INVALID_LEN_BOOL} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
182 Write ${DONTLOCK_INVALID_LEN_BOOL} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
183 Write ${TWO_SEG_FLAG_INVALID1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
184 Write ${TWO_SEG_FLAG_INVALID2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True}
Vijaybc331e22020-02-27 04:17:37 -0600185 Write ${TWO_SEG_FLAG_INVALID8} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN1} ${True}
186 Write ${TWO_SEG_FLAG_INVALID5} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN1} ${True}
187 Write ${TWO_SEG_FLAG_INVALID9} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN2} ${True}
188 Write ${TWO_SEG_FLAG_3} 234 hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN2} ${True}
189
190
191Verify GetLockList Returns An Empty Record For An Invalid Session Id
192 [Documentation] Verify GetLockList returns an empty record for an invalid session id.
193 [Tags] Verify_GetLockList_Returns_An_Empty_Record_For_An_Invalid_Session_Id
194
195 ${session_location}= Redfish.Get Session Location
196 ${session_id}= Evaluate os.path.basename($session_location) modules=os
197
198 ${records}= Run Keyword Get Locks List ${session_id}
199 ${records}= Run Keyword Get Locks List ZZzZZz9zzZ
200 ${length}= Get Length ${records}
201 Should Be Equal ${length} ${0}
202
203
Vijay355daac2020-03-26 12:06:08 -0500204Verify Lock Conflicts
205 [Documentation] Verify lock conflicts.
206 [Tags] Verify_Lock_Conflicts
207 [Template] Acquire And Release Lock
208
209 Write ${TWO_SEG_FLAG_2} ${234} hmc-id ${HTTP_OK} ['NA'] ${True}
210 Read ${TWO_SEG_FLAG_2} ${234} hmc-id ${HTTP_CONFLICT} ['NA'] ${False}
211 Read ${TWO_SEG_FLAG_2} ${234} hmc-id ${HTTP_OK} ['NA'] ${True}
212 Write ${TWO_SEG_FLAG_2} ${234} hmc-id ${HTTP_CONFLICT} ['NA'] ${False}
213 Write ${TWO_SEG_FLAG_2} ${234} hmc-id ${HTTP_OK} ['NA'] ${True}
214 Write ${TWO_SEG_FLAG_2} ${234} hmc-id ${HTTP_CONFLICT} ['NA'] ${False}
215
216
Vijay85610ee2020-04-03 05:30:28 -0500217Verify Persistency Of Locks After BMC Reboot
218 [Documentation] Verify persistency of locks after BMC reboot.
219 [Tags] Verify_Persistency_Of_Locks_After_BMC_Reboot
220 [Template] Locks Persistency Check After BMC Reboot
221
222 # lock_type seg_flags resource_id
223 Read ${TWO_SEG_FLAG_2} ${234}
224 Write ${TWO_SEG_FLAG_2} ${234}
225
226
Vijaybc331e22020-02-27 04:17:37 -0600227*** Keywords ***
228
Vijay85610ee2020-04-03 05:30:28 -0500229Locks Persistency Check After BMC Reboot
230 [Documentation] Locks persistency check after BMC reboot.
231 [Arguments] ${lock_type} ${seg_flags} ${resource_id}
232
233 # Description of argument(s):
234 # lock_type Type of lock (Read/Write).
235 # seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy.
236 # resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc.
237
238 ${transaction_id}= Run Keyword Acquire Lock On A Given Resource
239 ... ${lock_type} ${seg_flags} ${resource_id}
240
241 ${locks_prev}= Run Keyword Get Locks List ${SESSION_ID}
242
243 Initialize OpenBMC
244 OBMC Reboot (off)
245
246 ${locks_curr}= Run Keyword Get Locks List ${SESSION_ID}
247 Should Be Equal ${locks_prev} ${locks_curr}
248 Release Lock ${transaction_id}
249
250
Vijaybc331e22020-02-27 04:17:37 -0600251Return Data Dictionary For Single Request
252 [Documentation] Return data dictionary for single request.
253 [Arguments] ${lock_type} ${seg_flags} ${resource_id}
254
255 # Description of argument(s):
256 # lock_type Type of lock (Read/Write).
257 # seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy.
258 # resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc.
259
260 ${SEG_FLAGS_LOCK}= Create Dictionary LockType=${lock_type} SegmentFlags=@{seg_flags}
261 ... ResourceID=${resource_id}
262 ${SEG_FLAGS_ENTRIES}= Create List ${SEG_FLAGS_LOCK}
263 ${LOCK_REQUEST}= Create Dictionary Request=${SEG_FLAGS_ENTRIES}
264 Log To Console ${LOCK_REQUEST}
265
266 [Return] ${LOCK_REQUEST}
267
268
269Acquire Lock On A Given Resource
270 [Documentation] Acquire lock on a given resource.
271 [Arguments] ${lock_type} ${seg_flags} ${resource_id} ${exp_status_code}=${HTTP_OK}
Vijay355daac2020-03-26 12:06:08 -0500272 ... ${err_msgs}=${EMPTY_LIST}
Vijaybc331e22020-02-27 04:17:37 -0600273
274 # Description of argument(s):
275 # lock_type Type of lock (Read/Write).
276 # seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy.
277 # Ex: [{'LockFlag': 'LockAll', 'SegmentLength': 1},
Vijay355daac2020-03-26 12:06:08 -0500278 # {'LockFlag': 'LockSame', 'SegmentLength': 2}]
Vijaybc331e22020-02-27 04:17:37 -0600279 # resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc.
Vijay355daac2020-03-26 12:06:08 -0500280 # exp_status_code Expected status code from the AcquireLock request for given inputs.
281 # err_msgs List of expected error messages.
Vijaybc331e22020-02-27 04:17:37 -0600282
283 ${data}= Return Data Dictionary For Single Request ${lock_type} ${seg_flags} ${resource_id}
284 ${resp}= Redfish.Post /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock
285 ... body=${data} valid_status_codes=[${exp_status_code}]
286
Vijaybc331e22020-02-27 04:17:37 -0600287 ${transaction_id}= Run Keyword If ${exp_status_code} != ${HTTP_OK}
288 ... Set Variable ${0}
289 ... ELSE Load Lock Record And Build Transaction To Session Map ${resp.text}
290
Vijay355daac2020-03-26 12:06:08 -0500291 Run Keyword If ${exp_status_code} == ${HTTP_CONFLICT} and ${err_msgs} == ['NA']
292 ... Load Response And Verify Conflict ${resp.text} ${SESSION_ID}
293 ... ELSE Run Keyword If ${exp_status_code} != ${HTTP_OK} and ${err_msgs} != ${EMPTY_LIST}
Vijaybc331e22020-02-27 04:17:37 -0600294 ... Load Response And Verify Error ${resp.text} err_msgs=${err_msgs}
Vijay355daac2020-03-26 12:06:08 -0500295
Vijaybc331e22020-02-27 04:17:37 -0600296 Append Transaction Id And Session Id To Locks Dictionary ${transaction_id}
297
298 [Return] ${transaction_id}
299
300
301Load Lock Record And Build Transaction To Session Map
302 [Documentation] Load lock record and build transaction to session map.
303 [Arguments] ${resp_text}
304
305 # Description of argument(s):
306 # resp_text Response test from a REST request.
307
308 ${acquire_lock}= Evaluate json.loads('''${resp_text}''') json
309 Append Transaction Id And Session Id To Locks Dictionary ${acquire_lock["TransactionID"]}
310
311 [Return] ${acquire_lock["TransactionID"]}
312
313
314Load Response And Verify Error
315 [Documentation] Load response and verify error.
Vijay355daac2020-03-26 12:06:08 -0500316 [Arguments] ${error_resp} ${err_msgs}=${EMPTY_LIST}
Vijaybc331e22020-02-27 04:17:37 -0600317
318 # Description of argument(s):
319 # error_resp Error response from a REST request.
320 # err_msgs List of error msg patterns.
321
322 ${error_resp}= Replace String ${error_resp} \" \\"
323 ${error_response}= Evaluate json.loads('''${error_resp}''') json
324
325 ${errors}= Get Dictionary Values ${error_response}
326 ${extended_errors}= Create List
327
328 FOR ${error} IN @{errors}
329 Append To List ${extended_errors} ${error[0]["Message"]}
330 END
331
332 Log To Console EXTENDED = ${extended_errors}
333
334 FOR ${exp_error} IN @{err_msgs}
335 Run Keyword Expect List Of Errors In An Extended Errors ${exp_error} ${extended_errors}
336 END
337
338
339Expect List Of Errors In An Extended Errors
340 [Documentation] Expect list of errors in an extended errors.
Vijay355daac2020-03-26 12:06:08 -0500341 [Arguments] ${exp_error} ${extended_errors}=${EMPTY_LIST}
Vijaybc331e22020-02-27 04:17:37 -0600342
343 ${found}= Set Variable ${False}
344
345 FOR ${error_record} IN @{extended_errors}
346 ${found}= Evaluate '${exp_error}' in '${error_record}'
347 Exit For Loop If ${found} == ${True}
348 END
349
350 Should Be True ${found}
351
352
353Append Transaction Id And Session Id To Locks Dictionary
354 [Documentation] Append transaction id and session id to locks dictionary.
355 [Arguments] ${transaction_id}
356
357 # Description of argument(s):
358 # transaction_id Transaction ID created from acquire lock request. Ex: 8, 9 etc.
359
Vijaybc331e22020-02-27 04:17:37 -0600360 Set To Dictionary ${LOCKS} ${${transaction_id}} ${session_id}
Vijaybc331e22020-02-27 04:17:37 -0600361
362
363Get Locks List
364 [Documentation] Get locks list.
365 [Arguments] @{sessions} ${exp_status_code}=${HTTP_OK}
366
367 # Description of argument(s):
368 # sessions List of comma separated strings. Ex: ["euHoAQpvNe", "ecTjANqwFr"]
369 # exp_status_code expected status code from the GetLockList request for given inputs.
370
371 ${sessions}= Evaluate json.dumps(${sessions}) json
372 ${data}= Set Variable {"SessionIDs": ${sessions}}
373 ${resp}= Redfish.Post /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
374 ... body=${data} valid_status_codes=[${exp_status_code}]
375
376 ${locks}= Evaluate json.loads('''${resp.text}''') json
377
378 [Return] ${locks["Records"]}
379
380
381Release Lock
382 [Documentation] Release lock.
383 [Arguments] @{transaction_ids} ${release_type}=Transaction ${exp_status_code}=${HTTP_OK}
384
385 # Description of argument(s):
386 # transaction_ids List of transaction ids. Ex: [15, 18]
387 # release_type Release all locks acquired using current session or only given transaction numbers.
388 # Ex: Session, Transaction. Default will be Transaction.
389 # exp_status_code expected status code from the ReleaseLock request for given inputs.
390
391 ${data}= Set Variable {"Type": "${release_type}", "TransactionIDs": ${transaction_ids}}
392 ${data}= Evaluate json.dumps(${data}) json
393 Redfish.Post /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock
394 ... body=${data} valid_status_codes=[${exp_status_code}]
395
396
397Verify Lock Record
398 [Documentation] Verify lock record.
399 [Arguments] ${lock_found} &{lock_records}
400
401 # Description of argument(s):
402 # lock_found True if lock record is expected to be present, else False.
403 # lock_records A dictionary containing key value pairs of a lock record.
404
405 ${session}= Get From Dictionary ${LOCKS} ${lock_records["TransactionID"]}
406 ${locks}= Run Keyword Get Locks List ${session}
407
408 ${lock_record_found}= Set Variable ${False}
409
410 FOR ${record} IN @{locks}
411 ${record}= Evaluate json.dumps(${record}) json
412 ${record}= Evaluate json.loads('''${record}''') json
413 ${lock_record_found}= Set Variable If ${record["TransactionID"]} == ${lock_records["TransactionID"]}
414 ... ${True} ${False}
415
416 Continue For Loop If ${lock_record_found} == ${False}
417 Dictionaries Should Be Equal ${record} ${lock_records}
418 Exit For Loop
419 END
420
421 Should Be Equal ${lock_record_found} ${lock_found}
422
423
Vijay355daac2020-03-26 12:06:08 -0500424Load Response And Verify Conflict
425 [Documentation] Load response and verify conflict.
426 [Arguments] ${conflict_resp} ${sessions}
427
428 # Description of argument(s):
429 # conflict_resp Conflict response from a REST request.
430 # Example : { "Record": { "HMCID": "hmc-id", "LockType": "Write", "ResourceID": 234,
431 # "SegmentFlags": [ { "LockFlag": "DontLock", "SegmentLength": 3},
432 # { "LockFlag": "LockAll", "SegmentLength": 1}],
433 # "SessionID": "B6geYEdo6T", "TransactionID": 104 } }
434 # sessions Comma separated list of sessions
435
436 ${curr_locks}= Run Keyword Get Locks List ${sessions}
437 ${conflict_resp}= Replace String ${conflict_resp} \" \\"
438 ${conflict_response}= Evaluate json.loads('''${conflict_resp}''') json
439
440 ${conflicts}= Get Dictionary Values ${conflict_response}
441 List Should Contain Value ${conflicts} ${PREV_INPUTS}
442
443
Vijaybc331e22020-02-27 04:17:37 -0600444Acquire And Release Lock
445 [Documentation] Acquire and release lock.
446 [Arguments] ${lock_type} ${seg_flags} ${resource_id} ${hmc_id} ${exp_status_code}=${HTTP_OK}
Vijay355daac2020-03-26 12:06:08 -0500447 ... ${err_msgs}=${EMPTY_LIST} ${new_sess_req}=${True}
Vijaybc331e22020-02-27 04:17:37 -0600448
449 # Description of argument(s):
450 # lock_type Type of lock (Read/Write).
451 # seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy.
452 # Ex: [{'LockFlag': 'LockAll', 'SegmentLength': 1},
453 # {'LockFlag': 'LockSame', 'SegmentLength': 2}]
454 # resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc.
455 # hmc_id Hardware management console id.
456 # exp_status_code Expected status code from the AcquireLock request for given inputs.
Vijay355daac2020-03-26 12:06:08 -0500457 # err_msgs List of expected error messages.
458 # new_sess_req Create a new session before acquiring a lock if True.
Vijaybc331e22020-02-27 04:17:37 -0600459
460 # Get REST session to BMC.
461 Run Keyword If ${new_sess_req} == ${True} Create New Session
462
463 ${inputs}= Create Dictionary LockType=${lock_type} ResourceID=${resource_id}
464 ... SegmentFlags=${seg_flags} HMCID=${hmc_id}
465
466 ${transaction_id}= Run Keyword Acquire Lock On A Given Resource ${inputs["LockType"]}
467 ... ${inputs["SegmentFlags"]} ${inputs["ResourceID"]} ${exp_status_code} err_msgs=${err_msgs}
468
Vijay355daac2020-03-26 12:06:08 -0500469 # Each lock request from a new session is saved so that for next lock request using same session
470 # can refer to previous lock data to verify conflict records if any.
471 Run Keyword If ${new_sess_req} == ${True} Set Test Variable Dictionary Of Previous Lock Request
472 ... ${lock_type} ${seg_flags} ${resource_id} ${hmc_id} ${SESSION_ID} ${transaction_id}
Vijaybc331e22020-02-27 04:17:37 -0600473
Vijay355daac2020-03-26 12:06:08 -0500474 ${session}= Get From Dictionary ${LOCKS} ${transaction_id}
Vijaybc331e22020-02-27 04:17:37 -0600475 Set To Dictionary ${inputs} TransactionID=${${transaction_id}} SessionID=${session}
Vijay355daac2020-03-26 12:06:08 -0500476
Vijaybc331e22020-02-27 04:17:37 -0600477 ${lock_found}= Set Variable If ${exp_status_code} == ${HTTP_OK} ${True} ${False}
478 Verify Lock Record ${lock_found} &{inputs}
479
Vijay355daac2020-03-26 12:06:08 -0500480 Return From Keyword If '${exp_status_code}' != '${HTTP_OK}' or ${err_msgs} == ['NA']
Vijaybc331e22020-02-27 04:17:37 -0600481
482 Release Lock ${transaction_id}
Vijaybc331e22020-02-27 04:17:37 -0600483 Verify Lock Record ${False} &{inputs}
484
485 # Delete the session.
486 Redfish.Logout
487
488
489Create New Session
490 [Documentation] Create new session.
491
Vijay355daac2020-03-26 12:06:08 -0500492 # Delete current session.
Vijaybc331e22020-02-27 04:17:37 -0600493 Redfish.Logout
494
495 # Get a redfish session to BMC.
496 Redfish.Login
Vijay355daac2020-03-26 12:06:08 -0500497 ${session_id} ${session_key}= Return Session Id And Session Key
498 Set Test Variable ${SESSION_ID} ${session_id}
499 Set Test Variable ${SESSION_KEY} ${session_key}
Vijaybc331e22020-02-27 04:17:37 -0600500
501
502Test Teardown Execution
503 [Documentation] Test teardown execution.
504
505 FFDC On Test Case Fail
506 Redfish.Logout
507
Vijay355daac2020-03-26 12:06:08 -0500508
509Return Session Id And Session Key
510 [Documentation] Return session id and sesion key.
511
512 ${session_location}= Redfish.Get Session Location
513 ${session_id}= Evaluate os.path.basename($session_location) modules=os
514 ${session_key}= Redfish.Get Session Key
515
516 [Return] ${session_id} ${session_key}
517
518
519Test Setup Execution
520 [Documentation] Test setup execution.
521
522 Create New Session
523
524 Set Test Variable Dictionary Of Previous Lock Request ${EMPTY} ${EMPTY_LIST} ${EMPTY} ${EMPTY}
525 ... ${EMPTY} ${EMPTY}
526
527
528Set Test Variable Dictionary Of Previous Lock Request
529 [Documentation] Set test variable dictionary of previous lock request.
530 [Arguments] ${lock_type} ${seg_flags} ${resource_id} ${hmc_id} ${session_id} ${transaction_id}
531
532 # Description of argument(s):
533 # lock_type Type of lock (Read/Write).
534 # seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy.
535 # Ex: [{'LockFlag': 'LockAll', 'SegmentLength': 1},
536 # {'LockFlag': 'LockSame', 'SegmentLength': 2}]
537 # resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc.
538 # hmc_id Hardware management console id.
539 # session_id Session id of the transaction.
540 # transaction_id Transaction_id of the lock request.
541
542 ${prev_inputs}= Create Dictionary LockType=${lock_type} ResourceID=${resource_id}
543 ... SegmentFlags=${seg_flags} HMCID=${hmc_id} SessionID=${session_id} TransactionID=${transaction_id}
544
545 Set Test Variable ${PREV_INPUTS} ${prev_inputs}