blob: b04f07a5571db00529883c216ec1f74e8e18f72f [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
28${RSYSLOG_REGEX} start|exiting on signal 15
29${RSYSLOG_RETRY_REGEX} suspended, next retry
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 Keishing4df837f2018-09-19 14:06:01 -050062 ${login_footprint}= Catenate user:root POST http://127.0.0.1:8081/login json:None 200 OK
63 # Example: Just get the message part of the syslog
64 # user:root POST http://127.0.0.1:8081/login json:None 200 OK
65 ${cmd}= Catenate SEPARATOR= --no-pager | egrep '${login_footprint}'
66 ... | awk -F': ' '{print $2}'
67
68 Start Journal Log filter=${cmd}
George Keishing13a64e62018-09-10 13:07:36 -050069 Initialize OpenBMC
George Keishing4df837f2018-09-19 14:06:01 -050070 Sleep 5s
71 ${bmc_journald}= Stop Journal Log
George Keishing13a64e62018-09-10 13:07:36 -050072
George Keishing4df837f2018-09-19 14:06:01 -050073 Should Be Empty ${bmc_journald}
George Keishing13a64e62018-09-10 13:07:36 -050074 ... msg=${bmc_journald} contains unexpected REST entries.
75
76
George Keishingb77a3572018-09-13 23:26:28 -050077Verify REST Logging On BMC Journal When Enabled
George Keishing13a64e62018-09-10 13:07:36 -050078 [Documentation] Enable REST logging and verify from journald.
George Keishingb77a3572018-09-13 23:26:28 -050079 [Tags] Verify_REST_Logging_On_BMC_Journal_When_Enabled
George Keishing13a64e62018-09-10 13:07:36 -050080
81 ${log_dict}= Create Dictionary data=${True}
82 Write Attribute ${BMC_LOGGING_URI}${/}rest_api_logs Enabled data=${log_dict}
83 ... verify=${True} expected_value=${True}
84
85 # 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
86 Initialize OpenBMC
87
88 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
89 ... journalctl --no-pager
90
91 Should Contain ${bmc_journald} user:root POST http://127.0.0.1:8081/login json:None 200 OK
92 ... msg=${bmc_journald} doesn't contains REST entries.
93
94
George Keishing6a514ef2018-08-27 05:19:19 -050095Test Remote Logging REST Interface And Verify Config
96 [Documentation] Test remote logging interface and configuration.
97 [Tags] Test_Remote_Logging_REST_Interface_And_Verify_Config
98
George Keishing6a514ef2018-08-27 05:19:19 -050099 Verify Rsyslog Config On BMC
100
George Keishingbbfc3942018-09-19 10:15:48 -0500101 Configure Remote Log Server With Parameters remote_host=${EMPTY} remote_port=0
George Keishing6a514ef2018-08-27 05:19:19 -0500102 Verify Rsyslog Config On BMC remote_host=remote-host remote_port=port
103
104
George Keishing13451ed2018-09-06 12:46:16 -0500105Test Remote Logging Invalid Port Config And Verify BMC Journald
106 [Documentation] Test remote logging interface and configuration.
107 [Tags] Test_Remote_Logging_Invalid_Port_Config_And_Verify_BMC_Journald
108
109 # Invalid port derived by (REMOTE_LOG_SERVER_PORT + 1) port config setting.
110 ${INVALID_PORT}= Evaluate ${REMOTE_LOG_SERVER_PORT} + ${1}
George Keishingbbfc3942018-09-19 10:15:48 -0500111 Configure Remote Log Server With Parameters
George Keishing13451ed2018-09-06 12:46:16 -0500112 ... remote_host=${REMOTE_LOG_SERVER_HOST} remote_port=${INVALID_PORT}
113
114 Sleep 3s
115 # 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 ]
116 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
117 ... journalctl -b --no-pager | egrep 'rsyslog.*${RSYSLOG_RETRY_REGEX}'
118
119 Should Contain ${bmc_journald} ${RSYSLOG_RETRY_REGEX}
120 ... msg=${bmc_journald} doesn't contain rsyslog retry entries.
121
122
George Keishingc1ca5e92018-09-03 11:19:23 -0500123Verify Rsyslog Does Not Log On BMC
124 [Documentation] Check that rsyslog journald doesn't log on BMC.
125 [Tags] Verify_Rsyslog_Does_Not_Log_On_BMC
126
127 # Expected filter rsyslog entries.
128 # Example:
129 # 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.
130 # 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
131 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
132 ... journalctl -b --no-pager | egrep 'rsyslog' | egrep -Ev '${RSYSLOG_REGEX}'
133 ... ignore_err=${1}
134
135 Should Be Empty ${bmc_journald}
136 ... msg=${bmc_journald} contains unexpected rsyslog entries.
137
138
George Keishing67133672018-08-31 10:23:15 -0500139Verfiy BMC Journald Synced To Remote Logging Server
140 [Documentation] Check that BMC journald is sync to remote rsyslog.
141 [Tags] Verfiy_BMC_Journald_Synced_To_Remote_Logging_Server
142
George Keishing67133672018-08-31 10:23:15 -0500143 # Restart BMC dump service and get the last entry of the journald.
144 # Example:
George Keishing216e5842018-08-31 14:58:15 -0500145 # Sep 03 10:09:28 wsbmc123 systemd[1]: Started Phosphor Dump Manager.
George Keishing67133672018-08-31 10:23:15 -0500146 BMC Execute Command
147 ... systemctl restart xyz.openbmc_project.Dump.Manager.service
148
149 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
George Keishing82ea1d42018-09-11 13:45:36 -0500150 ... journalctl --no-pager | grep 'Started Phosphor Dump Manager'
George Keishing67133672018-08-31 10:23:15 -0500151
George Keishing216e5842018-08-31 14:58:15 -0500152 # Sep 3 10:09:28 wsbmc123 systemd[1]: Started Phosphor Dump Manager.
George Keishing82ea1d42018-09-11 13:45:36 -0500153 ${cmd}= Catenate SEPARATOR= egrep '${bmc_hostname}.*Started Phosphor Dump Manager' /var/log/syslog
George Keishing67133672018-08-31 10:23:15 -0500154 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
155
George Keishing216e5842018-08-31 14:58:15 -0500156 # TODO: rsyslog configuration and time date template to match BMC journald.
157 # Compare the BMC journlad log. Example:
158 # systemd[1]: Started Phosphor Dump Manager.
George Keishing82ea1d42018-09-11 13:45:36 -0500159 Should Contain ${remote_journald} ${bmc_journald.split('${bmc_hostname}')[1][0]}
George Keishing216e5842018-08-31 14:58:15 -0500160 ... msg= ${bmc_journald} doesn't match remote rsyslog:${remote_journald}.
George Keishing67133672018-08-31 10:23:15 -0500161
162
George Keishing2cec1862018-09-03 12:59:25 -0500163Verify Journald Post BMC Reset
164 [Documentation] Check that BMC journald is sync'ed to remote rsyslog after
165 ... BMC reset.
166 [Tags] Verify_Journald_Post_BMC_Reset
167
168 ${hostname} ${stderr} ${rc}= BMC Execute Command hostname
169 OBMC Reboot (off)
170
171 ${cmd}= Catenate grep ${hostname} /var/log/syslog |
172 ... egrep '${BMC_STOP_MSG}|${BMC_START_MSG}|${BMC_BOOT_MSG}'
173 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
174
175 # 1. Last reboot message to verify.
176 Should Contain ${remote_journald} ${BMC_STOP_MSG}
177 ... msg=The remote journald doesn't contain the IPMI shutdown message: ${BMC_STOP_MSG}.
178
179 # 2. Earliest booting message on journald.
180 Should Contain ${remote_journald} ${BMC_START_MSG}
181 ... msg=The remote journald doesn't contain the start message: ${BMC_START_MSG}.
182
183 # 3. Unique boot to standby message.
184 # Startup finished in 9.961s (kernel) + 1min 59.039s (userspace) = 2min 9.000s
185 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
186 ... journalctl --no-pager | egrep '${BMC_BOOT_MSG}' | tail -1
187
188 Should Contain ${remote_journald}
189 ... ${bmc_journald.split('${hostname}')[1]}
190 ... msg=The remote journald doesn't contain the boot message: ${BMC_BOOT_MSG}.
191
192
George Keishingcc18f7c2018-09-03 09:40:11 -0500193Verify BMC Journald Contains No Credential Data
George Keishingcb3b9b62018-09-14 12:11:19 -0500194 [Documentation] Check that BMC journald doesn't log any credential data.
George Keishingcc18f7c2018-09-03 09:40:11 -0500195 [Tags] Verify_BMC_Journald_Contains_No_Credential_Data
196
197 Open Connection And Log In
198 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
199 ... journalctl -o json-pretty | cat
200
201 Should Not Contain Any ${bmc_journald} ${OPENBMC_PASSWORD}
202 ... msg=Journald logs BMC credentials/password ${OPENBMC_PASSWORD}.
203
204
George Keishing9a0d4802018-08-31 13:29:40 -0500205Audit BMC SSH Login And Remote Logging
206 [Documentation] Check that the SSH login to BMC is logged and synced to
207 ... remote logging server.
208 [Tags] Audit_BMC_SSH_Login_And_Remote_Logging
209
George Keishingaef483e2018-09-19 07:57:22 -0500210 ${login_footprint}= Catenate Started SSH Per-Connection Server
211 # Example: Just get the message part of the syslog
212 # Started SSH Per-Connection Server (xx.xx.xx.xx:51292)
213 ${cmd}= Catenate SEPARATOR= --no-pager | egrep '${login_footprint}'
214 ... | awk -F': ' '{print $2}'
George Keishing9a0d4802018-08-31 13:29:40 -0500215
George Keishingaef483e2018-09-19 07:57:22 -0500216 Start Journal Log filter=${cmd}
George Keishing9a0d4802018-08-31 13:29:40 -0500217 Open Connection And Log In
George Keishingaef483e2018-09-19 07:57:22 -0500218 Sleep 5s
219 ${bmc_journald}= Stop Journal Log
220 @{ssh_entry}= Split To Lines ${bmc_journald}
George Keishing9a0d4802018-08-31 13:29:40 -0500221
George Keishingaef483e2018-09-19 07:57:22 -0500222 ${cmd}= Catenate SEPARATOR= egrep -E '*${bmc_hostname}.*${login_footprint}' /var/log/syslog
George Keishing9a0d4802018-08-31 13:29:40 -0500223
224 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
225
George Keishingaef483e2018-09-19 07:57:22 -0500226 Should Contain ${remote_journald} ${ssh_entry[0]}
George Keishing9a0d4802018-08-31 13:29:40 -0500227 ... msg=${remote_journald} don't contain ${bmc_journald} entry.
228
229
George Keishing76a5daf2018-09-14 06:00:01 -0500230Boot Host And Verify Data Is Synced To Remote Server
231 [Documentation] Boot host and verify the power on sequence logs are synced
232 ... to remote logging server.
233 [Tags] Boot_Host_And_Verify_Data_Is_Synced_To_Remote_Server
234
235 ${cmd}= Catenate SEPARATOR= --no-pager | egrep -Ev '${BMC_SYSLOG_REGEX}'
236 ... | awk -F': ' '{print $2}'
237
238 # Example: Just get the message part of the syslog
239 # Started OpenPOWER OCC Active Disable.
240 Start Journal Log filter=${cmd}
241
242 # Irrespective of the outcome, the journald should be synced.
243 Run Keyword And Ignore Error REST Power On
244 ${bmc_journald}= Stop Journal Log
245
246 ${cmd}= Catenate SEPARATOR= egrep '${bmc_hostname}' /var/log/syslog
247 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
248
249 @{lines}= Split To Lines ${bmc_journald}
250 :FOR ${line} IN @{lines}
251 \ Log To Console \n ${line}
252 \ Should Contain ${remote_journald} ${line}
253 ... mgs=${line} line doesn't contain in ${remote_journald}.
254
255
George Keishing6a514ef2018-08-27 05:19:19 -0500256*** Keywords ***
257
258Suite Setup Execution
259 [Documentation] Do the suite setup.
260
261 Should Not Be Empty ${REMOTE_LOG_SERVER_HOST}
262 Should Not Be Empty ${REMOTE_LOG_SERVER_PORT}
George Keishing67133672018-08-31 10:23:15 -0500263 Should Not Be Empty ${REMOTE_USERNAME}
264 Should Not Be Empty ${REMOTE_PASSWORD}
George Keishing6a514ef2018-08-27 05:19:19 -0500265 Ping Host ${REMOTE_LOG_SERVER_HOST}
George Keishing67133672018-08-31 10:23:15 -0500266 Remote Logging Server Execute Command true
George Keishing6a514ef2018-08-27 05:19:19 -0500267 Remote Logging Interface Should Exist
268
George Keishing216e5842018-08-31 14:58:15 -0500269 ${hostname} ${stderr} ${rc}= BMC Execute Command /bin/hostname
270 Set Suite Variable ${bmc_hostname} ${hostname}
George Keishingbbfc3942018-09-19 10:15:48 -0500271 Configure Remote Log Server With Parameters
George Keishing216e5842018-08-31 14:58:15 -0500272
273
274Test Setup Execution
275 [Documentation] Do the test setup.
276
George Keishingb77a3572018-09-13 23:26:28 -0500277 # Retain only the past 1 second log:
278 BMC Execute Command journalctl --vacuum-time=1s
George Keishing13a64e62018-09-10 13:07:36 -0500279
280 ${config_status}= Run Keyword And Return Status
George Keishing216e5842018-08-31 14:58:15 -0500281 ... Get Remote Log Server Configured
282
George Keishingbbfc3942018-09-19 10:15:48 -0500283 Run Keyword If ${config_status}==${FALSE}
284 ... Configure Remote Log Server With Parameters
George Keishing216e5842018-08-31 14:58:15 -0500285
286 ${ActiveState}= Get Service Attribute ActiveState rsyslog.service
287 Should Be Equal active ${ActiveState}
288 ... msg=rsyslog logging service not in active state.
289
George Keishing6a514ef2018-08-27 05:19:19 -0500290
291Remote Logging Interface Should Exist
292 [Documentation] Check that the remote logging URI exist.
293
294 ${resp}= OpenBMC Get Request ${REMOTE_LOGGING_URI}
295 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}