blob: 1e81270409a43019a9ee7851abcfe535a096d5fc [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
13Suite Teardown Redfish.Logout
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.
120 Redfish.Logout
121
122
Sivas SRR20fe0322019-06-17 04:24:18 -0500123Verify Enable NTP
124 [Documentation] Verify NTP protocol mode can be enabled.
125 [Teardown] Restore NTP Mode
126 [Tags] Verify_Enable_NTP
127
128 ${original_ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP
129 Set Suite Variable ${original_ntp}
130 Rprint Vars original_ntp fmt=terse
131 # The following patch command should set the ["NTP"]["ProtocolEnabled"] property to "True".
132 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={u'NTPEnabled': ${True}}
133 ${ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP
134 Rprint Vars ntp fmt=terse
135 Rvalid Value ntp["ProtocolEnabled"] valid_values=[True]
136
137
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500138*** Keywords ***
139
Sivas SRR4d645992019-06-20 05:34:50 -0500140
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500141Test Teardown Execution
142 [Documentation] Do the post test teardown.
143
144 FFDC On Test Case Fail
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500145
146
147Redfish Get DateTime
148 [Documentation] Returns BMC Datetime value from Redfish.
149
150 ${date_time}= Redfish.Get Attribute ${REDFISH_BASE_URI}Managers/bmc DateTime
151 [Return] ${date_time}
Sivas SRR8a53dad2019-05-16 08:56:14 -0500152
153
154Redfish Set DateTime
155 [Documentation] Set DateTime using Redfish.
Sivas SRR3f152ae2019-06-07 10:02:51 -0500156 [Arguments] ${date_time} &{kwargs}
Sivas SRR8a53dad2019-05-16 08:56:14 -0500157 # Description of argument(s):
Sivas SRR3f152ae2019-06-07 10:02:51 -0500158 # date_time New time to set for BMC (eg.
159 # "2019-06-30 09:21:28").
160 # kwargs Additional parms to be passed directly to
161 # th Redfish.Patch function. A good use for
162 # this is when testing a bad date-time, the
163 # caller can specify
164 # valid_status_codes=[${HTTP_BAD_REQUEST}].
Sivas SRR8a53dad2019-05-16 08:56:14 -0500165
Sivas SRR3f152ae2019-06-07 10:02:51 -0500166 Redfish.Patch ${REDFISH_BASE_URI}Managers/bmc body={'DateTime': '${date_time}'}
167 ... &{kwargs}
Sushil Singh79b04aa2019-06-18 05:25:34 -0500168
169
170Rest Set Time Owner
171 [Documentation] Set time owner of the system via REST.
172
173 # BMC_OWNER is defined in variable.py.
174 ${data}= Create Dictionary data=${BMC_OWNER}
175 Write Attribute ${TIME_MANAGER_URI}owner TimeOwner data=${data} verify=${TRUE}
176
Sivas SRR20fe0322019-06-17 04:24:18 -0500177Restore NTP Mode
178 [Documentation] Restore the original NTP mode.
179
180
181 Return From Keyword If &{original_ntp} == &{EMPTY}
182 Print Timen Restore NTP Mode.
183 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI}
184 ... body={u'NTPEnabled': ${original_ntp["ProtocolEnabled"]}}
185
186
187Suite Setup Execution
188 [Documentation] Do the suite level setup.
189
190 Printn
191 Redfish.Login