Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 1 | *** Settings *** |
| 2 | |
| 3 | Documentation Test Lock Management feature of Management Console on BMC. |
| 4 | |
| 5 | Resource ../../lib/resource.robot |
| 6 | Resource ../../lib/bmc_redfish_resource.robot |
| 7 | Resource ../../lib/openbmc_ffdc.robot |
| 8 | |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 9 | Test Setup Test Setup Execution |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 10 | Test 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. |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 91 | @{EMPTY_LIST} |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 92 | @{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 | |
| 102 | Acquire 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 |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 109 | 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} |
Vijay | 149ba76 | 2020-04-08 03:38:04 -0500 | [diff] [blame] | 112 | Read ${TWO_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 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} |
Vijay | 149ba76 | 2020-04-08 03:38:04 -0500 | [diff] [blame] | 117 | 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} |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 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} |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 133 | 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} |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 137 | 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} |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 141 | 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 | |
| 149 | Acquire 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 |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 156 | 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} |
Vijay | 60f01e4 | 2020-04-09 00:50:42 -0500 | [diff] [blame] | 159 | Write ${TWO_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 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} |
Vijay | 60f01e4 | 2020-04-09 00:50:42 -0500 | [diff] [blame] | 163 | Write ${THREE_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} |
| 164 | Write ${THREE_SEG_FLAG_2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} |
| 165 | Write ${THREE_SEG_FLAG_3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} |
| 166 | Write ${FOUR_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} |
| 167 | Write ${FOUR_SEG_FLAG_2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} |
| 168 | Write ${FOUR_SEG_FLAG_3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} |
| 169 | Write ${FIVE_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} |
| 170 | Write ${FIVE_SEG_FLAG_2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} |
| 171 | Write ${FIVE_SEG_FLAG_3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} |
| 172 | Write ${SIX_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} |
| 173 | Write ${SIX_SEG_FLAG_2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} |
| 174 | Write ${SIX_SEG_FLAG_3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 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} |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 185 | 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 | |
| 191 | Verify 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 | |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 204 | Verify 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 | |
Vijay | 85610ee | 2020-04-03 05:30:28 -0500 | [diff] [blame] | 217 | Verify 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 | |
Vijay | afdd2a1 | 2020-04-09 02:03:20 -0500 | [diff] [blame] | 227 | Verify Valid Lock Transactions Release |
| 228 | [Documentation] Verify valid lock transactions release. |
| 229 | [Tags] Verify_Valid_Lock_Transactions_Release |
| 230 | |
| 231 | ${transaction_id1}= Acquire Lock On A Given Resource |
| 232 | ... Read ${TWO_SEG_FLAG_2} ${234} |
| 233 | ${locks_before}= Get Locks List ${SESSION_ID} |
| 234 | |
| 235 | ${transaction_id2}= Acquire Lock On A Given Resource |
| 236 | ... Read ${TWO_SEG_FLAG_3} ${234} |
| 237 | ${transaction_id3}= Acquire Lock On A Given Resource |
| 238 | ... Read ${TWO_SEG_FLAG_2} ${234} |
| 239 | ${transaction_id4}= Acquire Lock On A Given Resource |
| 240 | ... Read ${TWO_SEG_FLAG_3} ${234} |
| 241 | |
| 242 | ${transaction_ids}= Create List ${transaction_id2} ${transaction_id3} ${transaction_id4} |
| 243 | Release Locks ${transaction_ids} |
| 244 | ${locks_after}= Get Locks List ${SESSION_ID} |
| 245 | Should Be Equal ${locks_before} ${locks_after} |
| 246 | |
| 247 | |
| 248 | Verify Invalid Lock Transactions Release |
| 249 | [Documentation] Verify invalid lock transactions release. |
| 250 | [Tags] Verify_Invalid_Lock_Transactions_Release |
| 251 | |
| 252 | ${transaction_id1}= Acquire Lock On A Given Resource |
| 253 | ... Read ${TWO_SEG_FLAG_2} ${234} |
| 254 | ${locks_before}= Get Locks List ${SESSION_ID} |
| 255 | |
| 256 | ${transaction_id2}= Evaluate ${transaction_id1} + 1 |
| 257 | ${transaction_id3}= Evaluate ${transaction_id1} - 1 |
| 258 | ${transaction_ids}= Create List ${transaction_id2} ${transaction_id1} ${transaction_id3} |
| 259 | |
| 260 | # If any transaction/s in the list does not belong to current session then it will be a bad request. |
| 261 | Release Locks ${transaction_ids} exp_status_code=${HTTP_BAD_REQUEST} |
| 262 | ${locks_after}= Get Locks List ${SESSION_ID} |
| 263 | Should Be Equal ${locks_before} ${locks_after} |
| 264 | |
| 265 | |
| 266 | Verify Locks Release By Session |
| 267 | [Documentation] Verify locks release by session. |
| 268 | [Tags] Verify_Locks_Release_By_Session |
| 269 | |
| 270 | ${locks_before}= Get Locks List ${SESSION_ID} |
| 271 | ${transaction_id1}= Acquire Lock On A Given Resource |
| 272 | ... Write ${TWO_SEG_FLAG_2} ${234} |
| 273 | |
| 274 | # Release Lock by Session without mentioning transaction_ids. |
| 275 | Release Locks release_type=Session |
| 276 | ${locks_after}= Get Locks List ${SESSION_ID} |
| 277 | Should Be Equal ${locks_before} ${locks_after} |
| 278 | |
| 279 | ${transaction_id1}= Acquire Lock On A Given Resource |
| 280 | ... Read ${TWO_SEG_FLAG_2} ${234} |
| 281 | ${transaction_id2}= Acquire Lock On A Given Resource |
| 282 | ... Read ${TWO_SEG_FLAG_3} ${234} |
| 283 | ${transaction_ids}= Create List ${transaction_id1} ${transaction_id2} |
| 284 | |
| 285 | # Release Lock by Session by mentioning transaction_ids also in the request. |
| 286 | Release Locks ${transaction_ids} release_type=Session |
| 287 | |
| 288 | |
| 289 | Verify Locks Created By One Session Cannot Be Deleted By Another Session |
| 290 | [Documentation] Verify locks created by one session cannot be deleted by another session. |
| 291 | [Tags] Verify_Locks_Created_By_One_Session_Cannot_Be_Deleted_By_Another_Session |
| 292 | |
| 293 | ${transaction_id1}= Acquire Lock On A Given Resource |
| 294 | ... Read ${TWO_SEG_FLAG_2} ${234} |
| 295 | ${locks_tran1}= Get Locks List ${SESSION_ID} |
| 296 | |
| 297 | Redfish.Login |
| 298 | ${session_id} ${session_key}= Return Session Id And Session Key |
| 299 | |
| 300 | ${transaction_id2}= Acquire Lock On A Given Resource |
| 301 | ... Read ${TWO_SEG_FLAG_3} ${234} |
| 302 | ${locks_before}= Get Locks List ${SESSION_ID} |
| 303 | |
| 304 | ${transaction_ids}= Create List ${transaction_id1} ${transaction_id2} |
| 305 | Release Locks ${transaction_ids} exp_status_code=${HTTP_UNAUTHORIZED} conflict_record=${locks_tran1} |
| 306 | ${locks_after}= Get Locks List ${SESSION_ID} |
| 307 | Should Be Equal ${locks_before} ${locks_after} |
| 308 | |
| 309 | # When release_type=Session, transaction_ids should be ignored. |
| 310 | Release Locks ${transaction_ids} release_type=Session |
| 311 | ${locks_after}= Get Locks List ${SESSION_ID} |
| 312 | Should Be Equal ${EMPTY_LIST} ${locks_after} |
| 313 | |
| 314 | |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 315 | *** Keywords *** |
| 316 | |
Vijay | 85610ee | 2020-04-03 05:30:28 -0500 | [diff] [blame] | 317 | Locks Persistency Check After BMC Reboot |
| 318 | [Documentation] Locks persistency check after BMC reboot. |
| 319 | [Arguments] ${lock_type} ${seg_flags} ${resource_id} |
| 320 | |
| 321 | # Description of argument(s): |
| 322 | # lock_type Type of lock (Read/Write). |
| 323 | # seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy. |
| 324 | # resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc. |
| 325 | |
| 326 | ${transaction_id}= Run Keyword Acquire Lock On A Given Resource |
| 327 | ... ${lock_type} ${seg_flags} ${resource_id} |
| 328 | |
| 329 | ${locks_prev}= Run Keyword Get Locks List ${SESSION_ID} |
| 330 | |
| 331 | Initialize OpenBMC |
| 332 | OBMC Reboot (off) |
| 333 | |
| 334 | ${locks_curr}= Run Keyword Get Locks List ${SESSION_ID} |
| 335 | Should Be Equal ${locks_prev} ${locks_curr} |
Vijay | afdd2a1 | 2020-04-09 02:03:20 -0500 | [diff] [blame] | 336 | ${transaction_ids}= Create List ${transaction_id} |
| 337 | Release Locks ${transaction_ids} |
Vijay | 85610ee | 2020-04-03 05:30:28 -0500 | [diff] [blame] | 338 | |
| 339 | |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 340 | Return Data Dictionary For Single Request |
| 341 | [Documentation] Return data dictionary for single request. |
| 342 | [Arguments] ${lock_type} ${seg_flags} ${resource_id} |
| 343 | |
| 344 | # Description of argument(s): |
| 345 | # lock_type Type of lock (Read/Write). |
| 346 | # seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy. |
| 347 | # resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc. |
| 348 | |
| 349 | ${SEG_FLAGS_LOCK}= Create Dictionary LockType=${lock_type} SegmentFlags=@{seg_flags} |
| 350 | ... ResourceID=${resource_id} |
| 351 | ${SEG_FLAGS_ENTRIES}= Create List ${SEG_FLAGS_LOCK} |
| 352 | ${LOCK_REQUEST}= Create Dictionary Request=${SEG_FLAGS_ENTRIES} |
| 353 | Log To Console ${LOCK_REQUEST} |
| 354 | |
| 355 | [Return] ${LOCK_REQUEST} |
| 356 | |
| 357 | |
| 358 | Acquire Lock On A Given Resource |
| 359 | [Documentation] Acquire lock on a given resource. |
| 360 | [Arguments] ${lock_type} ${seg_flags} ${resource_id} ${exp_status_code}=${HTTP_OK} |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 361 | ... ${err_msgs}=${EMPTY_LIST} |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 362 | |
| 363 | # Description of argument(s): |
| 364 | # lock_type Type of lock (Read/Write). |
| 365 | # seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy. |
| 366 | # Ex: [{'LockFlag': 'LockAll', 'SegmentLength': 1}, |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 367 | # {'LockFlag': 'LockSame', 'SegmentLength': 2}] |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 368 | # resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc. |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 369 | # exp_status_code Expected status code from the AcquireLock request for given inputs. |
| 370 | # err_msgs List of expected error messages. |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 371 | |
| 372 | ${data}= Return Data Dictionary For Single Request ${lock_type} ${seg_flags} ${resource_id} |
| 373 | ${resp}= Redfish.Post /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock |
| 374 | ... body=${data} valid_status_codes=[${exp_status_code}] |
| 375 | |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 376 | ${transaction_id}= Run Keyword If ${exp_status_code} != ${HTTP_OK} |
| 377 | ... Set Variable ${0} |
| 378 | ... ELSE Load Lock Record And Build Transaction To Session Map ${resp.text} |
| 379 | |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 380 | Run Keyword If ${exp_status_code} == ${HTTP_CONFLICT} and ${err_msgs} == ['NA'] |
| 381 | ... Load Response And Verify Conflict ${resp.text} ${SESSION_ID} |
| 382 | ... ELSE Run Keyword If ${exp_status_code} != ${HTTP_OK} and ${err_msgs} != ${EMPTY_LIST} |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 383 | ... Load Response And Verify Error ${resp.text} err_msgs=${err_msgs} |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 384 | |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 385 | Append Transaction Id And Session Id To Locks Dictionary ${transaction_id} |
| 386 | |
| 387 | [Return] ${transaction_id} |
| 388 | |
| 389 | |
| 390 | Load Lock Record And Build Transaction To Session Map |
| 391 | [Documentation] Load lock record and build transaction to session map. |
| 392 | [Arguments] ${resp_text} |
| 393 | |
| 394 | # Description of argument(s): |
| 395 | # resp_text Response test from a REST request. |
| 396 | |
| 397 | ${acquire_lock}= Evaluate json.loads('''${resp_text}''') json |
| 398 | Append Transaction Id And Session Id To Locks Dictionary ${acquire_lock["TransactionID"]} |
| 399 | |
| 400 | [Return] ${acquire_lock["TransactionID"]} |
| 401 | |
| 402 | |
| 403 | Load Response And Verify Error |
| 404 | [Documentation] Load response and verify error. |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 405 | [Arguments] ${error_resp} ${err_msgs}=${EMPTY_LIST} |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 406 | |
| 407 | # Description of argument(s): |
| 408 | # error_resp Error response from a REST request. |
| 409 | # err_msgs List of error msg patterns. |
| 410 | |
| 411 | ${error_resp}= Replace String ${error_resp} \" \\" |
| 412 | ${error_response}= Evaluate json.loads('''${error_resp}''') json |
| 413 | |
| 414 | ${errors}= Get Dictionary Values ${error_response} |
| 415 | ${extended_errors}= Create List |
| 416 | |
| 417 | FOR ${error} IN @{errors} |
| 418 | Append To List ${extended_errors} ${error[0]["Message"]} |
| 419 | END |
| 420 | |
| 421 | Log To Console EXTENDED = ${extended_errors} |
| 422 | |
| 423 | FOR ${exp_error} IN @{err_msgs} |
| 424 | Run Keyword Expect List Of Errors In An Extended Errors ${exp_error} ${extended_errors} |
| 425 | END |
| 426 | |
| 427 | |
| 428 | Expect List Of Errors In An Extended Errors |
| 429 | [Documentation] Expect list of errors in an extended errors. |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 430 | [Arguments] ${exp_error} ${extended_errors}=${EMPTY_LIST} |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 431 | |
| 432 | ${found}= Set Variable ${False} |
| 433 | |
| 434 | FOR ${error_record} IN @{extended_errors} |
| 435 | ${found}= Evaluate '${exp_error}' in '${error_record}' |
| 436 | Exit For Loop If ${found} == ${True} |
| 437 | END |
| 438 | |
| 439 | Should Be True ${found} |
| 440 | |
| 441 | |
| 442 | Append Transaction Id And Session Id To Locks Dictionary |
| 443 | [Documentation] Append transaction id and session id to locks dictionary. |
| 444 | [Arguments] ${transaction_id} |
| 445 | |
| 446 | # Description of argument(s): |
| 447 | # transaction_id Transaction ID created from acquire lock request. Ex: 8, 9 etc. |
| 448 | |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 449 | Set To Dictionary ${LOCKS} ${${transaction_id}} ${session_id} |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 450 | |
| 451 | |
| 452 | Get Locks List |
| 453 | [Documentation] Get locks list. |
| 454 | [Arguments] @{sessions} ${exp_status_code}=${HTTP_OK} |
| 455 | |
| 456 | # Description of argument(s): |
| 457 | # sessions List of comma separated strings. Ex: ["euHoAQpvNe", "ecTjANqwFr"] |
| 458 | # exp_status_code expected status code from the GetLockList request for given inputs. |
| 459 | |
| 460 | ${sessions}= Evaluate json.dumps(${sessions}) json |
| 461 | ${data}= Set Variable {"SessionIDs": ${sessions}} |
| 462 | ${resp}= Redfish.Post /ibm/v1/HMC/LockService/Actions/LockService.GetLockList |
| 463 | ... body=${data} valid_status_codes=[${exp_status_code}] |
| 464 | |
| 465 | ${locks}= Evaluate json.loads('''${resp.text}''') json |
| 466 | |
| 467 | [Return] ${locks["Records"]} |
| 468 | |
| 469 | |
Vijay | afdd2a1 | 2020-04-09 02:03:20 -0500 | [diff] [blame] | 470 | Release Locks |
| 471 | [Documentation] Release locks. |
| 472 | [Arguments] ${transaction_ids}=${EMPTY_LIST} ${release_type}=Transaction ${exp_status_code}=${HTTP_OK} |
| 473 | ... ${conflict_record}=${EMPTY_LIST} |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 474 | |
| 475 | # Description of argument(s): |
Vijay | afdd2a1 | 2020-04-09 02:03:20 -0500 | [diff] [blame] | 476 | # transaction_ids List of transaction ids or session ids. Ex: [15, 18] or ["euHoAQpvNe", "ecTjANqwFr"] |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 477 | # release_type Release all locks acquired using current session or only given transaction numbers. |
| 478 | # Ex: Session, Transaction. Default will be Transaction. |
| 479 | # exp_status_code expected status code from the ReleaseLock request for given inputs. |
Vijay | afdd2a1 | 2020-04-09 02:03:20 -0500 | [diff] [blame] | 480 | # conflict_record Expected conflict record. |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 481 | |
Vijay | afdd2a1 | 2020-04-09 02:03:20 -0500 | [diff] [blame] | 482 | # When release_type=Session then TransactionIDs list will be ignored. |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 483 | ${data}= Set Variable {"Type": "${release_type}", "TransactionIDs": ${transaction_ids}} |
| 484 | ${data}= Evaluate json.dumps(${data}) json |
Vijay | afdd2a1 | 2020-04-09 02:03:20 -0500 | [diff] [blame] | 485 | ${resp}= Redfish.Post /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 486 | ... body=${data} valid_status_codes=[${exp_status_code}] |
Vijay | afdd2a1 | 2020-04-09 02:03:20 -0500 | [diff] [blame] | 487 | Should Be True ${resp.status} ${exp_status_code} |
| 488 | Return From Keyword If ${conflict_record} == ${EMPTY_LIST} |
| 489 | |
| 490 | ${conflict}= Evaluate json.loads('''${resp.text}''') json |
| 491 | |
| 492 | # Example of conflict |
| 493 | # { |
| 494 | # "Record":{ |
| 495 | # "HMCID":"hmc-id", |
| 496 | # "LockType":"Read", |
| 497 | # "ResourceID":234, |
| 498 | # "SegmentFlags":[ |
| 499 | # { |
| 500 | # "LockFlag":"DontLock", |
| 501 | # "SegmentLength":3 |
| 502 | # }, |
| 503 | # { |
| 504 | # "LockFlag":"LockAll", |
| 505 | # "SegmentLength":1 |
| 506 | # } |
| 507 | # ], |
| 508 | # "SessionID":"OorUVwrXuT", |
| 509 | # "TransactionID":47 |
| 510 | # } |
| 511 | # } |
| 512 | |
| 513 | Should Be Equal ${conflict_record[0]} ${conflict["Record"]} |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 514 | |
| 515 | |
| 516 | Verify Lock Record |
| 517 | [Documentation] Verify lock record. |
| 518 | [Arguments] ${lock_found} &{lock_records} |
| 519 | |
| 520 | # Description of argument(s): |
| 521 | # lock_found True if lock record is expected to be present, else False. |
| 522 | # lock_records A dictionary containing key value pairs of a lock record. |
| 523 | |
| 524 | ${session}= Get From Dictionary ${LOCKS} ${lock_records["TransactionID"]} |
| 525 | ${locks}= Run Keyword Get Locks List ${session} |
| 526 | |
| 527 | ${lock_record_found}= Set Variable ${False} |
| 528 | |
| 529 | FOR ${record} IN @{locks} |
| 530 | ${record}= Evaluate json.dumps(${record}) json |
| 531 | ${record}= Evaluate json.loads('''${record}''') json |
| 532 | ${lock_record_found}= Set Variable If ${record["TransactionID"]} == ${lock_records["TransactionID"]} |
| 533 | ... ${True} ${False} |
| 534 | |
| 535 | Continue For Loop If ${lock_record_found} == ${False} |
| 536 | Dictionaries Should Be Equal ${record} ${lock_records} |
| 537 | Exit For Loop |
| 538 | END |
| 539 | |
| 540 | Should Be Equal ${lock_record_found} ${lock_found} |
| 541 | |
| 542 | |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 543 | Load Response And Verify Conflict |
| 544 | [Documentation] Load response and verify conflict. |
| 545 | [Arguments] ${conflict_resp} ${sessions} |
| 546 | |
| 547 | # Description of argument(s): |
| 548 | # conflict_resp Conflict response from a REST request. |
| 549 | # Example : { "Record": { "HMCID": "hmc-id", "LockType": "Write", "ResourceID": 234, |
| 550 | # "SegmentFlags": [ { "LockFlag": "DontLock", "SegmentLength": 3}, |
| 551 | # { "LockFlag": "LockAll", "SegmentLength": 1}], |
| 552 | # "SessionID": "B6geYEdo6T", "TransactionID": 104 } } |
| 553 | # sessions Comma separated list of sessions |
| 554 | |
| 555 | ${curr_locks}= Run Keyword Get Locks List ${sessions} |
| 556 | ${conflict_resp}= Replace String ${conflict_resp} \" \\" |
| 557 | ${conflict_response}= Evaluate json.loads('''${conflict_resp}''') json |
| 558 | |
| 559 | ${conflicts}= Get Dictionary Values ${conflict_response} |
| 560 | List Should Contain Value ${conflicts} ${PREV_INPUTS} |
| 561 | |
| 562 | |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 563 | Acquire And Release Lock |
| 564 | [Documentation] Acquire and release lock. |
| 565 | [Arguments] ${lock_type} ${seg_flags} ${resource_id} ${hmc_id} ${exp_status_code}=${HTTP_OK} |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 566 | ... ${err_msgs}=${EMPTY_LIST} ${new_sess_req}=${True} |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 567 | |
| 568 | # Description of argument(s): |
| 569 | # lock_type Type of lock (Read/Write). |
| 570 | # seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy. |
| 571 | # Ex: [{'LockFlag': 'LockAll', 'SegmentLength': 1}, |
| 572 | # {'LockFlag': 'LockSame', 'SegmentLength': 2}] |
| 573 | # resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc. |
| 574 | # hmc_id Hardware management console id. |
| 575 | # exp_status_code Expected status code from the AcquireLock request for given inputs. |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 576 | # err_msgs List of expected error messages. |
| 577 | # new_sess_req Create a new session before acquiring a lock if True. |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 578 | |
| 579 | # Get REST session to BMC. |
| 580 | Run Keyword If ${new_sess_req} == ${True} Create New Session |
| 581 | |
| 582 | ${inputs}= Create Dictionary LockType=${lock_type} ResourceID=${resource_id} |
| 583 | ... SegmentFlags=${seg_flags} HMCID=${hmc_id} |
| 584 | |
| 585 | ${transaction_id}= Run Keyword Acquire Lock On A Given Resource ${inputs["LockType"]} |
| 586 | ... ${inputs["SegmentFlags"]} ${inputs["ResourceID"]} ${exp_status_code} err_msgs=${err_msgs} |
| 587 | |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 588 | # Each lock request from a new session is saved so that for next lock request using same session |
| 589 | # can refer to previous lock data to verify conflict records if any. |
| 590 | Run Keyword If ${new_sess_req} == ${True} Set Test Variable Dictionary Of Previous Lock Request |
| 591 | ... ${lock_type} ${seg_flags} ${resource_id} ${hmc_id} ${SESSION_ID} ${transaction_id} |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 592 | |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 593 | ${session}= Get From Dictionary ${LOCKS} ${transaction_id} |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 594 | Set To Dictionary ${inputs} TransactionID=${${transaction_id}} SessionID=${session} |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 595 | |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 596 | ${lock_found}= Set Variable If ${exp_status_code} == ${HTTP_OK} ${True} ${False} |
| 597 | Verify Lock Record ${lock_found} &{inputs} |
| 598 | |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 599 | Return From Keyword If '${exp_status_code}' != '${HTTP_OK}' or ${err_msgs} == ['NA'] |
Vijay | afdd2a1 | 2020-04-09 02:03:20 -0500 | [diff] [blame] | 600 | ${transaction_ids}= Create List ${transaction_id} |
| 601 | Release Locks ${transaction_ids} |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 602 | Verify Lock Record ${False} &{inputs} |
| 603 | |
| 604 | # Delete the session. |
| 605 | Redfish.Logout |
| 606 | |
| 607 | |
| 608 | Create New Session |
| 609 | [Documentation] Create new session. |
| 610 | |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 611 | # Delete current session. |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 612 | Redfish.Logout |
| 613 | |
| 614 | # Get a redfish session to BMC. |
| 615 | Redfish.Login |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 616 | ${session_id} ${session_key}= Return Session Id And Session Key |
| 617 | Set Test Variable ${SESSION_ID} ${session_id} |
| 618 | Set Test Variable ${SESSION_KEY} ${session_key} |
Vijay | bc331e2 | 2020-02-27 04:17:37 -0600 | [diff] [blame] | 619 | |
| 620 | |
| 621 | Test Teardown Execution |
| 622 | [Documentation] Test teardown execution. |
| 623 | |
| 624 | FFDC On Test Case Fail |
| 625 | Redfish.Logout |
| 626 | |
Vijay | 355daac | 2020-03-26 12:06:08 -0500 | [diff] [blame] | 627 | |
| 628 | Return Session Id And Session Key |
| 629 | [Documentation] Return session id and sesion key. |
| 630 | |
| 631 | ${session_location}= Redfish.Get Session Location |
| 632 | ${session_id}= Evaluate os.path.basename($session_location) modules=os |
| 633 | ${session_key}= Redfish.Get Session Key |
| 634 | |
| 635 | [Return] ${session_id} ${session_key} |
| 636 | |
| 637 | |
| 638 | Test Setup Execution |
| 639 | [Documentation] Test setup execution. |
| 640 | |
| 641 | Create New Session |
| 642 | |
| 643 | Set Test Variable Dictionary Of Previous Lock Request ${EMPTY} ${EMPTY_LIST} ${EMPTY} ${EMPTY} |
| 644 | ... ${EMPTY} ${EMPTY} |
| 645 | |
| 646 | |
| 647 | Set Test Variable Dictionary Of Previous Lock Request |
| 648 | [Documentation] Set test variable dictionary of previous lock request. |
| 649 | [Arguments] ${lock_type} ${seg_flags} ${resource_id} ${hmc_id} ${session_id} ${transaction_id} |
| 650 | |
| 651 | # Description of argument(s): |
| 652 | # lock_type Type of lock (Read/Write). |
| 653 | # seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy. |
| 654 | # Ex: [{'LockFlag': 'LockAll', 'SegmentLength': 1}, |
| 655 | # {'LockFlag': 'LockSame', 'SegmentLength': 2}] |
| 656 | # resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc. |
| 657 | # hmc_id Hardware management console id. |
| 658 | # session_id Session id of the transaction. |
| 659 | # transaction_id Transaction_id of the lock request. |
| 660 | |
| 661 | ${prev_inputs}= Create Dictionary LockType=${lock_type} ResourceID=${resource_id} |
| 662 | ... SegmentFlags=${seg_flags} HMCID=${hmc_id} SessionID=${session_id} TransactionID=${transaction_id} |
| 663 | |
| 664 | Set Test Variable ${PREV_INPUTS} ${prev_inputs} |