redfish date time base keywords
Resolves openbmc/openbmc-test-automation#1751
Change-Id: I129b1fb35e16315aa198c4577496fe06f8f7a56f
Signed-off-by: Sivas SRR <sivas.srr@in.ibm.com>
diff --git a/lib/utils.robot b/lib/utils.robot
index afaf56e..6e5ef14 100755
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -698,3 +698,10 @@
[Documentation] Verify that the BMC chassis state is off.
${state}= Get Power State
Should be equal ${state} ${0}
+
+
+CLI Get BMC DateTime
+ [Documentation] Returns BMC date time from date command.
+
+ ${bmc_time_via_date} ${stderr} ${rc}= BMC Execute Command date +"%Y-%m-%d %H:%M:%S" print_err=1
+ [Return] ${bmc_time_via_date}
diff --git a/redfish/managers/test_managers_bmc_time.robot b/redfish/managers/test_managers_bmc_time.robot
new file mode 100644
index 0000000..f1932b9
--- /dev/null
+++ b/redfish/managers/test_managers_bmc_time.robot
@@ -0,0 +1,45 @@
+*** Settings ***
+Documentation Test BMC manager time functionality.
+Resource ../../lib/resource.robot
+Resource ../../lib/bmc_redfish_resource.robot
+Resource ../../lib/common_utils.robot
+Resource ../../lib/openbmc_ffdc.robot
+Resource ../../lib/utils.robot
+
+Test Setup Run Keywords Printn AND redfish.Login
+Test Teardown Test Teardown Execution
+
+*** Variables ***
+${max_time_diff_in_seconds} 6
+
+*** Test Cases ***
+
+Verify Redfish BMC Time
+ [Documentation] Verify that date/time obtained via redfish matches
+ ... date/time obtained via BMC command line.
+ [Tags] Verify_Redfish_BMC_Time
+
+ ${redfish_date_time}= Redfish Get DateTime
+ ${cli_date_time}= CLI Get BMC DateTime
+ ${time_diff}= Subtract Date From Date ${cli_date_time}
+ ... ${redfish_date_time}
+ ${time_diff}= Evaluate abs(${time_diff})
+ Rprint Vars redfish_date_time cli_date_time time_diff
+ Should Be True ${time_diff} < ${max_time_diff_in_seconds}
+ ... The difference between Redfish time and CLI time exceeds the allowed time difference.
+
+
+*** Keywords ***
+
+Test Teardown Execution
+ [Documentation] Do the post test teardown.
+
+ FFDC On Test Case Fail
+ redfish.Logout
+
+
+Redfish Get DateTime
+ [Documentation] Returns BMC Datetime value from Redfish.
+
+ ${date_time}= Redfish.Get Attribute ${REDFISH_BASE_URI}Managers/bmc DateTime
+ [Return] ${date_time}