blob: 2e6409cd93fa90a2531325d9df7d27daf540bf90 [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 SRR62d22d02019-06-08 12:13:31 -050067Verify NTP Server Set
68 [Documentation] Verify NTP server set.
69 [Tags] Verify_NTP_Server_Set
70
71 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']}
72 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI}
73 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1}
74 ... msg=NTP server value ${ntp_server_1} not stored.
75 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_2}
76 ... msg=NTP server value ${ntp_server_2} not stored.
77
78
79Verify NTP Server Value Not Duplicated
80 [Documentation] Verify NTP servers value not same for both primary and secondary server.
81 [Tags] Verify_NTP_Server_Value_Not_Duplicated
82
83 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_1}']}
84 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI}
85 Should Contain X Times ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} 1
George Keishing1af70ef2019-06-11 09:31:10 -050086 ... msg=NTP primary and secondary server values should not be same.
Sivas SRR62d22d02019-06-08 12:13:31 -050087
88
Sivas SRRaac72b02019-06-11 08:56:10 -050089Verify NTP Server Setting Persist After BMC Reboot
90 [Documentation] Verify NTP server setting persist after BMC reboot.
91 [Tags] Verify_NTP_Server_Setting_Persist_After_BMC_Reboot
92
93 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']}
94 Redfish OBMC Reboot (off)
95 Redfish.Login
96 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI}
97 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1}
98 ... msg=NTP server value ${ntp_server_1} not stored.
99 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_2}
100 ... msg=NTP server value ${ntp_server_2} not stored.
101 Redfish.Logout
102
103
Sivas SRR20fe0322019-06-17 04:24:18 -0500104Verify Enable NTP
105 [Documentation] Verify NTP protocol mode can be enabled.
106 [Teardown] Restore NTP Mode
107 [Tags] Verify_Enable_NTP
108
109 ${original_ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP
110 Set Suite Variable ${original_ntp}
111 Rprint Vars original_ntp fmt=terse
112 # The following patch command should set the ["NTP"]["ProtocolEnabled"] property to "True".
113 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={u'NTPEnabled': ${True}}
114 ${ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP
115 Rprint Vars ntp fmt=terse
116 Rvalid Value ntp["ProtocolEnabled"] valid_values=[True]
117
118
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500119*** Keywords ***
120
121Test Teardown Execution
122 [Documentation] Do the post test teardown.
123
124 FFDC On Test Case Fail
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500125
126
127Redfish Get DateTime
128 [Documentation] Returns BMC Datetime value from Redfish.
129
130 ${date_time}= Redfish.Get Attribute ${REDFISH_BASE_URI}Managers/bmc DateTime
131 [Return] ${date_time}
Sivas SRR8a53dad2019-05-16 08:56:14 -0500132
133
134Redfish Set DateTime
135 [Documentation] Set DateTime using Redfish.
Sivas SRR3f152ae2019-06-07 10:02:51 -0500136 [Arguments] ${date_time} &{kwargs}
Sivas SRR8a53dad2019-05-16 08:56:14 -0500137 # Description of argument(s):
Sivas SRR3f152ae2019-06-07 10:02:51 -0500138 # date_time New time to set for BMC (eg.
139 # "2019-06-30 09:21:28").
140 # kwargs Additional parms to be passed directly to
141 # th Redfish.Patch function. A good use for
142 # this is when testing a bad date-time, the
143 # caller can specify
144 # valid_status_codes=[${HTTP_BAD_REQUEST}].
Sivas SRR8a53dad2019-05-16 08:56:14 -0500145
Sivas SRR3f152ae2019-06-07 10:02:51 -0500146 Redfish.Patch ${REDFISH_BASE_URI}Managers/bmc body={'DateTime': '${date_time}'}
147 ... &{kwargs}
Sushil Singh79b04aa2019-06-18 05:25:34 -0500148
149
150Rest Set Time Owner
151 [Documentation] Set time owner of the system via REST.
152
153 # BMC_OWNER is defined in variable.py.
154 ${data}= Create Dictionary data=${BMC_OWNER}
155 Write Attribute ${TIME_MANAGER_URI}owner TimeOwner data=${data} verify=${TRUE}
156
Sivas SRR20fe0322019-06-17 04:24:18 -0500157Restore NTP Mode
158 [Documentation] Restore the original NTP mode.
159
160
161 Return From Keyword If &{original_ntp} == &{EMPTY}
162 Print Timen Restore NTP Mode.
163 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI}
164 ... body={u'NTPEnabled': ${original_ntp["ProtocolEnabled"]}}
165
166
167Suite Setup Execution
168 [Documentation] Do the suite level setup.
169
170 Printn
171 Redfish.Login
172
173