blob: fcfdeefcc3d40120ec3bea3538ab5e24a674a04b [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
George Keishing76a5daf2018-09-14 06:00:01 -050011Library String
George Keishing6a514ef2018-08-27 05:19:19 -050012Resource ../lib/resource.txt
13Resource ../lib/rest_client.robot
14Resource ../lib/utils.robot
15Resource ../lib/openbmc_ffdc.robot
George Keishing76a5daf2018-09-14 06:00:01 -050016Resource ../lib/boot_utils.robot
George Keishing9a0d4802018-08-31 13:29:40 -050017Library ../lib/gen_misc.py
George Keishing6a514ef2018-08-27 05:19:19 -050018
19Suite Setup Suite Setup Execution
George Keishing216e5842018-08-31 14:58:15 -050020Test Setup Test Setup Execution
George Keishing6a514ef2018-08-27 05:19:19 -050021Test Teardown FFDC On Test Case Fail
22
George Keishing2cec1862018-09-03 12:59:25 -050023*** Variables ***
24
25${BMC_STOP_MSG} Stopping Phosphor IPMI BT DBus Bridge
26${BMC_START_MSG} Starting Flush Journal to Persistent Storage
27${BMC_BOOT_MSG} Startup finished in
28
George Keishingc1ca5e92018-09-03 11:19:23 -050029# Strings to check from journald.
George Keishing76a5daf2018-09-14 06:00:01 -050030${RSYSLOG_REGEX} start|exiting on signal 15
31${BMC_SYSLOG_REGEX} dropbear|vrm-control.sh|
George Keishingc1ca5e92018-09-03 11:19:23 -050032
George Keishing6a514ef2018-08-27 05:19:19 -050033*** Test Cases ***
34
George Keishing13a64e62018-09-10 13:07:36 -050035Verify REST Logging On BMC Journal When Disabled
36 [Documentation] Enable REST logging and verify from journald.
George Keishingb77a3572018-09-13 23:26:28 -050037 [Tags] Verify_REST_Logging_On_BMC_Journal_When_Disabled
George Keishing13a64e62018-09-10 13:07:36 -050038
39 ${log_dict}= Create Dictionary data=${False}
40 Write Attribute ${BMC_LOGGING_URI}${/}rest_api_logs Enabled data=${log_dict}
41 ... verify=${True} expected_value=${False}
42
43 Initialize OpenBMC
44
45 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
46 ... journalctl --no-pager
47
48 Should Not Contain ${bmc_journald} user:root POST http://127.0.0.1:8081/login json:None 200 OK
49 ... msg=${bmc_journald} contains unexpected REST entries.
50
51
George Keishingb77a3572018-09-13 23:26:28 -050052Verify REST Logging On BMC Journal When Enabled
George Keishing13a64e62018-09-10 13:07:36 -050053 [Documentation] Enable REST logging and verify from journald.
George Keishingb77a3572018-09-13 23:26:28 -050054 [Tags] Verify_REST_Logging_On_BMC_Journal_When_Enabled
George Keishing13a64e62018-09-10 13:07:36 -050055
56 ${log_dict}= Create Dictionary data=${True}
57 Write Attribute ${BMC_LOGGING_URI}${/}rest_api_logs Enabled data=${log_dict}
58 ... verify=${True} expected_value=${True}
59
60 # 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
61 Initialize OpenBMC
62
63 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
64 ... journalctl --no-pager
65
66 Should Contain ${bmc_journald} user:root POST http://127.0.0.1:8081/login json:None 200 OK
67 ... msg=${bmc_journald} doesn't contains REST entries.
68
69
George Keishing6a514ef2018-08-27 05:19:19 -050070Test Remote Logging REST Interface And Verify Config
71 [Documentation] Test remote logging interface and configuration.
72 [Tags] Test_Remote_Logging_REST_Interface_And_Verify_Config
73
George Keishing6a514ef2018-08-27 05:19:19 -050074 Verify Rsyslog Config On BMC
75
76 Configure Remote Logging Server remote_host=${EMPTY} remote_port=0
77 Verify Rsyslog Config On BMC remote_host=remote-host remote_port=port
78
79
George Keishingc1ca5e92018-09-03 11:19:23 -050080Verify Rsyslog Does Not Log On BMC
81 [Documentation] Check that rsyslog journald doesn't log on BMC.
82 [Tags] Verify_Rsyslog_Does_Not_Log_On_BMC
83
84 # Expected filter rsyslog entries.
85 # Example:
86 # 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.
87 # 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
88 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
89 ... journalctl -b --no-pager | egrep 'rsyslog' | egrep -Ev '${RSYSLOG_REGEX}'
90 ... ignore_err=${1}
91
92 Should Be Empty ${bmc_journald}
93 ... msg=${bmc_journald} contains unexpected rsyslog entries.
94
95
George Keishing67133672018-08-31 10:23:15 -050096Verfiy BMC Journald Synced To Remote Logging Server
97 [Documentation] Check that BMC journald is sync to remote rsyslog.
98 [Tags] Verfiy_BMC_Journald_Synced_To_Remote_Logging_Server
99
George Keishing67133672018-08-31 10:23:15 -0500100 # Restart BMC dump service and get the last entry of the journald.
101 # Example:
George Keishing216e5842018-08-31 14:58:15 -0500102 # Sep 03 10:09:28 wsbmc123 systemd[1]: Started Phosphor Dump Manager.
George Keishing67133672018-08-31 10:23:15 -0500103 BMC Execute Command
104 ... systemctl restart xyz.openbmc_project.Dump.Manager.service
105
106 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
George Keishing82ea1d42018-09-11 13:45:36 -0500107 ... journalctl --no-pager | grep 'Started Phosphor Dump Manager'
George Keishing67133672018-08-31 10:23:15 -0500108
George Keishing216e5842018-08-31 14:58:15 -0500109 # Sep 3 10:09:28 wsbmc123 systemd[1]: Started Phosphor Dump Manager.
George Keishing82ea1d42018-09-11 13:45:36 -0500110 ${cmd}= Catenate SEPARATOR= egrep '${bmc_hostname}.*Started Phosphor Dump Manager' /var/log/syslog
George Keishing67133672018-08-31 10:23:15 -0500111 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
112
George Keishing216e5842018-08-31 14:58:15 -0500113 # TODO: rsyslog configuration and time date template to match BMC journald.
114 # Compare the BMC journlad log. Example:
115 # systemd[1]: Started Phosphor Dump Manager.
George Keishing82ea1d42018-09-11 13:45:36 -0500116 Should Contain ${remote_journald} ${bmc_journald.split('${bmc_hostname}')[1][0]}
George Keishing216e5842018-08-31 14:58:15 -0500117 ... msg= ${bmc_journald} doesn't match remote rsyslog:${remote_journald}.
George Keishing67133672018-08-31 10:23:15 -0500118
119
George Keishing2cec1862018-09-03 12:59:25 -0500120Verify Journald Post BMC Reset
121 [Documentation] Check that BMC journald is sync'ed to remote rsyslog after
122 ... BMC reset.
123 [Tags] Verify_Journald_Post_BMC_Reset
124
125 ${hostname} ${stderr} ${rc}= BMC Execute Command hostname
126 OBMC Reboot (off)
127
128 ${cmd}= Catenate grep ${hostname} /var/log/syslog |
129 ... egrep '${BMC_STOP_MSG}|${BMC_START_MSG}|${BMC_BOOT_MSG}'
130 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
131
132 # 1. Last reboot message to verify.
133 Should Contain ${remote_journald} ${BMC_STOP_MSG}
134 ... msg=The remote journald doesn't contain the IPMI shutdown message: ${BMC_STOP_MSG}.
135
136 # 2. Earliest booting message on journald.
137 Should Contain ${remote_journald} ${BMC_START_MSG}
138 ... msg=The remote journald doesn't contain the start message: ${BMC_START_MSG}.
139
140 # 3. Unique boot to standby message.
141 # Startup finished in 9.961s (kernel) + 1min 59.039s (userspace) = 2min 9.000s
142 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
143 ... journalctl --no-pager | egrep '${BMC_BOOT_MSG}' | tail -1
144
145 Should Contain ${remote_journald}
146 ... ${bmc_journald.split('${hostname}')[1]}
147 ... msg=The remote journald doesn't contain the boot message: ${BMC_BOOT_MSG}.
148
149
George Keishingcc18f7c2018-09-03 09:40:11 -0500150Verify BMC Journald Contains No Credential Data
George Keishingcb3b9b62018-09-14 12:11:19 -0500151 [Documentation] Check that BMC journald doesn't log any credential data.
George Keishingcc18f7c2018-09-03 09:40:11 -0500152 [Tags] Verify_BMC_Journald_Contains_No_Credential_Data
153
154 Open Connection And Log In
155 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
156 ... journalctl -o json-pretty | cat
157
158 Should Not Contain Any ${bmc_journald} ${OPENBMC_PASSWORD}
159 ... msg=Journald logs BMC credentials/password ${OPENBMC_PASSWORD}.
160
161
George Keishing9a0d4802018-08-31 13:29:40 -0500162Audit BMC SSH Login And Remote Logging
163 [Documentation] Check that the SSH login to BMC is logged and synced to
164 ... remote logging server.
165 [Tags] Audit_BMC_SSH_Login_And_Remote_Logging
166
167 ${test_host_name} ${test_host_ip}= Get Host Name IP
168
169 # Aug 31 17:22:55 wsbmc123 systemd[1]: Started SSH Per-Connection Server (xx.xx.xx.xx:51292)
170 Open Connection And Log In
George Keishing82ea1d42018-09-11 13:45:36 -0500171 Sleep 3s
George Keishing9a0d4802018-08-31 13:29:40 -0500172 ${login_footprint}= Catenate Started SSH Per-Connection Server.*${test_host_ip}
173
174 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
George Keishing13a64e62018-09-10 13:07:36 -0500175 ... journalctl --no-pager | grep '${login_footprint}' | tail -1
George Keishing9a0d4802018-08-31 13:29:40 -0500176
George Keishing13a64e62018-09-10 13:07:36 -0500177 ${cmd}= Catenate SEPARATOR= egrep '(${bmc_hostname}|${test_host_ip}).*${login_footprint}' /var/log/syslog
George Keishing9a0d4802018-08-31 13:29:40 -0500178
179 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
180
George Keishing82ea1d42018-09-11 13:45:36 -0500181 Should Contain ${remote_journald} ${bmc_journald.split('${bmc_hostname}')[1][0]}
George Keishing9a0d4802018-08-31 13:29:40 -0500182 ... msg=${remote_journald} don't contain ${bmc_journald} entry.
183
184
George Keishing76a5daf2018-09-14 06:00:01 -0500185Boot Host And Verify Data Is Synced To Remote Server
186 [Documentation] Boot host and verify the power on sequence logs are synced
187 ... to remote logging server.
188 [Tags] Boot_Host_And_Verify_Data_Is_Synced_To_Remote_Server
189
190 ${cmd}= Catenate SEPARATOR= --no-pager | egrep -Ev '${BMC_SYSLOG_REGEX}'
191 ... | awk -F': ' '{print $2}'
192
193 # Example: Just get the message part of the syslog
194 # Started OpenPOWER OCC Active Disable.
195 Start Journal Log filter=${cmd}
196
197 # Irrespective of the outcome, the journald should be synced.
198 Run Keyword And Ignore Error REST Power On
199 ${bmc_journald}= Stop Journal Log
200
201 ${cmd}= Catenate SEPARATOR= egrep '${bmc_hostname}' /var/log/syslog
202 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
203
204 @{lines}= Split To Lines ${bmc_journald}
205 :FOR ${line} IN @{lines}
206 \ Log To Console \n ${line}
207 \ Should Contain ${remote_journald} ${line}
208 ... mgs=${line} line doesn't contain in ${remote_journald}.
209
210
George Keishing6a514ef2018-08-27 05:19:19 -0500211*** Keywords ***
212
213Suite Setup Execution
214 [Documentation] Do the suite setup.
215
216 Should Not Be Empty ${REMOTE_LOG_SERVER_HOST}
217 Should Not Be Empty ${REMOTE_LOG_SERVER_PORT}
George Keishing67133672018-08-31 10:23:15 -0500218 Should Not Be Empty ${REMOTE_USERNAME}
219 Should Not Be Empty ${REMOTE_PASSWORD}
George Keishing6a514ef2018-08-27 05:19:19 -0500220 Ping Host ${REMOTE_LOG_SERVER_HOST}
George Keishing67133672018-08-31 10:23:15 -0500221 Remote Logging Server Execute Command true
George Keishing6a514ef2018-08-27 05:19:19 -0500222 Remote Logging Interface Should Exist
223
George Keishing216e5842018-08-31 14:58:15 -0500224 ${hostname} ${stderr} ${rc}= BMC Execute Command /bin/hostname
225 Set Suite Variable ${bmc_hostname} ${hostname}
George Keishing13a64e62018-09-10 13:07:36 -0500226 Configure Remote Logging Server
George Keishing216e5842018-08-31 14:58:15 -0500227
228
229Test Setup Execution
230 [Documentation] Do the test setup.
231
George Keishingb77a3572018-09-13 23:26:28 -0500232 # Retain only the past 1 second log:
233 BMC Execute Command journalctl --vacuum-time=1s
George Keishing13a64e62018-09-10 13:07:36 -0500234
235 ${config_status}= Run Keyword And Return Status
George Keishing216e5842018-08-31 14:58:15 -0500236 ... Get Remote Log Server Configured
237
238 Run Keyword If ${config_status}==${FALSE} Configure Remote Logging Server
239
240 ${ActiveState}= Get Service Attribute ActiveState rsyslog.service
241 Should Be Equal active ${ActiveState}
242 ... msg=rsyslog logging service not in active state.
243
George Keishing6a514ef2018-08-27 05:19:19 -0500244
245Remote Logging Interface Should Exist
246 [Documentation] Check that the remote logging URI exist.
247
248 ${resp}= OpenBMC Get Request ${REMOTE_LOGGING_URI}
249 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
250
251
252Configure Remote Logging Server
253 [Documentation] Configure the remote logging server on BMC.
254 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
255 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
256
257 # Description of argument(s):
258 # remote_host The host name or IP address of the remote logging server
259 # (e.g. "xx.xx.xx.xx").
260 # remote_port Remote ryslog server port number (e.g. "514").
261
262 # Example:
263 # https://xx.xx.xx.xx/xyz/openbmc_project/logging/config/remote
264 # Response code:200, Content:{
265 # "data": {
266 # "Address": "xx.xx.xx.xx",
267 # "Port": 514
268 # },
269 # "message": "200 OK",
270 # "status": "ok"
271 # }
272
273 ${host_dict}= Create Dictionary data=${remote_host}
274 Write Attribute ${REMOTE_LOGGING_URI} Address data=${host_dict}
275 ... verify=${TRUE} expected_value=${remote_host}
276
George Keishing216e5842018-08-31 14:58:15 -0500277 # TODO: From Dev to do bump up restart service time and bulk address and
278 # port update API.
279 # Reference: https://github.com/ibm-openbmc/dev/issues/59
280 Sleep 10s
281
George Keishing6a514ef2018-08-27 05:19:19 -0500282 ${remote_port}= Convert To Integer ${remote_port}
283 ${port_dict}= Create Dictionary data=${remote_port}
284 Write Attribute ${REMOTE_LOGGING_URI} Port data=${port_dict}
285 ... verify=${TRUE} expected_value=${remote_port}
286
George Keishing216e5842018-08-31 14:58:15 -0500287 # TODO: From Dev to do bump up restart service time and bulk address and
288 # port update API.
289 # Reference: https://github.com/ibm-openbmc/dev/issues/59
290 Sleep 10s
291
George Keishing6a514ef2018-08-27 05:19:19 -0500292
293Verify Rsyslog Config On BMC
294 [Documentation] Check if the rsyslog configuration on BMC is correct.
295 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
296 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
297
298 # Description of argument(s):
299 # remote_host The host name or IP address of the remote logging server
300 # (e.g. "xx.xx.xx.xx").
301 # remote_port Remote ryslog server port number (e.g. "514").
302
303 # Example:
304 # Configured:
305 # *.* @@xx.xx.xx.xx:514root@wsbmc123
306 # By default:
307 # #*.* @@remote-host:port
308
309 ${ryslog_conf} ${stderr} ${rc}= BMC Execute Command
310 ... cat /etc/rsyslog.d/server.conf
311
312 ${config}= Catenate @@${remote_host}:${remote_port}
313
314 Should Contain ${ryslog_conf} ${config}
315 ... msg=${remote_host} and ${remote_port} are not configured.
George Keishing67133672018-08-31 10:23:15 -0500316
317
318Remote Logging Server Execute Command
319 [Documentation] Login to remote logging server.
320 [Arguments] ${command}
321 ... ${remote_host}=${REMOTE_LOG_SERVER_HOST}
George Keishing216e5842018-08-31 14:58:15 -0500322 ... ${username}=${REMOTE_USERNAME}
323 ... ${password}=${REMOTE_PASSWORD}
324
325 # Description of argument(s):
326 # command Command line string.
327 # remote_host The host name or IP address of the remote logging server
328 # (e.g. "xx.xx.xx.xx").
329 # username Remote rsyslog server user name.
330 # password Remote rsyslog server password.
George Keishing67133672018-08-31 10:23:15 -0500331
332 ${remote_dict}= Create Dictionary host=${remote_host}
George Keishing216e5842018-08-31 14:58:15 -0500333 Open Connection And Log In ${username} ${password}
George Keishing67133672018-08-31 10:23:15 -0500334 ... &{remote_dict}
335 ${stdout} ${stderr}= Execute Command ${command} return_stderr=True
George Keishing13a64e62018-09-10 13:07:36 -0500336 Should Be Empty ${stderr}
George Keishing67133672018-08-31 10:23:15 -0500337 [Return] ${stdout}
338
George Keishing216e5842018-08-31 14:58:15 -0500339
340Get Remote Log Server Configured
341 [Documentation] Check that remote logging server is not configured.
342
343 ${address}= Read Attribute ${REMOTE_LOGGING_URI} Address
344 Should Not Be Equal ${address} ${REMOTE_LOG_SERVER_HOST}
345
346 ${port_number}= Convert To Integer ${REMOTE_LOG_SERVER_PORT}
347 ${port}= Read Attribute ${REMOTE_LOGGING_URI} Port
348 Should Not Be Equal ${port} ${port_number}