blob: 8280f78b4ca912facf6697642ac1df3bd7dfd94f [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
2Documentation This suite is used for testing the error logging
3... capability from the host
4
5Resource ../lib/rest_client.robot
6Resource ../lib/utils.robot
7
8
9Library BuiltIn
10Library Collections
11Library SSHLibrary
12
13*** Variables ***
14&{NIL} data=@{EMPTY}
15${SYSTEM_SHUTDOWN_TIME} 1min
16${WAIT_FOR_SERVICES_UP} 3min
17
18*** Test Cases ***
19
20valid path to logs
21 [Documentation] Test list all events
Chris Austen859be602016-07-07 16:46:31 -050022 [Tags] CI
Chris Austenb29d2e82016-06-07 12:25:35 -050023 ${resp} = openbmc get request /org/openbmc/records/events/
24 should be equal as strings ${resp.status_code} ${HTTP_OK}
25
26clear any logs
27 [Documentation] Test delete all events
Chris Austen859be602016-07-07 16:46:31 -050028 [Tags] CI
Chris Austenb29d2e82016-06-07 12:25:35 -050029 ${resp} = openbmc post request /org/openbmc/records/events/action/clear data=${NIL}
30 should be equal as strings ${resp.status_code} ${HTTP_OK}
31 ${resp} = openbmc get request /org/openbmc/records/events/
32 ${json} = to json ${resp.content}
33 Should Be Empty ${json['data']}
34
35write a log
36 [Documentation] Test create event
Chris Austen859be602016-07-07 16:46:31 -050037 [Tags] CI
Chris Austenb29d2e82016-06-07 12:25:35 -050038 create a test log
39
40Message attribute should match
41 [Documentation] Check message attribute for created event
Chris Austen859be602016-07-07 16:46:31 -050042 [Tags] CI
Chris Austenb29d2e82016-06-07 12:25:35 -050043 ${uri} = create a test log
44 ${content} = Read Attribute ${uri} message
45 Should Be Equal ${content} A Test event log just happened
46
47Severity attribute should match
48 [Documentation] Check severity attribute for created event
Chris Austen859be602016-07-07 16:46:31 -050049 [Tags] CI
Chris Austenb29d2e82016-06-07 12:25:35 -050050 ${uri} = create a test log
51 ${content}= Read Attribute ${uri} severity
52 Should Be Equal ${content} Info
53
54data_bytes attribute should match
55 [Documentation] Check data_bytes attribute for created event
Chris Austen859be602016-07-07 16:46:31 -050056 [Tags] CI
Chris Austenb29d2e82016-06-07 12:25:35 -050057 @{data_list} = Create List ${48} ${0} ${19} ${127} ${136} ${255}
58 ${uri} = create a test log
59 ${content} = Read Attribute ${uri} debug_data
60 Lists Should Be Equal ${content} ${data_list}
61
62delete the log
63 [Documentation] Test the delete event
Chris Austen859be602016-07-07 16:46:31 -050064 [Tags] CI
Chris Austenb29d2e82016-06-07 12:25:35 -050065 ${uri} = create a test log
66 ${deluri} = catenate SEPARATOR= ${uri} /action/delete
67 ${resp} = openbmc post request ${deluri} data=${NIL}
68 should be equal as strings ${resp.status_code} ${HTTP_OK}
69 ${resp} = openbmc get request ${deluri}
70 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
71
722nd delete should fail
73 [Documentation] Negative scnenario to delete already deleted event
Chris Austen859be602016-07-07 16:46:31 -050074 [Tags] CI
Chris Austenb29d2e82016-06-07 12:25:35 -050075 ${uri} = create a test log
76 ${deluri} = catenate SEPARATOR= ${uri} /action/delete
77 ${resp} = openbmc post request ${deluri} data=${NIL}
78 should be equal as strings ${resp.status_code} ${HTTP_OK}
79 ${resp} = openbmc post request ${deluri} data=${NIL}
80 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
81
82Intermixed delete
83 [Documentation] This testcase is for excersicing caching impleted,
84 ... Steps:
85 ... write three logs
86 ... delete middle log
87 ... middle log should not exist
88 ... time stamp should not match between logs(1st and 3rd)
Chris Austen859be602016-07-07 16:46:31 -050089 [Tags] CI
Chris Austenb29d2e82016-06-07 12:25:35 -050090 ${event1}= create a test log
91 ${event2}= create a test log
92 ${event3}= create a test log
93 ${deluri} = catenate SEPARATOR= ${event2} /action/delete
94 ${resp} = openbmc post request ${deluri} data=${NIL}
95 should be equal as strings ${resp.status_code} ${HTTP_OK}
96 ${time_event1}= Read Attribute ${event1} time
97 ${time_event3}= Read Attribute ${event3} time
98 should not be equal ${time_event1} ${time_event3}
99
100restarting event process retains logs
101 [Documentation] This is to test events are in place even after the
102 ... event service is restarted.
Chris Austen859be602016-07-07 16:46:31 -0500103 [Tags] CI
Chris Austenb29d2e82016-06-07 12:25:35 -0500104 ${resp} = openbmc get request /org/openbmc/records/events/
105 ${json} = to json ${resp.content}
106 ${logs_pre_restart}= set variable ${json['data']}
107
108 Open Connection And Log In
109 ${uptime}= Execute Command systemctl restart obmc-phosphor-event.service
110 Sleep ${10}
111
112 ${resp} = openbmc get request /org/openbmc/records/events/
113 ${json} = to json ${resp.content}
114 ${logs_post_restart}= set variable ${json['data']}
115 List Should Contain Sub List ${logs_post_restart} ${logs_pre_restart} msg=Failed to find all the eventlogs which are present before restart of event service
116
117deleting log after obmc-phosphor-event.service restart
118 [Documentation] This is to test event can be deleted created prior to
119 ... event service is restarted.
Chris Austen859be602016-07-07 16:46:31 -0500120 [Tags] CI
Chris Austenb29d2e82016-06-07 12:25:35 -0500121 ${uri}= create a test log
122
123 Open Connection And Log In
124 ${uptime}= Execute Command systemctl restart obmc-phosphor-event.service
125 Sleep ${10}
126
127 ${deluri} = catenate SEPARATOR= ${uri} /action/delete
128 ${resp} = openbmc post request ${deluri} data=${NIL}
129 should be equal as strings ${resp.status_code} ${HTTP_OK}
130
131makeing new log after obmc-phosphor-event.service restart
132 [Documentation] This is for testing event creation after the
133 ... event service is restarted.
Chris Austen859be602016-07-07 16:46:31 -0500134 [Tags] CI
Chris Austenb29d2e82016-06-07 12:25:35 -0500135 Open Connection And Log In
136 ${uptime}= Execute Command systemctl restart obmc-phosphor-event.service
137 Sleep ${10}
138
139 create a test log
140
141deleting new log after obmc-phosphor-event.service restart
142 [Documentation] This testcase is for testing deleted newly created event
143 ... after event service is restarted.
Chris Austen859be602016-07-07 16:46:31 -0500144 [Tags] CI
Chris Austenb29d2e82016-06-07 12:25:35 -0500145 Open Connection And Log In
146 ${uptime}= Execute Command systemctl restart obmc-phosphor-event.service
147 Sleep ${10}
148
149 ${uri}= create a test log
150 ${deluri} = catenate SEPARATOR= ${uri} /action/delete
151 ${resp} = openbmc post request ${deluri} data=${NIL}
152 should be equal as strings ${resp.status_code} ${HTTP_OK}
153
154Test events after openbmc reboot
155 [Documentation] This is to test event can be deleted created prior to
156 ... openbmc reboot
157 ... Steps:
158 ... Create event,
159 ... Reboot openbmc,
160 ... Events should exist post reboot,
161 ... Create two more events,
162 ... Delete old and new event
163 [Tags] reboot_tests
164 ${pre_reboot_event}= create a test log
165
166 Open Connection And Log In
167 ${output}= Execute Command /sbin/reboot
168 Sleep ${SYSTEM_SHUTDOWN_TIME}
169 Wait For Host To Ping ${OPENBMC_HOST}
170 Sleep ${WAIT_FOR_SERVICES_UP}
171
172 ${resp} = openbmc get request ${pre_reboot_event}
173 should be equal as strings ${resp.status_code} ${HTTP_OK}
174 ${post_reboot_event1}= create a test log
175 ${post_reboot_event2}= create a test log
176
177 ${del_prereboot_uri} = catenate SEPARATOR= ${pre_reboot_event} /action/delete
178 ${resp} = openbmc post request ${del_prereboot_uri} data=${NIL}
179 should be equal as strings ${resp.status_code} ${HTTP_OK}
180 ${del_postreboot_uri} = catenate SEPARATOR= ${post_reboot_event1} /action/delete
181 ${resp} = openbmc post request ${del_postreboot_uri} data=${NIL}
182 should be equal as strings ${resp.status_code} ${HTTP_OK}
183
184clearing logs results in no logs
185 [Documentation] This testcase is for clearning the events when no logs present
Chris Austen859be602016-07-07 16:46:31 -0500186 [Tags] CI
Chris Austenb29d2e82016-06-07 12:25:35 -0500187 ${resp} = openbmc post request /org/openbmc/records/events/action/clear data=${NIL}
188 should be equal as strings ${resp.status_code} ${HTTP_OK}
189 ${resp} = openbmc get request /org/openbmc/records/events/
190 ${json} = to json ${resp.content}
191 Should Be Empty ${json['data']}
192 ${resp} = openbmc post request /org/openbmc/records/events/action/clear data=${NIL}
193 should be equal as strings ${resp.status_code} ${HTTP_OK}
194
195
196*** Keywords ***
197
198create a test log
199 [arguments]
200 ${data} = create dictionary data=@{EMPTY}
201 ${resp} = openbmc post request /org/openbmc/records/events/action/acceptTestMessage data=${data}
202 should be equal as strings ${resp.status_code} ${HTTP_OK}
203 ${json} = to json ${resp.content}
204 ${LOGID} = convert to integer ${json['data']}
205 ${uri}= catenate SEPARATOR= /org/openbmc/records/events/ ${LOGID}
206 [return] ${uri}
207
208Open Connection And Log In
209 Open connection ${OPENBMC_HOST}
210 Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}