blob: 7c1fbea5a1449d704d88c2fc291517b5b52cb4e9 [file] [log] [blame]
George Keishingc37fca62017-11-24 05:07:32 -06001*** Settings ***
2Documentation Error logging utility keywords.
3
4Resource rest_client.robot
5Variables ../data/variables.py
6
Michael Walshdb1adf42020-03-20 15:05:46 -05007
8*** Variables ***
9
10
11# Define variables for use by callers of 'Get Error Logs'.
12${low_severity_errlog_regex} \\.(Informational|Notice|Debug)$
13&{low_severity_errlog_filter} Severity=${low_severity_errlog_regex}
14&{low_severity_errlog_filter_args} filter_dict=${low_severity_errlog_filter} regex=${True} invert=${True}
15# The following is equivalent to &{low_severity_errlog_filter_args} but the name may be more intuitive for
16# users. Example usage:
17# ${err_logs}= Get Error Logs &{filter_low_severity_errlogs}
18&{filter_low_severity_errlogs} &{low_severity_errlog_filter_args}
19
George Keishingc37fca62017-11-24 05:07:32 -060020*** Keywords ***
21
22Get Logging Entry List
23 [Documentation] Get logging entry and return the object list.
24
25 ${entry_list}= Create List
26 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}list quiet=${1}
27 Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND}
28 ${jsondata}= To JSON ${resp.content}
29
Marissa Garza20ccfc72020-06-19 12:51:10 -050030 FOR ${entry} IN @{jsondata["data"]}
31 Continue For Loop If '${entry.rsplit('/', 1)[1]}' == 'callout'
32 Append To List ${entry_list} ${entry}
33 END
George Keishingc37fca62017-11-24 05:07:32 -060034
35 # Logging entries list.
36 # ['/xyz/openbmc_project/logging/entry/14',
37 # '/xyz/openbmc_project/logging/entry/15']
38 [Return] ${entry_list}
39
40
41Logging Entry Should Exist
42 [Documentation] Find the matching message id and return the entry id.
43 [Arguments] ${message_id}
44
45 # Description of argument(s):
46 # message_id Logging message string.
47 # Example: "xyz.openbmc_project.Common.Error.InternalFailure"
48
George Keishing5ac6e172018-04-09 12:44:15 -050049 @{elog_entries}= Get Logging Entry List
George Keishingc37fca62017-11-24 05:07:32 -060050
Marissa Garza20ccfc72020-06-19 12:51:10 -050051 FOR ${entry} IN @{elog_entries}
52 ${resp}= Read Properties ${entry}
53 ${status}= Run Keyword And Return Status
54 ... Should Be Equal As Strings ${message_id} ${resp["Message"]}
55 Return From Keyword If ${status} == ${TRUE} ${entry}
56 END
George Keishingc37fca62017-11-24 05:07:32 -060057
58 Fail No ${message_id} logging entry found.
59
Steven Sombar95672942018-03-23 11:24:58 -050060
61Get Error Logs
Michael Walshdb1adf42020-03-20 15:05:46 -050062 [Documentation] Return the BMC error logs as a dictionary.
63 [Arguments] ${quiet}=1 &{filter_struct_args}
64
65 # Example of call using pre-defined filter args (defined above).
66
67 # ${err_logs}= Get Error Logs &{filter_low_severity_errlogs}
68
69 # In this example, all error logs with "Severity" fields that are neither Informational, Debug nor
70 # Notice will be returned.
Steven Sombar95672942018-03-23 11:24:58 -050071
72 # Description of argument(s):
Michael Walshdb1adf42020-03-20 15:05:46 -050073 # quiet Indicates whether this keyword should run without any output to the
74 # console, 0 = verbose, 1 = quiet.
75 # filter_struct_args filter_struct args (e.g. filter_dict, regex, etc.) to be passed directly
76 # to the Filter Struct keyword. See its prolog for details.
Steven Sombar95672942018-03-23 11:24:58 -050077
78 # The length of the returned dictionary indicates how many logs there are.
Michael Walshdb1adf42020-03-20 15:05:46 -050079
80 # Use 'Print Error Logs' to print. Example:
81
82 # Print Error Logs ${error_logs} Message.
Steven Sombar95672942018-03-23 11:24:58 -050083
84 ${status} ${error_logs}= Run Keyword And Ignore Error Read Properties
Michael Walshdb1adf42020-03-20 15:05:46 -050085 ... /xyz/openbmc_project/logging/entry/enumerate timeout=30 quiet=${quiet}
86 Return From Keyword If '${status}' == 'FAIL' &{EMPTY}
87 ${num_filter_struct_args}= Get Length ${filter_struct_args}
88 Return From Keyword If '${num_filter_struct_args}' == '${0}' ${error_logs}
89 ${filtered_error_logs}= Filter Struct ${error_logs} &{filter_struct_args}
90 [Return] ${filtered_error_logs}
Sivas SRRcf6714f2018-03-26 10:51:29 -050091
92
93Get IPMI SEL Setting
94 [Documentation] Returns status for given IPMI SEL setting.
95 [Arguments] ${setting}
96 # Description of argument(s):
97 # setting SEL setting which needs to be read(e.g. "Last Add Time").
98
99 ${resp}= Run IPMI Standard Command sel info
100
101 ${setting_line}= Get Lines Containing String ${resp} ${setting}
102 ... case-insensitive
103 ${setting_status}= Fetch From Right ${setting_line} :${SPACE}
104
105 [Return] ${setting_status}
106
107
108Verify Watchdog Errorlog Content
109 [Documentation] Verify watchdog errorlog content.
110 # Example:
111 # "/xyz/openbmc_project/logging/entry/1":
112 # {
113 # "AdditionalData": [],
114 # "Id": 1,
115 # "Message": "org.open_power.Host.Boot.Error.WatchdogTimedOut",
116 # "Resolved": 0,
117 # "Severity": "xyz.openbmc_project.Logging.Entry.Level.Error",
118 # "Timestamp": 1492715244828,
George Keishing58520d02020-02-24 10:55:32 -0600119 # "Associations": []
Sivas SRRcf6714f2018-03-26 10:51:29 -0500120 # },
121
122 ${elog_entry}= Get URL List ${BMC_LOGGING_ENTRY}
123 ${elog}= Read Properties ${elog_entry[0]}
124 Should Be Equal As Strings
125 ... ${elog["Message"]} org.open_power.Host.Boot.Error.WatchdogTimedOut
Sivas SRR21c2ef22018-04-18 11:01:38 -0500126 ... msg=Watchdog timeout error log was not found.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500127 Should Be Equal As Strings
128 ... ${elog["Severity"]} xyz.openbmc_project.Logging.Entry.Level.Error
Sivas SRR21c2ef22018-04-18 11:01:38 -0500129 ... msg=Watchdog timeout severity unexpected value.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500130
131
132Logging Test Binary Exist
133 [Documentation] Verify existence of prerequisite logging-test.
134 Open Connection And Log In
135 ${out} ${stderr}= Execute Command
136 ... which /tmp/tarball/bin/logging-test return_stderr=True
Sivas SRR21c2ef22018-04-18 11:01:38 -0500137 Should Be Empty ${stderr} msg=Logging Test stderr is non-empty.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500138 Should Contain ${out} logging-test
Sivas SRR21c2ef22018-04-18 11:01:38 -0500139 ... msg=Logging test returned unexpected result.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500140
141Clear Existing Error Logs
142 [Documentation] If error log isn't empty, reboot the BMC to clear the log.
143 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}${1}
144 Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND}
145 Initiate BMC Reboot
146 Wait Until Keyword Succeeds 10 min 10 sec
147 ... Is BMC Ready
148 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}${1}
149 Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND}
Sivas SRR21c2ef22018-04-18 11:01:38 -0500150 ... msg=Could not clear BMC error logs.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500151
152Create Test Error Log
153 [Documentation] Generate test error log.
154 # Test error log entry example:
155 # "/xyz/openbmc_project/logging/entry/1": {
156 # "AdditionalData": [
157 # "STRING=FOO"
158 # ],
159 # "Id": 1,
160 # "Message": "example.xyz.openbmc_project.Example.Elog.AutoTestSimple",
161 # "Severity": "xyz.openbmc_project.Logging.Entry.Level.Error",
162 # "Timestamp": 1487743963328,
George Keishing58520d02020-02-24 10:55:32 -0600163 # "Associations": []
Sivas SRRcf6714f2018-03-26 10:51:29 -0500164 # }
Joy Onyerikwu9b668972018-05-22 19:10:43 -0500165 BMC Execute Command /tmp/tarball/bin/logging-test -c AutoTestSimple
Sivas SRRcf6714f2018-03-26 10:51:29 -0500166
167Count Error Entries
168 [Documentation] Count Error entries.
169 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}
170 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
Sivas SRR21c2ef22018-04-18 11:01:38 -0500171 ... msg=Failed to get error logs.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500172 ${jsondata}= To JSON ${resp.content}
173 ${count}= Get Length ${jsondata["data"]}
174 [Return] ${count}
175
176Verify Test Error Log
177 [Documentation] Verify test error log entries.
178 ${elog_entry}= Get URL List ${BMC_LOGGING_ENTRY}
179 ${entry_id}= Read Attribute ${elog_entry[0]} Message
180 Should Be Equal ${entry_id}
181 ... example.xyz.openbmc_project.Example.Elog.AutoTestSimple
Sivas SRR21c2ef22018-04-18 11:01:38 -0500182 ... msg=Error log not from AutoTestSimple.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500183 ${entry_id}= Read Attribute ${elog_entry[0]} Severity
184 Should Be Equal ${entry_id}
185 ... xyz.openbmc_project.Logging.Entry.Level.Error
Sivas SRR21c2ef22018-04-18 11:01:38 -0500186 ... msg=Error log severity mismatch.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500187
188Delete Error Logs And Verify
189 [Documentation] Delete all error logs and verify.
190 Delete All Error Logs
Steven Sombara8800da2018-12-18 16:19:05 -0600191 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}list quiet=${1}
Sivas SRRcf6714f2018-03-26 10:51:29 -0500192 Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND}
Sivas SRR21c2ef22018-04-18 11:01:38 -0500193 ... msg=Error logs not deleted as expected.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500194
195
196Install Tarball
197 [Documentation] Install tarball on BMC.
Sivas SRRf27afbe2018-05-26 06:45:23 -0500198 Should Not Be Empty ${DEBUG_TARBALL_PATH}
199 ... msg=Debug tarball path value is required.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500200 BMC Execute Command rm -rf /tmp/tarball
201 Install Debug Tarball On BMC ${DEBUG_TARBALL_PATH}
George Keishing87e2a852019-05-29 12:30:14 -0500202
203
204Get Event Logs
205 [Documentation] Get all available EventLog entries.
206
207 #{
208 # "@odata.context": "/redfish/v1/$metadata#LogEntryCollection.LogEntryCollection",
209 # "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries",
210 # "@odata.type": "#LogEntryCollection.LogEntryCollection",
211 # "Description": "Collection of System Event Log Entries",
212 # "Members": [
213 # {
214 # "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
215 # "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1",
216 # "@odata.type": "#LogEntry.v1_4_0.LogEntry",
217 # "Created": "2019-05-29T13:19:27+00:00",
218 # "EntryType": "Event",
219 # "Id": "1",
220 # "Message": "org.open_power.Host.Error.Event",
221 # "Name": "System DBus Event Log Entry",
222 # "Severity": "Critical"
223 # }
224 # ],
225 # "Members@odata.count": 1,
226 # "Name": "System Event Log Entries"
227 #}
228
George Keishing32f6df62019-05-29 13:58:12 -0500229 ${members}= Redfish.Get Attribute ${EVENT_LOG_URI}Entries Members
George Keishing87e2a852019-05-29 12:30:14 -0500230 [Return] ${members}
George Keishing32f6df62019-05-29 13:58:12 -0500231
232
Joy Onyerikwud806cc02019-10-01 07:46:18 -0500233Get Event Logs Not Ok
234 [Documentation] Get all event logs where the 'Severity' is not 'OK'.
235
236 ${members}= Get Event Logs
237 ${severe_logs}= Evaluate [elog for elog in $members if elog['Severity'] != 'OK']
238 [Return] ${severe_logs}
239
240
Steven Sombar3468df52019-06-29 11:01:47 -0500241Get Number Of Event Logs
242 [Documentation] Return the number of EventLog members.
243
244 ${members}= Get Event Logs
245 ${num_members}= Get Length ${members}
246 [Return] ${num_members}
247
248
George Keishing32f6df62019-05-29 13:58:12 -0500249Redfish Purge Event Log
250 [Documentation] Do Redfish EventLog purge.
251
Sushil Singheda8bff2019-12-05 00:47:13 -0600252 ${target_action}= redfish_utils.Get Target Actions
253 ... /redfish/v1/Systems/system/LogServices/EventLog/ LogService.ClearLog
254 Redfish.Post ${target_action} body={'target': '${target_action}'}
255 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
256