blob: 3b07a05798d1d08d0788cbd50ecc1a6e153225d4 [file] [log] [blame]
George Keishing6a514ef2018-08-27 05:19:19 -05001*** Settings ***
2Documentation Remote logging test for rsyslog.
3
4# Program arguments:
5# REMOTE_LOG_SERVER_HOST The host name or IP address of the remote
George Keishing67133672018-08-31 10:23:15 -05006# logging server.
George Keishing6a514ef2018-08-27 05:19:19 -05007# REMOTE_LOG_SERVER_PORT The port number for the remote logging server.
George Keishing67133672018-08-31 10:23:15 -05008# REMOTE_USERNAME The username for the remote logging server.
9# REMOTE_PASSWORD The password for the remote logging server.
George Keishing6a514ef2018-08-27 05:19:19 -050010
11Resource ../lib/resource.txt
12Resource ../lib/rest_client.robot
13Resource ../lib/utils.robot
14Resource ../lib/openbmc_ffdc.robot
George Keishing9a0d4802018-08-31 13:29:40 -050015Library ../lib/gen_misc.py
George Keishing6a514ef2018-08-27 05:19:19 -050016
17Suite Setup Suite Setup Execution
George Keishing216e5842018-08-31 14:58:15 -050018Test Setup Test Setup Execution
George Keishing6a514ef2018-08-27 05:19:19 -050019Test Teardown FFDC On Test Case Fail
20
George Keishing2cec1862018-09-03 12:59:25 -050021*** Variables ***
22
23${BMC_STOP_MSG} Stopping Phosphor IPMI BT DBus Bridge
24${BMC_START_MSG} Starting Flush Journal to Persistent Storage
25${BMC_BOOT_MSG} Startup finished in
26
George Keishingc1ca5e92018-09-03 11:19:23 -050027# Strings to check from journald.
28${RSYSLOG_REGEX} start|exiting on signal 15
29
George Keishing6a514ef2018-08-27 05:19:19 -050030*** Test Cases ***
31
George Keishing13a64e62018-09-10 13:07:36 -050032Verify REST Logging On BMC Journal When Disabled
33 [Documentation] Enable REST logging and verify from journald.
34 [Tags] Verify_REST_Logging_On_BMC Journal_When_Disabled
35
36 ${log_dict}= Create Dictionary data=${False}
37 Write Attribute ${BMC_LOGGING_URI}${/}rest_api_logs Enabled data=${log_dict}
38 ... verify=${True} expected_value=${False}
39
40 Initialize OpenBMC
41
42 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
43 ... journalctl --no-pager
44
45 Should Not Contain ${bmc_journald} user:root POST http://127.0.0.1:8081/login json:None 200 OK
46 ... msg=${bmc_journald} contains unexpected REST entries.
47
48
49Verify REST Logging On BMC Journal When Enable
50 [Documentation] Enable REST logging and verify from journald.
51 [Tags] Verify_REST_Logging_On_BMC Journal_When_Enable
52
53 ${log_dict}= Create Dictionary data=${True}
54 Write Attribute ${BMC_LOGGING_URI}${/}rest_api_logs Enabled data=${log_dict}
55 ... verify=${True} expected_value=${True}
56
57 # Sep 10 14:34:35 witherspoon phosphor-gevent[1288]: 127.0.0.1 user:root POST http://127.0.0.1:8081/login json:None 200 OK
58 Initialize OpenBMC
59
60 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
61 ... journalctl --no-pager
62
63 Should Contain ${bmc_journald} user:root POST http://127.0.0.1:8081/login json:None 200 OK
64 ... msg=${bmc_journald} doesn't contains REST entries.
65
66
George Keishing6a514ef2018-08-27 05:19:19 -050067Test Remote Logging REST Interface And Verify Config
68 [Documentation] Test remote logging interface and configuration.
69 [Tags] Test_Remote_Logging_REST_Interface_And_Verify_Config
70
George Keishing6a514ef2018-08-27 05:19:19 -050071 Verify Rsyslog Config On BMC
72
73 Configure Remote Logging Server remote_host=${EMPTY} remote_port=0
74 Verify Rsyslog Config On BMC remote_host=remote-host remote_port=port
75
76
George Keishingc1ca5e92018-09-03 11:19:23 -050077Verify Rsyslog Does Not Log On BMC
78 [Documentation] Check that rsyslog journald doesn't log on BMC.
79 [Tags] Verify_Rsyslog_Does_Not_Log_On_BMC
80
81 # Expected filter rsyslog entries.
82 # Example:
83 # Sep 03 13:20:07 wsbmc123 rsyslogd[3356]: [origin software="rsyslogd" swVersion="8.29.0" x-pid="3356" x-info="http://www.rsyslog.com"] exiting on signal 15.
84 # Sep 03 13:20:18 wsbmc123 rsyslogd[3364]: [origin software="rsyslogd" swVersion="8.29.0" x-pid="3364" x-info="http://www.rsyslog.com"] start
85 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
86 ... journalctl -b --no-pager | egrep 'rsyslog' | egrep -Ev '${RSYSLOG_REGEX}'
87 ... ignore_err=${1}
88
89 Should Be Empty ${bmc_journald}
90 ... msg=${bmc_journald} contains unexpected rsyslog entries.
91
92
George Keishing67133672018-08-31 10:23:15 -050093Verfiy BMC Journald Synced To Remote Logging Server
94 [Documentation] Check that BMC journald is sync to remote rsyslog.
95 [Tags] Verfiy_BMC_Journald_Synced_To_Remote_Logging_Server
96
George Keishing67133672018-08-31 10:23:15 -050097 # Restart BMC dump service and get the last entry of the journald.
98 # Example:
George Keishing216e5842018-08-31 14:58:15 -050099 # Sep 03 10:09:28 wsbmc123 systemd[1]: Started Phosphor Dump Manager.
George Keishing67133672018-08-31 10:23:15 -0500100 BMC Execute Command
101 ... systemctl restart xyz.openbmc_project.Dump.Manager.service
102
103 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
George Keishing82ea1d42018-09-11 13:45:36 -0500104 ... journalctl --no-pager | grep 'Started Phosphor Dump Manager'
George Keishing67133672018-08-31 10:23:15 -0500105
George Keishing216e5842018-08-31 14:58:15 -0500106 # Sep 3 10:09:28 wsbmc123 systemd[1]: Started Phosphor Dump Manager.
George Keishing82ea1d42018-09-11 13:45:36 -0500107 ${cmd}= Catenate SEPARATOR= egrep '${bmc_hostname}.*Started Phosphor Dump Manager' /var/log/syslog
George Keishing67133672018-08-31 10:23:15 -0500108 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
109
George Keishing216e5842018-08-31 14:58:15 -0500110 # TODO: rsyslog configuration and time date template to match BMC journald.
111 # Compare the BMC journlad log. Example:
112 # systemd[1]: Started Phosphor Dump Manager.
George Keishing82ea1d42018-09-11 13:45:36 -0500113 Should Contain ${remote_journald} ${bmc_journald.split('${bmc_hostname}')[1][0]}
George Keishing216e5842018-08-31 14:58:15 -0500114 ... msg= ${bmc_journald} doesn't match remote rsyslog:${remote_journald}.
George Keishing67133672018-08-31 10:23:15 -0500115
116
George Keishing2cec1862018-09-03 12:59:25 -0500117Verify Journald Post BMC Reset
118 [Documentation] Check that BMC journald is sync'ed to remote rsyslog after
119 ... BMC reset.
120 [Tags] Verify_Journald_Post_BMC_Reset
121
122 ${hostname} ${stderr} ${rc}= BMC Execute Command hostname
123 OBMC Reboot (off)
124
125 ${cmd}= Catenate grep ${hostname} /var/log/syslog |
126 ... egrep '${BMC_STOP_MSG}|${BMC_START_MSG}|${BMC_BOOT_MSG}'
127 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
128
129 # 1. Last reboot message to verify.
130 Should Contain ${remote_journald} ${BMC_STOP_MSG}
131 ... msg=The remote journald doesn't contain the IPMI shutdown message: ${BMC_STOP_MSG}.
132
133 # 2. Earliest booting message on journald.
134 Should Contain ${remote_journald} ${BMC_START_MSG}
135 ... msg=The remote journald doesn't contain the start message: ${BMC_START_MSG}.
136
137 # 3. Unique boot to standby message.
138 # Startup finished in 9.961s (kernel) + 1min 59.039s (userspace) = 2min 9.000s
139 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
140 ... journalctl --no-pager | egrep '${BMC_BOOT_MSG}' | tail -1
141
142 Should Contain ${remote_journald}
143 ... ${bmc_journald.split('${hostname}')[1]}
144 ... msg=The remote journald doesn't contain the boot message: ${BMC_BOOT_MSG}.
145
146
George Keishingcc18f7c2018-09-03 09:40:11 -0500147Verify BMC Journald Contains No Credential Data
148 [Documentation] Check that BMC journald doesnt log any credential data.
149 [Tags] Verify_BMC_Journald_Contains_No_Credential_Data
150
151 Open Connection And Log In
152 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
153 ... journalctl -o json-pretty | cat
154
155 Should Not Contain Any ${bmc_journald} ${OPENBMC_PASSWORD}
156 ... msg=Journald logs BMC credentials/password ${OPENBMC_PASSWORD}.
157
158
George Keishing9a0d4802018-08-31 13:29:40 -0500159Audit BMC SSH Login And Remote Logging
160 [Documentation] Check that the SSH login to BMC is logged and synced to
161 ... remote logging server.
162 [Tags] Audit_BMC_SSH_Login_And_Remote_Logging
163
164 ${test_host_name} ${test_host_ip}= Get Host Name IP
165
166 # Aug 31 17:22:55 wsbmc123 systemd[1]: Started SSH Per-Connection Server (xx.xx.xx.xx:51292)
167 Open Connection And Log In
George Keishing82ea1d42018-09-11 13:45:36 -0500168 Sleep 3s
George Keishing9a0d4802018-08-31 13:29:40 -0500169 ${login_footprint}= Catenate Started SSH Per-Connection Server.*${test_host_ip}
170
171 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
George Keishing13a64e62018-09-10 13:07:36 -0500172 ... journalctl --no-pager | grep '${login_footprint}' | tail -1
George Keishing9a0d4802018-08-31 13:29:40 -0500173
George Keishing13a64e62018-09-10 13:07:36 -0500174 ${cmd}= Catenate SEPARATOR= egrep '(${bmc_hostname}|${test_host_ip}).*${login_footprint}' /var/log/syslog
George Keishing9a0d4802018-08-31 13:29:40 -0500175
176 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
177
George Keishing82ea1d42018-09-11 13:45:36 -0500178 Should Contain ${remote_journald} ${bmc_journald.split('${bmc_hostname}')[1][0]}
George Keishing9a0d4802018-08-31 13:29:40 -0500179 ... msg=${remote_journald} don't contain ${bmc_journald} entry.
180
181
George Keishing6a514ef2018-08-27 05:19:19 -0500182*** Keywords ***
183
184Suite Setup Execution
185 [Documentation] Do the suite setup.
186
187 Should Not Be Empty ${REMOTE_LOG_SERVER_HOST}
188 Should Not Be Empty ${REMOTE_LOG_SERVER_PORT}
George Keishing67133672018-08-31 10:23:15 -0500189 Should Not Be Empty ${REMOTE_USERNAME}
190 Should Not Be Empty ${REMOTE_PASSWORD}
George Keishing6a514ef2018-08-27 05:19:19 -0500191 Ping Host ${REMOTE_LOG_SERVER_HOST}
George Keishing67133672018-08-31 10:23:15 -0500192 Remote Logging Server Execute Command true
George Keishing6a514ef2018-08-27 05:19:19 -0500193 Remote Logging Interface Should Exist
194
George Keishing216e5842018-08-31 14:58:15 -0500195 ${hostname} ${stderr} ${rc}= BMC Execute Command /bin/hostname
196 Set Suite Variable ${bmc_hostname} ${hostname}
George Keishing13a64e62018-09-10 13:07:36 -0500197 Configure Remote Logging Server
George Keishing216e5842018-08-31 14:58:15 -0500198
199
200Test Setup Execution
201 [Documentation] Do the test setup.
202
George Keishing13a64e62018-09-10 13:07:36 -0500203 # TODO: Enable when fixed openbmc/phosphor-rest-server#26
204 #Remove Journald Logs
205
206 ${config_status}= Run Keyword And Return Status
George Keishing216e5842018-08-31 14:58:15 -0500207 ... Get Remote Log Server Configured
208
209 Run Keyword If ${config_status}==${FALSE} Configure Remote Logging Server
210
211 ${ActiveState}= Get Service Attribute ActiveState rsyslog.service
212 Should Be Equal active ${ActiveState}
213 ... msg=rsyslog logging service not in active state.
214
George Keishing6a514ef2018-08-27 05:19:19 -0500215
216Remote Logging Interface Should Exist
217 [Documentation] Check that the remote logging URI exist.
218
219 ${resp}= OpenBMC Get Request ${REMOTE_LOGGING_URI}
220 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
221
222
223Configure Remote Logging Server
224 [Documentation] Configure the remote logging server on BMC.
225 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
226 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
227
228 # Description of argument(s):
229 # remote_host The host name or IP address of the remote logging server
230 # (e.g. "xx.xx.xx.xx").
231 # remote_port Remote ryslog server port number (e.g. "514").
232
233 # Example:
234 # https://xx.xx.xx.xx/xyz/openbmc_project/logging/config/remote
235 # Response code:200, Content:{
236 # "data": {
237 # "Address": "xx.xx.xx.xx",
238 # "Port": 514
239 # },
240 # "message": "200 OK",
241 # "status": "ok"
242 # }
243
244 ${host_dict}= Create Dictionary data=${remote_host}
245 Write Attribute ${REMOTE_LOGGING_URI} Address data=${host_dict}
246 ... verify=${TRUE} expected_value=${remote_host}
247
George Keishing216e5842018-08-31 14:58:15 -0500248 # TODO: From Dev to do bump up restart service time and bulk address and
249 # port update API.
250 # Reference: https://github.com/ibm-openbmc/dev/issues/59
251 Sleep 10s
252
George Keishing6a514ef2018-08-27 05:19:19 -0500253 ${remote_port}= Convert To Integer ${remote_port}
254 ${port_dict}= Create Dictionary data=${remote_port}
255 Write Attribute ${REMOTE_LOGGING_URI} Port data=${port_dict}
256 ... verify=${TRUE} expected_value=${remote_port}
257
George Keishing216e5842018-08-31 14:58:15 -0500258 # TODO: From Dev to do bump up restart service time and bulk address and
259 # port update API.
260 # Reference: https://github.com/ibm-openbmc/dev/issues/59
261 Sleep 10s
262
George Keishing6a514ef2018-08-27 05:19:19 -0500263
264Verify Rsyslog Config On BMC
265 [Documentation] Check if the rsyslog configuration on BMC is correct.
266 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
267 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
268
269 # Description of argument(s):
270 # remote_host The host name or IP address of the remote logging server
271 # (e.g. "xx.xx.xx.xx").
272 # remote_port Remote ryslog server port number (e.g. "514").
273
274 # Example:
275 # Configured:
276 # *.* @@xx.xx.xx.xx:514root@wsbmc123
277 # By default:
278 # #*.* @@remote-host:port
279
280 ${ryslog_conf} ${stderr} ${rc}= BMC Execute Command
281 ... cat /etc/rsyslog.d/server.conf
282
283 ${config}= Catenate @@${remote_host}:${remote_port}
284
285 Should Contain ${ryslog_conf} ${config}
286 ... msg=${remote_host} and ${remote_port} are not configured.
George Keishing67133672018-08-31 10:23:15 -0500287
288
289Remote Logging Server Execute Command
290 [Documentation] Login to remote logging server.
291 [Arguments] ${command}
292 ... ${remote_host}=${REMOTE_LOG_SERVER_HOST}
George Keishing216e5842018-08-31 14:58:15 -0500293 ... ${username}=${REMOTE_USERNAME}
294 ... ${password}=${REMOTE_PASSWORD}
295
296 # Description of argument(s):
297 # command Command line string.
298 # remote_host The host name or IP address of the remote logging server
299 # (e.g. "xx.xx.xx.xx").
300 # username Remote rsyslog server user name.
301 # password Remote rsyslog server password.
George Keishing67133672018-08-31 10:23:15 -0500302
303 ${remote_dict}= Create Dictionary host=${remote_host}
George Keishing216e5842018-08-31 14:58:15 -0500304 Open Connection And Log In ${username} ${password}
George Keishing67133672018-08-31 10:23:15 -0500305 ... &{remote_dict}
306 ${stdout} ${stderr}= Execute Command ${command} return_stderr=True
George Keishing13a64e62018-09-10 13:07:36 -0500307 Should Be Empty ${stderr}
George Keishing67133672018-08-31 10:23:15 -0500308 [Return] ${stdout}
309
George Keishing216e5842018-08-31 14:58:15 -0500310
311Get Remote Log Server Configured
312 [Documentation] Check that remote logging server is not configured.
313
314 ${address}= Read Attribute ${REMOTE_LOGGING_URI} Address
315 Should Not Be Equal ${address} ${REMOTE_LOG_SERVER_HOST}
316
317 ${port_number}= Convert To Integer ${REMOTE_LOG_SERVER_PORT}
318 ${port}= Read Attribute ${REMOTE_LOGGING_URI} Port
319 Should Not Be Equal ${port} ${port_number}