blob: 5ce3eae0d6d7c354672e837032f4dbd60cf13d1e [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
George Keishingaef483e2018-09-19 07:57:22 -0500206 ${login_footprint}= Catenate Started SSH Per-Connection Server
207 # Example: Just get the message part of the syslog
208 # Started SSH Per-Connection Server (xx.xx.xx.xx:51292)
209 ${cmd}= Catenate SEPARATOR= --no-pager | egrep '${login_footprint}'
210 ... | awk -F': ' '{print $2}'
George Keishing9a0d4802018-08-31 13:29:40 -0500211
George Keishingaef483e2018-09-19 07:57:22 -0500212 Start Journal Log filter=${cmd}
George Keishing9a0d4802018-08-31 13:29:40 -0500213 Open Connection And Log In
George Keishingaef483e2018-09-19 07:57:22 -0500214 Sleep 5s
215 ${bmc_journald}= Stop Journal Log
216 @{ssh_entry}= Split To Lines ${bmc_journald}
George Keishing9a0d4802018-08-31 13:29:40 -0500217
George Keishingaef483e2018-09-19 07:57:22 -0500218 ${cmd}= Catenate SEPARATOR= egrep -E '*${bmc_hostname}.*${login_footprint}' /var/log/syslog
George Keishing9a0d4802018-08-31 13:29:40 -0500219
220 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
221
George Keishingaef483e2018-09-19 07:57:22 -0500222 Should Contain ${remote_journald} ${ssh_entry[0]}
George Keishing9a0d4802018-08-31 13:29:40 -0500223 ... msg=${remote_journald} don't contain ${bmc_journald} entry.
224
225
George Keishing76a5daf2018-09-14 06:00:01 -0500226Boot Host And Verify Data Is Synced To Remote Server
227 [Documentation] Boot host and verify the power on sequence logs are synced
228 ... to remote logging server.
229 [Tags] Boot_Host_And_Verify_Data_Is_Synced_To_Remote_Server
230
231 ${cmd}= Catenate SEPARATOR= --no-pager | egrep -Ev '${BMC_SYSLOG_REGEX}'
232 ... | awk -F': ' '{print $2}'
233
234 # Example: Just get the message part of the syslog
235 # Started OpenPOWER OCC Active Disable.
236 Start Journal Log filter=${cmd}
237
238 # Irrespective of the outcome, the journald should be synced.
239 Run Keyword And Ignore Error REST Power On
240 ${bmc_journald}= Stop Journal Log
241
242 ${cmd}= Catenate SEPARATOR= egrep '${bmc_hostname}' /var/log/syslog
243 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
244
245 @{lines}= Split To Lines ${bmc_journald}
246 :FOR ${line} IN @{lines}
247 \ Log To Console \n ${line}
248 \ Should Contain ${remote_journald} ${line}
249 ... mgs=${line} line doesn't contain in ${remote_journald}.
250
251
George Keishing6a514ef2018-08-27 05:19:19 -0500252*** Keywords ***
253
254Suite Setup Execution
255 [Documentation] Do the suite setup.
256
257 Should Not Be Empty ${REMOTE_LOG_SERVER_HOST}
258 Should Not Be Empty ${REMOTE_LOG_SERVER_PORT}
George Keishing67133672018-08-31 10:23:15 -0500259 Should Not Be Empty ${REMOTE_USERNAME}
260 Should Not Be Empty ${REMOTE_PASSWORD}
George Keishing6a514ef2018-08-27 05:19:19 -0500261 Ping Host ${REMOTE_LOG_SERVER_HOST}
George Keishing67133672018-08-31 10:23:15 -0500262 Remote Logging Server Execute Command true
George Keishing6a514ef2018-08-27 05:19:19 -0500263 Remote Logging Interface Should Exist
264
George Keishing216e5842018-08-31 14:58:15 -0500265 ${hostname} ${stderr} ${rc}= BMC Execute Command /bin/hostname
266 Set Suite Variable ${bmc_hostname} ${hostname}
George Keishing13a64e62018-09-10 13:07:36 -0500267 Configure Remote Logging Server
George Keishing216e5842018-08-31 14:58:15 -0500268
269
270Test Setup Execution
271 [Documentation] Do the test setup.
272
George Keishingb77a3572018-09-13 23:26:28 -0500273 # Retain only the past 1 second log:
274 BMC Execute Command journalctl --vacuum-time=1s
George Keishing13a64e62018-09-10 13:07:36 -0500275
276 ${config_status}= Run Keyword And Return Status
George Keishing216e5842018-08-31 14:58:15 -0500277 ... Get Remote Log Server Configured
278
279 Run Keyword If ${config_status}==${FALSE} Configure Remote Logging Server
280
281 ${ActiveState}= Get Service Attribute ActiveState rsyslog.service
282 Should Be Equal active ${ActiveState}
283 ... msg=rsyslog logging service not in active state.
284
George Keishing6a514ef2018-08-27 05:19:19 -0500285
286Remote Logging Interface Should Exist
287 [Documentation] Check that the remote logging URI exist.
288
289 ${resp}= OpenBMC Get Request ${REMOTE_LOGGING_URI}
290 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
291
292
293Configure Remote Logging Server
294 [Documentation] Configure the remote logging server on BMC.
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 # https://xx.xx.xx.xx/xyz/openbmc_project/logging/config/remote
305 # Response code:200, Content:{
306 # "data": {
307 # "Address": "xx.xx.xx.xx",
308 # "Port": 514
309 # },
310 # "message": "200 OK",
311 # "status": "ok"
312 # }
313
314 ${host_dict}= Create Dictionary data=${remote_host}
315 Write Attribute ${REMOTE_LOGGING_URI} Address data=${host_dict}
316 ... verify=${TRUE} expected_value=${remote_host}
317
George Keishing216e5842018-08-31 14:58:15 -0500318 # TODO: From Dev to do bump up restart service time and bulk address and
319 # port update API.
320 # Reference: https://github.com/ibm-openbmc/dev/issues/59
321 Sleep 10s
322
George Keishing6a514ef2018-08-27 05:19:19 -0500323 ${remote_port}= Convert To Integer ${remote_port}
324 ${port_dict}= Create Dictionary data=${remote_port}
325 Write Attribute ${REMOTE_LOGGING_URI} Port data=${port_dict}
326 ... verify=${TRUE} expected_value=${remote_port}
327
George Keishing216e5842018-08-31 14:58:15 -0500328 # TODO: From Dev to do bump up restart service time and bulk address and
329 # port update API.
330 # Reference: https://github.com/ibm-openbmc/dev/issues/59
331 Sleep 10s
332
George Keishing6a514ef2018-08-27 05:19:19 -0500333
George Keishing518d1622018-09-17 12:54:53 -0500334Configure Group Remote Logging Server
335 [Documentation] Configure the remote logging server on BMC.
336 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
337 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
338
339 # Description of argument(s):
340 # remote_host The host name or IP address of the remote logging server
341 # (e.g. "xx.xx.xx.xx").
342 # remote_port Remote ryslog server port number (e.g. "514").
343
344 @{remote_parm_list}= Create List ${remote_host} ${remote_port}
345
346 ${data}= Create Dictionary data=@{snmp_parm_list}
347
348 ${resp}= OpenBMC Post Request
349 ... ${REMOTE_LOGGING_CONFIG_URI}/action/remote data=${data}
350
351 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
352
353
George Keishing6a514ef2018-08-27 05:19:19 -0500354Verify Rsyslog Config On BMC
355 [Documentation] Check if the rsyslog configuration on BMC is correct.
356 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
357 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
358
359 # Description of argument(s):
360 # remote_host The host name or IP address of the remote logging server
361 # (e.g. "xx.xx.xx.xx").
362 # remote_port Remote ryslog server port number (e.g. "514").
363
364 # Example:
365 # Configured:
366 # *.* @@xx.xx.xx.xx:514root@wsbmc123
367 # By default:
368 # #*.* @@remote-host:port
369
370 ${ryslog_conf} ${stderr} ${rc}= BMC Execute Command
371 ... cat /etc/rsyslog.d/server.conf
372
373 ${config}= Catenate @@${remote_host}:${remote_port}
374
375 Should Contain ${ryslog_conf} ${config}
376 ... msg=${remote_host} and ${remote_port} are not configured.
George Keishing67133672018-08-31 10:23:15 -0500377
378
379Remote Logging Server Execute Command
380 [Documentation] Login to remote logging server.
381 [Arguments] ${command}
382 ... ${remote_host}=${REMOTE_LOG_SERVER_HOST}
George Keishing216e5842018-08-31 14:58:15 -0500383 ... ${username}=${REMOTE_USERNAME}
384 ... ${password}=${REMOTE_PASSWORD}
385
386 # Description of argument(s):
387 # command Command line string.
388 # remote_host The host name or IP address of the remote logging server
389 # (e.g. "xx.xx.xx.xx").
390 # username Remote rsyslog server user name.
391 # password Remote rsyslog server password.
George Keishing67133672018-08-31 10:23:15 -0500392
393 ${remote_dict}= Create Dictionary host=${remote_host}
George Keishing216e5842018-08-31 14:58:15 -0500394 Open Connection And Log In ${username} ${password}
George Keishing67133672018-08-31 10:23:15 -0500395 ... &{remote_dict}
396 ${stdout} ${stderr}= Execute Command ${command} return_stderr=True
George Keishing13a64e62018-09-10 13:07:36 -0500397 Should Be Empty ${stderr}
George Keishing67133672018-08-31 10:23:15 -0500398 [Return] ${stdout}
399
George Keishing216e5842018-08-31 14:58:15 -0500400
401Get Remote Log Server Configured
402 [Documentation] Check that remote logging server is not configured.
403
404 ${address}= Read Attribute ${REMOTE_LOGGING_URI} Address
405 Should Not Be Equal ${address} ${REMOTE_LOG_SERVER_HOST}
406
407 ${port_number}= Convert To Integer ${REMOTE_LOG_SERVER_PORT}
408 ${port}= Read Attribute ${REMOTE_LOGGING_URI} Port
409 Should Not Be Equal ${port} ${port_number}