xref: /openbmc/openbmc-test-automation/redfish/systems/eventlog/test_event_logging.robot (revision adf10ee95c4b47f8851b9553273cf867be970160)
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
16f699f55dSGeorge KeishingForce 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
130*adf10ee9Smanashsarma
131*adf10ee9Smanashsarma    # After issuing Redfish purge event log, there will be one informational error log
132*adf10ee9Smanashsarma    # in BMC with ID 1. Due to this the newly generated error log would have ID as 2.
133*adf10ee9Smanashsarma    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
2620b76e421SGeorge KeishingVerify IPMI SEL Event Entries
2630b76e421SGeorge Keishing    [Documentation]  Verify IPMI SEL's entries info.
2640b76e421SGeorge Keishing    [Tags]  Verify_IPMI_SEL_Event_Entries
2650b76e421SGeorge Keishing
2660b76e421SGeorge Keishing    # Generate error logs of random count.
2670b76e421SGeorge Keishing    ${count}=  Evaluate  random.randint(1, 5)  modules=random
2680b76e421SGeorge Keishing    Repeat Keyword  ${count}  Create Test Error Log
2690b76e421SGeorge Keishing
2700b76e421SGeorge Keishing    ${sel_entries_count}=  Get IPMI SEL Setting  Entries
2710b76e421SGeorge Keishing    Should Be Equal As Strings  ${sel_entries_count}  ${count}
2720b76e421SGeorge Keishing
2730b76e421SGeorge Keishing
274d35b5319SGeorge KeishingCreate Test Event Log And Delete
275d35b5319SGeorge Keishing    [Documentation]  Create an event log and delete it.
276d35b5319SGeorge Keishing    [Tags]  Create_Test_Event_Log_And_Delete
277d35b5319SGeorge Keishing
278d35b5319SGeorge Keishing    Create Test Error Log
279d35b5319SGeorge Keishing    Redfish Purge Event Log
280d35b5319SGeorge Keishing    Event Log Should Not Exist
281d35b5319SGeorge Keishing
282d35b5319SGeorge Keishing
283d35b5319SGeorge KeishingCreate Multiple Test Event Logs And Delete All
284d35b5319SGeorge Keishing    [Documentation]  Create multiple event logs and delete all.
285d35b5319SGeorge Keishing    [Tags]  Create_Multiple_Test_Event_Logs_And_Delete_All
286d35b5319SGeorge Keishing
287d35b5319SGeorge Keishing    Create Test Error Log
288d35b5319SGeorge Keishing    Create Test Error Log
289d35b5319SGeorge Keishing    Create Test Error Log
290d35b5319SGeorge Keishing    Redfish Purge Event Log
291d35b5319SGeorge Keishing    Event Log Should Not Exist
292d35b5319SGeorge Keishing
293d35b5319SGeorge Keishing
294ddbc88c7SGeorge KeishingCreate Two Test Event Logs And Delete One
295ddbc88c7SGeorge Keishing    [Documentation]  Create two event logs and delete the first entry.
29689f499d5SGeorge Keishing    [Tags]  Create_Two_Test_Event_Logs_And_Delete_One
297c2d33651SRahul Maheshwari    [Setup]  Redfish Power Off  stack_mode=skip
298ddbc88c7SGeorge Keishing
299ddbc88c7SGeorge Keishing    Redfish Purge Event Log
300c2d33651SRahul Maheshwari    Create Test PEL Log
301c2d33651SRahul Maheshwari    Create Test PEL Log
302c2d33651SRahul Maheshwari    ${error_entries_before}=  Get Redfish Error Entries
303c32434a3SYi Hu    Redfish.Delete  /redfish/v1/Systems/${SYSTEM_ID}/LogServices/EventLog/Entries/${error_entries_before[0]}
304c2d33651SRahul Maheshwari
305c2d33651SRahul Maheshwari    ${error_entries_after}=  Get Redfish Error Entries
306c2d33651SRahul Maheshwari    Should Not Contain  ${error_entries_after}  ${error_entries_before[0]}
307c2d33651SRahul Maheshwari    Should Contain  ${error_entries_after}  ${error_entries_before[1]}
308ddbc88c7SGeorge Keishing
309ddbc88c7SGeorge Keishing
310d35b5319SGeorge KeishingVerify Watchdog Timedout Event
311d35b5319SGeorge Keishing    [Documentation]  Trigger watchdog timed out and verify event log generated.
312d35b5319SGeorge Keishing    [Tags]  Verify_Watchdog_Timedout_Event
3132ab62414SGeorge Keishing    [Teardown]  Run Keywords  Test Teardown Execution  AND  Redfish Power Off  stack_mode=skip
314d35b5319SGeorge Keishing
3152ab62414SGeorge Keishing    Redfish Power Off  stack_mode=skip
316d35b5319SGeorge Keishing
317d35b5319SGeorge Keishing    # Clear errors if there are any.
318d35b5319SGeorge Keishing    Redfish.Login
319d35b5319SGeorge Keishing    Redfish Purge Event Log
320d35b5319SGeorge Keishing
3212ab62414SGeorge Keishing    # Reference: [Old legacy REST code] Trigger Host Watchdog Error
3222ab62414SGeorge Keishing    # Currently, no known redfish interface to set to trigger watchdog timer.
3232ab62414SGeorge Keishing
3242ab62414SGeorge Keishing    Redfish Initiate Auto Reboot  1000
325d35b5319SGeorge Keishing
326d35b5319SGeorge Keishing    # Logging takes time to generate the timeout error.
3272ab62414SGeorge Keishing    Wait Until Keyword Succeeds  3 min  20 sec  Verify Watchdog EventLog Content
328d35b5319SGeorge Keishing
329d35b5319SGeorge Keishing
330d35b5319SGeorge KeishingVerify Event Logs Capping
331d35b5319SGeorge Keishing    [Documentation]  Verify event logs capping.
332d35b5319SGeorge Keishing    [Tags]  Verify_Event_Logs_Capping
333d35b5319SGeorge Keishing
334d35b5319SGeorge Keishing    Redfish Purge Event Log
335d35b5319SGeorge Keishing
336033ee18fSGeorge Keishing    ${cmd}=  Catenate  uptime; for i in {1..201}; do /tmp/tarball/bin/logging-test -c
337033ee18fSGeorge Keishing    ...  AutoTestSimple;sleep 1;done; uptime
338d35b5319SGeorge Keishing    BMC Execute Command  ${cmd}
339d35b5319SGeorge Keishing
340d35b5319SGeorge Keishing    ${elogs}=  Get Event Logs
341d35b5319SGeorge Keishing    ${count}=  Get Length  ${elogs}
342d35b5319SGeorge Keishing    Run Keyword If  ${count} > 200
343d35b5319SGeorge Keishing    ...  Fail  Error logs created exceeded max capacity 200.
344d35b5319SGeorge Keishing
345d35b5319SGeorge Keishing
346759c6f97SGeorge KeishingTest Event Log Wrapping
347759c6f97SGeorge Keishing    [Documentation]  Verify event log entries wraps when 200 max cap is reached.
348759c6f97SGeorge Keishing    [Tags]  Test_Event_Log_Wrapping
349759c6f97SGeorge Keishing
350759c6f97SGeorge Keishing    # Restarting logging service in order to clear logs and get the next log
351759c6f97SGeorge Keishing    # ID set to 1.
352759c6f97SGeorge Keishing    BMC Execute Command
353759c6f97SGeorge Keishing    ...  systemctl restart xyz.openbmc_project.Logging.service
354759c6f97SGeorge Keishing    Sleep  10s  reason=Wait for logging service to restart properly.
355759c6f97SGeorge Keishing
356759c6f97SGeorge Keishing    # Create ${max_num_event_logs} event logs.
357033ee18fSGeorge Keishing    ${cmd}=  Catenate  uptime; for i in {1..${max_num_event_logs}}; do /tmp/tarball/bin/logging-test -c
358033ee18fSGeorge Keishing    ...  AutoTestSimple;sleep 1;done; uptime
359759c6f97SGeorge Keishing    BMC Execute Command  ${cmd}
360759c6f97SGeorge Keishing
361759c6f97SGeorge Keishing    # Verify that event logs with IDs 1 and ${max_num_event_logs} exist.
362759c6f97SGeorge Keishing    ${event_log}=  Get Event Logs
363759c6f97SGeorge Keishing
364759c6f97SGeorge Keishing    ${log_entries}=  Filter Struct  ${event_log}  [('Id', '1')]
36539c00518SMichael Walsh    Rprint Vars  log_entries
366759c6f97SGeorge Keishing    Should Be Equal As Strings  ${log_entries[0]["Id"]}  1
367759c6f97SGeorge Keishing
368759c6f97SGeorge Keishing    ${log_entries}=  Filter Struct  ${event_log}  [('Id', '${max_num_event_logs}')]
36939c00518SMichael Walsh    Rprint Vars  log_entries
370759c6f97SGeorge Keishing    Should Be Equal As Strings  ${log_entries[0]["Id"]}  ${max_num_event_logs}
371759c6f97SGeorge Keishing
372759c6f97SGeorge Keishing    # Create event log and verify the entry ID, ${max_num_event_logs + 1}.
373759c6f97SGeorge Keishing    ${next_event_log_id}=  Set Variable  ${max_num_event_logs + 1}
374759c6f97SGeorge Keishing
375759c6f97SGeorge Keishing    Create Test Error Log
376759c6f97SGeorge Keishing
377759c6f97SGeorge Keishing    ${event_log}=  Get Event Logs
378759c6f97SGeorge Keishing
379759c6f97SGeorge Keishing    ${log_entries}=  Filter Struct  ${event_log}  [('Id', '${next_event_log_id}')]
38039c00518SMichael Walsh    Rprint Vars  log_entries
381759c6f97SGeorge Keishing    Should Be Equal As Strings  ${log_entries[0]["Id"]}  ${next_event_log_id}
382759c6f97SGeorge Keishing
383759c6f97SGeorge Keishing    # Event log 1 should be wrapped.
384759c6f97SGeorge Keishing    ${log_entries}=  Filter Struct  ${event_log}  [('Id', '1')]
38539c00518SMichael Walsh    Rprint Vars  log_entries
386759c6f97SGeorge Keishing
387759c6f97SGeorge Keishing    ${length_log_entries}  Get Length  ${log_entries}
388759c6f97SGeorge Keishing    Should Be Equal As Integers  ${length_log_entries}  0
389759c6f97SGeorge Keishing    ...  msg=The event log should have wrapped such that entry ID 1 is now purged.
390759c6f97SGeorge Keishing
391759c6f97SGeorge Keishing
3922e092d04SdnirmalaVerify Default Value Of Resolved Field Is False For An Error Log Via Redfish
3932e092d04Sdnirmala    [Documentation]   Verify the Resolve field status is false for an error log from Redfish.
3942e092d04Sdnirmala    [Tags]  Verify_Default_Value_Of_Resolved_Field_Is_False_For_An_Error_Log_Via_Redfish
3952e092d04Sdnirmala
3962e092d04Sdnirmala    Redfish Purge Event Log
3972e092d04Sdnirmala    Create Test Error Log
3982e092d04Sdnirmala
3992e092d04Sdnirmala    # Check resolve field value of created error log.
4002e092d04Sdnirmala    ${elog_entry}=  Get Event Logs
4012e092d04Sdnirmala    Should Be Equal  ${elog_entry[0]["Resolved"]}  ${False}
4022e092d04Sdnirmala
4032e092d04Sdnirmala
4048cca7fb8SGeorge Keishing*** Keywords ***
4058cca7fb8SGeorge Keishing
4062f36947bSGeorge KeishingSuite Setup Execution
4072f36947bSGeorge Keishing   [Documentation]  Do test case setup tasks.
4082f36947bSGeorge Keishing
4092f36947bSGeorge Keishing    Redfish.Login
4102f36947bSGeorge Keishing
4112f36947bSGeorge Keishing    Redfish Purge Event Log
4122f36947bSGeorge Keishing
4132f36947bSGeorge Keishing    ${status}=  Run Keyword And Return Status  Logging Test Binary Exist
4142f36947bSGeorge Keishing    Run Keyword If  ${status} == ${False}  Install Tarball
4152f36947bSGeorge Keishing
4162f36947bSGeorge Keishing
4178cca7fb8SGeorge KeishingSuite Teardown Execution
4188cca7fb8SGeorge Keishing    [Documentation]  Do the post suite teardown.
4198cca7fb8SGeorge Keishing
4208cca7fb8SGeorge Keishing    Redfish.Logout
4218cca7fb8SGeorge Keishing
4228cca7fb8SGeorge Keishing
423b0a491f2SGeorge KeishingTest Setup Execution
4248cca7fb8SGeorge Keishing   [Documentation]  Do test case setup tasks.
4258cca7fb8SGeorge Keishing
4260b76e421SGeorge Keishing    Redfish Purge Event Log
4270b76e421SGeorge Keishing
4288cca7fb8SGeorge Keishing    ${status}=  Run Keyword And Return Status  Logging Test Binary Exist
4298cca7fb8SGeorge Keishing    Run Keyword If  ${status} == ${False}  Install Tarball
4308cca7fb8SGeorge Keishing
4318cca7fb8SGeorge Keishing
4328cca7fb8SGeorge KeishingTest Teardown Execution
4338cca7fb8SGeorge Keishing    [Documentation]  Do the post test teardown.
4348cca7fb8SGeorge Keishing
4358cca7fb8SGeorge Keishing    FFDC On Test Case Fail
436e5c5ebdfSGeorge Keishing    Redfish.Login
437b0a491f2SGeorge Keishing    Redfish Purge Event Log
4388cca7fb8SGeorge Keishing
4398cca7fb8SGeorge Keishing
44020c08e41SRahul MaheshwariGet Redfish Error Entries
44120c08e41SRahul Maheshwari    [Documentation]  Return Redfish error ids list.
442c32434a3SYi Hu    ${error_uris}=  redfish_utils.get_member_list  /redfish/v1/Systems/${SYSTEM_ID}/LogServices/EventLog/Entries
44320c08e41SRahul Maheshwari    ${error_ids}=  Create List
44420c08e41SRahul Maheshwari
44520c08e41SRahul Maheshwari    FOR  ${error_uri}  IN  @{error_uris}
44620c08e41SRahul Maheshwari      ${error_id}=  Fetch From Right  ${error_uri}  /
44720c08e41SRahul Maheshwari      Append To List  ${error_ids}  ${error_id}
44820c08e41SRahul Maheshwari    END
44920c08e41SRahul Maheshwari
45020c08e41SRahul Maheshwari    [Return]  ${error_ids}
45120c08e41SRahul Maheshwari
45220c08e41SRahul Maheshwari
4538cca7fb8SGeorge KeishingEvent Log Should Not Exist
4548cca7fb8SGeorge Keishing    [Documentation]  Event log entries should not exist.
4558cca7fb8SGeorge Keishing
4568cca7fb8SGeorge Keishing    ${elogs}=  Get Event Logs
4578cca7fb8SGeorge Keishing    Should Be Empty  ${elogs}  msg=System event log entry is not empty.
458b0a491f2SGeorge Keishing
459b0a491f2SGeorge Keishing
460b0a491f2SGeorge KeishingEvent Log Should Exist
461b0a491f2SGeorge Keishing    [Documentation]  Event log entries should exist.
462b0a491f2SGeorge Keishing
463b0a491f2SGeorge Keishing    ${elogs}=  Get Event Logs
464b0a491f2SGeorge Keishing    Should Not Be Empty  ${elogs}  msg=System event log entry is not empty.
465d35b5319SGeorge Keishing
466d35b5319SGeorge Keishing
467d35b5319SGeorge KeishingVerify Watchdog EventLog Content
468d35b5319SGeorge Keishing    [Documentation]  Verify watchdog event log content.
469d35b5319SGeorge Keishing
470d35b5319SGeorge Keishing    # Example:
471d35b5319SGeorge Keishing    # {
472d35b5319SGeorge Keishing    #    "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
473d35b5319SGeorge Keishing    #    "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/31",
474d35b5319SGeorge Keishing    #    "@odata.type": "#LogEntry.v1_4_0.LogEntry",
475d35b5319SGeorge Keishing    #    "Created": "2019-05-31T18:41:33+00:00",
476d35b5319SGeorge Keishing    #    "EntryType": "Event",
477d35b5319SGeorge Keishing    #    "Id": "31",
478d35b5319SGeorge Keishing    #    "Message": "org.open_power.Host.Boot.Error.WatchdogTimedOut",
479d35b5319SGeorge Keishing    #    "Name": "System DBus Event Log Entry",
480d35b5319SGeorge Keishing    #    "Severity": "Critical"
481d35b5319SGeorge Keishing    # }
482d35b5319SGeorge Keishing
4832ab62414SGeorge Keishing    ${elog_list}=  Get Event Logs
4842ab62414SGeorge Keishing
4852ab62414SGeorge Keishing    Rprint Vars  elog_list
4862ab62414SGeorge Keishing
4872ab62414SGeorge Keishing    FOR  ${entry}  IN  @{elog_list}
4882ab62414SGeorge Keishing        ${found_match}=  Run Keyword And Return Status  Is Watchdog Error Found  ${entry}
4892ab62414SGeorge Keishing        Exit For Loop If  '${found_match}' == 'True'
4902ab62414SGeorge Keishing    END
4912ab62414SGeorge Keishing
4922ab62414SGeorge Keishing    Run Keyword If  '${found_match}' == 'False'  Fail  msg=No watchdog error logged.
4932ab62414SGeorge Keishing
4942ab62414SGeorge Keishing
4952ab62414SGeorge KeishingIs Watchdog Error Found
4962ab62414SGeorge Keishing    [Documentation]  Check if the give log entry matches specific watchdog error.
4972ab62414SGeorge Keishing    [Arguments]  ${elog}
4982ab62414SGeorge Keishing
4992ab62414SGeorge Keishing    # Description of argument(s):
5002ab62414SGeorge Keishing    # elog   Error log entry dictionary data.
5012ab62414SGeorge Keishing
5022ab62414SGeorge Keishing    Should Contain Any
5032ab62414SGeorge Keishing    ...  ${elog["Message"]}  org.open_power.Host.Boot.Error.WatchdogTimedOut
5042ab62414SGeorge Keishing    ...  CEC Hardware - Hostboot-Service Processor Interface
505d35b5319SGeorge Keishing    ...  msg=Watchdog timeout event log was not found.
5062ab62414SGeorge Keishing
5072ab62414SGeorge Keishing    Log To Console  Matched Found: ${elog}
508