blob: ff320784115253b3a86c73665eeda34914581221 [file] [log] [blame]
Sivas SRR0e3bc6d2019-04-23 08:36:35 -05001*** Settings ***
2Documentation Test BMC manager time functionality.
Sivas SRR0e3bc6d2019-04-23 08:36:35 -05003Resource ../../lib/openbmc_ffdc.robot
Anvesh-Kumar_Rayankula365b8f92024-08-04 00:07:19 -05004Resource ../../lib/bmc_date_and_time_utils.robot
Sivas SRR0e3bc6d2019-04-23 08:36:35 -05005
Michael Walsh09083a82019-08-01 12:46:16 -05006Test Setup Printn
Sivas SRR0e3bc6d2019-04-23 08:36:35 -05007Test Teardown Test Teardown Execution
Sivas SRR20fe0322019-06-17 04:24:18 -05008Suite Setup Suite Setup Execution
George Keishingade5f6e2019-07-12 11:42:42 -05009Suite Teardown Suite Teardown Execution
Sivas SRR0e3bc6d2019-04-23 08:36:35 -050010
Matt Fischer6fb70d92023-10-24 19:06:33 -060011Test Tags Managers_BMC_Time
George Keishing79fcf232023-10-12 17:06:38 +053012
Sivas SRR0e3bc6d2019-04-23 08:36:35 -050013*** Variables ***
George Keishing79fcf232023-10-12 17:06:38 +053014
Sivas SRR0e3bc6d2019-04-23 08:36:35 -050015${max_time_diff_in_seconds} 6
Sivas SRR9e00ff32019-07-18 10:38:44 -050016# The "offset" consists of the value "26" specified for hours. Redfish will
17# convert that to the next day + 2 hours.
18${date_time_with_offset} 2019-04-25T26:24:46+00:00
19${expected_date_time} 2019-04-26T02:24:46+00:00
Sivas SRR3f152ae2019-06-07 10:02:51 -050020${invalid_datetime} "2019-04-251T12:24:46+00:00"
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
Anusha Dathatri87e4e552020-05-28 07:02:42 -050043 Set Time To Manual Mode
Sushil Singh79b04aa2019-06-18 05:25:34 -050044
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 SRR9e00ff32019-07-18 10:38:44 -050060Verify Set DateTime With Offset Using Redfish
61 [Documentation] Verify set DateTime with offset using redfish API.
62 [Tags] Verify_Set_DateTime_With_Offset_Using_Redfish
63 [Teardown] Run Keywords Redfish Set DateTime AND FFDC On Test Case Fail
64
65 Redfish Set DateTime ${date_time_with_offset}
66 ${cli_bmc_time}= CLI Get BMC DateTime
67
68 ${date_time_diff}= Subtract Date From Date ${cli_bmc_time}
69 ... ${expected_date_time} exclude_millis=yes
70 ${date_time_diff}= Convert to Integer ${date_time_diff}
Michael Walsh09083a82019-08-01 12:46:16 -050071 Rprint Vars date_time_with_offset expected_date_time cli_bmc_time
Sivas SRR9e00ff32019-07-18 10:38:44 -050072 ... date_time_diff max_time_diff_in_seconds
Michael Walsh09083a82019-08-01 12:46:16 -050073 Valid Range date_time_diff 0 ${max_time_diff_in_seconds}
Sivas SRR9e00ff32019-07-18 10:38:44 -050074
75
Sivas SRR3f152ae2019-06-07 10:02:51 -050076Verify Set DateTime With Invalid Data Using Redfish
77 [Documentation] Verify error while setting invalid DateTime using Redfish.
78 [Tags] Verify_Set_DateTime_With_Invalid_Data_Using_Redfish
79
80 Redfish Set DateTime ${invalid_datetime} valid_status_codes=[${HTTP_BAD_REQUEST}]
81
82
Sivas SRR4d645992019-06-20 05:34:50 -050083Verify DateTime Persists After Reboot
84 [Documentation] Verify date persists after BMC reboot.
85 [Tags] Verify_DateTime_Persists_After_Reboot
86
87 # Synchronize BMC date/time to local system date/time.
88 ${local_system_time}= Get Current Date
89 Redfish Set DateTime ${local_system_time}
90 Redfish OBMC Reboot (off)
91 Redfish.Login
92 ${bmc_time}= CLI Get BMC DateTime
93 ${local_system_time}= Get Current Date
94 ${time_diff}= Subtract Date From Date ${bmc_time}
95 ... ${local_system_time}
96 ${time_diff}= Evaluate abs(${time_diff})
97 Rprint Vars local_system_time bmc_time time_diff max_time_diff_in_seconds
98 Should Be True ${time_diff} < ${max_time_diff_in_seconds}
99 ... The difference between Redfish time and CLI time exceeds the allowed time difference.
100
101
Anusha Dathatri4ad9f432020-06-29 05:18:29 -0500102Verify Immediate Consumption Of BMC Date
103 [Documentation] Verify immediate change in BMC date time.
104 [Tags] Verify_Immediate_Consumption_Of_BMC_Date
105 [Setup] Run Keywords Set Time To Manual Mode AND
Anusha Dathatriad6a3df2020-07-22 05:20:18 -0500106 ... Redfish Set DateTime valid_status_codes=[${HTTP_OK}]
Anusha Dathatri4ad9f432020-06-29 05:18:29 -0500107 [Teardown] Run Keywords FFDC On Test Case Fail AND
108 ... Redfish Set DateTime valid_status_codes=[${HTTP_OK}]
109 [Template] Set BMC Date And Verify
110
111 # host_state
112 on
113 off
114
115
aravinth0510f031ca12022-06-16 12:47:33 +0000116
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500117*** Keywords ***
118
Sivas SRR4d645992019-06-20 05:34:50 -0500119
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500120Test Teardown Execution
121 [Documentation] Do the post test teardown.
122
123 FFDC On Test Case Fail
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500124
125
Sivas SRR20fe0322019-06-17 04:24:18 -0500126Suite Setup Execution
127 [Documentation] Do the suite level setup.
128
129 Printn
130 Redfish.Login
Tony Lee10822662020-05-12 14:53:35 +0800131 Get NTP Initial Status
ganesanb3937eaa2023-04-15 10:24:38 +0000132 ${old_date_time}= CLI Get BMC DateTime
133 ${year_status}= Run Keyword And Return Status Should Not Contain ${old_date_time} ${year_without_ntp}
134 Run Keyword If ${year_status} == False
135 ... Enable NTP And Add NTP Address
Anusha Dathatri87e4e552020-05-28 07:02:42 -0500136 Set Time To Manual Mode
Tony Lee10822662020-05-12 14:53:35 +0800137
George Keishingade5f6e2019-07-12 11:42:42 -0500138
139Suite Teardown Execution
140 [Documentation] Do the suite level teardown.
Sivas SRR9e00ff32019-07-18 10:38:44 -0500141
Anusha Dathatri87e4e552020-05-28 07:02:42 -0500142 Set Time To Manual Mode
Tony Lee10822662020-05-12 14:53:35 +0800143 Restore NTP Status
George Keishingade5f6e2019-07-12 11:42:42 -0500144 Redfish.Logout