xref: /openbmc/openbmc-test-automation/redfish/systems/eventlog/test_event_logging.robot (revision 8fe6024e813a06cf2ce756da64607708aa83cc4a)
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
8*8fe6024eSGeorge KeishingResource            ../../../lib/ipmi_client.robot
98cca7fb8SGeorge Keishing
10b0a491f2SGeorge KeishingTest Setup          Test Setup Execution
118cca7fb8SGeorge KeishingTest Teardown       Test Teardown Execution
12b0a491f2SGeorge KeishingSuite Teardown      Suite Teardown Execution
138cca7fb8SGeorge Keishing
148cca7fb8SGeorge Keishing*** Test Cases ***
158cca7fb8SGeorge Keishing
168cca7fb8SGeorge KeishingEvent Log Check After BMC Reboot
178cca7fb8SGeorge Keishing    [Documentation]  Check event log after BMC rebooted.
188cca7fb8SGeorge Keishing    [Tags]  Event_Log_Check_After_BMC_Reboot
198cca7fb8SGeorge Keishing
208cca7fb8SGeorge Keishing    Redfish Purge Event Log
218cca7fb8SGeorge Keishing    Event Log Should Not Exist
228cca7fb8SGeorge Keishing
238cca7fb8SGeorge Keishing    Redfish OBMC Reboot (off)
248cca7fb8SGeorge Keishing
258cca7fb8SGeorge Keishing    Redfish.Login
268cca7fb8SGeorge Keishing    Wait Until Keyword Succeeds  1 mins  15 secs   Redfish.Get  ${EVENT_LOG_URI}Entries
278cca7fb8SGeorge Keishing
288cca7fb8SGeorge Keishing    Event Log Should Not Exist
298cca7fb8SGeorge Keishing
308cca7fb8SGeorge Keishing
31b0a491f2SGeorge KeishingEvent Log Check After Host Poweron
32b0a491f2SGeorge Keishing    [Documentation]  Check event log after host has booted.
33b0a491f2SGeorge Keishing    [Tags]  Event_Log_Check_After_Host_Poweron
34b0a491f2SGeorge Keishing
35b0a491f2SGeorge Keishing    Redfish Purge Event Log
36b0a491f2SGeorge Keishing    Event Log Should Not Exist
37b0a491f2SGeorge Keishing
38b0a491f2SGeorge Keishing    Redfish Power On
39b0a491f2SGeorge Keishing
40b0a491f2SGeorge Keishing    Redfish.Login
41b0a491f2SGeorge Keishing    Event Log Should Not Exist
42b0a491f2SGeorge Keishing
43b0a491f2SGeorge Keishing
44b0a491f2SGeorge KeishingCreate Test Event Log And Verify
45b0a491f2SGeorge Keishing    [Documentation]  Create event logs and verify via redfish.
46b0a491f2SGeorge Keishing    [Tags]  Create_Test_Event_Log_And_Verify
47b0a491f2SGeorge Keishing
48b0a491f2SGeorge Keishing    Create Test Error Log
49b0a491f2SGeorge Keishing    Event Log Should Exist
50b0a491f2SGeorge Keishing
51b0a491f2SGeorge Keishing
52b0a491f2SGeorge KeishingTest Event Log Persistency On Restart
53b0a491f2SGeorge Keishing    [Documentation]  Restart logging service and verify event logs.
54b0a491f2SGeorge Keishing    [Tags]  Test_Event_Log_Persistency_On_Restart
55b0a491f2SGeorge Keishing
56b0a491f2SGeorge Keishing    Create Test Error Log
57b0a491f2SGeorge Keishing    Event Log Should Exist
58b0a491f2SGeorge Keishing
59b0a491f2SGeorge Keishing    BMC Execute Command
60b0a491f2SGeorge Keishing    ...  systemctl restart xyz.openbmc_project.Logging.service
61b0a491f2SGeorge Keishing    Sleep  10s  reason=Wait for logging service to restart properly.
62b0a491f2SGeorge Keishing
63b0a491f2SGeorge Keishing    Event Log Should Exist
64b0a491f2SGeorge Keishing
65b0a491f2SGeorge Keishing
66b0a491f2SGeorge KeishingTest Event Entry Numbering Reset On Restart
67b0a491f2SGeorge Keishing    [Documentation]  Restart logging service and verify event logs entry starts
68b0a491f2SGeorge Keishing    ...  from entry "Id" 1.
69b0a491f2SGeorge Keishing    [Tags]  Test_Event_Entry_Numbering_Reset_On_Restart
70b0a491f2SGeorge Keishing
71b0a491f2SGeorge Keishing    #{
72b0a491f2SGeorge Keishing    #  "@odata.context": "/redfish/v1/$metadata#LogEntryCollection.LogEntryCollection",
73b0a491f2SGeorge Keishing    #  "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries",
74b0a491f2SGeorge Keishing    #  "@odata.type": "#LogEntryCollection.LogEntryCollection",
75b0a491f2SGeorge Keishing    #  "Description": "Collection of System Event Log Entries",
76b0a491f2SGeorge Keishing    #  "Members": [
77b0a491f2SGeorge Keishing    #  {
78b0a491f2SGeorge Keishing    #    "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
79b0a491f2SGeorge Keishing    #    "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1",
80b0a491f2SGeorge Keishing    #    "@odata.type": "#LogEntry.v1_4_0.LogEntry",
81b0a491f2SGeorge Keishing    #    "Created": "2019-05-29T13:19:27+00:00",
82b0a491f2SGeorge Keishing    #    "EntryType": "Event",
83b0a491f2SGeorge Keishing    #    "Id": "1",               <----- Event log ID
84b0a491f2SGeorge Keishing    #    "Message": "org.open_power.Host.Error.Event",
85b0a491f2SGeorge Keishing    #    "Name": "System DBus Event Log Entry",
86b0a491f2SGeorge Keishing    #    "Severity": "Critical"
87b0a491f2SGeorge Keishing    #  }
88b0a491f2SGeorge Keishing    #  ],
89b0a491f2SGeorge Keishing    #  "Members@odata.count": 1,
90b0a491f2SGeorge Keishing    #  "Name": "System Event Log Entries"
91b0a491f2SGeorge Keishing    #}
92b0a491f2SGeorge Keishing
93b0a491f2SGeorge Keishing    Create Test Error Log
94b0a491f2SGeorge Keishing    Create Test Error Log
95b0a491f2SGeorge Keishing    Event Log Should Exist
96b0a491f2SGeorge Keishing
97b0a491f2SGeorge Keishing    Redfish Purge Event Log
98b0a491f2SGeorge Keishing    Event Log Should Not Exist
99b0a491f2SGeorge Keishing
100b0a491f2SGeorge Keishing    BMC Execute Command
101b0a491f2SGeorge Keishing    ...  systemctl restart xyz.openbmc_project.Logging.service
102b0a491f2SGeorge Keishing    Sleep  10s  reason=Wait for logging service to restart properly.
103b0a491f2SGeorge Keishing
104b0a491f2SGeorge Keishing    Create Test Error Log
105b0a491f2SGeorge Keishing    ${elogs}=  Get Event Logs
106b0a491f2SGeorge Keishing    Should Be Equal  ${elogs[0]["Id"]}  1  msg=Event log entry is not 1.
107b0a491f2SGeorge Keishing
108b0a491f2SGeorge Keishing
109b0a491f2SGeorge KeishingTest Event Log Persistency On Reboot
110b0a491f2SGeorge Keishing    [Documentation]  Reboot BMC and verify event log.
111b0a491f2SGeorge Keishing    [Tags]  Test_Event_Log_Persistency_On_Reboot
112b0a491f2SGeorge Keishing
113b0a491f2SGeorge Keishing    Redfish Purge Event Log
114b0a491f2SGeorge Keishing    Create Test Error Log
115b0a491f2SGeorge Keishing    Event Log Should Exist
116b0a491f2SGeorge Keishing
117b0a491f2SGeorge Keishing    Redfish OBMC Reboot (off)
118b0a491f2SGeorge Keishing
119b0a491f2SGeorge Keishing    Redfish.Login
120b0a491f2SGeorge Keishing    Wait Until Keyword Succeeds  1 mins  15 secs   Redfish.Get  ${EVENT_LOG_URI}Entries
121b0a491f2SGeorge Keishing
122b0a491f2SGeorge Keishing    Event Log Should Exist
123b0a491f2SGeorge Keishing
124b0a491f2SGeorge Keishing
125148d08c2SGeorge KeishingCreate Test Event Log And Verify Time Stamp
126148d08c2SGeorge Keishing    [Documentation]  Create event logs and verify time stamp.
127148d08c2SGeorge Keishing    [Tags]  Create_Test_Event_Log_And_Verify_Time_Stamp
128148d08c2SGeorge Keishing
129148d08c2SGeorge Keishing    #{
130148d08c2SGeorge Keishing    #  "@odata.context": "/redfish/v1/$metadata#LogEntryCollection.LogEntryCollection",
131148d08c2SGeorge Keishing    #  "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries",
132148d08c2SGeorge Keishing    #  "@odata.type": "#LogEntryCollection.LogEntryCollection",
133148d08c2SGeorge Keishing    #  "Description": "Collection of System Event Log Entries",
134148d08c2SGeorge Keishing    #  "Members": [
135148d08c2SGeorge Keishing    #  {
136148d08c2SGeorge Keishing    #    "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
137148d08c2SGeorge Keishing    #    "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1",
138148d08c2SGeorge Keishing    #    "@odata.type": "#LogEntry.v1_4_0.LogEntry",
139148d08c2SGeorge Keishing    #    "Created": "2019-05-29T13:19:27+00:00", <--- Time stamp
140148d08c2SGeorge Keishing    #    "EntryType": "Event",
141148d08c2SGeorge Keishing    #    "Id": "1",
142148d08c2SGeorge Keishing    #    "Message": "org.open_power.Host.Error.Event",
143148d08c2SGeorge Keishing    #    "Name": "System DBus Event Log Entry",
144148d08c2SGeorge Keishing    #    "Severity": "Critical"
145148d08c2SGeorge Keishing    #  }
146148d08c2SGeorge Keishing    #  ],
147148d08c2SGeorge Keishing    #  "Members@odata.count": 1,
148148d08c2SGeorge Keishing    #  "Name": "System Event Log Entries"
149148d08c2SGeorge Keishing    #}
150148d08c2SGeorge Keishing
151148d08c2SGeorge Keishing    Redfish Purge Event Log
152148d08c2SGeorge Keishing
153148d08c2SGeorge Keishing    Create Test Error Log
154148d08c2SGeorge Keishing    Sleep  2s
155148d08c2SGeorge Keishing    Create Test Error Log
156148d08c2SGeorge Keishing
157148d08c2SGeorge Keishing    ${elog_entry}=  Get Event Logs
158148d08c2SGeorge Keishing
159148d08c2SGeorge Keishing    # The event log generated is associated with the epoc time and unique
160148d08c2SGeorge Keishing    # for every error and in increasing time stamp.
161148d08c2SGeorge Keishing    ${time_stamp1}=  Convert Date  ${elog_entry[0]["Created"]}  epoch
162148d08c2SGeorge Keishing    ${time_stamp2}=  Convert Date  ${elog_entry[1]["Created"]}  epoch
163148d08c2SGeorge Keishing
164148d08c2SGeorge Keishing    Should Be True  ${time_stamp2} > ${time_stamp1}
165148d08c2SGeorge Keishing
166148d08c2SGeorge Keishing
1670b76e421SGeorge KeishingDelete Non Existing SEL Event Entry
1680b76e421SGeorge Keishing    [Documentation]  Delete non existing SEL event entry.
1690b76e421SGeorge Keishing    [Tags]  Delete_Non_Existing_SEL_Event_Entry
1700b76e421SGeorge Keishing
1710b76e421SGeorge Keishing    ${sel_delete}=  Run Keyword And Expect Error  *
1720b76e421SGeorge Keishing    ...  Run IPMI Standard Command  sel delete 100
1730b76e421SGeorge Keishing    Should Contain  ${sel_delete}  Unable to delete entry
1740b76e421SGeorge Keishing    ...  case_insensitive=True
1750b76e421SGeorge Keishing
1760b76e421SGeorge Keishing
1770b76e421SGeorge KeishingDelete Invalid SEL Event Entry
1780b76e421SGeorge Keishing    [Documentation]  Delete invalid SEL event entry.
1790b76e421SGeorge Keishing    [Tags]  Delete_Invalid_SEL_Event_Entry
1800b76e421SGeorge Keishing
1810b76e421SGeorge Keishing    ${sel_delete}=  Run Keyword And Expect Error  *
1820b76e421SGeorge Keishing    ...  Run IPMI Standard Command  sel delete abc
1830b76e421SGeorge Keishing    Should Contain  ${sel_delete}  Given SEL ID 'abc' is invalid
1840b76e421SGeorge Keishing    ...  case_insensitive=True
1850b76e421SGeorge Keishing
1860b76e421SGeorge Keishing
1870b76e421SGeorge KeishingVerify IPMI SEL Event Entries
1880b76e421SGeorge Keishing    [Documentation]  Verify IPMI SEL's entries info.
1890b76e421SGeorge Keishing    [Tags]  Verify_IPMI_SEL_Event_Entries
1900b76e421SGeorge Keishing
1910b76e421SGeorge Keishing    # Generate error logs of random count.
1920b76e421SGeorge Keishing    ${count}=  Evaluate  random.randint(1, 5)  modules=random
1930b76e421SGeorge Keishing    Repeat Keyword  ${count}  Create Test Error Log
1940b76e421SGeorge Keishing
1950b76e421SGeorge Keishing    ${sel_entries_count}=  Get IPMI SEL Setting  Entries
1960b76e421SGeorge Keishing    Should Be Equal As Strings  ${sel_entries_count}  ${count}
1970b76e421SGeorge Keishing
1980b76e421SGeorge Keishing
1990b76e421SGeorge KeishingVerify IPMI SEL Event Last Add Time
2000b76e421SGeorge Keishing    [Documentation]  Verify IPMI SEL's last added timestamp.
2010b76e421SGeorge Keishing    [Tags]  Verify_IPMI_SEL_Event_Last_Add_Time
2020b76e421SGeorge Keishing
2030b76e421SGeorge Keishing    Create Test Error Log
2040b76e421SGeorge Keishing    ${sel_time}=  Run IPMI Standard Command  sel time get
2050b76e421SGeorge Keishing    ${sel_time}=  Convert Date  ${sel_time}
2060b76e421SGeorge Keishing    ...  date_format=%m/%d/%Y %H:%M:%S  exclude_millis=True
2070b76e421SGeorge Keishing
2080b76e421SGeorge Keishing    ${sel_last_add_time}=  Get IPMI SEL Setting  Last Add Time
2090b76e421SGeorge Keishing    ${sel_last_add_time}=  Convert Date  ${sel_last_add_time}
2100b76e421SGeorge Keishing    ...  date_format=%m/%d/%Y %H:%M:%S  exclude_millis=True
2110b76e421SGeorge Keishing
2120b76e421SGeorge Keishing    ${time_diff}=
2130b76e421SGeorge Keishing    ...  Subtract Date From Date  ${sel_last_add_time}  ${sel_time}
2140b76e421SGeorge Keishing
2150b76e421SGeorge Keishing    # Verify if the delay in current time check and last add SEL time
2160b76e421SGeorge Keishing    # is less or equals to 2 seconds.
2170b76e421SGeorge Keishing    Should Be True  ${time_diff} <= 2
2180b76e421SGeorge Keishing
2190b76e421SGeorge Keishing
220d35b5319SGeorge KeishingCreate Test Event Log And Delete
221d35b5319SGeorge Keishing    [Documentation]  Create an event log and delete it.
222d35b5319SGeorge Keishing    [Tags]  Create_Test_Event_Log_And_Delete
223d35b5319SGeorge Keishing
224d35b5319SGeorge Keishing    Create Test Error Log
225d35b5319SGeorge Keishing    Redfish Purge Event Log
226d35b5319SGeorge Keishing    Event Log Should Not Exist
227d35b5319SGeorge Keishing
228d35b5319SGeorge Keishing
229d35b5319SGeorge KeishingCreate Multiple Test Event Logs And Delete All
230d35b5319SGeorge Keishing    [Documentation]  Create multiple event logs and delete all.
231d35b5319SGeorge Keishing    [Tags]  Create_Multiple_Test_Event_Logs_And_Delete_All
232d35b5319SGeorge Keishing
233d35b5319SGeorge Keishing    Create Test Error Log
234d35b5319SGeorge Keishing    Create Test Error Log
235d35b5319SGeorge Keishing    Create Test Error Log
236d35b5319SGeorge Keishing    Redfish Purge Event Log
237d35b5319SGeorge Keishing    Event Log Should Not Exist
238d35b5319SGeorge Keishing
239d35b5319SGeorge Keishing
240d35b5319SGeorge KeishingVerify Watchdog Timedout Event
241d35b5319SGeorge Keishing    [Documentation]  Trigger watchdog timed out and verify event log generated.
242d35b5319SGeorge Keishing    [Tags]  Verify_Watchdog_Timedout_Event
243d35b5319SGeorge Keishing
244d35b5319SGeorge Keishing    Redfish Power On
245d35b5319SGeorge Keishing
246d35b5319SGeorge Keishing    # Clear errors if there are any.
247d35b5319SGeorge Keishing    Redfish.Login
248d35b5319SGeorge Keishing    Redfish Purge Event Log
249d35b5319SGeorge Keishing
250d35b5319SGeorge Keishing    Trigger Host Watchdog Error
251d35b5319SGeorge Keishing
252d35b5319SGeorge Keishing    # Logging takes time to generate the timeout error.
253d35b5319SGeorge Keishing    Wait Until Keyword Succeeds  2 min  30 sec
254d35b5319SGeorge Keishing    ...  Verify Watchdog EventLog Content
255d35b5319SGeorge Keishing
256d35b5319SGeorge Keishing    Redfish Power Off
257d35b5319SGeorge Keishing
258d35b5319SGeorge Keishing
259d35b5319SGeorge KeishingVerify Event Logs Capping
260d35b5319SGeorge Keishing    [Documentation]  Verify event logs capping.
261d35b5319SGeorge Keishing    [Tags]  Verify_Event_Logs_Capping
262d35b5319SGeorge Keishing
263d35b5319SGeorge Keishing    Redfish Purge Event Log
264d35b5319SGeorge Keishing
265d35b5319SGeorge Keishing    ${cmd}=  Catenate  for i in {1..201}; do /tmp/tarball/bin/logging-test -c
266d35b5319SGeorge Keishing    ...  AutoTestSimple; done
267d35b5319SGeorge Keishing    BMC Execute Command  ${cmd}
268d35b5319SGeorge Keishing
269d35b5319SGeorge Keishing    ${elogs}=  Get Event Logs
270d35b5319SGeorge Keishing    ${count}=  Get Length  ${elogs}
271d35b5319SGeorge Keishing    Run Keyword If  ${count} > 200
272d35b5319SGeorge Keishing    ...  Fail  Error logs created exceeded max capacity 200.
273d35b5319SGeorge Keishing
274d35b5319SGeorge Keishing
2758cca7fb8SGeorge Keishing*** Keywords ***
2768cca7fb8SGeorge Keishing
2778cca7fb8SGeorge KeishingSuite Teardown Execution
2788cca7fb8SGeorge Keishing    [Documentation]  Do the post suite teardown.
2798cca7fb8SGeorge Keishing
2808cca7fb8SGeorge Keishing    Redfish.Logout
2818cca7fb8SGeorge Keishing
2828cca7fb8SGeorge Keishing
283b0a491f2SGeorge KeishingTest Setup Execution
2848cca7fb8SGeorge Keishing   [Documentation]  Do test case setup tasks.
2858cca7fb8SGeorge Keishing
2868cca7fb8SGeorge Keishing    Redfish.Login
2878cca7fb8SGeorge Keishing
2880b76e421SGeorge Keishing    Redfish Purge Event Log
2890b76e421SGeorge Keishing
2908cca7fb8SGeorge Keishing    ${status}=  Run Keyword And Return Status  Logging Test Binary Exist
2918cca7fb8SGeorge Keishing    Run Keyword If  ${status} == ${False}  Install Tarball
2928cca7fb8SGeorge Keishing
2938cca7fb8SGeorge Keishing
2948cca7fb8SGeorge KeishingTest Teardown Execution
2958cca7fb8SGeorge Keishing    [Documentation]  Do the post test teardown.
2968cca7fb8SGeorge Keishing
2978cca7fb8SGeorge Keishing    FFDC On Test Case Fail
298b0a491f2SGeorge Keishing    Redfish Purge Event Log
2998cca7fb8SGeorge Keishing
3008cca7fb8SGeorge Keishing
3018cca7fb8SGeorge KeishingEvent Log Should Not Exist
3028cca7fb8SGeorge Keishing    [Documentation]  Event log entries should not exist.
3038cca7fb8SGeorge Keishing
3048cca7fb8SGeorge Keishing    ${elogs}=  Get Event Logs
3058cca7fb8SGeorge Keishing    Should Be Empty  ${elogs}  msg=System event log entry is not empty.
306b0a491f2SGeorge Keishing
307b0a491f2SGeorge Keishing
308b0a491f2SGeorge KeishingEvent Log Should Exist
309b0a491f2SGeorge Keishing    [Documentation]  Event log entries should exist.
310b0a491f2SGeorge Keishing
311b0a491f2SGeorge Keishing    ${elogs}=  Get Event Logs
312b0a491f2SGeorge Keishing    Should Not Be Empty  ${elogs}  msg=System event log entry is not empty.
313d35b5319SGeorge Keishing
314d35b5319SGeorge Keishing
315d35b5319SGeorge KeishingVerify Watchdog EventLog Content
316d35b5319SGeorge Keishing    [Documentation]  Verify watchdog event log content.
317d35b5319SGeorge Keishing
318d35b5319SGeorge Keishing    # Example:
319d35b5319SGeorge Keishing    # {
320d35b5319SGeorge Keishing    #    "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
321d35b5319SGeorge Keishing    #    "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/31",
322d35b5319SGeorge Keishing    #    "@odata.type": "#LogEntry.v1_4_0.LogEntry",
323d35b5319SGeorge Keishing    #    "Created": "2019-05-31T18:41:33+00:00",
324d35b5319SGeorge Keishing    #    "EntryType": "Event",
325d35b5319SGeorge Keishing    #    "Id": "31",
326d35b5319SGeorge Keishing    #    "Message": "org.open_power.Host.Boot.Error.WatchdogTimedOut",
327d35b5319SGeorge Keishing    #    "Name": "System DBus Event Log Entry",
328d35b5319SGeorge Keishing    #    "Severity": "Critical"
329d35b5319SGeorge Keishing    # }
330d35b5319SGeorge Keishing
331d35b5319SGeorge Keishing    ${elog}=  Get Event Logs
332d35b5319SGeorge Keishing    Should Be Equal As Strings
333d35b5319SGeorge Keishing    ...  ${elog[0]["Message"]}  org.open_power.Host.Boot.Error.WatchdogTimedOut
334d35b5319SGeorge Keishing    ...  msg=Watchdog timeout event log was not found.
335d35b5319SGeorge Keishing    Should Be Equal As Strings
336d35b5319SGeorge Keishing    ...  ${elog[0]["Severity"]}  Critical
337d35b5319SGeorge Keishing    ...  msg=Watchdog timeout severity unexpected value.
338