1*** Settings *** 2Documentation Error logging utility keywords. 3 4Resource rest_client.robot 5Resource bmc_redfish_utils.robot 6Variables ../data/variables.py 7Variables ../data/pel_variables.py 8 9*** Variables *** 10 11 12# Define variables for use by callers of 'Get Error Logs'. 13${low_severity_errlog_regex} \\.(Informational|Notice|Debug|OK)$ 14&{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 21*** Keywords *** 22 23Get Logging Entry List 24 [Documentation] Get logging entry and return the object list. 25 26 ${entry_list}= Create List 27 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}list quiet=${1} 28 Return From Keyword If ${resp.status_code} == ${HTTP_NOT_FOUND} 29 30 FOR ${entry} IN @{resp.json()["data"]} 31 Continue For Loop If '${entry.rsplit('/', 1)[1]}' == 'callout' 32 Append To List ${entry_list} ${entry} 33 END 34 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 49 @{elog_entries}= Get Logging Entry List 50 51 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 57 58 Fail No ${message_id} logging entry found. 59 60 61Get Error Logs 62 [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. 71 72 # Description of argument(s): 73 # 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. 77 78 # The length of the returned dictionary indicates how many logs there are. 79 80 # Use 'Print Error Logs' to print. Example: 81 82 # Print Error Logs ${error_logs} Message. 83 84 ${status} ${error_logs}= Run Keyword And Ignore Error Read Properties 85 ... /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} 91 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, 119 # "Associations": [] 120 # }, 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 126 ... msg=Watchdog timeout error log was not found. 127 Should Be Equal As Strings 128 ... ${elog["Severity"]} xyz.openbmc_project.Logging.Entry.Level.Error 129 ... msg=Watchdog timeout severity unexpected value. 130 131 132Logging Test Binary Exist 133 [Documentation] Verify existence of prerequisite logging-test. 134 ${stdout} ${stderr} ${rc}= 135 ... BMC Execute Command test -f /tmp/tarball/bin/logging-test print_out=1 136 Should Be Empty ${stderr} msg=Logging Test stderr is non-empty. 137 138 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} 148 ... msg=Could not clear BMC error logs. 149 150 151Create Test PEL Log 152 [Documentation] Generate test PEL log. 153 [Arguments] ${pel_type}=Unrecoverable Error 154 155 # Description of argument(s): 156 # pel_type The PEL type (e.g. Internal Failure, FRU Callout, Procedural Callout). 157 158 # Test PEL log entry example: 159 # { 160 # "0x5000002D": { 161 # "SRC": "BD8D1002", 162 # "Message": "An application had an internal failure", 163 # "PLID": "0x5000002D", 164 # "CreatorID": "BMC", 165 # "Subsystem": "BMC Firmware", 166 # "Commit Time": "02/25/2020 04:47:09", 167 # "Sev": "Unrecoverable Error", 168 # "CompID": "0x1000" 169 # } 170 # } 171 172 Run Keyword If '${pel_type}' == 'Internal Failure' 173 ... BMC Execute Command ${CMD_INTERNAL_FAILURE} 174 ... ELSE IF '${pel_type}' == 'FRU Callout' 175 ... BMC Execute Command ${CMD_FRU_CALLOUT} 176 ... ELSE IF '${pel_type}' == 'Procedure And Symbolic FRU Callout' 177 ... BMC Execute Command ${CMD_PROCEDURAL_SYMBOLIC_FRU_CALLOUT} 178 ... ELSE IF '${pel_type}' == 'Unrecoverable Error' 179 ... BMC Execute Command ${CMD_UNRECOVERABLE_ERROR} 180 181 182Create Test Error Log 183 [Documentation] Generate test error log. 184 # Test error log entry example: 185 # "/xyz/openbmc_project/logging/entry/1": { 186 # "AdditionalData": [ 187 # "STRING=FOO" 188 # ], 189 # "Id": 1, 190 # "Message": "example.xyz.openbmc_project.Example.Elog.AutoTestSimple", 191 # "Severity": "xyz.openbmc_project.Logging.Entry.Level.Error", 192 # "Timestamp": 1487743963328, 193 # "Associations": [] 194 # } 195 BMC Execute Command /tmp/tarball/bin/logging-test -c AutoTestSimple 196 197Count Error Entries 198 [Documentation] Count Error entries. 199 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY} 200 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} 201 ... msg=Failed to get error logs. 202 ${count}= Get Length ${resp.json()["data"]} 203 [Return] ${count} 204 205Verify Test Error Log 206 [Documentation] Verify test error log entries. 207 ${elog_entry}= Get URL List ${BMC_LOGGING_ENTRY} 208 ${entry_id}= Read Attribute ${elog_entry[0]} Message 209 Should Be Equal ${entry_id} 210 ... example.xyz.openbmc_project.Example.Elog.AutoTestSimple 211 ... msg=Error log not from AutoTestSimple. 212 ${entry_id}= Read Attribute ${elog_entry[0]} Severity 213 Should Be Equal ${entry_id} 214 ... xyz.openbmc_project.Logging.Entry.Level.Error 215 ... msg=Error log severity mismatch. 216 217Delete Error Logs And Verify 218 [Documentation] Delete all error logs and verify. 219 Delete All Error Logs 220 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}list quiet=${1} 221 Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND} 222 ... msg=Error logs not deleted as expected. 223 224 225Install Tarball 226 [Documentation] Install tarball on BMC. 227 Should Not Be Empty ${DEBUG_TARBALL_PATH} 228 ... msg=Debug tarball path value is required. 229 BMC Execute Command rm -rf /tmp/tarball 230 Install Debug Tarball On BMC ${DEBUG_TARBALL_PATH} 231 232 233Get Event Logs 234 [Documentation] Get all available EventLog entries. 235 236 #{ 237 # "@odata.context": "/redfish/v1/$metadata#LogEntryCollection.LogEntryCollection", 238 # "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries", 239 # "@odata.type": "#LogEntryCollection.LogEntryCollection", 240 # "Description": "Collection of System Event Log Entries", 241 # "Members": [ 242 # { 243 # "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry", 244 # "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1", 245 # "@odata.type": "#LogEntry.v1_4_0.LogEntry", 246 # "Created": "2019-05-29T13:19:27+00:00", 247 # "EntryType": "Event", 248 # "Id": "1", 249 # "Message": "org.open_power.Host.Error.Event", 250 # "Name": "System DBus Event Log Entry", 251 # "Severity": "Critical" 252 # } 253 # ], 254 # "Members@odata.count": 1, 255 # "Name": "System Event Log Entries" 256 #} 257 258 ${members}= Redfish.Get Attribute ${EVENT_LOG_URI}Entries Members 259 [Return] ${members} 260 261 262Get Redfish Event Logs 263 [Documentation] Pack the list of all available EventLog entries in dictionary. 264 [Arguments] ${quiet}=1 &{filter_struct_args} 265 266 # Description of argument(s): 267 # quiet Indicates whether this keyword should run without any output to the 268 # console, 0 = verbose, 1 = quiet. 269 # filter_struct_args filter_struct args (e.g. filter_dict, regex, etc.) to be passed 270 # directly to the Filter Struct keyword. See its prolog for details. 271 272 ${packed_dict}= Create Dictionary 273 ${error_logs}= Get Event Logs 274 275 FOR ${idx} IN @{error_logs} 276 Set To Dictionary ${packed_dict} ${idx['@odata.id']}=${idx} 277 END 278 279 ${num_filter_struct_args}= Get Length ${filter_struct_args} 280 Return From Keyword If '${num_filter_struct_args}' == '${0}' &{packed_dict} 281 ${filtered_error_logs}= Filter Struct ${packed_dict} &{filter_struct_args} 282 283 [Return] ${filtered_error_logs} 284 285 286Get Event Logs Not Ok 287 [Documentation] Get all event logs where the 'Severity' is not 'OK'. 288 289 ${members}= Get Event Logs 290 ${severe_logs}= Evaluate [elog for elog in $members if elog['Severity'] != 'OK'] 291 [Return] ${severe_logs} 292 293 294Get Number Of Event Logs 295 [Documentation] Return the number of EventLog members. 296 297 ${members}= Get Event Logs 298 ${num_members}= Get Length ${members} 299 [Return] ${num_members} 300 301 302Redfish Purge Event Log 303 [Documentation] Do Redfish EventLog purge. 304 305 ${target_action}= redfish_utils.Get Target Actions 306 ... /redfish/v1/Systems/system/LogServices/EventLog/ LogService.ClearLog 307 Redfish.Post ${target_action} body={'target': '${target_action}'} 308 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 309 310 311Event Log Should Not Exist 312 [Documentation] Event log entries should not exist. 313 314 ${elogs}= Get Event Logs 315 Should Be Empty ${elogs} msg=System event log entry is not empty. 316 317 318Redfish Clear PostCodes 319 [Documentation] Do Redfish PostCodes purge from system. 320 321 ${target_action}= redfish_utils.Get Target Actions 322 ... /redfish/v1/Systems/system/LogServices/PostCodes/ LogService.ClearLog 323 Redfish.Post ${target_action} body={'target': '${target_action}'} 324 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 325 326 327Redfish Get PostCodes 328 [Documentation] Perform Redfish GET request and return the PostCodes entries as a list of dictionaries. 329 330 # Formatted example output from Rprint vars members 331 # members: 332 # [0]: 333 # [@odata.id]: /redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-1 334 # [@odata.type]: #LogEntry.v1_8_0.LogEntry 335 # [AdditionalDataURI]: /redfish/v1/Systems/system/LogServices/PostCodes/Entries/B1-1/attachment 336 # [Created]: 2022-08-06T04:38:10+00:00 337 # [EntryType]: Event 338 # [Id]: B1-1 339 # [Message]: Message": "Boot Count: 4: TS Offset: 0.0033; POST Code: 0x43 340 # [MessageArgs]: 341 # [0]: 4 342 # [1]: 0.0033 343 # [2]: 0x43 344 # [MessageId]: OpenBMC.0.2.BIOSPOSTCodeASCII 345 # [Name]: POST Code Log Entry 346 # [Severity]: OK 347 348 ${members}= Redfish.Get Attribute /redfish/v1/Systems/system/LogServices/PostCodes/Entries Members 349 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 350 351 [Return] ${members} 352