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