xref: /openbmc/openbmc-test-automation/redfish/systems/eventlog/test_event_logging.robot (revision 6462f26d1f19f537ff23b37eea63c15d2070c51e)
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
16759c6f97SGeorge Keishing** Variables ***
17759c6f97SGeorge Keishing
18759c6f97SGeorge Keishing${max_num_event_logs}  ${200}
19759c6f97SGeorge Keishing
208cca7fb8SGeorge Keishing*** Test Cases ***
218cca7fb8SGeorge Keishing
228cca7fb8SGeorge KeishingEvent Log Check After BMC Reboot
238cca7fb8SGeorge Keishing    [Documentation]  Check event log after BMC rebooted.
248cca7fb8SGeorge Keishing    [Tags]  Event_Log_Check_After_BMC_Reboot
258cca7fb8SGeorge Keishing
268cca7fb8SGeorge Keishing    Redfish Purge Event Log
278cca7fb8SGeorge Keishing    Event Log Should Not Exist
288cca7fb8SGeorge Keishing
298cca7fb8SGeorge Keishing    Redfish OBMC Reboot (off)
308cca7fb8SGeorge Keishing
318cca7fb8SGeorge Keishing    Redfish.Login
328cca7fb8SGeorge Keishing    Wait Until Keyword Succeeds  1 mins  15 secs   Redfish.Get  ${EVENT_LOG_URI}Entries
338cca7fb8SGeorge Keishing
348cca7fb8SGeorge Keishing    Event Log Should Not Exist
358cca7fb8SGeorge Keishing
368cca7fb8SGeorge Keishing
37b0a491f2SGeorge KeishingEvent Log Check After Host Poweron
38b0a491f2SGeorge Keishing    [Documentation]  Check event log after host has booted.
39b0a491f2SGeorge Keishing    [Tags]  Event_Log_Check_After_Host_Poweron
40b0a491f2SGeorge Keishing
41b0a491f2SGeorge Keishing    Redfish Purge Event Log
42b0a491f2SGeorge Keishing    Event Log Should Not Exist
43b0a491f2SGeorge Keishing
44b0a491f2SGeorge Keishing    Redfish Power On
45b0a491f2SGeorge Keishing
46b0a491f2SGeorge Keishing    Redfish.Login
47b0a491f2SGeorge Keishing    Event Log Should Not Exist
48b0a491f2SGeorge Keishing
49b0a491f2SGeorge Keishing
50b0a491f2SGeorge KeishingCreate Test Event Log And Verify
51b0a491f2SGeorge Keishing    [Documentation]  Create event logs and verify via redfish.
52b0a491f2SGeorge Keishing    [Tags]  Create_Test_Event_Log_And_Verify
53b0a491f2SGeorge Keishing
54b0a491f2SGeorge Keishing    Create Test Error Log
55b0a491f2SGeorge Keishing    Event Log Should Exist
56b0a491f2SGeorge Keishing
57b0a491f2SGeorge Keishing
5820c08e41SRahul MaheshwariDelete Redfish Event Log And Verify
5920c08e41SRahul Maheshwari    [Documentation]  Delete Redfish event log and verify via Redfish.
6020c08e41SRahul Maheshwari    [Tags]  Delete_Redfish_Event_Log_And_Verify
6120c08e41SRahul Maheshwari
6220c08e41SRahul Maheshwari    Redfish.Login
6320c08e41SRahul Maheshwari    Redfish Purge Event Log
6420c08e41SRahul Maheshwari    Create Test PEL Log
6520c08e41SRahul Maheshwari    ${elog_entry}=  Get Event Logs
6620c08e41SRahul Maheshwari
6720c08e41SRahul Maheshwari    Redfish.Delete  /redfish/v1/Systems/system/LogServices/EventLog/Entries/${elog_entry[0]["Id"]}
6820c08e41SRahul Maheshwari
6920c08e41SRahul Maheshwari    ${error_entries}=  Get Redfish Error Entries
7020c08e41SRahul Maheshwari    Should Be Empty  ${error_entries}
7120c08e41SRahul Maheshwari
7220c08e41SRahul Maheshwari
73b0a491f2SGeorge KeishingTest Event Log Persistency On Restart
74b0a491f2SGeorge Keishing    [Documentation]  Restart logging service and verify event logs.
75b0a491f2SGeorge Keishing    [Tags]  Test_Event_Log_Persistency_On_Restart
76b0a491f2SGeorge Keishing
77b0a491f2SGeorge Keishing    Create Test Error Log
78b0a491f2SGeorge Keishing    Event Log Should Exist
79b0a491f2SGeorge Keishing
80b0a491f2SGeorge Keishing    BMC Execute Command
81b0a491f2SGeorge Keishing    ...  systemctl restart xyz.openbmc_project.Logging.service
82b0a491f2SGeorge Keishing    Sleep  10s  reason=Wait for logging service to restart properly.
83b0a491f2SGeorge Keishing
84b0a491f2SGeorge Keishing    Event Log Should Exist
85b0a491f2SGeorge Keishing
86b0a491f2SGeorge Keishing
87b0a491f2SGeorge KeishingTest Event Entry Numbering Reset On Restart
88b0a491f2SGeorge Keishing    [Documentation]  Restart logging service and verify event logs entry starts
89b0a491f2SGeorge Keishing    ...  from entry "Id" 1.
90b0a491f2SGeorge Keishing    [Tags]  Test_Event_Entry_Numbering_Reset_On_Restart
91b0a491f2SGeorge Keishing
92b0a491f2SGeorge Keishing    #{
93b0a491f2SGeorge Keishing    #  "@odata.context": "/redfish/v1/$metadata#LogEntryCollection.LogEntryCollection",
94b0a491f2SGeorge Keishing    #  "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries",
95b0a491f2SGeorge Keishing    #  "@odata.type": "#LogEntryCollection.LogEntryCollection",
96b0a491f2SGeorge Keishing    #  "Description": "Collection of System Event Log Entries",
97b0a491f2SGeorge Keishing    #  "Members": [
98b0a491f2SGeorge Keishing    #  {
99b0a491f2SGeorge Keishing    #    "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
100b0a491f2SGeorge Keishing    #    "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1",
101b0a491f2SGeorge Keishing    #    "@odata.type": "#LogEntry.v1_4_0.LogEntry",
102b0a491f2SGeorge Keishing    #    "Created": "2019-05-29T13:19:27+00:00",
103b0a491f2SGeorge Keishing    #    "EntryType": "Event",
104b0a491f2SGeorge Keishing    #    "Id": "1",               <----- Event log ID
105b0a491f2SGeorge Keishing    #    "Message": "org.open_power.Host.Error.Event",
106b0a491f2SGeorge Keishing    #    "Name": "System DBus Event Log Entry",
107b0a491f2SGeorge Keishing    #    "Severity": "Critical"
108b0a491f2SGeorge Keishing    #  }
109b0a491f2SGeorge Keishing    #  ],
110b0a491f2SGeorge Keishing    #  "Members@odata.count": 1,
111b0a491f2SGeorge Keishing    #  "Name": "System Event Log Entries"
112b0a491f2SGeorge Keishing    #}
113b0a491f2SGeorge Keishing
114b0a491f2SGeorge Keishing    Create Test Error Log
115b0a491f2SGeorge Keishing    Create Test Error Log
116b0a491f2SGeorge Keishing    Event Log Should Exist
117b0a491f2SGeorge Keishing
118b0a491f2SGeorge Keishing    Redfish Purge Event Log
119b0a491f2SGeorge Keishing    Event Log Should Not Exist
120b0a491f2SGeorge Keishing
121b0a491f2SGeorge Keishing    BMC Execute Command
122b0a491f2SGeorge Keishing    ...  systemctl restart xyz.openbmc_project.Logging.service
123b0a491f2SGeorge Keishing    Sleep  10s  reason=Wait for logging service to restart properly.
124b0a491f2SGeorge Keishing
125b0a491f2SGeorge Keishing    Create Test Error Log
126b0a491f2SGeorge Keishing    ${elogs}=  Get Event Logs
127b0a491f2SGeorge Keishing    Should Be Equal  ${elogs[0]["Id"]}  1  msg=Event log entry is not 1.
128b0a491f2SGeorge Keishing
129b0a491f2SGeorge Keishing
130b0a491f2SGeorge KeishingTest Event Log Persistency On Reboot
131b0a491f2SGeorge Keishing    [Documentation]  Reboot BMC and verify event log.
132b0a491f2SGeorge Keishing    [Tags]  Test_Event_Log_Persistency_On_Reboot
133b0a491f2SGeorge Keishing
134b0a491f2SGeorge Keishing    Redfish Purge Event Log
135b0a491f2SGeorge Keishing    Create Test Error Log
136b0a491f2SGeorge Keishing    Event Log Should Exist
137b0a491f2SGeorge Keishing
138b0a491f2SGeorge Keishing    Redfish OBMC Reboot (off)
139b0a491f2SGeorge Keishing
140b0a491f2SGeorge Keishing    Redfish.Login
141b0a491f2SGeorge Keishing    Wait Until Keyword Succeeds  1 mins  15 secs   Redfish.Get  ${EVENT_LOG_URI}Entries
142b0a491f2SGeorge Keishing
143b0a491f2SGeorge Keishing    Event Log Should Exist
144b0a491f2SGeorge Keishing
145b0a491f2SGeorge Keishing
146ddbc88c7SGeorge Keishing# TODO: openbmc/openbmc-test-automation#1789
147ddbc88c7SGeorge KeishingCreate Test Event Log And Verify Resolved Field
148ddbc88c7SGeorge Keishing    [Documentation]  Create event log and verify "Resolved" field is 0.
149ddbc88c7SGeorge Keishing    [Tags]  Create_Test_Event_Log_And_Verify_Resolved_Field
150ddbc88c7SGeorge Keishing
151ddbc88c7SGeorge Keishing    # Example Error log:
152ddbc88c7SGeorge Keishing    #  "/xyz/openbmc_project/logging/entry/1": {
153ddbc88c7SGeorge Keishing    #    "AdditionalData": [
154ddbc88c7SGeorge Keishing    #        "STRING=FOO"
155ddbc88c7SGeorge Keishing    #    ],
156ddbc88c7SGeorge Keishing    #    "Id": 1,
157ddbc88c7SGeorge Keishing    #    "Message": "example.xyz.openbmc_project.Example.Elog.AutoTestSimple",
158ddbc88c7SGeorge Keishing    #    "Resolved": 0,
159ddbc88c7SGeorge Keishing    #    "Severity": "xyz.openbmc_project.Logging.Entry.Level.Error",
160ddbc88c7SGeorge Keishing    #    "Timestamp": 1490817164983,
16158520d01SGeorge Keishing    #    "Associations": []
162ddbc88c7SGeorge Keishing    # },
163ddbc88c7SGeorge Keishing
164ddbc88c7SGeorge Keishing    # To mark an error as resolved, without deleting the error, user would
165ddbc88c7SGeorge Keishing    # set this bool property.
166ddbc88c7SGeorge Keishing    # In this test context we are making sure "Resolved" field is "0"
167ddbc88c7SGeorge Keishing    # by default.
168ddbc88c7SGeorge Keishing
169ddbc88c7SGeorge Keishing    Redfish Purge Event Log
170ddbc88c7SGeorge Keishing    Create Test Error Log
171ddbc88c7SGeorge Keishing    ${elog_entry}=  Get URL List  ${BMC_LOGGING_ENTRY}
172ddbc88c7SGeorge Keishing    ${resolved}=  Read Attribute  ${elog_entry[0]}  Resolved
173ddbc88c7SGeorge Keishing    Should Be True  ${resolved} == 0
174ddbc88c7SGeorge Keishing
175ddbc88c7SGeorge Keishing
176148d08c2SGeorge KeishingCreate Test Event Log And Verify Time Stamp
177148d08c2SGeorge Keishing    [Documentation]  Create event logs and verify time stamp.
178148d08c2SGeorge Keishing    [Tags]  Create_Test_Event_Log_And_Verify_Time_Stamp
179148d08c2SGeorge Keishing
180148d08c2SGeorge Keishing    #{
181148d08c2SGeorge Keishing    #  "@odata.context": "/redfish/v1/$metadata#LogEntryCollection.LogEntryCollection",
182148d08c2SGeorge Keishing    #  "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries",
183148d08c2SGeorge Keishing    #  "@odata.type": "#LogEntryCollection.LogEntryCollection",
184148d08c2SGeorge Keishing    #  "Description": "Collection of System Event Log Entries",
185148d08c2SGeorge Keishing    #  "Members": [
186148d08c2SGeorge Keishing    #  {
187148d08c2SGeorge Keishing    #    "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
188148d08c2SGeorge Keishing    #    "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1",
189148d08c2SGeorge Keishing    #    "@odata.type": "#LogEntry.v1_4_0.LogEntry",
190148d08c2SGeorge Keishing    #    "Created": "2019-05-29T13:19:27+00:00", <--- Time stamp
191148d08c2SGeorge Keishing    #    "EntryType": "Event",
192148d08c2SGeorge Keishing    #    "Id": "1",
193148d08c2SGeorge Keishing    #    "Message": "org.open_power.Host.Error.Event",
194148d08c2SGeorge Keishing    #    "Name": "System DBus Event Log Entry",
195148d08c2SGeorge Keishing    #    "Severity": "Critical"
196148d08c2SGeorge Keishing    #  }
197148d08c2SGeorge Keishing    #  ],
198148d08c2SGeorge Keishing    #  "Members@odata.count": 1,
199148d08c2SGeorge Keishing    #  "Name": "System Event Log Entries"
200148d08c2SGeorge Keishing    #}
201148d08c2SGeorge Keishing
202148d08c2SGeorge Keishing    Redfish Purge Event Log
203148d08c2SGeorge Keishing
204148d08c2SGeorge Keishing    Create Test Error Log
205148d08c2SGeorge Keishing    Sleep  2s
206148d08c2SGeorge Keishing    Create Test Error Log
207148d08c2SGeorge Keishing
208148d08c2SGeorge Keishing    ${elog_entry}=  Get Event Logs
209148d08c2SGeorge Keishing
210148d08c2SGeorge Keishing    # The event log generated is associated with the epoc time and unique
211148d08c2SGeorge Keishing    # for every error and in increasing time stamp.
212148d08c2SGeorge Keishing    ${time_stamp1}=  Convert Date  ${elog_entry[0]["Created"]}  epoch
213148d08c2SGeorge Keishing    ${time_stamp2}=  Convert Date  ${elog_entry[1]["Created"]}  epoch
214148d08c2SGeorge Keishing
215148d08c2SGeorge Keishing    Should Be True  ${time_stamp2} > ${time_stamp1}
216148d08c2SGeorge Keishing
217148d08c2SGeorge Keishing
218*6462f26dSRahul MaheshwariVerify Setting Error Log As Resolved
219*6462f26dSRahul Maheshwari    [Documentation]  Verify modified field of error log is updated when error log is marked resolved.
220*6462f26dSRahul Maheshwari    [Tags]  Verify_Setting_Error_Log_As_Resolved
221*6462f26dSRahul Maheshwari
222*6462f26dSRahul Maheshwari    Create Test PEL Log
223*6462f26dSRahul Maheshwari    ${elog_entry}=  Get Event Logs
224*6462f26dSRahul Maheshwari
225*6462f26dSRahul Maheshwari    # Wait for 5 seconds after creating error log.
226*6462f26dSRahul Maheshwari    Sleep  5s
227*6462f26dSRahul Maheshwari
228*6462f26dSRahul Maheshwari    # Mark error log as resolved by setting it to true.
229*6462f26dSRahul Maheshwari    Redfish.Patch  ${EVENT_LOG_URI}Entries/${elog_entry[0]["Id"]}  body={'Resolved':True}
230*6462f26dSRahul Maheshwari
231*6462f26dSRahul Maheshwari    ${elog_entry}=  Get Event Logs
232*6462f26dSRahul Maheshwari
233*6462f26dSRahul Maheshwari    # Example error log with resolve field set to true:
234*6462f26dSRahul Maheshwari    # {
235*6462f26dSRahul Maheshwari    #  "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/2045",
236*6462f26dSRahul Maheshwari    #  "@odata.type": "#LogEntry.v1_8_0.LogEntry",
237*6462f26dSRahul Maheshwari    #  "AdditionalDataURI": "/redfish/v1/Systems/system/LogServices/EventLog/attachment/2045",
238*6462f26dSRahul Maheshwari    #  "Created": "2021-05-11T04:45:07+00:00",
239*6462f26dSRahul Maheshwari    #  "EntryType": "Event",
240*6462f26dSRahul Maheshwari    #  "Id": "2045",
241*6462f26dSRahul Maheshwari    #  "Message": "xyz.openbmc_project.Host.Error.Event",
242*6462f26dSRahul Maheshwari    #  "Modified": "2021-05-11T07:24:36+00:00",
243*6462f26dSRahul Maheshwari    #  "Name": "System Event Log Entry",
244*6462f26dSRahul Maheshwari    #  "Resolved": true,
245*6462f26dSRahul Maheshwari    #  "Severity": "OK"
246*6462f26dSRahul Maheshwari    # }
247*6462f26dSRahul Maheshwari
248*6462f26dSRahul Maheshwari    Should Be Equal As Strings  ${elog_entry[0]["Resolved"]}  True
249*6462f26dSRahul Maheshwari
250*6462f26dSRahul Maheshwari    # Difference created and modified time of error log should be around 5 seconds.
251*6462f26dSRahul Maheshwari    ${creation_time}=  Convert Date  ${elog_entry[0]["Created"]}  epoch
252*6462f26dSRahul Maheshwari    ${modification_time}=  Convert Date  ${elog_entry[0]["Modified"]}  epoch
253*6462f26dSRahul Maheshwari
254*6462f26dSRahul Maheshwari    ${diff}=  Subtract Date From Date  ${modification_time}  ${creation_time}
255*6462f26dSRahul Maheshwari    ${diff}=  Convert To Number  ${diff}
256*6462f26dSRahul Maheshwari    Should Be True  4 < ${diff} < 8
257*6462f26dSRahul Maheshwari
258*6462f26dSRahul Maheshwari
259ddbc88c7SGeorge KeishingVerify IPMI SEL Delete
260ddbc88c7SGeorge Keishing    [Documentation]  Verify IPMI SEL delete operation.
261ddbc88c7SGeorge Keishing    [Tags]  Verify_IPMI_SEL_Delete
262ddbc88c7SGeorge Keishing
263ddbc88c7SGeorge Keishing    Redfish Purge Event Log
264ddbc88c7SGeorge Keishing    Create Test Error Log
265ddbc88c7SGeorge Keishing
266ddbc88c7SGeorge Keishing    ${sel_list}=  Run IPMI Standard Command  sel list
267ddbc88c7SGeorge Keishing    Should Not Be Equal As Strings  ${sel_list}  SEL has no entries
268ddbc88c7SGeorge Keishing
269ddbc88c7SGeorge Keishing    # Example of SEL List:
270ddbc88c7SGeorge Keishing    # 4 | 04/21/2017 | 10:51:16 | System Event #0x01 | Undetermined system hardware failure | Asserted
271ddbc88c7SGeorge Keishing
272ddbc88c7SGeorge Keishing    ${sel_entry}=  Fetch from Left  ${sel_list}  |
273ddbc88c7SGeorge Keishing    ${sel_entry}=  Evaluate  $sel_entry.replace(' ','')
274ddbc88c7SGeorge Keishing    ${sel_entry}=  Convert To Integer  0x${sel_entry}
275ddbc88c7SGeorge Keishing
276ddbc88c7SGeorge Keishing    ${sel_delete}=  Run IPMI Standard Command  sel delete ${sel_entry}
277ddbc88c7SGeorge Keishing    Should Be Equal As Strings  ${sel_delete}  Deleted entry ${sel_entry}
278ddbc88c7SGeorge Keishing    ...  case_insensitive=True
279ddbc88c7SGeorge Keishing
280ddbc88c7SGeorge Keishing    ${sel_list}=  Run IPMI Standard Command  sel list
281ddbc88c7SGeorge Keishing    Should Be Equal As Strings  ${sel_list}  SEL has no entries
282ddbc88c7SGeorge Keishing    ...  case_insensitive=True
283ddbc88c7SGeorge Keishing
284ddbc88c7SGeorge Keishing
2850b76e421SGeorge KeishingDelete Non Existing SEL Event Entry
2860b76e421SGeorge Keishing    [Documentation]  Delete non existing SEL event entry.
2870b76e421SGeorge Keishing    [Tags]  Delete_Non_Existing_SEL_Event_Entry
2880b76e421SGeorge Keishing
2890b76e421SGeorge Keishing    ${sel_delete}=  Run Keyword And Expect Error  *
2900b76e421SGeorge Keishing    ...  Run IPMI Standard Command  sel delete 100
2910b76e421SGeorge Keishing    Should Contain  ${sel_delete}  Unable to delete entry
2920b76e421SGeorge Keishing    ...  case_insensitive=True
2930b76e421SGeorge Keishing
2940b76e421SGeorge Keishing
2950b76e421SGeorge KeishingDelete Invalid SEL Event Entry
2960b76e421SGeorge Keishing    [Documentation]  Delete invalid SEL event entry.
2970b76e421SGeorge Keishing    [Tags]  Delete_Invalid_SEL_Event_Entry
2980b76e421SGeorge Keishing
2990b76e421SGeorge Keishing    ${sel_delete}=  Run Keyword And Expect Error  *
3000b76e421SGeorge Keishing    ...  Run IPMI Standard Command  sel delete abc
3010b76e421SGeorge Keishing    Should Contain  ${sel_delete}  Given SEL ID 'abc' is invalid
3020b76e421SGeorge Keishing    ...  case_insensitive=True
3030b76e421SGeorge Keishing
3040b76e421SGeorge Keishing
3050b76e421SGeorge KeishingVerify IPMI SEL Event Entries
3060b76e421SGeorge Keishing    [Documentation]  Verify IPMI SEL's entries info.
3070b76e421SGeorge Keishing    [Tags]  Verify_IPMI_SEL_Event_Entries
3080b76e421SGeorge Keishing
3090b76e421SGeorge Keishing    # Generate error logs of random count.
3100b76e421SGeorge Keishing    ${count}=  Evaluate  random.randint(1, 5)  modules=random
3110b76e421SGeorge Keishing    Repeat Keyword  ${count}  Create Test Error Log
3120b76e421SGeorge Keishing
3130b76e421SGeorge Keishing    ${sel_entries_count}=  Get IPMI SEL Setting  Entries
3140b76e421SGeorge Keishing    Should Be Equal As Strings  ${sel_entries_count}  ${count}
3150b76e421SGeorge Keishing
3160b76e421SGeorge Keishing
3170b76e421SGeorge KeishingVerify IPMI SEL Event Last Add Time
3180b76e421SGeorge Keishing    [Documentation]  Verify IPMI SEL's last added timestamp.
3190b76e421SGeorge Keishing    [Tags]  Verify_IPMI_SEL_Event_Last_Add_Time
3200b76e421SGeorge Keishing
3210b76e421SGeorge Keishing    Create Test Error Log
3220b76e421SGeorge Keishing    ${sel_time}=  Run IPMI Standard Command  sel time get
3230b76e421SGeorge Keishing    ${sel_time}=  Convert Date  ${sel_time}
3240b76e421SGeorge Keishing    ...  date_format=%m/%d/%Y %H:%M:%S  exclude_millis=True
3250b76e421SGeorge Keishing
3260b76e421SGeorge Keishing    ${sel_last_add_time}=  Get IPMI SEL Setting  Last Add Time
3270b76e421SGeorge Keishing    ${sel_last_add_time}=  Convert Date  ${sel_last_add_time}
3280b76e421SGeorge Keishing    ...  date_format=%m/%d/%Y %H:%M:%S  exclude_millis=True
3290b76e421SGeorge Keishing
3300b76e421SGeorge Keishing    ${time_diff}=
3310b76e421SGeorge Keishing    ...  Subtract Date From Date  ${sel_last_add_time}  ${sel_time}
3320b76e421SGeorge Keishing
3330b76e421SGeorge Keishing    # Verify if the delay in current time check and last add SEL time
3340b76e421SGeorge Keishing    # is less or equals to 2 seconds.
3350b76e421SGeorge Keishing    Should Be True  ${time_diff} <= 2
3360b76e421SGeorge Keishing
3370b76e421SGeorge Keishing
338d35b5319SGeorge KeishingCreate Test Event Log And Delete
339d35b5319SGeorge Keishing    [Documentation]  Create an event log and delete it.
340d35b5319SGeorge Keishing    [Tags]  Create_Test_Event_Log_And_Delete
341d35b5319SGeorge Keishing
342d35b5319SGeorge Keishing    Create Test Error Log
343d35b5319SGeorge Keishing    Redfish Purge Event Log
344d35b5319SGeorge Keishing    Event Log Should Not Exist
345d35b5319SGeorge Keishing
346d35b5319SGeorge Keishing
347d35b5319SGeorge KeishingCreate Multiple Test Event Logs And Delete All
348d35b5319SGeorge Keishing    [Documentation]  Create multiple event logs and delete all.
349d35b5319SGeorge Keishing    [Tags]  Create_Multiple_Test_Event_Logs_And_Delete_All
350d35b5319SGeorge Keishing
351d35b5319SGeorge Keishing    Create Test Error Log
352d35b5319SGeorge Keishing    Create Test Error Log
353d35b5319SGeorge Keishing    Create Test Error Log
354d35b5319SGeorge Keishing    Redfish Purge Event Log
355d35b5319SGeorge Keishing    Event Log Should Not Exist
356d35b5319SGeorge Keishing
357d35b5319SGeorge Keishing
358ddbc88c7SGeorge Keishing# TODO: openbmc/openbmc-test-automation#1789
359ddbc88c7SGeorge KeishingCreate Two Test Event Logs And Delete One
360ddbc88c7SGeorge Keishing    [Documentation]  Create two event logs and delete the first entry.
36189f499d5SGeorge Keishing    [Tags]  Create_Two_Test_Event_Logs_And_Delete_One
362ddbc88c7SGeorge Keishing
363ddbc88c7SGeorge Keishing    Redfish Purge Event Log
364ddbc88c7SGeorge Keishing    Create Test Error Log
365ddbc88c7SGeorge Keishing    ${elog_entry}=  Get URL List  ${BMC_LOGGING_ENTRY}
366ddbc88c7SGeorge Keishing    Create Test Error Log
367ddbc88c7SGeorge Keishing    Delete Error log Entry  ${elog_entry[0]}
368ddbc88c7SGeorge Keishing    ${resp}=  OpenBMC Get Request  ${elog_entry[0]}
369ddbc88c7SGeorge Keishing    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_NOT_FOUND}
370ddbc88c7SGeorge Keishing
371ddbc88c7SGeorge Keishing
372d35b5319SGeorge KeishingVerify Watchdog Timedout Event
373d35b5319SGeorge Keishing    [Documentation]  Trigger watchdog timed out and verify event log generated.
374d35b5319SGeorge Keishing    [Tags]  Verify_Watchdog_Timedout_Event
375d35b5319SGeorge Keishing
376d35b5319SGeorge Keishing    Redfish Power On
377d35b5319SGeorge Keishing
378d35b5319SGeorge Keishing    # Clear errors if there are any.
379d35b5319SGeorge Keishing    Redfish.Login
380d35b5319SGeorge Keishing    Redfish Purge Event Log
381d35b5319SGeorge Keishing
382d35b5319SGeorge Keishing    Trigger Host Watchdog Error
383d35b5319SGeorge Keishing
384d35b5319SGeorge Keishing    # Logging takes time to generate the timeout error.
385d35b5319SGeorge Keishing    Wait Until Keyword Succeeds  2 min  30 sec
386d35b5319SGeorge Keishing    ...  Verify Watchdog EventLog Content
387d35b5319SGeorge Keishing
388d35b5319SGeorge Keishing
389d35b5319SGeorge KeishingVerify Event Logs Capping
390d35b5319SGeorge Keishing    [Documentation]  Verify event logs capping.
391d35b5319SGeorge Keishing    [Tags]  Verify_Event_Logs_Capping
392d35b5319SGeorge Keishing
393d35b5319SGeorge Keishing    Redfish Purge Event Log
394d35b5319SGeorge Keishing
395d35b5319SGeorge Keishing    ${cmd}=  Catenate  for i in {1..201}; do /tmp/tarball/bin/logging-test -c
396d2d2bd2bSGeorge Keishing    ...  AutoTestSimple;sleep 1;done
397d35b5319SGeorge Keishing    BMC Execute Command  ${cmd}
398d35b5319SGeorge Keishing
399d35b5319SGeorge Keishing    ${elogs}=  Get Event Logs
400d35b5319SGeorge Keishing    ${count}=  Get Length  ${elogs}
401d35b5319SGeorge Keishing    Run Keyword If  ${count} > 200
402d35b5319SGeorge Keishing    ...  Fail  Error logs created exceeded max capacity 200.
403d35b5319SGeorge Keishing
404d35b5319SGeorge Keishing
405759c6f97SGeorge KeishingTest Event Log Wrapping
406759c6f97SGeorge Keishing    [Documentation]  Verify event log entries wraps when 200 max cap is reached.
407759c6f97SGeorge Keishing    [Tags]  Test_Event_Log_Wrapping
408759c6f97SGeorge Keishing
409759c6f97SGeorge Keishing    # Restarting logging service in order to clear logs and get the next log
410759c6f97SGeorge Keishing    # ID set to 1.
411759c6f97SGeorge Keishing    BMC Execute Command
412759c6f97SGeorge Keishing    ...  systemctl restart xyz.openbmc_project.Logging.service
413759c6f97SGeorge Keishing    Sleep  10s  reason=Wait for logging service to restart properly.
414759c6f97SGeorge Keishing
415759c6f97SGeorge Keishing    # Create ${max_num_event_logs} event logs.
416759c6f97SGeorge Keishing    ${cmd}=  Catenate  for i in {1..${max_num_event_logs}}; do /tmp/tarball/bin/logging-test -c
417d2d2bd2bSGeorge Keishing    ...  AutoTestSimple;sleep 1;done
418759c6f97SGeorge Keishing    BMC Execute Command  ${cmd}
419759c6f97SGeorge Keishing
420759c6f97SGeorge Keishing    # Verify that event logs with IDs 1 and ${max_num_event_logs} exist.
421759c6f97SGeorge Keishing    ${event_log}=  Get Event Logs
422759c6f97SGeorge Keishing
423759c6f97SGeorge Keishing    ${log_entries}=  Filter Struct  ${event_log}  [('Id', '1')]
42439c00518SMichael Walsh    Rprint Vars  log_entries
425759c6f97SGeorge Keishing    Should Be Equal As Strings  ${log_entries[0]["Id"]}  1
426759c6f97SGeorge Keishing
427759c6f97SGeorge Keishing    ${log_entries}=  Filter Struct  ${event_log}  [('Id', '${max_num_event_logs}')]
42839c00518SMichael Walsh    Rprint Vars  log_entries
429759c6f97SGeorge Keishing    Should Be Equal As Strings  ${log_entries[0]["Id"]}  ${max_num_event_logs}
430759c6f97SGeorge Keishing
431759c6f97SGeorge Keishing    # Create event log and verify the entry ID, ${max_num_event_logs + 1}.
432759c6f97SGeorge Keishing    ${next_event_log_id}=  Set Variable  ${max_num_event_logs + 1}
433759c6f97SGeorge Keishing
434759c6f97SGeorge Keishing    Create Test Error Log
435759c6f97SGeorge Keishing
436759c6f97SGeorge Keishing    ${event_log}=  Get Event Logs
437759c6f97SGeorge Keishing
438759c6f97SGeorge Keishing    ${log_entries}=  Filter Struct  ${event_log}  [('Id', '${next_event_log_id}')]
43939c00518SMichael Walsh    Rprint Vars  log_entries
440759c6f97SGeorge Keishing    Should Be Equal As Strings  ${log_entries[0]["Id"]}  ${next_event_log_id}
441759c6f97SGeorge Keishing
442759c6f97SGeorge Keishing    # Event log 1 should be wrapped.
443759c6f97SGeorge Keishing    ${log_entries}=  Filter Struct  ${event_log}  [('Id', '1')]
44439c00518SMichael Walsh    Rprint Vars  log_entries
445759c6f97SGeorge Keishing
446759c6f97SGeorge Keishing    ${length_log_entries}  Get Length  ${log_entries}
447759c6f97SGeorge Keishing    Should Be Equal As Integers  ${length_log_entries}  0
448759c6f97SGeorge Keishing    ...  msg=The event log should have wrapped such that entry ID 1 is now purged.
449759c6f97SGeorge Keishing
450759c6f97SGeorge Keishing
4518cca7fb8SGeorge Keishing*** Keywords ***
4528cca7fb8SGeorge Keishing
4532f36947bSGeorge KeishingSuite Setup Execution
4542f36947bSGeorge Keishing   [Documentation]  Do test case setup tasks.
4552f36947bSGeorge Keishing
4562f36947bSGeorge Keishing    Redfish.Login
4572f36947bSGeorge Keishing
4582f36947bSGeorge Keishing    Redfish Purge Event Log
4592f36947bSGeorge Keishing
4602f36947bSGeorge Keishing    ${status}=  Run Keyword And Return Status  Logging Test Binary Exist
4612f36947bSGeorge Keishing    Run Keyword If  ${status} == ${False}  Install Tarball
4622f36947bSGeorge Keishing
4632f36947bSGeorge Keishing
4648cca7fb8SGeorge KeishingSuite Teardown Execution
4658cca7fb8SGeorge Keishing    [Documentation]  Do the post suite teardown.
4668cca7fb8SGeorge Keishing
4678cca7fb8SGeorge Keishing    Redfish.Logout
4688cca7fb8SGeorge Keishing
4698cca7fb8SGeorge Keishing
470b0a491f2SGeorge KeishingTest Setup Execution
4718cca7fb8SGeorge Keishing   [Documentation]  Do test case setup tasks.
4728cca7fb8SGeorge Keishing
4730b76e421SGeorge Keishing    Redfish Purge Event Log
4740b76e421SGeorge Keishing
4758cca7fb8SGeorge Keishing    ${status}=  Run Keyword And Return Status  Logging Test Binary Exist
4768cca7fb8SGeorge Keishing    Run Keyword If  ${status} == ${False}  Install Tarball
4778cca7fb8SGeorge Keishing
4788cca7fb8SGeorge Keishing
4798cca7fb8SGeorge KeishingTest Teardown Execution
4808cca7fb8SGeorge Keishing    [Documentation]  Do the post test teardown.
4818cca7fb8SGeorge Keishing
4828cca7fb8SGeorge Keishing    FFDC On Test Case Fail
483e5c5ebdfSGeorge Keishing    Redfish.Login
484b0a491f2SGeorge Keishing    Redfish Purge Event Log
4858cca7fb8SGeorge Keishing
4868cca7fb8SGeorge Keishing
48720c08e41SRahul MaheshwariGet Redfish Error Entries
48820c08e41SRahul Maheshwari    [Documentation]  Return Redfish error ids list.
48920c08e41SRahul Maheshwari    ${error_uris}=  redfish_utils.get_member_list  /redfish/v1/Systems/system/LogServices/EventLog/Entries
49020c08e41SRahul Maheshwari    ${error_ids}=  Create List
49120c08e41SRahul Maheshwari
49220c08e41SRahul Maheshwari    FOR  ${error_uri}  IN  @{error_uris}
49320c08e41SRahul Maheshwari      ${error_id}=  Fetch From Right  ${error_uri}  /
49420c08e41SRahul Maheshwari      Append To List  ${error_ids}  ${error_id}
49520c08e41SRahul Maheshwari    END
49620c08e41SRahul Maheshwari
49720c08e41SRahul Maheshwari    [Return]  ${error_ids}
49820c08e41SRahul Maheshwari
49920c08e41SRahul Maheshwari
5008cca7fb8SGeorge KeishingEvent Log Should Not Exist
5018cca7fb8SGeorge Keishing    [Documentation]  Event log entries should not exist.
5028cca7fb8SGeorge Keishing
5038cca7fb8SGeorge Keishing    ${elogs}=  Get Event Logs
5048cca7fb8SGeorge Keishing    Should Be Empty  ${elogs}  msg=System event log entry is not empty.
505b0a491f2SGeorge Keishing
506b0a491f2SGeorge Keishing
507b0a491f2SGeorge KeishingEvent Log Should Exist
508b0a491f2SGeorge Keishing    [Documentation]  Event log entries should exist.
509b0a491f2SGeorge Keishing
510b0a491f2SGeorge Keishing    ${elogs}=  Get Event Logs
511b0a491f2SGeorge Keishing    Should Not Be Empty  ${elogs}  msg=System event log entry is not empty.
512d35b5319SGeorge Keishing
513d35b5319SGeorge Keishing
514d35b5319SGeorge KeishingVerify Watchdog EventLog Content
515d35b5319SGeorge Keishing    [Documentation]  Verify watchdog event log content.
516d35b5319SGeorge Keishing
517d35b5319SGeorge Keishing    # Example:
518d35b5319SGeorge Keishing    # {
519d35b5319SGeorge Keishing    #    "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
520d35b5319SGeorge Keishing    #    "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/31",
521d35b5319SGeorge Keishing    #    "@odata.type": "#LogEntry.v1_4_0.LogEntry",
522d35b5319SGeorge Keishing    #    "Created": "2019-05-31T18:41:33+00:00",
523d35b5319SGeorge Keishing    #    "EntryType": "Event",
524d35b5319SGeorge Keishing    #    "Id": "31",
525d35b5319SGeorge Keishing    #    "Message": "org.open_power.Host.Boot.Error.WatchdogTimedOut",
526d35b5319SGeorge Keishing    #    "Name": "System DBus Event Log Entry",
527d35b5319SGeorge Keishing    #    "Severity": "Critical"
528d35b5319SGeorge Keishing    # }
529d35b5319SGeorge Keishing
530d35b5319SGeorge Keishing    ${elog}=  Get Event Logs
531d35b5319SGeorge Keishing    Should Be Equal As Strings
532d35b5319SGeorge Keishing    ...  ${elog[0]["Message"]}  org.open_power.Host.Boot.Error.WatchdogTimedOut
533d35b5319SGeorge Keishing    ...  msg=Watchdog timeout event log was not found.
534d35b5319SGeorge Keishing    Should Be Equal As Strings
535d35b5319SGeorge Keishing    ...  ${elog[0]["Severity"]}  Critical
536d35b5319SGeorge Keishing    ...  msg=Watchdog timeout severity unexpected value.
537