blob: b5d6ab092f2cef74feb7cf9923819bdd4d1306a3 [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 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 Keishing13451ed2018-09-06 12:46:16 -050080Test Remote Logging Invalid Port Config And Verify BMC Journald
81 [Documentation] Test remote logging interface and configuration.
82 [Tags] Test_Remote_Logging_Invalid_Port_Config_And_Verify_BMC_Journald
83
84 # Invalid port derived by (REMOTE_LOG_SERVER_PORT + 1) port config setting.
85 ${INVALID_PORT}= Evaluate ${REMOTE_LOG_SERVER_PORT} + ${1}
86 Configure Remote Logging Server
87 ... remote_host=${REMOTE_LOG_SERVER_HOST} remote_port=${INVALID_PORT}
88
89 Sleep 3s
90 # 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 ]
91 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
92 ... journalctl -b --no-pager | egrep 'rsyslog.*${RSYSLOG_RETRY_REGEX}'
93
94 Should Contain ${bmc_journald} ${RSYSLOG_RETRY_REGEX}
95 ... msg=${bmc_journald} doesn't contain rsyslog retry entries.
96
97
George Keishingc1ca5e92018-09-03 11:19:23 -050098Verify Rsyslog Does Not Log On BMC
99 [Documentation] Check that rsyslog journald doesn't log on BMC.
100 [Tags] Verify_Rsyslog_Does_Not_Log_On_BMC
101
102 # Expected filter rsyslog entries.
103 # Example:
104 # 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.
105 # 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
106 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
107 ... journalctl -b --no-pager | egrep 'rsyslog' | egrep -Ev '${RSYSLOG_REGEX}'
108 ... ignore_err=${1}
109
110 Should Be Empty ${bmc_journald}
111 ... msg=${bmc_journald} contains unexpected rsyslog entries.
112
113
George Keishing67133672018-08-31 10:23:15 -0500114Verfiy BMC Journald Synced To Remote Logging Server
115 [Documentation] Check that BMC journald is sync to remote rsyslog.
116 [Tags] Verfiy_BMC_Journald_Synced_To_Remote_Logging_Server
117
George Keishing67133672018-08-31 10:23:15 -0500118 # Restart BMC dump service and get the last entry of the journald.
119 # Example:
George Keishing216e5842018-08-31 14:58:15 -0500120 # Sep 03 10:09:28 wsbmc123 systemd[1]: Started Phosphor Dump Manager.
George Keishing67133672018-08-31 10:23:15 -0500121 BMC Execute Command
122 ... systemctl restart xyz.openbmc_project.Dump.Manager.service
123
124 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
George Keishing82ea1d42018-09-11 13:45:36 -0500125 ... journalctl --no-pager | grep 'Started Phosphor Dump Manager'
George Keishing67133672018-08-31 10:23:15 -0500126
George Keishing216e5842018-08-31 14:58:15 -0500127 # Sep 3 10:09:28 wsbmc123 systemd[1]: Started Phosphor Dump Manager.
George Keishing82ea1d42018-09-11 13:45:36 -0500128 ${cmd}= Catenate SEPARATOR= egrep '${bmc_hostname}.*Started Phosphor Dump Manager' /var/log/syslog
George Keishing67133672018-08-31 10:23:15 -0500129 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
130
George Keishing216e5842018-08-31 14:58:15 -0500131 # TODO: rsyslog configuration and time date template to match BMC journald.
132 # Compare the BMC journlad log. Example:
133 # systemd[1]: Started Phosphor Dump Manager.
George Keishing82ea1d42018-09-11 13:45:36 -0500134 Should Contain ${remote_journald} ${bmc_journald.split('${bmc_hostname}')[1][0]}
George Keishing216e5842018-08-31 14:58:15 -0500135 ... msg= ${bmc_journald} doesn't match remote rsyslog:${remote_journald}.
George Keishing67133672018-08-31 10:23:15 -0500136
137
George Keishing2cec1862018-09-03 12:59:25 -0500138Verify Journald Post BMC Reset
139 [Documentation] Check that BMC journald is sync'ed to remote rsyslog after
140 ... BMC reset.
141 [Tags] Verify_Journald_Post_BMC_Reset
142
143 ${hostname} ${stderr} ${rc}= BMC Execute Command hostname
144 OBMC Reboot (off)
145
146 ${cmd}= Catenate grep ${hostname} /var/log/syslog |
147 ... egrep '${BMC_STOP_MSG}|${BMC_START_MSG}|${BMC_BOOT_MSG}'
148 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
149
150 # 1. Last reboot message to verify.
151 Should Contain ${remote_journald} ${BMC_STOP_MSG}
152 ... msg=The remote journald doesn't contain the IPMI shutdown message: ${BMC_STOP_MSG}.
153
154 # 2. Earliest booting message on journald.
155 Should Contain ${remote_journald} ${BMC_START_MSG}
156 ... msg=The remote journald doesn't contain the start message: ${BMC_START_MSG}.
157
158 # 3. Unique boot to standby message.
159 # Startup finished in 9.961s (kernel) + 1min 59.039s (userspace) = 2min 9.000s
160 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
161 ... journalctl --no-pager | egrep '${BMC_BOOT_MSG}' | tail -1
162
163 Should Contain ${remote_journald}
164 ... ${bmc_journald.split('${hostname}')[1]}
165 ... msg=The remote journald doesn't contain the boot message: ${BMC_BOOT_MSG}.
166
167
George Keishingcc18f7c2018-09-03 09:40:11 -0500168Verify BMC Journald Contains No Credential Data
George Keishingcb3b9b62018-09-14 12:11:19 -0500169 [Documentation] Check that BMC journald doesn't log any credential data.
George Keishingcc18f7c2018-09-03 09:40:11 -0500170 [Tags] Verify_BMC_Journald_Contains_No_Credential_Data
171
172 Open Connection And Log In
173 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
174 ... journalctl -o json-pretty | cat
175
176 Should Not Contain Any ${bmc_journald} ${OPENBMC_PASSWORD}
177 ... msg=Journald logs BMC credentials/password ${OPENBMC_PASSWORD}.
178
179
George Keishing9a0d4802018-08-31 13:29:40 -0500180Audit BMC SSH Login And Remote Logging
181 [Documentation] Check that the SSH login to BMC is logged and synced to
182 ... remote logging server.
183 [Tags] Audit_BMC_SSH_Login_And_Remote_Logging
184
185 ${test_host_name} ${test_host_ip}= Get Host Name IP
186
187 # Aug 31 17:22:55 wsbmc123 systemd[1]: Started SSH Per-Connection Server (xx.xx.xx.xx:51292)
188 Open Connection And Log In
George Keishing82ea1d42018-09-11 13:45:36 -0500189 Sleep 3s
George Keishing9a0d4802018-08-31 13:29:40 -0500190 ${login_footprint}= Catenate Started SSH Per-Connection Server.*${test_host_ip}
191
192 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
George Keishing13a64e62018-09-10 13:07:36 -0500193 ... journalctl --no-pager | grep '${login_footprint}' | tail -1
George Keishing9a0d4802018-08-31 13:29:40 -0500194
George Keishing13a64e62018-09-10 13:07:36 -0500195 ${cmd}= Catenate SEPARATOR= egrep '(${bmc_hostname}|${test_host_ip}).*${login_footprint}' /var/log/syslog
George Keishing9a0d4802018-08-31 13:29:40 -0500196
197 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
198
George Keishing82ea1d42018-09-11 13:45:36 -0500199 Should Contain ${remote_journald} ${bmc_journald.split('${bmc_hostname}')[1][0]}
George Keishing9a0d4802018-08-31 13:29:40 -0500200 ... msg=${remote_journald} don't contain ${bmc_journald} entry.
201
202
George Keishing76a5daf2018-09-14 06:00:01 -0500203Boot Host And Verify Data Is Synced To Remote Server
204 [Documentation] Boot host and verify the power on sequence logs are synced
205 ... to remote logging server.
206 [Tags] Boot_Host_And_Verify_Data_Is_Synced_To_Remote_Server
207
208 ${cmd}= Catenate SEPARATOR= --no-pager | egrep -Ev '${BMC_SYSLOG_REGEX}'
209 ... | awk -F': ' '{print $2}'
210
211 # Example: Just get the message part of the syslog
212 # Started OpenPOWER OCC Active Disable.
213 Start Journal Log filter=${cmd}
214
215 # Irrespective of the outcome, the journald should be synced.
216 Run Keyword And Ignore Error REST Power On
217 ${bmc_journald}= Stop Journal Log
218
219 ${cmd}= Catenate SEPARATOR= egrep '${bmc_hostname}' /var/log/syslog
220 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
221
222 @{lines}= Split To Lines ${bmc_journald}
223 :FOR ${line} IN @{lines}
224 \ Log To Console \n ${line}
225 \ Should Contain ${remote_journald} ${line}
226 ... mgs=${line} line doesn't contain in ${remote_journald}.
227
228
George Keishing6a514ef2018-08-27 05:19:19 -0500229*** Keywords ***
230
231Suite Setup Execution
232 [Documentation] Do the suite setup.
233
234 Should Not Be Empty ${REMOTE_LOG_SERVER_HOST}
235 Should Not Be Empty ${REMOTE_LOG_SERVER_PORT}
George Keishing67133672018-08-31 10:23:15 -0500236 Should Not Be Empty ${REMOTE_USERNAME}
237 Should Not Be Empty ${REMOTE_PASSWORD}
George Keishing6a514ef2018-08-27 05:19:19 -0500238 Ping Host ${REMOTE_LOG_SERVER_HOST}
George Keishing67133672018-08-31 10:23:15 -0500239 Remote Logging Server Execute Command true
George Keishing6a514ef2018-08-27 05:19:19 -0500240 Remote Logging Interface Should Exist
241
George Keishing216e5842018-08-31 14:58:15 -0500242 ${hostname} ${stderr} ${rc}= BMC Execute Command /bin/hostname
243 Set Suite Variable ${bmc_hostname} ${hostname}
George Keishing13a64e62018-09-10 13:07:36 -0500244 Configure Remote Logging Server
George Keishing216e5842018-08-31 14:58:15 -0500245
246
247Test Setup Execution
248 [Documentation] Do the test setup.
249
George Keishingb77a3572018-09-13 23:26:28 -0500250 # Retain only the past 1 second log:
251 BMC Execute Command journalctl --vacuum-time=1s
George Keishing13a64e62018-09-10 13:07:36 -0500252
253 ${config_status}= Run Keyword And Return Status
George Keishing216e5842018-08-31 14:58:15 -0500254 ... Get Remote Log Server Configured
255
256 Run Keyword If ${config_status}==${FALSE} Configure Remote Logging Server
257
258 ${ActiveState}= Get Service Attribute ActiveState rsyslog.service
259 Should Be Equal active ${ActiveState}
260 ... msg=rsyslog logging service not in active state.
261
George Keishing6a514ef2018-08-27 05:19:19 -0500262
263Remote Logging Interface Should Exist
264 [Documentation] Check that the remote logging URI exist.
265
266 ${resp}= OpenBMC Get Request ${REMOTE_LOGGING_URI}
267 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
268
269
270Configure Remote Logging Server
271 [Documentation] Configure the remote logging server on BMC.
272 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
273 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
274
275 # Description of argument(s):
276 # remote_host The host name or IP address of the remote logging server
277 # (e.g. "xx.xx.xx.xx").
278 # remote_port Remote ryslog server port number (e.g. "514").
279
280 # Example:
281 # https://xx.xx.xx.xx/xyz/openbmc_project/logging/config/remote
282 # Response code:200, Content:{
283 # "data": {
284 # "Address": "xx.xx.xx.xx",
285 # "Port": 514
286 # },
287 # "message": "200 OK",
288 # "status": "ok"
289 # }
290
291 ${host_dict}= Create Dictionary data=${remote_host}
292 Write Attribute ${REMOTE_LOGGING_URI} Address data=${host_dict}
293 ... verify=${TRUE} expected_value=${remote_host}
294
George Keishing216e5842018-08-31 14:58:15 -0500295 # TODO: From Dev to do bump up restart service time and bulk address and
296 # port update API.
297 # Reference: https://github.com/ibm-openbmc/dev/issues/59
298 Sleep 10s
299
George Keishing6a514ef2018-08-27 05:19:19 -0500300 ${remote_port}= Convert To Integer ${remote_port}
301 ${port_dict}= Create Dictionary data=${remote_port}
302 Write Attribute ${REMOTE_LOGGING_URI} Port data=${port_dict}
303 ... verify=${TRUE} expected_value=${remote_port}
304
George Keishing216e5842018-08-31 14:58:15 -0500305 # TODO: From Dev to do bump up restart service time and bulk address and
306 # port update API.
307 # Reference: https://github.com/ibm-openbmc/dev/issues/59
308 Sleep 10s
309
George Keishing6a514ef2018-08-27 05:19:19 -0500310
311Verify Rsyslog Config On BMC
312 [Documentation] Check if the rsyslog configuration on BMC is correct.
313 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
314 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
315
316 # Description of argument(s):
317 # remote_host The host name or IP address of the remote logging server
318 # (e.g. "xx.xx.xx.xx").
319 # remote_port Remote ryslog server port number (e.g. "514").
320
321 # Example:
322 # Configured:
323 # *.* @@xx.xx.xx.xx:514root@wsbmc123
324 # By default:
325 # #*.* @@remote-host:port
326
327 ${ryslog_conf} ${stderr} ${rc}= BMC Execute Command
328 ... cat /etc/rsyslog.d/server.conf
329
330 ${config}= Catenate @@${remote_host}:${remote_port}
331
332 Should Contain ${ryslog_conf} ${config}
333 ... msg=${remote_host} and ${remote_port} are not configured.
George Keishing67133672018-08-31 10:23:15 -0500334
335
336Remote Logging Server Execute Command
337 [Documentation] Login to remote logging server.
338 [Arguments] ${command}
339 ... ${remote_host}=${REMOTE_LOG_SERVER_HOST}
George Keishing216e5842018-08-31 14:58:15 -0500340 ... ${username}=${REMOTE_USERNAME}
341 ... ${password}=${REMOTE_PASSWORD}
342
343 # Description of argument(s):
344 # command Command line string.
345 # remote_host The host name or IP address of the remote logging server
346 # (e.g. "xx.xx.xx.xx").
347 # username Remote rsyslog server user name.
348 # password Remote rsyslog server password.
George Keishing67133672018-08-31 10:23:15 -0500349
350 ${remote_dict}= Create Dictionary host=${remote_host}
George Keishing216e5842018-08-31 14:58:15 -0500351 Open Connection And Log In ${username} ${password}
George Keishing67133672018-08-31 10:23:15 -0500352 ... &{remote_dict}
353 ${stdout} ${stderr}= Execute Command ${command} return_stderr=True
George Keishing13a64e62018-09-10 13:07:36 -0500354 Should Be Empty ${stderr}
George Keishing67133672018-08-31 10:23:15 -0500355 [Return] ${stdout}
356
George Keishing216e5842018-08-31 14:58:15 -0500357
358Get Remote Log Server Configured
359 [Documentation] Check that remote logging server is not configured.
360
361 ${address}= Read Attribute ${REMOTE_LOGGING_URI} Address
362 Should Not Be Equal ${address} ${REMOTE_LOG_SERVER_HOST}
363
364 ${port_number}= Convert To Integer ${REMOTE_LOG_SERVER_PORT}
365 ${port}= Read Attribute ${REMOTE_LOGGING_URI} Port
366 Should Not Be Equal ${port} ${port_number}