18cca7fb8SGeorge Keishing*** Settings ***
28cca7fb8SGeorge KeishingDocumentation       Inventory of hardware resources under systems.
38cca7fb8SGeorge Keishing
48cca7fb8SGeorge KeishingResource            ../../../lib/bmc_redfish_resource.robot
58cca7fb8SGeorge KeishingResource            ../../../lib/bmc_redfish_utils.robot
68cca7fb8SGeorge KeishingResource            ../../../lib/logging_utils.robot
78cca7fb8SGeorge KeishingResource            ../../../lib/openbmc_ffdc.robot
88fe6024eSGeorge KeishingResource            ../../../lib/ipmi_client.robot
9759c6f97SGeorge KeishingLibrary             ../../../lib/logging_utils.py
108cca7fb8SGeorge Keishing
112f36947bSGeorge KeishingSuite Setup         Suite Setup Execution
122f36947bSGeorge KeishingSuite Teardown      Suite Teardown Execution
13b0a491f2SGeorge KeishingTest Setup          Test Setup Execution
148cca7fb8SGeorge KeishingTest Teardown       Test Teardown Execution
158cca7fb8SGeorge Keishing
16*6fb70d98SMatt FischerTest Tags          Event_Logging
17f699f55dSGeorge Keishing
18759c6f97SGeorge Keishing** Variables ***
19759c6f97SGeorge Keishing
20759c6f97SGeorge Keishing${max_num_event_logs}  ${200}
21759c6f97SGeorge Keishing
228cca7fb8SGeorge Keishing*** Test Cases ***
238cca7fb8SGeorge Keishing
248cca7fb8SGeorge KeishingEvent Log Check After BMC Reboot
258cca7fb8SGeorge Keishing    [Documentation]  Check event log after BMC rebooted.
268cca7fb8SGeorge Keishing    [Tags]  Event_Log_Check_After_BMC_Reboot
278cca7fb8SGeorge Keishing
288cca7fb8SGeorge Keishing    Redfish Purge Event Log
298cca7fb8SGeorge Keishing    Event Log Should Not Exist
308cca7fb8SGeorge Keishing
318cca7fb8SGeorge Keishing    Redfish OBMC Reboot (off)
328cca7fb8SGeorge Keishing
338cca7fb8SGeorge Keishing    Redfish.Login
348cca7fb8SGeorge Keishing    Wait Until Keyword Succeeds  1 mins  15 secs   Redfish.Get  ${EVENT_LOG_URI}Entries
358cca7fb8SGeorge Keishing
368cca7fb8SGeorge Keishing    Event Log Should Not Exist
378cca7fb8SGeorge Keishing
388cca7fb8SGeorge Keishing
39b0a491f2SGeorge KeishingEvent Log Check After Host Poweron
40b0a491f2SGeorge Keishing    [Documentation]  Check event log after host has booted.
41b0a491f2SGeorge Keishing    [Tags]  Event_Log_Check_After_Host_Poweron
42b0a491f2SGeorge Keishing
43b0a491f2SGeorge Keishing    Redfish Purge Event Log
44b0a491f2SGeorge Keishing    Event Log Should Not Exist
45b0a491f2SGeorge Keishing
46b0a491f2SGeorge Keishing    Redfish Power On
47b0a491f2SGeorge Keishing
48b0a491f2SGeorge Keishing    Redfish.Login
49b0a491f2SGeorge Keishing    Event Log Should Not Exist
50b0a491f2SGeorge Keishing
51b0a491f2SGeorge Keishing
52b0a491f2SGeorge KeishingCreate Test Event Log And Verify
53b0a491f2SGeorge Keishing    [Documentation]  Create event logs and verify via redfish.
54b0a491f2SGeorge Keishing    [Tags]  Create_Test_Event_Log_And_Verify
55b0a491f2SGeorge Keishing
56b0a491f2SGeorge Keishing    Create Test Error Log
57b0a491f2SGeorge Keishing    Event Log Should Exist
58b0a491f2SGeorge Keishing
59b0a491f2SGeorge Keishing
6020c08e41SRahul MaheshwariDelete Redfish Event Log And Verify
6120c08e41SRahul Maheshwari    [Documentation]  Delete Redfish event log and verify via Redfish.
6220c08e41SRahul Maheshwari    [Tags]  Delete_Redfish_Event_Log_And_Verify
6320c08e41SRahul Maheshwari
6420c08e41SRahul Maheshwari    Redfish.Login
6520c08e41SRahul Maheshwari    Redfish Purge Event Log
6620c08e41SRahul Maheshwari    Create Test PEL Log
6720c08e41SRahul Maheshwari    ${elog_entry}=  Get Event Logs
6820c08e41SRahul Maheshwari
69c32434a3SYi Hu    Redfish.Delete  /redfish/v1/Systems/${SYSTEM_ID}/LogServices/EventLog/Entries/${elog_entry[0]["Id"]}
7020c08e41SRahul Maheshwari
7120c08e41SRahul Maheshwari    ${error_entries}=  Get Redfish Error Entries
7220c08e41SRahul Maheshwari    Should Be Empty  ${error_entries}
7320c08e41SRahul Maheshwari
7420c08e41SRahul Maheshwari
75b0a491f2SGeorge KeishingTest Event Log Persistency On Restart
76b0a491f2SGeorge Keishing    [Documentation]  Restart logging service and verify event logs.
77b0a491f2SGeorge Keishing    [Tags]  Test_Event_Log_Persistency_On_Restart
78b0a491f2SGeorge Keishing
79b0a491f2SGeorge Keishing    Create Test Error Log
80b0a491f2SGeorge Keishing    Event Log Should Exist
81b0a491f2SGeorge Keishing
82b0a491f2SGeorge Keishing    BMC Execute Command
83b0a491f2SGeorge Keishing    ...  systemctl restart xyz.openbmc_project.Logging.service
84b0a491f2SGeorge Keishing    Sleep  10s  reason=Wait for logging service to restart properly.
85b0a491f2SGeorge Keishing
86b0a491f2SGeorge Keishing    Event Log Should Exist
87b0a491f2SGeorge Keishing
88b0a491f2SGeorge Keishing
89b0a491f2SGeorge KeishingTest Event Entry Numbering Reset On Restart
90b0a491f2SGeorge Keishing    [Documentation]  Restart logging service and verify event logs entry starts
91b0a491f2SGeorge Keishing    ...  from entry "Id" 1.
92b0a491f2SGeorge Keishing    [Tags]  Test_Event_Entry_Numbering_Reset_On_Restart
9320560f9cSRahul Maheshwari    [Setup]  Redfish Power Off  stack_mode=skip
94b0a491f2SGeorge Keishing
95b0a491f2SGeorge Keishing    #{
96b0a491f2SGeorge Keishing    #  "@odata.context": "/redfish/v1/$metadata#LogEntryCollection.LogEntryCollection",
97b0a491f2SGeorge Keishing    #  "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries",
98b0a491f2SGeorge Keishing    #  "@odata.type": "#LogEntryCollection.LogEntryCollection",
99b0a491f2SGeorge Keishing    #  "Description": "Collection of System Event Log Entries",
100b0a491f2SGeorge Keishing    #  "Members": [
101b0a491f2SGeorge Keishing    #  {
102b0a491f2SGeorge Keishing    #    "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
103b0a491f2SGeorge Keishing    #    "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1",
104b0a491f2SGeorge Keishing    #    "@odata.type": "#LogEntry.v1_4_0.LogEntry",
105b0a491f2SGeorge Keishing    #    "Created": "2019-05-29T13:19:27+00:00",
106b0a491f2SGeorge Keishing    #    "EntryType": "Event",
107b0a491f2SGeorge Keishing    #    "Id": "1",               <----- Event log ID
108b0a491f2SGeorge Keishing    #    "Message": "org.open_power.Host.Error.Event",
109b0a491f2SGeorge Keishing    #    "Name": "System DBus Event Log Entry",
110b0a491f2SGeorge Keishing    #    "Severity": "Critical"
111b0a491f2SGeorge Keishing    #  }
112b0a491f2SGeorge Keishing    #  ],
113b0a491f2SGeorge Keishing    #  "Members@odata.count": 1,
114b0a491f2SGeorge Keishing    #  "Name": "System Event Log Entries"
115b0a491f2SGeorge Keishing    #}
116b0a491f2SGeorge Keishing
11720560f9cSRahul Maheshwari    Create Test PEL Log
11820560f9cSRahul Maheshwari    Create Test PEL Log
119b0a491f2SGeorge Keishing    Event Log Should Exist
120b0a491f2SGeorge Keishing
121b0a491f2SGeorge Keishing    Redfish Purge Event Log
122b0a491f2SGeorge Keishing    Event Log Should Not Exist
123b0a491f2SGeorge Keishing
124b0a491f2SGeorge Keishing    BMC Execute Command
125b0a491f2SGeorge Keishing    ...  systemctl restart xyz.openbmc_project.Logging.service
126b0a491f2SGeorge Keishing    Sleep  10s  reason=Wait for logging service to restart properly.
127b0a491f2SGeorge Keishing
12820560f9cSRahul Maheshwari    Create Test PEL Log
129b0a491f2SGeorge Keishing    ${elogs}=  Get Event Logs
130adf10ee9Smanashsarma
131adf10ee9Smanashsarma    # After issuing Redfish purge event log, there will be one informational error log
132adf10ee9Smanashsarma    # in BMC with ID 1. Due to this the newly generated error log would have ID as 2.
133adf10ee9Smanashsarma    Should Be Equal  ${elogs[0]["Id"]}  2  msg=Event log entry is not 2
134b0a491f2SGeorge Keishing
135b0a491f2SGeorge Keishing
136b0a491f2SGeorge KeishingTest Event Log Persistency On Reboot
137b0a491f2SGeorge Keishing    [Documentation]  Reboot BMC and verify event log.
138b0a491f2SGeorge Keishing    [Tags]  Test_Event_Log_Persistency_On_Reboot
139b0a491f2SGeorge Keishing
140b0a491f2SGeorge Keishing    Redfish Purge Event Log
141b0a491f2SGeorge Keishing    Create Test Error Log
142b0a491f2SGeorge Keishing    Event Log Should Exist
143b0a491f2SGeorge Keishing
144b0a491f2SGeorge Keishing    Redfish OBMC Reboot (off)
145b0a491f2SGeorge Keishing
146b0a491f2SGeorge Keishing    Redfish.Login
147b0a491f2SGeorge Keishing    Wait Until Keyword Succeeds  1 mins  15 secs   Redfish.Get  ${EVENT_LOG_URI}Entries
148b0a491f2SGeorge Keishing
149b0a491f2SGeorge Keishing    Event Log Should Exist
150b0a491f2SGeorge Keishing
151b0a491f2SGeorge Keishing
152148d08c2SGeorge KeishingCreate Test Event Log And Verify Time Stamp
153148d08c2SGeorge Keishing    [Documentation]  Create event logs and verify time stamp.
154148d08c2SGeorge Keishing    [Tags]  Create_Test_Event_Log_And_Verify_Time_Stamp
155148d08c2SGeorge Keishing
156148d08c2SGeorge Keishing    #{
157148d08c2SGeorge Keishing    #  "@odata.context": "/redfish/v1/$metadata#LogEntryCollection.LogEntryCollection",
158148d08c2SGeorge Keishing    #  "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries",
159148d08c2SGeorge Keishing    #  "@odata.type": "#LogEntryCollection.LogEntryCollection",
160148d08c2SGeorge Keishing    #  "Description": "Collection of System Event Log Entries",
161148d08c2SGeorge Keishing    #  "Members": [
162148d08c2SGeorge Keishing    #  {
163148d08c2SGeorge Keishing    #    "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
164148d08c2SGeorge Keishing    #    "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1",
165148d08c2SGeorge Keishing    #    "@odata.type": "#LogEntry.v1_4_0.LogEntry",
166f4372444Sdnirmala    #    "Created": "2023-05-10T10:26:02.186+00:00", <--- Time stamp
167148d08c2SGeorge Keishing    #    "EntryType": "Event",
168148d08c2SGeorge Keishing    #    "Id": "1",
169148d08c2SGeorge Keishing    #    "Message": "org.open_power.Host.Error.Event",
170148d08c2SGeorge Keishing    #    "Name": "System DBus Event Log Entry",
171148d08c2SGeorge Keishing    #    "Severity": "Critical"
172148d08c2SGeorge Keishing    #  }
173148d08c2SGeorge Keishing    #  ],
174148d08c2SGeorge Keishing    #  "Members@odata.count": 1,
175148d08c2SGeorge Keishing    #  "Name": "System Event Log Entries"
176148d08c2SGeorge Keishing    #}
177148d08c2SGeorge Keishing
178148d08c2SGeorge Keishing    Redfish Purge Event Log
179148d08c2SGeorge Keishing
180148d08c2SGeorge Keishing    Create Test Error Log
181148d08c2SGeorge Keishing    Sleep  2s
182148d08c2SGeorge Keishing    Create Test Error Log
183148d08c2SGeorge Keishing
184148d08c2SGeorge Keishing    ${elog_entry}=  Get Event Logs
185148d08c2SGeorge Keishing
186148d08c2SGeorge Keishing    # The event log generated is associated with the epoc time and unique
187148d08c2SGeorge Keishing    # for every error and in increasing time stamp.
188f4372444Sdnirmala    ${time_stamp1}=  Convert Date  ${elog_entry[0]["Created"].split('.')[0]}  epoch
189f4372444Sdnirmala    ${time_stamp2}=  Convert Date  ${elog_entry[1]["Created"].split('.')[0]}  epoch
190148d08c2SGeorge Keishing
191148d08c2SGeorge Keishing    Should Be True  ${time_stamp2} > ${time_stamp1}
192148d08c2SGeorge Keishing
193148d08c2SGeorge Keishing
19424034a99SRahul Maheshwari# TODO: openbmc/openbmc-test-automation#1789
1956462f26dSRahul MaheshwariVerify Setting Error Log As Resolved
1966462f26dSRahul Maheshwari    [Documentation]  Verify modified field of error log is updated when error log is marked resolved.
1976462f26dSRahul Maheshwari    [Tags]  Verify_Setting_Error_Log_As_Resolved
1986462f26dSRahul Maheshwari
1996462f26dSRahul Maheshwari    Create Test PEL Log
2006462f26dSRahul Maheshwari    ${elog_entry}=  Get Event Logs
2016462f26dSRahul Maheshwari
2026462f26dSRahul Maheshwari    # Wait for 5 seconds after creating error log.
2036462f26dSRahul Maheshwari    Sleep  5s
2046462f26dSRahul Maheshwari
2056462f26dSRahul Maheshwari    # Mark error log as resolved by setting it to true.
2066462f26dSRahul Maheshwari    Redfish.Patch  ${EVENT_LOG_URI}Entries/${elog_entry[0]["Id"]}  body={'Resolved':True}
2076462f26dSRahul Maheshwari
2086462f26dSRahul Maheshwari    ${elog_entry}=  Get Event Logs
2096462f26dSRahul Maheshwari
2106462f26dSRahul Maheshwari    # Example error log with resolve field set to true:
2116462f26dSRahul Maheshwari    # {
2126462f26dSRahul Maheshwari    #  "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/2045",
2136462f26dSRahul Maheshwari    #  "@odata.type": "#LogEntry.v1_8_0.LogEntry",
2146462f26dSRahul Maheshwari    #  "AdditionalDataURI": "/redfish/v1/Systems/system/LogServices/EventLog/attachment/2045",
215f4372444Sdnirmala    #  "Created": "2023-05-10T10:26:02.186+00:00",
2166462f26dSRahul Maheshwari    #  "EntryType": "Event",
2176462f26dSRahul Maheshwari    #  "Id": "2045",
2186462f26dSRahul Maheshwari    #  "Message": "xyz.openbmc_project.Host.Error.Event",
219f4372444Sdnirmala    #  "Modified": "2023-05-10T10:26:02.186+00:00",
2206462f26dSRahul Maheshwari    #  "Name": "System Event Log Entry",
2216462f26dSRahul Maheshwari    #  "Resolved": true,
2226462f26dSRahul Maheshwari    #  "Severity": "OK"
2236462f26dSRahul Maheshwari    # }
2246462f26dSRahul Maheshwari
2256462f26dSRahul Maheshwari    Should Be Equal As Strings  ${elog_entry[0]["Resolved"]}  True
2266462f26dSRahul Maheshwari
2276462f26dSRahul Maheshwari    # Difference created and modified time of error log should be around 5 seconds.
228f4372444Sdnirmala    ${creation_time}=  Convert Date  ${elog_entry[0]["Created"].split('.')[0]}  epoch
229f4372444Sdnirmala    ${modification_time}=  Convert Date  ${elog_entry[0]["Modified"].split('.')[0]}  epoch
2306462f26dSRahul Maheshwari
2316462f26dSRahul Maheshwari    ${diff}=  Subtract Date From Date  ${modification_time}  ${creation_time}
2326462f26dSRahul Maheshwari    ${diff}=  Convert To Number  ${diff}
2336462f26dSRahul Maheshwari    Should Be True  4 < ${diff} < 8
2346462f26dSRahul Maheshwari
2356462f26dSRahul Maheshwari
236ddbc88c7SGeorge KeishingVerify IPMI SEL Delete
237ddbc88c7SGeorge Keishing    [Documentation]  Verify IPMI SEL delete operation.
238ddbc88c7SGeorge Keishing    [Tags]  Verify_IPMI_SEL_Delete
239ddbc88c7SGeorge Keishing
240ddbc88c7SGeorge Keishing    Redfish Purge Event Log
241ddbc88c7SGeorge Keishing    Create Test Error Log
242ddbc88c7SGeorge Keishing
243ddbc88c7SGeorge Keishing    ${sel_list}=  Run IPMI Standard Command  sel list
244ddbc88c7SGeorge Keishing    Should Not Be Equal As Strings  ${sel_list}  SEL has no entries
245ddbc88c7SGeorge Keishing
246ddbc88c7SGeorge Keishing    # Example of SEL List:
247ddbc88c7SGeorge Keishing    # 4 | 04/21/2017 | 10:51:16 | System Event #0x01 | Undetermined system hardware failure | Asserted
248ddbc88c7SGeorge Keishing
249ddbc88c7SGeorge Keishing    ${sel_entry}=  Fetch from Left  ${sel_list}  |
250ddbc88c7SGeorge Keishing    ${sel_entry}=  Evaluate  $sel_entry.replace(' ','')
251ddbc88c7SGeorge Keishing    ${sel_entry}=  Convert To Integer  0x${sel_entry}
252ddbc88c7SGeorge Keishing
253ddbc88c7SGeorge Keishing    ${sel_delete}=  Run IPMI Standard Command  sel delete ${sel_entry}
254ddbc88c7SGeorge Keishing    Should Be Equal As Strings  ${sel_delete}  Deleted entry ${sel_entry}
255ddbc88c7SGeorge Keishing    ...  case_insensitive=True
256ddbc88c7SGeorge Keishing
257ddbc88c7SGeorge Keishing    ${sel_list}=  Run IPMI Standard Command  sel list
258ddbc88c7SGeorge Keishing    Should Be Equal As Strings  ${sel_list}  SEL has no entries
259ddbc88c7SGeorge Keishing    ...  case_insensitive=True
260ddbc88c7SGeorge Keishing
261ddbc88c7SGeorge Keishing
262d35b5319SGeorge KeishingCreate Test Event Log And Delete
263d35b5319SGeorge Keishing    [Documentation]  Create an event log and delete it.
264d35b5319SGeorge Keishing    [Tags]  Create_Test_Event_Log_And_Delete
265d35b5319SGeorge Keishing
266d35b5319SGeorge Keishing    Create Test Error Log
267d35b5319SGeorge Keishing    Redfish Purge Event Log
268d35b5319SGeorge Keishing    Event Log Should Not Exist
269d35b5319SGeorge Keishing
270d35b5319SGeorge Keishing
271d35b5319SGeorge KeishingCreate Multiple Test Event Logs And Delete All
272d35b5319SGeorge Keishing    [Documentation]  Create multiple event logs and delete all.
273d35b5319SGeorge Keishing    [Tags]  Create_Multiple_Test_Event_Logs_And_Delete_All
274d35b5319SGeorge Keishing
275d35b5319SGeorge Keishing    Create Test Error Log
276d35b5319SGeorge Keishing    Create Test Error Log
277d35b5319SGeorge Keishing    Create Test Error Log
278d35b5319SGeorge Keishing    Redfish Purge Event Log
279d35b5319SGeorge Keishing    Event Log Should Not Exist
280d35b5319SGeorge Keishing
281d35b5319SGeorge Keishing
282ddbc88c7SGeorge KeishingCreate Two Test Event Logs And Delete One
283ddbc88c7SGeorge Keishing    [Documentation]  Create two event logs and delete the first entry.
28489f499d5SGeorge Keishing    [Tags]  Create_Two_Test_Event_Logs_And_Delete_One
285c2d33651SRahul Maheshwari    [Setup]  Redfish Power Off  stack_mode=skip
286ddbc88c7SGeorge Keishing
287ddbc88c7SGeorge Keishing    Redfish Purge Event Log
288c2d33651SRahul Maheshwari    Create Test PEL Log
289c2d33651SRahul Maheshwari    Create Test PEL Log
290c2d33651SRahul Maheshwari    ${error_entries_before}=  Get Redfish Error Entries
291c32434a3SYi Hu    Redfish.Delete  /redfish/v1/Systems/${SYSTEM_ID}/LogServices/EventLog/Entries/${error_entries_before[0]}
292c2d33651SRahul Maheshwari
293c2d33651SRahul Maheshwari    ${error_entries_after}=  Get Redfish Error Entries
294c2d33651SRahul Maheshwari    Should Not Contain  ${error_entries_after}  ${error_entries_before[0]}
295c2d33651SRahul Maheshwari    Should Contain  ${error_entries_after}  ${error_entries_before[1]}
296ddbc88c7SGeorge Keishing
297ddbc88c7SGeorge Keishing
298d35b5319SGeorge KeishingVerify Watchdog Timedout Event
299d35b5319SGeorge Keishing    [Documentation]  Trigger watchdog timed out and verify event log generated.
300d35b5319SGeorge Keishing    [Tags]  Verify_Watchdog_Timedout_Event
3012ab62414SGeorge Keishing    [Teardown]  Run Keywords  Test Teardown Execution  AND  Redfish Power Off  stack_mode=skip
302d35b5319SGeorge Keishing
3032ab62414SGeorge Keishing    Redfish Power Off  stack_mode=skip
304d35b5319SGeorge Keishing
305d35b5319SGeorge Keishing    # Clear errors if there are any.
306d35b5319SGeorge Keishing    Redfish.Login
307d35b5319SGeorge Keishing    Redfish Purge Event Log
308d35b5319SGeorge Keishing
3092ab62414SGeorge Keishing    # Reference: [Old legacy REST code] Trigger Host Watchdog Error
3102ab62414SGeorge Keishing    # Currently, no known redfish interface to set to trigger watchdog timer.
3112ab62414SGeorge Keishing
3122ab62414SGeorge Keishing    Redfish Initiate Auto Reboot  1000
313d35b5319SGeorge Keishing
314d35b5319SGeorge Keishing    # Logging takes time to generate the timeout error.
3152ab62414SGeorge Keishing    Wait Until Keyword Succeeds  3 min  20 sec  Verify Watchdog EventLog Content
316d35b5319SGeorge Keishing
317d35b5319SGeorge Keishing
318d35b5319SGeorge KeishingVerify Event Logs Capping
319d35b5319SGeorge Keishing    [Documentation]  Verify event logs capping.
320d35b5319SGeorge Keishing    [Tags]  Verify_Event_Logs_Capping
321d35b5319SGeorge Keishing
322d35b5319SGeorge Keishing    Redfish Purge Event Log
323d35b5319SGeorge Keishing
324033ee18fSGeorge Keishing    ${cmd}=  Catenate  uptime; for i in {1..201}; do /tmp/tarball/bin/logging-test -c
325033ee18fSGeorge Keishing    ...  AutoTestSimple;sleep 1;done; uptime
326d35b5319SGeorge Keishing    BMC Execute Command  ${cmd}
327d35b5319SGeorge Keishing
328d35b5319SGeorge Keishing    ${elogs}=  Get Event Logs
329d35b5319SGeorge Keishing    ${count}=  Get Length  ${elogs}
330d35b5319SGeorge Keishing    Run Keyword If  ${count} > 200
331d35b5319SGeorge Keishing    ...  Fail  Error logs created exceeded max capacity 200.
332d35b5319SGeorge Keishing
333d35b5319SGeorge Keishing
334759c6f97SGeorge KeishingTest Event Log Wrapping
335759c6f97SGeorge Keishing    [Documentation]  Verify event log entries wraps when 200 max cap is reached.
336759c6f97SGeorge Keishing    [Tags]  Test_Event_Log_Wrapping
337759c6f97SGeorge Keishing
338759c6f97SGeorge Keishing    # Restarting logging service in order to clear logs and get the next log
339759c6f97SGeorge Keishing    # ID set to 1.
340759c6f97SGeorge Keishing    BMC Execute Command
341759c6f97SGeorge Keishing    ...  systemctl restart xyz.openbmc_project.Logging.service
342759c6f97SGeorge Keishing    Sleep  10s  reason=Wait for logging service to restart properly.
343759c6f97SGeorge Keishing
344759c6f97SGeorge Keishing    # Create ${max_num_event_logs} event logs.
345033ee18fSGeorge Keishing    ${cmd}=  Catenate  uptime; for i in {1..${max_num_event_logs}}; do /tmp/tarball/bin/logging-test -c
346033ee18fSGeorge Keishing    ...  AutoTestSimple;sleep 1;done; uptime
347759c6f97SGeorge Keishing    BMC Execute Command  ${cmd}
348759c6f97SGeorge Keishing
349759c6f97SGeorge Keishing    # Verify that event logs with IDs 1 and ${max_num_event_logs} exist.
350759c6f97SGeorge Keishing    ${event_log}=  Get Event Logs
351759c6f97SGeorge Keishing
352759c6f97SGeorge Keishing    ${log_entries}=  Filter Struct  ${event_log}  [('Id', '1')]
35339c00518SMichael Walsh    Rprint Vars  log_entries
354759c6f97SGeorge Keishing    Should Be Equal As Strings  ${log_entries[0]["Id"]}  1
355759c6f97SGeorge Keishing
356759c6f97SGeorge Keishing    ${log_entries}=  Filter Struct  ${event_log}  [('Id', '${max_num_event_logs}')]
35739c00518SMichael Walsh    Rprint Vars  log_entries
358759c6f97SGeorge Keishing    Should Be Equal As Strings  ${log_entries[0]["Id"]}  ${max_num_event_logs}
359759c6f97SGeorge Keishing
360759c6f97SGeorge Keishing    # Create event log and verify the entry ID, ${max_num_event_logs + 1}.
361759c6f97SGeorge Keishing    ${next_event_log_id}=  Set Variable  ${max_num_event_logs + 1}
362759c6f97SGeorge Keishing
363759c6f97SGeorge Keishing    Create Test Error Log
364759c6f97SGeorge Keishing
365759c6f97SGeorge Keishing    ${event_log}=  Get Event Logs
366759c6f97SGeorge Keishing
367759c6f97SGeorge Keishing    ${log_entries}=  Filter Struct  ${event_log}  [('Id', '${next_event_log_id}')]
36839c00518SMichael Walsh    Rprint Vars  log_entries
369759c6f97SGeorge Keishing    Should Be Equal As Strings  ${log_entries[0]["Id"]}  ${next_event_log_id}
370759c6f97SGeorge Keishing
371759c6f97SGeorge Keishing    # Event log 1 should be wrapped.
372759c6f97SGeorge Keishing    ${log_entries}=  Filter Struct  ${event_log}  [('Id', '1')]
37339c00518SMichael Walsh    Rprint Vars  log_entries
374759c6f97SGeorge Keishing
375759c6f97SGeorge Keishing    ${length_log_entries}  Get Length  ${log_entries}
376759c6f97SGeorge Keishing    Should Be Equal As Integers  ${length_log_entries}  0
377759c6f97SGeorge Keishing    ...  msg=The event log should have wrapped such that entry ID 1 is now purged.
378759c6f97SGeorge Keishing
379759c6f97SGeorge Keishing
3802e092d04SdnirmalaVerify Default Value Of Resolved Field Is False For An Error Log Via Redfish
3812e092d04Sdnirmala    [Documentation]   Verify the Resolve field status is false for an error log from Redfish.
3822e092d04Sdnirmala    [Tags]  Verify_Default_Value_Of_Resolved_Field_Is_False_For_An_Error_Log_Via_Redfish
3832e092d04Sdnirmala
3842e092d04Sdnirmala    Redfish Purge Event Log
3852e092d04Sdnirmala    Create Test Error Log
3862e092d04Sdnirmala
3872e092d04Sdnirmala    # Check resolve field value of created error log.
3882e092d04Sdnirmala    ${elog_entry}=  Get Event Logs
3892e092d04Sdnirmala    Should Be Equal  ${elog_entry[0]["Resolved"]}  ${False}
3902e092d04Sdnirmala
3912e092d04Sdnirmala
3928cca7fb8SGeorge Keishing*** Keywords ***
3938cca7fb8SGeorge Keishing
3942f36947bSGeorge KeishingSuite Setup Execution
3952f36947bSGeorge Keishing   [Documentation]  Do test case setup tasks.
3962f36947bSGeorge Keishing
3972f36947bSGeorge Keishing    Redfish.Login
3982f36947bSGeorge Keishing
3992f36947bSGeorge Keishing    Redfish Purge Event Log
4002f36947bSGeorge Keishing
4012f36947bSGeorge Keishing    ${status}=  Run Keyword And Return Status  Logging Test Binary Exist
4022f36947bSGeorge Keishing    Run Keyword If  ${status} == ${False}  Install Tarball
4032f36947bSGeorge Keishing
4042f36947bSGeorge Keishing
4058cca7fb8SGeorge KeishingSuite Teardown Execution
4068cca7fb8SGeorge Keishing    [Documentation]  Do the post suite teardown.
4078cca7fb8SGeorge Keishing
4088cca7fb8SGeorge Keishing    Redfish.Logout
4098cca7fb8SGeorge Keishing
4108cca7fb8SGeorge Keishing
411b0a491f2SGeorge KeishingTest Setup Execution
4128cca7fb8SGeorge Keishing   [Documentation]  Do test case setup tasks.
4138cca7fb8SGeorge Keishing
4140b76e421SGeorge Keishing    Redfish Purge Event Log
4150b76e421SGeorge Keishing
4168cca7fb8SGeorge Keishing    ${status}=  Run Keyword And Return Status  Logging Test Binary Exist
4178cca7fb8SGeorge Keishing    Run Keyword If  ${status} == ${False}  Install Tarball
4188cca7fb8SGeorge Keishing
4198cca7fb8SGeorge Keishing
4208cca7fb8SGeorge KeishingTest Teardown Execution
4218cca7fb8SGeorge Keishing    [Documentation]  Do the post test teardown.
4228cca7fb8SGeorge Keishing
4238cca7fb8SGeorge Keishing    FFDC On Test Case Fail
424e5c5ebdfSGeorge Keishing    Redfish.Login
425b0a491f2SGeorge Keishing    Redfish Purge Event Log
4268cca7fb8SGeorge Keishing
4278cca7fb8SGeorge Keishing
42820c08e41SRahul MaheshwariGet Redfish Error Entries
42920c08e41SRahul Maheshwari    [Documentation]  Return Redfish error ids list.
430c32434a3SYi Hu    ${error_uris}=  redfish_utils.get_member_list  /redfish/v1/Systems/${SYSTEM_ID}/LogServices/EventLog/Entries
43120c08e41SRahul Maheshwari    ${error_ids}=  Create List
43220c08e41SRahul Maheshwari
43320c08e41SRahul Maheshwari    FOR  ${error_uri}  IN  @{error_uris}
43420c08e41SRahul Maheshwari      ${error_id}=  Fetch From Right  ${error_uri}  /
43520c08e41SRahul Maheshwari      Append To List  ${error_ids}  ${error_id}
43620c08e41SRahul Maheshwari    END
43720c08e41SRahul Maheshwari
438409df05dSGeorge Keishing    RETURN  ${error_ids}
43920c08e41SRahul Maheshwari
44020c08e41SRahul Maheshwari
4418cca7fb8SGeorge KeishingEvent Log Should Not Exist
4428cca7fb8SGeorge Keishing    [Documentation]  Event log entries should not exist.
4438cca7fb8SGeorge Keishing
4448cca7fb8SGeorge Keishing    ${elogs}=  Get Event Logs
4458cca7fb8SGeorge Keishing    Should Be Empty  ${elogs}  msg=System event log entry is not empty.
446b0a491f2SGeorge Keishing
447b0a491f2SGeorge Keishing
448b0a491f2SGeorge KeishingEvent Log Should Exist
449b0a491f2SGeorge Keishing    [Documentation]  Event log entries should exist.
450b0a491f2SGeorge Keishing
451b0a491f2SGeorge Keishing    ${elogs}=  Get Event Logs
452b0a491f2SGeorge Keishing    Should Not Be Empty  ${elogs}  msg=System event log entry is not empty.
453d35b5319SGeorge Keishing
454d35b5319SGeorge Keishing
455d35b5319SGeorge KeishingVerify Watchdog EventLog Content
456d35b5319SGeorge Keishing    [Documentation]  Verify watchdog event log content.
457d35b5319SGeorge Keishing
458d35b5319SGeorge Keishing    # Example:
459d35b5319SGeorge Keishing    # {
460d35b5319SGeorge Keishing    #    "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
461d35b5319SGeorge Keishing    #    "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/31",
462d35b5319SGeorge Keishing    #    "@odata.type": "#LogEntry.v1_4_0.LogEntry",
463d35b5319SGeorge Keishing    #    "Created": "2019-05-31T18:41:33+00:00",
464d35b5319SGeorge Keishing    #    "EntryType": "Event",
465d35b5319SGeorge Keishing    #    "Id": "31",
466d35b5319SGeorge Keishing    #    "Message": "org.open_power.Host.Boot.Error.WatchdogTimedOut",
467d35b5319SGeorge Keishing    #    "Name": "System DBus Event Log Entry",
468d35b5319SGeorge Keishing    #    "Severity": "Critical"
469d35b5319SGeorge Keishing    # }
470d35b5319SGeorge Keishing
4712ab62414SGeorge Keishing    ${elog_list}=  Get Event Logs
4722ab62414SGeorge Keishing
4732ab62414SGeorge Keishing    Rprint Vars  elog_list
4742ab62414SGeorge Keishing
4752ab62414SGeorge Keishing    FOR  ${entry}  IN  @{elog_list}
4762ab62414SGeorge Keishing        ${found_match}=  Run Keyword And Return Status  Is Watchdog Error Found  ${entry}
4772ab62414SGeorge Keishing        Exit For Loop If  '${found_match}' == 'True'
4782ab62414SGeorge Keishing    END
4792ab62414SGeorge Keishing
4802ab62414SGeorge Keishing    Run Keyword If  '${found_match}' == 'False'  Fail  msg=No watchdog error logged.
4812ab62414SGeorge Keishing
4822ab62414SGeorge Keishing
4832ab62414SGeorge KeishingIs Watchdog Error Found
4842ab62414SGeorge Keishing    [Documentation]  Check if the give log entry matches specific watchdog error.
4852ab62414SGeorge Keishing    [Arguments]  ${elog}
4862ab62414SGeorge Keishing
4872ab62414SGeorge Keishing    # Description of argument(s):
4882ab62414SGeorge Keishing    # elog   Error log entry dictionary data.
4892ab62414SGeorge Keishing
4902ab62414SGeorge Keishing    Should Contain Any
4912ab62414SGeorge Keishing    ...  ${elog["Message"]}  org.open_power.Host.Boot.Error.WatchdogTimedOut
4922ab62414SGeorge Keishing    ...  CEC Hardware - Hostboot-Service Processor Interface
493d35b5319SGeorge Keishing    ...  msg=Watchdog timeout event log was not found.
4942ab62414SGeorge Keishing
4952ab62414SGeorge Keishing    Log To Console  Matched Found: ${elog}
496