blob: ca275c525144c99cac803ac74b52a7a8871960c5 [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
George Keishingc1ca5e92018-09-03 11:19:23 -050025# Strings to check from journald.
George Keishing13451ed2018-09-06 12:46:16 -050026${BMC_STOP_MSG} Stopping Phosphor IPMI BT DBus Bridge
27${BMC_START_MSG} Starting Flush Journal to Persistent Storage
28${BMC_BOOT_MSG} Startup finished in
29${BMC_SYSLOG_REGEX} dropbear|vrm-control.sh
30${RSYSLOG_REGEX} start|exiting on signal 15
31${RSYSLOG_RETRY_REGEX} suspended, next retry
George Keishingc1ca5e92018-09-03 11:19:23 -050032
George Keishing6a514ef2018-08-27 05:19:19 -050033*** Test Cases ***
34
George Keishingeb9fc592018-09-18 07:58:17 -050035Test BMC Hostname Service And Verify
36 [Documentation] Write to hostname interface and verify via REST and
37 ... 'hostname' command.
38 [Tags] Test_BMC_Hostname_Service_And_Verify
39
40 ${openbmc_host_name} ${openbmc_ip} ${openbmc_short_name}=
41 ... Get Host Name IP host=${OPENBMC_HOST} short_name=1
42
43 ${host_name_dict}= Create Dictionary data=${openbmc_short_name}
44 Write Attribute ${NETWORK_MANAGER}config HostName data=${host_name_dict}
45 ... verify=${TRUE} expected_value=${openbmc_short_name}
46
47 ${hostname} ${stderr} ${rc}= BMC Execute Command hostname
48
49 Should Be Equal As Strings ${hostname} ${openbmc_short_name}
50 ... msg=The hostname interface ${openbmc_short_name} and command value ${hostname} do not match.
51
52 # Override the suite hostname variable if this test is executed.
53 Set Suite Variable ${bmc_hostname} ${openbmc_short_name}
54
55
George Keishing13a64e62018-09-10 13:07:36 -050056Verify REST Logging On BMC Journal When Disabled
57 [Documentation] Enable REST logging and verify from journald.
George Keishingb77a3572018-09-13 23:26:28 -050058 [Tags] Verify_REST_Logging_On_BMC_Journal_When_Disabled
George Keishing13a64e62018-09-10 13:07:36 -050059
60 ${log_dict}= Create Dictionary data=${False}
61 Write Attribute ${BMC_LOGGING_URI}${/}rest_api_logs Enabled data=${log_dict}
62 ... verify=${True} expected_value=${False}
63
64 Initialize OpenBMC
65
66 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
67 ... journalctl --no-pager
68
69 Should Not Contain ${bmc_journald} user:root POST http://127.0.0.1:8081/login json:None 200 OK
70 ... msg=${bmc_journald} contains unexpected REST entries.
71
72
George Keishingb77a3572018-09-13 23:26:28 -050073Verify REST Logging On BMC Journal When Enabled
George Keishing13a64e62018-09-10 13:07:36 -050074 [Documentation] Enable REST logging and verify from journald.
George Keishingb77a3572018-09-13 23:26:28 -050075 [Tags] Verify_REST_Logging_On_BMC_Journal_When_Enabled
George Keishing13a64e62018-09-10 13:07:36 -050076
77 ${log_dict}= Create Dictionary data=${True}
78 Write Attribute ${BMC_LOGGING_URI}${/}rest_api_logs Enabled data=${log_dict}
79 ... verify=${True} expected_value=${True}
80
81 # 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
82 Initialize OpenBMC
83
84 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
85 ... journalctl --no-pager
86
87 Should Contain ${bmc_journald} user:root POST http://127.0.0.1:8081/login json:None 200 OK
88 ... msg=${bmc_journald} doesn't contains REST entries.
89
90
George Keishing6a514ef2018-08-27 05:19:19 -050091Test Remote Logging REST Interface And Verify Config
92 [Documentation] Test remote logging interface and configuration.
93 [Tags] Test_Remote_Logging_REST_Interface_And_Verify_Config
94
George Keishing6a514ef2018-08-27 05:19:19 -050095 Verify Rsyslog Config On BMC
96
97 Configure Remote Logging Server remote_host=${EMPTY} remote_port=0
98 Verify Rsyslog Config On BMC remote_host=remote-host remote_port=port
99
100
George Keishing13451ed2018-09-06 12:46:16 -0500101Test Remote Logging Invalid Port Config And Verify BMC Journald
102 [Documentation] Test remote logging interface and configuration.
103 [Tags] Test_Remote_Logging_Invalid_Port_Config_And_Verify_BMC_Journald
104
105 # Invalid port derived by (REMOTE_LOG_SERVER_PORT + 1) port config setting.
106 ${INVALID_PORT}= Evaluate ${REMOTE_LOG_SERVER_PORT} + ${1}
107 Configure Remote Logging Server
108 ... remote_host=${REMOTE_LOG_SERVER_HOST} remote_port=${INVALID_PORT}
109
110 Sleep 3s
111 # Sep 14 05:47:09 wsbmc123 rsyslogd[1870]: action 'action 0' suspended, next retry is Fri Sep 14 05:47:39 2018 [v8.29.0 try http://www.rsyslog.com/e/2007 ]
112 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
113 ... journalctl -b --no-pager | egrep 'rsyslog.*${RSYSLOG_RETRY_REGEX}'
114
115 Should Contain ${bmc_journald} ${RSYSLOG_RETRY_REGEX}
116 ... msg=${bmc_journald} doesn't contain rsyslog retry entries.
117
118
George Keishingc1ca5e92018-09-03 11:19:23 -0500119Verify Rsyslog Does Not Log On BMC
120 [Documentation] Check that rsyslog journald doesn't log on BMC.
121 [Tags] Verify_Rsyslog_Does_Not_Log_On_BMC
122
123 # Expected filter rsyslog entries.
124 # Example:
125 # 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.
126 # 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
127 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
128 ... journalctl -b --no-pager | egrep 'rsyslog' | egrep -Ev '${RSYSLOG_REGEX}'
129 ... ignore_err=${1}
130
131 Should Be Empty ${bmc_journald}
132 ... msg=${bmc_journald} contains unexpected rsyslog entries.
133
134
George Keishing67133672018-08-31 10:23:15 -0500135Verfiy BMC Journald Synced To Remote Logging Server
136 [Documentation] Check that BMC journald is sync to remote rsyslog.
137 [Tags] Verfiy_BMC_Journald_Synced_To_Remote_Logging_Server
138
George Keishing67133672018-08-31 10:23:15 -0500139 # Restart BMC dump service and get the last entry of the journald.
140 # Example:
George Keishing216e5842018-08-31 14:58:15 -0500141 # Sep 03 10:09:28 wsbmc123 systemd[1]: Started Phosphor Dump Manager.
George Keishing67133672018-08-31 10:23:15 -0500142 BMC Execute Command
143 ... systemctl restart xyz.openbmc_project.Dump.Manager.service
144
145 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
George Keishing82ea1d42018-09-11 13:45:36 -0500146 ... journalctl --no-pager | grep 'Started Phosphor Dump Manager'
George Keishing67133672018-08-31 10:23:15 -0500147
George Keishing216e5842018-08-31 14:58:15 -0500148 # Sep 3 10:09:28 wsbmc123 systemd[1]: Started Phosphor Dump Manager.
George Keishing82ea1d42018-09-11 13:45:36 -0500149 ${cmd}= Catenate SEPARATOR= egrep '${bmc_hostname}.*Started Phosphor Dump Manager' /var/log/syslog
George Keishing67133672018-08-31 10:23:15 -0500150 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
151
George Keishing216e5842018-08-31 14:58:15 -0500152 # TODO: rsyslog configuration and time date template to match BMC journald.
153 # Compare the BMC journlad log. Example:
154 # systemd[1]: Started Phosphor Dump Manager.
George Keishing82ea1d42018-09-11 13:45:36 -0500155 Should Contain ${remote_journald} ${bmc_journald.split('${bmc_hostname}')[1][0]}
George Keishing216e5842018-08-31 14:58:15 -0500156 ... msg= ${bmc_journald} doesn't match remote rsyslog:${remote_journald}.
George Keishing67133672018-08-31 10:23:15 -0500157
158
George Keishing2cec1862018-09-03 12:59:25 -0500159Verify Journald Post BMC Reset
160 [Documentation] Check that BMC journald is sync'ed to remote rsyslog after
161 ... BMC reset.
162 [Tags] Verify_Journald_Post_BMC_Reset
163
164 ${hostname} ${stderr} ${rc}= BMC Execute Command hostname
165 OBMC Reboot (off)
166
167 ${cmd}= Catenate grep ${hostname} /var/log/syslog |
168 ... egrep '${BMC_STOP_MSG}|${BMC_START_MSG}|${BMC_BOOT_MSG}'
169 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
170
171 # 1. Last reboot message to verify.
172 Should Contain ${remote_journald} ${BMC_STOP_MSG}
173 ... msg=The remote journald doesn't contain the IPMI shutdown message: ${BMC_STOP_MSG}.
174
175 # 2. Earliest booting message on journald.
176 Should Contain ${remote_journald} ${BMC_START_MSG}
177 ... msg=The remote journald doesn't contain the start message: ${BMC_START_MSG}.
178
179 # 3. Unique boot to standby message.
180 # Startup finished in 9.961s (kernel) + 1min 59.039s (userspace) = 2min 9.000s
181 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
182 ... journalctl --no-pager | egrep '${BMC_BOOT_MSG}' | tail -1
183
184 Should Contain ${remote_journald}
185 ... ${bmc_journald.split('${hostname}')[1]}
186 ... msg=The remote journald doesn't contain the boot message: ${BMC_BOOT_MSG}.
187
188
George Keishingcc18f7c2018-09-03 09:40:11 -0500189Verify BMC Journald Contains No Credential Data
George Keishingcb3b9b62018-09-14 12:11:19 -0500190 [Documentation] Check that BMC journald doesn't log any credential data.
George Keishingcc18f7c2018-09-03 09:40:11 -0500191 [Tags] Verify_BMC_Journald_Contains_No_Credential_Data
192
193 Open Connection And Log In
194 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
195 ... journalctl -o json-pretty | cat
196
197 Should Not Contain Any ${bmc_journald} ${OPENBMC_PASSWORD}
198 ... msg=Journald logs BMC credentials/password ${OPENBMC_PASSWORD}.
199
200
George Keishing9a0d4802018-08-31 13:29:40 -0500201Audit BMC SSH Login And Remote Logging
202 [Documentation] Check that the SSH login to BMC is logged and synced to
203 ... remote logging server.
204 [Tags] Audit_BMC_SSH_Login_And_Remote_Logging
205
206 ${test_host_name} ${test_host_ip}= Get Host Name IP
207
208 # Aug 31 17:22:55 wsbmc123 systemd[1]: Started SSH Per-Connection Server (xx.xx.xx.xx:51292)
209 Open Connection And Log In
George Keishing82ea1d42018-09-11 13:45:36 -0500210 Sleep 3s
George Keishing9a0d4802018-08-31 13:29:40 -0500211 ${login_footprint}= Catenate Started SSH Per-Connection Server.*${test_host_ip}
212
213 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
George Keishing13a64e62018-09-10 13:07:36 -0500214 ... journalctl --no-pager | grep '${login_footprint}' | tail -1
George Keishing9a0d4802018-08-31 13:29:40 -0500215
George Keishing13a64e62018-09-10 13:07:36 -0500216 ${cmd}= Catenate SEPARATOR= egrep '(${bmc_hostname}|${test_host_ip}).*${login_footprint}' /var/log/syslog
George Keishing9a0d4802018-08-31 13:29:40 -0500217
218 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
219
George Keishing82ea1d42018-09-11 13:45:36 -0500220 Should Contain ${remote_journald} ${bmc_journald.split('${bmc_hostname}')[1][0]}
George Keishing9a0d4802018-08-31 13:29:40 -0500221 ... msg=${remote_journald} don't contain ${bmc_journald} entry.
222
223
George Keishing76a5daf2018-09-14 06:00:01 -0500224Boot Host And Verify Data Is Synced To Remote Server
225 [Documentation] Boot host and verify the power on sequence logs are synced
226 ... to remote logging server.
227 [Tags] Boot_Host_And_Verify_Data_Is_Synced_To_Remote_Server
228
229 ${cmd}= Catenate SEPARATOR= --no-pager | egrep -Ev '${BMC_SYSLOG_REGEX}'
230 ... | awk -F': ' '{print $2}'
231
232 # Example: Just get the message part of the syslog
233 # Started OpenPOWER OCC Active Disable.
234 Start Journal Log filter=${cmd}
235
236 # Irrespective of the outcome, the journald should be synced.
237 Run Keyword And Ignore Error REST Power On
238 ${bmc_journald}= Stop Journal Log
239
240 ${cmd}= Catenate SEPARATOR= egrep '${bmc_hostname}' /var/log/syslog
241 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
242
243 @{lines}= Split To Lines ${bmc_journald}
244 :FOR ${line} IN @{lines}
245 \ Log To Console \n ${line}
246 \ Should Contain ${remote_journald} ${line}
247 ... mgs=${line} line doesn't contain in ${remote_journald}.
248
249
George Keishing6a514ef2018-08-27 05:19:19 -0500250*** Keywords ***
251
252Suite Setup Execution
253 [Documentation] Do the suite setup.
254
255 Should Not Be Empty ${REMOTE_LOG_SERVER_HOST}
256 Should Not Be Empty ${REMOTE_LOG_SERVER_PORT}
George Keishing67133672018-08-31 10:23:15 -0500257 Should Not Be Empty ${REMOTE_USERNAME}
258 Should Not Be Empty ${REMOTE_PASSWORD}
George Keishing6a514ef2018-08-27 05:19:19 -0500259 Ping Host ${REMOTE_LOG_SERVER_HOST}
George Keishing67133672018-08-31 10:23:15 -0500260 Remote Logging Server Execute Command true
George Keishing6a514ef2018-08-27 05:19:19 -0500261 Remote Logging Interface Should Exist
262
George Keishing216e5842018-08-31 14:58:15 -0500263 ${hostname} ${stderr} ${rc}= BMC Execute Command /bin/hostname
264 Set Suite Variable ${bmc_hostname} ${hostname}
George Keishing13a64e62018-09-10 13:07:36 -0500265 Configure Remote Logging Server
George Keishing216e5842018-08-31 14:58:15 -0500266
267
268Test Setup Execution
269 [Documentation] Do the test setup.
270
George Keishingb77a3572018-09-13 23:26:28 -0500271 # Retain only the past 1 second log:
272 BMC Execute Command journalctl --vacuum-time=1s
George Keishing13a64e62018-09-10 13:07:36 -0500273
274 ${config_status}= Run Keyword And Return Status
George Keishing216e5842018-08-31 14:58:15 -0500275 ... Get Remote Log Server Configured
276
277 Run Keyword If ${config_status}==${FALSE} Configure Remote Logging Server
278
279 ${ActiveState}= Get Service Attribute ActiveState rsyslog.service
280 Should Be Equal active ${ActiveState}
281 ... msg=rsyslog logging service not in active state.
282
George Keishing6a514ef2018-08-27 05:19:19 -0500283
284Remote Logging Interface Should Exist
285 [Documentation] Check that the remote logging URI exist.
286
287 ${resp}= OpenBMC Get Request ${REMOTE_LOGGING_URI}
288 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
289
290
291Configure Remote Logging Server
292 [Documentation] Configure the remote logging server on BMC.
293 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
294 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
295
296 # Description of argument(s):
297 # remote_host The host name or IP address of the remote logging server
298 # (e.g. "xx.xx.xx.xx").
299 # remote_port Remote ryslog server port number (e.g. "514").
300
301 # Example:
302 # https://xx.xx.xx.xx/xyz/openbmc_project/logging/config/remote
303 # Response code:200, Content:{
304 # "data": {
305 # "Address": "xx.xx.xx.xx",
306 # "Port": 514
307 # },
308 # "message": "200 OK",
309 # "status": "ok"
310 # }
311
312 ${host_dict}= Create Dictionary data=${remote_host}
313 Write Attribute ${REMOTE_LOGGING_URI} Address data=${host_dict}
314 ... verify=${TRUE} expected_value=${remote_host}
315
George Keishing216e5842018-08-31 14:58:15 -0500316 # TODO: From Dev to do bump up restart service time and bulk address and
317 # port update API.
318 # Reference: https://github.com/ibm-openbmc/dev/issues/59
319 Sleep 10s
320
George Keishing6a514ef2018-08-27 05:19:19 -0500321 ${remote_port}= Convert To Integer ${remote_port}
322 ${port_dict}= Create Dictionary data=${remote_port}
323 Write Attribute ${REMOTE_LOGGING_URI} Port data=${port_dict}
324 ... verify=${TRUE} expected_value=${remote_port}
325
George Keishing216e5842018-08-31 14:58:15 -0500326 # TODO: From Dev to do bump up restart service time and bulk address and
327 # port update API.
328 # Reference: https://github.com/ibm-openbmc/dev/issues/59
329 Sleep 10s
330
George Keishing6a514ef2018-08-27 05:19:19 -0500331
George Keishing518d1622018-09-17 12:54:53 -0500332Configure Group Remote Logging Server
333 [Documentation] Configure the remote logging server on BMC.
334 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
335 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
336
337 # Description of argument(s):
338 # remote_host The host name or IP address of the remote logging server
339 # (e.g. "xx.xx.xx.xx").
340 # remote_port Remote ryslog server port number (e.g. "514").
341
342 @{remote_parm_list}= Create List ${remote_host} ${remote_port}
343
344 ${data}= Create Dictionary data=@{snmp_parm_list}
345
346 ${resp}= OpenBMC Post Request
347 ... ${REMOTE_LOGGING_CONFIG_URI}/action/remote data=${data}
348
349 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
350
351
George Keishing6a514ef2018-08-27 05:19:19 -0500352Verify Rsyslog Config On BMC
353 [Documentation] Check if the rsyslog configuration on BMC is correct.
354 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
355 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
356
357 # Description of argument(s):
358 # remote_host The host name or IP address of the remote logging server
359 # (e.g. "xx.xx.xx.xx").
360 # remote_port Remote ryslog server port number (e.g. "514").
361
362 # Example:
363 # Configured:
364 # *.* @@xx.xx.xx.xx:514root@wsbmc123
365 # By default:
366 # #*.* @@remote-host:port
367
368 ${ryslog_conf} ${stderr} ${rc}= BMC Execute Command
369 ... cat /etc/rsyslog.d/server.conf
370
371 ${config}= Catenate @@${remote_host}:${remote_port}
372
373 Should Contain ${ryslog_conf} ${config}
374 ... msg=${remote_host} and ${remote_port} are not configured.
George Keishing67133672018-08-31 10:23:15 -0500375
376
377Remote Logging Server Execute Command
378 [Documentation] Login to remote logging server.
379 [Arguments] ${command}
380 ... ${remote_host}=${REMOTE_LOG_SERVER_HOST}
George Keishing216e5842018-08-31 14:58:15 -0500381 ... ${username}=${REMOTE_USERNAME}
382 ... ${password}=${REMOTE_PASSWORD}
383
384 # Description of argument(s):
385 # command Command line string.
386 # remote_host The host name or IP address of the remote logging server
387 # (e.g. "xx.xx.xx.xx").
388 # username Remote rsyslog server user name.
389 # password Remote rsyslog server password.
George Keishing67133672018-08-31 10:23:15 -0500390
391 ${remote_dict}= Create Dictionary host=${remote_host}
George Keishing216e5842018-08-31 14:58:15 -0500392 Open Connection And Log In ${username} ${password}
George Keishing67133672018-08-31 10:23:15 -0500393 ... &{remote_dict}
394 ${stdout} ${stderr}= Execute Command ${command} return_stderr=True
George Keishing13a64e62018-09-10 13:07:36 -0500395 Should Be Empty ${stderr}
George Keishing67133672018-08-31 10:23:15 -0500396 [Return] ${stdout}
397
George Keishing216e5842018-08-31 14:58:15 -0500398
399Get Remote Log Server Configured
400 [Documentation] Check that remote logging server is not configured.
401
402 ${address}= Read Attribute ${REMOTE_LOGGING_URI} Address
403 Should Not Be Equal ${address} ${REMOTE_LOG_SERVER_HOST}
404
405 ${port_number}= Convert To Integer ${REMOTE_LOG_SERVER_PORT}
406 ${port}= Read Attribute ${REMOTE_LOGGING_URI} Port
407 Should Not Be Equal ${port} ${port_number}