blob: ae9582b889931e51aa29ed6b90ba1c6aa75904b6 [file] [log] [blame]
Michael Walsh98d56d12018-09-19 16:05:00 -05001*** Settings ***
Steven Sombar15d1b9d2018-09-26 11:39:24 -05002Documentation Verify openbmctool.py functionality.
Michael Walsh98d56d12018-09-19 16:05:00 -05003
Steven Sombar15d1b9d2018-09-26 11:39:24 -05004# This module tests the functionality of openbmctool.py.
George Keishing7c6342b2018-11-02 14:27:13 -05005# The following tests are performed:
Steven Sombar15d1b9d2018-09-26 11:39:24 -05006#
7# FRU status
8# FRU print
9# FRU list
10# FRU list of a single FRU
11# sensors print
12# sensors list
13# sensors list of a single sensor
14# health check
15# service data
Steven Sombarbd049cb2018-10-07 20:40:39 -050016# remote logging
Steven Sombarba09f582018-12-10 12:23:25 -060017# local_users queryenabled
Steven Sombar15d1b9d2018-09-26 11:39:24 -050018#
19# It is the responsibility of the user to include openbmctool.py's
20# directory PATH in $PATH.
21#
22# Test Parameters:
23# OPENBMC_HOST The BMC host name or IP address.
24# OPENBMC_USERNAME The username to login to the BMC.
25# OPENBMC_PASSWORD Password for OPENBMC_USERNAME.
Steven Sombarbd049cb2018-10-07 20:40:39 -050026# LOGGING_HOST The hostname or IP address of the remote
27# logging server. The default value is
28# '10.10.10.10'.
29# LOGGING_PORT The port number for remote logging on the
30# LOGGING_HOST. The default value is '514'.
31
Steven Sombar15d1b9d2018-09-26 11:39:24 -050032
Steven Sombar15d1b9d2018-09-26 11:39:24 -050033Library String
34Library OperatingSystem
Steven Sombarfbc75392018-11-27 15:50:59 -060035Library ../../lib/gen_print.py
36Library ../../lib/gen_robot_print.py
37Library ../../lib/openbmctool_utils.py
38Library ../../lib/gen_misc.py
39Library ../../lib/gen_robot_valid.py
40Resource ../../syslib/utils_os.robot
Sandhya Somashekar839a0c22019-01-31 05:05:43 -060041Resource ../../lib/resource.robot
Steven Sombar15d1b9d2018-09-26 11:39:24 -050042
43
44Suite Setup Suite Setup Execution
Michael Walshc108e422019-03-28 12:27:18 -050045Test Setup Printn
Michael Walsh98d56d12018-09-19 16:05:00 -050046
47*** Variables ***
48
Steven Sombar15d1b9d2018-09-26 11:39:24 -050049${min_number_items} ${30}
50${min_number_sensors} ${15}
Steven Sombarbd049cb2018-10-07 20:40:39 -050051${LOGGING_HOST} 10.10.10.10
52${LOGGING_PORT} 514
Steven Sombar15d1b9d2018-09-26 11:39:24 -050053
Michael Walsh98d56d12018-09-19 16:05:00 -050054
Steven Sombarba09f582018-12-10 12:23:25 -060055
Michael Walsh98d56d12018-09-19 16:05:00 -050056*** Test Cases ***
57
Steven Sombar15d1b9d2018-09-26 11:39:24 -050058Verify Openbmctool FRU Commands
59 [Documentation] Verify FRU commands work.
60 [Tags] Verify_Openbmctool_FRU_Commands
Michael Walsh98d56d12018-09-19 16:05:00 -050061
Steven Sombar15d1b9d2018-09-26 11:39:24 -050062 Verify FRU Status
63 Verify FRU Print
64 Verify FRU List
65 # Verify FRU List With Single FRU
66 # Known issue - openbmctool.py FRU list with single FRU is not working yet.
67 # See https://github.com/openbmc/openbmc-tools/issues/32.
68
69
70Verify Openbmctool Sensors Commands
71 [Documentation] Verify sensors commands work.
72 [Tags] Verify_Openbmctool_Sensors_Commands
73
74 Verify Sensors Print
75 Verify Sensors List
76 # Verify Sensors List With Single Sensor
77 # Known issue - openbmctool.py sensors list with single sensor is
78 # not working yet. See https://github.com/openbmc/openbmc-tools/issues/33.
79
80
81Verify Openbmctool Health Check Commands
82 [Documentation] Verify health check command works.
83 [Tags] Verify_Openbmctool_Health_Check_Commands
84
Steven Sombarbd049cb2018-10-07 20:40:39 -050085 ${health_results}= Get Health Check verify=${1}
86 Rprint Vars health_results
Steven Sombar15d1b9d2018-09-26 11:39:24 -050087
88
89Verify Openbmctool Service Data Commands
90 [Documentation] Verify collect service data command works.
Steven Sombarbd049cb2018-10-07 20:40:39 -050091 [Tags] Verify_Openbmctool_Service_Data_Commands
Steven Sombar15d1b9d2018-09-26 11:39:24 -050092
Steven Sombarbd049cb2018-10-07 20:40:39 -050093 ${service_paths}= Collect Service Data verify=${1}
94 Rprint Vars service_paths
95
96
97Verify Openbmctool Remote Logging Operations
98 [Documentation] Verify logging commands work.
99 [Tags] Verify_Openbmctool_Remote_Logging_Operations
100
101 # Verify Logging View
102 ${remote_logging_view}= Get Remote Logging View verify=${True}
103
104 # Save previous remote logging settings, if any.
105 ${remote_config}= Get Remote Logging Settings
106
107 # Enable remote logging and verify.
108 Verify Logging Parameters ${LOGGING_HOST} ${LOGGING_PORT}
109
110 # Disable remote logging and verify. Disable will clear any
111 # previous settings.
112 Verify Logging Disable ${LOGGING_HOST}
113
114 # Set original parameters back, if any.
115 Run Keyword If ${remote_config}
116 ... Verify Logging Parameters
117 ... ${remote_config['Address']} ${remote_config['Port']}
Steven Sombar15d1b9d2018-09-26 11:39:24 -0500118
119
Steven Sombarba09f582018-12-10 12:23:25 -0600120Verify Openbmctool Local Users Queryenabled
121 [Documentation] Verify "local_users queryenabled" function.
122 [Tags] Verify_Openbmctool_Local_Users_Queryenabled
123
124 # Example output from "queryenabled":
125 # User: root Enabled: 1
126 # User: freddy Enabled: 1
127 # User: ldap4 Enabled: {'description': "The ..."
128
129 ${rc} ${num_users}= Openbmctool Execute Command
130 ... local_users queryenabled | grep -c 'User.*Enabled'
131 Rprint Vars num_users
132 Check Greater Than Minimum ${num_users} ${0} local users
133
134
Steven Sombar15d1b9d2018-09-26 11:39:24 -0500135*** Keywords ***
136
137
138Verify FRU Status
139 [Documentation] Verify that the 'fru status' command works.
140
141 ${fru_status}= Get Fru Status
142 ${num_frus}= Get Length ${fru_status}
143 Rprint Vars num_frus
144 Check Greater Than Minimum ${num_frus} ${min_number_items} frus
145
146
147Verify FRU Print
148 [Documentation] Verify that the 'fru print' command works.
149
150 ${rc} ${num_frus}= Openbmctool Execute Command
151 ... fru print | wc -l
152 Rprint Vars num_frus
153 Check Greater Than Minimum ${num_frus} ${min_number_items} frus
154
155
156Verify FRU List
157 [Documentation] Verify that the 'fru list' command works.
158
159 # Note: The output from 'fru list' is the same as 'fru print'.
160 ${rc} ${num_frus}= Openbmctool Execute Command
161 ... fru list | wc -l
162 Rprint Vars num_frus
163 Check Greater Than Minimum ${num_frus} ${min_number_items} frus
164
165
166Verify FRU List With Single FRU
167 [Documentation] Verify that 'fru list' with parameter works.
168
169 # Get the name of one FRU, in this case the first one listed.
170 ${fru_status}= Get Fru Status
171 ${fruname}= Set Variable ${fru_status[0]['component']}
172 Rprint Vars fruname
173 Should Not Be Empty ${fruname} msg=Could not find a FRU.
George Keishing7c6342b2018-11-02 14:27:13 -0500174 # Get a fru list specifying just the FRU.
Steven Sombar15d1b9d2018-09-26 11:39:24 -0500175 ${rc} ${output}= Openbmctool Execute Command
176 ... fru list ${fruname} | wc -l
177 ${fru_detail}= Convert to Integer ${output}
178 Rprint Vars fru_detail
179 Should Be True ${fru_detail} <= ${min_number_items}
180 ... msg=Too many lines reported for fru status ${fruname}
181 Should Be True ${fru_detail} > ${4}
182 ... msg=Too few lines reported for fru status ${fruname}
183
184
185Verify Sensors Print
186 [Documentation] Verify that sensors print works.
187
188 ${sensor_status}= Get Sensors Print
189 ${num_sensors}= Get Length ${sensor_status}
Michael Walsh98d56d12018-09-19 16:05:00 -0500190 Rprint Vars num_sensors
Steven Sombar15d1b9d2018-09-26 11:39:24 -0500191 Check Greater Than Minimum ${num_sensors} ${min_number_sensors} sensors
192
193
194Verify Sensors List
195 [Documentation] Verify that sensors list works.
196
197 # Note: The output from 'sensors list' is the same as 'sensors print'.
198 ${sensor_status}= Get Sensors List
199 ${num_sensors}= Get Length ${sensor_status}
200 Rprint Vars num_sensors
201 Check Greater Than Minimum ${num_sensors} ${min_number_sensors} sensors
202
203
204Verify Sensors List With Single Sensor
205 [Documentation] Verify that sensors list with parameter works.
206
207 ${sensor}= Set Variable ambient
208 ${rc} ${num_sensors}= Openbmctool Execute Command
209 ... sensors list ${sensor} | wc -l
210 Rprint Vars sensor num_sensors
211 ${num_sensors}= Convert to Integer ${num_sensors}
212 Should Be True ${num_sensors} < ${10}
213 ... msg=Too many lines reported for list sensor ${sensor}
214
215
Steven Sombarbd049cb2018-10-07 20:40:39 -0500216Verify Logging Parameters
217 [Documentation] Verify remote_logging_config.
218 [Arguments] ${log_host} ${log_port}
Steven Sombar15d1b9d2018-09-26 11:39:24 -0500219
Steven Sombarbd049cb2018-10-07 20:40:39 -0500220 # Description of argument(s):
221 # log_host The host name or IP address of remote logging server.
222 # log_port The port number for remote logging on log_host.
223
224 ${rc} ${result}= Openbmctool Execute Command JSON
225 ... logging remote_logging_config -a ${log_host} -p ${log_port}
226 ... print_output=${False} ignore_err=${False}
227
228 ${remote_logging_view}= Get Remote Logging View verify=${True}
229
Michael Walshe7edb222019-08-19 17:39:38 -0500230 Valid Value remote_logging_view['Address'] valid_values=['${log_host}']
231 Valid Value remote_logging_view['Port'] valid_values=[int(${log_port})]
Steven Sombar15d1b9d2018-09-26 11:39:24 -0500232
233
Steven Sombarbd049cb2018-10-07 20:40:39 -0500234Verify Logging Disable
235 [Documentation] Verify remote_logging disable
236 [Arguments] ${log_host}
Steven Sombar15d1b9d2018-09-26 11:39:24 -0500237
Steven Sombarbd049cb2018-10-07 20:40:39 -0500238 # Description of argument(s):
239 # log_host The host name or IP address of remote logging server.
240
241 ${rc} ${result}= Openbmctool Execute Command JSON
242 ... logging remote_logging disable
243
244 ${remote_logging_view}= Get Remote Logging View verify=${True}
Michael Walshe7edb222019-08-19 17:39:38 -0500245 Valid Value remote_logging_view['Address'] valid_values=['']
Steven Sombarbd049cb2018-10-07 20:40:39 -0500246
247
248Get Remote Logging Settings
249 [Documentation] Return the remote config settings as a dictionary
250 ... if active. Otherwise, return ${False}.
251
252 ${remote_config}= Read Properties ${BMC_LOGGING_URI}config/remote
253 Return From Keyword If
254 ... '${remote_config["Address"]}' == '' or '${remote_config["Port"]}' == '0'
255 ... ${False}
256
257 [Return] ${remote_config}
Steven Sombar15d1b9d2018-09-26 11:39:24 -0500258
259
260Check Greater Than Minimum
261 [Documentation] Value should be greater than minimum, otherwise fail.
262 [Arguments] ${value_to_test} ${minimum_value} ${label}
263
264 # Description of argument(s):
265 # value_to_test Value to compare to the minimum.
266 # minimum_value The minimum acceptable value.
267 # label Name to print if failure.
268
269 ${value_to_test}= Convert to Integer ${value_to_test}
270 Should Be True ${value_to_test} > ${minimum_value}
271 ... msg=There should be at least ${minimum_value} ${label}.
272
273
274Suite Setup Execution
275 [Documentation] Verify connectivity to run openbmctool commands.
276
277 # Verify connectivity to the BMC host.
278 ${bmc_version}= Run Keyword And Ignore Error Get BMC Version
279 Run Keyword If '${bmc_version[0]}' == 'FAIL' Fail
280 ... msg=Could not connect to BMC ${OPENBMC_HOST} to get firmware version.
281
282 # Verify can find the openbmctool.
283 ${openbmctool_file_path}= which openbmctool.py
Michael Walshc108e422019-03-28 12:27:18 -0500284 Printn
Steven Sombar15d1b9d2018-09-26 11:39:24 -0500285 Rprint Vars openbmctool_file_path
286
287 # Get the version number from openbmctool.
288 ${openbmctool_version}= Get Openbmctool Version
289
290 Rprint Vars openbmctool_version OPENBMC_HOST bmc_version[1]