blob: b70edd13a3ce786fb1ee5b4650df95f92d6f594b [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
George Keishingab1bd922016-12-05 05:29:59 -06008Resource ../lib/resource.txt
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
George Keishing4d6c1da2016-07-15 05:51:22 -050013Suite Setup Open Connection And Log In
14Suite Teardown Close All Connections
Rahul Maheshwari93f68092016-10-24 02:42:12 -050015Test Teardown Post Test Execution
Chris Austenb29d2e82016-06-07 12:25:35 -050016
17*** Variables ***
Rahul Maheshwarif8785902016-12-12 01:23:13 -060018${SYSTEM_TIME_INVALID} 01/01/1969 00:00:00
19${SYSTEM_TIME_VALID} 02/29/2016 09:10:00
20${SYSTEM_TIME_VALID_EPOCH} 1456737000 #Equivalent epoch time for 02/29/2016 09:10:00
21${ALLOWED_TIME_DIFF} 3
22${SETTING_HOST} ${SETTINGS_URI}host0
George Keishingab1bd922016-12-05 05:29:59 -060023
Chris Austenb29d2e82016-06-07 12:25:35 -050024*** Test Cases ***
25
26Get System Time
Rahul Maheshwarif8785902016-12-12 01:23:13 -060027 [Documentation] Get system time using IPMI and verify that it matches
28 ... with BMC date time.
George Keishing845fb822016-11-01 13:23:19 -050029 [Tags] Get_System_Time
Chris Austenb29d2e82016-06-07 12:25:35 -050030
Rahul Maheshwarif8785902016-12-12 01:23:13 -060031 ${resp}= Run IPMI Standard Command sel time get
32 ${ipmidate}= Convert Date ${resp} date_format=%m/%d/%Y %H:%M:%S
33 ... exclude_millis=yes
34 ${bmcdate}= Get BMC Time Using IPMI
35 ${diff}= Subtract Date From Date ${bmcdate} ${ipmidate}
36 Should Be True ${diff} < ${ALLOWED_TIME_DIFF}
37 ... Open BMC time does not match with IPMI sel time
Chris Austenb29d2e82016-06-07 12:25:35 -050038
39Set Valid System Time
Rahul Maheshwarif8785902016-12-12 01:23:13 -060040 [Documentation] Set system time using IPMI and verify that it is
41 ... correctly set in BMC.
George Keishing845fb822016-11-01 13:23:19 -050042 [Tags] Set_Valid_System_Time
Chris Austenb29d2e82016-06-07 12:25:35 -050043
Rahul Maheshwarif8785902016-12-12 01:23:13 -060044 ${resp}= Run IPMI Standard Command sel time set "${SYSTEM_TIME_VALID}"
45 ${setdate}= Convert Date ${SYSTEM_TIME_VALID}
46 ... date_format=%m/%d/%Y %H:%M:%S exclude_millis=yes
47 ${bmcdate}= Get BMC Time Using IPMI
48 ${diff}= Subtract Date From Date ${bmcdate} ${setdate}
49 Should Be True ${diff} < ${ALLOWED_TIME_DIFF}
50 ... Open BMC time does not match with set time
Chris Austenb29d2e82016-06-07 12:25:35 -050051
52Set Invalid System Time
Rahul Maheshwarif8785902016-12-12 01:23:13 -060053 [Documentation] Set system time with invalid time using IPMI and verify
54 ... that it should throw error.
George Keishing845fb822016-11-01 13:23:19 -050055 [Tags] Set_Invalid_System_Time
Chris Austenb29d2e82016-06-07 12:25:35 -050056
Rahul Maheshwarif8785902016-12-12 01:23:13 -060057 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
58 ... sel time set "${SYSTEM_TIME_INVALID}"
59 Should Start With ${msg} Specified time could not be parsed
Chris Austenb29d2e82016-06-07 12:25:35 -050060
61Set System Time with no time
Rahul Maheshwarif8785902016-12-12 01:23:13 -060062 [Documentation] Set system time with no time using IPMI and verify
63 ... that it should throw error.
George Keishing845fb822016-11-01 13:23:19 -050064 [Tags] Set_System_Time_with_no_time
Chris Austenb29d2e82016-06-07 12:25:35 -050065
Rahul Maheshwarif8785902016-12-12 01:23:13 -060066 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
67 ... sel time set ""
68 Should Start With ${msg} Specified time could not be parsed
Chris Austenb29d2e82016-06-07 12:25:35 -050069
Rahul Maheshwari93f68092016-10-24 02:42:12 -050070
Rahul Maheshwarif8785902016-12-12 01:23:13 -060071Set BMC Time With BMC And Manual
72 #Operation Owner Mode Status BMC Time Host Time
73 Set BMC Time BMC MANUAL ok Set Change
Rahul Maheshwari93f68092016-10-24 02:42:12 -050074
Rahul Maheshwarif8785902016-12-12 01:23:13 -060075 [Documentation] Set BMC time when time owner is BMC and time mode is
76 ... manual.
77 [Tags] Set_BMC_Time_With_BMC_And_Manual
78 [Template] Set Time Using REST
Rahul Maheshwari93f68092016-10-24 02:42:12 -050079
Rahul Maheshwarif8785902016-12-12 01:23:13 -060080Set BMC Time With Both And Manual
81 #Operation Owner Mode Status BMC Time Host Time
82 Set BMC Time BOTH MANUAL ok Set Change
Rahul Maheshwari93f68092016-10-24 02:42:12 -050083
Rahul Maheshwarif8785902016-12-12 01:23:13 -060084 [Documentation] Set BMC time when time owner is Both and time mode is
85 ... manual.
86 [Tags] Set_BMC_Time_With_Both_And_Manual
87 [Template] Set Time Using REST
Rahul Maheshwari93f68092016-10-24 02:42:12 -050088
Rahul Maheshwari93f68092016-10-24 02:42:12 -050089
Rahul Maheshwarif8785902016-12-12 01:23:13 -060090Set BMC Time With Split And Manual
91 #Operation Owner Mode Status BMC Time Host Time
92 Set BMC Time SPLIT MANUAL ok Set No Change
Rahul Maheshwari93f68092016-10-24 02:42:12 -050093
Rahul Maheshwarif8785902016-12-12 01:23:13 -060094 [Documentation] Set BMC time when time owner is Split and time mode is
95 ... manual.
96 [Tags] Set_BMC_Time_With_Split_And_Manual
97 [Template] Set Time Using REST
Rahul Maheshwari93f68092016-10-24 02:42:12 -050098
Rahul Maheshwarif8785902016-12-12 01:23:13 -060099Set BMC Time With BMC And NTP
100 #Operation Owner Mode Status BMC Time Host Time
101 Set BMC Time BMC NTP error Not Set No Change
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500102
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600103 [Documentation] Set BMC time when time owner is BMC and time mode is
104 ... NTP.
105 [Tags] Set_BMC_Time_With_BMC_And_NTP
106 [Template] Set Time Using REST
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500107
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600108Set BMC Time With Host And Manual
109 #Operation Owner Mode Status BMC Time Host Time
110 Set BMC Time HOST MANUAL error Not Set No Change
111 [Documentation] Set BMC time when time owner is Host and time mode is
112 ... Manual.
113 [Tags] Set_BMC_Time_With_Host_And_Manual
114 [Template] Set Time Using REST
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500115
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600116Set BMC Time With Both And NTP
117 #Operation Owner Mode Status BMC Time Host Time
118 Set BMC Time BOTH NTP error Not Set No Change
119
120 [Documentation] Set BMC time when time owner is Both and time mode is
121 ... NTP.
122 [Tags] Set_BMC_Time_With_Both_And_NTP
123 [Template] Set Time Using REST
124
125Set BMC Time With Split And NTP
126 #Operation Owner Mode Status BMC Time Host Time
127 Set BMC Time SPLIT NTP error Not Set No Change
128
129 [Documentation] Set BMC time when time owner is Split and time mode is
130 ... NTP.
131 [Tags] Set_BMC_Time_With_Split_And_NTP
132 [Template] Set Time Using REST
133
134Set Host Time With Host And Manual
135 #Operation Owner Mode Status BMC Time Host Time
136 Set Host Time HOST MANUAL ok Change Set
137
138 [Documentation] Set host time when time owner is host and time mode is
139 ... manual.
140 [Tags] Set_Host_Time_With_Host_And_Manual
141 [Template] Set Time Using REST
142
143Set Host Time With Both And Manual
144 #Operation Owner Mode Status BMC Time Host Time
145 Set Host Time BOTH MANUAL ok Change Set
146
147 [Documentation] Set host time when time owner is both and time mode is
148 ... manual.
149 [Tags] Set_Host_Time_With_Both_And_Manual
150 [Template] Set Time Using REST
151
152Set Host Time With Both And NTP
153 #Operation Owner Mode Status BMC Time Host Time
154 Set Host Time BOTH NTP ok No Change Set
155
156 [Documentation] Set host time when time owner is both and time mode is
157 ... NTP.
158 [Tags] Set_Host_Time_With_Both_And_NTP
159 [Template] Set Time Using REST
160
161Set Host Time With Split And Manual
162 #Operation Owner Mode Status BMC Time Host Time
163 Set Host Time SPLIT MANUAL ok No Change Set
164
165 [Documentation] Set host time when time owner is split and time mode is
166 ... manual.
167 [Tags] Set_Host_Time_With_Split_And_Manual
168 [Template] Set Time Using REST
169
170Set Host Time With Split And NTP
171 #Operation Owner Mode Status BMC Time HOST Time
172 Set Host Time SPLIT NTP ok No Change Set
173
174 [Documentation] Set host time when time owner is split and time mode is
175 ... NTP.
176 [Tags] Set_Host_Time_With_Split_And_NTP
177 [Template] Set Time Using REST
178
179Set Host Time With BMC And Manual
180 #Operation Owner Mode Status BMC Time HOST Time
181 Set Host Time BMC MANUAL error No Change Not Set
182 [Documentation] Set host time when time owner is BMC and time mode is
183 ... Manual.
184 [Tags] Set_Host_Time_With_BMC_And_Manual
185 [Template] Set Time Using REST
186
187Set Host Time With BMC Owner NTP
188 #Operation Owner Mode Status BMC Time HOST Time
189 Set Host Time BMC NTP error No Change Not Set
190 [Documentation] Set host time when time owner is BMC and time mode is
191 ... NTP.
192 [Tags] Set_Host_Time_With_BMC_And_NTP
193 [Template] Set Time Using REST
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500194
195Set Invalid Time Mode
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600196 [Documentation] Set time mode with invalid value using REST and verify
197 ... that it should throw error.
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500198 [Tags] Set_Invalid_Time_Mode
199
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600200 ${timemode}= Set Variable abc
201 ${valueDict}= Create Dictionary data=${timemode}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500202
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600203 ${resp}= OpenBMC Put Request
204 ... ${SETTING_HOST}/attr/time_mode data=${valueDict}
205 ${jsondata}= to JSON ${resp.content}
206 Should Be Equal ${jsondata['status']} error
207
208 ${mode}= Read Attribute ${SETTING_HOST} time_mode
209 Should Not Be Equal ${mode} abc
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500210
211Set Invalid Time Owner
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600212 [Documentation] Set time owner with invalid value using REST and verify
213 ... that it should throw error.
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500214 [Tags] Set_Invalid_Time_Owner
215
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600216 ${timeowner}= Set Variable xyz
217 ${valueDict}= Create Dictionary data=${timeowner}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500218
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600219 ${resp}= OpenBMC Put Request
220 ... ${SETTING_HOST}/attr/time_owner data=${valueDict}
221 ${jsondata}= to JSON ${resp.content}
222 Should Be Equal ${jsondata['status']} error
223
224 ${owner}= Read Attribute ${SETTING_HOST} time_owner
225 Should Not Be Equal ${owner} xyz
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500226
227
Chris Austenb29d2e82016-06-07 12:25:35 -0500228*** Keywords ***
229
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600230Get BMC Time Using IPMI
231 [Documentation] Returns BMC time of the system via IPMI
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500232
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600233 ${stdout} ${stderr} ${output}=
234 ... Execute Command date "+%m/%d/%Y %H:%M:%S"
235 ... return_stdout=True return_stderr= True return_rc=True
236 Should Be Equal ${output} ${0} msg=${stderr}
237
238 ${resp}= Convert Date ${stdout} date_format=%m/%d/%Y %H:%M:%S
239 ... exclude_millis=yes
240 Should Not Be Empty ${resp}
241 [Return] ${resp}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500242
243Set Time Owner
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600244 [Arguments] ${args}
245 [Documentation] Set time owner of the system via REST
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500246
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600247 ${timeowner}= Set Variable ${args}
248 ${valueDict}= Create Dictionary data=${timeowner}
249
250 ${resp}= OpenBMC Put Request
251 ... ${SETTING_HOST}/attr/time_owner data=${valueDict}
252 ${jsondata}= to JSON ${resp.content}
253
Rahul Maheshwari2c725042017-01-29 22:55:28 -0600254 ${host_state}= Get Host State
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600255
Rahul Maheshwari2c725042017-01-29 22:55:28 -0600256 Run Keyword If '${host_state}' == 'Off'
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600257 ... Log System is in off state so owner change will get applied.
258 ... ELSE Run keyword
Rahul Maheshwari2c725042017-01-29 22:55:28 -0600259 ... Initiate Host PowerOff
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600260
261 ${owner}= Read Attribute ${SETTING_HOST} time_owner
262 Should Be Equal ${owner} ${args}
263
264 ${current_mode}=
265 ... Read Attribute ${TIME_MANAGER_URI.rstrip("/")} curr_time_owner
266 Should Be Equal ${current_mode} ${args}
267
268 [Return] ${jsondata['status']}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500269
270Set Time Mode
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600271 [Arguments] ${args}
272 [Documentation] Set time mode of the system via REST
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500273
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600274 ${timemode}= Set Variable ${args}
275 ${valueDict}= Create Dictionary data=${timemode}
276
277 ${resp}= OpenBMC Put Request
278 ... ${SETTING_HOST}/attr/time_mode data=${valueDict}
279 ${jsondata}= to JSON ${resp.content}
280 Sleep 5s
281
282 ${mode}= Read Attribute ${SETTING_HOST} time_mode
283 Should Be Equal ${mode} ${args}
284
285 ${current_mode}=
286 ... Read Attribute ${TIME_MANAGER_URI.rstrip("/")} curr_time_mode
287 Should Be Equal ${current_mode} ${args}
288
289Get BMC Time Using REST
290 [Documentation] Returns BMC time of the system via REST
291 ... Time Format : YYYY-MM-DD hh:mm:ss.mil
292 ... eg. 2016-12-14 07:09:58.000
293
294 @{time_owner}= Create List BMC
295 ${data}= Create Dictionary data=@{time_owner}
296 ${resp}= OpenBMC Post Request
297 ... ${TIME_MANAGER_URI}action/GetTime data=${data}
298 ${jsondata}= To JSON ${resp.content}
299 ${time_epoch}= Get From List ${jsondata["data"]} 0
300 ${resp}= Convert Date
301 ... ${time_epoch} date_format=%a %b %d %H:%M:%S %Y %Z
302 [Return] ${resp}
303
304Get HOST Time Using REST
305 [Documentation] Returns HOST time of the system via REST
306 ... Time Format : YYYY-MM-DD hh:mm:ss.mil
307 ... eg. 2016-12-14 07:09:58.000
308
309 @{time_owner}= Create List HOST
310 ${data}= Create Dictionary data=@{time_owner}
311 ${resp}= OpenBMC Post Request
312 ... ${TIME_MANAGER_URI}action/GetTime data=${data}
313 ${jsondata}= To JSON ${resp.content}
314 ${time_epoch}= Get From List ${jsondata["data"]} 0
315 ${resp}= Convert Date
316 ... ${time_epoch} date_format=%a %b %d %H:%M:%S %Y %Z
317 [Return] ${resp}
318
319Set Time Using REST
320 [Arguments] ${operation} ${owner} ${mode} ${status} ${bmc_time}
321 ... ${host_time}
322 [Documentation] Set BMC or Host time on system via REST.
323 ... Description of arguments:
324 ... operation : Set BMC/Host time
325 ... owner: Time owner
326 ... mode: Time mode
327 ... status: Expected status of set BMC time URI
328 ... bmc_time: Status of BMC time after operation
329 ... host_time: Status of HOST time after operation
330 ... Set - Given time is set
331 ... Not Set - Given time is not set
332 ... Change - time is change
333 ... No Change - time is not change
334
335 Set Time Owner ${owner}
336 Set Time Mode ${mode}
337
338 ${setdate}= Convert Date ${SYSTEM_TIME_VALID}
339 ... date_format=%m/%d/%Y %H:%M:%S exclude_millis=yes
340
341 @{bmc_date_list}= Create List BMC ${setdate}
342 @{host_date_list}= Create List HOST ${SYSTEM_TIME_VALID_EPOCH}
343
344 ${time_owner_date}= Set Variable If
345 ... '${operation}' == 'Set BMC Time' ${bmc_date_list}
346 ... '${operation}' == 'Set Host Time' ${host_date_list}
347
348 ${old_bmc_time}= Get BMC Time Using REST
349 ${old_host_time}= Get HOST Time Using REST
350
351 ${data}= Create Dictionary data=${time_owner_date}
352 ${resp}= OpenBMC Post Request
353 ... ${TIME_MANAGER_URI}action/SetTime data=${data}
354 ${jsondata}= To JSON ${resp.content}
355 Should Be Equal As Strings ${jsondata['status']} ${status}
356
357 ${new_bmc_time}= Get BMC Time Using REST
358 ${new_host_time}= Get HOST Time Using REST
359
360 ${bmc_diff_set_new}=
361 ... Subtract Date From Date ${setdate} ${new_bmc_time}
362 ${bmc_diff_set_new}= Evaluate abs(${bmc_diff_set_new})
363 ${bmc_diff_old_new}=
364 ... Subtract Date From Date ${old_bmc_time} ${new_bmc_time}
365 ${bmc_diff_old_new}= Evaluate abs(${bmc_diff_old_new})
366
367 ${host_diff_set_new}=
368 ... Subtract Date From Date ${setdate} ${new_host_time}
369 ${host_diff_set_new}= Evaluate abs(${host_diff_set_new})
370 ${host_diff_old_new}=
371 ... Subtract Date From Date ${old_host_time} ${new_host_time}
372 ${host_diff_old_new}= Evaluate abs(${host_diff_old_new})
373
374 Run Keyword If '${bmc_time}' == 'Not Set'
375 ... Should Be True ${bmc_diff_set_new} >= ${ALLOWED_TIME_DIFF}
376 ... ELSE IF '${bmc_time}' == 'Set'
377 ... Should Be True ${bmc_diff_set_new} <= ${ALLOWED_TIME_DIFF}
378 ... ELSE IF '${bmc_time}' == 'No Change'
379 ... Should Be True ${bmc_diff_old_new} <= ${ALLOWED_TIME_DIFF}
380 ... ELSE IF '${bmc_time}' == 'Change'
381 ... Should Be True ${bmc_diff_old_new} >= ${ALLOWED_TIME_DIFF}
382
383 Run Keyword If '${host_time}' == 'No Change'
384 ... Should Be True ${host_diff_old_new} <= ${ALLOWED_TIME_DIFF}
385 ... ELSE IF '${host_time}' == 'Change'
386 ... Should Be True ${host_diff_old_new} >= ${ALLOWED_TIME_DIFF}
387 ... ELSE IF '${host_time}' == 'Not Set'
388 ... Should Be True ${host_diff_set_new} >= ${ALLOWED_TIME_DIFF}
389 ... ELSE IF '${host_time}' == 'Set'
390 ... Should Be True ${host_diff_set_new} <= ${ALLOWED_TIME_DIFF}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500391
392
393Post Test Execution
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600394 [Documentation] Perform operations after test execution. Capture FFDC
395 ... in case of test case failure and sets default values for time mode
396 ... and owner.
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500397
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600398 Run Keyword If Test Failed FFDC On Test Case Fail
399 Set Time Owner BMC
400 Set Time Mode NTP