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 |
| 8 | |
| 9 | Test Setup Run Keywords Printn AND redfish.Login |
| 10 | Test Teardown Test Teardown Execution |
| 11 | |
| 12 | *** Variables *** |
| 13 | ${max_time_diff_in_seconds} 6 |
Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 14 | ${invalid_datetime} "2019-04-251T12:24:46+00:00" |
Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 15 | ${ntp_server_1} "9.9.9.9" |
| 16 | ${ntp_server_2} "2.2.3.3" |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 17 | |
| 18 | *** Test Cases *** |
| 19 | |
| 20 | Verify Redfish BMC Time |
| 21 | [Documentation] Verify that date/time obtained via redfish matches |
| 22 | ... date/time obtained via BMC command line. |
| 23 | [Tags] Verify_Redfish_BMC_Time |
| 24 | |
| 25 | ${redfish_date_time}= Redfish Get DateTime |
| 26 | ${cli_date_time}= CLI Get BMC DateTime |
| 27 | ${time_diff}= Subtract Date From Date ${cli_date_time} |
| 28 | ... ${redfish_date_time} |
| 29 | ${time_diff}= Evaluate abs(${time_diff}) |
| 30 | Rprint Vars redfish_date_time cli_date_time time_diff |
| 31 | Should Be True ${time_diff} < ${max_time_diff_in_seconds} |
| 32 | ... The difference between Redfish time and CLI time exceeds the allowed time difference. |
| 33 | |
| 34 | |
Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 35 | Verify Set Time Using Redfish |
| 36 | [Documentation] Verify set time using redfish API. |
| 37 | [Tags] Verify_Set_Time_Using_Redfish |
| 38 | |
| 39 | ${old_bmc_time}= CLI Get BMC DateTime |
| 40 | # Add 3 days to current date. |
| 41 | ${new_bmc_time}= Add Time to Date ${old_bmc_time} 3 Days |
| 42 | Redfish Set DateTime ${new_bmc_time} |
| 43 | ${cli_bmc_time}= CLI Get BMC DateTime |
| 44 | ${time_diff}= Subtract Date From Date ${cli_bmc_time} |
| 45 | ... ${new_bmc_time} |
| 46 | ${time_diff}= Evaluate abs(${time_diff}) |
| 47 | Rprint Vars old_bmc_time new_bmc_time cli_bmc_time time_diff max_time_diff_in_seconds |
| 48 | Should Be True ${time_diff} < ${max_time_diff_in_seconds} |
| 49 | ... The difference between Redfish time and CLI time exceeds the allowed time difference. |
| 50 | # Setting back to old bmc time. |
| 51 | Redfish Set DateTime ${old_bmc_time} |
| 52 | |
| 53 | |
Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 54 | Verify Set DateTime With Invalid Data Using Redfish |
| 55 | [Documentation] Verify error while setting invalid DateTime using Redfish. |
| 56 | [Tags] Verify_Set_DateTime_With_Invalid_Data_Using_Redfish |
| 57 | |
| 58 | Redfish Set DateTime ${invalid_datetime} valid_status_codes=[${HTTP_BAD_REQUEST}] |
| 59 | |
| 60 | |
Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 61 | Verify NTP Server Set |
| 62 | [Documentation] Verify NTP server set. |
| 63 | [Tags] Verify_NTP_Server_Set |
| 64 | |
| 65 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']} |
| 66 | ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI} |
| 67 | Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} |
| 68 | ... msg=NTP server value ${ntp_server_1} not stored. |
| 69 | Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_2} |
| 70 | ... msg=NTP server value ${ntp_server_2} not stored. |
| 71 | |
| 72 | |
| 73 | Verify NTP Server Value Not Duplicated |
| 74 | [Documentation] Verify NTP servers value not same for both primary and secondary server. |
| 75 | [Tags] Verify_NTP_Server_Value_Not_Duplicated |
| 76 | |
| 77 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_1}']} |
| 78 | ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI} |
| 79 | Should Contain X Times ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} 1 |
George Keishing | 1af70ef | 2019-06-11 09:31:10 -0500 | [diff] [blame] | 80 | ... msg=NTP primary and secondary server values should not be same. |
Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 81 | |
| 82 | |
Sivas SRR | aac72b0 | 2019-06-11 08:56:10 -0500 | [diff] [blame] | 83 | Verify NTP Server Setting Persist After BMC Reboot |
| 84 | [Documentation] Verify NTP server setting persist after BMC reboot. |
| 85 | [Tags] Verify_NTP_Server_Setting_Persist_After_BMC_Reboot |
| 86 | |
| 87 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']} |
| 88 | Redfish OBMC Reboot (off) |
| 89 | Redfish.Login |
| 90 | ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI} |
| 91 | Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} |
| 92 | ... msg=NTP server value ${ntp_server_1} not stored. |
| 93 | Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_2} |
| 94 | ... msg=NTP server value ${ntp_server_2} not stored. |
| 95 | Redfish.Logout |
| 96 | |
| 97 | |
Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 98 | *** Keywords *** |
| 99 | |
| 100 | Test Teardown Execution |
| 101 | [Documentation] Do the post test teardown. |
| 102 | |
| 103 | FFDC On Test Case Fail |
| 104 | redfish.Logout |
| 105 | |
| 106 | |
| 107 | Redfish Get DateTime |
| 108 | [Documentation] Returns BMC Datetime value from Redfish. |
| 109 | |
| 110 | ${date_time}= Redfish.Get Attribute ${REDFISH_BASE_URI}Managers/bmc DateTime |
| 111 | [Return] ${date_time} |
Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 112 | |
| 113 | |
| 114 | Redfish Set DateTime |
| 115 | [Documentation] Set DateTime using Redfish. |
Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 116 | [Arguments] ${date_time} &{kwargs} |
Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 117 | # Description of argument(s): |
Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 118 | # date_time New time to set for BMC (eg. |
| 119 | # "2019-06-30 09:21:28"). |
| 120 | # kwargs Additional parms to be passed directly to |
| 121 | # th Redfish.Patch function. A good use for |
| 122 | # this is when testing a bad date-time, the |
| 123 | # caller can specify |
| 124 | # valid_status_codes=[${HTTP_BAD_REQUEST}]. |
Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 125 | |
Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 126 | Redfish.Patch ${REDFISH_BASE_URI}Managers/bmc body={'DateTime': '${date_time}'} |
| 127 | ... &{kwargs} |