blob: 49cedc12a5e4e52fe8a85b98daa641a4792135ab [file] [log] [blame]
Anvesh-Kumar_Rayankula365b8f92024-08-04 00:07:19 -05001*** Settings ***
2Documentation NTP configuration and verification
3 ... tests.
4
5Resource ../../lib/openbmc_ffdc.robot
6Resource ../../lib/bmc_date_and_time_utils.robot
7
8Test Setup Printn
9Test Teardown FFDC On Test Case Fail
10Suite Setup Suite Setup Execution
11Suite Teardown Suite Teardown Execution
12
13
14*** Variables ***
15
16${ntp_server_1} 9.9.9.9
17${ntp_server_2} 2.2.3.3
18&{original_ntp} &{EMPTY}
19
20*** Test Cases ***
21
22Verify NTP Server Set
23 [Documentation] Patch NTP servers and verify NTP servers is set.
24 [Tags] Verify_NTP_Server_Set
25 [Setup] Set NTP state ${True}
26
27 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI}
28 ... body={'NTP':{'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']}}
29 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
30
31 # NTP network take few seconds to reload.
32 Wait Until Keyword Succeeds 30 sec 10 sec Verify NTP Servers Are Populated
33
34
35Verify NTP Server Value Not Duplicated
36 [Documentation] Verify NTP servers value not same for both primary and secondary server.
37 [Tags] Verify_NTP_Server_Value_Not_Duplicated
38
39 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI}
40 ... body={'NTP':{'NTPServers': ['${ntp_server_1}', '${ntp_server_1}']}}
41 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
42 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI}
43 Should Contain X Times ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} 1
44 ... msg=NTP primary and secondary server values should not be same.
45
46
47Verify NTP Server Setting Persist After BMC Reboot
48 [Documentation] Verify NTP server setting persist after BMC reboot.
49 [Tags] Verify_NTP_Server_Setting_Persist_After_BMC_Reboot
50 [Setup] Set NTP state ${True}
51
52 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI}
53 ... body={'NTP':{'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']}}
54 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
55 Redfish OBMC Reboot (off)
56 Redfish.Login
57
58 # NTP network take few seconds to reload.
59 Wait Until Keyword Succeeds 30 sec 10 sec Verify NTP Servers Are Populated
60
61
62Verify Enable NTP
63 [Documentation] Verify NTP protocol mode can be enabled.
64 [Teardown] Restore NTP Mode
65 [Tags] Verify_Enable_NTP
66
Anvesh-Kumar_Rayankula365b8f92024-08-04 00:07:19 -050067 # The following patch command should set the ["NTP"]["ProtocolEnabled"] property to "True".
68 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTP':{'ProtocolEnabled': ${True}}}
69 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
70 Wait Until Keyword Succeeds 1 min 5 sec
71 ... Verify System Time Sync Status ${True}
72 ${ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP
73 Rprint Vars ntp
74 Valid Value ntp["ProtocolEnabled"] valid_values=[True]
75
George Keishingaaf7d1c2024-09-03 13:46:49 +053076Verify Disable NTP
Sweta Potthuridc9abaa2024-08-14 02:04:11 -050077 [Documentation] Verify NTP protocol mode can be disabled.
78 [Teardown] Restore NTP Mode
79 [Tags] Verify_Disable_NTP
80
81 # The following patch command should set the ["NTP"]["ProtocolEnabled"] property to "False".
82 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTP':{'ProtocolEnabled': ${False}}}
83 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
84 Wait Until Keyword Succeeds 1 min 5 sec
85 ... Verify System Time Sync Status ${False}
86 ${ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP
87 Rprint Vars ntp
88 Valid Value ntp["ProtocolEnabled"] valid_values=[False]
Anvesh-Kumar_Rayankula365b8f92024-08-04 00:07:19 -050089
90Verify Set DateTime With NTP Enabled
91 [Documentation] Verify whether set managers dateTime is restricted with NTP enabled.
92 [Tags] Verify_Set_DateTime_With_NTP_Enabled
93
94 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTP':{'ProtocolEnabled': ${True}}}
95 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
96 ${ntp}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} NTP
97 Valid Value ntp["ProtocolEnabled"] valid_values=[True]
98 ${local_system_time}= Get Current Date
99 Redfish Set DateTime ${local_system_time}
100 ... valid_status_codes=[${HTTP_BAD_REQUEST}, ${HTTP_INTERNAL_SERVER_ERROR}]
101
Sweta Potthuriba083e52025-01-08 02:24:24 -0600102Verify NTP Server Is Not Populated In NetworkSuppliedServers
103 [Documentation] Patch NTP server and verify NTP servers is not populated
104 ... in NetworkSuppliedServers.
George Keishing4ebb3282025-01-17 10:01:34 +0530105 [Tags] Verify_NTP_Server_Is_Not_Populated_In_NetworkSuppliedServers
Sweta Potthuriba083e52025-01-08 02:24:24 -0600106 [Setup] Set NTP state ${True}
Anvesh-Kumar_Rayankula365b8f92024-08-04 00:07:19 -0500107
Sweta Potthuriba083e52025-01-08 02:24:24 -0600108 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI}
109 ... body={'NTP':{'NTPServers': ['${ntp_server_1}']}}
110 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
111
112 # Verify the NTP server is populated in NTPServers.
113 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI}
114 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1}
115 ... msg=NTP server value ${ntp_server_1} not stored.
116
117 # Checking whether added NTP server is not populated in
118 # ... NetworkSuppliedServers as it has only DHCP NTP server list.
119 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI}
120 Should Not Contain ${network_protocol["NTP"]["NetworkSuppliedServers"]} ${ntp_server_1}
121 ... msg=Static NTP server is coming up in NetworkSuppliedServers.
122
123*** Keywords ***
Anvesh-Kumar_Rayankula365b8f92024-08-04 00:07:19 -0500124
125Suite Setup Execution
126 [Documentation] Do the suite level setup.
127
128 Printn
129 Redfish.Login
130 Get NTP Initial Status
131 ${old_date_time}= CLI Get BMC DateTime
132 ${year_status}= Run Keyword And Return Status Should Not Contain ${old_date_time} ${year_without_ntp}
133 Run Keyword If ${year_status} == False
134 ... Enable NTP And Add NTP Address
135
Anvesh-Kumar_Rayankula365b8f92024-08-04 00:07:19 -0500136Suite Teardown Execution
137 [Documentation] Do the suite level teardown.
138
139 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI}
140 ... body={'NTP':{'NTPServers': ['${EMPTY}', '${EMPTY}']}}
141 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
142 Restore NTP Status
143 Redfish.Logout