1bc331e22SVijay*** Settings *** 2bc331e22SVijay 3bc331e22SVijayDocumentation Test Lock Management feature of Management Console on BMC. 4bc331e22SVijay 5bc331e22SVijayResource ../../lib/resource.robot 6bc331e22SVijayResource ../../lib/openbmc_ffdc.robot 7*566daaf3SGeorge KeishingResource ../../lib/bmc_redfish_utils.robot 8bc331e22SVijay 9*566daaf3SGeorge KeishingSuite Setup Delete All Redfish Sessions 10355daac7SVijayTest Setup Test Setup Execution 11bc331e22SVijayTest Teardown Test Teardown Execution 12*566daaf3SGeorge KeishingSuite Teardown Delete All Redfish Sessions 13bc331e22SVijay 14bc331e22SVijay*** Variables *** 15bc331e22SVijay 16bc331e22SVijay# Data-sets for testing different test cases. 17bc331e22SVijay&{LOCKALL_LEN1} LockFlag=LockAll SegmentLength=${1} 18bc331e22SVijay&{LOCKALL_LEN2} LockFlag=LockAll SegmentLength=${2} 19bc331e22SVijay&{LOCKALL_LEN3} LockFlag=LockAll SegmentLength=${3} 20bc331e22SVijay&{LOCKALL_LEN4} LockFlag=LockAll SegmentLength=${4} 21bc331e22SVijay&{LOCKALL_LEN5} LockFlag=LockAll SegmentLength=${5} 22bc331e22SVijay 23bc331e22SVijay&{LOCKALL_INVALID_LOCKFLAG1} LockFlag=LocAll SegmentLength=${2} 24bc331e22SVijay&{LOCKALL_INVALID_LOCKFLAG2} LockFlag=LOCKALL SegmentLength=${3} 25bc331e22SVijay&{LOCKALL_INVALID_LOCKFLAG3} LOCKFLAG=LockAll SegmentLength=${4} 26bc331e22SVijay&{LOCKSAME_INVALID_LOCKFLAG3} Lock=LockSame SegmentLength=${1} 27bc331e22SVijay&{LOCKSAME_INVALID_LOCKFLAG4} Lock=LockSame SegmentLength=${True} 28bc331e22SVijay 29bc331e22SVijay&{LOCKSAME_LEN1} LockFlag=LockSame SegmentLength=${1} 30bc331e22SVijay&{LOCKSAME_LEN2} LockFlag=LockSame SegmentLength=${2} 31bc331e22SVijay&{LOCKSAME_LEN3} LockFlag=LockSame SegmentLength=${3} 32bc331e22SVijay&{LOCKSAME_LEN4} LockFlag=LockSame SegmentLength=${4} 33bc331e22SVijay&{LOCKSAME_INVALID_LEN1} LockFlag=LockSame SegmentLength=${0} 34bc331e22SVijay&{LOCKSAME_INVALID_LEN2} LockFlag=LockSame SegmentLength=${5} 35bc331e22SVijay&{LOCKSAME_INVALID_LEN_STR} LockFlag=LockSame SegmentLength=2 36bc331e22SVijay&{LOCKSAME_INVALID_LEN_NEG} LockFlag=LockSame SegmentLength=${-3} 37bc331e22SVijay&{LOCKSAME_INVALID_LEN_BOOL} Lock=LockSame SegmentLength=${True} 38bc331e22SVijay 39bc331e22SVijay&{DONTLOCK_LEN1} LockFlag=DontLock SegmentLength=${1} 40bc331e22SVijay&{DONTLOCK_LEN2} LockFlag=DontLock SegmentLength=${2} 41bc331e22SVijay&{DONTLOCK_LEN3} LockFlag=DontLock SegmentLength=${3} 42bc331e22SVijay&{DONTLOCK_LEN4} LockFlag=DontLock SegmentLength=${4} 43bc331e22SVijay&{DONTLOCK_INVALID_LEN} LockFlag=DontLock SegmentLength=${5} 44bc331e22SVijay&{DONTLOCK_INVALID_LEN_BOOL} LockFlag=DONTLOCK SegmentLength=${False} 45bc331e22SVijay&{DONTLOCK_INVALID_LOCKFLAG} LOCKFLAG=LockAll SegmentLength=${4} 46bc331e22SVijay 47bc331e22SVijay@{ONE_SEG_FLAG_ALL} ${LOCKALL_LEN1} 48bc331e22SVijay@{ONE_SEG_FLAG_SAME} ${LOCKSAME_LEN3} 49bc331e22SVijay@{ONE_SEG_FLAG_DONT} ${DONTLOCK_LEN4} 50bc331e22SVijay 51bc331e22SVijay@{TWO_SEG_FLAG_1} ${LOCKALL_LEN1} ${LOCKSAME_LEN2} 52bc331e22SVijay@{TWO_SEG_FLAG_2} ${DONTLOCK_LEN3} ${LOCKALL_LEN1} 53bc331e22SVijay@{TWO_SEG_FLAG_3} ${DONTLOCK_LEN4} ${LOCKSAME_LEN3} 54bc331e22SVijay@{TWO_SEG_FLAG_4} ${DONTLOCK_INVALID_LEN} ${LOCKSAME_LEN3} 55bc331e22SVijay@{TWO_SEG_FLAG_5} ${DONTLOCK_LEN2} ${LOCKSAME_INVALID_LEN1} 56bc331e22SVijay 57bc331e22SVijay@{TWO_SEG_FLAG_INVALID1} ${DONTLOCK_LEN4} ${LOCKSAME_INVALID_LEN1} 58bc331e22SVijay@{TWO_SEG_FLAG_INVALID2} ${LOCKALL_LEN5} ${DONTLOCK_LEN1} 59bc331e22SVijay@{TWO_SEG_FLAG_INVALID3} ${DONTLOCK_LEN1} ${LOCKALL_INVALID_LOCKFLAG1} 60bc331e22SVijay@{TWO_SEG_FLAG_INVALID4} ${DONTLOCK_LEN2} ${LOCKALL_INVALID_LOCKFLAG2} 61bc331e22SVijay@{TWO_SEG_FLAG_INVALID5} ${DONTLOCK_LEN2} ${LOCKALL_INVALID_LOCKFLAG3} 62bc331e22SVijay@{TWO_SEG_FLAG_INVALID6} ${LOCKALL_LEN3} ${LOCKSAME_INVALID_LOCKFLAG3} 63bc331e22SVijay@{TWO_SEG_FLAG_INVALID7} ${DONTLOCK_LEN2} ${LOCKSAME_INVALID_LOCKFLAG4} 64bc331e22SVijay@{TWO_SEG_FLAG_INVALID8} ${DONTLOCK_INVALID_LOCKFLAG} ${LOCKSAME_INVALID_LEN_BOOL} 65bc331e22SVijay@{TWO_SEG_FLAG_INVALID9} ${DONTLOCK_LEN2} ${LOCKSAME_INVALID_LOCKFLAG4} 66bc331e22SVijay 67bc331e22SVijay@{THREE_SEG_FLAG_1} ${LOCKALL_LEN1} @{TWO_SEG_FLAG_3} 68bc331e22SVijay@{THREE_SEG_FLAG_2} ${LOCKSAME_LEN4} @{TWO_SEG_FLAG_2} 69bc331e22SVijay@{THREE_SEG_FLAG_3} ${DONTLOCK_LEN3} @{TWO_SEG_FLAG_1} 70bc331e22SVijay 71bc331e22SVijay@{FOUR_SEG_FLAG_1} ${LOCKALL_LEN1} @{THREE_SEG_FLAG_2} 72bc331e22SVijay@{FOUR_SEG_FLAG_2} ${LOCKSAME_LEN4} @{THREE_SEG_FLAG_3} 73bc331e22SVijay@{FOUR_SEG_FLAG_3} ${DONTLOCK_LEN3} @{THREE_SEG_FLAG_1} 74bc331e22SVijay 75bc331e22SVijay@{FIVE_SEG_FLAG_1} ${LOCKALL_LEN1} @{FOUR_SEG_FLAG_2} 76bc331e22SVijay@{FIVE_SEG_FLAG_2} ${LOCKSAME_LEN4} @{FOUR_SEG_FLAG_3} 77bc331e22SVijay@{FIVE_SEG_FLAG_3} ${DONTLOCK_LEN3} @{FOUR_SEG_FLAG_1} 78bc331e22SVijay 79bc331e22SVijay@{SIX_SEG_FLAG_1} ${LOCKALL_LEN1} @{FIVE_SEG_FLAG_2} 80bc331e22SVijay@{SIX_SEG_FLAG_2} ${LOCKSAME_LEN4} @{FIVE_SEG_FLAG_3} 81bc331e22SVijay@{SIX_SEG_FLAG_3} ${DONTLOCK_LEN3} @{FIVE_SEG_FLAG_1} 82bc331e22SVijay 83bc331e22SVijay@{SEVEN_SEG_FLAG_1} ${LOCKALL_LEN1} @{SIX_SEG_FLAG_2} 84bc331e22SVijay@{SEVEN_SEG_FLAG_2} ${LOCKSAME_LEN4} @{SIX_SEG_FLAG_3} 85bc331e22SVijay@{SEVEN_SEG_FLAG_3} ${DONTLOCK_LEN3} @{SIX_SEG_FLAG_1} 86bc331e22SVijay 87bc331e22SVijay# Different messages to be verified. 88bc331e22SVijay${PROP_REQ_ERR} is a required property and must be included in the request. 89bc331e22SVijay${PROP_ERR} is not in the list of valid properties for the resource. 90bc331e22SVijay${PROP_TYPE_ERR} is of a different type than the property can accept. 91bc331e22SVijay 92bc331e22SVijay# Build error patterns list. 93355daac7SVijay@{EMPTY_LIST} 94bc331e22SVijay@{ERR_PATTERN1} ${PROP_REQ_ERR} ${PROP_ERR} 95bc331e22SVijay@{ERR_PATTERN2} ${PROP_TYPE_ERR} 96bc331e22SVijay@{ERR_PATTERN3} ${PROP_REQ_ERR} ${PROP_ERR} ${PROP_TYPE_ERR} 97bc331e22SVijay 98bc331e22SVijay# Dictionary of Locks with Transaction ID as key and Session ID as a value. 99bc331e22SVijay&{LOCKS} 100bc331e22SVijay 101bc331e22SVijay 102bc331e22SVijay*** Test Cases *** 103bc331e22SVijay 104bc331e22SVijayAcquire And Release Different Read Locks 105bc331e22SVijay [Documentation] Acquire and release different read locks. 106bc331e22SVijay [Tags] Acquire_And_Release_Different_Read_Locks 107bc331e22SVijay [Template] Acquire And Release Lock 108bc331e22SVijay 109bc331e22SVijay # lock seg_flags resource_id hmc_id exp_status_code err_msgs new_sess 110bc331e22SVijay # type req 111355daac7SVijay Read ${ONE_SEG_FLAG_ALL} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 112355daac7SVijay Read ${ONE_SEG_FLAG_SAME} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 113355daac7SVijay Read ${ONE_SEG_FLAG_DONT} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 114149ba768SVijay Read ${TWO_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 115355daac7SVijay Read ${TWO_SEG_FLAG_2} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True} 116355daac7SVijay Read ${TWO_SEG_FLAG_3} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True} 117355daac7SVijay Read ${TWO_SEG_FLAG_4} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 118355daac7SVijay Read ${TWO_SEG_FLAG_5} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 119149ba768SVijay Read ${THREE_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 120149ba768SVijay Read ${THREE_SEG_FLAG_2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 121149ba768SVijay Read ${THREE_SEG_FLAG_3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 122149ba768SVijay Read ${FOUR_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 123149ba768SVijay Read ${FOUR_SEG_FLAG_2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 124149ba768SVijay Read ${FOUR_SEG_FLAG_3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 125149ba768SVijay Read ${FIVE_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 126149ba768SVijay Read ${FIVE_SEG_FLAG_2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 127149ba768SVijay Read ${FIVE_SEG_FLAG_3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 128149ba768SVijay Read ${SIX_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 129149ba768SVijay Read ${SIX_SEG_FLAG_2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 130149ba768SVijay Read ${SIX_SEG_FLAG_3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 131355daac7SVijay Read ${SEVEN_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 132355daac7SVijay Read ${SEVEN_SEG_FLAG_2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 133355daac7SVijay Read ${SEVEN_SEG_FLAG_3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 134355daac7SVijay Read ${LOCKSAME_INVALID_LEN1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 135bc331e22SVijay Read ${LOCKSAME_INVALID_LEN_STR} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN2} ${True} 136bc331e22SVijay Read ${LOCKSAME_INVALID_LEN_NEG} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN2} ${True} 137bc331e22SVijay Read ${LOCKSAME_INVALID_LEN_BOOL} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN2} ${True} 138bc331e22SVijay Read ${DONTLOCK_INVALID_LEN_BOOL} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN2} ${True} 139355daac7SVijay Read ${TWO_SEG_FLAG_INVALID1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 140355daac7SVijay Read ${TWO_SEG_FLAG_INVALID2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 141355daac7SVijay Read ${TWO_SEG_FLAG_INVALID3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 142355daac7SVijay Read ${TWO_SEG_FLAG_INVALID4} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 143bc331e22SVijay Read ${TWO_SEG_FLAG_INVALID5} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN1} ${True} 144bc331e22SVijay Read ${TWO_SEG_FLAG_INVALID6} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN1} ${True} 145bc331e22SVijay Read ${TWO_SEG_FLAG_INVALID7} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN3} ${True} 146bc331e22SVijay Read ${TWO_SEG_FLAG_INVALID8} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN1} ${True} 147bc331e22SVijay Read ${TWO_SEG_FLAG_INVALID9} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN2} ${True} 148bc331e22SVijay Read ${TWO_SEG_FLAG_3} 234 hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN2} ${True} 149bc331e22SVijay 150bc331e22SVijay 151bc331e22SVijayAcquire And Release Different Write Locks 152bc331e22SVijay [Documentation] Acquire and release different write locks. 153bc331e22SVijay [Tags] Acquire_And_Release_Different_Write_Locks 154bc331e22SVijay [Template] Acquire And Release Lock 155bc331e22SVijay 156bc331e22SVijay # lock seg_flags resource_id hmc_id exp_status_code err_msgs new_sess 157bc331e22SVijay # type req 158355daac7SVijay Write ${ONE_SEG_FLAG_ALL} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 159355daac7SVijay Write ${ONE_SEG_FLAG_SAME} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 160355daac7SVijay Write ${ONE_SEG_FLAG_DONT} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 16160f01e48SVijay Write ${TWO_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 162355daac7SVijay Write ${TWO_SEG_FLAG_2} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True} 163355daac7SVijay Write ${TWO_SEG_FLAG_3} ${234} hmc-id ${HTTP_OK} ${EMPTY_LIST} ${True} 164355daac7SVijay Write ${TWO_SEG_FLAG_INVALID4} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 16560f01e48SVijay Write ${THREE_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 16660f01e48SVijay Write ${THREE_SEG_FLAG_2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 16760f01e48SVijay Write ${THREE_SEG_FLAG_3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 16860f01e48SVijay Write ${FOUR_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 16960f01e48SVijay Write ${FOUR_SEG_FLAG_2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 17060f01e48SVijay Write ${FOUR_SEG_FLAG_3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 17160f01e48SVijay Write ${FIVE_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 17260f01e48SVijay Write ${FIVE_SEG_FLAG_2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 17360f01e48SVijay Write ${FIVE_SEG_FLAG_3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 17460f01e48SVijay Write ${SIX_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 17560f01e48SVijay Write ${SIX_SEG_FLAG_2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 17660f01e48SVijay Write ${SIX_SEG_FLAG_3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 177355daac7SVijay Write ${SEVEN_SEG_FLAG_1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 178355daac7SVijay Write ${SEVEN_SEG_FLAG_2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 179355daac7SVijay Write ${SEVEN_SEG_FLAG_3} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 180355daac7SVijay Write ${LOCKSAME_INVALID_LEN1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 181355daac7SVijay Write ${LOCKSAME_INVALID_LEN_STR} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 182355daac7SVijay Write ${LOCKSAME_INVALID_LEN_NEG} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 183355daac7SVijay Write ${LOCKSAME_INVALID_LEN_BOOL} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 184355daac7SVijay Write ${DONTLOCK_INVALID_LEN_BOOL} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 185355daac7SVijay Write ${TWO_SEG_FLAG_INVALID1} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 186355daac7SVijay Write ${TWO_SEG_FLAG_INVALID2} ${234} hmc-id ${HTTP_BAD_REQUEST} ${EMPTY_LIST} ${True} 187bc331e22SVijay Write ${TWO_SEG_FLAG_INVALID8} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN1} ${True} 188bc331e22SVijay Write ${TWO_SEG_FLAG_INVALID5} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN1} ${True} 189bc331e22SVijay Write ${TWO_SEG_FLAG_INVALID9} ${234} hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN2} ${True} 190bc331e22SVijay Write ${TWO_SEG_FLAG_3} 234 hmc-id ${HTTP_BAD_REQUEST} ${ERR_PATTERN2} ${True} 191bc331e22SVijay 192bc331e22SVijay 193bc331e22SVijayVerify GetLockList Returns An Empty Record For An Invalid Session Id 194bc331e22SVijay [Documentation] Verify GetLockList returns an empty record for an invalid session id. 195bc331e22SVijay [Tags] Verify_GetLockList_Returns_An_Empty_Record_For_An_Invalid_Session_Id 196bc331e22SVijay 197*566daaf3SGeorge Keishing ${resp}= Redfish Login kwargs= "Oem":{"OpenBMC" : {"ClientID":"${hmc_id}"}} 198bc331e22SVijay 199*566daaf3SGeorge Keishing ${records}= Get Locks List ${resp['Id']} 200*566daaf3SGeorge Keishing ${records}= Get Locks List ZZzZZz9zzZ 201bc331e22SVijay ${length}= Get Length ${records} 202bc331e22SVijay Should Be Equal ${length} ${0} 203bc331e22SVijay 204bc331e22SVijay 205355daac7SVijayVerify Lock Conflicts 206355daac7SVijay [Documentation] Verify lock conflicts. 207355daac7SVijay [Tags] Verify_Lock_Conflicts 208355daac7SVijay [Template] Acquire And Release Lock 209355daac7SVijay 210355daac7SVijay Write ${TWO_SEG_FLAG_2} ${234} hmc-id ${HTTP_OK} ['NA'] ${True} 211355daac7SVijay Read ${TWO_SEG_FLAG_2} ${234} hmc-id ${HTTP_CONFLICT} ['NA'] ${False} 212355daac7SVijay Read ${TWO_SEG_FLAG_2} ${234} hmc-id ${HTTP_OK} ['NA'] ${True} 213355daac7SVijay Write ${TWO_SEG_FLAG_2} ${234} hmc-id ${HTTP_CONFLICT} ['NA'] ${False} 214355daac7SVijay Write ${TWO_SEG_FLAG_2} ${234} hmc-id ${HTTP_OK} ['NA'] ${True} 215355daac7SVijay Write ${TWO_SEG_FLAG_2} ${234} hmc-id ${HTTP_CONFLICT} ['NA'] ${False} 216355daac7SVijay 217355daac7SVijay 218*566daaf3SGeorge KeishingVerify Persistency Of Read Locks After BMC Reboot 21985610eeeSVijay [Documentation] Verify persistency of locks after BMC reboot. 220*566daaf3SGeorge Keishing [Tags] Verify_Persistency_Of_Read_Locks_After_BMC_Reboot 22185610eeeSVijay [Template] Locks Persistency Check After BMC Reboot 22285610eeeSVijay 22385610eeeSVijay # lock_type seg_flags resource_id 22485610eeeSVijay Read ${TWO_SEG_FLAG_2} ${234} 225*566daaf3SGeorge Keishing 226*566daaf3SGeorge Keishing 227*566daaf3SGeorge KeishingVerify Persistency Of Write Locks After BMC Reboot 228*566daaf3SGeorge Keishing [Documentation] Verify persistency of locks after BMC reboot. 229*566daaf3SGeorge Keishing [Tags] Verify_Persistency_Of_Write_Locks_After_BMC_Reboot 230*566daaf3SGeorge Keishing [Template] Locks Persistency Check After BMC Reboot 231*566daaf3SGeorge Keishing 232*566daaf3SGeorge Keishing # lock_type seg_flags resource_id 23385610eeeSVijay Write ${TWO_SEG_FLAG_2} ${234} 23485610eeeSVijay 23585610eeeSVijay 236afdd2a1dSVijayVerify Valid Lock Transactions Release 237afdd2a1dSVijay [Documentation] Verify valid lock transactions release. 238afdd2a1dSVijay [Tags] Verify_Valid_Lock_Transactions_Release 239afdd2a1dSVijay 240*566daaf3SGeorge Keishing ${transaction_id1}= Acquire Lock On A Given Resource Read ${TWO_SEG_FLAG_2} ${234} 241afdd2a1dSVijay ${locks_before}= Get Locks List ${SESSION_ID} 242afdd2a1dSVijay 243*566daaf3SGeorge Keishing ${transaction_id2}= Acquire Lock On A Given Resource Read ${TWO_SEG_FLAG_3} ${234} 244*566daaf3SGeorge Keishing ${transaction_id3}= Acquire Lock On A Given Resource Read ${TWO_SEG_FLAG_2} ${234} 245*566daaf3SGeorge Keishing ${transaction_id4}= Acquire Lock On A Given Resource Read ${TWO_SEG_FLAG_3} ${234} 246afdd2a1dSVijay 247afdd2a1dSVijay ${transaction_ids}= Create List ${transaction_id2} ${transaction_id3} ${transaction_id4} 248afdd2a1dSVijay Release Locks ${transaction_ids} 249afdd2a1dSVijay ${locks_after}= Get Locks List ${SESSION_ID} 250afdd2a1dSVijay Should Be Equal ${locks_before} ${locks_after} 251afdd2a1dSVijay 252afdd2a1dSVijay 253afdd2a1dSVijayVerify Invalid Lock Transactions Release 254afdd2a1dSVijay [Documentation] Verify invalid lock transactions release. 255afdd2a1dSVijay [Tags] Verify_Invalid_Lock_Transactions_Release 256afdd2a1dSVijay 257*566daaf3SGeorge Keishing ${transaction_id1}= Acquire Lock On A Given Resource Read ${TWO_SEG_FLAG_2} ${234} 258afdd2a1dSVijay ${locks_before}= Get Locks List ${SESSION_ID} 259afdd2a1dSVijay 260afdd2a1dSVijay ${transaction_id2}= Evaluate ${transaction_id1} + 1 261afdd2a1dSVijay ${transaction_id3}= Evaluate ${transaction_id1} - 1 262afdd2a1dSVijay ${transaction_ids}= Create List ${transaction_id2} ${transaction_id1} ${transaction_id3} 263afdd2a1dSVijay 264afdd2a1dSVijay # If any transaction/s in the list does not belong to current session then it will be a bad request. 265afdd2a1dSVijay Release Locks ${transaction_ids} exp_status_code=${HTTP_BAD_REQUEST} 266afdd2a1dSVijay ${locks_after}= Get Locks List ${SESSION_ID} 267afdd2a1dSVijay Should Be Equal ${locks_before} ${locks_after} 268afdd2a1dSVijay 269afdd2a1dSVijay 270afdd2a1dSVijayVerify Locks Release By Session 271afdd2a1dSVijay [Documentation] Verify locks release by session. 272afdd2a1dSVijay [Tags] Verify_Locks_Release_By_Session 273afdd2a1dSVijay 274afdd2a1dSVijay ${locks_before}= Get Locks List ${SESSION_ID} 275*566daaf3SGeorge Keishing ${transaction_id1}= Acquire Lock On A Given Resource Write ${TWO_SEG_FLAG_2} ${234} 276afdd2a1dSVijay 277afdd2a1dSVijay # Release Lock by Session without mentioning transaction_ids. 278afdd2a1dSVijay Release Locks release_type=Session 279afdd2a1dSVijay ${locks_after}= Get Locks List ${SESSION_ID} 280afdd2a1dSVijay Should Be Equal ${locks_before} ${locks_after} 281afdd2a1dSVijay 282*566daaf3SGeorge Keishing ${transaction_id1}= Acquire Lock On A Given Resource Read ${TWO_SEG_FLAG_2} ${234} 283*566daaf3SGeorge Keishing ${transaction_id2}= Acquire Lock On A Given Resource Read ${TWO_SEG_FLAG_3} ${234} 284afdd2a1dSVijay ${transaction_ids}= Create List ${transaction_id1} ${transaction_id2} 285afdd2a1dSVijay 286afdd2a1dSVijay # Release Lock by Session by mentioning transaction_ids also in the request. 287afdd2a1dSVijay Release Locks ${transaction_ids} release_type=Session 288afdd2a1dSVijay 289afdd2a1dSVijay 290afdd2a1dSVijayVerify Locks Created By One Session Cannot Be Deleted By Another Session 291afdd2a1dSVijay [Documentation] Verify locks created by one session cannot be deleted by another session. 292afdd2a1dSVijay [Tags] Verify_Locks_Created_By_One_Session_Cannot_Be_Deleted_By_Another_Session 293*566daaf3SGeorge Keishing [Setup] No Operation 294afdd2a1dSVijay 295*566daaf3SGeorge Keishing ${resp}= Redfish Login kwargs= "Oem":{"OpenBMC" : {"ClientID":"hmc-id"}} 296*566daaf3SGeorge Keishing Set Test Variable ${SESSION_ID} ${resp['Id']} 297*566daaf3SGeorge Keishing ${transaction_id1}= Acquire Lock On A Given Resource Read ${TWO_SEG_FLAG_2} ${234} 298*566daaf3SGeorge Keishing ${locks_tran1}= Get Locks List ${resp['Id']} 299afdd2a1dSVijay 300*566daaf3SGeorge Keishing ${resp}= Redfish Login kwargs= "Oem":{"OpenBMC" : {"ClientID":"hmc-id"}} 301*566daaf3SGeorge Keishing Set Test Variable ${SESSION_ID} ${resp['Id']} 302afdd2a1dSVijay 303*566daaf3SGeorge Keishing ${transaction_id2}= Acquire Lock On A Given Resource Read ${TWO_SEG_FLAG_3} ${234} 304*566daaf3SGeorge Keishing ${locks_before}= Get Locks List ${resp['Id']} 305afdd2a1dSVijay 306afdd2a1dSVijay ${transaction_ids}= Create List ${transaction_id1} ${transaction_id2} 307afdd2a1dSVijay Release Locks ${transaction_ids} exp_status_code=${HTTP_UNAUTHORIZED} conflict_record=${locks_tran1} 308afdd2a1dSVijay ${locks_after}= Get Locks List ${SESSION_ID} 309afdd2a1dSVijay Should Be Equal ${locks_before} ${locks_after} 310afdd2a1dSVijay 311afdd2a1dSVijay # When release_type=Session, transaction_ids should be ignored. 312afdd2a1dSVijay Release Locks ${transaction_ids} release_type=Session 313afdd2a1dSVijay ${locks_after}= Get Locks List ${SESSION_ID} 314afdd2a1dSVijay Should Be Equal ${EMPTY_LIST} ${locks_after} 315afdd2a1dSVijay 316afdd2a1dSVijay 317bc331e22SVijay*** Keywords *** 318bc331e22SVijay 31985610eeeSVijayLocks Persistency Check After BMC Reboot 32085610eeeSVijay [Documentation] Locks persistency check after BMC reboot. 32185610eeeSVijay [Arguments] ${lock_type} ${seg_flags} ${resource_id} 32285610eeeSVijay 32385610eeeSVijay # Description of argument(s): 32485610eeeSVijay # lock_type Type of lock (Read/Write). 32585610eeeSVijay # seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy. 32685610eeeSVijay # resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc. 32785610eeeSVijay 328*566daaf3SGeorge Keishing ${transaction_id}= Acquire Lock On A Given Resource ${lock_type} ${seg_flags} ${resource_id} 32985610eeeSVijay 330*566daaf3SGeorge Keishing ${locks_prev}= Get Locks List ${SESSION_ID} 33185610eeeSVijay 332*566daaf3SGeorge Keishing Redfish OBMC Reboot (off) 333*566daaf3SGeorge Keishing Redfish Login 33485610eeeSVijay 335*566daaf3SGeorge Keishing ${locks_curr}= Get Locks List ${SESSION_ID} 33685610eeeSVijay Should Be Equal ${locks_prev} ${locks_curr} 337*566daaf3SGeorge Keishing 338afdd2a1dSVijay ${transaction_ids}= Create List ${transaction_id} 339afdd2a1dSVijay Release Locks ${transaction_ids} 34085610eeeSVijay 34185610eeeSVijay 342bc331e22SVijayReturn Data Dictionary For Single Request 343bc331e22SVijay [Documentation] Return data dictionary for single request. 344bc331e22SVijay [Arguments] ${lock_type} ${seg_flags} ${resource_id} 345bc331e22SVijay 346bc331e22SVijay # Description of argument(s): 347bc331e22SVijay # lock_type Type of lock (Read/Write). 348bc331e22SVijay # seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy. 349bc331e22SVijay # resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc. 350bc331e22SVijay 351*566daaf3SGeorge Keishing ${SEG_FLAGS_LOCK}= Create Dictionary 352*566daaf3SGeorge Keishing ... LockType=${lock_type} 353*566daaf3SGeorge Keishing ... SegmentFlags=@{seg_flags} 354bc331e22SVijay ... ResourceID=${resource_id} 355*566daaf3SGeorge Keishing 356bc331e22SVijay ${SEG_FLAGS_ENTRIES}= Create List ${SEG_FLAGS_LOCK} 357bc331e22SVijay ${LOCK_REQUEST}= Create Dictionary Request=${SEG_FLAGS_ENTRIES} 358*566daaf3SGeorge Keishing Log To Console \n ${LOCK_REQUEST} 359bc331e22SVijay 360bc331e22SVijay [Return] ${LOCK_REQUEST} 361bc331e22SVijay 362bc331e22SVijay 363bc331e22SVijayAcquire Lock On A Given Resource 364bc331e22SVijay [Documentation] Acquire lock on a given resource. 365bc331e22SVijay [Arguments] ${lock_type} ${seg_flags} ${resource_id} ${exp_status_code}=${HTTP_OK} 366355daac7SVijay ... ${err_msgs}=${EMPTY_LIST} 367bc331e22SVijay 368bc331e22SVijay # Description of argument(s): 369bc331e22SVijay # lock_type Type of lock (Read/Write). 370bc331e22SVijay # seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy. 371bc331e22SVijay # Ex: [{'LockFlag': 'LockAll', 'SegmentLength': 1}, 372bc331e22SVijay # {'LockFlag': 'LockSame', 'SegmentLength': 2}] 373bc331e22SVijay # resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc. 374355daac7SVijay # exp_status_code Expected status code from the AcquireLock request for given inputs. 375355daac7SVijay # err_msgs List of expected error messages. 376bc331e22SVijay 377bc331e22SVijay ${data}= Return Data Dictionary For Single Request ${lock_type} ${seg_flags} ${resource_id} 378*566daaf3SGeorge Keishing ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${data} 379bc331e22SVijay 380bc331e22SVijay ${transaction_id}= Run Keyword If ${exp_status_code} != ${HTTP_OK} 381bc331e22SVijay ... Set Variable ${0} 382*566daaf3SGeorge Keishing ... ELSE 383*566daaf3SGeorge Keishing ... Load Lock Record And Build Transaction To Session Map ${resp.text} 384bc331e22SVijay 385355daac7SVijay Run Keyword If ${exp_status_code} == ${HTTP_CONFLICT} and ${err_msgs} == ['NA'] 386355daac7SVijay ... Load Response And Verify Conflict ${resp.text} ${SESSION_ID} 387355daac7SVijay ... ELSE Run Keyword If ${exp_status_code} != ${HTTP_OK} and ${err_msgs} != ${EMPTY_LIST} 388bc331e22SVijay ... Load Response And Verify Error ${resp.text} err_msgs=${err_msgs} 389355daac7SVijay 390bc331e22SVijay Append Transaction Id And Session Id To Locks Dictionary ${transaction_id} 391bc331e22SVijay 392bc331e22SVijay [Return] ${transaction_id} 393bc331e22SVijay 394bc331e22SVijay 395bc331e22SVijayLoad Lock Record And Build Transaction To Session Map 396bc331e22SVijay [Documentation] Load lock record and build transaction to session map. 397bc331e22SVijay [Arguments] ${resp_text} 398bc331e22SVijay 399bc331e22SVijay # Description of argument(s): 400bc331e22SVijay # resp_text Response test from a REST request. 401bc331e22SVijay 402bc331e22SVijay ${acquire_lock}= Evaluate json.loads('''${resp_text}''') json 403bc331e22SVijay Append Transaction Id And Session Id To Locks Dictionary ${acquire_lock["TransactionID"]} 404bc331e22SVijay 405bc331e22SVijay [Return] ${acquire_lock["TransactionID"]} 406bc331e22SVijay 407bc331e22SVijay 408bc331e22SVijayLoad Response And Verify Error 409bc331e22SVijay [Documentation] Load response and verify error. 410355daac7SVijay [Arguments] ${error_resp} ${err_msgs}=${EMPTY_LIST} 411bc331e22SVijay 412bc331e22SVijay # Description of argument(s): 413bc331e22SVijay # error_resp Error response from a REST request. 414bc331e22SVijay # err_msgs List of error msg patterns. 415bc331e22SVijay 416bc331e22SVijay ${error_resp}= Replace String ${error_resp} \" \\" 417bc331e22SVijay ${error_response}= Evaluate json.loads('''${error_resp}''') json 418bc331e22SVijay 419bc331e22SVijay ${errors}= Get Dictionary Values ${error_response} 420bc331e22SVijay ${extended_errors}= Create List 421bc331e22SVijay 422bc331e22SVijay FOR ${error} IN @{errors} 423bc331e22SVijay Append To List ${extended_errors} ${error[0]["Message"]} 424bc331e22SVijay END 425bc331e22SVijay 426*566daaf3SGeorge Keishing Log To Console \n ${extended_errors} 427bc331e22SVijay 428bc331e22SVijay FOR ${exp_error} IN @{err_msgs} 429bc331e22SVijay Run Keyword Expect List Of Errors In An Extended Errors ${exp_error} ${extended_errors} 430bc331e22SVijay END 431bc331e22SVijay 432bc331e22SVijay 433bc331e22SVijayExpect List Of Errors In An Extended Errors 434bc331e22SVijay [Documentation] Expect list of errors in an extended errors. 435355daac7SVijay [Arguments] ${exp_error} ${extended_errors}=${EMPTY_LIST} 436bc331e22SVijay 437bc331e22SVijay ${found}= Set Variable ${False} 438bc331e22SVijay 439bc331e22SVijay FOR ${error_record} IN @{extended_errors} 440bc331e22SVijay ${found}= Evaluate '${exp_error}' in '${error_record}' 441bc331e22SVijay Exit For Loop If ${found} == ${True} 442bc331e22SVijay END 443bc331e22SVijay 444bc331e22SVijay Should Be True ${found} 445bc331e22SVijay 446bc331e22SVijay 447bc331e22SVijayAppend Transaction Id And Session Id To Locks Dictionary 448bc331e22SVijay [Documentation] Append transaction id and session id to locks dictionary. 449bc331e22SVijay [Arguments] ${transaction_id} 450bc331e22SVijay 451bc331e22SVijay # Description of argument(s): 452bc331e22SVijay # transaction_id Transaction ID created from acquire lock request. Ex: 8, 9 etc. 453bc331e22SVijay 454bc331e22SVijay Set To Dictionary ${LOCKS} ${${transaction_id}} ${session_id} 455bc331e22SVijay 456bc331e22SVijay 457bc331e22SVijayGet Locks List 458bc331e22SVijay [Documentation] Get locks list. 459bc331e22SVijay [Arguments] @{sessions} ${exp_status_code}=${HTTP_OK} 460bc331e22SVijay 461bc331e22SVijay # Description of argument(s): 462bc331e22SVijay # sessions List of comma separated strings. Ex: ["euHoAQpvNe", "ecTjANqwFr"] 463bc331e22SVijay # exp_status_code expected status code from the GetLockList request for given inputs. 464bc331e22SVijay 465bc331e22SVijay ${sessions}= Evaluate json.dumps(${sessions}) json 466bc331e22SVijay ${data}= Set Variable {"SessionIDs": ${sessions}} 467*566daaf3SGeorge Keishing ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList 468*566daaf3SGeorge Keishing ... data=${data} 469bc331e22SVijay ${locks}= Evaluate json.loads('''${resp.text}''') json 470bc331e22SVijay 471bc331e22SVijay [Return] ${locks["Records"]} 472bc331e22SVijay 473bc331e22SVijay 474afdd2a1dSVijayRelease Locks 475afdd2a1dSVijay [Documentation] Release locks. 476afdd2a1dSVijay [Arguments] ${transaction_ids}=${EMPTY_LIST} ${release_type}=Transaction ${exp_status_code}=${HTTP_OK} 477afdd2a1dSVijay ... ${conflict_record}=${EMPTY_LIST} 478bc331e22SVijay 479bc331e22SVijay # Description of argument(s): 480afdd2a1dSVijay # transaction_ids List of transaction ids or session ids. Ex: [15, 18] or ["euHoAQpvNe", "ecTjANqwFr"] 481bc331e22SVijay # release_type Release all locks acquired using current session or only given transaction numbers. 482bc331e22SVijay # Ex: Session, Transaction. Default will be Transaction. 483bc331e22SVijay # exp_status_code expected status code from the ReleaseLock request for given inputs. 484afdd2a1dSVijay # conflict_record Expected conflict record. 485bc331e22SVijay 486afdd2a1dSVijay # When release_type=Session then TransactionIDs list will be ignored. 487bc331e22SVijay ${data}= Set Variable {"Type": "${release_type}", "TransactionIDs": ${transaction_ids}} 488bc331e22SVijay ${data}= Evaluate json.dumps(${data}) json 489*566daaf3SGeorge Keishing ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock data=${data} 490*566daaf3SGeorge Keishing Should Be True ${resp.status_code} ${exp_status_code} 491afdd2a1dSVijay Return From Keyword If ${conflict_record} == ${EMPTY_LIST} 492afdd2a1dSVijay 493afdd2a1dSVijay ${conflict}= Evaluate json.loads('''${resp.text}''') json 494afdd2a1dSVijay 495afdd2a1dSVijay # Example of conflict 496afdd2a1dSVijay # { 497afdd2a1dSVijay # "Record":{ 498afdd2a1dSVijay # "HMCID":"hmc-id", 499afdd2a1dSVijay # "LockType":"Read", 500afdd2a1dSVijay # "ResourceID":234, 501afdd2a1dSVijay # "SegmentFlags":[ 502afdd2a1dSVijay # { 503afdd2a1dSVijay # "LockFlag":"DontLock", 504afdd2a1dSVijay # "SegmentLength":3 505afdd2a1dSVijay # }, 506afdd2a1dSVijay # { 507afdd2a1dSVijay # "LockFlag":"LockAll", 508afdd2a1dSVijay # "SegmentLength":1 509afdd2a1dSVijay # } 510afdd2a1dSVijay # ], 511afdd2a1dSVijay # "SessionID":"OorUVwrXuT", 512afdd2a1dSVijay # "TransactionID":47 513afdd2a1dSVijay # } 514afdd2a1dSVijay # } 515afdd2a1dSVijay 516afdd2a1dSVijay Should Be Equal ${conflict_record[0]} ${conflict["Record"]} 517bc331e22SVijay 518bc331e22SVijay 519bc331e22SVijayVerify Lock Record 520bc331e22SVijay [Documentation] Verify lock record. 521bc331e22SVijay [Arguments] ${lock_found} &{lock_records} 522bc331e22SVijay 523bc331e22SVijay # Description of argument(s): 524bc331e22SVijay # lock_found True if lock record is expected to be present, else False. 525bc331e22SVijay # lock_records A dictionary containing key value pairs of a lock record. 526bc331e22SVijay 527bc331e22SVijay ${session}= Get From Dictionary ${LOCKS} ${lock_records["TransactionID"]} 528*566daaf3SGeorge Keishing ${locks}= Get Locks List ${session} 529bc331e22SVijay 530bc331e22SVijay ${lock_record_found}= Set Variable ${False} 531bc331e22SVijay 532bc331e22SVijay FOR ${record} IN @{locks} 533bc331e22SVijay ${record}= Evaluate json.dumps(${record}) json 534bc331e22SVijay ${record}= Evaluate json.loads('''${record}''') json 535bc331e22SVijay ${lock_record_found}= Set Variable If ${record["TransactionID"]} == ${lock_records["TransactionID"]} 536bc331e22SVijay ... ${True} ${False} 537bc331e22SVijay 538bc331e22SVijay Continue For Loop If ${lock_record_found} == ${False} 539bc331e22SVijay Dictionaries Should Be Equal ${record} ${lock_records} 540bc331e22SVijay Exit For Loop 541bc331e22SVijay END 542bc331e22SVijay 543bc331e22SVijay Should Be Equal ${lock_record_found} ${lock_found} 544bc331e22SVijay 545bc331e22SVijay 546355daac7SVijayLoad Response And Verify Conflict 547355daac7SVijay [Documentation] Load response and verify conflict. 548355daac7SVijay [Arguments] ${conflict_resp} ${sessions} 549355daac7SVijay 550355daac7SVijay # Description of argument(s): 551355daac7SVijay # conflict_resp Conflict response from a REST request. 552355daac7SVijay # Example : { "Record": { "HMCID": "hmc-id", "LockType": "Write", "ResourceID": 234, 553355daac7SVijay # "SegmentFlags": [ { "LockFlag": "DontLock", "SegmentLength": 3}, 554355daac7SVijay # { "LockFlag": "LockAll", "SegmentLength": 1}], 555355daac7SVijay # "SessionID": "B6geYEdo6T", "TransactionID": 104 } } 556355daac7SVijay # sessions Comma separated list of sessions 557355daac7SVijay 558*566daaf3SGeorge Keishing ${curr_locks}= Get Locks List ${sessions} 559355daac7SVijay ${conflict_resp}= Replace String ${conflict_resp} \" \\" 560355daac7SVijay ${conflict_response}= Evaluate json.loads('''${conflict_resp}''') json 561355daac7SVijay 562355daac7SVijay ${conflicts}= Get Dictionary Values ${conflict_response} 563355daac7SVijay List Should Contain Value ${conflicts} ${PREV_INPUTS} 564355daac7SVijay 565355daac7SVijay 566bc331e22SVijayAcquire And Release Lock 567bc331e22SVijay [Documentation] Acquire and release lock. 568bc331e22SVijay [Arguments] ${lock_type} ${seg_flags} ${resource_id} ${hmc_id} ${exp_status_code}=${HTTP_OK} 569355daac7SVijay ... ${err_msgs}=${EMPTY_LIST} ${new_sess_req}=${True} 570bc331e22SVijay 571bc331e22SVijay # Description of argument(s): 572bc331e22SVijay # lock_type Type of lock (Read/Write). 573bc331e22SVijay # seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy. 574bc331e22SVijay # Ex: [{'LockFlag': 'LockAll', 'SegmentLength': 1}, 575bc331e22SVijay # {'LockFlag': 'LockSame', 'SegmentLength': 2}] 576bc331e22SVijay # resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc. 577bc331e22SVijay # hmc_id Hardware management console id. 578bc331e22SVijay # exp_status_code Expected status code from the AcquireLock request for given inputs. 579355daac7SVijay # err_msgs List of expected error messages. 580355daac7SVijay # new_sess_req Create a new session before acquiring a lock if True. 581bc331e22SVijay 582*566daaf3SGeorge Keishing # Delete the session. 583*566daaf3SGeorge Keishing Run Keyword If ${new_sess_req} == ${True} Delete All Redfish Sessions 584*566daaf3SGeorge Keishing 585bc331e22SVijay # Get REST session to BMC. 586bc331e22SVijay Run Keyword If ${new_sess_req} == ${True} Create New Session 587bc331e22SVijay 588*566daaf3SGeorge Keishing ${inputs}= Create Dictionary 589*566daaf3SGeorge Keishing ... LockType=${lock_type} 590*566daaf3SGeorge Keishing ... ResourceID=${resource_id} 591*566daaf3SGeorge Keishing ... SegmentFlags=${seg_flags} 592*566daaf3SGeorge Keishing ... HMCID=${hmc_id} 593bc331e22SVijay 594*566daaf3SGeorge Keishing ${transaction_id}= Acquire Lock On A Given Resource ${inputs["LockType"]} 595bc331e22SVijay ... ${inputs["SegmentFlags"]} ${inputs["ResourceID"]} ${exp_status_code} err_msgs=${err_msgs} 596bc331e22SVijay 597355daac7SVijay # Each lock request from a new session is saved so that for next lock request using same session 598355daac7SVijay # can refer to previous lock data to verify conflict records if any. 599355daac7SVijay Run Keyword If ${new_sess_req} == ${True} Set Test Variable Dictionary Of Previous Lock Request 600355daac7SVijay ... ${lock_type} ${seg_flags} ${resource_id} ${hmc_id} ${SESSION_ID} ${transaction_id} 601bc331e22SVijay 602355daac7SVijay ${session}= Get From Dictionary ${LOCKS} ${transaction_id} 603bc331e22SVijay Set To Dictionary ${inputs} TransactionID=${${transaction_id}} SessionID=${session} 604355daac7SVijay 605bc331e22SVijay ${lock_found}= Set Variable If ${exp_status_code} == ${HTTP_OK} ${True} ${False} 606bc331e22SVijay Verify Lock Record ${lock_found} &{inputs} 607bc331e22SVijay 608355daac7SVijay Return From Keyword If '${exp_status_code}' != '${HTTP_OK}' or ${err_msgs} == ['NA'] 609afdd2a1dSVijay ${transaction_ids}= Create List ${transaction_id} 610afdd2a1dSVijay Release Locks ${transaction_ids} 611bc331e22SVijay Verify Lock Record ${False} &{inputs} 612bc331e22SVijay 613bc331e22SVijay 614bc331e22SVijayCreate New Session 615bc331e22SVijay [Documentation] Create new session. 616bc331e22SVijay 617*566daaf3SGeorge Keishing ${resp}= Redfish Login kwargs= "Oem":{"OpenBMC" : {"ClientID":"${hmc_id}"}} 618*566daaf3SGeorge Keishing Set Test Variable ${SESSION_ID} ${resp['Id']} 619bc331e22SVijay 620bc331e22SVijay 621bc331e22SVijayTest Teardown Execution 622bc331e22SVijay [Documentation] Test teardown execution. 623bc331e22SVijay 624bc331e22SVijay FFDC On Test Case Fail 625*566daaf3SGeorge Keishing Delete All Redfish Sessions 626bc331e22SVijay 627355daac7SVijay 628355daac7SVijayReturn Session Id And Session Key 629355daac7SVijay [Documentation] Return session id and sesion key. 630355daac7SVijay 631355daac7SVijay ${session_location}= Redfish.Get Session Location 632355daac7SVijay ${session_id}= Evaluate os.path.basename($session_location) modules=os 633355daac7SVijay ${session_key}= Redfish.Get Session Key 634355daac7SVijay 635355daac7SVijay [Return] ${session_id} ${session_key} 636355daac7SVijay 637355daac7SVijay 638355daac7SVijayTest Setup Execution 639355daac7SVijay [Documentation] Test setup execution. 640355daac7SVijay 641*566daaf3SGeorge Keishing # This is a test constant value. 642*566daaf3SGeorge Keishing Set Test Variable ${hmc_id} hmc-id 643355daac7SVijay Create New Session 644355daac7SVijay 645*566daaf3SGeorge Keishing Set Test Variable Dictionary Of Previous Lock Request 646*566daaf3SGeorge Keishing ... ${EMPTY} ${EMPTY_LIST} ${EMPTY} ${EMPTY} ${EMPTY} ${EMPTY} 647355daac7SVijay 648355daac7SVijay 649355daac7SVijaySet Test Variable Dictionary Of Previous Lock Request 650355daac7SVijay [Documentation] Set test variable dictionary of previous lock request. 651355daac7SVijay [Arguments] ${lock_type} ${seg_flags} ${resource_id} ${hmc_id} ${session_id} ${transaction_id} 652355daac7SVijay 653355daac7SVijay # Description of argument(s): 654355daac7SVijay # lock_type Type of lock (Read/Write). 655355daac7SVijay # seg_flags Segmentation Flags to identify lock elements under system level in the hierarchy. 656355daac7SVijay # Ex: [{'LockFlag': 'LockAll', 'SegmentLength': 1}, 657355daac7SVijay # {'LockFlag': 'LockSame', 'SegmentLength': 2}] 658355daac7SVijay # resource_id Decimal +ve integer value of maximum 8 hex bytes. Ex: 134, 2048 etc. 659355daac7SVijay # hmc_id Hardware management console id. 660355daac7SVijay # session_id Session id of the transaction. 661355daac7SVijay # transaction_id Transaction_id of the lock request. 662355daac7SVijay 663*566daaf3SGeorge Keishing ${prev_inputs}= Create Dictionary 664*566daaf3SGeorge Keishing ... LockType=${lock_type} 665*566daaf3SGeorge Keishing ... ResourceID=${resource_id} 666*566daaf3SGeorge Keishing ... SegmentFlags=${seg_flags} 667*566daaf3SGeorge Keishing ... HMCID=${hmc_id} 668*566daaf3SGeorge Keishing ... SessionID=${session_id} 669*566daaf3SGeorge Keishing ... TransactionID=${transaction_id} 670355daac7SVijay 671355daac7SVijay Set Test Variable ${PREV_INPUTS} ${prev_inputs} 672