blob: 0023f519b7f6735ae3b959aa1e8da6e640958c6b [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}
112 Read ${TWO_SEG_FLAG_1} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True}
113 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}
117 Read ${THREE_SEG_FLAG_1} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True}
118 Read ${THREE_SEG_FLAG_2} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True}
119 Read ${THREE_SEG_FLAG_3} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True}
120 Read ${FOUR_SEG_FLAG_1} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True}
121 Read ${FOUR_SEG_FLAG_2} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True}
122 Read ${FOUR_SEG_FLAG_3} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True}
123 Read ${FIVE_SEG_FLAG_1} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True}
124 Read ${FIVE_SEG_FLAG_2} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True}
125 Read ${FIVE_SEG_FLAG_3} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True}
126 Read ${SIX_SEG_FLAG_1} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True}
127 Read ${SIX_SEG_FLAG_2} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True}
128 Read ${SIX_SEG_FLAG_3} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True}
129 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
Vijaybc331e22020-02-27 04:17:37 -0600217*** Keywords ***
218
219Return Data Dictionary For Single Request
220 [Documentation] Return data dictionary for single request.
221 [Arguments] ${lock_type} ${seg_flags} ${resource_id}
222
223 # Description of argument(s):
224 # lock_type Type of lock (Read/Write).
225 # seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy.
226 # resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc.
227
228 ${SEG_FLAGS_LOCK}= Create Dictionary LockType=${lock_type} SegmentFlags=@{seg_flags}
229 ... ResourceID=${resource_id}
230 ${SEG_FLAGS_ENTRIES}= Create List ${SEG_FLAGS_LOCK}
231 ${LOCK_REQUEST}= Create Dictionary Request=${SEG_FLAGS_ENTRIES}
232 Log To Console ${LOCK_REQUEST}
233
234 [Return] ${LOCK_REQUEST}
235
236
237Acquire Lock On A Given Resource
238 [Documentation] Acquire lock on a given resource.
239 [Arguments] ${lock_type} ${seg_flags} ${resource_id} ${exp_status_code}=${HTTP_OK}
Vijay355daac2020-03-26 12:06:08 -0500240 ... ${err_msgs}=${EMPTY_LIST}
Vijaybc331e22020-02-27 04:17:37 -0600241
242 # Description of argument(s):
243 # lock_type Type of lock (Read/Write).
244 # seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy.
245 # Ex: [{'LockFlag': 'LockAll', 'SegmentLength': 1},
Vijay355daac2020-03-26 12:06:08 -0500246 # {'LockFlag': 'LockSame', 'SegmentLength': 2}]
Vijaybc331e22020-02-27 04:17:37 -0600247 # resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc.
Vijay355daac2020-03-26 12:06:08 -0500248 # exp_status_code Expected status code from the AcquireLock request for given inputs.
249 # err_msgs List of expected error messages.
Vijaybc331e22020-02-27 04:17:37 -0600250
251 ${data}= Return Data Dictionary For Single Request ${lock_type} ${seg_flags} ${resource_id}
252 ${resp}= Redfish.Post /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock
253 ... body=${data} valid_status_codes=[${exp_status_code}]
254
Vijaybc331e22020-02-27 04:17:37 -0600255 ${transaction_id}= Run Keyword If ${exp_status_code} != ${HTTP_OK}
256 ... Set Variable ${0}
257 ... ELSE Load Lock Record And Build Transaction To Session Map ${resp.text}
258
Vijay355daac2020-03-26 12:06:08 -0500259 Run Keyword If ${exp_status_code} == ${HTTP_CONFLICT} and ${err_msgs} == ['NA']
260 ... Load Response And Verify Conflict ${resp.text} ${SESSION_ID}
261 ... ELSE Run Keyword If ${exp_status_code} != ${HTTP_OK} and ${err_msgs} != ${EMPTY_LIST}
Vijaybc331e22020-02-27 04:17:37 -0600262 ... Load Response And Verify Error ${resp.text} err_msgs=${err_msgs}
Vijay355daac2020-03-26 12:06:08 -0500263
Vijaybc331e22020-02-27 04:17:37 -0600264 Append Transaction Id And Session Id To Locks Dictionary ${transaction_id}
265
266 [Return] ${transaction_id}
267
268
269Load Lock Record And Build Transaction To Session Map
270 [Documentation] Load lock record and build transaction to session map.
271 [Arguments] ${resp_text}
272
273 # Description of argument(s):
274 # resp_text Response test from a REST request.
275
276 ${acquire_lock}= Evaluate json.loads('''${resp_text}''') json
277 Append Transaction Id And Session Id To Locks Dictionary ${acquire_lock["TransactionID"]}
278
279 [Return] ${acquire_lock["TransactionID"]}
280
281
282Load Response And Verify Error
283 [Documentation] Load response and verify error.
Vijay355daac2020-03-26 12:06:08 -0500284 [Arguments] ${error_resp} ${err_msgs}=${EMPTY_LIST}
Vijaybc331e22020-02-27 04:17:37 -0600285
286 # Description of argument(s):
287 # error_resp Error response from a REST request.
288 # err_msgs List of error msg patterns.
289
290 ${error_resp}= Replace String ${error_resp} \" \\"
291 ${error_response}= Evaluate json.loads('''${error_resp}''') json
292
293 ${errors}= Get Dictionary Values ${error_response}
294 ${extended_errors}= Create List
295
296 FOR ${error} IN @{errors}
297 Append To List ${extended_errors} ${error[0]["Message"]}
298 END
299
300 Log To Console EXTENDED = ${extended_errors}
301
302 FOR ${exp_error} IN @{err_msgs}
303 Run Keyword Expect List Of Errors In An Extended Errors ${exp_error} ${extended_errors}
304 END
305
306
307Expect List Of Errors In An Extended Errors
308 [Documentation] Expect list of errors in an extended errors.
Vijay355daac2020-03-26 12:06:08 -0500309 [Arguments] ${exp_error} ${extended_errors}=${EMPTY_LIST}
Vijaybc331e22020-02-27 04:17:37 -0600310
311 ${found}= Set Variable ${False}
312
313 FOR ${error_record} IN @{extended_errors}
314 ${found}= Evaluate '${exp_error}' in '${error_record}'
315 Exit For Loop If ${found} == ${True}
316 END
317
318 Should Be True ${found}
319
320
321Append Transaction Id And Session Id To Locks Dictionary
322 [Documentation] Append transaction id and session id to locks dictionary.
323 [Arguments] ${transaction_id}
324
325 # Description of argument(s):
326 # transaction_id Transaction ID created from acquire lock request. Ex: 8, 9 etc.
327
Vijaybc331e22020-02-27 04:17:37 -0600328 Set To Dictionary ${LOCKS} ${${transaction_id}} ${session_id}
Vijaybc331e22020-02-27 04:17:37 -0600329
330
331Get Locks List
332 [Documentation] Get locks list.
333 [Arguments] @{sessions} ${exp_status_code}=${HTTP_OK}
334
335 # Description of argument(s):
336 # sessions List of comma separated strings. Ex: ["euHoAQpvNe", "ecTjANqwFr"]
337 # exp_status_code expected status code from the GetLockList request for given inputs.
338
339 ${sessions}= Evaluate json.dumps(${sessions}) json
340 ${data}= Set Variable {"SessionIDs": ${sessions}}
341 ${resp}= Redfish.Post /ibm/v1/HMC/LockService/Actions/LockService.GetLockList
342 ... body=${data} valid_status_codes=[${exp_status_code}]
343
344 ${locks}= Evaluate json.loads('''${resp.text}''') json
345
346 [Return] ${locks["Records"]}
347
348
349Release Lock
350 [Documentation] Release lock.
351 [Arguments] @{transaction_ids} ${release_type}=Transaction ${exp_status_code}=${HTTP_OK}
352
353 # Description of argument(s):
354 # transaction_ids List of transaction ids. Ex: [15, 18]
355 # release_type Release all locks acquired using current session or only given transaction numbers.
356 # Ex: Session, Transaction. Default will be Transaction.
357 # exp_status_code expected status code from the ReleaseLock request for given inputs.
358
359 ${data}= Set Variable {"Type": "${release_type}", "TransactionIDs": ${transaction_ids}}
360 ${data}= Evaluate json.dumps(${data}) json
361 Redfish.Post /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock
362 ... body=${data} valid_status_codes=[${exp_status_code}]
363
364
365Verify Lock Record
366 [Documentation] Verify lock record.
367 [Arguments] ${lock_found} &{lock_records}
368
369 # Description of argument(s):
370 # lock_found True if lock record is expected to be present, else False.
371 # lock_records A dictionary containing key value pairs of a lock record.
372
373 ${session}= Get From Dictionary ${LOCKS} ${lock_records["TransactionID"]}
374 ${locks}= Run Keyword Get Locks List ${session}
375
376 ${lock_record_found}= Set Variable ${False}
377
378 FOR ${record} IN @{locks}
379 ${record}= Evaluate json.dumps(${record}) json
380 ${record}= Evaluate json.loads('''${record}''') json
381 ${lock_record_found}= Set Variable If ${record["TransactionID"]} == ${lock_records["TransactionID"]}
382 ... ${True} ${False}
383
384 Continue For Loop If ${lock_record_found} == ${False}
385 Dictionaries Should Be Equal ${record} ${lock_records}
386 Exit For Loop
387 END
388
389 Should Be Equal ${lock_record_found} ${lock_found}
390
391
Vijay355daac2020-03-26 12:06:08 -0500392Load Response And Verify Conflict
393 [Documentation] Load response and verify conflict.
394 [Arguments] ${conflict_resp} ${sessions}
395
396 # Description of argument(s):
397 # conflict_resp Conflict response from a REST request.
398 # Example : { "Record": { "HMCID": "hmc-id", "LockType": "Write", "ResourceID": 234,
399 # "SegmentFlags": [ { "LockFlag": "DontLock", "SegmentLength": 3},
400 # { "LockFlag": "LockAll", "SegmentLength": 1}],
401 # "SessionID": "B6geYEdo6T", "TransactionID": 104 } }
402 # sessions Comma separated list of sessions
403
404 ${curr_locks}= Run Keyword Get Locks List ${sessions}
405 ${conflict_resp}= Replace String ${conflict_resp} \" \\"
406 ${conflict_response}= Evaluate json.loads('''${conflict_resp}''') json
407
408 ${conflicts}= Get Dictionary Values ${conflict_response}
409 List Should Contain Value ${conflicts} ${PREV_INPUTS}
410
411
Vijaybc331e22020-02-27 04:17:37 -0600412Acquire And Release Lock
413 [Documentation] Acquire and release lock.
414 [Arguments] ${lock_type} ${seg_flags} ${resource_id} ${hmc_id} ${exp_status_code}=${HTTP_OK}
Vijay355daac2020-03-26 12:06:08 -0500415 ... ${err_msgs}=${EMPTY_LIST} ${new_sess_req}=${True}
Vijaybc331e22020-02-27 04:17:37 -0600416
417 # Description of argument(s):
418 # lock_type Type of lock (Read/Write).
419 # seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy.
420 # Ex: [{'LockFlag': 'LockAll', 'SegmentLength': 1},
421 # {'LockFlag': 'LockSame', 'SegmentLength': 2}]
422 # resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc.
423 # hmc_id Hardware management console id.
424 # exp_status_code Expected status code from the AcquireLock request for given inputs.
Vijay355daac2020-03-26 12:06:08 -0500425 # err_msgs List of expected error messages.
426 # new_sess_req Create a new session before acquiring a lock if True.
Vijaybc331e22020-02-27 04:17:37 -0600427
428 # Get REST session to BMC.
429 Run Keyword If ${new_sess_req} == ${True} Create New Session
430
431 ${inputs}= Create Dictionary LockType=${lock_type} ResourceID=${resource_id}
432 ... SegmentFlags=${seg_flags} HMCID=${hmc_id}
433
434 ${transaction_id}= Run Keyword Acquire Lock On A Given Resource ${inputs["LockType"]}
435 ... ${inputs["SegmentFlags"]} ${inputs["ResourceID"]} ${exp_status_code} err_msgs=${err_msgs}
436
Vijay355daac2020-03-26 12:06:08 -0500437 # Each lock request from a new session is saved so that for next lock request using same session
438 # can refer to previous lock data to verify conflict records if any.
439 Run Keyword If ${new_sess_req} == ${True} Set Test Variable Dictionary Of Previous Lock Request
440 ... ${lock_type} ${seg_flags} ${resource_id} ${hmc_id} ${SESSION_ID} ${transaction_id}
Vijaybc331e22020-02-27 04:17:37 -0600441
Vijay355daac2020-03-26 12:06:08 -0500442 ${session}= Get From Dictionary ${LOCKS} ${transaction_id}
Vijaybc331e22020-02-27 04:17:37 -0600443 Set To Dictionary ${inputs} TransactionID=${${transaction_id}} SessionID=${session}
Vijay355daac2020-03-26 12:06:08 -0500444
Vijaybc331e22020-02-27 04:17:37 -0600445 ${lock_found}= Set Variable If ${exp_status_code} == ${HTTP_OK} ${True} ${False}
446 Verify Lock Record ${lock_found} &{inputs}
447
Vijay355daac2020-03-26 12:06:08 -0500448 Return From Keyword If '${exp_status_code}' != '${HTTP_OK}' or ${err_msgs} == ['NA']
Vijaybc331e22020-02-27 04:17:37 -0600449
450 Release Lock ${transaction_id}
Vijaybc331e22020-02-27 04:17:37 -0600451 Verify Lock Record ${False} &{inputs}
452
453 # Delete the session.
454 Redfish.Logout
455
456
457Create New Session
458 [Documentation] Create new session.
459
Vijay355daac2020-03-26 12:06:08 -0500460 # Delete current session.
Vijaybc331e22020-02-27 04:17:37 -0600461 Redfish.Logout
462
463 # Get a redfish session to BMC.
464 Redfish.Login
Vijay355daac2020-03-26 12:06:08 -0500465 ${session_id} ${session_key}= Return Session Id And Session Key
466 Set Test Variable ${SESSION_ID} ${session_id}
467 Set Test Variable ${SESSION_KEY} ${session_key}
Vijaybc331e22020-02-27 04:17:37 -0600468
469
470Test Teardown Execution
471 [Documentation] Test teardown execution.
472
473 FFDC On Test Case Fail
474 Redfish.Logout
475
Vijay355daac2020-03-26 12:06:08 -0500476
477Return Session Id And Session Key
478 [Documentation] Return session id and sesion key.
479
480 ${session_location}= Redfish.Get Session Location
481 ${session_id}= Evaluate os.path.basename($session_location) modules=os
482 ${session_key}= Redfish.Get Session Key
483
484 [Return] ${session_id} ${session_key}
485
486
487Test Setup Execution
488 [Documentation] Test setup execution.
489
490 Create New Session
491
492 Set Test Variable Dictionary Of Previous Lock Request ${EMPTY} ${EMPTY_LIST} ${EMPTY} ${EMPTY}
493 ... ${EMPTY} ${EMPTY}
494
495
496Set Test Variable Dictionary Of Previous Lock Request
497 [Documentation] Set test variable dictionary of previous lock request.
498 [Arguments] ${lock_type} ${seg_flags} ${resource_id} ${hmc_id} ${session_id} ${transaction_id}
499
500 # Description of argument(s):
501 # lock_type Type of lock (Read/Write).
502 # seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy.
503 # Ex: [{'LockFlag': 'LockAll', 'SegmentLength': 1},
504 # {'LockFlag': 'LockSame', 'SegmentLength': 2}]
505 # resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc.
506 # hmc_id Hardware management console id.
507 # session_id Session id of the transaction.
508 # transaction_id Transaction_id of the lock request.
509
510 ${prev_inputs}= Create Dictionary LockType=${lock_type} ResourceID=${resource_id}
511 ... SegmentFlags=${seg_flags} HMCID=${hmc_id} SessionID=${session_id} TransactionID=${transaction_id}
512
513 Set Test Variable ${PREV_INPUTS} ${prev_inputs}