blob: bc77fc451e1f54282c1460678bc2d7471acceb08 [file] [log] [blame]
George Keishingc37fca62017-11-24 05:07:32 -06001*** Settings ***
2Documentation Error logging utility keywords.
3
4Resource rest_client.robot
George Keishinga6c00892021-10-11 01:09:54 -05005Resource bmc_redfish_utils.robot
George Keishingc37fca62017-11-24 05:07:32 -06006Variables ../data/variables.py
Rahul Maheshwarib8580dd2021-05-10 00:57:33 -05007Variables ../data/pel_variables.py
Michael Walshdb1adf42020-03-20 15:05:46 -05008
9*** Variables ***
10
11
12# Define variables for use by callers of 'Get Error Logs'.
George Keishinga80d8ac2024-01-13 01:15:14 +053013# Old regex: ${low_severity_errlog_regex} \\.(Informational|Notice|Debug|OK)$
14# Simplified regex string search
15${low_severity_errlog_regex} Informational|Notice|Debug|OK
Michael Walshdb1adf42020-03-20 15:05:46 -050016&{low_severity_errlog_filter} Severity=${low_severity_errlog_regex}
17&{low_severity_errlog_filter_args} filter_dict=${low_severity_errlog_filter} regex=${True} invert=${True}
18# The following is equivalent to &{low_severity_errlog_filter_args} but the name may be more intuitive for
19# users. Example usage:
20# ${err_logs}= Get Error Logs &{filter_low_severity_errlogs}
21&{filter_low_severity_errlogs} &{low_severity_errlog_filter_args}
22
George Keishingc37fca62017-11-24 05:07:32 -060023*** Keywords ***
24
George Keishingba746442023-03-07 11:51:39 +053025Filter Expected Logging Events
26 [Documentation] Get redfish logging entry, remove the user input expected
27 ... log event and return the object list.
28 [Arguments] ${expected_event}=None
29
30 # Description of argument(s):
31 # expected_eventd Event log list.
32
33 ${all_event_list}= Get Redfish Event Logs
34 Remove Values From List ${all_event_list} ${expected_event}
35
36 [Return] ${all_event_list}
37
38
George Keishingc37fca62017-11-24 05:07:32 -060039Get Logging Entry List
40 [Documentation] Get logging entry and return the object list.
41
42 ${entry_list}= Create List
43 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}list quiet=${1}
44 Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND}
George Keishingc37fca62017-11-24 05:07:32 -060045
George Keishingfbd67002022-08-01 11:24:03 -050046 FOR ${entry} IN @{resp.json()["data"]}
Marissa Garza20ccfc72020-06-19 12:51:10 -050047 Continue For Loop If '${entry.rsplit('/', 1)[1]}' == 'callout'
48 Append To List ${entry_list} ${entry}
49 END
George Keishingc37fca62017-11-24 05:07:32 -060050
51 # Logging entries list.
52 # ['/xyz/openbmc_project/logging/entry/14',
53 # '/xyz/openbmc_project/logging/entry/15']
54 [Return] ${entry_list}
55
56
57Logging Entry Should Exist
58 [Documentation] Find the matching message id and return the entry id.
59 [Arguments] ${message_id}
60
61 # Description of argument(s):
62 # message_id Logging message string.
63 # Example: "xyz.openbmc_project.Common.Error.InternalFailure"
64
George Keishing5ac6e172018-04-09 12:44:15 -050065 @{elog_entries}= Get Logging Entry List
George Keishingc37fca62017-11-24 05:07:32 -060066
Marissa Garza20ccfc72020-06-19 12:51:10 -050067 FOR ${entry} IN @{elog_entries}
68 ${resp}= Read Properties ${entry}
69 ${status}= Run Keyword And Return Status
70 ... Should Be Equal As Strings ${message_id} ${resp["Message"]}
71 Return From Keyword If ${status} == ${TRUE} ${entry}
72 END
George Keishingc37fca62017-11-24 05:07:32 -060073
74 Fail No ${message_id} logging entry found.
75
Steven Sombar95672942018-03-23 11:24:58 -050076
77Get Error Logs
Michael Walshdb1adf42020-03-20 15:05:46 -050078 [Documentation] Return the BMC error logs as a dictionary.
79 [Arguments] ${quiet}=1 &{filter_struct_args}
80
81 # Example of call using pre-defined filter args (defined above).
82
83 # ${err_logs}= Get Error Logs &{filter_low_severity_errlogs}
84
85 # In this example, all error logs with "Severity" fields that are neither Informational, Debug nor
86 # Notice will be returned.
Steven Sombar95672942018-03-23 11:24:58 -050087
88 # Description of argument(s):
Michael Walshdb1adf42020-03-20 15:05:46 -050089 # quiet Indicates whether this keyword should run without any output to the
90 # console, 0 = verbose, 1 = quiet.
91 # filter_struct_args filter_struct args (e.g. filter_dict, regex, etc.) to be passed directly
92 # to the Filter Struct keyword. See its prolog for details.
Steven Sombar95672942018-03-23 11:24:58 -050093
94 # The length of the returned dictionary indicates how many logs there are.
Michael Walshdb1adf42020-03-20 15:05:46 -050095
96 # Use 'Print Error Logs' to print. Example:
97
98 # Print Error Logs ${error_logs} Message.
Steven Sombar95672942018-03-23 11:24:58 -050099
100 ${status} ${error_logs}= Run Keyword And Ignore Error Read Properties
Michael Walshdb1adf42020-03-20 15:05:46 -0500101 ... /xyz/openbmc_project/logging/entry/enumerate timeout=30 quiet=${quiet}
102 Return From Keyword If '${status}' == 'FAIL' &{EMPTY}
103 ${num_filter_struct_args}= Get Length ${filter_struct_args}
104 Return From Keyword If '${num_filter_struct_args}' == '${0}' ${error_logs}
105 ${filtered_error_logs}= Filter Struct ${error_logs} &{filter_struct_args}
106 [Return] ${filtered_error_logs}
Sivas SRRcf6714f2018-03-26 10:51:29 -0500107
108
109Get IPMI SEL Setting
110 [Documentation] Returns status for given IPMI SEL setting.
111 [Arguments] ${setting}
112 # Description of argument(s):
113 # setting SEL setting which needs to be read(e.g. "Last Add Time").
114
115 ${resp}= Run IPMI Standard Command sel info
116
117 ${setting_line}= Get Lines Containing String ${resp} ${setting}
118 ... case-insensitive
119 ${setting_status}= Fetch From Right ${setting_line} :${SPACE}
120
121 [Return] ${setting_status}
122
123
124Verify Watchdog Errorlog Content
125 [Documentation] Verify watchdog errorlog content.
126 # Example:
127 # "/xyz/openbmc_project/logging/entry/1":
128 # {
129 # "AdditionalData": [],
130 # "Id": 1,
131 # "Message": "org.open_power.Host.Boot.Error.WatchdogTimedOut",
132 # "Resolved": 0,
133 # "Severity": "xyz.openbmc_project.Logging.Entry.Level.Error",
134 # "Timestamp": 1492715244828,
George Keishing58520d02020-02-24 10:55:32 -0600135 # "Associations": []
Sivas SRRcf6714f2018-03-26 10:51:29 -0500136 # },
137
138 ${elog_entry}= Get URL List ${BMC_LOGGING_ENTRY}
139 ${elog}= Read Properties ${elog_entry[0]}
140 Should Be Equal As Strings
141 ... ${elog["Message"]} org.open_power.Host.Boot.Error.WatchdogTimedOut
Sivas SRR21c2ef22018-04-18 11:01:38 -0500142 ... msg=Watchdog timeout error log was not found.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500143 Should Be Equal As Strings
144 ... ${elog["Severity"]} xyz.openbmc_project.Logging.Entry.Level.Error
Sivas SRR21c2ef22018-04-18 11:01:38 -0500145 ... msg=Watchdog timeout severity unexpected value.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500146
147
148Logging Test Binary Exist
149 [Documentation] Verify existence of prerequisite logging-test.
George Keishing5f0c1fa2022-08-05 13:30:16 -0500150 ${stdout} ${stderr} ${rc}=
151 ... BMC Execute Command test -f /tmp/tarball/bin/logging-test print_out=1
Sivas SRR21c2ef22018-04-18 11:01:38 -0500152 Should Be Empty ${stderr} msg=Logging Test stderr is non-empty.
George Keishing5f0c1fa2022-08-05 13:30:16 -0500153
Sivas SRRcf6714f2018-03-26 10:51:29 -0500154
155Clear Existing Error Logs
156 [Documentation] If error log isn't empty, reboot the BMC to clear the log.
157 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}${1}
158 Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND}
159 Initiate BMC Reboot
160 Wait Until Keyword Succeeds 10 min 10 sec
161 ... Is BMC Ready
162 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}${1}
163 Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND}
Sivas SRR21c2ef22018-04-18 11:01:38 -0500164 ... msg=Could not clear BMC error logs.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500165
Rahul Maheshwarib8580dd2021-05-10 00:57:33 -0500166
167Create Test PEL Log
168 [Documentation] Generate test PEL log.
Rahul Maheshwari55e23462022-02-16 23:19:35 -0600169 [Arguments] ${pel_type}=Unrecoverable Error
Rahul Maheshwarib8580dd2021-05-10 00:57:33 -0500170
171 # Description of argument(s):
172 # pel_type The PEL type (e.g. Internal Failure, FRU Callout, Procedural Callout).
173
174 # Test PEL log entry example:
175 # {
176 # "0x5000002D": {
177 # "SRC": "BD8D1002",
178 # "Message": "An application had an internal failure",
179 # "PLID": "0x5000002D",
180 # "CreatorID": "BMC",
181 # "Subsystem": "BMC Firmware",
182 # "Commit Time": "02/25/2020 04:47:09",
183 # "Sev": "Unrecoverable Error",
184 # "CompID": "0x1000"
185 # }
186 # }
187
188 Run Keyword If '${pel_type}' == 'Internal Failure'
189 ... BMC Execute Command ${CMD_INTERNAL_FAILURE}
190 ... ELSE IF '${pel_type}' == 'FRU Callout'
191 ... BMC Execute Command ${CMD_FRU_CALLOUT}
192 ... ELSE IF '${pel_type}' == 'Procedure And Symbolic FRU Callout'
193 ... BMC Execute Command ${CMD_PROCEDURAL_SYMBOLIC_FRU_CALLOUT}
Rahul Maheshwari55e23462022-02-16 23:19:35 -0600194 ... ELSE IF '${pel_type}' == 'Unrecoverable Error'
195 ... BMC Execute Command ${CMD_UNRECOVERABLE_ERROR}
Rahul Maheshwarib8580dd2021-05-10 00:57:33 -0500196
197
Sivas SRRcf6714f2018-03-26 10:51:29 -0500198Create Test Error Log
199 [Documentation] Generate test error log.
200 # Test error log entry example:
201 # "/xyz/openbmc_project/logging/entry/1": {
202 # "AdditionalData": [
203 # "STRING=FOO"
204 # ],
205 # "Id": 1,
206 # "Message": "example.xyz.openbmc_project.Example.Elog.AutoTestSimple",
207 # "Severity": "xyz.openbmc_project.Logging.Entry.Level.Error",
208 # "Timestamp": 1487743963328,
George Keishing58520d02020-02-24 10:55:32 -0600209 # "Associations": []
Sivas SRRcf6714f2018-03-26 10:51:29 -0500210 # }
Joy Onyerikwu9b668972018-05-22 19:10:43 -0500211 BMC Execute Command /tmp/tarball/bin/logging-test -c AutoTestSimple
Sivas SRRcf6714f2018-03-26 10:51:29 -0500212
213Count Error Entries
214 [Documentation] Count Error entries.
215 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}
216 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
Sivas SRR21c2ef22018-04-18 11:01:38 -0500217 ... msg=Failed to get error logs.
George Keishingfbd67002022-08-01 11:24:03 -0500218 ${count}= Get Length ${resp.json()["data"]}
Sivas SRRcf6714f2018-03-26 10:51:29 -0500219 [Return] ${count}
220
221Verify Test Error Log
222 [Documentation] Verify test error log entries.
223 ${elog_entry}= Get URL List ${BMC_LOGGING_ENTRY}
224 ${entry_id}= Read Attribute ${elog_entry[0]} Message
225 Should Be Equal ${entry_id}
226 ... example.xyz.openbmc_project.Example.Elog.AutoTestSimple
Sivas SRR21c2ef22018-04-18 11:01:38 -0500227 ... msg=Error log not from AutoTestSimple.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500228 ${entry_id}= Read Attribute ${elog_entry[0]} Severity
229 Should Be Equal ${entry_id}
230 ... xyz.openbmc_project.Logging.Entry.Level.Error
Sivas SRR21c2ef22018-04-18 11:01:38 -0500231 ... msg=Error log severity mismatch.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500232
233Delete Error Logs And Verify
234 [Documentation] Delete all error logs and verify.
235 Delete All Error Logs
Steven Sombara8800da2018-12-18 16:19:05 -0600236 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}list quiet=${1}
Sivas SRRcf6714f2018-03-26 10:51:29 -0500237 Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND}
Sivas SRR21c2ef22018-04-18 11:01:38 -0500238 ... msg=Error logs not deleted as expected.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500239
240
241Install Tarball
242 [Documentation] Install tarball on BMC.
Sivas SRRf27afbe2018-05-26 06:45:23 -0500243 Should Not Be Empty ${DEBUG_TARBALL_PATH}
244 ... msg=Debug tarball path value is required.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500245 BMC Execute Command rm -rf /tmp/tarball
246 Install Debug Tarball On BMC ${DEBUG_TARBALL_PATH}
George Keishing87e2a852019-05-29 12:30:14 -0500247
248
249Get Event Logs
250 [Documentation] Get all available EventLog entries.
251
252 #{
253 # "@odata.context": "/redfish/v1/$metadata#LogEntryCollection.LogEntryCollection",
254 # "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries",
255 # "@odata.type": "#LogEntryCollection.LogEntryCollection",
256 # "Description": "Collection of System Event Log Entries",
257 # "Members": [
258 # {
259 # "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
260 # "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1",
261 # "@odata.type": "#LogEntry.v1_4_0.LogEntry",
262 # "Created": "2019-05-29T13:19:27+00:00",
263 # "EntryType": "Event",
264 # "Id": "1",
265 # "Message": "org.open_power.Host.Error.Event",
266 # "Name": "System DBus Event Log Entry",
267 # "Severity": "Critical"
268 # }
269 # ],
270 # "Members@odata.count": 1,
271 # "Name": "System Event Log Entries"
272 #}
273
George Keishing32f6df62019-05-29 13:58:12 -0500274 ${members}= Redfish.Get Attribute ${EVENT_LOG_URI}Entries Members
George Keishing87e2a852019-05-29 12:30:14 -0500275 [Return] ${members}
George Keishing32f6df62019-05-29 13:58:12 -0500276
277
George Keishing438fd3b2021-10-08 02:15:18 -0500278Get Redfish Event Logs
279 [Documentation] Pack the list of all available EventLog entries in dictionary.
George Keishinga6c00892021-10-11 01:09:54 -0500280 [Arguments] ${quiet}=1 &{filter_struct_args}
281
282 # Description of argument(s):
283 # quiet Indicates whether this keyword should run without any output to the
284 # console, 0 = verbose, 1 = quiet.
285 # filter_struct_args filter_struct args (e.g. filter_dict, regex, etc.) to be passed
286 # directly to the Filter Struct keyword. See its prolog for details.
George Keishing438fd3b2021-10-08 02:15:18 -0500287
288 ${packed_dict}= Create Dictionary
289 ${error_logs}= Get Event Logs
290
George Keishing1769aa92021-10-19 10:44:47 -0500291 FOR ${idx} IN @{error_logs}
George Keishing438fd3b2021-10-08 02:15:18 -0500292 Set To Dictionary ${packed_dict} ${idx['@odata.id']}=${idx}
293 END
294
George Keishinga6c00892021-10-11 01:09:54 -0500295 ${num_filter_struct_args}= Get Length ${filter_struct_args}
296 Return From Keyword If '${num_filter_struct_args}' == '${0}' &{packed_dict}
297 ${filtered_error_logs}= Filter Struct ${packed_dict} &{filter_struct_args}
298
299 [Return] ${filtered_error_logs}
George Keishing438fd3b2021-10-08 02:15:18 -0500300
301
Joy Onyerikwud806cc02019-10-01 07:46:18 -0500302Get Event Logs Not Ok
303 [Documentation] Get all event logs where the 'Severity' is not 'OK'.
304
305 ${members}= Get Event Logs
306 ${severe_logs}= Evaluate [elog for elog in $members if elog['Severity'] != 'OK']
307 [Return] ${severe_logs}
308
309
Steven Sombar3468df52019-06-29 11:01:47 -0500310Get Number Of Event Logs
311 [Documentation] Return the number of EventLog members.
312
313 ${members}= Get Event Logs
314 ${num_members}= Get Length ${members}
315 [Return] ${num_members}
316
317
George Keishing32f6df62019-05-29 13:58:12 -0500318Redfish Purge Event Log
319 [Documentation] Do Redfish EventLog purge.
320
Sushil Singheda8bff2019-12-05 00:47:13 -0600321 ${target_action}= redfish_utils.Get Target Actions
Yi Huc32434a2024-01-11 17:33:10 -0800322 ... /redfish/v1/Systems/${SYSTEM_ID}/LogServices/EventLog/ LogService.ClearLog
Sushil Singheda8bff2019-12-05 00:47:13 -0600323 Redfish.Post ${target_action} body={'target': '${target_action}'}
324 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
325
Tim Lee26393aa2022-04-15 11:00:37 +0800326
327Event Log Should Not Exist
328 [Documentation] Event log entries should not exist.
329
330 ${elogs}= Get Event Logs
331 Should Be Empty ${elogs} msg=System event log entry is not empty.
George Keishingcdfea1d2022-08-05 10:42:39 -0500332
333
334Redfish Clear PostCodes
335 [Documentation] Do Redfish PostCodes purge from system.
336
337 ${target_action}= redfish_utils.Get Target Actions
Yi Huc32434a2024-01-11 17:33:10 -0800338 ... /redfish/v1/Systems/${SYSTEM_ID}/LogServices/PostCodes/ LogService.ClearLog
George Keishingcdfea1d2022-08-05 10:42:39 -0500339 Redfish.Post ${target_action} body={'target': '${target_action}'}
340 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
341
342
343Redfish Get PostCodes
344 [Documentation] Perform Redfish GET request and return the PostCodes entries as a list of dictionaries.
345
346 # Formatted example output from Rprint vars members
347 # members:
348 # [0]:
349 # [@odata.id]: /redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-1
350 # [@odata.type]: #LogEntry.v1_8_0.LogEntry
351 # [AdditionalDataURI]: /redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-1/attachment
352 # [Created]: 2022-08-06T04:38:10+00:00
353 # [EntryType]: Event
354 # [Id]: B1-1
355 # [Message]: Message": "Boot Count: 4: TS Offset: 0.0033; POST Code: 0x43
356 # [MessageArgs]:
357 # [0]: 4
358 # [1]: 0.0033
359 # [2]: 0x43
360 # [MessageId]: OpenBMC.0.2.BIOSPOSTCodeASCII
361 # [Name]: POST Code Log Entry
362 # [Severity]: OK
363
Yi Huc32434a2024-01-11 17:33:10 -0800364 ${members}= Redfish.Get Attribute /redfish/v1/Systems/${SYSTEM_ID}/LogServices/PostCodes/Entries Members
George Keishingcdfea1d2022-08-05 10:42:39 -0500365 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
366
367 [Return] ${members}