blob: d82dc3935dd77d3f446879315a75e6766481930a [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 Keishing2cec1862018-09-03 12:59:25 -050015Resource ../lib/boot_utils.robot
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 Keishing6a514ef2018-08-27 05:19:19 -0500125*** Keywords ***
126
127Suite Setup Execution
128 [Documentation] Do the suite setup.
129
130 Should Not Be Empty ${REMOTE_LOG_SERVER_HOST}
131 Should Not Be Empty ${REMOTE_LOG_SERVER_PORT}
George Keishing67133672018-08-31 10:23:15 -0500132 Should Not Be Empty ${REMOTE_USERNAME}
133 Should Not Be Empty ${REMOTE_PASSWORD}
George Keishing6a514ef2018-08-27 05:19:19 -0500134 Ping Host ${REMOTE_LOG_SERVER_HOST}
George Keishing67133672018-08-31 10:23:15 -0500135 Remote Logging Server Execute Command true
George Keishing6a514ef2018-08-27 05:19:19 -0500136 Remote Logging Interface Should Exist
137
George Keishing216e5842018-08-31 14:58:15 -0500138 ${hostname} ${stderr} ${rc}= BMC Execute Command /bin/hostname
139 Set Suite Variable ${bmc_hostname} ${hostname}
140
141
142Test Setup Execution
143 [Documentation] Do the test setup.
144
145 Remove Journald Logs
146 ${cofig_status}= Run Keyword And Return Status
147 ... Get Remote Log Server Configured
148
149 Run Keyword If ${config_status}==${FALSE} Configure Remote Logging Server
150
151 ${ActiveState}= Get Service Attribute ActiveState rsyslog.service
152 Should Be Equal active ${ActiveState}
153 ... msg=rsyslog logging service not in active state.
154
George Keishing6a514ef2018-08-27 05:19:19 -0500155
156Remote Logging Interface Should Exist
157 [Documentation] Check that the remote logging URI exist.
158
159 ${resp}= OpenBMC Get Request ${REMOTE_LOGGING_URI}
160 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
161
162
163Configure Remote Logging Server
164 [Documentation] Configure the remote logging server on BMC.
165 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
166 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
167
168 # Description of argument(s):
169 # remote_host The host name or IP address of the remote logging server
170 # (e.g. "xx.xx.xx.xx").
171 # remote_port Remote ryslog server port number (e.g. "514").
172
173 # Example:
174 # https://xx.xx.xx.xx/xyz/openbmc_project/logging/config/remote
175 # Response code:200, Content:{
176 # "data": {
177 # "Address": "xx.xx.xx.xx",
178 # "Port": 514
179 # },
180 # "message": "200 OK",
181 # "status": "ok"
182 # }
183
184 ${host_dict}= Create Dictionary data=${remote_host}
185 Write Attribute ${REMOTE_LOGGING_URI} Address data=${host_dict}
186 ... verify=${TRUE} expected_value=${remote_host}
187
George Keishing216e5842018-08-31 14:58:15 -0500188 # TODO: From Dev to do bump up restart service time and bulk address and
189 # port update API.
190 # Reference: https://github.com/ibm-openbmc/dev/issues/59
191 Sleep 10s
192
George Keishing6a514ef2018-08-27 05:19:19 -0500193 ${remote_port}= Convert To Integer ${remote_port}
194 ${port_dict}= Create Dictionary data=${remote_port}
195 Write Attribute ${REMOTE_LOGGING_URI} Port data=${port_dict}
196 ... verify=${TRUE} expected_value=${remote_port}
197
George Keishing216e5842018-08-31 14:58:15 -0500198 # TODO: From Dev to do bump up restart service time and bulk address and
199 # port update API.
200 # Reference: https://github.com/ibm-openbmc/dev/issues/59
201 Sleep 10s
202
George Keishing6a514ef2018-08-27 05:19:19 -0500203
204Verify Rsyslog Config On BMC
205 [Documentation] Check if the rsyslog configuration on BMC is correct.
206 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
207 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
208
209 # Description of argument(s):
210 # remote_host The host name or IP address of the remote logging server
211 # (e.g. "xx.xx.xx.xx").
212 # remote_port Remote ryslog server port number (e.g. "514").
213
214 # Example:
215 # Configured:
216 # *.* @@xx.xx.xx.xx:514root@wsbmc123
217 # By default:
218 # #*.* @@remote-host:port
219
220 ${ryslog_conf} ${stderr} ${rc}= BMC Execute Command
221 ... cat /etc/rsyslog.d/server.conf
222
223 ${config}= Catenate @@${remote_host}:${remote_port}
224
225 Should Contain ${ryslog_conf} ${config}
226 ... msg=${remote_host} and ${remote_port} are not configured.
George Keishing67133672018-08-31 10:23:15 -0500227
228
229Remote Logging Server Execute Command
230 [Documentation] Login to remote logging server.
231 [Arguments] ${command}
232 ... ${remote_host}=${REMOTE_LOG_SERVER_HOST}
George Keishing216e5842018-08-31 14:58:15 -0500233 ... ${username}=${REMOTE_USERNAME}
234 ... ${password}=${REMOTE_PASSWORD}
235
236 # Description of argument(s):
237 # command Command line string.
238 # remote_host The host name or IP address of the remote logging server
239 # (e.g. "xx.xx.xx.xx").
240 # username Remote rsyslog server user name.
241 # password Remote rsyslog server password.
George Keishing67133672018-08-31 10:23:15 -0500242
243 ${remote_dict}= Create Dictionary host=${remote_host}
George Keishing216e5842018-08-31 14:58:15 -0500244 Open Connection And Log In ${username} ${password}
George Keishing67133672018-08-31 10:23:15 -0500245 ... &{remote_dict}
246 ${stdout} ${stderr}= Execute Command ${command} return_stderr=True
247 Should Be Empty ${stderr}
248 [Return] ${stdout}
249
George Keishing216e5842018-08-31 14:58:15 -0500250
251Get Remote Log Server Configured
252 [Documentation] Check that remote logging server is not configured.
253
254 ${address}= Read Attribute ${REMOTE_LOGGING_URI} Address
255 Should Not Be Equal ${address} ${REMOTE_LOG_SERVER_HOST}
256
257 ${port_number}= Convert To Integer ${REMOTE_LOG_SERVER_PORT}
258 ${port}= Read Attribute ${REMOTE_LOGGING_URI} Port
259 Should Not Be Equal ${port} ${port_number}