blob: b2bb56c8bf8023ecc019a162e483d3ee70525581 [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 Keishinga6c00892021-10-11 01:09:54 -050013${low_severity_errlog_regex} \\.(Informational|Notice|Debug|OK)$
Michael Walshdb1adf42020-03-20 15:05:46 -050014&{low_severity_errlog_filter} Severity=${low_severity_errlog_regex}
15&{low_severity_errlog_filter_args} filter_dict=${low_severity_errlog_filter} regex=${True} invert=${True}
16# The following is equivalent to &{low_severity_errlog_filter_args} but the name may be more intuitive for
17# users. Example usage:
18# ${err_logs}= Get Error Logs &{filter_low_severity_errlogs}
19&{filter_low_severity_errlogs} &{low_severity_errlog_filter_args}
20
George Keishingc37fca62017-11-24 05:07:32 -060021*** Keywords ***
22
George Keishingba746442023-03-07 11:51:39 +053023Filter Expected Logging Events
24 [Documentation] Get redfish logging entry, remove the user input expected
25 ... log event and return the object list.
26 [Arguments] ${expected_event}=None
27
28 # Description of argument(s):
29 # expected_eventd Event log list.
30
31 ${all_event_list}= Get Redfish Event Logs
32 Remove Values From List ${all_event_list} ${expected_event}
33
34 [Return] ${all_event_list}
35
36
George Keishingc37fca62017-11-24 05:07:32 -060037Get Logging Entry List
38 [Documentation] Get logging entry and return the object list.
39
40 ${entry_list}= Create List
41 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}list quiet=${1}
42 Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND}
George Keishingc37fca62017-11-24 05:07:32 -060043
George Keishingfbd67002022-08-01 11:24:03 -050044 FOR ${entry} IN @{resp.json()["data"]}
Marissa Garza20ccfc72020-06-19 12:51:10 -050045 Continue For Loop If '${entry.rsplit('/', 1)[1]}' == 'callout'
46 Append To List ${entry_list} ${entry}
47 END
George Keishingc37fca62017-11-24 05:07:32 -060048
49 # Logging entries list.
50 # ['/xyz/openbmc_project/logging/entry/14',
51 # '/xyz/openbmc_project/logging/entry/15']
52 [Return] ${entry_list}
53
54
55Logging Entry Should Exist
56 [Documentation] Find the matching message id and return the entry id.
57 [Arguments] ${message_id}
58
59 # Description of argument(s):
60 # message_id Logging message string.
61 # Example: "xyz.openbmc_project.Common.Error.InternalFailure"
62
George Keishing5ac6e172018-04-09 12:44:15 -050063 @{elog_entries}= Get Logging Entry List
George Keishingc37fca62017-11-24 05:07:32 -060064
Marissa Garza20ccfc72020-06-19 12:51:10 -050065 FOR ${entry} IN @{elog_entries}
66 ${resp}= Read Properties ${entry}
67 ${status}= Run Keyword And Return Status
68 ... Should Be Equal As Strings ${message_id} ${resp["Message"]}
69 Return From Keyword If ${status} == ${TRUE} ${entry}
70 END
George Keishingc37fca62017-11-24 05:07:32 -060071
72 Fail No ${message_id} logging entry found.
73
Steven Sombar95672942018-03-23 11:24:58 -050074
75Get Error Logs
Michael Walshdb1adf42020-03-20 15:05:46 -050076 [Documentation] Return the BMC error logs as a dictionary.
77 [Arguments] ${quiet}=1 &{filter_struct_args}
78
79 # Example of call using pre-defined filter args (defined above).
80
81 # ${err_logs}= Get Error Logs &{filter_low_severity_errlogs}
82
83 # In this example, all error logs with "Severity" fields that are neither Informational, Debug nor
84 # Notice will be returned.
Steven Sombar95672942018-03-23 11:24:58 -050085
86 # Description of argument(s):
Michael Walshdb1adf42020-03-20 15:05:46 -050087 # quiet Indicates whether this keyword should run without any output to the
88 # console, 0 = verbose, 1 = quiet.
89 # filter_struct_args filter_struct args (e.g. filter_dict, regex, etc.) to be passed directly
90 # to the Filter Struct keyword. See its prolog for details.
Steven Sombar95672942018-03-23 11:24:58 -050091
92 # The length of the returned dictionary indicates how many logs there are.
Michael Walshdb1adf42020-03-20 15:05:46 -050093
94 # Use 'Print Error Logs' to print. Example:
95
96 # Print Error Logs ${error_logs} Message.
Steven Sombar95672942018-03-23 11:24:58 -050097
98 ${status} ${error_logs}= Run Keyword And Ignore Error Read Properties
Michael Walshdb1adf42020-03-20 15:05:46 -050099 ... /xyz/openbmc_project/logging/entry/enumerate timeout=30 quiet=${quiet}
100 Return From Keyword If '${status}' == 'FAIL' &{EMPTY}
101 ${num_filter_struct_args}= Get Length ${filter_struct_args}
102 Return From Keyword If '${num_filter_struct_args}' == '${0}' ${error_logs}
103 ${filtered_error_logs}= Filter Struct ${error_logs} &{filter_struct_args}
104 [Return] ${filtered_error_logs}
Sivas SRRcf6714f2018-03-26 10:51:29 -0500105
106
107Get IPMI SEL Setting
108 [Documentation] Returns status for given IPMI SEL setting.
109 [Arguments] ${setting}
110 # Description of argument(s):
111 # setting SEL setting which needs to be read(e.g. "Last Add Time").
112
113 ${resp}= Run IPMI Standard Command sel info
114
115 ${setting_line}= Get Lines Containing String ${resp} ${setting}
116 ... case-insensitive
117 ${setting_status}= Fetch From Right ${setting_line} :${SPACE}
118
119 [Return] ${setting_status}
120
121
122Verify Watchdog Errorlog Content
123 [Documentation] Verify watchdog errorlog content.
124 # Example:
125 # "/xyz/openbmc_project/logging/entry/1":
126 # {
127 # "AdditionalData": [],
128 # "Id": 1,
129 # "Message": "org.open_power.Host.Boot.Error.WatchdogTimedOut",
130 # "Resolved": 0,
131 # "Severity": "xyz.openbmc_project.Logging.Entry.Level.Error",
132 # "Timestamp": 1492715244828,
George Keishing58520d02020-02-24 10:55:32 -0600133 # "Associations": []
Sivas SRRcf6714f2018-03-26 10:51:29 -0500134 # },
135
136 ${elog_entry}= Get URL List ${BMC_LOGGING_ENTRY}
137 ${elog}= Read Properties ${elog_entry[0]}
138 Should Be Equal As Strings
139 ... ${elog["Message"]} org.open_power.Host.Boot.Error.WatchdogTimedOut
Sivas SRR21c2ef22018-04-18 11:01:38 -0500140 ... msg=Watchdog timeout error log was not found.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500141 Should Be Equal As Strings
142 ... ${elog["Severity"]} xyz.openbmc_project.Logging.Entry.Level.Error
Sivas SRR21c2ef22018-04-18 11:01:38 -0500143 ... msg=Watchdog timeout severity unexpected value.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500144
145
146Logging Test Binary Exist
147 [Documentation] Verify existence of prerequisite logging-test.
George Keishing5f0c1fa2022-08-05 13:30:16 -0500148 ${stdout} ${stderr} ${rc}=
149 ... BMC Execute Command test -f /tmp/tarball/bin/logging-test print_out=1
Sivas SRR21c2ef22018-04-18 11:01:38 -0500150 Should Be Empty ${stderr} msg=Logging Test stderr is non-empty.
George Keishing5f0c1fa2022-08-05 13:30:16 -0500151
Sivas SRRcf6714f2018-03-26 10:51:29 -0500152
153Clear Existing Error Logs
154 [Documentation] If error log isn't empty, reboot the BMC to clear the log.
155 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}${1}
156 Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND}
157 Initiate BMC Reboot
158 Wait Until Keyword Succeeds 10 min 10 sec
159 ... Is BMC Ready
160 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}${1}
161 Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND}
Sivas SRR21c2ef22018-04-18 11:01:38 -0500162 ... msg=Could not clear BMC error logs.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500163
Rahul Maheshwarib8580dd2021-05-10 00:57:33 -0500164
165Create Test PEL Log
166 [Documentation] Generate test PEL log.
Rahul Maheshwari55e23462022-02-16 23:19:35 -0600167 [Arguments] ${pel_type}=Unrecoverable Error
Rahul Maheshwarib8580dd2021-05-10 00:57:33 -0500168
169 # Description of argument(s):
170 # pel_type The PEL type (e.g. Internal Failure, FRU Callout, Procedural Callout).
171
172 # Test PEL log entry example:
173 # {
174 # "0x5000002D": {
175 # "SRC": "BD8D1002",
176 # "Message": "An application had an internal failure",
177 # "PLID": "0x5000002D",
178 # "CreatorID": "BMC",
179 # "Subsystem": "BMC Firmware",
180 # "Commit Time": "02/25/2020 04:47:09",
181 # "Sev": "Unrecoverable Error",
182 # "CompID": "0x1000"
183 # }
184 # }
185
186 Run Keyword If '${pel_type}' == 'Internal Failure'
187 ... BMC Execute Command ${CMD_INTERNAL_FAILURE}
188 ... ELSE IF '${pel_type}' == 'FRU Callout'
189 ... BMC Execute Command ${CMD_FRU_CALLOUT}
190 ... ELSE IF '${pel_type}' == 'Procedure And Symbolic FRU Callout'
191 ... BMC Execute Command ${CMD_PROCEDURAL_SYMBOLIC_FRU_CALLOUT}
Rahul Maheshwari55e23462022-02-16 23:19:35 -0600192 ... ELSE IF '${pel_type}' == 'Unrecoverable Error'
193 ... BMC Execute Command ${CMD_UNRECOVERABLE_ERROR}
Rahul Maheshwarib8580dd2021-05-10 00:57:33 -0500194
195
Sivas SRRcf6714f2018-03-26 10:51:29 -0500196Create Test Error Log
197 [Documentation] Generate test error log.
198 # Test error log entry example:
199 # "/xyz/openbmc_project/logging/entry/1": {
200 # "AdditionalData": [
201 # "STRING=FOO"
202 # ],
203 # "Id": 1,
204 # "Message": "example.xyz.openbmc_project.Example.Elog.AutoTestSimple",
205 # "Severity": "xyz.openbmc_project.Logging.Entry.Level.Error",
206 # "Timestamp": 1487743963328,
George Keishing58520d02020-02-24 10:55:32 -0600207 # "Associations": []
Sivas SRRcf6714f2018-03-26 10:51:29 -0500208 # }
Joy Onyerikwu9b668972018-05-22 19:10:43 -0500209 BMC Execute Command /tmp/tarball/bin/logging-test -c AutoTestSimple
Sivas SRRcf6714f2018-03-26 10:51:29 -0500210
211Count Error Entries
212 [Documentation] Count Error entries.
213 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}
214 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
Sivas SRR21c2ef22018-04-18 11:01:38 -0500215 ... msg=Failed to get error logs.
George Keishingfbd67002022-08-01 11:24:03 -0500216 ${count}= Get Length ${resp.json()["data"]}
Sivas SRRcf6714f2018-03-26 10:51:29 -0500217 [Return] ${count}
218
219Verify Test Error Log
220 [Documentation] Verify test error log entries.
221 ${elog_entry}= Get URL List ${BMC_LOGGING_ENTRY}
222 ${entry_id}= Read Attribute ${elog_entry[0]} Message
223 Should Be Equal ${entry_id}
224 ... example.xyz.openbmc_project.Example.Elog.AutoTestSimple
Sivas SRR21c2ef22018-04-18 11:01:38 -0500225 ... msg=Error log not from AutoTestSimple.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500226 ${entry_id}= Read Attribute ${elog_entry[0]} Severity
227 Should Be Equal ${entry_id}
228 ... xyz.openbmc_project.Logging.Entry.Level.Error
Sivas SRR21c2ef22018-04-18 11:01:38 -0500229 ... msg=Error log severity mismatch.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500230
231Delete Error Logs And Verify
232 [Documentation] Delete all error logs and verify.
233 Delete All Error Logs
Steven Sombara8800da2018-12-18 16:19:05 -0600234 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}list quiet=${1}
Sivas SRRcf6714f2018-03-26 10:51:29 -0500235 Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND}
Sivas SRR21c2ef22018-04-18 11:01:38 -0500236 ... msg=Error logs not deleted as expected.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500237
238
239Install Tarball
240 [Documentation] Install tarball on BMC.
Sivas SRRf27afbe2018-05-26 06:45:23 -0500241 Should Not Be Empty ${DEBUG_TARBALL_PATH}
242 ... msg=Debug tarball path value is required.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500243 BMC Execute Command rm -rf /tmp/tarball
244 Install Debug Tarball On BMC ${DEBUG_TARBALL_PATH}
George Keishing87e2a852019-05-29 12:30:14 -0500245
246
247Get Event Logs
248 [Documentation] Get all available EventLog entries.
249
250 #{
251 # "@odata.context": "/redfish/v1/$metadata#LogEntryCollection.LogEntryCollection",
252 # "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries",
253 # "@odata.type": "#LogEntryCollection.LogEntryCollection",
254 # "Description": "Collection of System Event Log Entries",
255 # "Members": [
256 # {
257 # "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
258 # "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1",
259 # "@odata.type": "#LogEntry.v1_4_0.LogEntry",
260 # "Created": "2019-05-29T13:19:27+00:00",
261 # "EntryType": "Event",
262 # "Id": "1",
263 # "Message": "org.open_power.Host.Error.Event",
264 # "Name": "System DBus Event Log Entry",
265 # "Severity": "Critical"
266 # }
267 # ],
268 # "Members@odata.count": 1,
269 # "Name": "System Event Log Entries"
270 #}
271
George Keishing32f6df62019-05-29 13:58:12 -0500272 ${members}= Redfish.Get Attribute ${EVENT_LOG_URI}Entries Members
George Keishing87e2a852019-05-29 12:30:14 -0500273 [Return] ${members}
George Keishing32f6df62019-05-29 13:58:12 -0500274
275
George Keishing438fd3b2021-10-08 02:15:18 -0500276Get Redfish Event Logs
277 [Documentation] Pack the list of all available EventLog entries in dictionary.
George Keishinga6c00892021-10-11 01:09:54 -0500278 [Arguments] ${quiet}=1 &{filter_struct_args}
279
280 # Description of argument(s):
281 # quiet Indicates whether this keyword should run without any output to the
282 # console, 0 = verbose, 1 = quiet.
283 # filter_struct_args filter_struct args (e.g. filter_dict, regex, etc.) to be passed
284 # directly to the Filter Struct keyword. See its prolog for details.
George Keishing438fd3b2021-10-08 02:15:18 -0500285
286 ${packed_dict}= Create Dictionary
287 ${error_logs}= Get Event Logs
288
George Keishing1769aa92021-10-19 10:44:47 -0500289 FOR ${idx} IN @{error_logs}
George Keishing438fd3b2021-10-08 02:15:18 -0500290 Set To Dictionary ${packed_dict} ${idx['@odata.id']}=${idx}
291 END
292
George Keishinga6c00892021-10-11 01:09:54 -0500293 ${num_filter_struct_args}= Get Length ${filter_struct_args}
294 Return From Keyword If '${num_filter_struct_args}' == '${0}' &{packed_dict}
295 ${filtered_error_logs}= Filter Struct ${packed_dict} &{filter_struct_args}
296
297 [Return] ${filtered_error_logs}
George Keishing438fd3b2021-10-08 02:15:18 -0500298
299
Joy Onyerikwud806cc02019-10-01 07:46:18 -0500300Get Event Logs Not Ok
301 [Documentation] Get all event logs where the 'Severity' is not 'OK'.
302
303 ${members}= Get Event Logs
304 ${severe_logs}= Evaluate [elog for elog in $members if elog['Severity'] != 'OK']
305 [Return] ${severe_logs}
306
307
Steven Sombar3468df52019-06-29 11:01:47 -0500308Get Number Of Event Logs
309 [Documentation] Return the number of EventLog members.
310
311 ${members}= Get Event Logs
312 ${num_members}= Get Length ${members}
313 [Return] ${num_members}
314
315
George Keishing32f6df62019-05-29 13:58:12 -0500316Redfish Purge Event Log
317 [Documentation] Do Redfish EventLog purge.
318
Sushil Singheda8bff2019-12-05 00:47:13 -0600319 ${target_action}= redfish_utils.Get Target Actions
320 ... /redfish/v1/Systems/system/LogServices/EventLog/ LogService.ClearLog
321 Redfish.Post ${target_action} body={'target': '${target_action}'}
322 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
323
Tim Lee26393aa2022-04-15 11:00:37 +0800324
325Event Log Should Not Exist
326 [Documentation] Event log entries should not exist.
327
328 ${elogs}= Get Event Logs
329 Should Be Empty ${elogs} msg=System event log entry is not empty.
George Keishingcdfea1d2022-08-05 10:42:39 -0500330
331
332Redfish Clear PostCodes
333 [Documentation] Do Redfish PostCodes purge from system.
334
335 ${target_action}= redfish_utils.Get Target Actions
336 ... /redfish/v1/Systems/system/LogServices/PostCodes/ LogService.ClearLog
337 Redfish.Post ${target_action} body={'target': '${target_action}'}
338 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
339
340
341Redfish Get PostCodes
342 [Documentation] Perform Redfish GET request and return the PostCodes entries as a list of dictionaries.
343
344 # Formatted example output from Rprint vars members
345 # members:
346 # [0]:
347 # [@odata.id]: /redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-1
348 # [@odata.type]: #LogEntry.v1_8_0.LogEntry
349 # [AdditionalDataURI]: /redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-1/attachment
350 # [Created]: 2022-08-06T04:38:10+00:00
351 # [EntryType]: Event
352 # [Id]: B1-1
353 # [Message]: Message": "Boot Count: 4: TS Offset: 0.0033; POST Code: 0x43
354 # [MessageArgs]:
355 # [0]: 4
356 # [1]: 0.0033
357 # [2]: 0x43
358 # [MessageId]: OpenBMC.0.2.BIOSPOSTCodeASCII
359 # [Name]: POST Code Log Entry
360 # [Severity]: OK
361
362 ${members}= Redfish.Get Attribute /redfish/v1/Systems/system/LogServices/PostCodes/Entries Members
363 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
364
365 [Return] ${members}