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