| Anvesh-Kumar_Rayankula | 365b8f9 | 2024-08-04 00:07:19 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation NTP configuration and verification |
| 3 | ... tests. |
| 4 | |
| 5 | Resource ../../lib/openbmc_ffdc.robot |
| 6 | Resource ../../lib/bmc_date_and_time_utils.robot |
| 7 | |
| 8 | Test Setup Printn |
| 9 | Test Teardown FFDC On Test Case Fail |
| 10 | Suite Setup Suite Setup Execution |
| 11 | Suite Teardown Suite Teardown Execution |
| 12 | |
| Igor Kanyuka | feb79d6 | 2025-10-20 21:24:03 +0100 | [diff] [blame^] | 13 | Test Tags BMC_Network_Protocol |
| Anvesh-Kumar_Rayankula | 365b8f9 | 2024-08-04 00:07:19 -0500 | [diff] [blame] | 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 | |
| 23 | Verify 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 | |
| 36 | Verify 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 | |
| 48 | Verify 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 | |
| 63 | Verify Enable NTP |
| 64 | [Documentation] Verify NTP protocol mode can be enabled. |
| 65 | [Teardown] Restore NTP Mode |
| 66 | [Tags] Verify_Enable_NTP |
| 67 | |
| Anvesh-Kumar_Rayankula | 365b8f9 | 2024-08-04 00:07:19 -0500 | [diff] [blame] | 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 | |
| George Keishing | aaf7d1c | 2024-09-03 13:46:49 +0530 | [diff] [blame] | 77 | Verify Disable NTP |
| Sweta Potthuri | dc9abaa | 2024-08-14 02:04:11 -0500 | [diff] [blame] | 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] |
| Anvesh-Kumar_Rayankula | 365b8f9 | 2024-08-04 00:07:19 -0500 | [diff] [blame] | 90 | |
| 91 | Verify 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 | |
| Sweta Potthuri | ba083e5 | 2025-01-08 02:24:24 -0600 | [diff] [blame] | 103 | Verify NTP Server Is Not Populated In NetworkSuppliedServers |
| 104 | [Documentation] Patch NTP server and verify NTP servers is not populated |
| 105 | ... in NetworkSuppliedServers. |
| George Keishing | 4ebb328 | 2025-01-17 10:01:34 +0530 | [diff] [blame] | 106 | [Tags] Verify_NTP_Server_Is_Not_Populated_In_NetworkSuppliedServers |
| Sweta Potthuri | ba083e5 | 2025-01-08 02:24:24 -0600 | [diff] [blame] | 107 | [Setup] Set NTP state ${True} |
| Anvesh-Kumar_Rayankula | 365b8f9 | 2024-08-04 00:07:19 -0500 | [diff] [blame] | 108 | |
| Sweta Potthuri | ba083e5 | 2025-01-08 02:24:24 -0600 | [diff] [blame] | 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 *** |
| Anvesh-Kumar_Rayankula | 365b8f9 | 2024-08-04 00:07:19 -0500 | [diff] [blame] | 125 | |
| 126 | Suite 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} |
| George Keishing | e6e161e | 2025-05-08 10:18:30 +0530 | [diff] [blame] | 134 | |
| 135 | IF ${year_status} == False Enable NTP And Add NTP Address |
| Anvesh-Kumar_Rayankula | 365b8f9 | 2024-08-04 00:07:19 -0500 | [diff] [blame] | 136 | |
| Anvesh-Kumar_Rayankula | 365b8f9 | 2024-08-04 00:07:19 -0500 | [diff] [blame] | 137 | Suite 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 |