blob: ea01908ba86c5e53a48f65ef61acdb80d6d5bafa [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
8
9Test Setup Run Keywords Printn AND redfish.Login
10Test Teardown Test Teardown Execution
11
12*** Variables ***
13${max_time_diff_in_seconds} 6
Sivas SRR3f152ae2019-06-07 10:02:51 -050014${invalid_datetime} "2019-04-251T12:24:46+00:00"
Sivas SRR0e3bc6d2019-04-23 08:36:35 -050015
16*** Test Cases ***
17
18Verify Redfish BMC Time
19 [Documentation] Verify that date/time obtained via redfish matches
20 ... date/time obtained via BMC command line.
21 [Tags] Verify_Redfish_BMC_Time
22
23 ${redfish_date_time}= Redfish Get DateTime
24 ${cli_date_time}= CLI Get BMC DateTime
25 ${time_diff}= Subtract Date From Date ${cli_date_time}
26 ... ${redfish_date_time}
27 ${time_diff}= Evaluate abs(${time_diff})
28 Rprint Vars redfish_date_time cli_date_time time_diff
29 Should Be True ${time_diff} < ${max_time_diff_in_seconds}
30 ... The difference between Redfish time and CLI time exceeds the allowed time difference.
31
32
Sivas SRR8a53dad2019-05-16 08:56:14 -050033Verify Set Time Using Redfish
34 [Documentation] Verify set time using redfish API.
35 [Tags] Verify_Set_Time_Using_Redfish
36
37 ${old_bmc_time}= CLI Get BMC DateTime
38 # Add 3 days to current date.
39 ${new_bmc_time}= Add Time to Date ${old_bmc_time} 3 Days
40 Redfish Set DateTime ${new_bmc_time}
41 ${cli_bmc_time}= CLI Get BMC DateTime
42 ${time_diff}= Subtract Date From Date ${cli_bmc_time}
43 ... ${new_bmc_time}
44 ${time_diff}= Evaluate abs(${time_diff})
45 Rprint Vars old_bmc_time new_bmc_time cli_bmc_time time_diff max_time_diff_in_seconds
46 Should Be True ${time_diff} < ${max_time_diff_in_seconds}
47 ... The difference between Redfish time and CLI time exceeds the allowed time difference.
48 # Setting back to old bmc time.
49 Redfish Set DateTime ${old_bmc_time}
50
51
Sivas SRR3f152ae2019-06-07 10:02:51 -050052Verify Set DateTime With Invalid Data Using Redfish
53 [Documentation] Verify error while setting invalid DateTime using Redfish.
54 [Tags] Verify_Set_DateTime_With_Invalid_Data_Using_Redfish
55
56 Redfish Set DateTime ${invalid_datetime} valid_status_codes=[${HTTP_BAD_REQUEST}]
57
58
Sivas SRR0e3bc6d2019-04-23 08:36:35 -050059*** Keywords ***
60
61Test Teardown Execution
62 [Documentation] Do the post test teardown.
63
64 FFDC On Test Case Fail
65 redfish.Logout
66
67
68Redfish Get DateTime
69 [Documentation] Returns BMC Datetime value from Redfish.
70
71 ${date_time}= Redfish.Get Attribute ${REDFISH_BASE_URI}Managers/bmc DateTime
72 [Return] ${date_time}
Sivas SRR8a53dad2019-05-16 08:56:14 -050073
74
75Redfish Set DateTime
76 [Documentation] Set DateTime using Redfish.
Sivas SRR3f152ae2019-06-07 10:02:51 -050077 [Arguments] ${date_time} &{kwargs}
Sivas SRR8a53dad2019-05-16 08:56:14 -050078 # Description of argument(s):
Sivas SRR3f152ae2019-06-07 10:02:51 -050079 # date_time New time to set for BMC (eg.
80 # "2019-06-30 09:21:28").
81 # kwargs Additional parms to be passed directly to
82 # th Redfish.Patch function. A good use for
83 # this is when testing a bad date-time, the
84 # caller can specify
85 # valid_status_codes=[${HTTP_BAD_REQUEST}].
Sivas SRR8a53dad2019-05-16 08:56:14 -050086
Sivas SRR3f152ae2019-06-07 10:02:51 -050087 Redfish.Patch ${REDFISH_BASE_URI}Managers/bmc body={'DateTime': '${date_time}'}
88 ... &{kwargs}
Sivas SRR8a53dad2019-05-16 08:56:14 -050089