blob: 79c37dabdc471c5a55b928efc2b1b9ddeb0ce1ac [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
Sushil Singh79b04aa2019-06-18 05:25:34 -05008Resource ../../lib/rest_client.robot
Sivas SRR0e3bc6d2019-04-23 08:36:35 -05009
10Test Setup Run Keywords Printn AND redfish.Login
11Test Teardown Test Teardown Execution
12
13*** Variables ***
14${max_time_diff_in_seconds} 6
Sivas SRR3f152ae2019-06-07 10:02:51 -050015${invalid_datetime} "2019-04-251T12:24:46+00:00"
Sivas SRR62d22d02019-06-08 12:13:31 -050016${ntp_server_1} "9.9.9.9"
17${ntp_server_2} "2.2.3.3"
Sivas SRR0e3bc6d2019-04-23 08:36:35 -050018
19*** Test Cases ***
20
21Verify Redfish BMC Time
22 [Documentation] Verify that date/time obtained via redfish matches
23 ... date/time obtained via BMC command line.
24 [Tags] Verify_Redfish_BMC_Time
25
26 ${redfish_date_time}= Redfish Get DateTime
27 ${cli_date_time}= CLI Get BMC DateTime
28 ${time_diff}= Subtract Date From Date ${cli_date_time}
29 ... ${redfish_date_time}
30 ${time_diff}= Evaluate abs(${time_diff})
31 Rprint Vars redfish_date_time cli_date_time time_diff
32 Should Be True ${time_diff} < ${max_time_diff_in_seconds}
33 ... The difference between Redfish time and CLI time exceeds the allowed time difference.
34
35
Sivas SRR8a53dad2019-05-16 08:56:14 -050036Verify Set Time Using Redfish
37 [Documentation] Verify set time using redfish API.
38 [Tags] Verify_Set_Time_Using_Redfish
39
Sushil Singh79b04aa2019-06-18 05:25:34 -050040 Rest Set Time Owner
41
Sivas SRR8a53dad2019-05-16 08:56:14 -050042 ${old_bmc_time}= CLI Get BMC DateTime
43 # Add 3 days to current date.
44 ${new_bmc_time}= Add Time to Date ${old_bmc_time} 3 Days
45 Redfish Set DateTime ${new_bmc_time}
46 ${cli_bmc_time}= CLI Get BMC DateTime
47 ${time_diff}= Subtract Date From Date ${cli_bmc_time}
48 ... ${new_bmc_time}
49 ${time_diff}= Evaluate abs(${time_diff})
50 Rprint Vars old_bmc_time new_bmc_time cli_bmc_time time_diff max_time_diff_in_seconds
51 Should Be True ${time_diff} < ${max_time_diff_in_seconds}
52 ... The difference between Redfish time and CLI time exceeds the allowed time difference.
53 # Setting back to old bmc time.
54 Redfish Set DateTime ${old_bmc_time}
55
56
Sivas SRR3f152ae2019-06-07 10:02:51 -050057Verify Set DateTime With Invalid Data Using Redfish
58 [Documentation] Verify error while setting invalid DateTime using Redfish.
59 [Tags] Verify_Set_DateTime_With_Invalid_Data_Using_Redfish
60
61 Redfish Set DateTime ${invalid_datetime} valid_status_codes=[${HTTP_BAD_REQUEST}]
62
63
Sivas SRR62d22d02019-06-08 12:13:31 -050064Verify NTP Server Set
65 [Documentation] Verify NTP server set.
66 [Tags] Verify_NTP_Server_Set
67
68 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']}
69 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI}
70 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1}
71 ... msg=NTP server value ${ntp_server_1} not stored.
72 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_2}
73 ... msg=NTP server value ${ntp_server_2} not stored.
74
75
76Verify NTP Server Value Not Duplicated
77 [Documentation] Verify NTP servers value not same for both primary and secondary server.
78 [Tags] Verify_NTP_Server_Value_Not_Duplicated
79
80 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_1}']}
81 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI}
82 Should Contain X Times ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} 1
George Keishing1af70ef2019-06-11 09:31:10 -050083 ... msg=NTP primary and secondary server values should not be same.
Sivas SRR62d22d02019-06-08 12:13:31 -050084
85
Sivas SRRaac72b02019-06-11 08:56:10 -050086Verify NTP Server Setting Persist After BMC Reboot
87 [Documentation] Verify NTP server setting persist after BMC reboot.
88 [Tags] Verify_NTP_Server_Setting_Persist_After_BMC_Reboot
89
90 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']}
91 Redfish OBMC Reboot (off)
92 Redfish.Login
93 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI}
94 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1}
95 ... msg=NTP server value ${ntp_server_1} not stored.
96 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_2}
97 ... msg=NTP server value ${ntp_server_2} not stored.
98 Redfish.Logout
99
100
Sivas SRR0e3bc6d2019-04-23 08:36:35 -0500101*** Keywords ***
102
103Test Teardown Execution
104 [Documentation] Do the post test teardown.
105
106 FFDC On Test Case Fail
107 redfish.Logout
108
109
110Redfish Get DateTime
111 [Documentation] Returns BMC Datetime value from Redfish.
112
113 ${date_time}= Redfish.Get Attribute ${REDFISH_BASE_URI}Managers/bmc DateTime
114 [Return] ${date_time}
Sivas SRR8a53dad2019-05-16 08:56:14 -0500115
116
117Redfish Set DateTime
118 [Documentation] Set DateTime using Redfish.
Sivas SRR3f152ae2019-06-07 10:02:51 -0500119 [Arguments] ${date_time} &{kwargs}
Sivas SRR8a53dad2019-05-16 08:56:14 -0500120 # Description of argument(s):
Sivas SRR3f152ae2019-06-07 10:02:51 -0500121 # date_time New time to set for BMC (eg.
122 # "2019-06-30 09:21:28").
123 # kwargs Additional parms to be passed directly to
124 # th Redfish.Patch function. A good use for
125 # this is when testing a bad date-time, the
126 # caller can specify
127 # valid_status_codes=[${HTTP_BAD_REQUEST}].
Sivas SRR8a53dad2019-05-16 08:56:14 -0500128
Sivas SRR3f152ae2019-06-07 10:02:51 -0500129 Redfish.Patch ${REDFISH_BASE_URI}Managers/bmc body={'DateTime': '${date_time}'}
130 ... &{kwargs}
Sushil Singh79b04aa2019-06-18 05:25:34 -0500131
132
133Rest Set Time Owner
134 [Documentation] Set time owner of the system via REST.
135
136 # BMC_OWNER is defined in variable.py.
137 ${data}= Create Dictionary data=${BMC_OWNER}
138 Write Attribute ${TIME_MANAGER_URI}owner TimeOwner data=${data} verify=${TRUE}
139