1*** Settings *** 2Documentation NTP configuration and verification 3 ... tests. 4 5Resource ../../lib/openbmc_ffdc.robot 6Resource ../../lib/bmc_date_and_time_utils.robot 7 8Test Setup Printn 9Test Teardown FFDC On Test Case Fail 10Suite Setup Suite Setup Execution 11Suite Teardown Suite Teardown Execution 12 13Test Tags BMC_Network_Protocol 14 15*** Variables *** 16 17${ntp_server_1} 9.9.9.9 18${ntp_server_2} 2.2.3.3 19&{original_ntp} &{EMPTY} 20 21*** Test Cases *** 22 23Verify NTP Server Set 24 [Documentation] Patch NTP servers and verify NTP servers is set. 25 [Tags] Verify_NTP_Server_Set 26 [Setup] Set NTP state ${True} 27 28 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} 29 ... body={'NTP':{'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']}} 30 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 31 32 # NTP network take few seconds to reload. 33 Wait Until Keyword Succeeds 30 sec 10 sec Verify NTP Servers Are Populated 34 35 36Verify NTP Server Value Not Duplicated 37 [Documentation] Verify NTP servers value not same for both primary and secondary server. 38 [Tags] Verify_NTP_Server_Value_Not_Duplicated 39 40 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} 41 ... body={'NTP':{'NTPServers': ['${ntp_server_1}', '${ntp_server_1}']}} 42 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 43 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI} 44 Should Contain X Times ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} 1 45 ... msg=NTP primary and secondary server values should not be same. 46 47 48Verify NTP Server Setting Persist After BMC Reboot 49 [Documentation] Verify NTP server setting persist after BMC reboot. 50 [Tags] Verify_NTP_Server_Setting_Persist_After_BMC_Reboot 51 [Setup] Set NTP state ${True} 52 53 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} 54 ... body={'NTP':{'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']}} 55 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 56 Redfish OBMC Reboot (off) 57 Redfish.Login 58 59 # NTP network take few seconds to reload. 60 Wait Until Keyword Succeeds 30 sec 10 sec Verify NTP Servers Are Populated 61 62 63Verify Enable NTP 64 [Documentation] Verify NTP protocol mode can be enabled. 65 [Teardown] Restore NTP Mode 66 [Tags] Verify_Enable_NTP 67 68 # The following patch command should set the ["NTP"]["ProtocolEnabled"] property to "True". 69 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTP':{'ProtocolEnabled': ${True}}} 70 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 71 Wait Until Keyword Succeeds 1 min 5 sec 72 ... Verify System Time Sync Status ${True} 73 ${ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP 74 Rprint Vars ntp 75 Valid Value ntp["ProtocolEnabled"] valid_values=[True] 76 77Verify Disable NTP 78 [Documentation] Verify NTP protocol mode can be disabled. 79 [Teardown] Restore NTP Mode 80 [Tags] Verify_Disable_NTP 81 82 # The following patch command should set the ["NTP"]["ProtocolEnabled"] property to "False". 83 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTP':{'ProtocolEnabled': ${False}}} 84 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 85 Wait Until Keyword Succeeds 1 min 5 sec 86 ... Verify System Time Sync Status ${False} 87 ${ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP 88 Rprint Vars ntp 89 Valid Value ntp["ProtocolEnabled"] valid_values=[False] 90 91Verify Set DateTime With NTP Enabled 92 [Documentation] Verify whether set managers dateTime is restricted with NTP enabled. 93 [Tags] Verify_Set_DateTime_With_NTP_Enabled 94 95 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTP':{'ProtocolEnabled': ${True}}} 96 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 97 ${ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP 98 Valid Value ntp["ProtocolEnabled"] valid_values=[True] 99 ${local_system_time}= Get Current Date 100 Redfish Set DateTime ${local_system_time} 101 ... valid_status_codes=[${HTTP_BAD_REQUEST}, ${HTTP_INTERNAL_SERVER_ERROR}] 102 103Verify NTP Server Is Not Populated In NetworkSuppliedServers 104 [Documentation] Patch NTP server and verify NTP servers is not populated 105 ... in NetworkSuppliedServers. 106 [Tags] Verify_NTP_Server_Is_Not_Populated_In_NetworkSuppliedServers 107 [Setup] Set NTP state ${True} 108 109 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} 110 ... body={'NTP':{'NTPServers': ['${ntp_server_1}']}} 111 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 112 113 # Verify the NTP server is populated in NTPServers. 114 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI} 115 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} 116 ... msg=NTP server value ${ntp_server_1} not stored. 117 118 # Checking whether added NTP server is not populated in 119 # ... NetworkSuppliedServers as it has only DHCP NTP server list. 120 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI} 121 Should Not Contain ${network_protocol["NTP"]["NetworkSuppliedServers"]} ${ntp_server_1} 122 ... msg=Static NTP server is coming up in NetworkSuppliedServers. 123 124*** Keywords *** 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 135 IF ${year_status} == False Enable NTP And Add NTP Address 136 137Suite Teardown Execution 138 [Documentation] Do the suite level teardown. 139 140 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} 141 ... body={'NTP':{'NTPServers': ['${EMPTY}', '${EMPTY}']}} 142 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 143 Restore NTP Status 144 Redfish.Logout 145