1*** Settings *** 2 3Documentation Test lock management feature of management console on BMC. 4 5Resource ../../lib/resource.robot 6Resource ../../lib/openbmc_ffdc.robot 7Resource ../../lib/bmc_redfish_utils.robot 8Resource ../../lib/external_intf/management_console_utils.robot 9Resource ../../lib/rest_response_code.robot 10Library ../../lib/bmc_network_utils.py 11Library JSONLibrary 12 13Suite Setup Run Keyword And Ignore Error Delete All Redfish Sessions 14Suite Teardown Run Keyword And Ignore Error Delete All Redfish Sessions 15Test Setup Printn 16Test Teardown FFDC On Test Case Fail 17 18*** Variables *** 19 20${CONFLICT_RQUEST} Conflict 21${BAD_REQUEST} Bad Request 22&{default_trans_id} TransactionID=${1} 23 24*** Test Cases *** 25 26Acquire Read Write Lock 27 [Documentation] Acquire and release different read locks. 28 [Tags] Acquire_Read_Write_Lock 29 [Template] Acquire Lock On Resource 30 31 # client_id lock_type reboot_flag 32 HMCID-01 ReadCase1 False 33 HMCID-01 ReadCase2 False 34 HMCID-01 ReadCase3 False 35 HMCID-01 WriteCase1 False 36 HMCID-01 WriteCase2 False 37 HMCID-01 WriteCase3 False 38 39 40Acquire Read Lock On Read Lock 41 [Documentation] Acquire read lock on another read lock. 42 [Tags] Acquire_Read_Lock_On_Read_Lock 43 [Template] Acquire Lock On Another Lock 44 45 # client_id 46 HMCID-01 47 48 49Fail To Acquire Lock On Another Lock 50 [Documentation] Fail to acquire another lock. 51 [Tags] Fail_To_Acquire_Lock_On_Another_Lock 52 [Template] Verify Acquire Lock Fails On Another Lock 53 54 # client_id lock_type 55 HMCID-01 ReadCase7,WriteCase6 56 HMCID-01 WriteCase6,WriteCase6 57 HMCID-01 WriteCase6,ReadCase7 58 59 60Acquire Lock After Reboot 61 [Documentation] Acquire and release read and write locks after reboot. 62 [Tags] Acquire_Lock_After_Reboot 63 [Template] Verify Acquire Lock After Reboot 64 65 # client_id lock_type 66 HMCID-01 ReadCase1 67 HMCID-01 ReadCase2 68 HMCID-01 ReadCase3 69 HMCID-01 WriteCase1 70 HMCID-01 WriteCase2 71 HMCID-01 WriteCase3 72 73 74Acquire And Release Lock In Loop 75 [Documentation] Acquire and release read, write locks in loop. 76 [Tags] Acquire_And_Release_Lock_In_Loop 77 [Template] Verify Acquire And Release Lock In Loop 78 79 # client_id lock_type 80 HMCID-01 ReadCase1 81 HMCID-01 ReadCase2 82 HMCID-01 ReadCase3 83 HMCID-01 WriteCase1 84 HMCID-01 WriteCase2 85 HMCID-01 WriteCase3 86 87 88Fail To Acquire Read And Write In Single Request 89 [Documentation] Fail to acquire read and write lock in single request. 90 [Tags] Fail_To_Acquire_Read_And_Write_In_Single_Request 91 [Template] Verify Fail To Acquire Read And Write In Single Request 92 93 # client_id lock_type status_code 94 HMCID-01 ReadCase1,WriteCase1 ${HTTP_CONFLICT} 95 HMCID-01 WriteCase1,ReadCase1 ${HTTP_CONFLICT} 96 HMCID-01 WriteCase1,WriteCase1 ${HTTP_CONFLICT} 97 98 99Acquire Read In Single Request 100 [Documentation] Acquire read in single request. 101 [Tags] Acquire_Read_In_Single_Request 102 [Template] Verify Acquire Read In Single Request 103 104 # client_id lock_type 105 HMCID-01 ReadCase1,ReadCase1 106 107 108Acquire Multiple Lock Request At CEC Level 109 [Documentation] Acquire write lock on read lock under CEC level. 110 [Tags] Acquire_Multiple_Lock_Request_At_CEC_Level 111 [Template] Verify Acquire Multiple Lock Request At CEC Level 112 113 # client_id lock_type 114 HMCID-01 ReadCase4,WriteCase4 115 HMCID-01 WriteCase5,ReadCase5 116 HMCID-01 ReadCase6,WriteCase6 117 HMCID-01 WriteCase7,ReadCase7 118 119 120Verify Release Of Valid Locks 121 [Documentation] Release all valid locks. 122 [Tags] Verify_Release_Of_Valid_Locks 123 [Template] Acquire And Release Multiple Locks 124 125 # client_id lock_type release_lock_type 126 HMCID-01 ReadCase1,ReadCase1,ReadCase1 Transaction 127 HMCID-02 ReadCase1,ReadCase1,ReadCase1 Session 128 129 130Release Lock When Session Deleted 131 [Documentation] Release lock when session gets deleted. 132 [Tags] Release_Lock_When_Session_Deleted 133 [Template] Verify Release Lock When Session Deleted 134 135 # client_id lock_type 136 HMCID-01 ReadCase1 137 HMCID-01 WriteCase1 138 139 140Fail To Release Lock With Invalid TransactionID 141 [Documentation] Fail to release lock with invalid transaction id. 142 [Tags] Fail_To_Release_Lock_With_Invalid_TransactionID 143 [Template] Verify Fail To Release Lock With Invalid TransactionID 144 145 # client_id lock_type release_lock_type 146 HMCID-01 ReadCase1 Transaction 147 HMCID-01 WriteCase1 Transaction 148 149 150Fail To Release Multiple Lock With Invalid TransactionID 151 [Documentation] Release in-valid lock result in fail. 152 [Tags] Fail_To_Release_Multiple_Lock_With_Invalid_TransactionID 153 [Template] Verify Fail To Release Multiple Lock With Invalid TransactionID 154 155 # client_id lock_type release_lock_type 156 HMCID-01 ReadCase1,ReadCase1,ReadCase1 Transaction 157 12345 ReadCase2,ReadCase2,ReadCase2 Transaction 158 HMCID ReadCase3,ReadCase3,ReadCase3 Transaction 159 160 161Fail To Release Multiple Lock With Valid And Invalid TransactionID 162 [Documentation] Release multiple lock with valid and invalid transaction. 163 [Tags] Fail_To_Release_Multiple_Lock_With_Valid_And_Invalid_TransactionID 164 [Template] Verify Fail To Release Multiple Lock With Valid And Invalid TransactionID 165 166 # client_id lock_type release_lock_type 167 HMCID-01 ReadCase1,ReadCase1 Transaction 168 169 170Fail To Release Lock With String As TransactionID Data Type 171 [Documentation] Fail to release lock with string as transaction id data type. 172 [Tags] Fail_To_Release_Lock_With_String_As_TransactionID_Data_Type 173 [Template] Verify Fail To Release Lock With TransactionID As String Type 174 175 # client_id lock_type release_lock_type 176 HMCID-01 ReadCase1 Transaction 177 HMCID-01 WriteCase1 Transaction 178 179 180Fail To Release Lock For Another Session 181 [Documentation] Failed to release locks from another session. 182 [Tags] Fail_To_Release_Lock_For_Another_Session 183 [Template] Verify Fail To Release Lock For Another Session 184 185 # client_id lock_type 186 HMCID-01,HMCID-02 ReadCase1,ReadCase1 187 188 189Verify Lock Is Not Persistent On BMC Reboot 190 [Documentation] Acquire lock and after reboot the locks are removed as no persistency 191 ... maintained. 192 [Tags] Verify_Lock_Is_Not_Persistent_On_BMC_Reboot 193 [Template] Acquire Lock On Resource 194 195 # client_id lock_type reboot_flag 196 HMCID-01 ReadCase1 True 197 HMCID-01 ReadCase2 True 198 HMCID-01 ReadCase3 True 199 HMCID-01 WriteCase1 True 200 HMCID-01 WriteCase2 True 201 HMCID-01 WriteCase3 True 202 203 204Test Invalid Resource ID Data Type Locking 205 [Documentation] Failed to acquire lock for invalid resource id data type. 206 [Tags] Test_Invalid_Resource_ID_Data_Type_Locking 207 [Template] Verify Fail To Acquire Lock For Invalid Resource ID Data Type 208 209 # client_id lock_type 210 HMCID-01 ReadCase1 211 HMCID-01 ReadCase2 212 HMCID-01 ReadCase3 213 HMCID-01 WriteCase1 214 HMCID-01 WriteCase2 215 HMCID-01 WriteCase3 216 217 218Fail To Acquire Lock For Invalid Lock Type 219 [Documentation] Failed to acquire read, write lock for invalid lock data passed. 220 [Tags] Fail_To_Acquire_Lock_For_Invalid_Lock_Type 221 [Template] Verify Fail To Acquire Lock For Invalid Lock Data 222 223 # client_id lock_type message 224 HMCID-01 ReadCase1 ${BAD_REQUEST} 225 HMCID-01 ReadCase2 ${BAD_REQUEST} 226 HMCID-01 ReadCase3 ${BAD_REQUEST} 227 HMCID-01 ReadCase4 ${BAD_REQUEST} 228 HMCID-01 ReadCase5 ${BAD_REQUEST} 229 HMCID-01 WriteCase1 ${BAD_REQUEST} 230 HMCID-01 WriteCase2 ${BAD_REQUEST} 231 HMCID-01 WriteCase3 ${BAD_REQUEST} 232 HMCID-01 WriteCase4 ${BAD_REQUEST} 233 HMCID-01 WriteCase5 ${BAD_REQUEST} 234 235 236Fail To Acquire Lock For Invalid Lock Flag 237 [Documentation] Failed to acquire read write lock for invalid lock flag passed. 238 [Tags] Fail_To_Acquire_Lock_For_Invalid_Lock_Flag 239 [Template] Verify Fail To Acquire Lock For Invalid Lock Data 240 241 # client_id lock_type message 242 HMCID-01 ReadCase6 ${BAD_REQUEST} 243 HMCID-01 ReadCase7 ${BAD_REQUEST} 244 HMCID-01 ReadCase8 ${BAD_REQUEST} 245 HMCID-01 ReadCase9 ${BAD_REQUEST} 246 HMCID-01 ReadCase10 ${BAD_REQUEST} 247 HMCID-01 ReadCase11 ${BAD_REQUEST} 248 HMCID-01 WriteCase6 ${BAD_REQUEST} 249 HMCID-01 WriteCase7 ${BAD_REQUEST} 250 HMCID-01 WriteCase8 ${BAD_REQUEST} 251 HMCID-01 WriteCase9 ${BAD_REQUEST} 252 HMCID-01 WriteCase10 ${BAD_REQUEST} 253 HMCID-01 WriteCase11 ${BAD_REQUEST} 254 255 256Check After Reboot Transaction ID Set To Default 257 [Documentation] After reboot, the transaction id starts with default i.e. 1, 258 ... if any lock is acquired. 259 [Tags] Check_After_Reboot_Transaction_ID_Set_To_Default 260 [Template] Verify Acquire And Release Lock In Loop 261 262 # client_id lock_type reboot_flag 263 HMCID-01 ReadCase1 True 264 HMCID-01 WriteCase1 True 265 266 267Fail To Acquire Lock For Invalid Segment Flag 268 [Documentation] Failed to acquire read write lock for invalid segment flag passed. 269 [Tags] Fail_To_Acquire_Lock_For_Invalid_Segment_Flag 270 [Template] Verify Fail To Acquire Lock For Invalid Lock Data 271 272 # client_id lock_type message 273 HMCID-01 ReadCase12 ${BAD_REQUEST} 274 HMCID-01 ReadCase13 ${BAD_REQUEST} 275 HMCID-01 ReadCase14 ${BAD_REQUEST} 276 HMCID-01 WriteCase12 ${BAD_REQUEST} 277 HMCID-01 WriteCase13 ${BAD_REQUEST} 278 HMCID-01 WriteCase14 ${BAD_REQUEST} 279 280 281Fail To Acquire Lock For Invalid Segment Data Type Flag 282 [Documentation] Failed to acquire read write lock for invalid segment flag passed. 283 [Tags] Fail_To_Acquire_Lock_For_Invalid_Segment_Data_Type_Flag 284 [Template] Verify Fail To Acquire Lock For Invalid Lock Data 285 286 # client_id lock_type message 287 HMCID-01 ReadCase15 ${EMPTY} 288 HMCID-01 ReadCase16 ${EMPTY} 289 HMCID-01 ReadCase17 ${EMPTY} 290 HMCID-01 ReadCase18 ${EMPTY} 291 HMCID-01 WriteCase15 ${EMPTY} 292 HMCID-01 WriteCase16 ${EMPTY} 293 HMCID-01 WriteCase17 ${EMPTY} 294 HMCID-01 WriteCase18 ${EMPTY} 295 296 297Get Empty Lock Records For Session Where No Locks Acquired 298 [Documentation] If session does not acquire locks then get lock should return 299 ... empty lock records. 300 [Tags] Get_Empty_Lock_Records_For_Session_Where_No_Locks_Acquired 301 [Template] Verify No Locks Records For Session With No Acquired Lock 302 303 # client_id 304 HMCID-01 305 306 307Get Lock Records Empty For Invalid Session 308 [Documentation] Record of lock list is empty for invalid session. 309 [Tags] Get_Lock_Records_Empty_For_Invalid_Session 310 [Template] Verify Empty Lock Records For Invalid Session 311 312 # client_id 313 HMCID-01 314 315 316Get Lock Records For Multiple Session 317 [Documentation] Get lock records of multiple session. 318 [Tags] Get_Lock_Records_For_Multiple_Session 319 [Template] Verify Lock Records Of Multiple Session 320 321 # client_ids lock_type 322 HMCID-01,HMCID-02 ReadCase1,ReadCase1 323 324 325Get Lock Records For Multiple Invalid Session 326 [Documentation] Record of lock list is empty for list of invalid session. 327 [Tags] Get_Lock_Records_For_Multiple_Invalid_Session 328 [Template] Verify Lock Records For Multiple Invalid Session 329 330 # client_id 331 HMCID-01 332 333 334Get Lock Records For Multiple Invalid And Valid Session 335 [Documentation] Get record of lock from invalid and valid session. 336 [Tags] Get_Lock_Records_For_Multiple_Invalid_And_Valid_Session 337 [Template] Verify Lock Records For Multiple Invalid And Valid Session 338 339 # client_id lock_type 340 HMCID-01,HMCID-02 ReadCase1 341 342*** Keywords *** 343 344Create Redfish Session With ClientID 345 [Documentation] Create redifish session with client id. 346 [Arguments] ${client_id} 347 348 # Description of argument(s): 349 # client_id This client id can contain string value 350 # (e.g. 12345, "HMCID"). 351 352 ${session_info}= Create Dictionary 353 ${session}= Redfish Login kwargs="Oem":{"OpenBMC" : {"ClientID":"${client_id}"}} 354 355 Set To Dictionary ${session_info} SessionIDs ${session['Id']} 356 Set To Dictionary ${session_info} ClientID ${session["Oem"]["OpenBMC"]["ClientID"]} 357 358 [Return] ${session_info} 359 360 361RW General Dictionary 362 [Documentation] Create dictionary of lock request. 363 [Arguments] ${read_case} ${res_id} 364 365 # Description of argument(s): 366 # read_case Read or Write lock type. 367 # res_id Resource id. 368 369 ${request_dict}= Create Dictionary 370 371 FOR ${key} IN @{read_case.keys()} 372 Set To Dictionary ${request_dict} LockType ${key} 373 Set To Dictionary ${request_dict} SegmentFlags ${read_case["${key}"]} 374 END 375 376 Set To Dictionary ${request_dict} ResourceID ${res_id} 377 378 [Return] ${request_dict} 379 380 381Return Description Of Response 382 [Documentation] Return description of REST response. 383 [Arguments] ${resp_text} 384 385 # Description of argument(s): 386 # resp_text REST response body. 387 388 # resp_text after successful partition file upload looks like: 389 # { 390 # "Description": "File Created" 391 # } 392 393 ${message}= Evaluate json.loads('''${resp_text}''') json 394 395 [Return] ${message} 396 397 398Verify Redfish Session Deleted 399 [Documentation] Verify the redfish session is deleted. 400 [Arguments] ${session_info} 401 402 # Description of argument(s): 403 # session_info Session information are stored in dictionary. 404 405 # ${session_info} = { 406 # 'SessionIDs': 'XXXXXXXXX', 407 # 'ClientID': 'XXXXXX', 408 # 'SessionToken': 'XXXXXXXXX', 409 # 'SessionResp': session response from redfish login 410 # } 411 412 # SessionIDs : Session IDs 413 # ClientID : Client ID 414 # SessionToken : Session token 415 # SessionResp : Response of creating an redfish login session 416 417 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions 418 419 FOR ${session} IN @{sessions['Members']} 420 Should Not Be Equal As Strings 421 ... session ['/redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}'] 422 END 423 424 425Verify Redfish List Of Session Deleted 426 [Documentation] Verify all the list of redfish session is deleted. 427 [Arguments] ${session_info_list} 428 429 # Description of argument(s): 430 # session_info_list List contains individual session record are stored in dictionary. 431 432 # ${session_info_list} = [{ 433 # 'SessionIDs': 'XXXXXXXXX', 434 # 'ClientID': 'XXXXXX', 435 # 'SessionToken': 'XXXXXXXXX', 436 # 'SessionResp': session response from redfish login 437 # }] 438 439 # SessionIDs : Session IDs 440 # ClientID : Client ID 441 # SessionToken : Session token 442 # SessionResp : Response of creating an redfish login session 443 444 FOR ${session_record} IN @{session_info_list} 445 Verify Redfish Session Deleted ${session_record} 446 END 447 448 449Redfish Post Acquire Lock 450 [Documentation] Acquire and release lock. 451 [Arguments] ${lock_type} ${status_code}=${HTTP_OK} 452 453 # Description of argument(s): 454 # lock_type Read lock or Write lock. 455 # status_code HTTP status code. 456 457 ${lock_dict_param}= Form Data To Acquire Lock ${lock_type} 458 ${lock_dict_param}= Convert JSON To String ${lock_dict_param} 459 ${resp}= Redfish Post Request 460 ... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param} 461 ... expected_status=any 462 Should Be Equal As Strings ${resp.status_code} ${status_code} 463 464 Run Keyword If ${status_code} == ${HTTP_BAD_REQUEST} 465 ... Valid Value ${BAD_REQUEST} ['${resp.content}'] 466 ... ELSE 467 ... Run Keyword And Return Return Description Of Response ${resp.content} 468 469 [Return] ${resp} 470 471 472Redfish Post Acquire List Lock 473 [Documentation] Acquire and release lock. 474 [Arguments] ${lock_type} ${status_code}=${HTTP_OK} 475 476 # Description of argument(s): 477 # lock_type Read lock or Write lock. 478 # status_code HTTP status code. 479 480 ${lock_dict_param}= Create Data To Acquire List Of Lock ${lock_type} 481 ${lock_dict_param}= Convert JSON To String ${lock_dict_param} 482 ${resp}= Redfish Post Request 483 ... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param} 484 ... expected_status=any 485 Should Be Equal As Strings ${resp.status_code} ${status_code} 486 487 Run Keyword If ${status_code} == ${HTTP_CONFLICT} 488 ... Should Be Equal As Strings ${CONFLICT_RQUEST} ${resp.content} 489 ... ELSE 490 ... Run Keyword And Return Return Description Of Response ${resp.content} 491 492 [Return] ${resp} 493 494 495Redfish Post Acquire Invalid Lock 496 [Documentation] Redfish to post request to acquire in-valid lock. 497 [Arguments] ${lock_type} ${message} ${status_code}=${HTTP_OK} 498 499 # Description of argument(s): 500 # lock_type Read lock or Write lock. 501 # message Return message from URI. 502 # status_code HTTP status code. 503 504 ${lock_dict_param}= Form Data To Acquire Invalid Lock ${lock_type} 505 ${lock_dict_param}= Convert JSON To String ${lock_dict_param} 506 ${resp}= Redfish Post Request 507 ... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param} 508 Should Be Equal As Strings ${resp.status_code} ${status_code} 509 Run Keyword If '${message}' != '${EMPTY}' 510 ... Valid Value message ['${resp.content}'] 511 512 [Return] ${resp} 513 514 515Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID 516 [Documentation] Redfish to post request to acquire in-valid lock with invalid data type of resource id. 517 [Arguments] ${lock_type} ${status_code}=${HTTP_OK} 518 519 # Description of argument(s): 520 # lock_type Read lock or Write lock. 521 # status_code HTTP status code. 522 523 ${lock_dict_param}= 524 ... Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID ${lock_type} 525 ${lock_dict_param}= Convert JSON To String ${lock_dict_param} 526 ${resp}= Redfish Post Request 527 ... /ibm/v1/HMC/LockService/Actions/LockService.AcquireLock data=${lock_dict_param} 528 Should Be Equal As Strings ${resp.status_code} ${status_code} 529 530 [Return] ${resp} 531 532 533Form Data To Acquire Lock 534 [Documentation] Create a dictionary for lock request. 535 [Arguments] ${lock_type} 536 537 # Description of argument(s): 538 # lock_type Read lock or Write lock. 539 540 ${lock_res_info}= Get Lock Resource Information 541 ${resp}= RW General Dictionary 542 ... ${lock_res_info["Valid Case"]["${lock_type}"]} 543 ... ${lock_res_info["Valid Case"]["ResourceID"]} 544 ${temp_list}= Create List ${resp} 545 ${lock_request_dict}= Create Dictionary Request=${temp_list} 546 547 [Return] ${lock_request_dict} 548 549 550Create Data To Acquire List Of Lock 551 [Documentation] Create a dictionary for list of lock request. 552 [Arguments] ${lock_type_list} 553 554 # Description of argument(s): 555 # lock_type Read lock or Write lock. 556 557 ${temp_list}= Create List 558 ${lock_res_info}= Get Lock Resource Information 559 560 FOR ${lock_type} IN @{lock_type_list} 561 ${resp}= RW General Dictionary 562 ... ${lock_res_info["Valid Case"]["${lock_type}"]} 563 ... ${lock_res_info["Valid Case"]["ResourceID"]} 564 Append To List ${temp_list} ${resp} 565 END 566 567 ${lock_request_dict}= Create Dictionary Request=${temp_list} 568 569 [Return] ${lock_request_dict} 570 571 572Form Data To Acquire Invalid Lock With Invalid Data Type Of Resource ID 573 [Documentation] Create a dictionary for in-valid lock request. 574 [Arguments] ${lock_type} 575 576 # Description of argument(s): 577 # lock_type Read lock or Write lock. 578 579 ${lock_res_info}= Get Lock Resource Information 580 ${resp}= RW General Dictionary 581 ... ${lock_res_info["Valid Case"]["${lock_type}"]} 582 ... ${lock_res_info["Invalid Case"]["ResourceIDInvalidDataType"]} 583 ${temp_list}= Create List ${resp} 584 ${lock_request_dict}= Create Dictionary Request=${temp_list} 585 586 [Return] ${lock_request_dict} 587 588 589Form Data To Acquire Invalid Lock 590 [Documentation] Create a dictionary for in-valid lock request. 591 [Arguments] ${lock_type} 592 593 # Description of argument(s): 594 # lock_type Read lock or Write lock. 595 596 ${lock_res_info}= Get Lock Resource Information 597 ${resp}= RW General Dictionary 598 ... ${lock_res_info["Invalid Case"]["${lock_type}"]} 599 ... ${lock_res_info["Valid Case"]["ResourceID"]} 600 ${temp_list}= Create List ${resp} 601 ${lock_request_dict}= Create Dictionary Request=${temp_list} 602 603 [Return] ${lock_request_dict} 604 605 606Get Locks List On Resource 607 [Documentation] Get locks list. 608 [Arguments] ${session_info} ${exp_status_code}=${HTTP_OK} 609 610 # Description of argument(s): 611 # session_info Session information in dict. 612 # exp_status_code Expected HTTP status code. 613 614 ${data}= Set Variable {"SessionIDs": ["${session_info['SessionIDs']}"]} 615 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList 616 ... data=${data} 617 ${locks}= Evaluate json.loads('''${resp.text}''') json 618 619 [Return] ${locks["Records"]} 620 621 622Verify Lock On Resource 623 [Documentation] Verify lock on resource. 624 [Arguments] ${session_info} ${transaction_id} 625 626 # Description of argument(s): 627 # session_info Session information in dict. 628 # transaction_id Transaction id in list stored in dict. 629 630 ${sessions}= Redfish.Get Properties /redfish/v1/SessionService/Sessions/${session_info['SessionIDs']} 631 Rprint Vars sessions 632 ${lock_list}= Get Locks List On Resource ${session_info} 633 ${lock_length}= Get Length ${lock_list} 634 ${tran_id_length}= Get Length ${transaction_id} 635 Should Be Equal As Integers ${tran_id_length} ${lock_length} 636 637 FOR ${tran_id} ${lock} IN ZIP ${transaction_id} ${lock_list} 638 Valid Value session_info['ClientID'] ['${lock['HMCID']}'] 639 Valid Value session_info['SessionIDs'] ['${lock['SessionID']}'] 640 Should Be Equal As Integers ${tran_id['TransactionID']} ${lock['TransactionID']} 641 END 642 643 644Acquire Lock On Resource 645 [Documentation] Acquire lock on resource. 646 [Arguments] ${client_id} ${lock_type} ${reboot_flag}=False 647 648 # Description of argument(s): 649 # client_id This client id can contain string value 650 # (e.g. 12345, "HMCID"). 651 # lock_type Read lock or Write lock. 652 # reboot_flag Flag is used to run reboot the BMC code. 653 # (e.g. True or False). 654 655 ${trans_id_emptylist}= Create List 656 ${trans_id_list}= Create List 657 658 ${session_info}= Create Redfish Session With ClientID ${client_id} 659 ${trans_id}= Redfish Post Acquire Lock ${lock_type} 660 Append To List ${trans_id_list} ${trans_id} 661 662 Verify Lock On Resource ${session_info} ${trans_id_list} 663 664 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN} 665 666 Run Keyword If '${reboot_flag}' == 'True' 667 ... Run Keywords Redfish BMC Reset Operation AND 668 ... Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} AND 669 ... Wait Until Keyword Succeeds 3 min 10 sec Redfish BMC Match States match_state=Enabled AND 670 ... Is BMC Standby AND 671 ... Verify Lock On Resource ${session_info} ${trans_id_emptylist} 672 673 Run Keyword If '${reboot_flag}' == 'False' 674 ... Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK} 675 676 ${trans_id_emptylist}= Create List 677 Verify Lock On Resource ${session_info} ${trans_id_emptylist} 678 Redfish Delete Session ${session_info} 679 680 681Form Data To Release Lock 682 [Documentation] Create a dictonay to release lock. 683 [Arguments] ${trans_id_list} 684 685 # Description of argument(s): 686 # trans_id_list 687 688 @{tran_ids}= Create List 689 690 FOR ${item} IN @{trans_id_list} 691 Append To List ${tran_ids} ${item['TransactionID']} 692 END 693 694 [Return] ${tran_ids} 695 696 697Release Locks On Resource 698 [Documentation] Redfish request to release a lock. 699 [Arguments] ${session_info} ${trans_id_list} ${release_lock_type}=Transaction 700 ... ${status_code}=${HTTP_OK} 701 702 # Description of argument(s): 703 # session_info Session information in dict. 704 # trans_id_list Transaction id list. 705 # release_lock_type Release lock by Transaction, Session. 706 # status_code HTTP status code. 707 708 ${tran_ids}= Form Data To Release Lock ${trans_id_list} 709 ${data}= Set Variable {"Type": "${release_lock_type}", "TransactionIDs":${tran_ids}} 710 ${data}= Evaluate json.dumps(${data}) json 711 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock data=${data} 712 Should Be Equal As Strings ${resp.status_code} ${status_code} 713 714 715Release locks And Delete Session 716 [Documentation] Release locks and delete redfish session. 717 [Arguments] ${session_info} ${trans_id_list} 718 719 Release Locks On Resource ${session_info} ${trans_id_list} 720 721 ${trans_id_emptylist}= Create List 722 Verify Lock On Resource ${session_info} ${trans_id_emptylist} 723 724 Redfish Delete Session ${session_info} 725 726 727Acquire Lock On Another Lock 728 [Documentation] Acquire lock on another lock. 729 [Arguments] ${client_id} 730 731 # Description of argument(s): 732 # client_id This client id can contain string value 733 # (e.g. 12345, "HMCID"). 734 735 ${trans_id_list}= Create List 736 ${session_info}= Create Redfish Session With ClientID ${client_id} 737 738 ${trans_id}= Redfish Post Acquire Lock ReadCase1 739 Append To List ${trans_id_list} ${trans_id} 740 741 ${trans_id}= Redfish Post Acquire Lock ReadCase1 742 Append To List ${trans_id_list} ${trans_id} 743 744 Verify Lock On Resource ${session_info} ${trans_id_list} 745 746 Release locks And Delete Session ${session_info} ${trans_id_list} 747 748 749Verify Fail To Acquire Read And Write In Single Request 750 [Documentation] Verify fail to acquire read and write lock passed in single request. 751 [Arguments] ${client_id} ${lock_type} ${status_code} 752 753 # Description of argument(s): 754 # client_id This client id can contain string value 755 # (e.g. 12345, "HMCID"). 756 # lock_type Read lock or Write lock. 757 # status_code HTTP status code 758 759 ${lock_type_list}= Split String ${lock_type} , 760 761 ${session_info}= Create Redfish Session With ClientID ${client_id} 762 ${trans_id}= Redfish Post Acquire List Lock ${lock_type_list} status_code=${status_code} 763 Redfish Delete Session ${session_info} 764 765 766Verify Acquire Read In Single Request 767 [Documentation] Verify acquire read in single request. 768 [Arguments] ${client_id} ${lock_type} 769 770 # Description of argument(s): 771 # client_id This client id can contain string value 772 # (e.g. 12345, "HMCID"). 773 # lock_type Read lock or Write lock. 774 775 ${trans_id_list}= Create List 776 ${lock_type_list}= Split String ${lock_type} , 777 778 ${session_info}= Create Redfish Session With ClientID ${client_id} 779 ${trans_id}= Redfish Post Acquire List Lock ${lock_type_list} 780 Append To List ${trans_id_list} ${trans_id} 781 Append To List ${trans_id_list} ${trans_id} 782 783 Verify Lock On Resource ${session_info} ${trans_id_list} 784 Remove From List ${trans_id_list} 1 785 Release Locks On Resource ${session_info} ${trans_id_list} 786 787 Redfish Delete Session ${session_info} 788 789 790Verify Empty Lock Records For Invalid Session 791 [Documentation] Verify no lock record found for invalid session. 792 [Arguments] ${client_id} 793 794 # Description of argument(s): 795 # client_id This client id can contain string value 796 # (e.g. 12345, "HMCID"). 797 798 ${session_info1}= Create Redfish Session With ClientID ${client_id} 799 800 ${lock_list1}= Get Locks List On Resource ${session_info1} 801 ${lock_length1}= Get Length ${lock_list1} 802 803 ${session_info2}= Copy Dictionary ${session_info1} deepcopy=True 804 set to dictionary ${session_info2} SessionIDs xxyXyyYZZz 805 806 ${lock_list2}= Get Locks List On Resource ${session_info2} 807 ${lock_length2}= Get Length ${lock_list2} 808 809 Should Be Equal As Integers ${lock_length1} ${lock_length2} 810 811 Redfish Delete Session ${session_info1} 812 813 814Verify Acquire Lock Fails On Another Lock 815 [Documentation] Verify acquire lock on another lock fails. 816 [Arguments] ${client_id} ${lock_type} 817 818 # Description of argument(s): 819 # client_id This client id can contain string value 820 # (e.g. 12345, "HMCID"). 821 # lock_type Read lock or Write lock. 822 823 @{lock_type_list}= Split String ${lock_type} , 824 ${session_info}= Create Redfish Session With ClientID ${client_id} 825 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0] 826 827 ${trans_id_list}= Create List 828 Append To List ${trans_id_list} ${trans_id} 829 830 Verify Lock On Resource ${session_info} ${trans_id_list} 831 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1] status_code=${HTTP_CONFLICT} 832 833 Release locks And Delete Session ${session_info} ${trans_id_list} 834 835 836Verify Acquire Lock After Reboot 837 [Documentation] Acquire read and write lock after the reboot and release lock. 838 [Arguments] ${client_id} ${lock_type} 839 840 # Description of argument(s): 841 # client_id This client id can contain string value 842 # (e.g. 12345, "HMCID"). 843 # lock_type Read lock or Write lock. 844 845 ${trans_id_list}= Create List 846 ${session_info}= Create Session With ClientID ${client_id} 847 848 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN} 849 Redfish BMC Reset Operation 850 Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} 851 Wait Until Keyword Succeeds 3 min 10 sec Redfish BMC Match States match_state=Enabled 852 Is BMC Standby 853 854 ${trans_id}= Redfish Post Acquire Lock ${lock_type} 855 Append To List ${trans_id_list} ${trans_id} 856 Verify Lock On Resource ${session_info} ${trans_id_list} 857 858 Release locks And Delete Session ${session_info} ${trans_id_list} 859 860 861Verify Acquire Multiple Lock Request At CEC Level 862 [Documentation] Acquire lock in loop. 863 [Arguments] ${client_id} ${lock_type} 864 865 # Description of argument(s): 866 # client_id This client id can contain string value 867 # (e.g. 12345, "HMCID"). 868 # lock_type Read lock or Write lock. 869 870 ${trans_id_list}= Create List 871 @{lock_type_list}= Split String ${lock_type} , 872 ${session_info}= Create Redfish Session With ClientID ${client_id} 873 874 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0] 875 Append To List ${trans_id_list} ${trans_id} 876 877 Verify Lock On Resource ${session_info} ${trans_id_list} 878 879 Redfish Post Acquire Lock ${lock_type_list}[1] status_code=${HTTP_CONFLICT} 880 881 Release locks And Delete Session ${session_info} ${trans_id_list} 882 883 884Post Reboot Acquire Lock 885 [Documentation] Post reboot acquire lock and verify the transaction id is 1. 886 [Arguments] ${session_info} ${lock_type} 887 888 # Description of argument(s): 889 # session_info Session information. 890 # lock_type Read lock or Write lock. 891 892 ${trans_id_list}= Create List 893 ${trans_id_list_var}= Create List 894 ${trans_id}= Redfish Post Acquire Lock ${lock_type} 895 Append To List ${trans_id_list} ${trans_id} 896 Append To List ${trans_id_list_var} ${default_trans_id} 897 Verify Lock On Resource ${session_info} ${trans_id_list} 898 Verify Lock On Resource ${session_info} ${trans_id_list_var} 899 Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK} 900 ${trans_id_emptylist}= Create List 901 Verify Lock On Resource ${session_info} ${trans_id_emptylist} 902 903 904Verify Acquire And Release Lock In Loop 905 [Documentation] Acquire lock in loop. 906 [Arguments] ${client_id} ${lock_type} ${reboot_flag}=False 907 908 # Description of argument(s): 909 # client_id This client id can contain string value 910 # (e.g. 12345, "HMCID"). 911 # lock_type Read lock or Write lock. 912 # reboot_flag Flag is used to run reboot the BMC code. 913 # (e.g. True or False). 914 915 FOR ${count} IN RANGE 1 11 916 ${trans_id_list}= Create List 917 ${session_info}= Create Redfish Session With ClientID ${client_id} 918 ${trans_id}= Redfish Post Acquire Lock ${lock_type} 919 Append To List ${trans_id_list} ${trans_id} 920 Verify Lock On Resource ${session_info} ${trans_id_list} 921 Release Locks On Resource ${session_info} ${trans_id_list} Transaction ${HTTP_OK} 922 ${trans_id_emptylist}= Create List 923 Verify Lock On Resource ${session_info} ${trans_id_emptylist} 924 Redfish Delete Session ${session_info} 925 END 926 927 ${session_info}= Create Redfish Session With ClientID ${client_id} 928 ${before_reboot_xauth_token}= Set Variable ${XAUTH_TOKEN} 929 930 Run Keyword If '${reboot_flag}' == 'True' 931 ... Run Keywords Redfish BMC Reset Operation AND 932 ... Set Global Variable ${XAUTH_TOKEN} ${before_reboot_xauth_token} AND 933 ... Wait Until Keyword Succeeds 3 min 10 sec Redfish BMC Match States match_state=Enabled AND 934 ... Is BMC Standby AND 935 ... Post Reboot Acquire Lock ${session_info} ${lock_type} 936 Redfish Delete Session ${session_info} 937 938 939Acquire And Release Multiple Locks 940 [Documentation] Acquire mutilple locks on resource. 941 [Arguments] ${client_id} ${lock_type} ${release_lock_type} 942 943 # Description of argument(s): 944 # client_id This client id can contain string value 945 # (e.g. 12345, "HMCID"). 946 # lock_type Read lock or Write lock. 947 # release_lock_type The value can be Transaction or Session. 948 949 @{lock_type_list}= Split String ${lock_type} , 950 ${session_info}= Create Redfish Session With ClientID ${client_id} 951 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0] 952 953 ${trans_id_list}= Create List 954 955 Append To List ${trans_id_list} ${trans_id} 956 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1] 957 958 Append To List ${trans_id_list} ${trans_id} 959 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2] 960 961 Append To List ${trans_id_list} ${trans_id} 962 Verify Lock On Resource ${session_info} ${trans_id_list} 963 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=${release_lock_type} 964 965 ${trans_id_emptylist}= Create List 966 Verify Lock On Resource ${session_info} ${trans_id_emptylist} 967 Redfish Delete Session ${session_info} 968 969 970Verify Release Lock When Session Deleted 971 [Documentation] Verify lock get released when session are deleted. 972 [Arguments] ${client_id} ${lock_type} 973 974 # Description of argument(s): 975 # client_ids This client id can contain string value 976 # (e.g. 12345, "HMCID"). 977 # lock_type Read lock or Write lock. 978 979 ${trans_id_list}= Create List 980 @{lock_type_list}= Split String ${lock_type} , 981 982 ${pre_session_info}= Create Redfish Session With ClientID ${client_id} 983 984 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0] 985 Append To List ${trans_id_list} ${trans_id} 986 Verify Lock On Resource ${pre_session_info} ${trans_id_list} 987 988 Redfish Delete Session ${pre_session_info} 989 ${post_session_info}= Create Redfish Session With ClientID ${client_id} 990 ${resp}= Get Locks List On Resource With Session List ${pre_session_info} ${HTTP_BAD_REQUEST} 991 992 Redfish Delete Session ${post_session_info} 993 994 995 996Verify Fail To Release Lock With Invalid TransactionID 997 [Documentation] Verify fail to be release lock with invalid transaction ID. 998 [Arguments] ${client_id} ${lock_type} ${release_lock_type} 999 1000 # Description of argument(s): 1001 # client_id This client id can contain string value 1002 # (e.g. 12345, "HMCID"). 1003 # lock_type Read lock or Write lock. 1004 # release_lock_type The value can be Transaction or Session. 1005 1006 ${trans_id_list}= Create List 1007 @{lock_type_list}= Split String ${lock_type} , 1008 1009 ${session_info}= Create Redfish Session With ClientID ${client_id} 1010 1011 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0] 1012 ${value}= Get From Dictionary ${trans_id} TransactionID 1013 ${value}= Evaluate ${value} + 10 1014 Set To Dictionary ${trans_id} TransactionID ${value} 1015 Append To List ${trans_id_list} ${trans_id} 1016 1017 Release Locks On Resource 1018 ... ${session_info} ${trans_id_list} 1019 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST} 1020 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session 1021 1022 ${trans_id_emptylist}= Create List 1023 Verify Lock On Resource ${session_info} ${trans_id_emptylist} 1024 Redfish Delete Session ${session_info} 1025 1026 1027Verify Fail To Release Multiple Lock With Invalid TransactionID 1028 [Documentation] Verify release multiple locks with invalid transaction ID fails. 1029 [Arguments] ${client_id} ${lock_type} ${release_lock_type} 1030 1031 # Description of argument(s): 1032 # client_id This client id can contain string value 1033 # (e.g. 12345, "HMCID"). 1034 # lock_type Read lock or Write lock. 1035 # release_lock_type The value can be Transaction or Session. 1036 1037 ${trans_id_list}= Create List 1038 @{lock_type_list}= Split String ${lock_type} , 1039 1040 ${session_info}= Create Redfish Session With ClientID ${client_id} 1041 1042 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0] 1043 ${value}= Get From Dictionary ${trans_id} TransactionID 1044 ${value}= Evaluate ${value} + 10 1045 Set To Dictionary ${trans_id} TransactionID ${value} 1046 Append To List ${trans_id_list} ${trans_id} 1047 1048 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1] 1049 ${value}= Get From Dictionary ${trans_id} TransactionID 1050 ${value}= Evaluate ${value} + 10 1051 Set To Dictionary ${trans_id} TransactionID ${value} 1052 Append To List ${trans_id_list} ${trans_id} 1053 1054 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[2] 1055 ${value}= Get From Dictionary ${trans_id} TransactionID 1056 ${value}= Evaluate ${value} + 10 1057 Set To Dictionary ${trans_id} TransactionID ${value} 1058 Append To List ${trans_id_list} ${trans_id} 1059 1060 Release Locks On Resource 1061 ... ${session_info} ${trans_id_list} 1062 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST} 1063 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session 1064 1065 ${trans_id_emptylist}= Create List 1066 Verify Lock On Resource ${session_info} ${trans_id_emptylist} 1067 Redfish Delete Session ${session_info} 1068 1069 1070Verify Fail To Release Multiple Lock With Valid And Invalid TransactionID 1071 [Documentation] Verify fail to be release multiple lock with valid and invalid transaction ID. 1072 [Arguments] ${client_id} ${lock_type} ${release_lock_type} 1073 1074 # Description of argument(s): 1075 # client_id This client id can contain string value 1076 # (e.g. 12345, "HMCID"). 1077 # lock_type Read lock or Write lock. 1078 # release_lock_type The value can be Transaction or Session. 1079 1080 ${trans_id_list}= Create List 1081 @{lock_type_list}= Split String ${lock_type} , 1082 1083 ${session_info}= Create Redfish Session With ClientID ${client_id} 1084 1085 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0] 1086 Append To List ${trans_id_list} ${trans_id} 1087 1088 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1] 1089 ${value}= Get From Dictionary ${trans_id} TransactionID 1090 ${value}= Evaluate ${value} + 10 1091 Set To Dictionary ${trans_id} TransactionID ${value} 1092 Append To List ${trans_id_list} ${trans_id} 1093 1094 Release Locks On Resource 1095 ... ${session_info} ${trans_id_list} 1096 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST} 1097 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=Session 1098 1099 ${trans_id_emptylist}= Create List 1100 Verify Lock On Resource ${session_info} ${trans_id_emptylist} 1101 Redfish Delete Session ${session_info} 1102 1103 1104Verify Fail To Release Lock With TransactionID As String Type 1105 [Documentation] Verify fail to be release lock with transaction ID as string data type. 1106 [Arguments] ${client_id} ${lock_type} ${release_lock_type} 1107 1108 # Description of argument(s): 1109 # client_id This client id can contain string value 1110 # (e.g. 12345, "HMCID"). 1111 # lock_type Read lock or Write lock. 1112 # release_lock_type The value can be Transaction or Session. 1113 1114 ${trans_id_list}= Create List 1115 @{lock_type_list}= Split String ${lock_type} , 1116 1117 ${session_info}= Create Redfish Session With ClientID ${client_id} 1118 1119 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0] 1120 1121 Append To List ${trans_id_list} ${trans_id} 1122 1123 ${temp_trans_id_list}= Copy Dictionary ${trans_id_list} deepcopy=True 1124 1125 ${value}= Get From Dictionary ${trans_id_list}[0] TransactionID 1126 ${value}= Set Variable \'${value}\' 1127 Set To Dictionary ${temp_trans_id_list}[0] TransactionID ${value} 1128 1129 Release Locks On Resource 1130 ... ${session_info} ${temp_trans_id_list} 1131 ... release_lock_type=${release_lock_type} status_code=${HTTP_BAD_REQUEST} 1132 1133 Release Locks On Resource ${session_info} ${trans_id_list} release_lock_type=${release_lock_type} 1134 1135 ${trans_id_emptylist}= Create List 1136 Verify Lock On Resource ${session_info} ${trans_id_emptylist} 1137 Redfish Delete Session ${session_info} 1138 1139 1140Verify Fail To Release Lock For Another Session 1141 [Documentation] Verify failed to release the lock form another session. 1142 [Arguments] ${client_id} ${lock_type} 1143 1144 # Description of argument(s): 1145 # client_id This client id can contain string value 1146 # (e.g. 12345, "HMCID"). 1147 # lock_type Read lock or Write lock. 1148 1149 ${client_ids}= Split String ${client_id} , 1150 ${lock_type_list}= Split String ${lock_type} , 1151 ${trans_id_list1}= Create List 1152 ${trans_id_list2}= Create List 1153 1154 ${session_info1}= Create Redfish Session With ClientID ${client_ids}[0] 1155 1156 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0] 1157 Append To List ${trans_id_list1} ${trans_id} 1158 Verify Lock On Resource ${session_info1} ${trans_id_list1} 1159 1160 ${session_info2}= Create Redfish Session With ClientID ${client_ids}[1] 1161 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1] 1162 Append To List ${trans_id_list2} ${trans_id} 1163 Verify Lock On Resource ${session_info2} ${trans_id_list2} 1164 1165 Release Locks On Resource 1166 ... ${session_info1} ${trans_id_list1} Transaction status_code=${HTTP_BAD_REQUEST} 1167 Verify Lock On Resource ${session_info1} ${trans_id_list1} 1168 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Session 1169 Release Locks On Resource ${session_info2} ${trans_id_list2} release_lock_type=Session 1170 Redfish Delete Session ${session_info1} 1171 Redfish Delete Session ${session_info2} 1172 1173 1174Verify Fail To Acquire Lock For Invalid Resource ID Data Type 1175 [Documentation] Verify fail to acquire the lock with invalid resource id data type. 1176 [Arguments] ${client_id} ${lock_type} 1177 1178 # Description of argument(s): 1179 # client_id This client id can contain string value 1180 # (e.g. 12345, "HMCID"). 1181 # lock_type Read lock or Write lock. 1182 1183 ${session_info}= Create Redfish Session With ClientID ${client_id} 1184 Redfish Post Acquire Invalid Lock With Invalid Data Type Of Resource ID 1185 ... ${lock_type} status_code=${HTTP_BAD_REQUEST} 1186 Redfish Delete Session ${session_info} 1187 1188 1189Verify Fail To Acquire Lock For Invalid Lock Data 1190 [Documentation] Verify fail to acquired lock with invalid lock types, lock flags, segment flags. 1191 [Arguments] ${client_id} ${lock_type} ${message} 1192 1193 # Description of argument(s): 1194 # client_id This client id can contain string value 1195 # (e.g. 12345, "HMCID"). 1196 # lock_type Read lock or Write lock. 1197 # message Return message from URI. 1198 1199 ${session_info}= Create Redfish Session With ClientID ${client_id} 1200 ${trans_id}= Redfish Post Acquire Invalid Lock 1201 ... ${lock_type} message=${message} status_code=${HTTP_BAD_REQUEST} 1202 Redfish Delete Session ${session_info} 1203 1204 1205Verify No Locks Records For Session With No Acquired Lock 1206 [Documentation] Verify no records found for a session where no lock is acquired. 1207 [Arguments] ${client_id} 1208 1209 # Description of argument(s): 1210 # client_id This client id can contain string value 1211 # (e.g. 12345, "HMCID"). 1212 1213 ${session_info}= Create Redfish Session With ClientID ${client_id} 1214 ${trans_id_emptylist}= Create List 1215 Verify Lock On Resource ${session_info} ${trans_id_emptylist} 1216 Redfish Delete Session ${session_info} 1217 1218 1219Create List Of Session ID 1220 [Documentation] Create session id list from session dict info. 1221 [Arguments] ${session_dict_info} 1222 1223 # Description of argument(s): 1224 # session_dict_info Session information in dict. 1225 1226 @{session_id_list}= Create List 1227 1228 FOR ${session} IN @{session_dict_info} 1229 Append To List ${session_id_list} ${session["SessionIDs"]} 1230 END 1231 1232 ${num_id}= Get Length ${session_id_list} 1233 Should Not Be Equal As Integers ${num_id} ${0} 1234 1235 ${session_id_list}= Evaluate json.dumps(${session_id_list}) json 1236 1237 [Return] ${session_id_list} 1238 1239 1240Get Locks List On Resource With Session List 1241 [Documentation] Get locks list from session of list. 1242 [Arguments] ${session_id_list} ${exp_status_code}=${HTTP_OK} 1243 1244 # Description of argument(s): 1245 # session_id_list Session ids list. 1246 # exp_status_code Expected HTTP status code. 1247 1248 ${resp}= Redfish Post Request /ibm/v1/HMC/LockService/Actions/LockService.GetLockList 1249 ... data={"SessionIDs":${session_id_list}} expected_status=any 1250 Should Be Equal As Strings ${resp.status_code} ${exp_status_code} 1251 ${locks}= Evaluate json.loads('''${resp.text}''') json 1252 1253 [Return] ${locks} 1254 1255 1256Verify List Of Session Lock On Resource 1257 [Documentation] Verify list of lock record from list of sessions. 1258 [Arguments] ${session_dict_info} ${transaction_id_list} 1259 1260 # Description of argument(s): 1261 # session_dict_info Session information in dict. 1262 # transaction_id_list Transaction id in list stored in dict. 1263 1264 ${session_id_list}= Create List Of Session ID ${session_dict_info} 1265 ${lock_list_resp}= Get Locks List On Resource With Session List ${session_id_list} 1266 ${lock_list}= Set Variable ${lock_list_resp['Records']} 1267 1268 FOR ${session_id} ${tran_id} ${lock_record} IN ZIP 1269 ... ${session_dict_info} ${transaction_id_list} ${lock_list} 1270 Valid Value session_id['SessionIDs'] ['${lock_record['SessionID']}'] 1271 Should Be Equal As Integers ${tran_id['TransactionID']} ${lock_record['TransactionID']} 1272 END 1273 1274 1275Verify Lock Records Of Multiple Session 1276 [Documentation] Verify all records found for a multiple sessions. 1277 [Arguments] ${client_ids} ${lock_type} 1278 1279 # Description of argument(s): 1280 # client_ids This client id can contain string value 1281 # (e.g. 12345, "HMCID"). 1282 # lock_type Read lock or Write lock. 1283 1284 ${client_id_list}= Split String ${client_ids} , 1285 ${lock_type_list}= Split String ${lock_type} , 1286 ${trans_id_list1}= Create List 1287 ${trans_id_list2}= Create List 1288 1289 ${session_dict_list}= Create List 1290 ${lock_list}= Create List 1291 1292 ${client_id1}= Create List 1293 Append To List ${client_id1} ${client_id_list}[0] 1294 ${session_info1}= Create Session With List Of ClientID ${client_id1} 1295 Append To List ${session_dict_list} ${session_info1}[0] 1296 Verify A Session Created With ClientID ${client_id1} ${session_info1} 1297 1298 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0] 1299 Append To List ${trans_id_list1} ${trans_id} 1300 Append To List ${lock_list} ${trans_id} 1301 Verify Lock On Resource ${session_info1}[0] ${trans_id_list1} 1302 1303 1304 ${client_id2}= Create List 1305 Append To List ${client_id2} ${client_id_list}[1] 1306 ${session_info2}= Create Session With List Of ClientID ${client_id2} 1307 Append To List ${session_dict_list} ${session_info2}[0] 1308 Verify A Session Created With ClientID ${client_id2} ${session_info2} 1309 1310 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[1] 1311 Append To List ${trans_id_list2} ${trans_id} 1312 Append To List ${lock_list} ${trans_id} 1313 Verify Lock On Resource ${session_info2}[0] ${trans_id_list2} 1314 1315 Verify List Of Session Lock On Resource ${session_dict_list} ${lock_list} 1316 1317 ${session_token}= Get From Dictionary ${session_info1}[0] SessionToken 1318 Set Global Variable ${XAUTH_TOKEN} ${session_token} 1319 1320 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Transaction 1321 1322 ${session_token}= Get From Dictionary ${session_info2}[0] SessionToken 1323 Set Global Variable ${XAUTH_TOKEN} ${session_token} 1324 1325 Release Locks On Resource ${session_info2} ${trans_id_list2} release_lock_type=Transaction 1326 1327 ${trans_id_emptylist}= Create List 1328 Verify Lock On Resource ${session_info1}[0] ${trans_id_emptylist} 1329 Verify Lock On Resource ${session_info2}[0] ${trans_id_emptylist} 1330 1331 Redfish Delete List Of Session ${session_dict_list} 1332 1333 1334Verify Lock Records For Multiple Invalid Session 1335 [Documentation] Verify no lock record found for multiple invalid session. 1336 [Arguments] ${client_id} 1337 1338 # Description of argument(s): 1339 # client_id This client id can contain string value 1340 # (e.g. 12345, "HMCID"). 1341 1342 ${session_dict_list}= Create List 1343 ${invalid_session_ids}= Create List xxyXyyYZZz xXyXYyYZzz 1344 1345 ${session_info1}= Create Session With ClientID ${client_id} 1346 1347 ${session_info2}= Copy Dictionary ${session_info1} deepcopy=True 1348 set to dictionary ${session_info2} SessionIDs ${invalid_session_ids}[0] 1349 Append To List ${session_dict_list} ${session_info2} 1350 1351 ${session_info3}= Copy Dictionary ${session_info1} deepcopy=True 1352 set to dictionary ${session_info3} SessionIDs ${invalid_session_ids}[0] 1353 Append To List ${session_dict_list} ${session_info3} 1354 1355 ${lock_list1}= Get Locks List On Resource ${session_info1} 1356 ${lock_length1}= Get Length ${lock_list1} 1357 1358 ${session_id_list}= Create List Of Session ID ${session_dict_list} 1359 ${lock_list_resp}= Get Locks List On Resource With Session List ${session_id_list} 1360 ${lock_length2}= Get Length ${lock_list_resp['Records']} 1361 1362 Should Be Equal As Integers ${lock_length1} ${lock_length2} 1363 1364 Redfish Delete Session ${session_info1} 1365 1366 1367Verify Lock Records For Multiple Invalid And Valid Session 1368 [Documentation] Verify all records found for a valid and invalid sessions. 1369 [Arguments] ${client_ids} ${lock_type} 1370 1371 # Description of argument(s): 1372 # client_ids This client id can contain string value 1373 # (e.g. 12345, "HMCID"). 1374 # lock_type Read lock or Write lock. 1375 1376 ${client_id_list}= Split String ${client_ids} , 1377 ${lock_type_list}= Split String ${lock_type} , 1378 ${trans_id_list1}= Create List 1379 ${invalid_session_ids}= Create List xxyXyyYZZz 1380 1381 ${session_dict_list}= Create List 1382 ${lock_list}= Create List 1383 1384 ${client_id1}= Create List 1385 Append To List ${client_id1} ${client_id_list}[0] 1386 ${session_info1}= Create Session With List Of ClientID ${client_id1} 1387 Append To List ${session_dict_list} ${session_info1}[0] 1388 Verify A Session Created With ClientID ${client_id1} ${session_info1} 1389 1390 ${trans_id}= Redfish Post Acquire Lock ${lock_type_list}[0] 1391 Append To List ${trans_id_list1} ${trans_id} 1392 Append To List ${lock_list} ${trans_id} 1393 Verify Lock On Resource ${session_info1}[0] ${trans_id_list1} 1394 1395 ${session_info2}= Copy Dictionary ${session_info1} deepcopy=True 1396 set to dictionary ${session_info2}[0] SessionIDs ${invalid_session_ids}[0] 1397 Append To List ${session_dict_list} ${session_info2}[0] 1398 1399 Verify List Of Session Lock On Resource ${session_dict_list} ${lock_list} 1400 1401 ${session_token}= Get From Dictionary ${session_info1}[0] SessionToken 1402 Set Global Variable ${XAUTH_TOKEN} ${session_token} 1403 1404 Release Locks On Resource ${session_info1} ${trans_id_list1} release_lock_type=Transaction 1405 1406 ${trans_id_emptylist}= Create List 1407 Verify Lock On Resource ${session_info1}[0] ${trans_id_emptylist} 1408 1409 Redfish Delete Session ${session_info1}[0] 1410 1411 1412Delete All Redfish and HMC Sessions 1413 [Documentation] Delete all active redfish sessions. 1414 1415 ${saved_session_info}= Get Redfish Session Info 1416 1417 ${resp_list}= Redfish_Utils.Get Member List 1418 ... /redfish/v1/SessionService/Sessions 1419 1420 # Remove the current login session from the list. 1421 Remove Values From List ${resp_list} ${saved_session_info["location"]} 1422 1423 FOR ${session} IN @{resp_list} 1424 Run Keyword And Ignore Error Redfish.Delete ${session} 1425 END 1426 1427 1428Restart Bmcweb On Failure 1429 [Documentation] Restart bmcweb only if test failed. 1430 1431 Return From Keyword If "${TEST_STATUS}" == "PASS" 1432 1433 # This procedure is needs to be corrected or removed, when we figure out 1434 # what is causing the real failure here. 1435 1436 Log To Console Likely ConnectionResetError: Restarting bmcweb 1437 1438 ${stdout} ${stderr} ${rc}= BMC Execute Command 1439 ... systemctl restart bmcweb print_out=1 1440 1441 Should Be Empty ${stderr} 1442 1443 Sleep 10s reason=Wait for service to restart properly. 1444