xref: /openbmc/openbmc-test-automation/redfish/systems/eventlog/test_event_logging.robot (revision 20c08e41c256227a42063b246cc17a4c4a92e0e3)
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
58*20c08e41SRahul MaheshwariDelete Redfish Event Log And Verify
59*20c08e41SRahul Maheshwari    [Documentation]  Delete Redfish event log and verify via Redfish.
60*20c08e41SRahul Maheshwari    [Tags]  Delete_Redfish_Event_Log_And_Verify
61*20c08e41SRahul Maheshwari
62*20c08e41SRahul Maheshwari    Redfish.Login
63*20c08e41SRahul Maheshwari    Redfish Purge Event Log
64*20c08e41SRahul Maheshwari    Create Test PEL Log
65*20c08e41SRahul Maheshwari    ${elog_entry}=  Get Event Logs
66*20c08e41SRahul Maheshwari
67*20c08e41SRahul Maheshwari    Redfish.Delete  /redfish/v1/Systems/system/LogServices/EventLog/Entries/${elog_entry[0]["Id"]}
68*20c08e41SRahul Maheshwari
69*20c08e41SRahul Maheshwari    ${error_entries}=  Get Redfish Error Entries
70*20c08e41SRahul Maheshwari    Should Be Empty  ${error_entries}
71*20c08e41SRahul Maheshwari
72*20c08e41SRahul 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
218ddbc88c7SGeorge KeishingVerify IPMI SEL Delete
219ddbc88c7SGeorge Keishing    [Documentation]  Verify IPMI SEL delete operation.
220ddbc88c7SGeorge Keishing    [Tags]  Verify_IPMI_SEL_Delete
221ddbc88c7SGeorge Keishing
222ddbc88c7SGeorge Keishing    Redfish Purge Event Log
223ddbc88c7SGeorge Keishing    Create Test Error Log
224ddbc88c7SGeorge Keishing
225ddbc88c7SGeorge Keishing    ${sel_list}=  Run IPMI Standard Command  sel list
226ddbc88c7SGeorge Keishing    Should Not Be Equal As Strings  ${sel_list}  SEL has no entries
227ddbc88c7SGeorge Keishing
228ddbc88c7SGeorge Keishing    # Example of SEL List:
229ddbc88c7SGeorge Keishing    # 4 | 04/21/2017 | 10:51:16 | System Event #0x01 | Undetermined system hardware failure | Asserted
230ddbc88c7SGeorge Keishing
231ddbc88c7SGeorge Keishing    ${sel_entry}=  Fetch from Left  ${sel_list}  |
232ddbc88c7SGeorge Keishing    ${sel_entry}=  Evaluate  $sel_entry.replace(' ','')
233ddbc88c7SGeorge Keishing    ${sel_entry}=  Convert To Integer  0x${sel_entry}
234ddbc88c7SGeorge Keishing
235ddbc88c7SGeorge Keishing    ${sel_delete}=  Run IPMI Standard Command  sel delete ${sel_entry}
236ddbc88c7SGeorge Keishing    Should Be Equal As Strings  ${sel_delete}  Deleted entry ${sel_entry}
237ddbc88c7SGeorge Keishing    ...  case_insensitive=True
238ddbc88c7SGeorge Keishing
239ddbc88c7SGeorge Keishing    ${sel_list}=  Run IPMI Standard Command  sel list
240ddbc88c7SGeorge Keishing    Should Be Equal As Strings  ${sel_list}  SEL has no entries
241ddbc88c7SGeorge Keishing    ...  case_insensitive=True
242ddbc88c7SGeorge Keishing
243ddbc88c7SGeorge Keishing
2440b76e421SGeorge KeishingDelete Non Existing SEL Event Entry
2450b76e421SGeorge Keishing    [Documentation]  Delete non existing SEL event entry.
2460b76e421SGeorge Keishing    [Tags]  Delete_Non_Existing_SEL_Event_Entry
2470b76e421SGeorge Keishing
2480b76e421SGeorge Keishing    ${sel_delete}=  Run Keyword And Expect Error  *
2490b76e421SGeorge Keishing    ...  Run IPMI Standard Command  sel delete 100
2500b76e421SGeorge Keishing    Should Contain  ${sel_delete}  Unable to delete entry
2510b76e421SGeorge Keishing    ...  case_insensitive=True
2520b76e421SGeorge Keishing
2530b76e421SGeorge Keishing
2540b76e421SGeorge KeishingDelete Invalid SEL Event Entry
2550b76e421SGeorge Keishing    [Documentation]  Delete invalid SEL event entry.
2560b76e421SGeorge Keishing    [Tags]  Delete_Invalid_SEL_Event_Entry
2570b76e421SGeorge Keishing
2580b76e421SGeorge Keishing    ${sel_delete}=  Run Keyword And Expect Error  *
2590b76e421SGeorge Keishing    ...  Run IPMI Standard Command  sel delete abc
2600b76e421SGeorge Keishing    Should Contain  ${sel_delete}  Given SEL ID 'abc' is invalid
2610b76e421SGeorge Keishing    ...  case_insensitive=True
2620b76e421SGeorge Keishing
2630b76e421SGeorge Keishing
2640b76e421SGeorge KeishingVerify IPMI SEL Event Entries
2650b76e421SGeorge Keishing    [Documentation]  Verify IPMI SEL's entries info.
2660b76e421SGeorge Keishing    [Tags]  Verify_IPMI_SEL_Event_Entries
2670b76e421SGeorge Keishing
2680b76e421SGeorge Keishing    # Generate error logs of random count.
2690b76e421SGeorge Keishing    ${count}=  Evaluate  random.randint(1, 5)  modules=random
2700b76e421SGeorge Keishing    Repeat Keyword  ${count}  Create Test Error Log
2710b76e421SGeorge Keishing
2720b76e421SGeorge Keishing    ${sel_entries_count}=  Get IPMI SEL Setting  Entries
2730b76e421SGeorge Keishing    Should Be Equal As Strings  ${sel_entries_count}  ${count}
2740b76e421SGeorge Keishing
2750b76e421SGeorge Keishing
2760b76e421SGeorge KeishingVerify IPMI SEL Event Last Add Time
2770b76e421SGeorge Keishing    [Documentation]  Verify IPMI SEL's last added timestamp.
2780b76e421SGeorge Keishing    [Tags]  Verify_IPMI_SEL_Event_Last_Add_Time
2790b76e421SGeorge Keishing
2800b76e421SGeorge Keishing    Create Test Error Log
2810b76e421SGeorge Keishing    ${sel_time}=  Run IPMI Standard Command  sel time get
2820b76e421SGeorge Keishing    ${sel_time}=  Convert Date  ${sel_time}
2830b76e421SGeorge Keishing    ...  date_format=%m/%d/%Y %H:%M:%S  exclude_millis=True
2840b76e421SGeorge Keishing
2850b76e421SGeorge Keishing    ${sel_last_add_time}=  Get IPMI SEL Setting  Last Add Time
2860b76e421SGeorge Keishing    ${sel_last_add_time}=  Convert Date  ${sel_last_add_time}
2870b76e421SGeorge Keishing    ...  date_format=%m/%d/%Y %H:%M:%S  exclude_millis=True
2880b76e421SGeorge Keishing
2890b76e421SGeorge Keishing    ${time_diff}=
2900b76e421SGeorge Keishing    ...  Subtract Date From Date  ${sel_last_add_time}  ${sel_time}
2910b76e421SGeorge Keishing
2920b76e421SGeorge Keishing    # Verify if the delay in current time check and last add SEL time
2930b76e421SGeorge Keishing    # is less or equals to 2 seconds.
2940b76e421SGeorge Keishing    Should Be True  ${time_diff} <= 2
2950b76e421SGeorge Keishing
2960b76e421SGeorge Keishing
297d35b5319SGeorge KeishingCreate Test Event Log And Delete
298d35b5319SGeorge Keishing    [Documentation]  Create an event log and delete it.
299d35b5319SGeorge Keishing    [Tags]  Create_Test_Event_Log_And_Delete
300d35b5319SGeorge Keishing
301d35b5319SGeorge Keishing    Create Test Error Log
302d35b5319SGeorge Keishing    Redfish Purge Event Log
303d35b5319SGeorge Keishing    Event Log Should Not Exist
304d35b5319SGeorge Keishing
305d35b5319SGeorge Keishing
306d35b5319SGeorge KeishingCreate Multiple Test Event Logs And Delete All
307d35b5319SGeorge Keishing    [Documentation]  Create multiple event logs and delete all.
308d35b5319SGeorge Keishing    [Tags]  Create_Multiple_Test_Event_Logs_And_Delete_All
309d35b5319SGeorge Keishing
310d35b5319SGeorge Keishing    Create Test Error Log
311d35b5319SGeorge Keishing    Create Test Error Log
312d35b5319SGeorge Keishing    Create Test Error Log
313d35b5319SGeorge Keishing    Redfish Purge Event Log
314d35b5319SGeorge Keishing    Event Log Should Not Exist
315d35b5319SGeorge Keishing
316d35b5319SGeorge Keishing
317ddbc88c7SGeorge Keishing# TODO: openbmc/openbmc-test-automation#1789
318ddbc88c7SGeorge KeishingCreate Two Test Event Logs And Delete One
319ddbc88c7SGeorge Keishing    [Documentation]  Create two event logs and delete the first entry.
32089f499d5SGeorge Keishing    [Tags]  Create_Two_Test_Event_Logs_And_Delete_One
321ddbc88c7SGeorge Keishing
322ddbc88c7SGeorge Keishing    Redfish Purge Event Log
323ddbc88c7SGeorge Keishing    Create Test Error Log
324ddbc88c7SGeorge Keishing    ${elog_entry}=  Get URL List  ${BMC_LOGGING_ENTRY}
325ddbc88c7SGeorge Keishing    Create Test Error Log
326ddbc88c7SGeorge Keishing    Delete Error log Entry  ${elog_entry[0]}
327ddbc88c7SGeorge Keishing    ${resp}=  OpenBMC Get Request  ${elog_entry[0]}
328ddbc88c7SGeorge Keishing    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_NOT_FOUND}
329ddbc88c7SGeorge Keishing
330ddbc88c7SGeorge Keishing
331d35b5319SGeorge KeishingVerify Watchdog Timedout Event
332d35b5319SGeorge Keishing    [Documentation]  Trigger watchdog timed out and verify event log generated.
333d35b5319SGeorge Keishing    [Tags]  Verify_Watchdog_Timedout_Event
334d35b5319SGeorge Keishing
335d35b5319SGeorge Keishing    Redfish Power On
336d35b5319SGeorge Keishing
337d35b5319SGeorge Keishing    # Clear errors if there are any.
338d35b5319SGeorge Keishing    Redfish.Login
339d35b5319SGeorge Keishing    Redfish Purge Event Log
340d35b5319SGeorge Keishing
341d35b5319SGeorge Keishing    Trigger Host Watchdog Error
342d35b5319SGeorge Keishing
343d35b5319SGeorge Keishing    # Logging takes time to generate the timeout error.
344d35b5319SGeorge Keishing    Wait Until Keyword Succeeds  2 min  30 sec
345d35b5319SGeorge Keishing    ...  Verify Watchdog EventLog Content
346d35b5319SGeorge Keishing
347d35b5319SGeorge Keishing
348d35b5319SGeorge KeishingVerify Event Logs Capping
349d35b5319SGeorge Keishing    [Documentation]  Verify event logs capping.
350d35b5319SGeorge Keishing    [Tags]  Verify_Event_Logs_Capping
351d35b5319SGeorge Keishing
352d35b5319SGeorge Keishing    Redfish Purge Event Log
353d35b5319SGeorge Keishing
354d35b5319SGeorge Keishing    ${cmd}=  Catenate  for i in {1..201}; do /tmp/tarball/bin/logging-test -c
355d2d2bd2bSGeorge Keishing    ...  AutoTestSimple;sleep 1;done
356d35b5319SGeorge Keishing    BMC Execute Command  ${cmd}
357d35b5319SGeorge Keishing
358d35b5319SGeorge Keishing    ${elogs}=  Get Event Logs
359d35b5319SGeorge Keishing    ${count}=  Get Length  ${elogs}
360d35b5319SGeorge Keishing    Run Keyword If  ${count} > 200
361d35b5319SGeorge Keishing    ...  Fail  Error logs created exceeded max capacity 200.
362d35b5319SGeorge Keishing
363d35b5319SGeorge Keishing
364759c6f97SGeorge KeishingTest Event Log Wrapping
365759c6f97SGeorge Keishing    [Documentation]  Verify event log entries wraps when 200 max cap is reached.
366759c6f97SGeorge Keishing    [Tags]  Test_Event_Log_Wrapping
367759c6f97SGeorge Keishing
368759c6f97SGeorge Keishing    # Restarting logging service in order to clear logs and get the next log
369759c6f97SGeorge Keishing    # ID set to 1.
370759c6f97SGeorge Keishing    BMC Execute Command
371759c6f97SGeorge Keishing    ...  systemctl restart xyz.openbmc_project.Logging.service
372759c6f97SGeorge Keishing    Sleep  10s  reason=Wait for logging service to restart properly.
373759c6f97SGeorge Keishing
374759c6f97SGeorge Keishing    # Create ${max_num_event_logs} event logs.
375759c6f97SGeorge Keishing    ${cmd}=  Catenate  for i in {1..${max_num_event_logs}}; do /tmp/tarball/bin/logging-test -c
376d2d2bd2bSGeorge Keishing    ...  AutoTestSimple;sleep 1;done
377759c6f97SGeorge Keishing    BMC Execute Command  ${cmd}
378759c6f97SGeorge Keishing
379759c6f97SGeorge Keishing    # Verify that event logs with IDs 1 and ${max_num_event_logs} exist.
380759c6f97SGeorge Keishing    ${event_log}=  Get Event Logs
381759c6f97SGeorge Keishing
382759c6f97SGeorge Keishing    ${log_entries}=  Filter Struct  ${event_log}  [('Id', '1')]
38339c00518SMichael Walsh    Rprint Vars  log_entries
384759c6f97SGeorge Keishing    Should Be Equal As Strings  ${log_entries[0]["Id"]}  1
385759c6f97SGeorge Keishing
386759c6f97SGeorge Keishing    ${log_entries}=  Filter Struct  ${event_log}  [('Id', '${max_num_event_logs}')]
38739c00518SMichael Walsh    Rprint Vars  log_entries
388759c6f97SGeorge Keishing    Should Be Equal As Strings  ${log_entries[0]["Id"]}  ${max_num_event_logs}
389759c6f97SGeorge Keishing
390759c6f97SGeorge Keishing    # Create event log and verify the entry ID, ${max_num_event_logs + 1}.
391759c6f97SGeorge Keishing    ${next_event_log_id}=  Set Variable  ${max_num_event_logs + 1}
392759c6f97SGeorge Keishing
393759c6f97SGeorge Keishing    Create Test Error Log
394759c6f97SGeorge Keishing
395759c6f97SGeorge Keishing    ${event_log}=  Get Event Logs
396759c6f97SGeorge Keishing
397759c6f97SGeorge Keishing    ${log_entries}=  Filter Struct  ${event_log}  [('Id', '${next_event_log_id}')]
39839c00518SMichael Walsh    Rprint Vars  log_entries
399759c6f97SGeorge Keishing    Should Be Equal As Strings  ${log_entries[0]["Id"]}  ${next_event_log_id}
400759c6f97SGeorge Keishing
401759c6f97SGeorge Keishing    # Event log 1 should be wrapped.
402759c6f97SGeorge Keishing    ${log_entries}=  Filter Struct  ${event_log}  [('Id', '1')]
40339c00518SMichael Walsh    Rprint Vars  log_entries
404759c6f97SGeorge Keishing
405759c6f97SGeorge Keishing    ${length_log_entries}  Get Length  ${log_entries}
406759c6f97SGeorge Keishing    Should Be Equal As Integers  ${length_log_entries}  0
407759c6f97SGeorge Keishing    ...  msg=The event log should have wrapped such that entry ID 1 is now purged.
408759c6f97SGeorge Keishing
409759c6f97SGeorge Keishing
4108cca7fb8SGeorge Keishing*** Keywords ***
4118cca7fb8SGeorge Keishing
4122f36947bSGeorge KeishingSuite Setup Execution
4132f36947bSGeorge Keishing   [Documentation]  Do test case setup tasks.
4142f36947bSGeorge Keishing
4152f36947bSGeorge Keishing    Redfish.Login
4162f36947bSGeorge Keishing
4172f36947bSGeorge Keishing    Redfish Purge Event Log
4182f36947bSGeorge Keishing
4192f36947bSGeorge Keishing    ${status}=  Run Keyword And Return Status  Logging Test Binary Exist
4202f36947bSGeorge Keishing    Run Keyword If  ${status} == ${False}  Install Tarball
4212f36947bSGeorge Keishing
4222f36947bSGeorge Keishing
4238cca7fb8SGeorge KeishingSuite Teardown Execution
4248cca7fb8SGeorge Keishing    [Documentation]  Do the post suite teardown.
4258cca7fb8SGeorge Keishing
4268cca7fb8SGeorge Keishing    Redfish.Logout
4278cca7fb8SGeorge Keishing
4288cca7fb8SGeorge Keishing
429b0a491f2SGeorge KeishingTest Setup Execution
4308cca7fb8SGeorge Keishing   [Documentation]  Do test case setup tasks.
4318cca7fb8SGeorge Keishing
4320b76e421SGeorge Keishing    Redfish Purge Event Log
4330b76e421SGeorge Keishing
4348cca7fb8SGeorge Keishing    ${status}=  Run Keyword And Return Status  Logging Test Binary Exist
4358cca7fb8SGeorge Keishing    Run Keyword If  ${status} == ${False}  Install Tarball
4368cca7fb8SGeorge Keishing
4378cca7fb8SGeorge Keishing
4388cca7fb8SGeorge KeishingTest Teardown Execution
4398cca7fb8SGeorge Keishing    [Documentation]  Do the post test teardown.
4408cca7fb8SGeorge Keishing
4418cca7fb8SGeorge Keishing    FFDC On Test Case Fail
442e5c5ebdfSGeorge Keishing    Redfish.Login
443b0a491f2SGeorge Keishing    Redfish Purge Event Log
4448cca7fb8SGeorge Keishing
4458cca7fb8SGeorge Keishing
446*20c08e41SRahul MaheshwariGet Redfish Error Entries
447*20c08e41SRahul Maheshwari    [Documentation]  Return Redfish error ids list.
448*20c08e41SRahul Maheshwari    ${error_uris}=  redfish_utils.get_member_list  /redfish/v1/Systems/system/LogServices/EventLog/Entries
449*20c08e41SRahul Maheshwari    ${error_ids}=  Create List
450*20c08e41SRahul Maheshwari
451*20c08e41SRahul Maheshwari    FOR  ${error_uri}  IN  @{error_uris}
452*20c08e41SRahul Maheshwari      ${error_id}=  Fetch From Right  ${error_uri}  /
453*20c08e41SRahul Maheshwari      Append To List  ${error_ids}  ${error_id}
454*20c08e41SRahul Maheshwari    END
455*20c08e41SRahul Maheshwari
456*20c08e41SRahul Maheshwari    [Return]  ${error_ids}
457*20c08e41SRahul Maheshwari
458*20c08e41SRahul Maheshwari
4598cca7fb8SGeorge KeishingEvent Log Should Not Exist
4608cca7fb8SGeorge Keishing    [Documentation]  Event log entries should not exist.
4618cca7fb8SGeorge Keishing
4628cca7fb8SGeorge Keishing    ${elogs}=  Get Event Logs
4638cca7fb8SGeorge Keishing    Should Be Empty  ${elogs}  msg=System event log entry is not empty.
464b0a491f2SGeorge Keishing
465b0a491f2SGeorge Keishing
466b0a491f2SGeorge KeishingEvent Log Should Exist
467b0a491f2SGeorge Keishing    [Documentation]  Event log entries should exist.
468b0a491f2SGeorge Keishing
469b0a491f2SGeorge Keishing    ${elogs}=  Get Event Logs
470b0a491f2SGeorge Keishing    Should Not Be Empty  ${elogs}  msg=System event log entry is not empty.
471d35b5319SGeorge Keishing
472d35b5319SGeorge Keishing
473d35b5319SGeorge KeishingVerify Watchdog EventLog Content
474d35b5319SGeorge Keishing    [Documentation]  Verify watchdog event log content.
475d35b5319SGeorge Keishing
476d35b5319SGeorge Keishing    # Example:
477d35b5319SGeorge Keishing    # {
478d35b5319SGeorge Keishing    #    "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
479d35b5319SGeorge Keishing    #    "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/31",
480d35b5319SGeorge Keishing    #    "@odata.type": "#LogEntry.v1_4_0.LogEntry",
481d35b5319SGeorge Keishing    #    "Created": "2019-05-31T18:41:33+00:00",
482d35b5319SGeorge Keishing    #    "EntryType": "Event",
483d35b5319SGeorge Keishing    #    "Id": "31",
484d35b5319SGeorge Keishing    #    "Message": "org.open_power.Host.Boot.Error.WatchdogTimedOut",
485d35b5319SGeorge Keishing    #    "Name": "System DBus Event Log Entry",
486d35b5319SGeorge Keishing    #    "Severity": "Critical"
487d35b5319SGeorge Keishing    # }
488d35b5319SGeorge Keishing
489d35b5319SGeorge Keishing    ${elog}=  Get Event Logs
490d35b5319SGeorge Keishing    Should Be Equal As Strings
491d35b5319SGeorge Keishing    ...  ${elog[0]["Message"]}  org.open_power.Host.Boot.Error.WatchdogTimedOut
492d35b5319SGeorge Keishing    ...  msg=Watchdog timeout event log was not found.
493d35b5319SGeorge Keishing    Should Be Equal As Strings
494d35b5319SGeorge Keishing    ...  ${elog[0]["Severity"]}  Critical
495d35b5319SGeorge Keishing    ...  msg=Watchdog timeout severity unexpected value.
496