blob: 54c6a1a7583afb254d843e00c5d9d431e0991cf4 [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
8
9Test Setup Run Keywords Printn AND redfish.Login
10Test Teardown Test Teardown Execution
11
12*** Variables ***
13${max_time_diff_in_seconds} 6
Sivas SRR3f152ae2019-06-07 10:02:51 -050014${invalid_datetime} "2019-04-251T12:24:46+00:00"
Sivas SRR62d22d02019-06-08 12:13:31 -050015${ntp_server_1} "9.9.9.9"
16${ntp_server_2} "2.2.3.3"
Sivas SRR0e3bc6d2019-04-23 08:36:35 -050017
18*** Test Cases ***
19
20Verify Redfish BMC Time
21 [Documentation] Verify that date/time obtained via redfish matches
22 ... date/time obtained via BMC command line.
23 [Tags] Verify_Redfish_BMC_Time
24
25 ${redfish_date_time}= Redfish Get DateTime
26 ${cli_date_time}= CLI Get BMC DateTime
27 ${time_diff}= Subtract Date From Date ${cli_date_time}
28 ... ${redfish_date_time}
29 ${time_diff}= Evaluate abs(${time_diff})
30 Rprint Vars redfish_date_time cli_date_time time_diff
31 Should Be True ${time_diff} < ${max_time_diff_in_seconds}
32 ... The difference between Redfish time and CLI time exceeds the allowed time difference.
33
34
Sivas SRR8a53dad2019-05-16 08:56:14 -050035Verify Set Time Using Redfish
36 [Documentation] Verify set time using redfish API.
37 [Tags] Verify_Set_Time_Using_Redfish
38
39 ${old_bmc_time}= CLI Get BMC DateTime
40 # Add 3 days to current date.
41 ${new_bmc_time}= Add Time to Date ${old_bmc_time} 3 Days
42 Redfish Set DateTime ${new_bmc_time}
43 ${cli_bmc_time}= CLI Get BMC DateTime
44 ${time_diff}= Subtract Date From Date ${cli_bmc_time}
45 ... ${new_bmc_time}
46 ${time_diff}= Evaluate abs(${time_diff})
47 Rprint Vars old_bmc_time new_bmc_time cli_bmc_time time_diff max_time_diff_in_seconds
48 Should Be True ${time_diff} < ${max_time_diff_in_seconds}
49 ... The difference between Redfish time and CLI time exceeds the allowed time difference.
50 # Setting back to old bmc time.
51 Redfish Set DateTime ${old_bmc_time}
52
53
Sivas SRR3f152ae2019-06-07 10:02:51 -050054Verify Set DateTime With Invalid Data Using Redfish
55 [Documentation] Verify error while setting invalid DateTime using Redfish.
56 [Tags] Verify_Set_DateTime_With_Invalid_Data_Using_Redfish
57
58 Redfish Set DateTime ${invalid_datetime} valid_status_codes=[${HTTP_BAD_REQUEST}]
59
60
Sivas SRR62d22d02019-06-08 12:13:31 -050061Verify NTP Server Set
62 [Documentation] Verify NTP server set.
63 [Tags] Verify_NTP_Server_Set
64
65 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']}
66 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI}
67 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1}
68 ... msg=NTP server value ${ntp_server_1} not stored.
69 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_2}
70 ... msg=NTP server value ${ntp_server_2} not stored.
71
72
73Verify NTP Server Value Not Duplicated
74 [Documentation] Verify NTP servers value not same for both primary and secondary server.
75 [Tags] Verify_NTP_Server_Value_Not_Duplicated
76
77 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_1}']}
78 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI}
79 Should Contain X Times ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1} 1
George Keishing1af70ef2019-06-11 09:31:10 -050080 ... msg=NTP primary and secondary server values should not be same.
Sivas SRR62d22d02019-06-08 12:13:31 -050081
82
Sivas SRRaac72b02019-06-11 08:56:10 -050083Verify NTP Server Setting Persist After BMC Reboot
84 [Documentation] Verify NTP server setting persist after BMC reboot.
85 [Tags] Verify_NTP_Server_Setting_Persist_After_BMC_Reboot
86
87 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']}
88 Redfish OBMC Reboot (off)
89 Redfish.Login
90 ${network_protocol}= Redfish.Get Properties ${REDFISH_NW_PROTOCOL_URI}
91 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_1}
92 ... msg=NTP server value ${ntp_server_1} not stored.
93 Should Contain ${network_protocol["NTP"]["NTPServers"]} ${ntp_server_2}
94 ... msg=NTP server value ${ntp_server_2} not stored.
95 Redfish.Logout
96
97
Sivas SRR0e3bc6d2019-04-23 08:36:35 -050098*** Keywords ***
99
100Test Teardown Execution
101 [Documentation] Do the post test teardown.
102
103 FFDC On Test Case Fail
104 redfish.Logout
105
106
107Redfish Get DateTime
108 [Documentation] Returns BMC Datetime value from Redfish.
109
110 ${date_time}= Redfish.Get Attribute ${REDFISH_BASE_URI}Managers/bmc DateTime
111 [Return] ${date_time}
Sivas SRR8a53dad2019-05-16 08:56:14 -0500112
113
114Redfish Set DateTime
115 [Documentation] Set DateTime using Redfish.
Sivas SRR3f152ae2019-06-07 10:02:51 -0500116 [Arguments] ${date_time} &{kwargs}
Sivas SRR8a53dad2019-05-16 08:56:14 -0500117 # Description of argument(s):
Sivas SRR3f152ae2019-06-07 10:02:51 -0500118 # date_time New time to set for BMC (eg.
119 # "2019-06-30 09:21:28").
120 # kwargs Additional parms to be passed directly to
121 # th Redfish.Patch function. A good use for
122 # this is when testing a bad date-time, the
123 # caller can specify
124 # valid_status_codes=[${HTTP_BAD_REQUEST}].
Sivas SRR8a53dad2019-05-16 08:56:14 -0500125
Sivas SRR3f152ae2019-06-07 10:02:51 -0500126 Redfish.Patch ${REDFISH_BASE_URI}Managers/bmc body={'DateTime': '${date_time}'}
127 ... &{kwargs}