blob: 5515473db7c214c22b006cdcdb7bb0a3af8b014e [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 SRR3f152ae2019-06-07 10:02:51 -050017${invalid_datetime} "2019-04-251T12:24:46+00:00"
Sivas SRR62d22d02019-06-08 12:13:31 -050018${ntp_server_1} "9.9.9.9"
19${ntp_server_2} "2.2.3.3"
Sivas SRR20fe0322019-06-17 04:24:18 -050020&{original_ntp} &{EMPTY}
Sivas SRR0e3bc6d2019-04-23 08:36:35 -050021
22*** Test Cases ***
23
24Verify 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 SRR8a53dad2019-05-16 08:56:14 -050039Verify Set Time Using Redfish
40 [Documentation] Verify set time using redfish API.
41 [Tags] Verify_Set_Time_Using_Redfish
42
Sushil Singh79b04aa2019-06-18 05:25:34 -050043 Rest Set Time Owner
44
Sivas SRR8a53dad2019-05-16 08:56:14 -050045 ${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 SRR3f152ae2019-06-07 10:02:51 -050060Verify 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 SRR4d645992019-06-20 05:34:50 -050067Verify 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 SRR62d22d02019-06-08 12:13:31 -050086Verify 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
98Verify 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 Keishing1af70ef2019-06-11 09:31:10 -0500105 ... msg=NTP primary and secondary server values should not be same.
Sivas SRR62d22d02019-06-08 12:13:31 -0500106
107
Sivas SRRaac72b02019-06-11 08:56:10 -0500108Verify 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 SRRaac72b02019-06-11 08:56:10 -0500120
121
Sivas SRR20fe0322019-06-17 04:24:18 -0500122Verify 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 Walsh39c00512019-07-17 10:54:06 -0500129 Rprint Vars original_ntp
Sivas SRR20fe0322019-06-17 04:24:18 -0500130 # 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 Walsh39c00512019-07-17 10:54:06 -0500133 Rprint Vars ntp
Sivas SRR20fe0322019-06-17 04:24:18 -0500134 Rvalid Value ntp["ProtocolEnabled"] valid_values=[True]
135
136
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500137*** Keywords ***
138
Sivas SRR4d645992019-06-20 05:34:50 -0500139
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500140Test Teardown Execution
141 [Documentation] Do the post test teardown.
142
143 FFDC On Test Case Fail
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500144
145
146Redfish 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 SRR8a53dad2019-05-16 08:56:14 -0500151
152
153Redfish Set DateTime
154 [Documentation] Set DateTime using Redfish.
Sivas SRR3f152ae2019-06-07 10:02:51 -0500155 [Arguments] ${date_time} &{kwargs}
Sivas SRR8a53dad2019-05-16 08:56:14 -0500156 # Description of argument(s):
Sivas SRR3f152ae2019-06-07 10:02:51 -0500157 # 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 SRR8a53dad2019-05-16 08:56:14 -0500164
Sivas SRR3f152ae2019-06-07 10:02:51 -0500165 Redfish.Patch ${REDFISH_BASE_URI}Managers/bmc body={'DateTime': '${date_time}'}
166 ... &{kwargs}
Sushil Singh79b04aa2019-06-18 05:25:34 -0500167
168
169Rest 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 SRR20fe0322019-06-17 04:24:18 -0500176Restore 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
186Suite Setup Execution
187 [Documentation] Do the suite level setup.
188
189 Printn
190 Redfish.Login
George Keishingade5f6e2019-07-12 11:42:42 -0500191 Rest Set Time Owner
192
193Suite Teardown Execution
194 [Documentation] Do the suite level teardown.
195 Rest Set Time Owner
Sivas SRR64613ff2019-07-13 03:06:33 -0500196 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI}
197 ... body={'NTPServers': ['${EMPTY}', '${EMPTY}']}
George Keishingade5f6e2019-07-12 11:42:42 -0500198 Redfish.Logout