blob: daecd5fc48728c44a826b8324423c71bf74a6519 [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
30 :FOR ${entry} IN @{jsondata["data"]}
31 \ Continue For Loop If '${entry.rsplit('/', 1)[1]}' == 'callout'
32 \ Append To List ${entry_list} ${entry}
33
34 # Logging entries list.
35 # ['/xyz/openbmc_project/logging/entry/14',
36 # '/xyz/openbmc_project/logging/entry/15']
37 [Return] ${entry_list}
38
39
40Logging Entry Should Exist
41 [Documentation] Find the matching message id and return the entry id.
42 [Arguments] ${message_id}
43
44 # Description of argument(s):
45 # message_id Logging message string.
46 # Example: "xyz.openbmc_project.Common.Error.InternalFailure"
47
George Keishing5ac6e172018-04-09 12:44:15 -050048 @{elog_entries}= Get Logging Entry List
George Keishingc37fca62017-11-24 05:07:32 -060049
50 :FOR ${entry} IN @{elog_entries}
51 \ ${resp}= Read Properties ${entry}
52 \ ${status}= Run Keyword And Return Status
53 ... Should Be Equal As Strings ${message_id} ${resp["Message"]}
54 \ Return From Keyword If ${status} == ${TRUE} ${entry}
55
56 Fail No ${message_id} logging entry found.
57
Steven Sombar95672942018-03-23 11:24:58 -050058
59Get Error Logs
Michael Walshdb1adf42020-03-20 15:05:46 -050060 [Documentation] Return the BMC error logs as a dictionary.
61 [Arguments] ${quiet}=1 &{filter_struct_args}
62
63 # Example of call using pre-defined filter args (defined above).
64
65 # ${err_logs}= Get Error Logs &{filter_low_severity_errlogs}
66
67 # In this example, all error logs with "Severity" fields that are neither Informational, Debug nor
68 # Notice will be returned.
Steven Sombar95672942018-03-23 11:24:58 -050069
70 # Description of argument(s):
Michael Walshdb1adf42020-03-20 15:05:46 -050071 # quiet Indicates whether this keyword should run without any output to the
72 # console, 0 = verbose, 1 = quiet.
73 # filter_struct_args filter_struct args (e.g. filter_dict, regex, etc.) to be passed directly
74 # to the Filter Struct keyword. See its prolog for details.
Steven Sombar95672942018-03-23 11:24:58 -050075
76 # The length of the returned dictionary indicates how many logs there are.
Michael Walshdb1adf42020-03-20 15:05:46 -050077
78 # Use 'Print Error Logs' to print. Example:
79
80 # Print Error Logs ${error_logs} Message.
Steven Sombar95672942018-03-23 11:24:58 -050081
82 ${status} ${error_logs}= Run Keyword And Ignore Error Read Properties
Michael Walshdb1adf42020-03-20 15:05:46 -050083 ... /xyz/openbmc_project/logging/entry/enumerate timeout=30 quiet=${quiet}
84 Return From Keyword If '${status}' == 'FAIL' &{EMPTY}
85 ${num_filter_struct_args}= Get Length ${filter_struct_args}
86 Return From Keyword If '${num_filter_struct_args}' == '${0}' ${error_logs}
87 ${filtered_error_logs}= Filter Struct ${error_logs} &{filter_struct_args}
88 [Return] ${filtered_error_logs}
Sivas SRRcf6714f2018-03-26 10:51:29 -050089
90
91Get IPMI SEL Setting
92 [Documentation] Returns status for given IPMI SEL setting.
93 [Arguments] ${setting}
94 # Description of argument(s):
95 # setting SEL setting which needs to be read(e.g. "Last Add Time").
96
97 ${resp}= Run IPMI Standard Command sel info
98
99 ${setting_line}= Get Lines Containing String ${resp} ${setting}
100 ... case-insensitive
101 ${setting_status}= Fetch From Right ${setting_line} :${SPACE}
102
103 [Return] ${setting_status}
104
105
106Verify Watchdog Errorlog Content
107 [Documentation] Verify watchdog errorlog content.
108 # Example:
109 # "/xyz/openbmc_project/logging/entry/1":
110 # {
111 # "AdditionalData": [],
112 # "Id": 1,
113 # "Message": "org.open_power.Host.Boot.Error.WatchdogTimedOut",
114 # "Resolved": 0,
115 # "Severity": "xyz.openbmc_project.Logging.Entry.Level.Error",
116 # "Timestamp": 1492715244828,
George Keishing58520d02020-02-24 10:55:32 -0600117 # "Associations": []
Sivas SRRcf6714f2018-03-26 10:51:29 -0500118 # },
119
120 ${elog_entry}= Get URL List ${BMC_LOGGING_ENTRY}
121 ${elog}= Read Properties ${elog_entry[0]}
122 Should Be Equal As Strings
123 ... ${elog["Message"]} org.open_power.Host.Boot.Error.WatchdogTimedOut
Sivas SRR21c2ef22018-04-18 11:01:38 -0500124 ... msg=Watchdog timeout error log was not found.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500125 Should Be Equal As Strings
126 ... ${elog["Severity"]} xyz.openbmc_project.Logging.Entry.Level.Error
Sivas SRR21c2ef22018-04-18 11:01:38 -0500127 ... msg=Watchdog timeout severity unexpected value.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500128
129
130Logging Test Binary Exist
131 [Documentation] Verify existence of prerequisite logging-test.
132 Open Connection And Log In
133 ${out} ${stderr}= Execute Command
134 ... which /tmp/tarball/bin/logging-test return_stderr=True
Sivas SRR21c2ef22018-04-18 11:01:38 -0500135 Should Be Empty ${stderr} msg=Logging Test stderr is non-empty.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500136 Should Contain ${out} logging-test
Sivas SRR21c2ef22018-04-18 11:01:38 -0500137 ... msg=Logging test returned unexpected result.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500138
139Clear Existing Error Logs
140 [Documentation] If error log isn't empty, reboot the BMC to clear the log.
141 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}${1}
142 Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND}
143 Initiate BMC Reboot
144 Wait Until Keyword Succeeds 10 min 10 sec
145 ... Is BMC Ready
146 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}${1}
147 Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND}
Sivas SRR21c2ef22018-04-18 11:01:38 -0500148 ... msg=Could not clear BMC error logs.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500149
150Create Test Error Log
151 [Documentation] Generate test error log.
152 # Test error log entry example:
153 # "/xyz/openbmc_project/logging/entry/1": {
154 # "AdditionalData": [
155 # "STRING=FOO"
156 # ],
157 # "Id": 1,
158 # "Message": "example.xyz.openbmc_project.Example.Elog.AutoTestSimple",
159 # "Severity": "xyz.openbmc_project.Logging.Entry.Level.Error",
160 # "Timestamp": 1487743963328,
George Keishing58520d02020-02-24 10:55:32 -0600161 # "Associations": []
Sivas SRRcf6714f2018-03-26 10:51:29 -0500162 # }
Joy Onyerikwu9b668972018-05-22 19:10:43 -0500163 BMC Execute Command /tmp/tarball/bin/logging-test -c AutoTestSimple
Sivas SRRcf6714f2018-03-26 10:51:29 -0500164
165Count Error Entries
166 [Documentation] Count Error entries.
167 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}
168 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
Sivas SRR21c2ef22018-04-18 11:01:38 -0500169 ... msg=Failed to get error logs.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500170 ${jsondata}= To JSON ${resp.content}
171 ${count}= Get Length ${jsondata["data"]}
172 [Return] ${count}
173
174Verify Test Error Log
175 [Documentation] Verify test error log entries.
176 ${elog_entry}= Get URL List ${BMC_LOGGING_ENTRY}
177 ${entry_id}= Read Attribute ${elog_entry[0]} Message
178 Should Be Equal ${entry_id}
179 ... example.xyz.openbmc_project.Example.Elog.AutoTestSimple
Sivas SRR21c2ef22018-04-18 11:01:38 -0500180 ... msg=Error log not from AutoTestSimple.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500181 ${entry_id}= Read Attribute ${elog_entry[0]} Severity
182 Should Be Equal ${entry_id}
183 ... xyz.openbmc_project.Logging.Entry.Level.Error
Sivas SRR21c2ef22018-04-18 11:01:38 -0500184 ... msg=Error log severity mismatch.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500185
186Delete Error Logs And Verify
187 [Documentation] Delete all error logs and verify.
188 Delete All Error Logs
Steven Sombara8800da2018-12-18 16:19:05 -0600189 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}list quiet=${1}
Sivas SRRcf6714f2018-03-26 10:51:29 -0500190 Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND}
Sivas SRR21c2ef22018-04-18 11:01:38 -0500191 ... msg=Error logs not deleted as expected.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500192
193
194Install Tarball
195 [Documentation] Install tarball on BMC.
Sivas SRRf27afbe2018-05-26 06:45:23 -0500196 Should Not Be Empty ${DEBUG_TARBALL_PATH}
197 ... msg=Debug tarball path value is required.
Sivas SRRcf6714f2018-03-26 10:51:29 -0500198 BMC Execute Command rm -rf /tmp/tarball
199 Install Debug Tarball On BMC ${DEBUG_TARBALL_PATH}
George Keishing87e2a852019-05-29 12:30:14 -0500200
201
202Get Event Logs
203 [Documentation] Get all available EventLog entries.
204
205 #{
206 # "@odata.context": "/redfish/v1/$metadata#LogEntryCollection.LogEntryCollection",
207 # "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries",
208 # "@odata.type": "#LogEntryCollection.LogEntryCollection",
209 # "Description": "Collection of System Event Log Entries",
210 # "Members": [
211 # {
212 # "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
213 # "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1",
214 # "@odata.type": "#LogEntry.v1_4_0.LogEntry",
215 # "Created": "2019-05-29T13:19:27+00:00",
216 # "EntryType": "Event",
217 # "Id": "1",
218 # "Message": "org.open_power.Host.Error.Event",
219 # "Name": "System DBus Event Log Entry",
220 # "Severity": "Critical"
221 # }
222 # ],
223 # "Members@odata.count": 1,
224 # "Name": "System Event Log Entries"
225 #}
226
George Keishing32f6df62019-05-29 13:58:12 -0500227 ${members}= Redfish.Get Attribute ${EVENT_LOG_URI}Entries Members
George Keishing87e2a852019-05-29 12:30:14 -0500228 [Return] ${members}
George Keishing32f6df62019-05-29 13:58:12 -0500229
230
Joy Onyerikwud806cc02019-10-01 07:46:18 -0500231Get Event Logs Not Ok
232 [Documentation] Get all event logs where the 'Severity' is not 'OK'.
233
234 ${members}= Get Event Logs
235 ${severe_logs}= Evaluate [elog for elog in $members if elog['Severity'] != 'OK']
236 [Return] ${severe_logs}
237
238
Steven Sombar3468df52019-06-29 11:01:47 -0500239Get Number Of Event Logs
240 [Documentation] Return the number of EventLog members.
241
242 ${members}= Get Event Logs
243 ${num_members}= Get Length ${members}
244 [Return] ${num_members}
245
246
George Keishing32f6df62019-05-29 13:58:12 -0500247Redfish Purge Event Log
248 [Documentation] Do Redfish EventLog purge.
249
Sushil Singheda8bff2019-12-05 00:47:13 -0600250 ${target_action}= redfish_utils.Get Target Actions
251 ... /redfish/v1/Systems/system/LogServices/EventLog/ LogService.ClearLog
252 Redfish.Post ${target_action} body={'target': '${target_action}'}
253 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
254