blob: c91f178e72445b41890a1d79d3be1005faa2b265 [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
George Keishingab1bd922016-12-05 05:29:59 -06007Resource ../lib/resource.txt
Chris Austenb29d2e82016-06-07 12:25:35 -05008
George Keishing4d6c1da2016-07-15 05:51:22 -05009Library OperatingSystem
10Library DateTime
Chris Austenb29d2e82016-06-07 12:25:35 -050011
George Keishing4d6c1da2016-07-15 05:51:22 -050012Suite Setup Open Connection And Log In
13Suite Teardown Close All Connections
Rahul Maheshwari93f68092016-10-24 02:42:12 -050014Test Teardown Post Test Execution
Chris Austenb29d2e82016-06-07 12:25:35 -050015
16*** Variables ***
Rahul Maheshwarif8785902016-12-12 01:23:13 -060017${SYSTEM_TIME_INVALID} 01/01/1969 00:00:00
18${SYSTEM_TIME_VALID} 02/29/2016 09:10:00
19${SYSTEM_TIME_VALID_EPOCH} 1456737000 #Equivalent epoch time for 02/29/2016 09:10:00
20${ALLOWED_TIME_DIFF} 3
21${SETTING_HOST} ${SETTINGS_URI}host0
George Keishingab1bd922016-12-05 05:29:59 -060022
Chris Austenb29d2e82016-06-07 12:25:35 -050023*** Test Cases ***
24
25Get System Time
Rahul Maheshwarif8785902016-12-12 01:23:13 -060026 [Documentation] Get system time using IPMI and verify that it matches
27 ... with BMC date time.
George Keishing845fb822016-11-01 13:23:19 -050028 [Tags] Get_System_Time
Chris Austenb29d2e82016-06-07 12:25:35 -050029
Rahul Maheshwarif8785902016-12-12 01:23:13 -060030 ${resp}= Run IPMI Standard Command sel time get
31 ${ipmidate}= Convert Date ${resp} date_format=%m/%d/%Y %H:%M:%S
32 ... exclude_millis=yes
33 ${bmcdate}= Get BMC Time Using IPMI
34 ${diff}= Subtract Date From Date ${bmcdate} ${ipmidate}
35 Should Be True ${diff} < ${ALLOWED_TIME_DIFF}
36 ... Open BMC time does not match with IPMI sel time
Chris Austenb29d2e82016-06-07 12:25:35 -050037
38Set Valid System Time
Rahul Maheshwarif8785902016-12-12 01:23:13 -060039 [Documentation] Set system time using IPMI and verify that it is
40 ... correctly set in BMC.
George Keishing845fb822016-11-01 13:23:19 -050041 [Tags] Set_Valid_System_Time
Chris Austenb29d2e82016-06-07 12:25:35 -050042
Rahul Maheshwarif8785902016-12-12 01:23:13 -060043 ${resp}= Run IPMI Standard Command sel time set "${SYSTEM_TIME_VALID}"
44 ${setdate}= Convert Date ${SYSTEM_TIME_VALID}
45 ... date_format=%m/%d/%Y %H:%M:%S exclude_millis=yes
46 ${bmcdate}= Get BMC Time Using IPMI
47 ${diff}= Subtract Date From Date ${bmcdate} ${setdate}
48 Should Be True ${diff} < ${ALLOWED_TIME_DIFF}
49 ... Open BMC time does not match with set time
Chris Austenb29d2e82016-06-07 12:25:35 -050050
51Set Invalid System Time
Rahul Maheshwarif8785902016-12-12 01:23:13 -060052 [Documentation] Set system time with invalid time using IPMI and verify
53 ... that it should throw error.
George Keishing845fb822016-11-01 13:23:19 -050054 [Tags] Set_Invalid_System_Time
Chris Austenb29d2e82016-06-07 12:25:35 -050055
Rahul Maheshwarif8785902016-12-12 01:23:13 -060056 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
57 ... sel time set "${SYSTEM_TIME_INVALID}"
58 Should Start With ${msg} Specified time could not be parsed
Chris Austenb29d2e82016-06-07 12:25:35 -050059
60Set System Time with no time
Rahul Maheshwarif8785902016-12-12 01:23:13 -060061 [Documentation] Set system time with no time using IPMI and verify
62 ... that it should throw error.
George Keishing845fb822016-11-01 13:23:19 -050063 [Tags] Set_System_Time_with_no_time
Chris Austenb29d2e82016-06-07 12:25:35 -050064
Rahul Maheshwarif8785902016-12-12 01:23:13 -060065 ${msg}= Run Keyword And Expect Error * Run IPMI Standard Command
66 ... sel time set ""
67 Should Start With ${msg} Specified time could not be parsed
Chris Austenb29d2e82016-06-07 12:25:35 -050068
Rahul Maheshwari93f68092016-10-24 02:42:12 -050069
Rahul Maheshwarif8785902016-12-12 01:23:13 -060070Set BMC Time With BMC And Manual
71 #Operation Owner Mode Status BMC Time Host Time
72 Set BMC Time BMC MANUAL ok Set Change
Rahul Maheshwari93f68092016-10-24 02:42:12 -050073
Rahul Maheshwarif8785902016-12-12 01:23:13 -060074 [Documentation] Set BMC time when time owner is BMC and time mode is
75 ... manual.
76 [Tags] Set_BMC_Time_With_BMC_And_Manual
77 [Template] Set Time Using REST
Rahul Maheshwari93f68092016-10-24 02:42:12 -050078
Rahul Maheshwarif8785902016-12-12 01:23:13 -060079Set BMC Time With Both And Manual
80 #Operation Owner Mode Status BMC Time Host Time
81 Set BMC Time BOTH MANUAL ok Set Change
Rahul Maheshwari93f68092016-10-24 02:42:12 -050082
Rahul Maheshwarif8785902016-12-12 01:23:13 -060083 [Documentation] Set BMC time when time owner is Both and time mode is
84 ... manual.
85 [Tags] Set_BMC_Time_With_Both_And_Manual
86 [Template] Set Time Using REST
Rahul Maheshwari93f68092016-10-24 02:42:12 -050087
Rahul Maheshwari93f68092016-10-24 02:42:12 -050088
Rahul Maheshwarif8785902016-12-12 01:23:13 -060089Set BMC Time With Split And Manual
90 #Operation Owner Mode Status BMC Time Host Time
91 Set BMC Time SPLIT MANUAL ok Set No Change
Rahul Maheshwari93f68092016-10-24 02:42:12 -050092
Rahul Maheshwarif8785902016-12-12 01:23:13 -060093 [Documentation] Set BMC time when time owner is Split and time mode is
94 ... manual.
95 [Tags] Set_BMC_Time_With_Split_And_Manual
96 [Template] Set Time Using REST
Rahul Maheshwari93f68092016-10-24 02:42:12 -050097
Rahul Maheshwarif8785902016-12-12 01:23:13 -060098Set BMC Time With BMC And NTP
99 #Operation Owner Mode Status BMC Time Host Time
100 Set BMC Time BMC NTP error Not Set No Change
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500101
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600102 [Documentation] Set BMC time when time owner is BMC and time mode is
103 ... NTP.
104 [Tags] Set_BMC_Time_With_BMC_And_NTP
105 [Template] Set Time Using REST
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500106
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600107Set BMC Time With Host And Manual
108 #Operation Owner Mode Status BMC Time Host Time
109 Set BMC Time HOST MANUAL error Not Set No Change
110 [Documentation] Set BMC time when time owner is Host and time mode is
111 ... Manual.
112 [Tags] Set_BMC_Time_With_Host_And_Manual
113 [Template] Set Time Using REST
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500114
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600115Set BMC Time With Both And NTP
116 #Operation Owner Mode Status BMC Time Host Time
117 Set BMC Time BOTH NTP error Not Set No Change
118
119 [Documentation] Set BMC time when time owner is Both and time mode is
120 ... NTP.
121 [Tags] Set_BMC_Time_With_Both_And_NTP
122 [Template] Set Time Using REST
123
124Set BMC Time With Split And NTP
125 #Operation Owner Mode Status BMC Time Host Time
126 Set BMC Time SPLIT NTP error Not Set No Change
127
128 [Documentation] Set BMC time when time owner is Split and time mode is
129 ... NTP.
130 [Tags] Set_BMC_Time_With_Split_And_NTP
131 [Template] Set Time Using REST
132
133Set Host Time With Host And Manual
134 #Operation Owner Mode Status BMC Time Host Time
135 Set Host Time HOST MANUAL ok Change Set
136
137 [Documentation] Set host time when time owner is host and time mode is
138 ... manual.
139 [Tags] Set_Host_Time_With_Host_And_Manual
140 [Template] Set Time Using REST
141
142Set Host Time With Both And Manual
143 #Operation Owner Mode Status BMC Time Host Time
144 Set Host Time BOTH MANUAL ok Change Set
145
146 [Documentation] Set host time when time owner is both and time mode is
147 ... manual.
148 [Tags] Set_Host_Time_With_Both_And_Manual
149 [Template] Set Time Using REST
150
151Set Host Time With Both And NTP
152 #Operation Owner Mode Status BMC Time Host Time
153 Set Host Time BOTH NTP ok No Change Set
154
155 [Documentation] Set host time when time owner is both and time mode is
156 ... NTP.
157 [Tags] Set_Host_Time_With_Both_And_NTP
158 [Template] Set Time Using REST
159
160Set Host Time With Split And Manual
161 #Operation Owner Mode Status BMC Time Host Time
162 Set Host Time SPLIT MANUAL ok No Change Set
163
164 [Documentation] Set host time when time owner is split and time mode is
165 ... manual.
166 [Tags] Set_Host_Time_With_Split_And_Manual
167 [Template] Set Time Using REST
168
169Set Host Time With Split And NTP
170 #Operation Owner Mode Status BMC Time HOST Time
171 Set Host Time SPLIT NTP ok No Change Set
172
173 [Documentation] Set host time when time owner is split and time mode is
174 ... NTP.
175 [Tags] Set_Host_Time_With_Split_And_NTP
176 [Template] Set Time Using REST
177
178Set Host Time With BMC And Manual
179 #Operation Owner Mode Status BMC Time HOST Time
180 Set Host Time BMC MANUAL error No Change Not Set
181 [Documentation] Set host time when time owner is BMC and time mode is
182 ... Manual.
183 [Tags] Set_Host_Time_With_BMC_And_Manual
184 [Template] Set Time Using REST
185
186Set Host Time With BMC Owner NTP
187 #Operation Owner Mode Status BMC Time HOST Time
188 Set Host Time BMC NTP error No Change Not Set
189 [Documentation] Set host time when time owner is BMC and time mode is
190 ... NTP.
191 [Tags] Set_Host_Time_With_BMC_And_NTP
192 [Template] Set Time Using REST
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500193
194Set Invalid Time Mode
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600195 [Documentation] Set time mode with invalid value using REST and verify
196 ... that it should throw error.
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500197 [Tags] Set_Invalid_Time_Mode
198
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600199 ${timemode}= Set Variable abc
200 ${valueDict}= Create Dictionary data=${timemode}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500201
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600202 ${resp}= OpenBMC Put Request
203 ... ${SETTING_HOST}/attr/time_mode data=${valueDict}
204 ${jsondata}= to JSON ${resp.content}
205 Should Be Equal ${jsondata['status']} error
206
207 ${mode}= Read Attribute ${SETTING_HOST} time_mode
208 Should Not Be Equal ${mode} abc
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500209
210Set Invalid Time Owner
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600211 [Documentation] Set time owner with invalid value using REST and verify
212 ... that it should throw error.
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500213 [Tags] Set_Invalid_Time_Owner
214
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600215 ${timeowner}= Set Variable xyz
216 ${valueDict}= Create Dictionary data=${timeowner}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500217
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600218 ${resp}= OpenBMC Put Request
219 ... ${SETTING_HOST}/attr/time_owner data=${valueDict}
220 ${jsondata}= to JSON ${resp.content}
221 Should Be Equal ${jsondata['status']} error
222
223 ${owner}= Read Attribute ${SETTING_HOST} time_owner
224 Should Not Be Equal ${owner} xyz
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500225
226
Chris Austenb29d2e82016-06-07 12:25:35 -0500227*** Keywords ***
228
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600229Get BMC Time Using IPMI
230 [Documentation] Returns BMC time of the system via IPMI
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500231
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600232 ${stdout} ${stderr} ${output}=
233 ... Execute Command date "+%m/%d/%Y %H:%M:%S"
234 ... return_stdout=True return_stderr= True return_rc=True
235 Should Be Equal ${output} ${0} msg=${stderr}
236
237 ${resp}= Convert Date ${stdout} date_format=%m/%d/%Y %H:%M:%S
238 ... exclude_millis=yes
239 Should Not Be Empty ${resp}
240 [Return] ${resp}
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500241
242Set Time Owner
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600243 [Arguments] ${args}
244 [Documentation] Set time owner of the system via REST
Rahul Maheshwari93f68092016-10-24 02:42:12 -0500245
Rahul Maheshwarif8785902016-12-12 01:23:13 -0600246 ${timeowner}= Set Variable ${args}
247 ${valueDict}= Create Dictionary data=${timeowner}
248
249 ${resp}= OpenBMC Put Request
250 ... ${SETTING_HOST}/attr/time_owner data=${valueDict}
251 ${jsondata}= to JSON ${resp.content}
252
253 @{states}= Create List BMC_READY HOST_POWERED_OFF
254 ${bmc_state}= Get BMC State
255
256 Run Keyword If '${bmc_state}' in ${states}
257 ... Log System is in off state so owner change will get applied.
258 ... ELSE Run keyword
259 ... Initiate Power Off
260
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