1*** Settings *** 2Documentation Error logging utility keywords. 3 4Resource rest_client.robot 5Variables ../data/variables.py 6 7 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 20*** 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 48 @{elog_entries}= Get Logging Entry List 49 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 58 59Get Error Logs 60 [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. 69 70 # Description of argument(s): 71 # 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. 75 76 # The length of the returned dictionary indicates how many logs there are. 77 78 # Use 'Print Error Logs' to print. Example: 79 80 # Print Error Logs ${error_logs} Message. 81 82 ${status} ${error_logs}= Run Keyword And Ignore Error Read Properties 83 ... /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} 89 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, 117 # "Associations": [] 118 # }, 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 124 ... msg=Watchdog timeout error log was not found. 125 Should Be Equal As Strings 126 ... ${elog["Severity"]} xyz.openbmc_project.Logging.Entry.Level.Error 127 ... msg=Watchdog timeout severity unexpected value. 128 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 135 Should Be Empty ${stderr} msg=Logging Test stderr is non-empty. 136 Should Contain ${out} logging-test 137 ... msg=Logging test returned unexpected result. 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 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, 161 # "Associations": [] 162 # } 163 BMC Execute Command /tmp/tarball/bin/logging-test -c AutoTestSimple 164 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} 169 ... msg=Failed to get error logs. 170 ${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 180 ... msg=Error log not from AutoTestSimple. 181 ${entry_id}= Read Attribute ${elog_entry[0]} Severity 182 Should Be Equal ${entry_id} 183 ... xyz.openbmc_project.Logging.Entry.Level.Error 184 ... msg=Error log severity mismatch. 185 186Delete Error Logs And Verify 187 [Documentation] Delete all error logs and verify. 188 Delete All Error Logs 189 ${resp}= OpenBMC Get Request ${BMC_LOGGING_ENTRY}list quiet=${1} 190 Should Be Equal As Strings ${resp.status_code} ${HTTP_NOT_FOUND} 191 ... msg=Error logs not deleted as expected. 192 193 194Install Tarball 195 [Documentation] Install tarball on BMC. 196 Should Not Be Empty ${DEBUG_TARBALL_PATH} 197 ... msg=Debug tarball path value is required. 198 BMC Execute Command rm -rf /tmp/tarball 199 Install Debug Tarball On BMC ${DEBUG_TARBALL_PATH} 200 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 227 ${members}= Redfish.Get Attribute ${EVENT_LOG_URI}Entries Members 228 [Return] ${members} 229 230 231Get 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 239Get 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 247Redfish Purge Event Log 248 [Documentation] Do Redfish EventLog purge. 249 250 ${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 255