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 |
| 13 | Suite Teardown Redfish.Logout |
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 | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 67 | Verify NTP Server Set |
| 68 | [Documentation] Verify NTP server set. |
| 69 | [Tags] Verify_NTP_Server_Set |
| 70 | |
| 71 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']} |
| 72 | ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI} |
| 73 | Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} |
| 74 | ... msg=NTP server value ${ntp_server_1} not stored. |
| 75 | Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_2} |
| 76 | ... msg=NTP server value ${ntp_server_2} not stored. |
| 77 | |
| 78 | |
| 79 | Verify NTP Server Value Not Duplicated |
| 80 | [Documentation] Verify NTP servers value not same for both primary and secondary server. |
| 81 | [Tags] Verify_NTP_Server_Value_Not_Duplicated |
| 82 | |
| 83 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_1}']} |
| 84 | ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI} |
| 85 | Should Contain X Times ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} 1 |
George Keishing | 1af70ef | 2019-06-11 09:31:10 -0500 | [diff] [blame] | 86 | ... msg=NTP primary and secondary server values should not be same. |
Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 87 | |
| 88 | |
Sivas SRR | aac72b0 | 2019-06-11 08:56:10 -0500 | [diff] [blame] | 89 | Verify NTP Server Setting Persist After BMC Reboot |
| 90 | [Documentation] Verify NTP server setting persist after BMC reboot. |
| 91 | [Tags] Verify_NTP_Server_Setting_Persist_After_BMC_Reboot |
| 92 | |
| 93 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']} |
| 94 | Redfish OBMC Reboot (off) |
| 95 | Redfish.Login |
| 96 | ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI} |
| 97 | Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} |
| 98 | ... msg=NTP server value ${ntp_server_1} not stored. |
| 99 | Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_2} |
| 100 | ... msg=NTP server value ${ntp_server_2} not stored. |
| 101 | Redfish.Logout |
| 102 | |
| 103 | |
Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 104 | Verify Enable NTP |
| 105 | [Documentation] Verify NTP protocol mode can be enabled. |
| 106 | [Teardown] Restore NTP Mode |
| 107 | [Tags] Verify_Enable_NTP |
| 108 | |
| 109 | ${original_ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP |
| 110 | Set Suite Variable ${original_ntp} |
| 111 | Rprint Vars original_ntp fmt=terse |
| 112 | # The following patch command should set the ["NTP"]["ProtocolEnabled"] property to "True". |
| 113 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={u'NTPEnabled': ${True}} |
| 114 | ${ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP |
| 115 | Rprint Vars ntp fmt=terse |
| 116 | Rvalid Value ntp["ProtocolEnabled"] valid_values=[True] |
| 117 | |
| 118 | |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 119 | *** Keywords *** |
| 120 | |
| 121 | Test Teardown Execution |
| 122 | [Documentation] Do the post test teardown. |
| 123 | |
| 124 | FFDC On Test Case Fail |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 125 | |
| 126 | |
| 127 | Redfish Get DateTime |
| 128 | [Documentation] Returns BMC Datetime value from Redfish. |
| 129 | |
| 130 | ${date_time}= Redfish.Get Attribute ${REDFISH_BASE_URI}Managers/bmc DateTime |
| 131 | [Return] ${date_time} |
Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 132 | |
| 133 | |
| 134 | Redfish Set DateTime |
| 135 | [Documentation] Set DateTime using Redfish. |
Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 136 | [Arguments] ${date_time} &{kwargs} |
Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 137 | # Description of argument(s): |
Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 138 | # date_time New time to set for BMC (eg. |
| 139 | # "2019-06-30 09:21:28"). |
| 140 | # kwargs Additional parms to be passed directly to |
| 141 | # th Redfish.Patch function. A good use for |
| 142 | # this is when testing a bad date-time, the |
| 143 | # caller can specify |
| 144 | # valid_status_codes=[${HTTP_BAD_REQUEST}]. |
Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 145 | |
Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 146 | Redfish.Patch ${REDFISH_BASE_URI}Managers/bmc body={'DateTime': '${date_time}'} |
| 147 | ... &{kwargs} |
Sushil Singh | 79b04aa | 2019-06-18 05:25:34 -0500 | [diff] [blame] | 148 | |
| 149 | |
| 150 | Rest Set Time Owner |
| 151 | [Documentation] Set time owner of the system via REST. |
| 152 | |
| 153 | # BMC_OWNER is defined in variable.py. |
| 154 | ${data}= Create Dictionary data=${BMC_OWNER} |
| 155 | Write Attribute ${TIME_MANAGER_URI}owner TimeOwner data=${data} verify=${TRUE} |
| 156 | |
Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 157 | Restore NTP Mode |
| 158 | [Documentation] Restore the original NTP mode. |
| 159 | |
| 160 | |
| 161 | Return From Keyword If &{original_ntp} == &{EMPTY} |
| 162 | Print Timen Restore NTP Mode. |
| 163 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} |
| 164 | ... body={u'NTPEnabled': ${original_ntp["ProtocolEnabled"]}} |
| 165 | |
| 166 | |
| 167 | Suite Setup Execution |
| 168 | [Documentation] Do the suite level setup. |
| 169 | |
| 170 | Printn |
| 171 | Redfish.Login |
| 172 | |
| 173 | |