blob: 813cad97281b949817b8d8af7e259174138b7ecd [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 Keishing6a514ef2018-08-27 05:19:19 -050026*** Test Cases ***
27
28Test Remote Logging REST Interface And Verify Config
29 [Documentation] Test remote logging interface and configuration.
30 [Tags] Test_Remote_Logging_REST_Interface_And_Verify_Config
31
32 Configure Remote Logging Server
33 Verify Rsyslog Config On BMC
34
35 Configure Remote Logging Server remote_host=${EMPTY} remote_port=0
36 Verify Rsyslog Config On BMC remote_host=remote-host remote_port=port
37
38
George Keishing67133672018-08-31 10:23:15 -050039Verfiy BMC Journald Synced To Remote Logging Server
40 [Documentation] Check that BMC journald is sync to remote rsyslog.
41 [Tags] Verfiy_BMC_Journald_Synced_To_Remote_Logging_Server
42
43 ${hostname} ${stderr} ${rc}= BMC Execute Command /bin/hostname
44 Remove Journald Logs
45
46 Configure Remote Logging Server
47 # Take a couple second to restart rsyslog service.
48 Sleep 3s
49
50 # Restart BMC dump service and get the last entry of the journald.
51 # Example:
52 # Aug 31 15:16:54 wsbmc123 systemd[1]: Started Phosphor Dump Manager
53 BMC Execute Command
54 ... systemctl restart xyz.openbmc_project.Dump.Manager.service
55
56 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
57 ... journalctl --no-pager | tail -1
58
59 ${cmd}= Catenate cat /var/log/syslog|grep ${hostname} | tail -1
60 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
61
62 Should Be Equal As Strings ${bmc_journald} ${remote_journald}
63 ... msg=${bmc_journald} and ${remote_journald} don't match.
64
65
George Keishing2cec1862018-09-03 12:59:25 -050066Verify Journald Post BMC Reset
67 [Documentation] Check that BMC journald is sync'ed to remote rsyslog after
68 ... BMC reset.
69 [Tags] Verify_Journald_Post_BMC_Reset
70
71 ${hostname} ${stderr} ${rc}= BMC Execute Command hostname
72 OBMC Reboot (off)
73
74 ${cmd}= Catenate grep ${hostname} /var/log/syslog |
75 ... egrep '${BMC_STOP_MSG}|${BMC_START_MSG}|${BMC_BOOT_MSG}'
76 ${remote_journald}= Remote Logging Server Execute Command command=${cmd}
77
78 # 1. Last reboot message to verify.
79 Should Contain ${remote_journald} ${BMC_STOP_MSG}
80 ... msg=The remote journald doesn't contain the IPMI shutdown message: ${BMC_STOP_MSG}.
81
82 # 2. Earliest booting message on journald.
83 Should Contain ${remote_journald} ${BMC_START_MSG}
84 ... msg=The remote journald doesn't contain the start message: ${BMC_START_MSG}.
85
86 # 3. Unique boot to standby message.
87 # Startup finished in 9.961s (kernel) + 1min 59.039s (userspace) = 2min 9.000s
88 ${bmc_journald} ${stderr} ${rc}= BMC Execute Command
89 ... journalctl --no-pager | egrep '${BMC_BOOT_MSG}' | tail -1
90
91 Should Contain ${remote_journald}
92 ... ${bmc_journald.split('${hostname}')[1]}
93 ... msg=The remote journald doesn't contain the boot message: ${BMC_BOOT_MSG}.
94
95
George Keishing6a514ef2018-08-27 05:19:19 -050096*** Keywords ***
97
98Suite Setup Execution
99 [Documentation] Do the suite setup.
100
101 Should Not Be Empty ${REMOTE_LOG_SERVER_HOST}
102 Should Not Be Empty ${REMOTE_LOG_SERVER_PORT}
George Keishing67133672018-08-31 10:23:15 -0500103 Should Not Be Empty ${REMOTE_USERNAME}
104 Should Not Be Empty ${REMOTE_PASSWORD}
George Keishing6a514ef2018-08-27 05:19:19 -0500105 Ping Host ${REMOTE_LOG_SERVER_HOST}
George Keishing67133672018-08-31 10:23:15 -0500106 Remote Logging Server Execute Command true
George Keishing6a514ef2018-08-27 05:19:19 -0500107 Remote Logging Interface Should Exist
108
109
110Remote Logging Interface Should Exist
111 [Documentation] Check that the remote logging URI exist.
112
113 ${resp}= OpenBMC Get Request ${REMOTE_LOGGING_URI}
114 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
115
116
117Configure Remote Logging Server
118 [Documentation] Configure the remote logging server on BMC.
119 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
120 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
121
122 # Description of argument(s):
123 # remote_host The host name or IP address of the remote logging server
124 # (e.g. "xx.xx.xx.xx").
125 # remote_port Remote ryslog server port number (e.g. "514").
126
127 # Example:
128 # https://xx.xx.xx.xx/xyz/openbmc_project/logging/config/remote
129 # Response code:200, Content:{
130 # "data": {
131 # "Address": "xx.xx.xx.xx",
132 # "Port": 514
133 # },
134 # "message": "200 OK",
135 # "status": "ok"
136 # }
137
138 ${host_dict}= Create Dictionary data=${remote_host}
139 Write Attribute ${REMOTE_LOGGING_URI} Address data=${host_dict}
140 ... verify=${TRUE} expected_value=${remote_host}
141
142 ${remote_port}= Convert To Integer ${remote_port}
143 ${port_dict}= Create Dictionary data=${remote_port}
144 Write Attribute ${REMOTE_LOGGING_URI} Port data=${port_dict}
145 ... verify=${TRUE} expected_value=${remote_port}
146
147
148Verify Rsyslog Config On BMC
149 [Documentation] Check if the rsyslog configuration on BMC is correct.
150 [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST}
151 ... ${remote_port}=${REMOTE_LOG_SERVER_PORT}
152
153 # Description of argument(s):
154 # remote_host The host name or IP address of the remote logging server
155 # (e.g. "xx.xx.xx.xx").
156 # remote_port Remote ryslog server port number (e.g. "514").
157
158 # Example:
159 # Configured:
160 # *.* @@xx.xx.xx.xx:514root@wsbmc123
161 # By default:
162 # #*.* @@remote-host:port
163
164 ${ryslog_conf} ${stderr} ${rc}= BMC Execute Command
165 ... cat /etc/rsyslog.d/server.conf
166
167 ${config}= Catenate @@${remote_host}:${remote_port}
168
169 Should Contain ${ryslog_conf} ${config}
170 ... msg=${remote_host} and ${remote_port} are not configured.
George Keishing67133672018-08-31 10:23:15 -0500171
172
173Remote Logging Server Execute Command
174 [Documentation] Login to remote logging server.
175 [Arguments] ${command}
176 ... ${remote_host}=${REMOTE_LOG_SERVER_HOST}
177 ... ${user_name}=${REMOTE_USERNAME}
178 ... ${user_password}=${REMOTE_PASSWORD}
179
180 ${remote_dict}= Create Dictionary host=${remote_host}
181 Open Connection And Log In ${user_name} ${user_password}
182 ... &{remote_dict}
183 ${stdout} ${stderr}= Execute Command ${command} return_stderr=True
184 Should Be Empty ${stderr}
185 [Return] ${stdout}
186