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 8 9Test Setup Run Keywords Printn AND redfish.Login 10Test Teardown Test Teardown Execution 11 12*** Variables *** 13${max_time_diff_in_seconds} 6 14${invalid_datetime} "2019-04-251T12:24:46+00:00" 15${ntp_server_1} "9.9.9.9" 16${ntp_server_2} "2.2.3.3" 17 18*** Test Cases *** 19 20Verify Redfish BMC Time 21 [Documentation] Verify that date/time obtained via redfish matches 22 ... date/time obtained via BMC command line. 23 [Tags] Verify_Redfish_BMC_Time 24 25 ${redfish_date_time}= Redfish Get DateTime 26 ${cli_date_time}= CLI Get BMC DateTime 27 ${time_diff}= Subtract Date From Date ${cli_date_time} 28 ... ${redfish_date_time} 29 ${time_diff}= Evaluate abs(${time_diff}) 30 Rprint Vars redfish_date_time cli_date_time time_diff 31 Should Be True ${time_diff} < ${max_time_diff_in_seconds} 32 ... The difference between Redfish time and CLI time exceeds the allowed time difference. 33 34 35Verify Set Time Using Redfish 36 [Documentation] Verify set time using redfish API. 37 [Tags] Verify_Set_Time_Using_Redfish 38 39 ${old_bmc_time}= CLI Get BMC DateTime 40 # Add 3 days to current date. 41 ${new_bmc_time}= Add Time to Date ${old_bmc_time} 3 Days 42 Redfish Set DateTime ${new_bmc_time} 43 ${cli_bmc_time}= CLI Get BMC DateTime 44 ${time_diff}= Subtract Date From Date ${cli_bmc_time} 45 ... ${new_bmc_time} 46 ${time_diff}= Evaluate abs(${time_diff}) 47 Rprint Vars old_bmc_time new_bmc_time cli_bmc_time time_diff max_time_diff_in_seconds 48 Should Be True ${time_diff} < ${max_time_diff_in_seconds} 49 ... The difference between Redfish time and CLI time exceeds the allowed time difference. 50 # Setting back to old bmc time. 51 Redfish Set DateTime ${old_bmc_time} 52 53 54Verify Set DateTime With Invalid Data Using Redfish 55 [Documentation] Verify error while setting invalid DateTime using Redfish. 56 [Tags] Verify_Set_DateTime_With_Invalid_Data_Using_Redfish 57 58 Redfish Set DateTime ${invalid_datetime} valid_status_codes=[${HTTP_BAD_REQUEST}] 59 60 61Verify NTP Server Set 62 [Documentation] Verify NTP server set. 63 [Tags] Verify_NTP_Server_Set 64 65 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']} 66 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI} 67 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} 68 ... msg=NTP server value ${ntp_server_1} not stored. 69 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_2} 70 ... msg=NTP server value ${ntp_server_2} not stored. 71 72 73Verify NTP Server Value Not Duplicated 74 [Documentation] Verify NTP servers value not same for both primary and secondary server. 75 [Tags] Verify_NTP_Server_Value_Not_Duplicated 76 77 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_1}']} 78 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI} 79 Should Contain X Times ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} 1 80 ... msg=NTP primary and secondary server values should not be same. 81 82 83*** Keywords *** 84 85Test Teardown Execution 86 [Documentation] Do the post test teardown. 87 88 FFDC On Test Case Fail 89 redfish.Logout 90 91 92Redfish Get DateTime 93 [Documentation] Returns BMC Datetime value from Redfish. 94 95 ${date_time}= Redfish.Get Attribute ${REDFISH_BASE_URI}Managers/bmc DateTime 96 [Return] ${date_time} 97 98 99Redfish Set DateTime 100 [Documentation] Set DateTime using Redfish. 101 [Arguments] ${date_time} &{kwargs} 102 # Description of argument(s): 103 # date_time New time to set for BMC (eg. 104 # "2019-06-30 09:21:28"). 105 # kwargs Additional parms to be passed directly to 106 # th Redfish.Patch function. A good use for 107 # this is when testing a bad date-time, the 108 # caller can specify 109 # valid_status_codes=[${HTTP_BAD_REQUEST}]. 110 111 Redfish.Patch ${REDFISH_BASE_URI}Managers/bmc body={'DateTime': '${date_time}'} 112 ... &{kwargs} 113