Added new test case to test_managers_bmc_time
- Verify_Set_DateTime_With_NTP_Enabled
Check set date time is restricted when NTP Protocol is Enabled.
- Added keyword to check NTP Protocol Enabled sync with systemd-timesyncd service status.
Tested: Run robot /redfish/managers/test_managers_bmc_time.robot
Signed-off-by: Aravinth R <aravinthr@ami.com>
Change-Id: Ic17696d9bd53478d3a8ae323869c937c2b2eaeda
diff --git a/redfish/managers/test_managers_bmc_time.robot b/redfish/managers/test_managers_bmc_time.robot
index cfc83c6..89b9f49 100644
--- a/redfish/managers/test_managers_bmc_time.robot
+++ b/redfish/managers/test_managers_bmc_time.robot
@@ -154,6 +154,8 @@
# The following patch command should set the ["NTP"]["ProtocolEnabled"] property to "True".
Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTP':{'ProtocolEnabled': ${True}}}
... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
+ Wait Until Keyword Succeeds 30 sec 5 sec
+ ... Verify System Time Sync Status ${True}
${ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP
Rprint Vars ntp
Valid Value ntp["ProtocolEnabled"] valid_values=[True]
@@ -173,6 +175,19 @@
off
+Verify Set DateTime With NTP Enabled
+ [Documentation] Verify whether set managers dateTime is restricted with NTP enabled.
+ [Tags] Verify_Set_DateTime_With_NTP_Enabled
+
+ Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTP':{'ProtocolEnabled': ${True}}}
+ ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
+ ${ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP
+ Valid Value ntp["ProtocolEnabled"] valid_values=[True]
+ ${local_system_time}= Get Current Date
+ Redfish Set DateTime ${local_system_time}
+ ... valid_status_codes=[${HTTP_BAD_REQUEST}, ${HTTP_INTERNAL_SERVER_ERROR}]
+
+
*** Keywords ***
@@ -301,3 +316,20 @@
Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_2}
... msg=NTP server value ${ntp_server_2} not stored.
+
+Verify System Time Sync Status
+ [Documentation] Verify the status of service systemd-timesyncd matches the NTP protocol enabled state.
+ [Arguments] ${expected_sync_status}=${True}
+
+ # Description of argument(s):
+ # expected_sync_status expected status at which NTP protocol enabled will be updated for verification
+ # (eg. True, False).
+
+ ${resp}= BMC Execute Command
+ ... systemctl status systemd-timesyncd
+ ... ignore_err=${1}
+ ${sync_status}= Get Lines Matching Regexp ${resp[0]} .*Active.*
+ Run Keyword If ${expected_sync_status}==${True}
+ ... Should Contain ${sync_status} active (running)
+ Run Keyword If ${expected_sync_status}==${False}
+ ... Should Contain ${sync_status} inactive (dead)