blob: d4cd332dffce54d2a3207f66dc2bf3d7c9d6c1c4 [file] [log] [blame]
Sivas SRR0e3bc6d2019-04-23 08:36:35 -05001*** Settings ***
2Documentation Test BMC manager time functionality.
3Resource ../../lib/resource.robot
4Resource ../../lib/bmc_redfish_resource.robot
5Resource ../../lib/common_utils.robot
6Resource ../../lib/openbmc_ffdc.robot
7Resource ../../lib/utils.robot
Sushil Singh79b04aa2019-06-18 05:25:34 -05008Resource ../../lib/rest_client.robot
Sivas SRR20fe0322019-06-17 04:24:18 -05009Library ../../lib/gen_robot_valid.py
Sivas SRR0e3bc6d2019-04-23 08:36:35 -050010
Sivas SRR0e3bc6d2019-04-23 08:36:35 -050011Test Teardown Test Teardown Execution
Sivas SRR20fe0322019-06-17 04:24:18 -050012Suite Setup Suite Setup Execution
George Keishingade5f6e2019-07-12 11:42:42 -050013Suite Teardown Suite Teardown Execution
Sivas SRR0e3bc6d2019-04-23 08:36:35 -050014
15*** Variables ***
16${max_time_diff_in_seconds} 6
Sivas SRR9e00ff32019-07-18 10:38:44 -050017# The "offset" consists of the value "26" specified for hours. Redfish will
18# convert that to the next day + 2 hours.
19${date_time_with_offset} 2019-04-25T26:24:46+00:00
20${expected_date_time} 2019-04-26T02:24:46+00:00
Sivas SRR3f152ae2019-06-07 10:02:51 -050021${invalid_datetime} "2019-04-251T12:24:46+00:00"
Sivas SRR62d22d02019-06-08 12:13:31 -050022${ntp_server_1} "9.9.9.9"
23${ntp_server_2} "2.2.3.3"
Sivas SRR20fe0322019-06-17 04:24:18 -050024&{original_ntp} &{EMPTY}
Sivas SRR0e3bc6d2019-04-23 08:36:35 -050025
26*** Test Cases ***
27
28Verify Redfish BMC Time
29 [Documentation] Verify that date/time obtained via redfish matches
30 ... date/time obtained via BMC command line.
31 [Tags] Verify_Redfish_BMC_Time
32
33 ${redfish_date_time}= Redfish Get DateTime
34 ${cli_date_time}= CLI Get BMC DateTime
35 ${time_diff}= Subtract Date From Date ${cli_date_time}
36 ... ${redfish_date_time}
37 ${time_diff}= Evaluate abs(${time_diff})
38 Rprint Vars redfish_date_time cli_date_time time_diff
39 Should Be True ${time_diff} < ${max_time_diff_in_seconds}
40 ... The difference between Redfish time and CLI time exceeds the allowed time difference.
41
42
Sivas SRR8a53dad2019-05-16 08:56:14 -050043Verify Set Time Using Redfish
44 [Documentation] Verify set time using redfish API.
45 [Tags] Verify_Set_Time_Using_Redfish
46
Sushil Singh79b04aa2019-06-18 05:25:34 -050047 Rest Set Time Owner
48
Sivas SRR8a53dad2019-05-16 08:56:14 -050049 ${old_bmc_time}= CLI Get BMC DateTime
50 # Add 3 days to current date.
51 ${new_bmc_time}= Add Time to Date ${old_bmc_time} 3 Days
52 Redfish Set DateTime ${new_bmc_time}
53 ${cli_bmc_time}= CLI Get BMC DateTime
54 ${time_diff}= Subtract Date From Date ${cli_bmc_time}
55 ... ${new_bmc_time}
56 ${time_diff}= Evaluate abs(${time_diff})
57 Rprint Vars old_bmc_time new_bmc_time cli_bmc_time time_diff max_time_diff_in_seconds
58 Should Be True ${time_diff} < ${max_time_diff_in_seconds}
59 ... The difference between Redfish time and CLI time exceeds the allowed time difference.
60 # Setting back to old bmc time.
61 Redfish Set DateTime ${old_bmc_time}
62
63
Sivas SRR9e00ff32019-07-18 10:38:44 -050064Verify Set DateTime With Offset Using Redfish
65 [Documentation] Verify set DateTime with offset using redfish API.
66 [Tags] Verify_Set_DateTime_With_Offset_Using_Redfish
67 [Teardown] Run Keywords Redfish Set DateTime AND FFDC On Test Case Fail
68
69 Redfish Set DateTime ${date_time_with_offset}
70 ${cli_bmc_time}= CLI Get BMC DateTime
71
72 ${date_time_diff}= Subtract Date From Date ${cli_bmc_time}
73 ... ${expected_date_time} exclude_millis=yes
74 ${date_time_diff}= Convert to Integer ${date_time_diff}
75 Rpvars date_time_with_offset expected_date_time cli_bmc_time
76 ... date_time_diff max_time_diff_in_seconds
77 Rvalid Range date_time_diff 0..${max_time_diff_in_seconds}
78
79
Sivas SRR3f152ae2019-06-07 10:02:51 -050080Verify Set DateTime With Invalid Data Using Redfish
81 [Documentation] Verify error while setting invalid DateTime using Redfish.
82 [Tags] Verify_Set_DateTime_With_Invalid_Data_Using_Redfish
83
84 Redfish Set DateTime ${invalid_datetime} valid_status_codes=[${HTTP_BAD_REQUEST}]
85
86
Sivas SRR4d645992019-06-20 05:34:50 -050087Verify DateTime Persists After Reboot
88 [Documentation] Verify date persists after BMC reboot.
89 [Tags] Verify_DateTime_Persists_After_Reboot
90
91 # Synchronize BMC date/time to local system date/time.
92 ${local_system_time}= Get Current Date
93 Redfish Set DateTime ${local_system_time}
94 Redfish OBMC Reboot (off)
95 Redfish.Login
96 ${bmc_time}= CLI Get BMC DateTime
97 ${local_system_time}= Get Current Date
98 ${time_diff}= Subtract Date From Date ${bmc_time}
99 ... ${local_system_time}
100 ${time_diff}= Evaluate abs(${time_diff})
101 Rprint Vars local_system_time bmc_time time_diff max_time_diff_in_seconds
102 Should Be True ${time_diff} < ${max_time_diff_in_seconds}
103 ... The difference between Redfish time and CLI time exceeds the allowed time difference.
104
105
Sivas SRR62d22d02019-06-08 12:13:31 -0500106Verify NTP Server Set
107 [Documentation] Verify NTP server set.
108 [Tags] Verify_NTP_Server_Set
109
110 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']}
111 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI}
112 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1}
113 ... msg=NTP server value ${ntp_server_1} not stored.
114 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_2}
115 ... msg=NTP server value ${ntp_server_2} not stored.
116
117
118Verify NTP Server Value Not Duplicated
119 [Documentation] Verify NTP servers value not same for both primary and secondary server.
120 [Tags] Verify_NTP_Server_Value_Not_Duplicated
121
122 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_1}']}
123 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI}
124 Should Contain X Times ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} 1
George Keishing1af70ef2019-06-11 09:31:10 -0500125 ... msg=NTP primary and secondary server values should not be same.
Sivas SRR62d22d02019-06-08 12:13:31 -0500126
127
Sivas SRRaac72b02019-06-11 08:56:10 -0500128Verify NTP Server Setting Persist After BMC Reboot
129 [Documentation] Verify NTP server setting persist after BMC reboot.
130 [Tags] Verify_NTP_Server_Setting_Persist_After_BMC_Reboot
131
132 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']}
133 Redfish OBMC Reboot (off)
134 Redfish.Login
135 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI}
136 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1}
137 ... msg=NTP server value ${ntp_server_1} not stored.
138 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_2}
139 ... msg=NTP server value ${ntp_server_2} not stored.
Sivas SRRaac72b02019-06-11 08:56:10 -0500140
141
Sivas SRR20fe0322019-06-17 04:24:18 -0500142Verify Enable NTP
143 [Documentation] Verify NTP protocol mode can be enabled.
144 [Teardown] Restore NTP Mode
145 [Tags] Verify_Enable_NTP
146
147 ${original_ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP
148 Set Suite Variable ${original_ntp}
Michael Walsh39c00512019-07-17 10:54:06 -0500149 Rprint Vars original_ntp
Sivas SRR20fe0322019-06-17 04:24:18 -0500150 # The following patch command should set the ["NTP"]["ProtocolEnabled"] property to "True".
151 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={u'NTPEnabled': ${True}}
152 ${ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP
Michael Walsh39c00512019-07-17 10:54:06 -0500153 Rprint Vars ntp
Sivas SRR20fe0322019-06-17 04:24:18 -0500154 Rvalid Value ntp["ProtocolEnabled"] valid_values=[True]
155
156
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500157*** Keywords ***
158
Sivas SRR4d645992019-06-20 05:34:50 -0500159
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500160Test Teardown Execution
161 [Documentation] Do the post test teardown.
162
163 FFDC On Test Case Fail
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500164
165
166Redfish Get DateTime
167 [Documentation] Returns BMC Datetime value from Redfish.
168
169 ${date_time}= Redfish.Get Attribute ${REDFISH_BASE_URI}Managers/bmc DateTime
170 [Return] ${date_time}
Sivas SRR8a53dad2019-05-16 08:56:14 -0500171
172
173Redfish Set DateTime
174 [Documentation] Set DateTime using Redfish.
Sivas SRR9e00ff32019-07-18 10:38:44 -0500175 [Arguments] ${date_time}=${EMPTY} &{kwargs}
Sivas SRR8a53dad2019-05-16 08:56:14 -0500176 # Description of argument(s):
Sivas SRR3f152ae2019-06-07 10:02:51 -0500177 # date_time New time to set for BMC (eg.
Sivas SRR9e00ff32019-07-18 10:38:44 -0500178 # "2019-06-30 09:21:28"). If this value is
179 # empty, it will be set to the UTC current
180 # date time of the local system.
Sivas SRR3f152ae2019-06-07 10:02:51 -0500181 # kwargs Additional parms to be passed directly to
182 # th Redfish.Patch function. A good use for
183 # this is when testing a bad date-time, the
184 # caller can specify
185 # valid_status_codes=[${HTTP_BAD_REQUEST}].
Sivas SRR8a53dad2019-05-16 08:56:14 -0500186
Sivas SRR9e00ff32019-07-18 10:38:44 -0500187 # Assign default value of UTC current date time if date_time is empty.
188 ${date_time}= Run Keyword If
189 ... '${date_time}' == '${EMPTY}' Get Current Date time_zone=UTC
190 ... ELSE
191 ... Set Variable ${date_time}
Sivas SRR3f152ae2019-06-07 10:02:51 -0500192 Redfish.Patch ${REDFISH_BASE_URI}Managers/bmc body={'DateTime': '${date_time}'}
193 ... &{kwargs}
Sushil Singh79b04aa2019-06-18 05:25:34 -0500194
195
196Rest Set Time Owner
197 [Documentation] Set time owner of the system via REST.
198
199 # BMC_OWNER is defined in variable.py.
200 ${data}= Create Dictionary data=${BMC_OWNER}
201 Write Attribute ${TIME_MANAGER_URI}owner TimeOwner data=${data} verify=${TRUE}
202
Sivas SRR9e00ff32019-07-18 10:38:44 -0500203
Sivas SRR20fe0322019-06-17 04:24:18 -0500204Restore NTP Mode
205 [Documentation] Restore the original NTP mode.
206
207
208 Return From Keyword If &{original_ntp} == &{EMPTY}
209 Print Timen Restore NTP Mode.
210 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI}
211 ... body={u'NTPEnabled': ${original_ntp["ProtocolEnabled"]}}
212
213
214Suite Setup Execution
215 [Documentation] Do the suite level setup.
216
217 Printn
218 Redfish.Login
George Keishingade5f6e2019-07-12 11:42:42 -0500219 Rest Set Time Owner
220
221Suite Teardown Execution
222 [Documentation] Do the suite level teardown.
Sivas SRR9e00ff32019-07-18 10:38:44 -0500223
Sivas SRR64613ff2019-07-13 03:06:33 -0500224 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI}
225 ... body={'NTPServers': ['${EMPTY}', '${EMPTY}']}
Sivas SRR9e00ff32019-07-18 10:38:44 -0500226 Rest Set Time Owner
George Keishingade5f6e2019-07-12 11:42:42 -0500227 Redfish.Logout