blob: be713b50a228df106300af869e3688e70f0675bd [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
George Keishing4d6c1da2016-07-15 05:51:22 -05002Documentation This suite is used for testing the error logging
3... capability from the host
Chris Austenb29d2e82016-06-07 12:25:35 -05004
George Keishing4d6c1da2016-07-15 05:51:22 -05005Resource ../lib/rest_client.robot
6Resource ../lib/utils.robot
7Resource ../lib/connection_client.robot
George Keishingd55a4be2016-08-26 03:28:17 -05008Resource ../lib/openbmc_ffdc.robot
George Keishing29ef22d2017-01-30 09:11:29 -06009Resource ../lib/state_manager.robot
Chris Austenb29d2e82016-06-07 12:25:35 -050010
George Keishing4d6c1da2016-07-15 05:51:22 -050011Library Collections
Chris Austenb29d2e82016-06-07 12:25:35 -050012
Rahul Maheshwari06174f22017-03-06 03:17:09 -060013Test Setup Open Connection And Log In
14Test Teardown Post Test Case Execution
Chris Austenb29d2e82016-06-07 12:25:35 -050015
Sridevi Ramesh066a7b12017-01-19 10:01:28 -060016Force Tags Event_Logging
17
Chris Austenb29d2e82016-06-07 12:25:35 -050018*** Variables ***
19&{NIL} data=@{EMPTY}
20${SYSTEM_SHUTDOWN_TIME} 1min
21${WAIT_FOR_SERVICES_UP} 3min
22
George Keishingec807372016-12-05 03:54:51 -060023${EVENT_RECORD} ${RECORDS_URI}events/
24
Chris Austenb29d2e82016-06-07 12:25:35 -050025*** Test Cases ***
26
27valid path to logs
28 [Documentation] Test list all events
Chris Austen859be602016-07-07 16:46:31 -050029 [Tags] CI
George Keishingec807372016-12-05 03:54:51 -060030 ${resp}= openbmc get request ${EVENT_RECORD}
Chris Austenb29d2e82016-06-07 12:25:35 -050031 should be equal as strings ${resp.status_code} ${HTTP_OK}
32
33clear any logs
34 [Documentation] Test delete all events
George Keishing97651c72016-10-04 00:44:15 -050035 [Tags] CI clear_any_logs
George Keishingec807372016-12-05 03:54:51 -060036 ${resp}= openbmc post request ${EVENT_RECORD}action/clear data=${NIL}
Chris Austenb29d2e82016-06-07 12:25:35 -050037 should be equal as strings ${resp.status_code} ${HTTP_OK}
George Keishingec807372016-12-05 03:54:51 -060038 ${resp}= openbmc get request ${EVENT_RECORD}
Gunnar Mills1cd544d2016-12-06 11:19:22 -060039 ${json}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -050040 Should Be Empty ${json['data']}
41
42write a log
43 [Documentation] Test create event
George Keishing97651c72016-10-04 00:44:15 -050044 [Tags] CI write_a_log
Chris Austenb29d2e82016-06-07 12:25:35 -050045 create a test log
46
47Message attribute should match
48 [Documentation] Check message attribute for created event
Chris Austen859be602016-07-07 16:46:31 -050049 [Tags] CI
Gunnar Mills1cd544d2016-12-06 11:19:22 -060050 ${uri}= create a test log
51 ${content}= Read Attribute ${uri} message
Chris Austenb29d2e82016-06-07 12:25:35 -050052 Should Be Equal ${content} A Test event log just happened
53
54Severity attribute should match
55 [Documentation] Check severity attribute for created event
Chris Austen859be602016-07-07 16:46:31 -050056 [Tags] CI
Gunnar Mills1cd544d2016-12-06 11:19:22 -060057 ${uri}= create a test log
Chris Austenb29d2e82016-06-07 12:25:35 -050058 ${content}= Read Attribute ${uri} severity
59 Should Be Equal ${content} Info
60
61data_bytes attribute should match
62 [Documentation] Check data_bytes attribute for created event
Chris Austen859be602016-07-07 16:46:31 -050063 [Tags] CI
Gunnar Mills1cd544d2016-12-06 11:19:22 -060064 @{data_list}= Create List ${48} ${0} ${19} ${127} ${136} ${255}
65 ${uri}= create a test log
66 ${content}= Read Attribute ${uri} debug_data
Chris Austenb29d2e82016-06-07 12:25:35 -050067 Lists Should Be Equal ${content} ${data_list}
68
69delete the log
70 [Documentation] Test the delete event
Chris Austen859be602016-07-07 16:46:31 -050071 [Tags] CI
Gunnar Mills1cd544d2016-12-06 11:19:22 -060072 ${uri}= create a test log
73 ${deluri}= catenate SEPARATOR= ${uri} /action/delete
74 ${resp}= openbmc post request ${deluri} data=${NIL}
Chris Austenb29d2e82016-06-07 12:25:35 -050075 should be equal as strings ${resp.status_code} ${HTTP_OK}
Gunnar Mills1cd544d2016-12-06 11:19:22 -060076 ${resp}= openbmc get request ${deluri}
Chris Austenb29d2e82016-06-07 12:25:35 -050077 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
78
792nd delete should fail
80 [Documentation] Negative scnenario to delete already deleted event
Chris Austen859be602016-07-07 16:46:31 -050081 [Tags] CI
Gunnar Mills1cd544d2016-12-06 11:19:22 -060082 ${uri}= create a test log
83 ${deluri}= catenate SEPARATOR= ${uri} /action/delete
84 ${resp}= openbmc post request ${deluri} data=${NIL}
Chris Austenb29d2e82016-06-07 12:25:35 -050085 should be equal as strings ${resp.status_code} ${HTTP_OK}
Gunnar Mills1cd544d2016-12-06 11:19:22 -060086 ${resp}= openbmc post request ${deluri} data=${NIL}
Chris Austenb29d2e82016-06-07 12:25:35 -050087 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
88
89Intermixed delete
George Keishing70490c32016-09-20 10:55:46 -050090 [Documentation] This testcase does the following sequence
Chris Austenb29d2e82016-06-07 12:25:35 -050091 ... Steps:
92 ... write three logs
93 ... delete middle log
94 ... middle log should not exist
Chris Austen859be602016-07-07 16:46:31 -050095 [Tags] CI
Chris Austenb29d2e82016-06-07 12:25:35 -050096 ${event1}= create a test log
97 ${event2}= create a test log
98 ${event3}= create a test log
Gunnar Mills1cd544d2016-12-06 11:19:22 -060099 ${deluri}= catenate SEPARATOR= ${event2} /action/delete
100 ${resp}= openbmc post request ${deluri} data=${NIL}
Chris Austenb29d2e82016-06-07 12:25:35 -0500101 should be equal as strings ${resp.status_code} ${HTTP_OK}
George Keishing70490c32016-09-20 10:55:46 -0500102 ${resp}= openbmc get request ${event2}
103 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
Chris Austenb29d2e82016-06-07 12:25:35 -0500104
George Keishingbf5442c2016-12-06 01:57:44 -0600105Test Event Logs Persistency
106 [Documentation] Create event logs, restart the event service
107 ... and verify if logs persist.
108 [Tags] CI Test_Event_Logs_Persistency
George Keishingec807372016-12-05 03:54:51 -0600109 ${resp}= openbmc get request ${EVENT_RECORD}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600110 ${json}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -0500111 ${logs_pre_restart}= set variable ${json['data']}
112
George Keishingbf5442c2016-12-06 01:57:44 -0600113 ${output} ${stderr} ${rc}= Execute Command
114 ... systemctl restart org.openbmc.records.events.service
115 ... return_stderr=True return_rc=True
116 Should Be Empty ${stderr}
117 Should Be Equal ${rc} ${0}
Chris Austenb29d2e82016-06-07 12:25:35 -0500118 Sleep ${10}
119
George Keishingec807372016-12-05 03:54:51 -0600120 ${resp}= openbmc get request ${EVENT_RECORD}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600121 ${json}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -0500122 ${logs_post_restart}= set variable ${json['data']}
George Keishingbf5442c2016-12-06 01:57:44 -0600123 List Should Contain Sub List
124 ... ${logs_post_restart} ${logs_pre_restart}
125 ... msg=The event logs are mismatched.
Chris Austenb29d2e82016-06-07 12:25:35 -0500126
Chris Austenb29d2e82016-06-07 12:25:35 -0500127
George Keishingbf5442c2016-12-06 01:57:44 -0600128Test Event Deletion Post Restarting Event Manager
129 [Documentation] Create event log, restart event service and
130 ... delete the event created earlier.
131 [Tags] CI Test_Event_Deletion Post_Restarting_Event_Manager
132
133 ${uri}= create a test log
134
135 ${output} ${stderr} ${rc}= Execute Command
136 ... systemctl restart org.openbmc.records.events.service
137 ... return_stderr=True return_rc=True
138 Should Be Empty ${stderr}
139 Should Be Equal ${rc} ${0}
Chris Austenb29d2e82016-06-07 12:25:35 -0500140 Sleep ${10}
141
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600142 ${deluri}= catenate SEPARATOR= ${uri} /action/delete
143 ${resp}= openbmc post request ${deluri} data=${NIL}
Chris Austenb29d2e82016-06-07 12:25:35 -0500144 should be equal as strings ${resp.status_code} ${HTTP_OK}
145
George Keishing410b6292016-07-05 10:40:16 -0500146making new log after obmc-phosphor-event.service restart
Chris Austenb29d2e82016-06-07 12:25:35 -0500147 [Documentation] This is for testing event creation after the
148 ... event service is restarted.
Chris Austen859be602016-07-07 16:46:31 -0500149 [Tags] CI
George Keishingbf5442c2016-12-06 01:57:44 -0600150 ${output} ${stderr} ${rc}= Execute Command
151 ... systemctl restart org.openbmc.records.events.service
152 ... return_stderr=True return_rc=True
153 Should Be Empty ${stderr}
154 Should Be Equal ${rc} ${0}
Chris Austenb29d2e82016-06-07 12:25:35 -0500155 Sleep ${10}
156
157 create a test log
158
159deleting new log after obmc-phosphor-event.service restart
George Keishingbf5442c2016-12-06 01:57:44 -0600160 [Documentation] This testcase is for testing deleted newly created event
161 ... after event service is restarted.
Chris Austen859be602016-07-07 16:46:31 -0500162 [Tags] CI
George Keishingbf5442c2016-12-06 01:57:44 -0600163 ${output} ${stderr} ${rc}= Execute Command
164 ... systemctl restart org.openbmc.records.events.service
165 ... return_stderr=True return_rc=True
166 Should Be Empty ${stderr}
167 Should Be Equal ${rc} ${0}
Chris Austenb29d2e82016-06-07 12:25:35 -0500168 Sleep ${10}
169
170 ${uri}= create a test log
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600171 ${deluri}= catenate SEPARATOR= ${uri} /action/delete
172 ${resp}= openbmc post request ${deluri} data=${NIL}
Chris Austenb29d2e82016-06-07 12:25:35 -0500173 should be equal as strings ${resp.status_code} ${HTTP_OK}
174
175Test events after openbmc reboot
176 [Documentation] This is to test event can be deleted created prior to
177 ... openbmc reboot
178 ... Steps:
179 ... Create event,
George Keishingf88767a2016-11-17 01:58:05 -0600180 ... Power off if ON else no-op
Chris Austenb29d2e82016-06-07 12:25:35 -0500181 ... Reboot openbmc,
George Keishing17982fb2016-11-08 04:59:37 -0600182 ... Wait for BMC to READY or Powered OFF state
Chris Austenb29d2e82016-06-07 12:25:35 -0500183 ... Events should exist post reboot,
184 ... Create two more events,
185 ... Delete old and new event
causten147f5752016-08-11 16:24:45 -0500186 [Tags] bmcreboot
Chris Austenb29d2e82016-06-07 12:25:35 -0500187 ${pre_reboot_event}= create a test log
188
George Keishing29ef22d2017-01-30 09:11:29 -0600189 Initiate Host PowerOff
George Keishingf88767a2016-11-17 01:58:05 -0600190
Sridevi Ramesh742b3b52017-02-05 12:14:33 -0600191 Initiate BMC Reboot
Chris Austenb29d2e82016-06-07 12:25:35 -0500192
George Keishing29ef22d2017-01-30 09:11:29 -0600193 Wait Until Keyword Succeeds 10 min 10 sec Is BMC Ready
George Keishing17982fb2016-11-08 04:59:37 -0600194
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600195 ${resp}= openbmc get request ${pre_reboot_event}
Chris Austenb29d2e82016-06-07 12:25:35 -0500196 should be equal as strings ${resp.status_code} ${HTTP_OK}
197 ${post_reboot_event1}= create a test log
Chris Austenb29d2e82016-06-07 12:25:35 -0500198
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600199 ${del_prereboot_uri}= catenate SEPARATOR= ${pre_reboot_event} /action/delete
200 ${resp}= openbmc post request ${del_prereboot_uri} data=${NIL}
Chris Austenb29d2e82016-06-07 12:25:35 -0500201 should be equal as strings ${resp.status_code} ${HTTP_OK}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600202 ${del_postreboot_uri}= catenate SEPARATOR= ${post_reboot_event1} /action/delete
203 ${resp}= openbmc post request ${del_postreboot_uri} data=${NIL}
Chris Austenb29d2e82016-06-07 12:25:35 -0500204 should be equal as strings ${resp.status_code} ${HTTP_OK}
205
206clearing logs results in no logs
207 [Documentation] This testcase is for clearning the events when no logs present
Chris Austen859be602016-07-07 16:46:31 -0500208 [Tags] CI
George Keishingec807372016-12-05 03:54:51 -0600209 ${resp}= openbmc post request ${EVENT_RECORD}action/clear data=${NIL}
Chris Austenb29d2e82016-06-07 12:25:35 -0500210 should be equal as strings ${resp.status_code} ${HTTP_OK}
George Keishingec807372016-12-05 03:54:51 -0600211 ${resp}= openbmc get request ${EVENT_RECORD}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600212 ${json}= to json ${resp.content}
Chris Austenb29d2e82016-06-07 12:25:35 -0500213 Should Be Empty ${json['data']}
George Keishingbf5442c2016-12-06 01:57:44 -0600214 ${resp}= openbmc post request ${EVENT_RECORD}action/clear data=${NIL}
Chris Austenb29d2e82016-06-07 12:25:35 -0500215 should be equal as strings ${resp.status_code} ${HTTP_OK}
216
217
218*** Keywords ***
219
220create a test log
Gunnar Mills38032802016-12-12 13:43:40 -0600221 [Arguments]
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600222 ${data}= create dictionary data=@{EMPTY}
George Keishingec807372016-12-05 03:54:51 -0600223 ${resp}= openbmc post request ${EVENT_RECORD}action/acceptTestMessage data=${data}
Chris Austenb29d2e82016-06-07 12:25:35 -0500224 should be equal as strings ${resp.status_code} ${HTTP_OK}
Gunnar Mills1cd544d2016-12-06 11:19:22 -0600225 ${json}= to json ${resp.content}
226 ${LOGID}= convert to integer ${json['data']}
George Keishingec807372016-12-05 03:54:51 -0600227 ${uri}= catenate SEPARATOR= ${EVENT_RECORD} ${LOGID}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600228 [Return] ${uri}
Rahul Maheshwari06174f22017-03-06 03:17:09 -0600229
230Post Test Case Execution
231 [Documentation] Do the post test teardown.
232 ... 1. Capture FFDC on test failure.
233 ... 2. Close all open SSH connections.
234
235 FFDC On Test Case Fail
236 Close All Connections