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