1365b8f93SAnvesh-Kumar_Rayankula*** Settings ***
2365b8f93SAnvesh-Kumar_RayankulaDocumentation                NTP configuration and verification
3365b8f93SAnvesh-Kumar_Rayankula                             ...  tests.
4365b8f93SAnvesh-Kumar_Rayankula
5365b8f93SAnvesh-Kumar_RayankulaResource                     ../../lib/openbmc_ffdc.robot
6365b8f93SAnvesh-Kumar_RayankulaResource                     ../../lib/bmc_date_and_time_utils.robot
7365b8f93SAnvesh-Kumar_Rayankula
8365b8f93SAnvesh-Kumar_RayankulaTest Setup                   Printn
9365b8f93SAnvesh-Kumar_RayankulaTest Teardown                FFDC On Test Case Fail
10365b8f93SAnvesh-Kumar_RayankulaSuite Setup                  Suite Setup Execution
11365b8f93SAnvesh-Kumar_RayankulaSuite Teardown               Suite Teardown Execution
12365b8f93SAnvesh-Kumar_Rayankula
13365b8f93SAnvesh-Kumar_Rayankula
14365b8f93SAnvesh-Kumar_Rayankula*** Variables ***
15365b8f93SAnvesh-Kumar_Rayankula
16365b8f93SAnvesh-Kumar_Rayankula${ntp_server_1}              9.9.9.9
17365b8f93SAnvesh-Kumar_Rayankula${ntp_server_2}              2.2.3.3
18365b8f93SAnvesh-Kumar_Rayankula&{original_ntp}              &{EMPTY}
19365b8f93SAnvesh-Kumar_Rayankula
20365b8f93SAnvesh-Kumar_Rayankula*** Test Cases ***
21365b8f93SAnvesh-Kumar_Rayankula
22365b8f93SAnvesh-Kumar_RayankulaVerify NTP Server Set
23365b8f93SAnvesh-Kumar_Rayankula    [Documentation]  Patch NTP servers and verify NTP servers is set.
24365b8f93SAnvesh-Kumar_Rayankula    [Tags]  Verify_NTP_Server_Set
25365b8f93SAnvesh-Kumar_Rayankula    [Setup]  Set NTP state  ${True}
26365b8f93SAnvesh-Kumar_Rayankula
27365b8f93SAnvesh-Kumar_Rayankula    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}
28365b8f93SAnvesh-Kumar_Rayankula    ...  body={'NTP':{'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']}}
29365b8f93SAnvesh-Kumar_Rayankula    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
30365b8f93SAnvesh-Kumar_Rayankula
31365b8f93SAnvesh-Kumar_Rayankula    # NTP network take few seconds to reload.
32365b8f93SAnvesh-Kumar_Rayankula    Wait Until Keyword Succeeds  30 sec  10 sec  Verify NTP Servers Are Populated
33365b8f93SAnvesh-Kumar_Rayankula
34365b8f93SAnvesh-Kumar_Rayankula
35365b8f93SAnvesh-Kumar_RayankulaVerify NTP Server Value Not Duplicated
36365b8f93SAnvesh-Kumar_Rayankula    [Documentation]  Verify NTP servers value not same for both primary and secondary server.
37365b8f93SAnvesh-Kumar_Rayankula    [Tags]  Verify_NTP_Server_Value_Not_Duplicated
38365b8f93SAnvesh-Kumar_Rayankula
39365b8f93SAnvesh-Kumar_Rayankula    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}
40365b8f93SAnvesh-Kumar_Rayankula    ...  body={'NTP':{'NTPServers': ['${ntp_server_1}', '${ntp_server_1}']}}
41365b8f93SAnvesh-Kumar_Rayankula    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
42365b8f93SAnvesh-Kumar_Rayankula    ${network_protocol}=  Redfish.Get Properties  ${REDFISH_NW_PROTOCOL_URI}
43365b8f93SAnvesh-Kumar_Rayankula    Should Contain X Times  ${network_protocol["NTP"]["NTPServers"]}  ${ntp_server_1}  1
44365b8f93SAnvesh-Kumar_Rayankula    ...  msg=NTP primary and secondary server values should not be same.
45365b8f93SAnvesh-Kumar_Rayankula
46365b8f93SAnvesh-Kumar_Rayankula
47365b8f93SAnvesh-Kumar_RayankulaVerify NTP Server Setting Persist After BMC Reboot
48365b8f93SAnvesh-Kumar_Rayankula    [Documentation]  Verify NTP server setting persist after BMC reboot.
49365b8f93SAnvesh-Kumar_Rayankula    [Tags]  Verify_NTP_Server_Setting_Persist_After_BMC_Reboot
50365b8f93SAnvesh-Kumar_Rayankula    [Setup]  Set NTP state  ${True}
51365b8f93SAnvesh-Kumar_Rayankula
52365b8f93SAnvesh-Kumar_Rayankula    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}
53365b8f93SAnvesh-Kumar_Rayankula    ...  body={'NTP':{'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']}}
54365b8f93SAnvesh-Kumar_Rayankula    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
55365b8f93SAnvesh-Kumar_Rayankula    Redfish OBMC Reboot (off)
56365b8f93SAnvesh-Kumar_Rayankula    Redfish.Login
57365b8f93SAnvesh-Kumar_Rayankula
58365b8f93SAnvesh-Kumar_Rayankula    # NTP network take few seconds to reload.
59365b8f93SAnvesh-Kumar_Rayankula    Wait Until Keyword Succeeds  30 sec  10 sec  Verify NTP Servers Are Populated
60365b8f93SAnvesh-Kumar_Rayankula
61365b8f93SAnvesh-Kumar_Rayankula
62365b8f93SAnvesh-Kumar_RayankulaVerify Enable NTP
63365b8f93SAnvesh-Kumar_Rayankula    [Documentation]  Verify NTP protocol mode can be enabled.
64365b8f93SAnvesh-Kumar_Rayankula    [Teardown]  Restore NTP Mode
65365b8f93SAnvesh-Kumar_Rayankula    [Tags]  Verify_Enable_NTP
66365b8f93SAnvesh-Kumar_Rayankula
67365b8f93SAnvesh-Kumar_Rayankula    # The following patch command should set the ["NTP"]["ProtocolEnabled"] property to "True".
68365b8f93SAnvesh-Kumar_Rayankula    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}  body={'NTP':{'ProtocolEnabled': ${True}}}
69365b8f93SAnvesh-Kumar_Rayankula    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
70365b8f93SAnvesh-Kumar_Rayankula    Wait Until Keyword Succeeds  1 min  5 sec
71365b8f93SAnvesh-Kumar_Rayankula    ...  Verify System Time Sync Status  ${True}
72365b8f93SAnvesh-Kumar_Rayankula    ${ntp}=  Redfish.Get Attribute  ${REDFISH_NW_PROTOCOL_URI}  NTP
73365b8f93SAnvesh-Kumar_Rayankula    Rprint Vars  ntp
74365b8f93SAnvesh-Kumar_Rayankula    Valid Value  ntp["ProtocolEnabled"]  valid_values=[True]
75365b8f93SAnvesh-Kumar_Rayankula
76*dc9abaacSSweta PotthuriVerify Disble NTP
77*dc9abaacSSweta Potthuri    [Documentation]  Verify NTP protocol mode can be disabled.
78*dc9abaacSSweta Potthuri    [Teardown]  Restore NTP Mode
79*dc9abaacSSweta Potthuri    [Tags]  Verify_Disable_NTP
80*dc9abaacSSweta Potthuri
81*dc9abaacSSweta Potthuri    # The following patch command should set the ["NTP"]["ProtocolEnabled"] property to "False".
82*dc9abaacSSweta Potthuri    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}  body={'NTP':{'ProtocolEnabled': ${False}}}
83*dc9abaacSSweta Potthuri    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
84*dc9abaacSSweta Potthuri    Wait Until Keyword Succeeds  1 min  5 sec
85*dc9abaacSSweta Potthuri    ...  Verify System Time Sync Status  ${False}
86*dc9abaacSSweta Potthuri    ${ntp}=  Redfish.Get Attribute  ${REDFISH_NW_PROTOCOL_URI}  NTP
87*dc9abaacSSweta Potthuri    Rprint Vars  ntp
88*dc9abaacSSweta Potthuri    Valid Value  ntp["ProtocolEnabled"]  valid_values=[False]
89365b8f93SAnvesh-Kumar_Rayankula
90365b8f93SAnvesh-Kumar_RayankulaVerify Set DateTime With NTP Enabled
91365b8f93SAnvesh-Kumar_Rayankula    [Documentation]  Verify whether set managers dateTime is restricted with NTP enabled.
92365b8f93SAnvesh-Kumar_Rayankula    [Tags]  Verify_Set_DateTime_With_NTP_Enabled
93365b8f93SAnvesh-Kumar_Rayankula
94365b8f93SAnvesh-Kumar_Rayankula    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}  body={'NTP':{'ProtocolEnabled': ${True}}}
95365b8f93SAnvesh-Kumar_Rayankula    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
96365b8f93SAnvesh-Kumar_Rayankula    ${ntp}=  Redfish.Get Attribute  ${REDFISH_NW_PROTOCOL_URI}  NTP
97365b8f93SAnvesh-Kumar_Rayankula    Valid Value  ntp["ProtocolEnabled"]  valid_values=[True]
98365b8f93SAnvesh-Kumar_Rayankula    ${local_system_time}=  Get Current Date
99365b8f93SAnvesh-Kumar_Rayankula    Redfish Set DateTime  ${local_system_time}
100365b8f93SAnvesh-Kumar_Rayankula    ...  valid_status_codes=[${HTTP_BAD_REQUEST}, ${HTTP_INTERNAL_SERVER_ERROR}]
101365b8f93SAnvesh-Kumar_Rayankula
102365b8f93SAnvesh-Kumar_Rayankula*** Keywords ***
103365b8f93SAnvesh-Kumar_Rayankula
104365b8f93SAnvesh-Kumar_Rayankula
105365b8f93SAnvesh-Kumar_RayankulaSuite Setup Execution
106365b8f93SAnvesh-Kumar_Rayankula    [Documentation]  Do the suite level setup.
107365b8f93SAnvesh-Kumar_Rayankula
108365b8f93SAnvesh-Kumar_Rayankula    Printn
109365b8f93SAnvesh-Kumar_Rayankula    Redfish.Login
110365b8f93SAnvesh-Kumar_Rayankula    Get NTP Initial Status
111365b8f93SAnvesh-Kumar_Rayankula    ${old_date_time}=  CLI Get BMC DateTime
112365b8f93SAnvesh-Kumar_Rayankula    ${year_status}=  Run Keyword And Return Status  Should Not Contain  ${old_date_time}  ${year_without_ntp}
113365b8f93SAnvesh-Kumar_Rayankula    Run Keyword If  ${year_status} == False
114365b8f93SAnvesh-Kumar_Rayankula    ...  Enable NTP And Add NTP Address
115365b8f93SAnvesh-Kumar_Rayankula
116365b8f93SAnvesh-Kumar_RayankulaSuite Teardown Execution
117365b8f93SAnvesh-Kumar_Rayankula    [Documentation]  Do the suite level teardown.
118365b8f93SAnvesh-Kumar_Rayankula
119365b8f93SAnvesh-Kumar_Rayankula    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}
120365b8f93SAnvesh-Kumar_Rayankula    ...  body={'NTP':{'NTPServers': ['${EMPTY}', '${EMPTY}']}}
121365b8f93SAnvesh-Kumar_Rayankula    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
122365b8f93SAnvesh-Kumar_Rayankula    Restore NTP Status
123365b8f93SAnvesh-Kumar_Rayankula    Redfish.Logout
124