blob: b6b383d8b9079ae58a0bd808ce105a5a36620c44 [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
11Resource ../lib/resource.txt
12Resource ../lib/rest_client.robot
13Resource ../lib/utils.robot
14Resource ../lib/openbmc_ffdc.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
23${BMC_STOP_MSG} Stopping Phosphor IPMI BT DBus Bridge
24${BMC_START_MSG} Starting Flush Journal to Persistent Storage
25${BMC_BOOT_MSG} Startup finished in
26
George Keishingc1ca5e92018-09-03 11:19:23 -050027# Strings to check from journald.
28${RSYSLOG_REGEX} start|exiting on signal 15
29
George Keishing6a514ef2018-08-27 05:19:19 -050030*** Test Cases ***
31
32Test Remote Logging REST Interface And Verify Config
33 [Documentation] Test remote logging interface and configuration.
34 [Tags] Test_Remote_Logging_REST_Interface_And_Verify_Config
35
George Keishing6a514ef2018-08-27 05:19:19 -050036 Verify Rsyslog Config On BMC
37
38 Configure Remote Logging Server remote_host=${EMPTY} remote_port=0
39 Verify Rsyslog Config On BMC remote_host=remote-host remote_port=port
40
41
George Keishingc1ca5e92018-09-03 11:19:23 -050042Verify Rsyslog Does Not Log On BMC
43 [Documentation] Check that rsyslog journald doesn't log on BMC.
44 [Tags] Verify_Rsyslog_Does_Not_Log_On_BMC
45
46 # Expected filter rsyslog entries.
47 # Example:
48 # 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.
49 # 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
50 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
51 ... journalctl -b --no-pager | egrep 'rsyslog' | egrep -Ev '${RSYSLOG_REGEX}'
52 ... ignore_err=${1}
53
54 Should Be Empty ${bmc_journald}
55 ... msg=${bmc_journald} contains unexpected rsyslog entries.
56
57
George Keishing67133672018-08-31 10:23:15 -050058Verfiy BMC Journald Synced To Remote Logging Server
59 [Documentation] Check that BMC journald is sync to remote rsyslog.
60 [Tags] Verfiy_BMC_Journald_Synced_To_Remote_Logging_Server
61
George Keishing67133672018-08-31 10:23:15 -050062 # Restart BMC dump service and get the last entry of the journald.
63 # Example:
George Keishing216e5842018-08-31 14:58:15 -050064 # Sep 03 10:09:28 wsbmc123 systemd[1]: Started Phosphor Dump Manager.
George Keishing67133672018-08-31 10:23:15 -050065 BMC Execute Command
66 ... systemctl restart xyz.openbmc_project.Dump.Manager.service
67
68 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
69 ... journalctl --no-pager | tail -1
70
George Keishing216e5842018-08-31 14:58:15 -050071 # Sep 3 10:09:28 wsbmc123 systemd[1]: Started Phosphor Dump Manager.
72 ${cmd}= Catenate cat /var/log/syslog|grep ${bmc_hostname} | tail -1
George Keishing67133672018-08-31 10:23:15 -050073 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
74
George Keishing216e5842018-08-31 14:58:15 -050075 # TODO: rsyslog configuration and time date template to match BMC journald.
76 # Compare the BMC journlad log. Example:
77 # systemd[1]: Started Phosphor Dump Manager.
78 Should Be Equal As Strings ${bmc_journald.split('${bmc_hostname}')[1]}
79 ... ${remote_journald.split('${bmc_hostname}')[1]}
80 ... msg= ${bmc_journald} doesn't match remote rsyslog:${remote_journald}.
George Keishing67133672018-08-31 10:23:15 -050081
82
George Keishing2cec1862018-09-03 12:59:25 -050083Verify Journald Post BMC Reset
84 [Documentation] Check that BMC journald is sync'ed to remote rsyslog after
85 ... BMC reset.
86 [Tags] Verify_Journald_Post_BMC_Reset
87
88 ${hostname} ${stderr} ${rc}= BMC Execute Command hostname
89 OBMC Reboot (off)
90
91 ${cmd}= Catenate grep ${hostname} /var/log/syslog |
92 ... egrep '${BMC_STOP_MSG}|${BMC_START_MSG}|${BMC_BOOT_MSG}'
93 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
94
95 # 1. Last reboot message to verify.
96 Should Contain ${remote_journald} ${BMC_STOP_MSG}
97 ... msg=The remote journald doesn't contain the IPMI shutdown message: ${BMC_STOP_MSG}.
98
99 # 2. Earliest booting message on journald.
100 Should Contain ${remote_journald} ${BMC_START_MSG}
101 ... msg=The remote journald doesn't contain the start message: ${BMC_START_MSG}.
102
103 # 3. Unique boot to standby message.
104 # Startup finished in 9.961s (kernel) + 1min 59.039s (userspace) = 2min 9.000s
105 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
106 ... journalctl --no-pager | egrep '${BMC_BOOT_MSG}' | tail -1
107
108 Should Contain ${remote_journald}
109 ... ${bmc_journald.split('${hostname}')[1]}
110 ... msg=The remote journald doesn't contain the boot message: ${BMC_BOOT_MSG}.
111
112
George Keishingcc18f7c2018-09-03 09:40:11 -0500113Verify BMC Journald Contains No Credential Data
114 [Documentation] Check that BMC journald doesnt log any credential data.
115 [Tags] Verify_BMC_Journald_Contains_No_Credential_Data
116
117 Open Connection And Log In
118 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
119 ... journalctl -o json-pretty | cat
120
121 Should Not Contain Any ${bmc_journald} ${OPENBMC_PASSWORD}
122 ... msg=Journald logs BMC credentials/password ${OPENBMC_PASSWORD}.
123
124
George Keishing9a0d4802018-08-31 13:29:40 -0500125Audit BMC SSH Login And Remote Logging
126 [Documentation] Check that the SSH login to BMC is logged and synced to
127 ... remote logging server.
128 [Tags] Audit_BMC_SSH_Login_And_Remote_Logging
129
130 ${test_host_name} ${test_host_ip}= Get Host Name IP
131
132 # Aug 31 17:22:55 wsbmc123 systemd[1]: Started SSH Per-Connection Server (xx.xx.xx.xx:51292)
133 Open Connection And Log In
134
135 ${login_footprint}= Catenate Started SSH Per-Connection Server.*${test_host_ip}
136
137 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
138 ... journalctl --no-pager | grep '${login_footprint}'
139
140 ${cmd}= Catenate SEPARATOR= grep '${bmc_hostname}|${test_host_ip}|${login_footprint}' /var/log/syslog
141
142 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
143
144 Should Contain ${remote_journald} ${bmc_journald}
145 ... msg=${remote_journald} don't contain ${bmc_journald} entry.
146
147
George Keishing6a514ef2018-08-27 05:19:19 -0500148*** Keywords ***
149
150Suite Setup Execution
151 [Documentation] Do the suite setup.
152
153 Should Not Be Empty ${REMOTE_LOG_SERVER_HOST}
154 Should Not Be Empty ${REMOTE_LOG_SERVER_PORT}
George Keishing67133672018-08-31 10:23:15 -0500155 Should Not Be Empty ${REMOTE_USERNAME}
156 Should Not Be Empty ${REMOTE_PASSWORD}
George Keishing6a514ef2018-08-27 05:19:19 -0500157 Ping Host ${REMOTE_LOG_SERVER_HOST}
George Keishing67133672018-08-31 10:23:15 -0500158 Remote Logging Server Execute Command true
George Keishing6a514ef2018-08-27 05:19:19 -0500159 Remote Logging Interface Should Exist
160
George Keishing216e5842018-08-31 14:58:15 -0500161 ${hostname} ${stderr} ${rc}= BMC Execute Command /bin/hostname
162 Set Suite Variable ${bmc_hostname} ${hostname}
163
164
165Test Setup Execution
166 [Documentation] Do the test setup.
167
168 Remove Journald Logs
169 ${cofig_status}= Run Keyword And Return Status
170 ... Get Remote Log Server Configured
171
172 Run Keyword If ${config_status}==${FALSE} Configure Remote Logging Server
173
174 ${ActiveState}= Get Service Attribute ActiveState rsyslog.service
175 Should Be Equal active ${ActiveState}
176 ... msg=rsyslog logging service not in active state.
177
George Keishing6a514ef2018-08-27 05:19:19 -0500178
179Remote Logging Interface Should Exist
180 [Documentation] Check that the remote logging URI exist.
181
182 ${resp}= OpenBMC Get Request ${REMOTE_LOGGING_URI}
183 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
184
185
186Configure Remote Logging Server
187 [Documentation] Configure the remote logging server on BMC.
188 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
189 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
190
191 # Description of argument(s):
192 # remote_host The host name or IP address of the remote logging server
193 # (e.g. "xx.xx.xx.xx").
194 # remote_port Remote ryslog server port number (e.g. "514").
195
196 # Example:
197 # https://xx.xx.xx.xx/xyz/openbmc_project/logging/config/remote
198 # Response code:200, Content:{
199 # "data": {
200 # "Address": "xx.xx.xx.xx",
201 # "Port": 514
202 # },
203 # "message": "200 OK",
204 # "status": "ok"
205 # }
206
207 ${host_dict}= Create Dictionary data=${remote_host}
208 Write Attribute ${REMOTE_LOGGING_URI} Address data=${host_dict}
209 ... verify=${TRUE} expected_value=${remote_host}
210
George Keishing216e5842018-08-31 14:58:15 -0500211 # TODO: From Dev to do bump up restart service time and bulk address and
212 # port update API.
213 # Reference: https://github.com/ibm-openbmc/dev/issues/59
214 Sleep 10s
215
George Keishing6a514ef2018-08-27 05:19:19 -0500216 ${remote_port}= Convert To Integer ${remote_port}
217 ${port_dict}= Create Dictionary data=${remote_port}
218 Write Attribute ${REMOTE_LOGGING_URI} Port data=${port_dict}
219 ... verify=${TRUE} expected_value=${remote_port}
220
George Keishing216e5842018-08-31 14:58:15 -0500221 # TODO: From Dev to do bump up restart service time and bulk address and
222 # port update API.
223 # Reference: https://github.com/ibm-openbmc/dev/issues/59
224 Sleep 10s
225
George Keishing6a514ef2018-08-27 05:19:19 -0500226
227Verify Rsyslog Config On BMC
228 [Documentation] Check if the rsyslog configuration on BMC is correct.
229 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
230 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
231
232 # Description of argument(s):
233 # remote_host The host name or IP address of the remote logging server
234 # (e.g. "xx.xx.xx.xx").
235 # remote_port Remote ryslog server port number (e.g. "514").
236
237 # Example:
238 # Configured:
239 # *.* @@xx.xx.xx.xx:514root@wsbmc123
240 # By default:
241 # #*.* @@remote-host:port
242
243 ${ryslog_conf} ${stderr} ${rc}= BMC Execute Command
244 ... cat /etc/rsyslog.d/server.conf
245
246 ${config}= Catenate @@${remote_host}:${remote_port}
247
248 Should Contain ${ryslog_conf} ${config}
249 ... msg=${remote_host} and ${remote_port} are not configured.
George Keishing67133672018-08-31 10:23:15 -0500250
251
252Remote Logging Server Execute Command
253 [Documentation] Login to remote logging server.
254 [Arguments] ${command}
255 ... ${remote_host}=${REMOTE_LOG_SERVER_HOST}
George Keishing216e5842018-08-31 14:58:15 -0500256 ... ${username}=${REMOTE_USERNAME}
257 ... ${password}=${REMOTE_PASSWORD}
258
259 # Description of argument(s):
260 # command Command line string.
261 # remote_host The host name or IP address of the remote logging server
262 # (e.g. "xx.xx.xx.xx").
263 # username Remote rsyslog server user name.
264 # password Remote rsyslog server password.
George Keishing67133672018-08-31 10:23:15 -0500265
266 ${remote_dict}= Create Dictionary host=${remote_host}
George Keishing216e5842018-08-31 14:58:15 -0500267 Open Connection And Log In ${username} ${password}
George Keishing67133672018-08-31 10:23:15 -0500268 ... &{remote_dict}
269 ${stdout} ${stderr}= Execute Command ${command} return_stderr=True
270 Should Be Empty ${stderr}
271 [Return] ${stdout}
272
George Keishing216e5842018-08-31 14:58:15 -0500273
274Get Remote Log Server Configured
275 [Documentation] Check that remote logging server is not configured.
276
277 ${address}= Read Attribute ${REMOTE_LOGGING_URI} Address
278 Should Not Be Equal ${address} ${REMOTE_LOG_SERVER_HOST}
279
280 ${port_number}= Convert To Integer ${REMOTE_LOG_SERVER_PORT}
281 ${port}= Read Attribute ${REMOTE_LOGGING_URI} Port
282 Should Not Be Equal ${port} ${port_number}