1*** Settings *** 2Documentation Test BMC manager time functionality. 3Resource ../../lib/openbmc_ffdc.robot 4Resource ../../lib/bmc_date_and_time_utils.robot 5 6Test Setup Printn 7Test Teardown Test Teardown Execution 8Suite Setup Suite Setup Execution 9Suite Teardown Suite Teardown Execution 10 11Test Tags Managers_BMC_Time 12 13*** Variables *** 14 15${max_time_diff_in_seconds} 6 16# The "offset" consists of the value "26" specified for hours. Redfish will 17# convert that to the next day + 2 hours. 18${date_time_with_offset} 2019-04-25T26:24:46+00:00 19${expected_date_time} 2019-04-26T02:24:46+00:00 20${invalid_datetime} "2019-04-251T12:24:46+00:00" 21 22*** Test Cases *** 23 24Verify Redfish BMC Time 25 [Documentation] Verify that date/time obtained via redfish matches 26 ... date/time obtained via BMC command line. 27 [Tags] Verify_Redfish_BMC_Time 28 29 ${redfish_date_time}= Redfish Get DateTime 30 ${cli_date_time}= CLI Get BMC DateTime 31 ${time_diff}= Subtract Date From Date ${cli_date_time} 32 ... ${redfish_date_time} 33 ${time_diff}= Evaluate abs(${time_diff}) 34 Rprint Vars redfish_date_time cli_date_time time_diff 35 Should Be True ${time_diff} < ${max_time_diff_in_seconds} 36 ... The difference between Redfish time and CLI time exceeds the allowed time difference. 37 38 39Verify Set Time Using Redfish 40 [Documentation] Verify set time using redfish API. 41 [Tags] Verify_Set_Time_Using_Redfish 42 43 Set Time To Manual Mode 44 45 ${old_bmc_time}= CLI Get BMC DateTime 46 # Add 3 days to current date. 47 ${new_bmc_time}= Add Time to Date ${old_bmc_time} 3 Days 48 Redfish Set DateTime ${new_bmc_time} 49 ${cli_bmc_time}= CLI Get BMC DateTime 50 ${time_diff}= Subtract Date From Date ${cli_bmc_time} 51 ... ${new_bmc_time} 52 ${time_diff}= Evaluate abs(${time_diff}) 53 Rprint Vars old_bmc_time new_bmc_time cli_bmc_time time_diff max_time_diff_in_seconds 54 Should Be True ${time_diff} < ${max_time_diff_in_seconds} 55 ... The difference between Redfish time and CLI time exceeds the allowed time difference. 56 # Setting back to old bmc time. 57 Redfish Set DateTime ${old_bmc_time} 58 59 60Verify Set DateTime With Offset Using Redfish 61 [Documentation] Verify set DateTime with offset using redfish API. 62 [Tags] Verify_Set_DateTime_With_Offset_Using_Redfish 63 [Teardown] Run Keywords Redfish Set DateTime AND FFDC On Test Case Fail 64 65 Redfish Set DateTime ${date_time_with_offset} 66 ${cli_bmc_time}= CLI Get BMC DateTime 67 68 ${date_time_diff}= Subtract Date From Date ${cli_bmc_time} 69 ... ${expected_date_time} exclude_millis=yes 70 ${date_time_diff}= Convert to Integer ${date_time_diff} 71 Rprint Vars date_time_with_offset expected_date_time cli_bmc_time 72 ... date_time_diff max_time_diff_in_seconds 73 Valid Range date_time_diff 0 ${max_time_diff_in_seconds} 74 75 76Verify Set DateTime With Invalid Data Using Redfish 77 [Documentation] Verify error while setting invalid DateTime using Redfish. 78 [Tags] Verify_Set_DateTime_With_Invalid_Data_Using_Redfish 79 80 Redfish Set DateTime ${invalid_datetime} valid_status_codes=[${HTTP_BAD_REQUEST}] 81 82 83Verify DateTime Persists After Reboot 84 [Documentation] Verify date persists after BMC reboot. 85 [Tags] Verify_DateTime_Persists_After_Reboot 86 87 # Synchronize BMC date/time to local system date/time. 88 ${local_system_time}= Get Current Date 89 Redfish Set DateTime ${local_system_time} 90 Redfish OBMC Reboot (off) 91 Redfish.Login 92 ${bmc_time}= CLI Get BMC DateTime 93 ${local_system_time}= Get Current Date 94 ${time_diff}= Subtract Date From Date ${bmc_time} 95 ... ${local_system_time} 96 ${time_diff}= Evaluate abs(${time_diff}) 97 Rprint Vars local_system_time bmc_time time_diff max_time_diff_in_seconds 98 Should Be True ${time_diff} < ${max_time_diff_in_seconds} 99 ... The difference between Redfish time and CLI time exceeds the allowed time difference. 100 101 102Verify Immediate Consumption Of BMC Date 103 [Documentation] Verify immediate change in BMC date time. 104 [Tags] Verify_Immediate_Consumption_Of_BMC_Date 105 [Setup] Run Keywords Set Time To Manual Mode AND 106 ... Redfish Set DateTime valid_status_codes=[${HTTP_OK}] 107 [Teardown] Run Keywords FFDC On Test Case Fail AND 108 ... Redfish Set DateTime valid_status_codes=[${HTTP_OK}] 109 [Template] Set BMC Date And Verify 110 111 # host_state 112 on 113 off 114 115 116 117*** Keywords *** 118 119 120Test Teardown Execution 121 [Documentation] Do the post test teardown. 122 123 FFDC On Test Case Fail 124 125 126Suite Setup Execution 127 [Documentation] Do the suite level setup. 128 129 Printn 130 Redfish.Login 131 Get NTP Initial Status 132 ${old_date_time}= CLI Get BMC DateTime 133 ${year_status}= Run Keyword And Return Status Should Not Contain ${old_date_time} ${year_without_ntp} 134 Run Keyword If ${year_status} == False 135 ... Enable NTP And Add NTP Address 136 Set Time To Manual Mode 137 138 139Suite Teardown Execution 140 [Documentation] Do the suite level teardown. 141 142 Set Time To Manual Mode 143 Restore NTP Status 144 Redfish.Logout 145