Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test BMC manager time functionality. |
| 3 | Resource ../../lib/resource.robot |
| 4 | Resource ../../lib/bmc_redfish_resource.robot |
| 5 | Resource ../../lib/common_utils.robot |
| 6 | Resource ../../lib/openbmc_ffdc.robot |
| 7 | Resource ../../lib/utils.robot |
| 8 | |
| 9 | Test Setup Run Keywords Printn AND redfish.Login |
| 10 | Test Teardown Test Teardown Execution |
| 11 | |
| 12 | *** Variables *** |
| 13 | ${max_time_diff_in_seconds} 6 |
| 14 | |
| 15 | *** Test Cases *** |
| 16 | |
| 17 | Verify Redfish BMC Time |
| 18 | [Documentation] Verify that date/time obtained via redfish matches |
| 19 | ... date/time obtained via BMC command line. |
| 20 | [Tags] Verify_Redfish_BMC_Time |
| 21 | |
| 22 | ${redfish_date_time}= Redfish Get DateTime |
| 23 | ${cli_date_time}= CLI Get BMC DateTime |
| 24 | ${time_diff}= Subtract Date From Date ${cli_date_time} |
| 25 | ... ${redfish_date_time} |
| 26 | ${time_diff}= Evaluate abs(${time_diff}) |
| 27 | Rprint Vars redfish_date_time cli_date_time time_diff |
| 28 | Should Be True ${time_diff} < ${max_time_diff_in_seconds} |
| 29 | ... The difference between Redfish time and CLI time exceeds the allowed time difference. |
| 30 | |
| 31 | |
Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 32 | Verify Set Time Using Redfish |
| 33 | [Documentation] Verify set time using redfish API. |
| 34 | [Tags] Verify_Set_Time_Using_Redfish |
| 35 | |
| 36 | ${old_bmc_time}= CLI Get BMC DateTime |
| 37 | # Add 3 days to current date. |
| 38 | ${new_bmc_time}= Add Time to Date ${old_bmc_time} 3 Days |
| 39 | Redfish Set DateTime ${new_bmc_time} |
| 40 | ${cli_bmc_time}= CLI Get BMC DateTime |
| 41 | ${time_diff}= Subtract Date From Date ${cli_bmc_time} |
| 42 | ... ${new_bmc_time} |
| 43 | ${time_diff}= Evaluate abs(${time_diff}) |
| 44 | Rprint Vars old_bmc_time new_bmc_time cli_bmc_time time_diff max_time_diff_in_seconds |
| 45 | Should Be True ${time_diff} < ${max_time_diff_in_seconds} |
| 46 | ... The difference between Redfish time and CLI time exceeds the allowed time difference. |
| 47 | # Setting back to old bmc time. |
| 48 | Redfish Set DateTime ${old_bmc_time} |
| 49 | |
| 50 | |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 51 | *** Keywords *** |
| 52 | |
| 53 | Test Teardown Execution |
| 54 | [Documentation] Do the post test teardown. |
| 55 | |
| 56 | FFDC On Test Case Fail |
| 57 | redfish.Logout |
| 58 | |
| 59 | |
| 60 | Redfish Get DateTime |
| 61 | [Documentation] Returns BMC Datetime value from Redfish. |
| 62 | |
| 63 | ${date_time}= Redfish.Get Attribute ${REDFISH_BASE_URI}Managers/bmc DateTime |
| 64 | [Return] ${date_time} |
Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 65 | |
| 66 | |
| 67 | Redfish Set DateTime |
| 68 | [Documentation] Set DateTime using Redfish. |
| 69 | [Arguments] ${date_time} |
| 70 | # Description of argument(s): |
| 71 | # date_time New time to set for BMC (eg. 2019-06-30 09:21:28). |
| 72 | |
| 73 | ${payload}= Create Dictionary DateTime=${date_time} |
| 74 | Redfish.Patch ${REDFISH_BASE_URI}Managers/bmc body=&{payload} |
| 75 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_BAD_REQUEST}] |
| 76 | |
| 77 | |