blob: 9f35fa82b46f2589a18366195f24396cf7c66bfe [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
14
15*** Test Cases ***
16
17Verify Redfish BMC Time
18 [Documentation] Verify that date/time obtained via redfish matches
19 ... date/time obtained via BMC command line.
20 [Tags] Verify_Redfish_BMC_Time
21
22 ${redfish_date_time}= Redfish Get DateTime
23 ${cli_date_time}= CLI Get BMC DateTime
24 ${time_diff}= Subtract Date From Date ${cli_date_time}
25 ... ${redfish_date_time}
26 ${time_diff}= Evaluate abs(${time_diff})
27 Rprint Vars redfish_date_time cli_date_time time_diff
28 Should Be True ${time_diff} < ${max_time_diff_in_seconds}
29 ... The difference between Redfish time and CLI time exceeds the allowed time difference.
30
31
Sivas SRR8a53dad2019-05-16 08:56:14 -050032Verify Set Time Using Redfish
33 [Documentation] Verify set time using redfish API.
34 [Tags] Verify_Set_Time_Using_Redfish
35
36 ${old_bmc_time}= CLI Get BMC DateTime
37 # Add 3 days to current date.
38 ${new_bmc_time}= Add Time to Date ${old_bmc_time} 3 Days
39 Redfish Set DateTime ${new_bmc_time}
40 ${cli_bmc_time}= CLI Get BMC DateTime
41 ${time_diff}= Subtract Date From Date ${cli_bmc_time}
42 ... ${new_bmc_time}
43 ${time_diff}= Evaluate abs(${time_diff})
44 Rprint Vars old_bmc_time new_bmc_time cli_bmc_time time_diff max_time_diff_in_seconds
45 Should Be True ${time_diff} < ${max_time_diff_in_seconds}
46 ... The difference between Redfish time and CLI time exceeds the allowed time difference.
47 # Setting back to old bmc time.
48 Redfish Set DateTime ${old_bmc_time}
49
50
Sivas SRR0e3bc6d2019-04-23 08:36:35 -050051*** Keywords ***
52
53Test Teardown Execution
54 [Documentation] Do the post test teardown.
55
56 FFDC On Test Case Fail
57 redfish.Logout
58
59
60Redfish Get DateTime
61 [Documentation] Returns BMC Datetime value from Redfish.
62
63 ${date_time}= Redfish.Get Attribute ${REDFISH_BASE_URI}Managers/bmc DateTime
64 [Return] ${date_time}
Sivas SRR8a53dad2019-05-16 08:56:14 -050065
66
67Redfish Set DateTime
68 [Documentation] Set DateTime using Redfish.
69 [Arguments] ${date_time}
70 # Description of argument(s):
71 # date_time New time to set for BMC (eg. 2019-06-30 09:21:28).
72
73 ${payload}= Create Dictionary DateTime=${date_time}
74 Redfish.Patch ${REDFISH_BASE_URI}Managers/bmc body=&{payload}
75 ... valid_status_codes=[${HTTP_OK}, ${HTTP_BAD_REQUEST}]
76
77