blob: ed82ccb95885541c089c4c1325a3a6f964093205 [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/openbmc_ffdc.robot
George Keishing76a5daf2018-09-14 06:00:01 -050013Resource ../lib/boot_utils.robot
George Keishingbbfc3942018-09-19 10:15:48 -050014Resource ../lib/remote_logging_utils.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
George Keishingc1ca5e92018-09-03 11:19:23 -050023# Strings to check from journald.
George Keishing13451ed2018-09-06 12:46:16 -050024${BMC_STOP_MSG} Stopping Phosphor IPMI BT DBus Bridge
25${BMC_START_MSG} Starting Flush Journal to Persistent Storage
26${BMC_BOOT_MSG} Startup finished in
27${BMC_SYSLOG_REGEX} dropbear|vrm-control.sh
George Keishingeacb1882018-09-20 00:11:00 -050028${RSYSLOG_REGEX} start|exiting on signal 15|there are no active actions configured
George Keishing686cacb2019-01-16 01:05:20 -060029${RSYSLOG_RETRY_REGEX} suspended
George Keishingc1ca5e92018-09-03 11:19:23 -050030
George Keishing6a514ef2018-08-27 05:19:19 -050031*** Test Cases ***
32
George Keishingeb9fc592018-09-18 07:58:17 -050033Test BMC Hostname Service And Verify
34 [Documentation] Write to hostname interface and verify via REST and
35 ... 'hostname' command.
36 [Tags] Test_BMC_Hostname_Service_And_Verify
37
38 ${openbmc_host_name} ${openbmc_ip} ${openbmc_short_name}=
39 ... Get Host Name IP host=${OPENBMC_HOST} short_name=1
40
41 ${host_name_dict}= Create Dictionary data=${openbmc_short_name}
42 Write Attribute ${NETWORK_MANAGER}config HostName data=${host_name_dict}
43 ... verify=${TRUE} expected_value=${openbmc_short_name}
44
45 ${hostname} ${stderr} ${rc}= BMC Execute Command hostname
46
47 Should Be Equal As Strings ${hostname} ${openbmc_short_name}
48 ... msg=The hostname interface ${openbmc_short_name} and command value ${hostname} do not match.
49
50 # Override the suite hostname variable if this test is executed.
51 Set Suite Variable ${bmc_hostname} ${openbmc_short_name}
52
53
George Keishing13a64e62018-09-10 13:07:36 -050054Verify REST Logging On BMC Journal When Disabled
55 [Documentation] Enable REST logging and verify from journald.
George Keishingb77a3572018-09-13 23:26:28 -050056 [Tags] Verify_REST_Logging_On_BMC_Journal_When_Disabled
George Keishing13a64e62018-09-10 13:07:36 -050057
58 ${log_dict}= Create Dictionary data=${False}
59 Write Attribute ${BMC_LOGGING_URI}${/}rest_api_logs Enabled data=${log_dict}
60 ... verify=${True} expected_value=${False}
61
George Keishingeacb1882018-09-20 00:11:00 -050062 # If it was enabled prior, this REST footprint will show up.
63 # Takes around 5 seconds for the REST to restart service when policy is changed.
64 Sleep 10s
65
George Keishing6218e762018-10-06 13:14:36 -050066 ${login_footprint}= Catenate login json:None 200 OK
George Keishing4df837f2018-09-19 14:06:01 -050067 # Example: Just get the message part of the syslog
George Keishing6218e762018-10-06 13:14:36 -050068 # user:root POST http://xx.xx.xx.xx/login json:None 200 OK
George Keishing4df837f2018-09-19 14:06:01 -050069 ${cmd}= Catenate SEPARATOR= --no-pager | egrep '${login_footprint}'
70 ... | awk -F': ' '{print $2}'
71
72 Start Journal Log filter=${cmd}
George Keishing13a64e62018-09-10 13:07:36 -050073 Initialize OpenBMC
George Keishing4df837f2018-09-19 14:06:01 -050074 Sleep 5s
75 ${bmc_journald}= Stop Journal Log
George Keishing13a64e62018-09-10 13:07:36 -050076
George Keishing4df837f2018-09-19 14:06:01 -050077 Should Be Empty ${bmc_journald}
George Keishing13a64e62018-09-10 13:07:36 -050078 ... msg=${bmc_journald} contains unexpected REST entries.
79
80
George Keishingb77a3572018-09-13 23:26:28 -050081Verify REST Logging On BMC Journal When Enabled
George Keishing13a64e62018-09-10 13:07:36 -050082 [Documentation] Enable REST logging and verify from journald.
George Keishingb77a3572018-09-13 23:26:28 -050083 [Tags] Verify_REST_Logging_On_BMC_Journal_When_Enabled
George Keishing13a64e62018-09-10 13:07:36 -050084
85 ${log_dict}= Create Dictionary data=${True}
86 Write Attribute ${BMC_LOGGING_URI}${/}rest_api_logs Enabled data=${log_dict}
87 ... verify=${True} expected_value=${True}
88
George Keishing686cacb2019-01-16 01:05:20 -060089 Sleep 5s
90
91 Start Journal Log
George Keishing13a64e62018-09-10 13:07:36 -050092 Initialize OpenBMC
George Keishing6218e762018-10-06 13:14:36 -050093 Log Out OpenBMC
George Keishing686cacb2019-01-16 01:05:20 -060094 ${bmc_journald}= Stop Journal Log
George Keishing13a64e62018-09-10 13:07:36 -050095
George Keishing6218e762018-10-06 13:14:36 -050096 Should Contain ${bmc_journald} login json:None 200 OK
George Keishing13a64e62018-09-10 13:07:36 -050097 ... msg=${bmc_journald} doesn't contains REST entries.
98
99
George Keishing38733f32018-09-20 05:56:50 -0500100Test Remote API Valid Config Combination
101 [Documentation] Verify valid combination of address and port.
102 [Tags] Test_Remote_API_Valid_Config_Combination
103 [Template] Verify Configure Remote Logging Server
104 # Forego normal test setup:
105 [Setup] No Operation
106
107 # Address Port Expected result
108 ${EMPTY} ${REMOTE_LOG_SERVER_PORT} ${True}
109 ${REMOTE_LOG_SERVER_HOST} ${REMOTE_LOG_SERVER_PORT} ${True}
George Keishing38733f32018-09-20 05:56:50 -0500110 ${REMOTE_LOG_SERVER_HOST} ${0} ${True}
111
112
113Test Remote API Invalid Config Combination
114 [Documentation] Verify invalid combination of address and port.
115 [Tags] Test_Remote_API_Invalid_Config_Combination
116 [Template] Verify Configure Remote Logging Server
117 # Forego normal test setup:
118 [Setup] No Operation
119
120 # Address Port Expected result
121 ${0} ${REMOTE_LOG_SERVER_PORT} ${False}
122 "0" ${REMOTE_LOG_SERVER_PORT} ${False}
123 ${REMOTE_LOG_SERVER_HOST} ${EMPTY} ${False}
124 ${REMOTE_LOG_SERVER_HOST} "0" ${False}
125
126
George Keishing6a514ef2018-08-27 05:19:19 -0500127Test Remote Logging REST Interface And Verify Config
128 [Documentation] Test remote logging interface and configuration.
129 [Tags] Test_Remote_Logging_REST_Interface_And_Verify_Config
130
George Keishing6a514ef2018-08-27 05:19:19 -0500131 Verify Rsyslog Config On BMC
132
George Keishing6a514ef2018-08-27 05:19:19 -0500133
George Keishing13451ed2018-09-06 12:46:16 -0500134Test Remote Logging Invalid Port Config And Verify BMC Journald
135 [Documentation] Test remote logging interface and configuration.
136 [Tags] Test_Remote_Logging_Invalid_Port_Config_And_Verify_BMC_Journald
137
138 # Invalid port derived by (REMOTE_LOG_SERVER_PORT + 1) port config setting.
139 ${INVALID_PORT}= Evaluate ${REMOTE_LOG_SERVER_PORT} + ${1}
George Keishingbbfc3942018-09-19 10:15:48 -0500140 Configure Remote Log Server With Parameters
George Keishing13451ed2018-09-06 12:46:16 -0500141 ... remote_host=${REMOTE_LOG_SERVER_HOST} remote_port=${INVALID_PORT}
142
143 Sleep 3s
Joy Onyerikwudbfe97d2019-03-11 19:44:56 -0500144 # rsyslogd[1870]: action 'action 0' suspended,
145 # next retry is Fri Sep 14 05:47:39 2018 [v8.29.0 try http://www.rsyslog.com/e/2007 ]
George Keishing13451ed2018-09-06 12:46:16 -0500146 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
147 ... journalctl -b --no-pager | egrep 'rsyslog.*${RSYSLOG_RETRY_REGEX}'
148
149 Should Contain ${bmc_journald} ${RSYSLOG_RETRY_REGEX}
150 ... msg=${bmc_journald} doesn't contain rsyslog retry entries.
151
152
George Keishing67133672018-08-31 10:23:15 -0500153Verfiy BMC Journald Synced To Remote Logging Server
154 [Documentation] Check that BMC journald is sync to remote rsyslog.
155 [Tags] Verfiy_BMC_Journald_Synced_To_Remote_Logging_Server
156
George Keishing67133672018-08-31 10:23:15 -0500157 # Restart BMC dump service and get the last entry of the journald.
158 # Example:
George Keishing96904c42018-09-20 09:25:30 -0500159 # systemd[1]: Started Phosphor Dump Manager.
George Keishing67133672018-08-31 10:23:15 -0500160 BMC Execute Command
161 ... systemctl restart xyz.openbmc_project.Dump.Manager.service
162
163 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
George Keishing82ea1d42018-09-11 13:45:36 -0500164 ... journalctl --no-pager | grep 'Started Phosphor Dump Manager'
George Keishing67133672018-08-31 10:23:15 -0500165
George Keishing96904c42018-09-20 09:25:30 -0500166 # systemd[1]: Started Phosphor Dump Manager.
George Keishing82ea1d42018-09-11 13:45:36 -0500167 ${cmd}= Catenate SEPARATOR= egrep '${bmc_hostname}.*Started Phosphor Dump Manager' /var/log/syslog
George Keishing67133672018-08-31 10:23:15 -0500168 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
169
George Keishing216e5842018-08-31 14:58:15 -0500170 # TODO: rsyslog configuration and time date template to match BMC journald.
171 # Compare the BMC journlad log. Example:
172 # systemd[1]: Started Phosphor Dump Manager.
George Keishing82ea1d42018-09-11 13:45:36 -0500173 Should Contain ${remote_journald} ${bmc_journald.split('${bmc_hostname}')[1][0]}
George Keishing216e5842018-08-31 14:58:15 -0500174 ... msg= ${bmc_journald} doesn't match remote rsyslog:${remote_journald}.
George Keishing67133672018-08-31 10:23:15 -0500175
176
George Keishing2cec1862018-09-03 12:59:25 -0500177Verify Journald Post BMC Reset
178 [Documentation] Check that BMC journald is sync'ed to remote rsyslog after
179 ... BMC reset.
180 [Tags] Verify_Journald_Post_BMC_Reset
181
182 ${hostname} ${stderr} ${rc}= BMC Execute Command hostname
183 OBMC Reboot (off)
184
185 ${cmd}= Catenate grep ${hostname} /var/log/syslog |
186 ... egrep '${BMC_STOP_MSG}|${BMC_START_MSG}|${BMC_BOOT_MSG}'
187 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
188
189 # 1. Last reboot message to verify.
190 Should Contain ${remote_journald} ${BMC_STOP_MSG}
191 ... msg=The remote journald doesn't contain the IPMI shutdown message: ${BMC_STOP_MSG}.
192
193 # 2. Earliest booting message on journald.
194 Should Contain ${remote_journald} ${BMC_START_MSG}
195 ... msg=The remote journald doesn't contain the start message: ${BMC_START_MSG}.
196
197 # 3. Unique boot to standby message.
198 # Startup finished in 9.961s (kernel) + 1min 59.039s (userspace) = 2min 9.000s
199 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
George Keishing6218e762018-10-06 13:14:36 -0500200 ... journalctl -b --no-pager | egrep '${BMC_BOOT_MSG}'
George Keishing2cec1862018-09-03 12:59:25 -0500201
202 Should Contain ${remote_journald}
203 ... ${bmc_journald.split('${hostname}')[1]}
204 ... msg=The remote journald doesn't contain the boot message: ${BMC_BOOT_MSG}.
205
206
George Keishingcc18f7c2018-09-03 09:40:11 -0500207Verify BMC Journald Contains No Credential Data
George Keishingcb3b9b62018-09-14 12:11:19 -0500208 [Documentation] Check that BMC journald doesn't log any credential data.
George Keishingcc18f7c2018-09-03 09:40:11 -0500209 [Tags] Verify_BMC_Journald_Contains_No_Credential_Data
210
George Keishingc25c55d2018-10-30 02:23:44 -0500211 Initialize OpenBMC
212 Update Root Password ${REST_PASSWORD}
213
214 # Time for user manager to sync.
215 Sleep 5 s
216
George Keishingcc18f7c2018-09-03 09:40:11 -0500217 Open Connection And Log In
218 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
219 ... journalctl -o json-pretty | cat
220
George Keishingc25c55d2018-10-30 02:23:44 -0500221 Should Not Contain Any ${bmc_journald} ${OPENBMC_PASSWORD} ${REST_PASSWORD}
George Keishingcc18f7c2018-09-03 09:40:11 -0500222 ... msg=Journald logs BMC credentials/password ${OPENBMC_PASSWORD}.
223
224
George Keishing9a0d4802018-08-31 13:29:40 -0500225Audit BMC SSH Login And Remote Logging
226 [Documentation] Check that the SSH login to BMC is logged and synced to
227 ... remote logging server.
228 [Tags] Audit_BMC_SSH_Login_And_Remote_Logging
229
George Keishingaef483e2018-09-19 07:57:22 -0500230 ${login_footprint}= Catenate Started SSH Per-Connection Server
231 # Example: Just get the message part of the syslog
232 # Started SSH Per-Connection Server (xx.xx.xx.xx:51292)
233 ${cmd}= Catenate SEPARATOR= --no-pager | egrep '${login_footprint}'
234 ... | awk -F': ' '{print $2}'
George Keishing9a0d4802018-08-31 13:29:40 -0500235
George Keishingaef483e2018-09-19 07:57:22 -0500236 Start Journal Log filter=${cmd}
George Keishing9a0d4802018-08-31 13:29:40 -0500237 Open Connection And Log In
George Keishingaef483e2018-09-19 07:57:22 -0500238 Sleep 5s
239 ${bmc_journald}= Stop Journal Log
240 @{ssh_entry}= Split To Lines ${bmc_journald}
George Keishing9a0d4802018-08-31 13:29:40 -0500241
George Keishingaef483e2018-09-19 07:57:22 -0500242 ${cmd}= Catenate SEPARATOR= egrep -E '*${bmc_hostname}.*${login_footprint}' /var/log/syslog
George Keishing9a0d4802018-08-31 13:29:40 -0500243
244 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
245
George Keishingaef483e2018-09-19 07:57:22 -0500246 Should Contain ${remote_journald} ${ssh_entry[0]}
George Keishing9a0d4802018-08-31 13:29:40 -0500247 ... msg=${remote_journald} don't contain ${bmc_journald} entry.
248
249
George Keishing6218e762018-10-06 13:14:36 -0500250Verify Rsyslog Does Not Log On BMC
251 [Documentation] Check that rsyslog journald doesn't log on BMC.
252 [Tags] Verify_Rsyslog_Does_Not_Log_On_BMC
253
254 # Expected filter rsyslog entries.
255 # Example:
Joy Onyerikwudbfe97d2019-03-11 19:44:56 -0500256 # syslogd[3356]:
257 # [origin software="rsyslogd" swVersion="8.29.0" x-pid="3356" x-info="http://www.rsyslog.com"]
258 # exiting on signal 15.
259 # rsyslogd[3364]:
260 # [origin software="rsyslogd" swVersion="8.29.0" x-pid="3364" x-info="http://www.rsyslog.com"] start
George Keishing6218e762018-10-06 13:14:36 -0500261 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
262 ... journalctl -b --no-pager | egrep 'rsyslog' | egrep -Ev '${RSYSLOG_REGEX}|${RSYSLOG_RETRY_REGEX}'
263 ... ignore_err=${1}
264
265 Should Be Empty ${bmc_journald}
266 ... msg=${bmc_journald} contains unexpected rsyslog entries.
267
268
George Keishing76a5daf2018-09-14 06:00:01 -0500269Boot Host And Verify Data Is Synced To Remote Server
270 [Documentation] Boot host and verify the power on sequence logs are synced
271 ... to remote logging server.
272 [Tags] Boot_Host_And_Verify_Data_Is_Synced_To_Remote_Server
273
George Keishing307c3fa2018-10-25 11:43:23 -0500274 # Filter kernel dmesg from the journald log.
275 # Example: xx.xx.xx kernel:
276
277 ${openbmc_host_name} ${openbmc_ip} ${openbmc_short_name}=
278 ... Get Host Name IP host=${OPENBMC_HOST} short_name=1
279
280 ${cmd}= Catenate SEPARATOR= --no-pager | egrep -Ev '${BMC_SYSLOG_REGEX}
281 ... |${openbmc_short_name} kernel' | awk -F': ' '{print $2}'
George Keishing76a5daf2018-09-14 06:00:01 -0500282
283 # Example: Just get the message part of the syslog
284 # Started OpenPOWER OCC Active Disable.
285 Start Journal Log filter=${cmd}
286
287 # Irrespective of the outcome, the journald should be synced.
288 Run Keyword And Ignore Error REST Power On
289 ${bmc_journald}= Stop Journal Log
290
291 ${cmd}= Catenate SEPARATOR= egrep '${bmc_hostname}' /var/log/syslog
292 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
293
294 @{lines}= Split To Lines ${bmc_journald}
George Keishing307c3fa2018-10-25 11:43:23 -0500295
George Keishing76a5daf2018-09-14 06:00:01 -0500296 :FOR ${line} IN @{lines}
297 \ Log To Console \n ${line}
298 \ Should Contain ${remote_journald} ${line}
299 ... mgs=${line} line doesn't contain in ${remote_journald}.
300
301
George Keishing6a514ef2018-08-27 05:19:19 -0500302*** Keywords ***
303
304Suite Setup Execution
305 [Documentation] Do the suite setup.
306
307 Should Not Be Empty ${REMOTE_LOG_SERVER_HOST}
308 Should Not Be Empty ${REMOTE_LOG_SERVER_PORT}
George Keishing67133672018-08-31 10:23:15 -0500309 Should Not Be Empty ${REMOTE_USERNAME}
310 Should Not Be Empty ${REMOTE_PASSWORD}
George Keishing6a514ef2018-08-27 05:19:19 -0500311 Ping Host ${REMOTE_LOG_SERVER_HOST}
George Keishing67133672018-08-31 10:23:15 -0500312 Remote Logging Server Execute Command true
George Keishing6a514ef2018-08-27 05:19:19 -0500313 Remote Logging Interface Should Exist
314
George Keishing216e5842018-08-31 14:58:15 -0500315 ${hostname} ${stderr} ${rc}= BMC Execute Command /bin/hostname
316 Set Suite Variable ${bmc_hostname} ${hostname}
George Keishingbbfc3942018-09-19 10:15:48 -0500317 Configure Remote Log Server With Parameters
George Keishing216e5842018-08-31 14:58:15 -0500318
319
320Test Setup Execution
321 [Documentation] Do the test setup.
322
George Keishingb77a3572018-09-13 23:26:28 -0500323 # Retain only the past 1 second log:
324 BMC Execute Command journalctl --vacuum-time=1s
George Keishing13a64e62018-09-10 13:07:36 -0500325
326 ${config_status}= Run Keyword And Return Status
George Keishing216e5842018-08-31 14:58:15 -0500327 ... Get Remote Log Server Configured
328
George Keishingbbfc3942018-09-19 10:15:48 -0500329 Run Keyword If ${config_status}==${FALSE}
330 ... Configure Remote Log Server With Parameters
George Keishing216e5842018-08-31 14:58:15 -0500331
George Keishing6a514ef2018-08-27 05:19:19 -0500332
333Remote Logging Interface Should Exist
334 [Documentation] Check that the remote logging URI exist.
335
336 ${resp}= OpenBMC Get Request ${REMOTE_LOGGING_URI}
337 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
George Keishing38733f32018-09-20 05:56:50 -0500338
339
340Verify Configure Remote Logging Server
341 [Documentation] Configure the remote logging REST interface on BMC.
342 [Arguments] ${remote_host} ${remote_port} ${expectation}
343
344 # Description of argument(s):
345 # remote_host The host name or IP address of the remote logging server
346 # (e.g. "xx.xx.xx.xx").
347 # remote_port Remote ryslog server port number (e.g. "514").
348 # expectation Expect boolean True/False.
349
350
351 ${status}= Run Keyword And Return Status
George Keishingccd6d092018-09-21 00:39:43 -0500352 ... Configure Remote Log Server With Parameters remote_host=${remote_host} remote_port=${remote_port}
George Keishing38733f32018-09-20 05:56:50 -0500353
354 Should Be Equal ${status} ${expectation}
355 ... msg=Test result ${status} and expectation ${expectation} do not match.