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 | |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 11 | Test Teardown Test Teardown Execution |
Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 12 | Suite Setup Suite Setup Execution |
George Keishing | ade5f6e | 2019-07-12 11:42:42 -0500 | [diff] [blame] | 13 | Suite Teardown Suite Teardown Execution |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 14 | |
| 15 | *** Variables *** |
| 16 | ${max_time_diff_in_seconds} 6 |
Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 17 | ${invalid_datetime} "2019-04-251T12:24:46+00:00" |
Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 18 | ${ntp_server_1} "9.9.9.9" |
| 19 | ${ntp_server_2} "2.2.3.3" |
Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 20 | &{original_ntp} &{EMPTY} |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 21 | |
| 22 | *** Test Cases *** |
| 23 | |
| 24 | Verify Redfish BMC Time |
| 25 | [Documentation] Verify that date/time obtained via redfish matches |
| 26 | ... date/time obtained via BMC command line. |
| 27 | [Tags] Verify_Redfish_BMC_Time |
| 28 | |
| 29 | ${redfish_date_time}= Redfish Get DateTime |
| 30 | ${cli_date_time}= CLI Get BMC DateTime |
| 31 | ${time_diff}= Subtract Date From Date ${cli_date_time} |
| 32 | ... ${redfish_date_time} |
| 33 | ${time_diff}= Evaluate abs(${time_diff}) |
| 34 | Rprint Vars redfish_date_time cli_date_time time_diff |
| 35 | Should Be True ${time_diff} < ${max_time_diff_in_seconds} |
| 36 | ... The difference between Redfish time and CLI time exceeds the allowed time difference. |
| 37 | |
| 38 | |
Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 39 | Verify Set Time Using Redfish |
| 40 | [Documentation] Verify set time using redfish API. |
| 41 | [Tags] Verify_Set_Time_Using_Redfish |
| 42 | |
Sushil Singh | 79b04aa | 2019-06-18 05:25:34 -0500 | [diff] [blame] | 43 | Rest Set Time Owner |
| 44 | |
Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 45 | ${old_bmc_time}= CLI Get BMC DateTime |
| 46 | # Add 3 days to current date. |
| 47 | ${new_bmc_time}= Add Time to Date ${old_bmc_time} 3 Days |
| 48 | Redfish Set DateTime ${new_bmc_time} |
| 49 | ${cli_bmc_time}= CLI Get BMC DateTime |
| 50 | ${time_diff}= Subtract Date From Date ${cli_bmc_time} |
| 51 | ... ${new_bmc_time} |
| 52 | ${time_diff}= Evaluate abs(${time_diff}) |
| 53 | Rprint Vars old_bmc_time new_bmc_time cli_bmc_time time_diff max_time_diff_in_seconds |
| 54 | Should Be True ${time_diff} < ${max_time_diff_in_seconds} |
| 55 | ... The difference between Redfish time and CLI time exceeds the allowed time difference. |
| 56 | # Setting back to old bmc time. |
| 57 | Redfish Set DateTime ${old_bmc_time} |
| 58 | |
| 59 | |
Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 60 | Verify Set DateTime With Invalid Data Using Redfish |
| 61 | [Documentation] Verify error while setting invalid DateTime using Redfish. |
| 62 | [Tags] Verify_Set_DateTime_With_Invalid_Data_Using_Redfish |
| 63 | |
| 64 | Redfish Set DateTime ${invalid_datetime} valid_status_codes=[${HTTP_BAD_REQUEST}] |
| 65 | |
| 66 | |
Sivas SRR | 4d64599 | 2019-06-20 05:34:50 -0500 | [diff] [blame] | 67 | Verify DateTime Persists After Reboot |
| 68 | [Documentation] Verify date persists after BMC reboot. |
| 69 | [Tags] Verify_DateTime_Persists_After_Reboot |
| 70 | |
| 71 | # Synchronize BMC date/time to local system date/time. |
| 72 | ${local_system_time}= Get Current Date |
| 73 | Redfish Set DateTime ${local_system_time} |
| 74 | Redfish OBMC Reboot (off) |
| 75 | Redfish.Login |
| 76 | ${bmc_time}= CLI Get BMC DateTime |
| 77 | ${local_system_time}= Get Current Date |
| 78 | ${time_diff}= Subtract Date From Date ${bmc_time} |
| 79 | ... ${local_system_time} |
| 80 | ${time_diff}= Evaluate abs(${time_diff}) |
| 81 | Rprint Vars local_system_time bmc_time time_diff max_time_diff_in_seconds |
| 82 | Should Be True ${time_diff} < ${max_time_diff_in_seconds} |
| 83 | ... The difference between Redfish time and CLI time exceeds the allowed time difference. |
| 84 | |
| 85 | |
Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 86 | Verify NTP Server Set |
| 87 | [Documentation] Verify NTP server set. |
| 88 | [Tags] Verify_NTP_Server_Set |
| 89 | |
| 90 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']} |
| 91 | ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI} |
| 92 | Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} |
| 93 | ... msg=NTP server value ${ntp_server_1} not stored. |
| 94 | Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_2} |
| 95 | ... msg=NTP server value ${ntp_server_2} not stored. |
| 96 | |
| 97 | |
| 98 | Verify NTP Server Value Not Duplicated |
| 99 | [Documentation] Verify NTP servers value not same for both primary and secondary server. |
| 100 | [Tags] Verify_NTP_Server_Value_Not_Duplicated |
| 101 | |
| 102 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_1}']} |
| 103 | ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI} |
| 104 | Should Contain X Times ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} 1 |
George Keishing | 1af70ef | 2019-06-11 09:31:10 -0500 | [diff] [blame] | 105 | ... msg=NTP primary and secondary server values should not be same. |
Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 106 | |
| 107 | |
Sivas SRR | aac72b0 | 2019-06-11 08:56:10 -0500 | [diff] [blame] | 108 | Verify NTP Server Setting Persist After BMC Reboot |
| 109 | [Documentation] Verify NTP server setting persist after BMC reboot. |
| 110 | [Tags] Verify_NTP_Server_Setting_Persist_After_BMC_Reboot |
| 111 | |
| 112 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']} |
| 113 | Redfish OBMC Reboot (off) |
| 114 | Redfish.Login |
| 115 | ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI} |
| 116 | Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} |
| 117 | ... msg=NTP server value ${ntp_server_1} not stored. |
| 118 | Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_2} |
| 119 | ... msg=NTP server value ${ntp_server_2} not stored. |
Sivas SRR | aac72b0 | 2019-06-11 08:56:10 -0500 | [diff] [blame] | 120 | |
| 121 | |
Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 122 | Verify Enable NTP |
| 123 | [Documentation] Verify NTP protocol mode can be enabled. |
| 124 | [Teardown] Restore NTP Mode |
| 125 | [Tags] Verify_Enable_NTP |
| 126 | |
| 127 | ${original_ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP |
| 128 | Set Suite Variable ${original_ntp} |
Michael Walsh | 39c0051 | 2019-07-17 10:54:06 -0500 | [diff] [blame] | 129 | Rprint Vars original_ntp |
Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 130 | # The following patch command should set the ["NTP"]["ProtocolEnabled"] property to "True". |
| 131 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={u'NTPEnabled': ${True}} |
| 132 | ${ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP |
Michael Walsh | 39c0051 | 2019-07-17 10:54:06 -0500 | [diff] [blame] | 133 | Rprint Vars ntp |
Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 134 | Rvalid Value ntp["ProtocolEnabled"] valid_values=[True] |
| 135 | |
| 136 | |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 137 | *** Keywords *** |
| 138 | |
Sivas SRR | 4d64599 | 2019-06-20 05:34:50 -0500 | [diff] [blame] | 139 | |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 140 | Test Teardown Execution |
| 141 | [Documentation] Do the post test teardown. |
| 142 | |
| 143 | FFDC On Test Case Fail |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 144 | |
| 145 | |
| 146 | Redfish Get DateTime |
| 147 | [Documentation] Returns BMC Datetime value from Redfish. |
| 148 | |
| 149 | ${date_time}= Redfish.Get Attribute ${REDFISH_BASE_URI}Managers/bmc DateTime |
| 150 | [Return] ${date_time} |
Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 151 | |
| 152 | |
| 153 | Redfish Set DateTime |
| 154 | [Documentation] Set DateTime using Redfish. |
Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 155 | [Arguments] ${date_time} &{kwargs} |
Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 156 | # Description of argument(s): |
Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 157 | # date_time New time to set for BMC (eg. |
| 158 | # "2019-06-30 09:21:28"). |
| 159 | # kwargs Additional parms to be passed directly to |
| 160 | # th Redfish.Patch function. A good use for |
| 161 | # this is when testing a bad date-time, the |
| 162 | # caller can specify |
| 163 | # valid_status_codes=[${HTTP_BAD_REQUEST}]. |
Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 164 | |
Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 165 | Redfish.Patch ${REDFISH_BASE_URI}Managers/bmc body={'DateTime': '${date_time}'} |
| 166 | ... &{kwargs} |
Sushil Singh | 79b04aa | 2019-06-18 05:25:34 -0500 | [diff] [blame] | 167 | |
| 168 | |
| 169 | Rest Set Time Owner |
| 170 | [Documentation] Set time owner of the system via REST. |
| 171 | |
| 172 | # BMC_OWNER is defined in variable.py. |
| 173 | ${data}= Create Dictionary data=${BMC_OWNER} |
| 174 | Write Attribute ${TIME_MANAGER_URI}owner TimeOwner data=${data} verify=${TRUE} |
| 175 | |
Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 176 | Restore NTP Mode |
| 177 | [Documentation] Restore the original NTP mode. |
| 178 | |
| 179 | |
| 180 | Return From Keyword If &{original_ntp} == &{EMPTY} |
| 181 | Print Timen Restore NTP Mode. |
| 182 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} |
| 183 | ... body={u'NTPEnabled': ${original_ntp["ProtocolEnabled"]}} |
| 184 | |
| 185 | |
| 186 | Suite Setup Execution |
| 187 | [Documentation] Do the suite level setup. |
| 188 | |
| 189 | Printn |
| 190 | Redfish.Login |
George Keishing | ade5f6e | 2019-07-12 11:42:42 -0500 | [diff] [blame] | 191 | Rest Set Time Owner |
| 192 | |
| 193 | Suite Teardown Execution |
| 194 | [Documentation] Do the suite level teardown. |
| 195 | Rest Set Time Owner |
Sivas SRR | 64613ff | 2019-07-13 03:06:33 -0500 | [diff] [blame] | 196 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} |
| 197 | ... body={'NTPServers': ['${EMPTY}', '${EMPTY}']} |
George Keishing | ade5f6e | 2019-07-12 11:42:42 -0500 | [diff] [blame] | 198 | Redfish.Logout |