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 | |
| 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 | |
| 22 | Verify 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 | |
| 35 | Verify 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 | |
| 47 | Verify 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 | |
| 62 | Verify Enable NTP |
| 63 | [Documentation] Verify NTP protocol mode can be enabled. |
| 64 | [Teardown] Restore NTP Mode |
| 65 | [Tags] Verify_Enable_NTP |
| 66 | |
| 67 | ${original_ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP |
| 68 | Set Suite Variable ${original_ntp} |
| 69 | Rprint Vars original_ntp |
| 70 | # The following patch command should set the ["NTP"]["ProtocolEnabled"] property to "True". |
| 71 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTP':{'ProtocolEnabled': ${True}}} |
| 72 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
| 73 | Wait Until Keyword Succeeds 1 min 5 sec |
| 74 | ... Verify System Time Sync Status ${True} |
| 75 | ${ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP |
| 76 | Rprint Vars ntp |
| 77 | Valid Value ntp["ProtocolEnabled"] valid_values=[True] |
| 78 | |
| 79 | |
| 80 | Verify Set DateTime With NTP Enabled |
| 81 | [Documentation] Verify whether set managers dateTime is restricted with NTP enabled. |
| 82 | [Tags] Verify_Set_DateTime_With_NTP_Enabled |
| 83 | |
| 84 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTP':{'ProtocolEnabled': ${True}}} |
| 85 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
| 86 | ${ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP |
| 87 | Valid Value ntp["ProtocolEnabled"] valid_values=[True] |
| 88 | ${local_system_time}= Get Current Date |
| 89 | Redfish Set DateTime ${local_system_time} |
| 90 | ... valid_status_codes=[${HTTP_BAD_REQUEST}, ${HTTP_INTERNAL_SERVER_ERROR}] |
| 91 | |
| 92 | |
| 93 | *** Keywords *** |
| 94 | |
| 95 | |
| 96 | Suite Setup Execution |
| 97 | [Documentation] Do the suite level setup. |
| 98 | |
| 99 | Printn |
| 100 | Redfish.Login |
| 101 | Get NTP Initial Status |
| 102 | ${old_date_time}= CLI Get BMC DateTime |
| 103 | ${year_status}= Run Keyword And Return Status Should Not Contain ${old_date_time} ${year_without_ntp} |
| 104 | Run Keyword If ${year_status} == False |
| 105 | ... Enable NTP And Add NTP Address |
| 106 | |
| 107 | |
| 108 | Suite Teardown Execution |
| 109 | [Documentation] Do the suite level teardown. |
| 110 | |
| 111 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} |
| 112 | ... body={'NTP':{'NTPServers': ['${EMPTY}', '${EMPTY}']}} |
| 113 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
| 114 | Restore NTP Status |
| 115 | Redfish.Logout |