blob: 9fe9ecf870c0cff1153ace1d857643a7c906cacd [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
2Documentation This suite is for testing System time in Open BMC.
3
Rahul Maheshwari93f68092016-10-24 02:42:12 -05004Resource ../lib/rest_client.robot
George Keishing4d6c1da2016-07-15 05:51:22 -05005Resource ../lib/ipmi_client.robot
George Keishingd55a4be2016-08-26 03:28:17 -05006Resource ../lib/openbmc_ffdc.robot
Rahul Maheshwari2c725042017-01-29 22:55:28 -06007Resource ../lib/state_manager.robot
Sandhya Somashekar839a0c22019-01-31 05:05:43 -06008Resource ../lib/resource.robot
Chris Austenb29d2e82016-06-07 12:25:35 -05009
George Keishing4d6c1da2016-07-15 05:51:22 -050010Library OperatingSystem
11Library DateTime
Chris Austenb29d2e82016-06-07 12:25:35 -050012
Rahul Maheshwari06174f22017-03-06 03:17:09 -060013Test Setup Open Connection And Log In
14Test Teardown Post Test Case Execution
Chris Austenb29d2e82016-06-07 12:25:35 -050015
Sweta Potthurib1631202017-08-28 04:11:34 -050016Force Tags Clock_Time
17
Chris Austenb29d2e82016-06-07 12:25:35 -050018*** Variables ***
Rahul Maheshwarif8785902016-12-12 01:23:13 -060019${SYSTEM_TIME_INVALID} 01/01/1969 00:00:00
20${SYSTEM_TIME_VALID} 02/29/2016 09:10:00
Rahul Maheshwarif8785902016-12-12 01:23:13 -060021${ALLOWED_TIME_DIFF} 3
Rahul Maheshwarif486ae82017-10-24 06:10:14 -050022# Equivalent epoch time for 02/17/2017 04:11:40
23${SYSTEM_TIME_VALID_EPOCH} ${1487304700000000}
George Keishingab1bd922016-12-05 05:29:59 -060024
Chris Austenb29d2e82016-06-07 12:25:35 -050025*** Test Cases ***
26
27Get System Time
Rahul Maheshwarif8785902016-12-12 01:23:13 -060028 [Documentation] Get system time using IPMI and verify that it matches
29 ... with BMC date time.
George Keishing845fb822016-11-01 13:23:19 -050030 [Tags] Get_System_Time
Chris Austenb29d2e82016-06-07 12:25:35 -050031
Rahul Maheshwarif8785902016-12-12 01:23:13 -060032 ${resp}= Run IPMI Standard Command sel time get
33 ${ipmidate}= Convert Date ${resp} date_format=%m/%d/%Y %H:%M:%S
34 ... exclude_millis=yes
35 ${bmcdate}= Get BMC Time Using IPMI
36 ${diff}= Subtract Date From Date ${bmcdate} ${ipmidate}
Sridevi Rameshae444822017-02-13 05:51:52 -060037 ${diff}= Convert To Number ${diff}
Rahul Maheshwarif8785902016-12-12 01:23:13 -060038 Should Be True ${diff} < ${ALLOWED_TIME_DIFF}
39 ... Open BMC time does not match with IPMI sel time
Chris Austenb29d2e82016-06-07 12:25:35 -050040
Rahul Maheshwari52d92942019-01-21 10:54:52 -060041
Chris Austenb29d2e82016-06-07 12:25:35 -050042Set Valid System Time
Rahul Maheshwarif8785902016-12-12 01:23:13 -060043 [Documentation] Set system time using IPMI and verify that it is
44 ... correctly set in BMC.
George Keishing845fb822016-11-01 13:23:19 -050045 [Tags] Set_Valid_System_Time
Chris Austenb29d2e82016-06-07 12:25:35 -050046
Rahul Maheshwarif486ae82017-10-24 06:10:14 -050047 Set Time Mode ${MANUAL_MODE}
Rahul Maheshwari7588f872017-04-13 05:51:24 -050048
Rahul Maheshwari11a1cc32019-01-24 02:53:05 -060049 # Added delay for NTP mode to get disabled fully
50 Sleep 30s
51
Rahul Maheshwarif8785902016-12-12 01:23:13 -060052 ${resp}= Run IPMI Standard Command sel time set "${SYSTEM_TIME_VALID}"
53 ${setdate}= Convert Date ${SYSTEM_TIME_VALID}
54 ... date_format=%m/%d/%Y %H:%M:%S exclude_millis=yes
55 ${bmcdate}= Get BMC Time Using IPMI
56 ${diff}= Subtract Date From Date ${bmcdate} ${setdate}
Sridevi Rameshae444822017-02-13 05:51:52 -060057 ${diff}= Convert To Number ${diff}
Rahul Maheshwarif8785902016-12-12 01:23:13 -060058 Should Be True ${diff} < ${ALLOWED_TIME_DIFF}
59 ... Open BMC time does not match with set time
Chris Austenb29d2e82016-06-07 12:25:35 -050060
Rahul Maheshwari52d92942019-01-21 10:54:52 -060061
Chris Austenb29d2e82016-06-07 12:25:35 -050062Set Invalid System Time
Rahul Maheshwarif8785902016-12-12 01:23:13 -060063 [Documentation] Set system time with invalid time using IPMI and verify
64 ... that it should throw error.
George Keishing845fb822016-11-01 13:23:19 -050065 [Tags] Set_Invalid_System_Time
Chris Austenb29d2e82016-06-07 12:25:35 -050066
Rahul Maheshwarif486ae82017-10-24 06:10:14 -050067 Set Time Mode ${MANUAL_MODE}
Rahul Maheshwari7588f872017-04-13 05:51:24 -050068
Rahul Maheshwarif8785902016-12-12 01:23:13 -060069 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
70 ... sel time set "${SYSTEM_TIME_INVALID}"
71 Should Start With ${msg} Specified time could not be parsed
Chris Austenb29d2e82016-06-07 12:25:35 -050072
73Set System Time with no time
Rahul Maheshwarif8785902016-12-12 01:23:13 -060074 [Documentation] Set system time with no time using IPMI and verify
75 ... that it should throw error.
George Keishing845fb822016-11-01 13:23:19 -050076 [Tags] Set_System_Time_with_no_time
Chris Austenb29d2e82016-06-07 12:25:35 -050077
Rahul Maheshwarif486ae82017-10-24 06:10:14 -050078 Set Time Mode ${MANUAL_MODE}
Rahul Maheshwari7588f872017-04-13 05:51:24 -050079
Rahul Maheshwarif8785902016-12-12 01:23:13 -060080 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
81 ... sel time set ""
82 Should Start With ${msg} Specified time could not be parsed
Chris Austenb29d2e82016-06-07 12:25:35 -050083
Rahul Maheshwari93f68092016-10-24 02:42:12 -050084
Rahul Maheshwarif8785902016-12-12 01:23:13 -060085Set BMC Time With BMC And Manual
Rahul Maheshwarif8785902016-12-12 01:23:13 -060086 [Documentation] Set BMC time when time owner is BMC and time mode is
87 ... manual.
88 [Tags] Set_BMC_Time_With_BMC_And_Manual
89 [Template] Set Time Using REST
Tony Lee3829a2b2020-06-09 17:03:04 +080090 [Teardown] Run Keywords Set Time Owner ${BMC_OWNER} AND Post Test Case Execution
Rahul Maheshwari93f68092016-10-24 02:42:12 -050091
Rahul Maheshwarif486ae82017-10-24 06:10:14 -050092 #Operation Owner Mode Status BMC Time Host Time
George Keishing5abfe602018-07-05 11:54:37 -050093 Set BMC Time ${BMC_OWNER} ${MANUAL_MODE} ok Set Change
Rahul Maheshwari93f68092016-10-24 02:42:12 -050094
George Keishing5abfe602018-07-05 11:54:37 -050095
96Set BMC Time With Both And Manual
Rahul Maheshwarif8785902016-12-12 01:23:13 -060097 [Documentation] Set BMC time when time owner is Both and time mode is
98 ... manual.
99 [Tags] Set_BMC_Time_With_Both_And_Manual
100 [Template] Set Time Using REST
Tony Lee3829a2b2020-06-09 17:03:04 +0800101 [Teardown] Run Keywords Set Time Owner ${BMC_OWNER} AND Post Test Case Execution
George Keishing5abfe602018-07-05 11:54:37 -0500102 #Operation Owner Mode Status BMC Time Host Time
103 Set BMC Time ${BOTH_OWNER} ${MANUAL_MODE} ok Set Change
104
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500105
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600106Set BMC Time With Split And Manual
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600107 [Documentation] Set BMC time when time owner is Split and time mode is
108 ... manual.
109 [Tags] Set_BMC_Time_With_Split_And_Manual
110 [Template] Set Time Using REST
Tony Lee3829a2b2020-06-09 17:03:04 +0800111 [Teardown] Run Keywords Set Time Owner ${BMC_OWNER} AND Post Test Case Execution
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500112 #Operation Owner Mode Status BMC Time Host Time
George Keishing5abfe602018-07-05 11:54:37 -0500113 Set BMC Time ${SPLIT_OWNER} ${MANUAL_MODE} ok Set No Change
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500114
George Keishing5abfe602018-07-05 11:54:37 -0500115
116Set BMC Time With BMC And NTP
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600117 [Documentation] Set BMC time when time owner is BMC and time mode is
118 ... NTP.
119 [Tags] Set_BMC_Time_With_BMC_And_NTP
120 [Template] Set Time Using REST
Tony Lee3829a2b2020-06-09 17:03:04 +0800121 [Teardown] Run Keywords Set Time Owner ${BMC_OWNER} AND Post Test Case Execution
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500122 #Operation Owner Mode Status BMC Time Host Time
Rahul Maheshwari8cc47172018-09-06 01:46:50 -0500123 Set BMC Time ${BMC_OWNER} ${NTP_MODE} error Not Set No Change
George Keishing5abfe602018-07-05 11:54:37 -0500124
125
126Set BMC Time With Host And Manual
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600127 [Documentation] Set BMC time when time owner is Host and time mode is
128 ... Manual.
129 [Tags] Set_BMC_Time_With_Host_And_Manual
130 [Template] Set Time Using REST
Tony Lee3829a2b2020-06-09 17:03:04 +0800131 [Teardown] Run Keywords Set Time Owner ${BMC_OWNER} AND Post Test Case Execution
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500132
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500133 #Operation Owner Mode Status BMC Time Host Time
Rahul Maheshwari8cc47172018-09-06 01:46:50 -0500134 Set BMC Time ${HOST_OWNER} ${MANUAL_MODE} error Not Set No Change
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600135
George Keishing5abfe602018-07-05 11:54:37 -0500136
137Set BMC Time With Both And NTP
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600138 [Documentation] Set BMC time when time owner is Both and time mode is
139 ... NTP.
140 [Tags] Set_BMC_Time_With_Both_And_NTP
141 [Template] Set Time Using REST
Tony Lee3829a2b2020-06-09 17:03:04 +0800142 [Teardown] Run Keywords Set Time Owner ${BMC_OWNER} AND Post Test Case Execution
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600143
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500144 #Operation Owner Mode Status BMC Time Host Time
Rahul Maheshwari8cc47172018-09-06 01:46:50 -0500145 Set BMC Time ${BOTH_OWNER} ${NTP_MODE} error Not Set No Change
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600146
George Keishing5abfe602018-07-05 11:54:37 -0500147
148Set BMC Time With Split And NTP
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600149 [Documentation] Set BMC time when time owner is Split and time mode is
150 ... NTP.
151 [Tags] Set_BMC_Time_With_Split_And_NTP
152 [Template] Set Time Using REST
Tony Lee3829a2b2020-06-09 17:03:04 +0800153 [Teardown] Run Keywords Set Time Owner ${BMC_OWNER} AND Post Test Case Execution
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600154
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500155 #Operation Owner Mode Status BMC Time Host Time
Rahul Maheshwari8cc47172018-09-06 01:46:50 -0500156 Set BMC Time ${SPLIT_OWNER} ${NTP_MODE} error Not Set No Change
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500157
George Keishing5abfe602018-07-05 11:54:37 -0500158
159Set BMC Time With Host And NTP
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500160 [Documentation] Set BMC time when time owner is Host and time mode is
161 ... NTP.
162 [Tags] Set_BMC_Time_With_Host_And_NTP
163 [Template] Set Time Using REST
Tony Lee3829a2b2020-06-09 17:03:04 +0800164 [Teardown] Run Keywords Set Time Owner ${BMC_OWNER} AND Post Test Case Execution
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500165
George Keishing5abfe602018-07-05 11:54:37 -0500166 #Operation Owner Mode Status BMC Time Host Time
Rahul Maheshwari8cc47172018-09-06 01:46:50 -0500167 Set BMC Time ${HOST_OWNER} ${NTP_MODE} error Not Set No Change
George Keishing5abfe602018-07-05 11:54:37 -0500168
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500169
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600170Set Host Time With Host And Manual
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600171 [Documentation] Set host time when time owner is host and time mode is
172 ... manual.
173 [Tags] Set_Host_Time_With_Host_And_Manual
174 [Template] Set Time Using REST
Tony Lee3829a2b2020-06-09 17:03:04 +0800175 [Teardown] Run Keywords Set Time Owner ${BMC_OWNER} AND Post Test Case Execution
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600176
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500177 #Operation Owner Mode Status BMC Time Host Time
George Keishing5abfe602018-07-05 11:54:37 -0500178 Set Host Time ${HOST_OWNER} ${MANUAL_MODE} ok Change Set
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600179
George Keishing5abfe602018-07-05 11:54:37 -0500180
George Keishing5abfe602018-07-05 11:54:37 -0500181Set Host Time With Both And NTP
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600182 [Documentation] Set host time when time owner is both and time mode is
183 ... NTP.
184 [Tags] Set_Host_Time_With_Both_And_NTP
185 [Template] Set Time Using REST
Tony Lee3829a2b2020-06-09 17:03:04 +0800186 [Teardown] Run Keywords Set Time Owner ${BMC_OWNER} AND Post Test Case Execution
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600187
George Keishing5abfe602018-07-05 11:54:37 -0500188 #Operation Owner Mode Status BMC Time Host Time
Rahul Maheshwari8cc47172018-09-06 01:46:50 -0500189 Set Host Time ${BOTH_OWNER} ${NTP_MODE} error No Change Not Set
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600190
George Keishing5abfe602018-07-05 11:54:37 -0500191
192Set Host Time With Split And Manual
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600193 [Documentation] Set host time when time owner is split and time mode is
194 ... manual.
195 [Tags] Set_Host_Time_With_Split_And_Manual
196 [Template] Set Time Using REST
Tony Lee3829a2b2020-06-09 17:03:04 +0800197 [Teardown] Run Keywords Set Time Owner ${BMC_OWNER} AND Post Test Case Execution
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600198
George Keishing5abfe602018-07-05 11:54:37 -0500199 #Operation Owner Mode Status BMC Time Host Time
200 Set Host Time ${SPLIT_OWNER} ${MANUAL_MODE} ok No Change Set
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600201
George Keishing5abfe602018-07-05 11:54:37 -0500202
203Set Host Time With Split And NTP
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600204 [Documentation] Set host time when time owner is split and time mode is
205 ... NTP.
206 [Tags] Set_Host_Time_With_Split_And_NTP
207 [Template] Set Time Using REST
Tony Lee3829a2b2020-06-09 17:03:04 +0800208 [Teardown] Run Keywords Set Time Owner ${BMC_OWNER} AND Post Test Case Execution
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600209
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500210 #Operation Owner Mode Status BMC Time HOST Time
George Keishing5abfe602018-07-05 11:54:37 -0500211 Set Host Time ${SPLIT_OWNER} ${NTP_MODE} ok No Change Set
212
213
214Set Host Time With BMC And Manual
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600215 [Documentation] Set host time when time owner is BMC and time mode is
216 ... Manual.
217 [Tags] Set_Host_Time_With_BMC_And_Manual
218 [Template] Set Time Using REST
Tony Lee3829a2b2020-06-09 17:03:04 +0800219 [Teardown] Run Keywords Set Time Owner ${BMC_OWNER} AND Post Test Case Execution
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600220
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500221 #Operation Owner Mode Status BMC Time HOST Time
Rahul Maheshwari8cc47172018-09-06 01:46:50 -0500222 Set Host Time ${BMC_OWNER} ${MANUAL_MODE} error No Change Not Set
George Keishing5abfe602018-07-05 11:54:37 -0500223
224
225Set Host Time With BMC Owner NTP
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600226 [Documentation] Set host time when time owner is BMC and time mode is
227 ... NTP.
George Keishingac8661e2022-02-10 00:36:12 -0600228 [Tags] Set_Host_Time_With_BMC_Owner_NTP
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600229 [Template] Set Time Using REST
Tony Lee3829a2b2020-06-09 17:03:04 +0800230 [Teardown] Run Keywords Set Time Owner ${BMC_OWNER} AND Post Test Case Execution
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500231
George Keishing5abfe602018-07-05 11:54:37 -0500232 #Operation Owner Mode Status BMC Time HOST Time
Rahul Maheshwari8cc47172018-09-06 01:46:50 -0500233 Set Host Time ${BMC_OWNER} ${NTP_MODE} error No Change Not Set
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500234
George Keishing5abfe602018-07-05 11:54:37 -0500235
236Set Host Time With Host And NTP
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500237 [Documentation] Set host time when time owner is Host and time mode is
238 ... NTP.
239 [Tags] Set_Host_Time_With_Host_And_NTP
240 [Template] Set Time Using REST
Tony Lee3829a2b2020-06-09 17:03:04 +0800241 [Teardown] Run Keywords Set Time Owner ${BMC_OWNER} AND Post Test Case Execution
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500242
George Keishing5abfe602018-07-05 11:54:37 -0500243 #Operation Owner Mode Status BMC Time Host Time
Rahul Maheshwari8cc47172018-09-06 01:46:50 -0500244 Set Host Time ${HOST_OWNER} ${NTP_MODE} error Not Change No Set
George Keishing5abfe602018-07-05 11:54:37 -0500245
246
Rahul Maheshwari52d92942019-01-21 10:54:52 -0600247Set Host Time With Both And Manual
248 [Documentation] Set host time when time owner is both and time mode is
249 ... manual.
250 [Tags] Set_Host_Time_With_Both_And_Manual
251 [Template] Set Time Using REST
Tony Lee3829a2b2020-06-09 17:03:04 +0800252 [Teardown] Run Keywords Set Time Owner ${BMC_OWNER} AND Post Test Case Execution
Rahul Maheshwari52d92942019-01-21 10:54:52 -0600253
254 #Operation Owner Mode Status BMC Time Host Time
255 Set Host Time ${BOTH_OWNER} ${MANUAL_MODE} ok Change Set
256
257
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500258Set Invalid Time Mode
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600259 [Documentation] Set time mode with invalid value using REST and verify
260 ... that it should throw error.
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500261 [Tags] Set_Invalid_Time_Mode
Tony Lee3829a2b2020-06-09 17:03:04 +0800262 [Teardown] Run Keywords Set Time Owner ${BMC_OWNER} AND Post Test Case Execution
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500263
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500264 ${timemode}=
265 ... Set Variable xyz.openbmc_project.Time.Synchronization.Method.abc
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600266 ${valueDict}= Create Dictionary data=${timemode}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500267
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600268 ${resp}= OpenBMC Put Request
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500269 ... ${TIME_MANAGER_URI}sync_method/attr/TimeSyncMethod data=${valueDict}
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600270 ${jsondata}= to JSON ${resp.content}
271 Should Be Equal ${jsondata['status']} error
272
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500273 ${mode}= Read Attribute ${TIME_MANAGER_URI}sync_method TimeSyncMethod
274 Should Not Be Equal ${mode}
275 ... xyz.openbmc_project.Time.Synchronization.Method.abc
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500276
Tony Lee3829a2b2020-06-09 17:03:04 +0800277
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500278Set Invalid Time Owner
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600279 [Documentation] Set time owner with invalid value using REST and verify
280 ... that it should throw error.
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500281 [Tags] Set_Invalid_Time_Owner
Tony Lee3829a2b2020-06-09 17:03:04 +0800282 [Teardown] Run Keywords Set Time Owner ${BMC_OWNER} AND Post Test Case Execution
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500283
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500284 ${timeowner}= Set Variable xyz.openbmc_project.Time.Owner.Owners.xyz
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600285 ${valueDict}= Create Dictionary data=${timeowner}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500286
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600287 ${resp}= OpenBMC Put Request
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500288 ... ${TIME_MANAGER_URI}owner/attr/TimeOwner data=${valueDict}
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600289 ${jsondata}= to JSON ${resp.content}
290 Should Be Equal ${jsondata['status']} error
291
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500292 ${owner}= Read Attribute ${TIME_MANAGER_URI}owner TimeOwner
293 Should Not Be Equal ${owner} xyz.openbmc_project.Time.Owner.Owners.xyz
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500294
295
Chris Austenb29d2e82016-06-07 12:25:35 -0500296*** Keywords ***
297
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600298Get BMC Time Using IPMI
299 [Documentation] Returns BMC time of the system via IPMI
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500300
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600301 ${stdout} ${stderr} ${output}=
302 ... Execute Command date "+%m/%d/%Y %H:%M:%S"
303 ... return_stdout=True return_stderr= True return_rc=True
304 Should Be Equal ${output} ${0} msg=${stderr}
305
306 ${resp}= Convert Date ${stdout} date_format=%m/%d/%Y %H:%M:%S
307 ... exclude_millis=yes
308 Should Not Be Empty ${resp}
309 [Return] ${resp}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500310
Rahul Maheshwari52d92942019-01-21 10:54:52 -0600311
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500312Set Time Owner
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600313 [Arguments] ${args}
314 [Documentation] Set time owner of the system via REST
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500315
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600316 ${timeowner}= Set Variable ${args}
317 ${valueDict}= Create Dictionary data=${timeowner}
318
319 ${resp}= OpenBMC Put Request
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500320 ... ${TIME_MANAGER_URI}owner/attr/TimeOwner data=${valueDict}
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600321 ${jsondata}= to JSON ${resp.content}
322
Rahul Maheshwari2c725042017-01-29 22:55:28 -0600323 ${host_state}= Get Host State
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600324
Rahul Maheshwari2c725042017-01-29 22:55:28 -0600325 Run Keyword If '${host_state}' == 'Off'
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600326 ... Log System is in off state so owner change will get applied.
327 ... ELSE Run keyword
Rahul Maheshwari2c725042017-01-29 22:55:28 -0600328 ... Initiate Host PowerOff
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600329
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500330 ${owner}= Read Attribute ${TIME_MANAGER_URI}owner TimeOwner
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600331 Should Be Equal ${owner} ${args}
332
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600333 [Return] ${jsondata['status']}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500334
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500335
Tony Lee3829a2b2020-06-09 17:03:04 +0800336Verify Set Time Via REST
337 [Documentation] Verify set time via REST.
338 [Arguments] ${target} ${expected_status}
339 # Description of argument(s):
340 # target The target of the set time operation: "bmc" or "host".
341 # expected_status Expected status of set time operation
342
343 ${time_owner_url}= Set Variable ${TIME_MANAGER_URI}${target}
344
345 ${args}= Create Dictionary data=${SYSTEM_TIME_VALID_EPOCH}
346 ${resp}= OpenBMC Put Request
347 ... ${time_owner_url}/attr/Elapsed data=${args}
348 ${jsondata}= to Json ${resp.content}
349 Run Keyword If "${expected_status}" == "ok"
350 ... Should Not Be Equal As Strings ${jsondata['message']} 403 Forbidden
351 Should Be Equal As Strings ${jsondata['status']} ${expected_status}
352
353
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500354Set Time Mode
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600355 [Arguments] ${args}
356 [Documentation] Set time mode of the system via REST
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500357
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600358 ${timemode}= Set Variable ${args}
359 ${valueDict}= Create Dictionary data=${timemode}
360
361 ${resp}= OpenBMC Put Request
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500362 ... ${TIME_MANAGER_URI}sync_method/attr/TimeSyncMethod data=${valueDict}
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600363 ${jsondata}= to JSON ${resp.content}
364 Sleep 5s
365
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500366 ${mode}= Read Attribute ${TIME_MANAGER_URI}sync_method TimeSyncMethod
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600367 Should Be Equal ${mode} ${args}
368
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600369
370Get BMC Time Using REST
371 [Documentation] Returns BMC time of the system via REST
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500372 ... Time Format : epoch time in microseconds
373 ... e.g 1507809604687329
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600374
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500375 ${resp}= Read Attribute ${TIME_MANAGER_URI}/bmc Elapsed
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600376 [Return] ${resp}
377
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500378
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600379Get HOST Time Using REST
380 [Documentation] Returns HOST time of the system via REST
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500381 ... Time Format : epoch time in microseconds
382 ... e.g 1507809604687329
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600383
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500384 ${resp}= Read Attribute ${TIME_MANAGER_URI}/host Elapsed
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600385 [Return] ${resp}
386
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500387
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600388Set Time Using REST
389 [Arguments] ${operation} ${owner} ${mode} ${status} ${bmc_time}
390 ... ${host_time}
391 [Documentation] Set BMC or Host time on system via REST.
392 ... Description of arguments:
393 ... operation : Set BMC/Host time
394 ... owner: Time owner
395 ... mode: Time mode
396 ... status: Expected status of set BMC time URI
397 ... bmc_time: Status of BMC time after operation
398 ... host_time: Status of HOST time after operation
399 ... Set - Given time is set
400 ... Not Set - Given time is not set
401 ... Change - time is change
402 ... No Change - time is not change
403
404 Set Time Owner ${owner}
405 Set Time Mode ${mode}
406
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500407 ${setdate}= Set Variable ${SYSTEM_TIME_VALID_EPOCH}
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600408
Sridevi Rameshae444822017-02-13 05:51:52 -0600409 ${start_time}= Get Current Date
410
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600411 ${old_bmc_time}= Get BMC Time Using REST
412 ${old_host_time}= Get HOST Time Using REST
413
Rahul Maheshwari52d92942019-01-21 10:54:52 -0600414 Run Keyword If '${operation}' == 'Set BMC Time'
415 ... Wait Until Keyword Succeeds 1 min 20 sec Verify Set Time Via REST
416 ... bmc ${status}
417 ... ELSE IF '${operation}' == 'Set Host Time'
418 ... Wait Until Keyword Succeeds 1 min 20 sec Verify Set Time Via REST
419 ... host ${status}
420
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600421
422 ${new_bmc_time}= Get BMC Time Using REST
423 ${new_host_time}= Get HOST Time Using REST
424
Sridevi Rameshae444822017-02-13 05:51:52 -0600425 ${end_time}= Get Current Date
426 ${time_duration}= Subtract Date From Date ${start_time} ${end_time}
427 ${time_duration} Evaluate abs(${time_duration})
428
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500429 # Convert epoch to date format: YYYY-MM-DD hh:mm:ss.mil
430 ${setdate}= Convert epoch to date ${setdate}
431 ${new_bmc_time}= Convert epoch to date ${new_bmc_time}
432 ${old_bmc_time}= Convert epoch to date ${old_bmc_time}
433 ${new_host_time}= Convert epoch to date ${new_host_time}
434 ${old_host_time}= Convert epoch to date ${old_host_time}
435
436
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600437 ${bmc_diff_set_new}=
438 ... Subtract Date From Date ${setdate} ${new_bmc_time}
439 ${bmc_diff_set_new}= Evaluate abs(${bmc_diff_set_new})
440 ${bmc_diff_old_new}=
441 ... Subtract Date From Date ${old_bmc_time} ${new_bmc_time}
442 ${bmc_diff_old_new}= Evaluate abs(${bmc_diff_old_new})
443
444 ${host_diff_set_new}=
445 ... Subtract Date From Date ${setdate} ${new_host_time}
446 ${host_diff_set_new}= Evaluate abs(${host_diff_set_new})
447 ${host_diff_old_new}=
448 ... Subtract Date From Date ${old_host_time} ${new_host_time}
449 ${host_diff_old_new}= Evaluate abs(${host_diff_old_new})
450
451 Run Keyword If '${bmc_time}' == 'Not Set'
Sridevi Rameshae444822017-02-13 05:51:52 -0600452 ... Should Be True ${bmc_diff_set_new} >= ${time_duration}
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600453 ... ELSE IF '${bmc_time}' == 'Set'
Sridevi Rameshae444822017-02-13 05:51:52 -0600454 ... Should Be True ${bmc_diff_set_new} <= ${time_duration}
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600455 ... ELSE IF '${bmc_time}' == 'No Change'
Sridevi Rameshae444822017-02-13 05:51:52 -0600456 ... Should Be True ${bmc_diff_old_new} <= ${time_duration}
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600457 ... ELSE IF '${bmc_time}' == 'Change'
Sridevi Rameshae444822017-02-13 05:51:52 -0600458 ... Should Be True ${bmc_diff_old_new} >= ${time_duration}
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600459
460 Run Keyword If '${host_time}' == 'No Change'
Sridevi Rameshae444822017-02-13 05:51:52 -0600461 ... Should Be True ${host_diff_old_new} <= ${time_duration}
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600462 ... ELSE IF '${host_time}' == 'Change'
Sridevi Rameshae444822017-02-13 05:51:52 -0600463 ... Should Be True ${host_diff_old_new} >= ${time_duration}
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600464 ... ELSE IF '${host_time}' == 'Not Set'
Sridevi Rameshae444822017-02-13 05:51:52 -0600465 ... Should Be True ${host_diff_set_new} >= ${time_duration}
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600466 ... ELSE IF '${host_time}' == 'Set'
Sridevi Rameshae444822017-02-13 05:51:52 -0600467 ... Should Be True ${host_diff_set_new} <= ${time_duration}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500468
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500469Convert epoch to date
470 [Documentation] Convert epoch time to date format.
471 [Arguments] ${epoch_time}
472 # Description of argument(s):
Rahul Maheshwari7e863322018-02-02 06:03:06 -0600473 # epoch_time epoch time in milliseconds.
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500474 # (e.g. 1487304700000000)
475
Rahul Maheshwari7e863322018-02-02 06:03:06 -0600476 # Convert epoch_time into floating point number.
477 ${epoch_time}= Convert To Number ${epoch_time}
478
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500479 # Convert epoch time from microseconds to seconds
480 ${epoch_time_sec}= Evaluate ${epoch_time}/1000000
481
482 # Convert epoch time to date format: YYYY-MM-DD hh:mm:ss.mil
483 # e.g. 2017-02-16 22:14:11.000
484 ${date}= Convert Date ${epoch_time_sec}
485
486 [Return] ${date}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500487
Rahul Maheshwari52d92942019-01-21 10:54:52 -0600488
Rahul Maheshwari06174f22017-03-06 03:17:09 -0600489Post Test Case Execution
490 [Documentation] Do the post test teardown.
491 ... 1. Capture FFDC on test failure.
492 ... 2. Sets defaults for time mode and owner.
493 ... 3. Close all open SSH connections.
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500494
Rahul Maheshwari06174f22017-03-06 03:17:09 -0600495 FFDC On Test Case Fail
Rahul Maheshwarif486ae82017-10-24 06:10:14 -0500496 Set Time Mode ${NTP_MODE}
Rahul Maheshwari06174f22017-03-06 03:17:09 -0600497 Close All Connections