blob: 1fc75a6f55f7abeea78eebb6cc7c77babaf2a16b [file] [log] [blame]
George Keishing8cca7fb2019-05-30 04:23:50 -05001*** Settings ***
2Documentation Inventory of hardware resources under systems.
3
4Resource ../../../lib/bmc_redfish_resource.robot
5Resource ../../../lib/bmc_redfish_utils.robot
6Resource ../../../lib/logging_utils.robot
7Resource ../../../lib/openbmc_ffdc.robot
George Keishing8fe60242019-06-03 23:06:12 -05008Resource ../../../lib/ipmi_client.robot
George Keishing759c6f92019-06-03 12:14:42 -05009Library ../../../lib/logging_utils.py
George Keishing8cca7fb2019-05-30 04:23:50 -050010
George Keishing2f369472019-07-23 12:03:10 -050011Suite Setup Suite Setup Execution
12Suite Teardown Suite Teardown Execution
George Keishingb0a491f2019-05-31 02:49:22 -050013Test Setup Test Setup Execution
George Keishing8cca7fb2019-05-30 04:23:50 -050014Test Teardown Test Teardown Execution
15
Matt Fischer6fb70d92023-10-24 19:06:33 -060016Test Tags Event_Logging
George Keishingf699f552023-09-14 19:05:01 +053017
George Keishing759c6f92019-06-03 12:14:42 -050018** Variables ***
19
20${max_num_event_logs} ${200}
21
George Keishing8cca7fb2019-05-30 04:23:50 -050022*** Test Cases ***
23
24Event Log Check After BMC Reboot
25 [Documentation] Check event log after BMC rebooted.
26 [Tags] Event_Log_Check_After_BMC_Reboot
27
28 Redfish Purge Event Log
29 Event Log Should Not Exist
30
31 Redfish OBMC Reboot (off)
32
33 Redfish.Login
34 Wait Until Keyword Succeeds 1 mins 15 secs Redfish.Get ${EVENT_LOG_URI}Entries
35
36 Event Log Should Not Exist
37
38
George Keishingb0a491f2019-05-31 02:49:22 -050039Event Log Check After Host Poweron
40 [Documentation] Check event log after host has booted.
41 [Tags] Event_Log_Check_After_Host_Poweron
42
43 Redfish Purge Event Log
44 Event Log Should Not Exist
45
46 Redfish Power On
47
48 Redfish.Login
49 Event Log Should Not Exist
50
51
52Create Test Event Log And Verify
53 [Documentation] Create event logs and verify via redfish.
54 [Tags] Create_Test_Event_Log_And_Verify
55
56 Create Test Error Log
57 Event Log Should Exist
58
59
Rahul Maheshwari20c08e42021-05-10 01:41:01 -050060Delete Redfish Event Log And Verify
61 [Documentation] Delete Redfish event log and verify via Redfish.
62 [Tags] Delete_Redfish_Event_Log_And_Verify
63
64 Redfish.Login
65 Redfish Purge Event Log
66 Create Test PEL Log
67 ${elog_entry}= Get Event Logs
68
Yi Huc32434a2024-01-11 17:33:10 -080069 Redfish.Delete /redfish/v1/Systems/${SYSTEM_ID}/LogServices/EventLog/Entries/${elog_entry[0]["Id"]}
Rahul Maheshwari20c08e42021-05-10 01:41:01 -050070
71 ${error_entries}= Get Redfish Error Entries
72 Should Be Empty ${error_entries}
73
74
George Keishingb0a491f2019-05-31 02:49:22 -050075Test Event Log Persistency On Restart
76 [Documentation] Restart logging service and verify event logs.
77 [Tags] Test_Event_Log_Persistency_On_Restart
78
79 Create Test Error Log
80 Event Log Should Exist
81
82 BMC Execute Command
83 ... systemctl restart xyz.openbmc_project.Logging.service
84 Sleep 10s reason=Wait for logging service to restart properly.
85
86 Event Log Should Exist
87
88
89Test Event Entry Numbering Reset On Restart
90 [Documentation] Restart logging service and verify event logs entry starts
91 ... from entry "Id" 1.
92 [Tags] Test_Event_Entry_Numbering_Reset_On_Restart
Rahul Maheshwari20560f92021-12-21 05:16:11 -060093 [Setup] Redfish Power Off stack_mode=skip
George Keishingb0a491f2019-05-31 02:49:22 -050094
95 #{
96 # "@odata.context": "/redfish/v1/$metadata#LogEntryCollection.LogEntryCollection",
97 # "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries",
98 # "@odata.type": "#LogEntryCollection.LogEntryCollection",
99 # "Description": "Collection of System Event Log Entries",
100 # "Members": [
101 # {
102 # "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
103 # "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1",
104 # "@odata.type": "#LogEntry.v1_4_0.LogEntry",
105 # "Created": "2019-05-29T13:19:27+00:00",
106 # "EntryType": "Event",
107 # "Id": "1", <----- Event log ID
108 # "Message": "org.open_power.Host.Error.Event",
109 # "Name": "System DBus Event Log Entry",
110 # "Severity": "Critical"
111 # }
112 # ],
113 # "Members@odata.count": 1,
114 # "Name": "System Event Log Entries"
115 #}
116
Rahul Maheshwari20560f92021-12-21 05:16:11 -0600117 Create Test PEL Log
118 Create Test PEL Log
George Keishingb0a491f2019-05-31 02:49:22 -0500119 Event Log Should Exist
120
121 Redfish Purge Event Log
122 Event Log Should Not Exist
123
124 BMC Execute Command
125 ... systemctl restart xyz.openbmc_project.Logging.service
126 Sleep 10s reason=Wait for logging service to restart properly.
127
Rahul Maheshwari20560f92021-12-21 05:16:11 -0600128 Create Test PEL Log
George Keishingb0a491f2019-05-31 02:49:22 -0500129 ${elogs}= Get Event Logs
manashsarmaadf10ee2024-05-14 07:14:17 -0500130
131 # After issuing Redfish purge event log, there will be one informational error log
132 # in BMC with ID 1. Due to this the newly generated error log would have ID as 2.
133 Should Be Equal ${elogs[0]["Id"]} 2 msg=Event log entry is not 2
George Keishingb0a491f2019-05-31 02:49:22 -0500134
135
136Test Event Log Persistency On Reboot
137 [Documentation] Reboot BMC and verify event log.
138 [Tags] Test_Event_Log_Persistency_On_Reboot
139
140 Redfish Purge Event Log
141 Create Test Error Log
142 Event Log Should Exist
143
144 Redfish OBMC Reboot (off)
145
146 Redfish.Login
147 Wait Until Keyword Succeeds 1 mins 15 secs Redfish.Get ${EVENT_LOG_URI}Entries
148
149 Event Log Should Exist
150
151
George Keishing148d08c2019-05-31 12:39:04 -0500152Create Test Event Log And Verify Time Stamp
153 [Documentation] Create event logs and verify time stamp.
154 [Tags] Create_Test_Event_Log_And_Verify_Time_Stamp
155
156 #{
157 # "@odata.context": "/redfish/v1/$metadata#LogEntryCollection.LogEntryCollection",
158 # "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries",
159 # "@odata.type": "#LogEntryCollection.LogEntryCollection",
160 # "Description": "Collection of System Event Log Entries",
161 # "Members": [
162 # {
163 # "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
164 # "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1",
165 # "@odata.type": "#LogEntry.v1_4_0.LogEntry",
dnirmalaf4372442023-05-09 07:58:32 -0500166 # "Created": "2023-05-10T10:26:02.186+00:00", <--- Time stamp
George Keishing148d08c2019-05-31 12:39:04 -0500167 # "EntryType": "Event",
168 # "Id": "1",
169 # "Message": "org.open_power.Host.Error.Event",
170 # "Name": "System DBus Event Log Entry",
171 # "Severity": "Critical"
172 # }
173 # ],
174 # "Members@odata.count": 1,
175 # "Name": "System Event Log Entries"
176 #}
177
178 Redfish Purge Event Log
179
180 Create Test Error Log
181 Sleep 2s
182 Create Test Error Log
183
184 ${elog_entry}= Get Event Logs
185
186 # The event log generated is associated with the epoc time and unique
187 # for every error and in increasing time stamp.
dnirmalaf4372442023-05-09 07:58:32 -0500188 ${time_stamp1}= Convert Date ${elog_entry[0]["Created"].split('.')[0]} epoch
189 ${time_stamp2}= Convert Date ${elog_entry[1]["Created"].split('.')[0]} epoch
George Keishing148d08c2019-05-31 12:39:04 -0500190
191 Should Be True ${time_stamp2} > ${time_stamp1}
192
193
Rahul Maheshwari6462f262021-05-10 00:49:46 -0500194Verify Setting Error Log As Resolved
195 [Documentation] Verify modified field of error log is updated when error log is marked resolved.
196 [Tags] Verify_Setting_Error_Log_As_Resolved
197
198 Create Test PEL Log
199 ${elog_entry}= Get Event Logs
200
201 # Wait for 5 seconds after creating error log.
202 Sleep 5s
203
204 # Mark error log as resolved by setting it to true.
205 Redfish.Patch ${EVENT_LOG_URI}Entries/${elog_entry[0]["Id"]} body={'Resolved':True}
manashsarma8c065062025-03-05 04:42:05 -0600206 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
Rahul Maheshwari6462f262021-05-10 00:49:46 -0500207
208 ${elog_entry}= Get Event Logs
209
210 # Example error log with resolve field set to true:
211 # {
212 # "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/2045",
213 # "@odata.type": "#LogEntry.v1_8_0.LogEntry",
214 # "AdditionalDataURI": "/redfish/v1/Systems/system/LogServices/EventLog/attachment/2045",
dnirmalaf4372442023-05-09 07:58:32 -0500215 # "Created": "2023-05-10T10:26:02.186+00:00",
Rahul Maheshwari6462f262021-05-10 00:49:46 -0500216 # "EntryType": "Event",
217 # "Id": "2045",
218 # "Message": "xyz.openbmc_project.Host.Error.Event",
dnirmalaf4372442023-05-09 07:58:32 -0500219 # "Modified": "2023-05-10T10:26:02.186+00:00",
Rahul Maheshwari6462f262021-05-10 00:49:46 -0500220 # "Name": "System Event Log Entry",
221 # "Resolved": true,
222 # "Severity": "OK"
223 # }
224
225 Should Be Equal As Strings ${elog_entry[0]["Resolved"]} True
226
227 # Difference created and modified time of error log should be around 5 seconds.
dnirmalaf4372442023-05-09 07:58:32 -0500228 ${creation_time}= Convert Date ${elog_entry[0]["Created"].split('.')[0]} epoch
229 ${modification_time}= Convert Date ${elog_entry[0]["Modified"].split('.')[0]} epoch
Rahul Maheshwari6462f262021-05-10 00:49:46 -0500230
231 ${diff}= Subtract Date From Date ${modification_time} ${creation_time}
232 ${diff}= Convert To Number ${diff}
233 Should Be True 4 < ${diff} < 8
234
235
George Keishingd35b5312019-05-31 14:29:07 -0500236Create Test Event Log And Delete
237 [Documentation] Create an event log and delete it.
238 [Tags] Create_Test_Event_Log_And_Delete
239
240 Create Test Error Log
241 Redfish Purge Event Log
242 Event Log Should Not Exist
243
244
245Create Multiple Test Event Logs And Delete All
246 [Documentation] Create multiple event logs and delete all.
247 [Tags] Create_Multiple_Test_Event_Logs_And_Delete_All
248
249 Create Test Error Log
250 Create Test Error Log
251 Create Test Error Log
252 Redfish Purge Event Log
253 Event Log Should Not Exist
254
255
George Keishingddbc88c2019-06-06 07:29:41 -0500256Create Two Test Event Logs And Delete One
257 [Documentation] Create two event logs and delete the first entry.
George Keishing89f499d2021-04-19 05:25:40 -0500258 [Tags] Create_Two_Test_Event_Logs_And_Delete_One
Rahul Maheshwaric2d33652021-12-21 00:19:58 -0600259 [Setup] Redfish Power Off stack_mode=skip
George Keishingddbc88c2019-06-06 07:29:41 -0500260
261 Redfish Purge Event Log
Rahul Maheshwaric2d33652021-12-21 00:19:58 -0600262 Create Test PEL Log
263 Create Test PEL Log
264 ${error_entries_before}= Get Redfish Error Entries
Yi Huc32434a2024-01-11 17:33:10 -0800265 Redfish.Delete /redfish/v1/Systems/${SYSTEM_ID}/LogServices/EventLog/Entries/${error_entries_before[0]}
Rahul Maheshwaric2d33652021-12-21 00:19:58 -0600266
267 ${error_entries_after}= Get Redfish Error Entries
268 Should Not Contain ${error_entries_after} ${error_entries_before[0]}
269 Should Contain ${error_entries_after} ${error_entries_before[1]}
George Keishingddbc88c2019-06-06 07:29:41 -0500270
271
George Keishingd35b5312019-05-31 14:29:07 -0500272Verify Watchdog Timedout Event
273 [Documentation] Trigger watchdog timed out and verify event log generated.
274 [Tags] Verify_Watchdog_Timedout_Event
George Keishing2ab62412022-07-28 11:53:23 -0500275 [Teardown] Run Keywords Test Teardown Execution AND Redfish Power Off stack_mode=skip
George Keishingd35b5312019-05-31 14:29:07 -0500276
George Keishing2ab62412022-07-28 11:53:23 -0500277 Redfish Power Off stack_mode=skip
George Keishingd35b5312019-05-31 14:29:07 -0500278
279 # Clear errors if there are any.
280 Redfish.Login
281 Redfish Purge Event Log
282
George Keishing2ab62412022-07-28 11:53:23 -0500283 # Reference: [Old legacy REST code] Trigger Host Watchdog Error
284 # Currently, no known redfish interface to set to trigger watchdog timer.
285
286 Redfish Initiate Auto Reboot 1000
George Keishingd35b5312019-05-31 14:29:07 -0500287
288 # Logging takes time to generate the timeout error.
George Keishing2ab62412022-07-28 11:53:23 -0500289 Wait Until Keyword Succeeds 3 min 20 sec Verify Watchdog EventLog Content
George Keishingd35b5312019-05-31 14:29:07 -0500290
George Keishingd35b5312019-05-31 14:29:07 -0500291
292Verify Event Logs Capping
293 [Documentation] Verify event logs capping.
294 [Tags] Verify_Event_Logs_Capping
295
296 Redfish Purge Event Log
297
George Keishing033ee182022-07-28 05:24:55 -0500298 ${cmd}= Catenate uptime; for i in {1..201}; do /tmp/tarball/bin/logging-test -c
299 ... AutoTestSimple;sleep 1;done; uptime
George Keishingd35b5312019-05-31 14:29:07 -0500300 BMC Execute Command ${cmd}
301
302 ${elogs}= Get Event Logs
303 ${count}= Get Length ${elogs}
304 Run Keyword If ${count} > 200
305 ... Fail Error logs created exceeded max capacity 200.
306
307
George Keishing759c6f92019-06-03 12:14:42 -0500308Test Event Log Wrapping
309 [Documentation] Verify event log entries wraps when 200 max cap is reached.
310 [Tags] Test_Event_Log_Wrapping
311
312 # Restarting logging service in order to clear logs and get the next log
313 # ID set to 1.
314 BMC Execute Command
315 ... systemctl restart xyz.openbmc_project.Logging.service
316 Sleep 10s reason=Wait for logging service to restart properly.
317
318 # Create ${max_num_event_logs} event logs.
George Keishing033ee182022-07-28 05:24:55 -0500319 ${cmd}= Catenate uptime; for i in {1..${max_num_event_logs}}; do /tmp/tarball/bin/logging-test -c
320 ... AutoTestSimple;sleep 1;done; uptime
George Keishing759c6f92019-06-03 12:14:42 -0500321 BMC Execute Command ${cmd}
322
323 # Verify that event logs with IDs 1 and ${max_num_event_logs} exist.
324 ${event_log}= Get Event Logs
325
326 ${log_entries}= Filter Struct ${event_log} [('Id', '1')]
Michael Walsh39c00512019-07-17 10:54:06 -0500327 Rprint Vars log_entries
George Keishing759c6f92019-06-03 12:14:42 -0500328 Should Be Equal As Strings ${log_entries[0]["Id"]} 1
329
330 ${log_entries}= Filter Struct ${event_log} [('Id', '${max_num_event_logs}')]
Michael Walsh39c00512019-07-17 10:54:06 -0500331 Rprint Vars log_entries
George Keishing759c6f92019-06-03 12:14:42 -0500332 Should Be Equal As Strings ${log_entries[0]["Id"]} ${max_num_event_logs}
333
334 # Create event log and verify the entry ID, ${max_num_event_logs + 1}.
335 ${next_event_log_id}= Set Variable ${max_num_event_logs + 1}
336
337 Create Test Error Log
338
339 ${event_log}= Get Event Logs
340
341 ${log_entries}= Filter Struct ${event_log} [('Id', '${next_event_log_id}')]
Michael Walsh39c00512019-07-17 10:54:06 -0500342 Rprint Vars log_entries
George Keishing759c6f92019-06-03 12:14:42 -0500343 Should Be Equal As Strings ${log_entries[0]["Id"]} ${next_event_log_id}
344
345 # Event log 1 should be wrapped.
346 ${log_entries}= Filter Struct ${event_log} [('Id', '1')]
Michael Walsh39c00512019-07-17 10:54:06 -0500347 Rprint Vars log_entries
George Keishing759c6f92019-06-03 12:14:42 -0500348
349 ${length_log_entries} Get Length ${log_entries}
350 Should Be Equal As Integers ${length_log_entries} 0
351 ... msg=The event log should have wrapped such that entry ID 1 is now purged.
352
353
dnirmala2e092d02023-04-18 01:17:32 -0500354Verify Default Value Of Resolved Field Is False For An Error Log Via Redfish
355 [Documentation] Verify the Resolve field status is false for an error log from Redfish.
356 [Tags] Verify_Default_Value_Of_Resolved_Field_Is_False_For_An_Error_Log_Via_Redfish
357
358 Redfish Purge Event Log
359 Create Test Error Log
360
361 # Check resolve field value of created error log.
362 ${elog_entry}= Get Event Logs
363 Should Be Equal ${elog_entry[0]["Resolved"]} ${False}
364
365
George Keishing8cca7fb2019-05-30 04:23:50 -0500366*** Keywords ***
367
George Keishing2f369472019-07-23 12:03:10 -0500368Suite Setup Execution
369 [Documentation] Do test case setup tasks.
370
371 Redfish.Login
372
373 Redfish Purge Event Log
374
375 ${status}= Run Keyword And Return Status Logging Test Binary Exist
376 Run Keyword If ${status} == ${False} Install Tarball
377
378
George Keishing8cca7fb2019-05-30 04:23:50 -0500379Suite Teardown Execution
380 [Documentation] Do the post suite teardown.
381
382 Redfish.Logout
383
384
George Keishingb0a491f2019-05-31 02:49:22 -0500385Test Setup Execution
386 [Documentation] Do test case setup tasks.
George Keishing8cca7fb2019-05-30 04:23:50 -0500387
George Keishing0b76e422019-06-03 01:58:52 -0500388 Redfish Purge Event Log
389
George Keishing8cca7fb2019-05-30 04:23:50 -0500390 ${status}= Run Keyword And Return Status Logging Test Binary Exist
391 Run Keyword If ${status} == ${False} Install Tarball
392
393
394Test Teardown Execution
395 [Documentation] Do the post test teardown.
396
397 FFDC On Test Case Fail
George Keishinge5c5ebd2019-06-04 13:52:12 -0500398 Redfish.Login
George Keishingb0a491f2019-05-31 02:49:22 -0500399 Redfish Purge Event Log
George Keishing8cca7fb2019-05-30 04:23:50 -0500400
401
Rahul Maheshwari20c08e42021-05-10 01:41:01 -0500402Get Redfish Error Entries
403 [Documentation] Return Redfish error ids list.
Yi Huc32434a2024-01-11 17:33:10 -0800404 ${error_uris}= redfish_utils.get_member_list /redfish/v1/Systems/${SYSTEM_ID}/LogServices/EventLog/Entries
Rahul Maheshwari20c08e42021-05-10 01:41:01 -0500405 ${error_ids}= Create List
406
407 FOR ${error_uri} IN @{error_uris}
408 ${error_id}= Fetch From Right ${error_uri} /
409 Append To List ${error_ids} ${error_id}
410 END
411
George Keishing409df052024-01-17 22:36:14 +0530412 RETURN ${error_ids}
Rahul Maheshwari20c08e42021-05-10 01:41:01 -0500413
414
George Keishing8cca7fb2019-05-30 04:23:50 -0500415Event Log Should Not Exist
416 [Documentation] Event log entries should not exist.
417
418 ${elogs}= Get Event Logs
419 Should Be Empty ${elogs} msg=System event log entry is not empty.
George Keishingb0a491f2019-05-31 02:49:22 -0500420
421
422Event Log Should Exist
423 [Documentation] Event log entries should exist.
424
425 ${elogs}= Get Event Logs
426 Should Not Be Empty ${elogs} msg=System event log entry is not empty.
George Keishingd35b5312019-05-31 14:29:07 -0500427
428
429Verify Watchdog EventLog Content
430 [Documentation] Verify watchdog event log content.
431
432 # Example:
433 # {
434 # "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
435 # "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/31",
436 # "@odata.type": "#LogEntry.v1_4_0.LogEntry",
437 # "Created": "2019-05-31T18:41:33+00:00",
438 # "EntryType": "Event",
439 # "Id": "31",
440 # "Message": "org.open_power.Host.Boot.Error.WatchdogTimedOut",
441 # "Name": "System DBus Event Log Entry",
442 # "Severity": "Critical"
443 # }
444
George Keishing2ab62412022-07-28 11:53:23 -0500445 ${elog_list}= Get Event Logs
446
447 Rprint Vars elog_list
448
449 FOR ${entry} IN @{elog_list}
450 ${found_match}= Run Keyword And Return Status Is Watchdog Error Found ${entry}
451 Exit For Loop If '${found_match}' == 'True'
452 END
453
454 Run Keyword If '${found_match}' == 'False' Fail msg=No watchdog error logged.
455
456
457Is Watchdog Error Found
458 [Documentation] Check if the give log entry matches specific watchdog error.
459 [Arguments] ${elog}
460
461 # Description of argument(s):
462 # elog Error log entry dictionary data.
463
464 Should Contain Any
465 ... ${elog["Message"]} org.open_power.Host.Boot.Error.WatchdogTimedOut
466 ... CEC Hardware - Hostboot-Service Processor Interface
George Keishingd35b5312019-05-31 14:29:07 -0500467 ... msg=Watchdog timeout event log was not found.
George Keishing2ab62412022-07-28 11:53:23 -0500468
469 Log To Console Matched Found: ${elog}