xref: /openbmc/openbmc-test-automation/redfish/systems/eventlog/test_event_logging.robot (revision 148d08c2a272e287f51c7378ed5abf8f4c1106aa)
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
88cca7fb8SGeorge Keishing
9b0a491f2SGeorge KeishingTest Setup          Test Setup Execution
108cca7fb8SGeorge KeishingTest Teardown       Test Teardown Execution
11b0a491f2SGeorge KeishingSuite Teardown      Suite Teardown Execution
128cca7fb8SGeorge Keishing
138cca7fb8SGeorge Keishing*** Test Cases ***
148cca7fb8SGeorge Keishing
158cca7fb8SGeorge KeishingEvent Log Check After BMC Reboot
168cca7fb8SGeorge Keishing    [Documentation]  Check event log after BMC rebooted.
178cca7fb8SGeorge Keishing    [Tags]  Event_Log_Check_After_BMC_Reboot
188cca7fb8SGeorge Keishing
198cca7fb8SGeorge Keishing    Redfish Purge Event Log
208cca7fb8SGeorge Keishing    Event Log Should Not Exist
218cca7fb8SGeorge Keishing
228cca7fb8SGeorge Keishing    Redfish OBMC Reboot (off)
238cca7fb8SGeorge Keishing
248cca7fb8SGeorge Keishing    Redfish.Login
258cca7fb8SGeorge Keishing    Wait Until Keyword Succeeds  1 mins  15 secs   Redfish.Get  ${EVENT_LOG_URI}Entries
268cca7fb8SGeorge Keishing
278cca7fb8SGeorge Keishing    Event Log Should Not Exist
288cca7fb8SGeorge Keishing
298cca7fb8SGeorge Keishing
30b0a491f2SGeorge KeishingEvent Log Check After Host Poweron
31b0a491f2SGeorge Keishing    [Documentation]  Check event log after host has booted.
32b0a491f2SGeorge Keishing    [Tags]  Event_Log_Check_After_Host_Poweron
33b0a491f2SGeorge Keishing
34b0a491f2SGeorge Keishing    Redfish Purge Event Log
35b0a491f2SGeorge Keishing    Event Log Should Not Exist
36b0a491f2SGeorge Keishing
37b0a491f2SGeorge Keishing    Redfish Power On
38b0a491f2SGeorge Keishing
39b0a491f2SGeorge Keishing    Redfish.Login
40b0a491f2SGeorge Keishing    Event Log Should Not Exist
41b0a491f2SGeorge Keishing
42b0a491f2SGeorge Keishing
43b0a491f2SGeorge KeishingCreate Test Event Log And Verify
44b0a491f2SGeorge Keishing    [Documentation]  Create event logs and verify via redfish.
45b0a491f2SGeorge Keishing    [Tags]  Create_Test_Event_Log_And_Verify
46b0a491f2SGeorge Keishing
47b0a491f2SGeorge Keishing    Create Test Error Log
48b0a491f2SGeorge Keishing    Event Log Should Exist
49b0a491f2SGeorge Keishing
50b0a491f2SGeorge Keishing
51b0a491f2SGeorge KeishingTest Event Log Persistency On Restart
52b0a491f2SGeorge Keishing    [Documentation]  Restart logging service and verify event logs.
53b0a491f2SGeorge Keishing    [Tags]  Test_Event_Log_Persistency_On_Restart
54b0a491f2SGeorge Keishing
55b0a491f2SGeorge Keishing    Create Test Error Log
56b0a491f2SGeorge Keishing    Event Log Should Exist
57b0a491f2SGeorge Keishing
58b0a491f2SGeorge Keishing    BMC Execute Command
59b0a491f2SGeorge Keishing    ...  systemctl restart xyz.openbmc_project.Logging.service
60b0a491f2SGeorge Keishing    Sleep  10s  reason=Wait for logging service to restart properly.
61b0a491f2SGeorge Keishing
62b0a491f2SGeorge Keishing    Event Log Should Exist
63b0a491f2SGeorge Keishing
64b0a491f2SGeorge Keishing
65b0a491f2SGeorge KeishingTest Event Entry Numbering Reset On Restart
66b0a491f2SGeorge Keishing    [Documentation]  Restart logging service and verify event logs entry starts
67b0a491f2SGeorge Keishing    ...  from entry "Id" 1.
68b0a491f2SGeorge Keishing    [Tags]  Test_Event_Entry_Numbering_Reset_On_Restart
69b0a491f2SGeorge Keishing
70b0a491f2SGeorge Keishing    #{
71b0a491f2SGeorge Keishing    #  "@odata.context": "/redfish/v1/$metadata#LogEntryCollection.LogEntryCollection",
72b0a491f2SGeorge Keishing    #  "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries",
73b0a491f2SGeorge Keishing    #  "@odata.type": "#LogEntryCollection.LogEntryCollection",
74b0a491f2SGeorge Keishing    #  "Description": "Collection of System Event Log Entries",
75b0a491f2SGeorge Keishing    #  "Members": [
76b0a491f2SGeorge Keishing    #  {
77b0a491f2SGeorge Keishing    #    "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
78b0a491f2SGeorge Keishing    #    "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1",
79b0a491f2SGeorge Keishing    #    "@odata.type": "#LogEntry.v1_4_0.LogEntry",
80b0a491f2SGeorge Keishing    #    "Created": "2019-05-29T13:19:27+00:00",
81b0a491f2SGeorge Keishing    #    "EntryType": "Event",
82b0a491f2SGeorge Keishing    #    "Id": "1",               <----- Event log ID
83b0a491f2SGeorge Keishing    #    "Message": "org.open_power.Host.Error.Event",
84b0a491f2SGeorge Keishing    #    "Name": "System DBus Event Log Entry",
85b0a491f2SGeorge Keishing    #    "Severity": "Critical"
86b0a491f2SGeorge Keishing    #  }
87b0a491f2SGeorge Keishing    #  ],
88b0a491f2SGeorge Keishing    #  "Members@odata.count": 1,
89b0a491f2SGeorge Keishing    #  "Name": "System Event Log Entries"
90b0a491f2SGeorge Keishing    #}
91b0a491f2SGeorge Keishing
92b0a491f2SGeorge Keishing    Create Test Error Log
93b0a491f2SGeorge Keishing    Create Test Error Log
94b0a491f2SGeorge Keishing    Event Log Should Exist
95b0a491f2SGeorge Keishing
96b0a491f2SGeorge Keishing    Redfish Purge Event Log
97b0a491f2SGeorge Keishing    Event Log Should Not Exist
98b0a491f2SGeorge Keishing
99b0a491f2SGeorge Keishing    BMC Execute Command
100b0a491f2SGeorge Keishing    ...  systemctl restart xyz.openbmc_project.Logging.service
101b0a491f2SGeorge Keishing    Sleep  10s  reason=Wait for logging service to restart properly.
102b0a491f2SGeorge Keishing
103b0a491f2SGeorge Keishing    Create Test Error Log
104b0a491f2SGeorge Keishing    ${elogs}=  Get Event Logs
105b0a491f2SGeorge Keishing    Should Be Equal  ${elogs[0]["Id"]}  1  msg=Event log entry is not 1.
106b0a491f2SGeorge Keishing
107b0a491f2SGeorge Keishing
108b0a491f2SGeorge KeishingTest Event Log Persistency On Reboot
109b0a491f2SGeorge Keishing    [Documentation]  Reboot BMC and verify event log.
110b0a491f2SGeorge Keishing    [Tags]  Test_Event_Log_Persistency_On_Reboot
111b0a491f2SGeorge Keishing
112b0a491f2SGeorge Keishing    Redfish Purge Event Log
113b0a491f2SGeorge Keishing    Create Test Error Log
114b0a491f2SGeorge Keishing    Event Log Should Exist
115b0a491f2SGeorge Keishing
116b0a491f2SGeorge Keishing    Redfish OBMC Reboot (off)
117b0a491f2SGeorge Keishing
118b0a491f2SGeorge Keishing    Redfish.Login
119b0a491f2SGeorge Keishing    Wait Until Keyword Succeeds  1 mins  15 secs   Redfish.Get  ${EVENT_LOG_URI}Entries
120b0a491f2SGeorge Keishing
121b0a491f2SGeorge Keishing    Event Log Should Exist
122b0a491f2SGeorge Keishing
123b0a491f2SGeorge Keishing
124*148d08c2SGeorge KeishingCreate Test Event Log And Verify Time Stamp
125*148d08c2SGeorge Keishing    [Documentation]  Create event logs and verify time stamp.
126*148d08c2SGeorge Keishing    [Tags]  Create_Test_Event_Log_And_Verify_Time_Stamp
127*148d08c2SGeorge Keishing
128*148d08c2SGeorge Keishing    #{
129*148d08c2SGeorge Keishing    #  "@odata.context": "/redfish/v1/$metadata#LogEntryCollection.LogEntryCollection",
130*148d08c2SGeorge Keishing    #  "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries",
131*148d08c2SGeorge Keishing    #  "@odata.type": "#LogEntryCollection.LogEntryCollection",
132*148d08c2SGeorge Keishing    #  "Description": "Collection of System Event Log Entries",
133*148d08c2SGeorge Keishing    #  "Members": [
134*148d08c2SGeorge Keishing    #  {
135*148d08c2SGeorge Keishing    #    "@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
136*148d08c2SGeorge Keishing    #    "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog/Entries/1",
137*148d08c2SGeorge Keishing    #    "@odata.type": "#LogEntry.v1_4_0.LogEntry",
138*148d08c2SGeorge Keishing    #    "Created": "2019-05-29T13:19:27+00:00", <--- Time stamp
139*148d08c2SGeorge Keishing    #    "EntryType": "Event",
140*148d08c2SGeorge Keishing    #    "Id": "1",
141*148d08c2SGeorge Keishing    #    "Message": "org.open_power.Host.Error.Event",
142*148d08c2SGeorge Keishing    #    "Name": "System DBus Event Log Entry",
143*148d08c2SGeorge Keishing    #    "Severity": "Critical"
144*148d08c2SGeorge Keishing    #  }
145*148d08c2SGeorge Keishing    #  ],
146*148d08c2SGeorge Keishing    #  "Members@odata.count": 1,
147*148d08c2SGeorge Keishing    #  "Name": "System Event Log Entries"
148*148d08c2SGeorge Keishing    #}
149*148d08c2SGeorge Keishing
150*148d08c2SGeorge Keishing    Redfish Purge Event Log
151*148d08c2SGeorge Keishing
152*148d08c2SGeorge Keishing    Create Test Error Log
153*148d08c2SGeorge Keishing    Sleep  2s
154*148d08c2SGeorge Keishing    Create Test Error Log
155*148d08c2SGeorge Keishing
156*148d08c2SGeorge Keishing    ${elog_entry}=  Get Event Logs
157*148d08c2SGeorge Keishing
158*148d08c2SGeorge Keishing    # The event log generated is associated with the epoc time and unique
159*148d08c2SGeorge Keishing    # for every error and in increasing time stamp.
160*148d08c2SGeorge Keishing    ${time_stamp1}=  Convert Date  ${elog_entry[0]["Created"]}  epoch
161*148d08c2SGeorge Keishing    ${time_stamp2}=  Convert Date  ${elog_entry[1]["Created"]}  epoch
162*148d08c2SGeorge Keishing
163*148d08c2SGeorge Keishing    Should Be True  ${time_stamp2} > ${time_stamp1}
164*148d08c2SGeorge Keishing
165*148d08c2SGeorge Keishing
1668cca7fb8SGeorge Keishing*** Keywords ***
1678cca7fb8SGeorge Keishing
1688cca7fb8SGeorge KeishingSuite Teardown Execution
1698cca7fb8SGeorge Keishing    [Documentation]  Do the post suite teardown.
1708cca7fb8SGeorge Keishing
1718cca7fb8SGeorge Keishing    Redfish.Logout
1728cca7fb8SGeorge Keishing
1738cca7fb8SGeorge Keishing
174b0a491f2SGeorge KeishingTest Setup Execution
1758cca7fb8SGeorge Keishing   [Documentation]  Do test case setup tasks.
1768cca7fb8SGeorge Keishing
1778cca7fb8SGeorge Keishing    Redfish.Login
1788cca7fb8SGeorge Keishing
1798cca7fb8SGeorge Keishing    ${status}=  Run Keyword And Return Status  Logging Test Binary Exist
1808cca7fb8SGeorge Keishing    Run Keyword If  ${status} == ${False}  Install Tarball
1818cca7fb8SGeorge Keishing
1828cca7fb8SGeorge Keishing
1838cca7fb8SGeorge KeishingTest Teardown Execution
1848cca7fb8SGeorge Keishing    [Documentation]  Do the post test teardown.
1858cca7fb8SGeorge Keishing
1868cca7fb8SGeorge Keishing    FFDC On Test Case Fail
187b0a491f2SGeorge Keishing    Redfish Purge Event Log
1888cca7fb8SGeorge Keishing
1898cca7fb8SGeorge Keishing
1908cca7fb8SGeorge KeishingEvent Log Should Not Exist
1918cca7fb8SGeorge Keishing    [Documentation]  Event log entries should not exist.
1928cca7fb8SGeorge Keishing
1938cca7fb8SGeorge Keishing    ${elogs}=  Get Event Logs
1948cca7fb8SGeorge Keishing    Should Be Empty  ${elogs}  msg=System event log entry is not empty.
195b0a491f2SGeorge Keishing
196b0a491f2SGeorge Keishing
197b0a491f2SGeorge KeishingEvent Log Should Exist
198b0a491f2SGeorge Keishing    [Documentation]  Event log entries should exist.
199b0a491f2SGeorge Keishing
200b0a491f2SGeorge Keishing    ${elogs}=  Get Event Logs
201b0a491f2SGeorge Keishing    Should Not Be Empty  ${elogs}  msg=System event log entry is not empty.
202