blob: ea4db5534841b514254c232d159089f044a3222b [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
18Test Teardown FFDC On Test Case Fail
19
George Keishing2cec1862018-09-03 12:59:25 -050020*** Variables ***
21
22${BMC_STOP_MSG} Stopping Phosphor IPMI BT DBus Bridge
23${BMC_START_MSG} Starting Flush Journal to Persistent Storage
24${BMC_BOOT_MSG} Startup finished in
25
George Keishingc1ca5e92018-09-03 11:19:23 -050026# Strings to check from journald.
27${RSYSLOG_REGEX} start|exiting on signal 15
28
George Keishing6a514ef2018-08-27 05:19:19 -050029*** Test Cases ***
30
31Test Remote Logging REST Interface And Verify Config
32 [Documentation] Test remote logging interface and configuration.
33 [Tags] Test_Remote_Logging_REST_Interface_And_Verify_Config
34
35 Configure Remote Logging Server
36 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
62 ${hostname} ${stderr} ${rc}= BMC Execute Command /bin/hostname
63 Remove Journald Logs
64
65 Configure Remote Logging Server
66 # Take a couple second to restart rsyslog service.
67 Sleep 3s
68
69 # Restart BMC dump service and get the last entry of the journald.
70 # Example:
71 # Aug 31 15:16:54 wsbmc123 systemd[1]: Started Phosphor Dump Manager
72 BMC Execute Command
73 ... systemctl restart xyz.openbmc_project.Dump.Manager.service
74
75 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
76 ... journalctl --no-pager | tail -1
77
78 ${cmd}= Catenate cat /var/log/syslog|grep ${hostname} | tail -1
79 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
80
81 Should Be Equal As Strings ${bmc_journald} ${remote_journald}
82 ... msg=${bmc_journald} and ${remote_journald} don't match.
83
84
George Keishing2cec1862018-09-03 12:59:25 -050085Verify Journald Post BMC Reset
86 [Documentation] Check that BMC journald is sync'ed to remote rsyslog after
87 ... BMC reset.
88 [Tags] Verify_Journald_Post_BMC_Reset
89
90 ${hostname} ${stderr} ${rc}= BMC Execute Command hostname
91 OBMC Reboot (off)
92
93 ${cmd}= Catenate grep ${hostname} /var/log/syslog |
94 ... egrep '${BMC_STOP_MSG}|${BMC_START_MSG}|${BMC_BOOT_MSG}'
95 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
96
97 # 1. Last reboot message to verify.
98 Should Contain ${remote_journald} ${BMC_STOP_MSG}
99 ... msg=The remote journald doesn't contain the IPMI shutdown message: ${BMC_STOP_MSG}.
100
101 # 2. Earliest booting message on journald.
102 Should Contain ${remote_journald} ${BMC_START_MSG}
103 ... msg=The remote journald doesn't contain the start message: ${BMC_START_MSG}.
104
105 # 3. Unique boot to standby message.
106 # Startup finished in 9.961s (kernel) + 1min 59.039s (userspace) = 2min 9.000s
107 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
108 ... journalctl --no-pager | egrep '${BMC_BOOT_MSG}' | tail -1
109
110 Should Contain ${remote_journald}
111 ... ${bmc_journald.split('${hostname}')[1]}
112 ... msg=The remote journald doesn't contain the boot message: ${BMC_BOOT_MSG}.
113
114
George Keishing6a514ef2018-08-27 05:19:19 -0500115*** Keywords ***
116
117Suite Setup Execution
118 [Documentation] Do the suite setup.
119
120 Should Not Be Empty ${REMOTE_LOG_SERVER_HOST}
121 Should Not Be Empty ${REMOTE_LOG_SERVER_PORT}
George Keishing67133672018-08-31 10:23:15 -0500122 Should Not Be Empty ${REMOTE_USERNAME}
123 Should Not Be Empty ${REMOTE_PASSWORD}
George Keishing6a514ef2018-08-27 05:19:19 -0500124 Ping Host ${REMOTE_LOG_SERVER_HOST}
George Keishing67133672018-08-31 10:23:15 -0500125 Remote Logging Server Execute Command true
George Keishing6a514ef2018-08-27 05:19:19 -0500126 Remote Logging Interface Should Exist
127
128
129Remote Logging Interface Should Exist
130 [Documentation] Check that the remote logging URI exist.
131
132 ${resp}= OpenBMC Get Request ${REMOTE_LOGGING_URI}
133 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
134
135
136Configure Remote Logging Server
137 [Documentation] Configure the remote logging server on BMC.
138 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
139 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
140
141 # Description of argument(s):
142 # remote_host The host name or IP address of the remote logging server
143 # (e.g. "xx.xx.xx.xx").
144 # remote_port Remote ryslog server port number (e.g. "514").
145
146 # Example:
147 # https://xx.xx.xx.xx/xyz/openbmc_project/logging/config/remote
148 # Response code:200, Content:{
149 # "data": {
150 # "Address": "xx.xx.xx.xx",
151 # "Port": 514
152 # },
153 # "message": "200 OK",
154 # "status": "ok"
155 # }
156
157 ${host_dict}= Create Dictionary data=${remote_host}
158 Write Attribute ${REMOTE_LOGGING_URI} Address data=${host_dict}
159 ... verify=${TRUE} expected_value=${remote_host}
160
161 ${remote_port}= Convert To Integer ${remote_port}
162 ${port_dict}= Create Dictionary data=${remote_port}
163 Write Attribute ${REMOTE_LOGGING_URI} Port data=${port_dict}
164 ... verify=${TRUE} expected_value=${remote_port}
165
166
167Verify Rsyslog Config On BMC
168 [Documentation] Check if the rsyslog configuration on BMC is correct.
169 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
170 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
171
172 # Description of argument(s):
173 # remote_host The host name or IP address of the remote logging server
174 # (e.g. "xx.xx.xx.xx").
175 # remote_port Remote ryslog server port number (e.g. "514").
176
177 # Example:
178 # Configured:
179 # *.* @@xx.xx.xx.xx:514root@wsbmc123
180 # By default:
181 # #*.* @@remote-host:port
182
183 ${ryslog_conf} ${stderr} ${rc}= BMC Execute Command
184 ... cat /etc/rsyslog.d/server.conf
185
186 ${config}= Catenate @@${remote_host}:${remote_port}
187
188 Should Contain ${ryslog_conf} ${config}
189 ... msg=${remote_host} and ${remote_port} are not configured.
George Keishing67133672018-08-31 10:23:15 -0500190
191
192Remote Logging Server Execute Command
193 [Documentation] Login to remote logging server.
194 [Arguments] ${command}
195 ... ${remote_host}=${REMOTE_LOG_SERVER_HOST}
196 ... ${user_name}=${REMOTE_USERNAME}
197 ... ${user_password}=${REMOTE_PASSWORD}
198
199 ${remote_dict}= Create Dictionary host=${remote_host}
200 Open Connection And Log In ${user_name} ${user_password}
201 ... &{remote_dict}
202 ${stdout} ${stderr}= Execute Command ${command} return_stderr=True
203 Should Be Empty ${stderr}
204 [Return] ${stdout}
205