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