blob: 660d449a8b93a72dc60de5ec47d5d53ce9326e53 [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
22 ${resp} = openbmc get request /org/openbmc/records/events/
23 should be equal as strings ${resp.status_code} ${HTTP_OK}
24
25clear any logs
26 [Documentation] Test delete all events
27 ${resp} = openbmc post request /org/openbmc/records/events/action/clear data=${NIL}
28 should be equal as strings ${resp.status_code} ${HTTP_OK}
29 ${resp} = openbmc get request /org/openbmc/records/events/
30 ${json} = to json ${resp.content}
31 Should Be Empty ${json['data']}
32
33write a log
34 [Documentation] Test create event
35 create a test log
36
37Message attribute should match
38 [Documentation] Check message attribute for created event
39 ${uri} = create a test log
40 ${content} = Read Attribute ${uri} message
41 Should Be Equal ${content} A Test event log just happened
42
43Severity attribute should match
44 [Documentation] Check severity attribute for created event
45 ${uri} = create a test log
46 ${content}= Read Attribute ${uri} severity
47 Should Be Equal ${content} Info
48
49data_bytes attribute should match
50 [Documentation] Check data_bytes attribute for created event
51 @{data_list} = Create List ${48} ${0} ${19} ${127} ${136} ${255}
52 ${uri} = create a test log
53 ${content} = Read Attribute ${uri} debug_data
54 Lists Should Be Equal ${content} ${data_list}
55
56delete the log
57 [Documentation] Test the delete event
58 ${uri} = create a test log
59 ${deluri} = catenate SEPARATOR= ${uri} /action/delete
60 ${resp} = openbmc post request ${deluri} data=${NIL}
61 should be equal as strings ${resp.status_code} ${HTTP_OK}
62 ${resp} = openbmc get request ${deluri}
63 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
64
652nd delete should fail
66 [Documentation] Negative scnenario to delete already deleted event
67 ${uri} = create a test log
68 ${deluri} = catenate SEPARATOR= ${uri} /action/delete
69 ${resp} = openbmc post request ${deluri} data=${NIL}
70 should be equal as strings ${resp.status_code} ${HTTP_OK}
71 ${resp} = openbmc post request ${deluri} data=${NIL}
72 should be equal as strings ${resp.status_code} ${HTTP_NOT_FOUND}
73
74Intermixed delete
75 [Documentation] This testcase is for excersicing caching impleted,
76 ... Steps:
77 ... write three logs
78 ... delete middle log
79 ... middle log should not exist
80 ... time stamp should not match between logs(1st and 3rd)
81 ${event1}= create a test log
82 ${event2}= create a test log
83 ${event3}= create a test log
84 ${deluri} = catenate SEPARATOR= ${event2} /action/delete
85 ${resp} = openbmc post request ${deluri} data=${NIL}
86 should be equal as strings ${resp.status_code} ${HTTP_OK}
87 ${time_event1}= Read Attribute ${event1} time
88 ${time_event3}= Read Attribute ${event3} time
89 should not be equal ${time_event1} ${time_event3}
90
91restarting event process retains logs
92 [Documentation] This is to test events are in place even after the
93 ... event service is restarted.
94 ${resp} = openbmc get request /org/openbmc/records/events/
95 ${json} = to json ${resp.content}
96 ${logs_pre_restart}= set variable ${json['data']}
97
98 Open Connection And Log In
99 ${uptime}= Execute Command systemctl restart obmc-phosphor-event.service
100 Sleep ${10}
101
102 ${resp} = openbmc get request /org/openbmc/records/events/
103 ${json} = to json ${resp.content}
104 ${logs_post_restart}= set variable ${json['data']}
105 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
106
107deleting log after obmc-phosphor-event.service restart
108 [Documentation] This is to test event can be deleted created prior to
109 ... event service is restarted.
110 ${uri}= create a test log
111
112 Open Connection And Log In
113 ${uptime}= Execute Command systemctl restart obmc-phosphor-event.service
114 Sleep ${10}
115
116 ${deluri} = catenate SEPARATOR= ${uri} /action/delete
117 ${resp} = openbmc post request ${deluri} data=${NIL}
118 should be equal as strings ${resp.status_code} ${HTTP_OK}
119
120makeing new log after obmc-phosphor-event.service restart
121 [Documentation] This is for testing event creation after the
122 ... event service is restarted.
123 Open Connection And Log In
124 ${uptime}= Execute Command systemctl restart obmc-phosphor-event.service
125 Sleep ${10}
126
127 create a test log
128
129deleting new log after obmc-phosphor-event.service restart
130 [Documentation] This testcase is for testing deleted newly created event
131 ... after event service is restarted.
132 Open Connection And Log In
133 ${uptime}= Execute Command systemctl restart obmc-phosphor-event.service
134 Sleep ${10}
135
136 ${uri}= create a test log
137 ${deluri} = catenate SEPARATOR= ${uri} /action/delete
138 ${resp} = openbmc post request ${deluri} data=${NIL}
139 should be equal as strings ${resp.status_code} ${HTTP_OK}
140
141Test events after openbmc reboot
142 [Documentation] This is to test event can be deleted created prior to
143 ... openbmc reboot
144 ... Steps:
145 ... Create event,
146 ... Reboot openbmc,
147 ... Events should exist post reboot,
148 ... Create two more events,
149 ... Delete old and new event
150 [Tags] reboot_tests
151 ${pre_reboot_event}= create a test log
152
153 Open Connection And Log In
154 ${output}= Execute Command /sbin/reboot
155 Sleep ${SYSTEM_SHUTDOWN_TIME}
156 Wait For Host To Ping ${OPENBMC_HOST}
157 Sleep ${WAIT_FOR_SERVICES_UP}
158
159 ${resp} = openbmc get request ${pre_reboot_event}
160 should be equal as strings ${resp.status_code} ${HTTP_OK}
161 ${post_reboot_event1}= create a test log
162 ${post_reboot_event2}= create a test log
163
164 ${del_prereboot_uri} = catenate SEPARATOR= ${pre_reboot_event} /action/delete
165 ${resp} = openbmc post request ${del_prereboot_uri} data=${NIL}
166 should be equal as strings ${resp.status_code} ${HTTP_OK}
167 ${del_postreboot_uri} = catenate SEPARATOR= ${post_reboot_event1} /action/delete
168 ${resp} = openbmc post request ${del_postreboot_uri} data=${NIL}
169 should be equal as strings ${resp.status_code} ${HTTP_OK}
170
171clearing logs results in no logs
172 [Documentation] This testcase is for clearning the events when no logs present
173 ${resp} = openbmc post request /org/openbmc/records/events/action/clear data=${NIL}
174 should be equal as strings ${resp.status_code} ${HTTP_OK}
175 ${resp} = openbmc get request /org/openbmc/records/events/
176 ${json} = to json ${resp.content}
177 Should Be Empty ${json['data']}
178 ${resp} = openbmc post request /org/openbmc/records/events/action/clear data=${NIL}
179 should be equal as strings ${resp.status_code} ${HTTP_OK}
180
181
182*** Keywords ***
183
184create a test log
185 [arguments]
186 ${data} = create dictionary data=@{EMPTY}
187 ${resp} = openbmc post request /org/openbmc/records/events/action/acceptTestMessage data=${data}
188 should be equal as strings ${resp.status_code} ${HTTP_OK}
189 ${json} = to json ${resp.content}
190 ${LOGID} = convert to integer ${json['data']}
191 ${uri}= catenate SEPARATOR= /org/openbmc/records/events/ ${LOGID}
192 [return] ${uri}
193
194Open Connection And Log In
195 Open connection ${OPENBMC_HOST}
196 Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}