blob: d8457432b6f2473b2bbf2dac85dbfd5d2b268680 [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${date_time_with_offset} 2019-04-25T26:24:46+00:00
sarandev33d500892025-01-21 01:45:16 -060017${invalid_datetime} 2019-04-251T12:24:46+00:00
Sivas SRR0e3bc6d2019-04-23 08:36:35 -050018
19*** Test Cases ***
20
21Verify Redfish BMC Time
22 [Documentation] Verify that date/time obtained via redfish matches
23 ... date/time obtained via BMC command line.
24 [Tags] Verify_Redfish_BMC_Time
25
26 ${redfish_date_time}= Redfish Get DateTime
27 ${cli_date_time}= CLI Get BMC DateTime
28 ${time_diff}= Subtract Date From Date ${cli_date_time}
29 ... ${redfish_date_time}
30 ${time_diff}= Evaluate abs(${time_diff})
31 Rprint Vars redfish_date_time cli_date_time time_diff
32 Should Be True ${time_diff} < ${max_time_diff_in_seconds}
33 ... The difference between Redfish time and CLI time exceeds the allowed time difference.
34
35
Sivas SRR8a53dad2019-05-16 08:56:14 -050036Verify Set Time Using Redfish
37 [Documentation] Verify set time using redfish API.
38 [Tags] Verify_Set_Time_Using_Redfish
39
Anusha Dathatri87e4e552020-05-28 07:02:42 -050040 Set Time To Manual Mode
Sushil Singh79b04aa2019-06-18 05:25:34 -050041
Sivas SRR8a53dad2019-05-16 08:56:14 -050042 ${old_bmc_time}= CLI Get BMC DateTime
43 # Add 3 days to current date.
44 ${new_bmc_time}= Add Time to Date ${old_bmc_time} 3 Days
45 Redfish Set DateTime ${new_bmc_time}
46 ${cli_bmc_time}= CLI Get BMC DateTime
47 ${time_diff}= Subtract Date From Date ${cli_bmc_time}
48 ... ${new_bmc_time}
49 ${time_diff}= Evaluate abs(${time_diff})
50 Rprint Vars old_bmc_time new_bmc_time cli_bmc_time time_diff max_time_diff_in_seconds
51 Should Be True ${time_diff} < ${max_time_diff_in_seconds}
52 ... The difference between Redfish time and CLI time exceeds the allowed time difference.
53 # Setting back to old bmc time.
54 Redfish Set DateTime ${old_bmc_time}
55
56
Sivas SRR9e00ff32019-07-18 10:38:44 -050057Verify Set DateTime With Offset Using Redfish
sarandev34055c962025-03-25 00:49:55 -050058 [Documentation] Verify error while setting DateTime with offset using redfish API.
Sivas SRR9e00ff32019-07-18 10:38:44 -050059 [Tags] Verify_Set_DateTime_With_Offset_Using_Redfish
60 [Teardown] Run Keywords Redfish Set DateTime AND FFDC On Test Case Fail
61
sarandev34055c962025-03-25 00:49:55 -050062 Redfish Set DateTime ${date_time_with_offset} invalid
Sivas SRR9e00ff32019-07-18 10:38:44 -050063
64
Sivas SRR3f152ae2019-06-07 10:02:51 -050065Verify Set DateTime With Invalid Data Using Redfish
66 [Documentation] Verify error while setting invalid DateTime using Redfish.
67 [Tags] Verify_Set_DateTime_With_Invalid_Data_Using_Redfish
68
sarandev34055c962025-03-25 00:49:55 -050069 Redfish Set DateTime ${invalid_datetime} invalid
Sivas SRR3f152ae2019-06-07 10:02:51 -050070
71
Sivas SRR4d645992019-06-20 05:34:50 -050072Verify DateTime Persists After Reboot
73 [Documentation] Verify date persists after BMC reboot.
74 [Tags] Verify_DateTime_Persists_After_Reboot
75
76 # Synchronize BMC date/time to local system date/time.
77 ${local_system_time}= Get Current Date
78 Redfish Set DateTime ${local_system_time}
79 Redfish OBMC Reboot (off)
80 Redfish.Login
81 ${bmc_time}= CLI Get BMC DateTime
82 ${local_system_time}= Get Current Date
83 ${time_diff}= Subtract Date From Date ${bmc_time}
84 ... ${local_system_time}
85 ${time_diff}= Evaluate abs(${time_diff})
86 Rprint Vars local_system_time bmc_time time_diff max_time_diff_in_seconds
87 Should Be True ${time_diff} < ${max_time_diff_in_seconds}
88 ... The difference between Redfish time and CLI time exceeds the allowed time difference.
89
90
Anusha Dathatri4ad9f432020-06-29 05:18:29 -050091Verify Immediate Consumption Of BMC Date
92 [Documentation] Verify immediate change in BMC date time.
93 [Tags] Verify_Immediate_Consumption_Of_BMC_Date
94 [Setup] Run Keywords Set Time To Manual Mode AND
sarandev34055c962025-03-25 00:49:55 -050095 ... Redfish Set DateTime
Anusha Dathatri4ad9f432020-06-29 05:18:29 -050096 [Teardown] Run Keywords FFDC On Test Case Fail AND
sarandev34055c962025-03-25 00:49:55 -050097 ... Redfish Set DateTime
Anusha Dathatri4ad9f432020-06-29 05:18:29 -050098 [Template] Set BMC Date And Verify
99
100 # host_state
101 on
102 off
103
104
aravinth0510f031ca12022-06-16 12:47:33 +0000105
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500106*** Keywords ***
107
Sivas SRR4d645992019-06-20 05:34:50 -0500108
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500109Test Teardown Execution
110 [Documentation] Do the post test teardown.
111
112 FFDC On Test Case Fail
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500113
114
Sivas SRR20fe0322019-06-17 04:24:18 -0500115Suite Setup Execution
116 [Documentation] Do the suite level setup.
117
118 Printn
119 Redfish.Login
Tony Lee10822662020-05-12 14:53:35 +0800120 Get NTP Initial Status
ganesanb3937eaa2023-04-15 10:24:38 +0000121 ${old_date_time}= CLI Get BMC DateTime
122 ${year_status}= Run Keyword And Return Status Should Not Contain ${old_date_time} ${year_without_ntp}
123 Run Keyword If ${year_status} == False
124 ... Enable NTP And Add NTP Address
Anusha Dathatri87e4e552020-05-28 07:02:42 -0500125 Set Time To Manual Mode
Tony Lee10822662020-05-12 14:53:35 +0800126
George Keishingade5f6e2019-07-12 11:42:42 -0500127
128Suite Teardown Execution
129 [Documentation] Do the suite level teardown.
Sivas SRR9e00ff32019-07-18 10:38:44 -0500130
Anusha Dathatri87e4e552020-05-28 07:02:42 -0500131 Set Time To Manual Mode
Tony Lee10822662020-05-12 14:53:35 +0800132 Restore NTP Status
George Keishingade5f6e2019-07-12 11:42:42 -0500133 Redfish.Logout