1*** Settings *** 2Documentation Test BMC manager time functionality. 3Resource ../../lib/resource.robot 4Resource ../../lib/bmc_redfish_resource.robot 5Resource ../../lib/common_utils.robot 6Resource ../../lib/openbmc_ffdc.robot 7Resource ../../lib/utils.robot 8Resource ../../lib/rest_client.robot 9 10Test Setup Run Keywords Printn AND redfish.Login 11Test Teardown Test Teardown Execution 12 13*** Variables *** 14${max_time_diff_in_seconds} 6 15${invalid_datetime} "2019-04-251T12:24:46+00:00" 16${ntp_server_1} "9.9.9.9" 17${ntp_server_2} "2.2.3.3" 18 19*** Test Cases *** 20 21Verify Redfish BMC Time 22 [Documentation] Verify that date/time obtained via redfish matches 23 ... date/time obtained via BMC command line. 24 [Tags] Verify_Redfish_BMC_Time 25 26 ${redfish_date_time}= Redfish Get DateTime 27 ${cli_date_time}= CLI Get BMC DateTime 28 ${time_diff}= Subtract Date From Date ${cli_date_time} 29 ... ${redfish_date_time} 30 ${time_diff}= Evaluate abs(${time_diff}) 31 Rprint Vars redfish_date_time cli_date_time time_diff 32 Should Be True ${time_diff} < ${max_time_diff_in_seconds} 33 ... The difference between Redfish time and CLI time exceeds the allowed time difference. 34 35 36Verify Set Time Using Redfish 37 [Documentation] Verify set time using redfish API. 38 [Tags] Verify_Set_Time_Using_Redfish 39 40 Rest Set Time Owner 41 42 ${old_bmc_time}= CLI Get BMC DateTime 43 # Add 3 days to current date. 44 ${new_bmc_time}= Add Time to Date ${old_bmc_time} 3 Days 45 Redfish Set DateTime ${new_bmc_time} 46 ${cli_bmc_time}= CLI Get BMC DateTime 47 ${time_diff}= Subtract Date From Date ${cli_bmc_time} 48 ... ${new_bmc_time} 49 ${time_diff}= Evaluate abs(${time_diff}) 50 Rprint Vars old_bmc_time new_bmc_time cli_bmc_time time_diff max_time_diff_in_seconds 51 Should Be True ${time_diff} < ${max_time_diff_in_seconds} 52 ... The difference between Redfish time and CLI time exceeds the allowed time difference. 53 # Setting back to old bmc time. 54 Redfish Set DateTime ${old_bmc_time} 55 56 57Verify Set DateTime With Invalid Data Using Redfish 58 [Documentation] Verify error while setting invalid DateTime using Redfish. 59 [Tags] Verify_Set_DateTime_With_Invalid_Data_Using_Redfish 60 61 Redfish Set DateTime ${invalid_datetime} valid_status_codes=[${HTTP_BAD_REQUEST}] 62 63 64Verify NTP Server Set 65 [Documentation] Verify NTP server set. 66 [Tags] Verify_NTP_Server_Set 67 68 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']} 69 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI} 70 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} 71 ... msg=NTP server value ${ntp_server_1} not stored. 72 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_2} 73 ... msg=NTP server value ${ntp_server_2} not stored. 74 75 76Verify NTP Server Value Not Duplicated 77 [Documentation] Verify NTP servers value not same for both primary and secondary server. 78 [Tags] Verify_NTP_Server_Value_Not_Duplicated 79 80 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_1}']} 81 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI} 82 Should Contain X Times ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} 1 83 ... msg=NTP primary and secondary server values should not be same. 84 85 86Verify NTP Server Setting Persist After BMC Reboot 87 [Documentation] Verify NTP server setting persist after BMC reboot. 88 [Tags] Verify_NTP_Server_Setting_Persist_After_BMC_Reboot 89 90 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']} 91 Redfish OBMC Reboot (off) 92 Redfish.Login 93 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI} 94 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} 95 ... msg=NTP server value ${ntp_server_1} not stored. 96 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_2} 97 ... msg=NTP server value ${ntp_server_2} not stored. 98 Redfish.Logout 99 100 101*** Keywords *** 102 103Test Teardown Execution 104 [Documentation] Do the post test teardown. 105 106 FFDC On Test Case Fail 107 redfish.Logout 108 109 110Redfish Get DateTime 111 [Documentation] Returns BMC Datetime value from Redfish. 112 113 ${date_time}= Redfish.Get Attribute ${REDFISH_BASE_URI}Managers/bmc DateTime 114 [Return] ${date_time} 115 116 117Redfish Set DateTime 118 [Documentation] Set DateTime using Redfish. 119 [Arguments] ${date_time} &{kwargs} 120 # Description of argument(s): 121 # date_time New time to set for BMC (eg. 122 # "2019-06-30 09:21:28"). 123 # kwargs Additional parms to be passed directly to 124 # th Redfish.Patch function. A good use for 125 # this is when testing a bad date-time, the 126 # caller can specify 127 # valid_status_codes=[${HTTP_BAD_REQUEST}]. 128 129 Redfish.Patch ${REDFISH_BASE_URI}Managers/bmc body={'DateTime': '${date_time}'} 130 ... &{kwargs} 131 132 133Rest Set Time Owner 134 [Documentation] Set time owner of the system via REST. 135 136 # BMC_OWNER is defined in variable.py. 137 ${data}= Create Dictionary data=${BMC_OWNER} 138 Write Attribute ${TIME_MANAGER_URI}owner TimeOwner data=${data} verify=${TRUE} 139 140