Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test BMC manager time functionality. |
| 3 | Resource ../../lib/resource.robot |
| 4 | Resource ../../lib/bmc_redfish_resource.robot |
| 5 | Resource ../../lib/common_utils.robot |
| 6 | Resource ../../lib/openbmc_ffdc.robot |
| 7 | Resource ../../lib/utils.robot |
Sushil Singh | 79b04aa | 2019-06-18 05:25:34 -0500 | [diff] [blame] | 8 | Resource ../../lib/rest_client.robot |
Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 9 | Library ../../lib/gen_robot_valid.py |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 10 | |
Michael Walsh | 09083a8 | 2019-08-01 12:46:16 -0500 | [diff] [blame] | 11 | Test Setup Printn |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 12 | Test Teardown Test Teardown Execution |
Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 13 | Suite Setup Suite Setup Execution |
George Keishing | ade5f6e | 2019-07-12 11:42:42 -0500 | [diff] [blame] | 14 | Suite Teardown Suite Teardown Execution |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 15 | |
George Keishing | 79fcf23 | 2023-10-12 17:06:38 +0530 | [diff] [blame] | 16 | Force Tags Managers_BMC_Time |
| 17 | |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 18 | *** Variables *** |
George Keishing | 79fcf23 | 2023-10-12 17:06:38 +0530 | [diff] [blame] | 19 | |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 20 | ${max_time_diff_in_seconds} 6 |
Sivas SRR | 9e00ff3 | 2019-07-18 10:38:44 -0500 | [diff] [blame] | 21 | # The "offset" consists of the value "26" specified for hours. Redfish will |
| 22 | # convert that to the next day + 2 hours. |
| 23 | ${date_time_with_offset} 2019-04-25T26:24:46+00:00 |
| 24 | ${expected_date_time} 2019-04-26T02:24:46+00:00 |
Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 25 | ${invalid_datetime} "2019-04-251T12:24:46+00:00" |
George Keishing | 5c7318d | 2022-07-07 12:46:00 -0500 | [diff] [blame] | 26 | ${ntp_server_1} 9.9.9.9 |
| 27 | ${ntp_server_2} 2.2.3.3 |
Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 28 | &{original_ntp} &{EMPTY} |
ganesanb | 3937eaa | 2023-04-15 10:24:38 +0000 | [diff] [blame] | 29 | ${year_without_ntp} 1970 |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 30 | |
| 31 | *** Test Cases *** |
| 32 | |
| 33 | Verify Redfish BMC Time |
| 34 | [Documentation] Verify that date/time obtained via redfish matches |
| 35 | ... date/time obtained via BMC command line. |
| 36 | [Tags] Verify_Redfish_BMC_Time |
| 37 | |
| 38 | ${redfish_date_time}= Redfish Get DateTime |
| 39 | ${cli_date_time}= CLI Get BMC DateTime |
| 40 | ${time_diff}= Subtract Date From Date ${cli_date_time} |
| 41 | ... ${redfish_date_time} |
| 42 | ${time_diff}= Evaluate abs(${time_diff}) |
| 43 | Rprint Vars redfish_date_time cli_date_time time_diff |
| 44 | Should Be True ${time_diff} < ${max_time_diff_in_seconds} |
| 45 | ... The difference between Redfish time and CLI time exceeds the allowed time difference. |
| 46 | |
| 47 | |
Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 48 | Verify Set Time Using Redfish |
| 49 | [Documentation] Verify set time using redfish API. |
| 50 | [Tags] Verify_Set_Time_Using_Redfish |
| 51 | |
Anusha Dathatri | 87e4e55 | 2020-05-28 07:02:42 -0500 | [diff] [blame] | 52 | Set Time To Manual Mode |
Sushil Singh | 79b04aa | 2019-06-18 05:25:34 -0500 | [diff] [blame] | 53 | |
Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 54 | ${old_bmc_time}= CLI Get BMC DateTime |
| 55 | # Add 3 days to current date. |
| 56 | ${new_bmc_time}= Add Time to Date ${old_bmc_time} 3 Days |
| 57 | Redfish Set DateTime ${new_bmc_time} |
| 58 | ${cli_bmc_time}= CLI Get BMC DateTime |
| 59 | ${time_diff}= Subtract Date From Date ${cli_bmc_time} |
| 60 | ... ${new_bmc_time} |
| 61 | ${time_diff}= Evaluate abs(${time_diff}) |
| 62 | Rprint Vars old_bmc_time new_bmc_time cli_bmc_time time_diff max_time_diff_in_seconds |
| 63 | Should Be True ${time_diff} < ${max_time_diff_in_seconds} |
| 64 | ... The difference between Redfish time and CLI time exceeds the allowed time difference. |
| 65 | # Setting back to old bmc time. |
| 66 | Redfish Set DateTime ${old_bmc_time} |
| 67 | |
| 68 | |
Sivas SRR | 9e00ff3 | 2019-07-18 10:38:44 -0500 | [diff] [blame] | 69 | Verify Set DateTime With Offset Using Redfish |
| 70 | [Documentation] Verify set DateTime with offset using redfish API. |
| 71 | [Tags] Verify_Set_DateTime_With_Offset_Using_Redfish |
| 72 | [Teardown] Run Keywords Redfish Set DateTime AND FFDC On Test Case Fail |
| 73 | |
| 74 | Redfish Set DateTime ${date_time_with_offset} |
| 75 | ${cli_bmc_time}= CLI Get BMC DateTime |
| 76 | |
| 77 | ${date_time_diff}= Subtract Date From Date ${cli_bmc_time} |
| 78 | ... ${expected_date_time} exclude_millis=yes |
| 79 | ${date_time_diff}= Convert to Integer ${date_time_diff} |
Michael Walsh | 09083a8 | 2019-08-01 12:46:16 -0500 | [diff] [blame] | 80 | Rprint Vars date_time_with_offset expected_date_time cli_bmc_time |
Sivas SRR | 9e00ff3 | 2019-07-18 10:38:44 -0500 | [diff] [blame] | 81 | ... date_time_diff max_time_diff_in_seconds |
Michael Walsh | 09083a8 | 2019-08-01 12:46:16 -0500 | [diff] [blame] | 82 | Valid Range date_time_diff 0 ${max_time_diff_in_seconds} |
Sivas SRR | 9e00ff3 | 2019-07-18 10:38:44 -0500 | [diff] [blame] | 83 | |
| 84 | |
Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 85 | Verify Set DateTime With Invalid Data Using Redfish |
| 86 | [Documentation] Verify error while setting invalid DateTime using Redfish. |
| 87 | [Tags] Verify_Set_DateTime_With_Invalid_Data_Using_Redfish |
| 88 | |
| 89 | Redfish Set DateTime ${invalid_datetime} valid_status_codes=[${HTTP_BAD_REQUEST}] |
| 90 | |
| 91 | |
Sivas SRR | 4d64599 | 2019-06-20 05:34:50 -0500 | [diff] [blame] | 92 | Verify DateTime Persists After Reboot |
| 93 | [Documentation] Verify date persists after BMC reboot. |
| 94 | [Tags] Verify_DateTime_Persists_After_Reboot |
| 95 | |
| 96 | # Synchronize BMC date/time to local system date/time. |
| 97 | ${local_system_time}= Get Current Date |
| 98 | Redfish Set DateTime ${local_system_time} |
| 99 | Redfish OBMC Reboot (off) |
| 100 | Redfish.Login |
| 101 | ${bmc_time}= CLI Get BMC DateTime |
| 102 | ${local_system_time}= Get Current Date |
| 103 | ${time_diff}= Subtract Date From Date ${bmc_time} |
| 104 | ... ${local_system_time} |
| 105 | ${time_diff}= Evaluate abs(${time_diff}) |
| 106 | Rprint Vars local_system_time bmc_time time_diff max_time_diff_in_seconds |
| 107 | Should Be True ${time_diff} < ${max_time_diff_in_seconds} |
| 108 | ... The difference between Redfish time and CLI time exceeds the allowed time difference. |
| 109 | |
| 110 | |
Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 111 | Verify NTP Server Set |
George Keishing | 5c7318d | 2022-07-07 12:46:00 -0500 | [diff] [blame] | 112 | [Documentation] Patch NTP servers and verify NTP servers is set. |
Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 113 | [Tags] Verify_NTP_Server_Set |
George Keishing | 5c7318d | 2022-07-07 12:46:00 -0500 | [diff] [blame] | 114 | [Setup] Set NTP state ${True} |
Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 115 | |
George Keishing | 093c1bd | 2020-02-10 09:47:34 -0600 | [diff] [blame] | 116 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} |
| 117 | ... body={'NTP':{'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']}} |
George Keishing | fa2840d | 2020-01-28 01:41:30 -0600 | [diff] [blame] | 118 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 119 | |
George Keishing | 5c7318d | 2022-07-07 12:46:00 -0500 | [diff] [blame] | 120 | # NTP network take few seconds to reload. |
| 121 | Wait Until Keyword Succeeds 30 sec 10 sec Verify NTP Servers Are Populated |
Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 122 | |
| 123 | Verify NTP Server Value Not Duplicated |
| 124 | [Documentation] Verify NTP servers value not same for both primary and secondary server. |
| 125 | [Tags] Verify_NTP_Server_Value_Not_Duplicated |
| 126 | |
George Keishing | 093c1bd | 2020-02-10 09:47:34 -0600 | [diff] [blame] | 127 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} |
| 128 | ... body={'NTP':{'NTPServers': ['${ntp_server_1}', '${ntp_server_1}']}} |
George Keishing | fa2840d | 2020-01-28 01:41:30 -0600 | [diff] [blame] | 129 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 130 | ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI} |
| 131 | Should Contain X Times ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} 1 |
George Keishing | 1af70ef | 2019-06-11 09:31:10 -0500 | [diff] [blame] | 132 | ... msg=NTP primary and secondary server values should not be same. |
Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 133 | |
| 134 | |
Sivas SRR | aac72b0 | 2019-06-11 08:56:10 -0500 | [diff] [blame] | 135 | Verify NTP Server Setting Persist After BMC Reboot |
| 136 | [Documentation] Verify NTP server setting persist after BMC reboot. |
| 137 | [Tags] Verify_NTP_Server_Setting_Persist_After_BMC_Reboot |
George Keishing | 5c7318d | 2022-07-07 12:46:00 -0500 | [diff] [blame] | 138 | [Setup] Set NTP state ${True} |
Sivas SRR | aac72b0 | 2019-06-11 08:56:10 -0500 | [diff] [blame] | 139 | |
George Keishing | 093c1bd | 2020-02-10 09:47:34 -0600 | [diff] [blame] | 140 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} |
| 141 | ... body={'NTP':{'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']}} |
George Keishing | fa2840d | 2020-01-28 01:41:30 -0600 | [diff] [blame] | 142 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
Sivas SRR | aac72b0 | 2019-06-11 08:56:10 -0500 | [diff] [blame] | 143 | Redfish OBMC Reboot (off) |
| 144 | Redfish.Login |
George Keishing | 5c7318d | 2022-07-07 12:46:00 -0500 | [diff] [blame] | 145 | |
| 146 | # NTP network take few seconds to reload. |
| 147 | Wait Until Keyword Succeeds 30 sec 10 sec Verify NTP Servers Are Populated |
Sivas SRR | aac72b0 | 2019-06-11 08:56:10 -0500 | [diff] [blame] | 148 | |
| 149 | |
Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 150 | Verify Enable NTP |
| 151 | [Documentation] Verify NTP protocol mode can be enabled. |
| 152 | [Teardown] Restore NTP Mode |
| 153 | [Tags] Verify_Enable_NTP |
| 154 | |
| 155 | ${original_ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP |
| 156 | Set Suite Variable ${original_ntp} |
Michael Walsh | 39c0051 | 2019-07-17 10:54:06 -0500 | [diff] [blame] | 157 | Rprint Vars original_ntp |
Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 158 | # The following patch command should set the ["NTP"]["ProtocolEnabled"] property to "True". |
George Keishing | fa2840d | 2020-01-28 01:41:30 -0600 | [diff] [blame] | 159 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTP':{'ProtocolEnabled': ${True}}} |
| 160 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
aravinth0510 | 83f3118 | 2022-09-30 12:32:57 +0000 | [diff] [blame] | 161 | Wait Until Keyword Succeeds 1 min 5 sec |
aravinth0510 | f031ca1 | 2022-06-16 12:47:33 +0000 | [diff] [blame] | 162 | ... Verify System Time Sync Status ${True} |
Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 163 | ${ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP |
Michael Walsh | 39c0051 | 2019-07-17 10:54:06 -0500 | [diff] [blame] | 164 | Rprint Vars ntp |
Michael Walsh | e7edb22 | 2019-08-19 17:39:38 -0500 | [diff] [blame] | 165 | Valid Value ntp["ProtocolEnabled"] valid_values=[True] |
Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 166 | |
| 167 | |
Anusha Dathatri | 4ad9f43 | 2020-06-29 05:18:29 -0500 | [diff] [blame] | 168 | Verify Immediate Consumption Of BMC Date |
| 169 | [Documentation] Verify immediate change in BMC date time. |
| 170 | [Tags] Verify_Immediate_Consumption_Of_BMC_Date |
| 171 | [Setup] Run Keywords Set Time To Manual Mode AND |
Anusha Dathatri | ad6a3df | 2020-07-22 05:20:18 -0500 | [diff] [blame] | 172 | ... Redfish Set DateTime valid_status_codes=[${HTTP_OK}] |
Anusha Dathatri | 4ad9f43 | 2020-06-29 05:18:29 -0500 | [diff] [blame] | 173 | [Teardown] Run Keywords FFDC On Test Case Fail AND |
| 174 | ... Redfish Set DateTime valid_status_codes=[${HTTP_OK}] |
| 175 | [Template] Set BMC Date And Verify |
| 176 | |
| 177 | # host_state |
| 178 | on |
| 179 | off |
| 180 | |
| 181 | |
aravinth0510 | f031ca1 | 2022-06-16 12:47:33 +0000 | [diff] [blame] | 182 | Verify Set DateTime With NTP Enabled |
| 183 | [Documentation] Verify whether set managers dateTime is restricted with NTP enabled. |
| 184 | [Tags] Verify_Set_DateTime_With_NTP_Enabled |
| 185 | |
| 186 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTP':{'ProtocolEnabled': ${True}}} |
| 187 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
| 188 | ${ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP |
| 189 | Valid Value ntp["ProtocolEnabled"] valid_values=[True] |
| 190 | ${local_system_time}= Get Current Date |
| 191 | Redfish Set DateTime ${local_system_time} |
| 192 | ... valid_status_codes=[${HTTP_BAD_REQUEST}, ${HTTP_INTERNAL_SERVER_ERROR}] |
| 193 | |
| 194 | |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 195 | *** Keywords *** |
| 196 | |
Sivas SRR | 4d64599 | 2019-06-20 05:34:50 -0500 | [diff] [blame] | 197 | |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 198 | Test Teardown Execution |
| 199 | [Documentation] Do the post test teardown. |
| 200 | |
| 201 | FFDC On Test Case Fail |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 202 | |
| 203 | |
| 204 | Redfish Get DateTime |
| 205 | [Documentation] Returns BMC Datetime value from Redfish. |
| 206 | |
ganesanb | 4d43028 | 2023-04-27 14:33:23 +0000 | [diff] [blame] | 207 | ${date_time}= Redfish.Get Attribute ${REDFISH_BASE_URI}Managers/${MANAGER_ID} DateTime |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame^] | 208 | RETURN ${date_time} |
Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 209 | |
| 210 | |
| 211 | Redfish Set DateTime |
| 212 | [Documentation] Set DateTime using Redfish. |
Sivas SRR | 9e00ff3 | 2019-07-18 10:38:44 -0500 | [diff] [blame] | 213 | [Arguments] ${date_time}=${EMPTY} &{kwargs} |
Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 214 | # Description of argument(s): |
Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 215 | # date_time New time to set for BMC (eg. |
Sivas SRR | 9e00ff3 | 2019-07-18 10:38:44 -0500 | [diff] [blame] | 216 | # "2019-06-30 09:21:28"). If this value is |
| 217 | # empty, it will be set to the UTC current |
| 218 | # date time of the local system. |
George Keishing | 7bc01e9 | 2021-06-15 11:07:14 -0500 | [diff] [blame] | 219 | # kwargs Additional parameters to be passed directly to |
Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 220 | # th Redfish.Patch function. A good use for |
| 221 | # this is when testing a bad date-time, the |
| 222 | # caller can specify |
| 223 | # valid_status_codes=[${HTTP_BAD_REQUEST}]. |
Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 224 | |
Sivas SRR | 9e00ff3 | 2019-07-18 10:38:44 -0500 | [diff] [blame] | 225 | # Assign default value of UTC current date time if date_time is empty. |
| 226 | ${date_time}= Run Keyword If |
| 227 | ... '${date_time}' == '${EMPTY}' Get Current Date time_zone=UTC |
| 228 | ... ELSE |
| 229 | ... Set Variable ${date_time} |
Anusha Dathatri | ad6a3df | 2020-07-22 05:20:18 -0500 | [diff] [blame] | 230 | Wait Until Keyword Succeeds 1min 5sec |
ganesanb | 4d43028 | 2023-04-27 14:33:23 +0000 | [diff] [blame] | 231 | ... Redfish.Patch ${REDFISH_BASE_URI}Managers/${MANAGER_ID} body={'DateTime': '${date_time}'} &{kwargs} |
Sushil Singh | 79b04aa | 2019-06-18 05:25:34 -0500 | [diff] [blame] | 232 | |
| 233 | |
Anusha Dathatri | 87e4e55 | 2020-05-28 07:02:42 -0500 | [diff] [blame] | 234 | Set Time To Manual Mode |
Anusha Dathatri | d1a7bf0 | 2021-09-15 03:04:45 -0500 | [diff] [blame] | 235 | [Documentation] Set date time to manual mode via Redfish. |
Sushil Singh | 79b04aa | 2019-06-18 05:25:34 -0500 | [diff] [blame] | 236 | |
Anusha Dathatri | d1a7bf0 | 2021-09-15 03:04:45 -0500 | [diff] [blame] | 237 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTP':{'ProtocolEnabled': ${False}}} |
| 238 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
Sushil Singh | 79b04aa | 2019-06-18 05:25:34 -0500 | [diff] [blame] | 239 | |
Sivas SRR | 9e00ff3 | 2019-07-18 10:38:44 -0500 | [diff] [blame] | 240 | |
Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 241 | Restore NTP Mode |
| 242 | [Documentation] Restore the original NTP mode. |
| 243 | |
| 244 | |
| 245 | Return From Keyword If &{original_ntp} == &{EMPTY} |
| 246 | Print Timen Restore NTP Mode. |
| 247 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} |
George Keishing | fa2840d | 2020-01-28 01:41:30 -0600 | [diff] [blame] | 248 | ... body={'NTP':{'ProtocolEnabled': ${original_ntp["ProtocolEnabled"]}}} |
| 249 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 250 | |
| 251 | |
| 252 | Suite Setup Execution |
| 253 | [Documentation] Do the suite level setup. |
| 254 | |
| 255 | Printn |
| 256 | Redfish.Login |
Tony Lee | 1082266 | 2020-05-12 14:53:35 +0800 | [diff] [blame] | 257 | Get NTP Initial Status |
ganesanb | 3937eaa | 2023-04-15 10:24:38 +0000 | [diff] [blame] | 258 | ${old_date_time}= CLI Get BMC DateTime |
| 259 | ${year_status}= Run Keyword And Return Status Should Not Contain ${old_date_time} ${year_without_ntp} |
| 260 | Run Keyword If ${year_status} == False |
| 261 | ... Enable NTP And Add NTP Address |
Anusha Dathatri | 87e4e55 | 2020-05-28 07:02:42 -0500 | [diff] [blame] | 262 | Set Time To Manual Mode |
Tony Lee | 1082266 | 2020-05-12 14:53:35 +0800 | [diff] [blame] | 263 | |
George Keishing | ade5f6e | 2019-07-12 11:42:42 -0500 | [diff] [blame] | 264 | |
| 265 | Suite Teardown Execution |
| 266 | [Documentation] Do the suite level teardown. |
Sivas SRR | 9e00ff3 | 2019-07-18 10:38:44 -0500 | [diff] [blame] | 267 | |
Sivas SRR | 64613ff | 2019-07-13 03:06:33 -0500 | [diff] [blame] | 268 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} |
George Keishing | f05a103 | 2020-01-27 11:08:51 -0600 | [diff] [blame] | 269 | ... body={'NTP':{'NTPServers': ['${EMPTY}', '${EMPTY}']}} |
| 270 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
Anusha Dathatri | 87e4e55 | 2020-05-28 07:02:42 -0500 | [diff] [blame] | 271 | Set Time To Manual Mode |
Tony Lee | 1082266 | 2020-05-12 14:53:35 +0800 | [diff] [blame] | 272 | Restore NTP Status |
George Keishing | ade5f6e | 2019-07-12 11:42:42 -0500 | [diff] [blame] | 273 | Redfish.Logout |
Tony Lee | 1082266 | 2020-05-12 14:53:35 +0800 | [diff] [blame] | 274 | |
| 275 | |
| 276 | Set NTP state |
| 277 | [Documentation] Set NTP service inactive. |
| 278 | [Arguments] ${state} |
| 279 | |
| 280 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTP':{'ProtocolEnabled': ${state}}} |
| 281 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
| 282 | |
| 283 | |
| 284 | Get NTP Initial Status |
| 285 | [Documentation] Get NTP service Status. |
| 286 | |
| 287 | ${original_ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP |
| 288 | Set Suite Variable ${original_ntp} |
| 289 | |
| 290 | |
| 291 | Restore NTP Status |
| 292 | [Documentation] Restore NTP Status. |
| 293 | |
| 294 | Run Keyword If '${original_ntp["ProtocolEnabled"]}' == 'True' |
| 295 | ... Set NTP state ${TRUE} |
Anusha Dathatri | 4ad9f43 | 2020-06-29 05:18:29 -0500 | [diff] [blame] | 296 | ... ELSE Set NTP state ${FALSE} |
| 297 | |
| 298 | |
| 299 | Set BMC Date And Verify |
| 300 | [Documentation] Set BMC Date Time at a given host state and verify. |
| 301 | [Arguments] ${host_state} |
| 302 | # Description of argument(s): |
| 303 | # host_state Host state at which date time will be updated for verification |
| 304 | # (eg. on, off). |
| 305 | |
| 306 | Run Keyword If '${host_state}' == 'on' |
| 307 | ... Redfish Power On stack_mode=skip |
| 308 | ... ELSE |
| 309 | ... Redfish Power off stack_mode=skip |
| 310 | ${current_date}= Get Current Date time_zone=UTC |
| 311 | ${new_value}= Subtract Time From Date ${current_date} 1 day |
| 312 | Redfish Set DateTime ${new_value} valid_status_codes=[${HTTP_OK}] |
| 313 | ${current_value}= Redfish Get DateTime |
| 314 | ${time_diff}= Subtract Date From Date ${current_value} ${new_value} |
| 315 | Should Be True '${time_diff}'<='3' |
George Keishing | 5c7318d | 2022-07-07 12:46:00 -0500 | [diff] [blame] | 316 | |
| 317 | Verify NTP Servers Are Populated |
ganesanb | 4d43028 | 2023-04-27 14:33:23 +0000 | [diff] [blame] | 318 | [Documentation] Redfish GET request /redfish/v1/Managers/${MANAGER_ID}/NetworkProtocol response |
George Keishing | 5c7318d | 2022-07-07 12:46:00 -0500 | [diff] [blame] | 319 | ... and verify if NTP servers are populated. |
| 320 | |
| 321 | ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI} |
| 322 | Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} |
| 323 | ... msg=NTP server value ${ntp_server_1} not stored. |
| 324 | Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_2} |
| 325 | ... msg=NTP server value ${ntp_server_2} not stored. |
| 326 | |
aravinth0510 | f031ca1 | 2022-06-16 12:47:33 +0000 | [diff] [blame] | 327 | |
| 328 | Verify System Time Sync Status |
| 329 | [Documentation] Verify the status of service systemd-timesyncd matches the NTP protocol enabled state. |
| 330 | [Arguments] ${expected_sync_status}=${True} |
| 331 | |
| 332 | # Description of argument(s): |
| 333 | # expected_sync_status expected status at which NTP protocol enabled will be updated for verification |
| 334 | # (eg. True, False). |
| 335 | |
| 336 | ${resp}= BMC Execute Command |
| 337 | ... systemctl status systemd-timesyncd |
| 338 | ... ignore_err=${1} |
| 339 | ${sync_status}= Get Lines Matching Regexp ${resp[0]} .*Active.* |
| 340 | Run Keyword If ${expected_sync_status}==${True} |
| 341 | ... Should Contain ${sync_status} active (running) |
| 342 | Run Keyword If ${expected_sync_status}==${False} |
| 343 | ... Should Contain ${sync_status} inactive (dead) |
ganesanb | 3937eaa | 2023-04-15 10:24:38 +0000 | [diff] [blame] | 344 | |
| 345 | Enable NTP And Add NTP Address |
| 346 | [Documentation] Enable NTP Protocol and Add NTP Address. |
| 347 | |
| 348 | Set NTP state ${TRUE} |
| 349 | |
| 350 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTP':{'NTPServers': ${NTP_SERVER_ADDRESSES}}} |
| 351 | ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] |
| 352 | |
| 353 | Wait Until Keyword Succeeds 1 min 10 sec Check Date And Time Was Changed |
George Keishing | e01ee58 | 2023-05-16 10:17:08 +0530 | [diff] [blame] | 354 | |
ganesanb | 3937eaa | 2023-04-15 10:24:38 +0000 | [diff] [blame] | 355 | Check Date And Time Was Changed |
| 356 | [Documentation] Verify date was current date and time. |
| 357 | |
| 358 | ${new_date_time}= CLI Get BMC DateTime |
| 359 | Should Not Contain ${new_date_time} ${year_without_ntp} |