blob: 125a3a9f2f85a4e3c9c076af33ff9b23d57542f1 [file] [log] [blame]
George Keishing0fff68a2017-04-27 22:25:49 -05001*** Settings ***
Steven Sombar130a04f2017-07-16 10:02:37 -05002Documentation Keywords for system test.
George Keishing0fff68a2017-04-27 22:25:49 -05003
George Keishing91c852f2017-05-03 02:48:21 -05004Library ../lib/gen_robot_keyword.py
Steven Sombar021cbc42019-03-28 11:49:21 -05005Library ../lib/gen_print.py
George Keishing36efbc02018-12-12 10:18:23 -06006Library ../lib/gen_robot_print.py
Steven Sombar07be3742018-01-11 13:02:40 -06007Resource ../lib/boot_utils.robot
George Keishing91c852f2017-05-03 02:48:21 -05008Resource ../extended/obmc_boot_test_resource.robot
George Keishing0fff68a2017-04-27 22:25:49 -05009Resource ../lib/utils.robot
George Keishing91c852f2017-05-03 02:48:21 -050010Resource ../lib/state_manager.robot
George Keishingcff7aa02017-05-16 08:05:10 -050011Resource ../lib/rest_client.robot
Sandhya Somashekar839a0c22019-01-31 05:05:43 -060012Resource resource.robot
George Keishing4ef29082017-05-13 05:01:23 -050013Library OperatingSystem
14Library DateTime
15
George Keishing0fff68a2017-04-27 22:25:49 -050016*** Variables ***
17
Steven Sombar130a04f2017-07-16 10:02:37 -050018${htx_log_dir_path} ${EXECDIR}${/}logs${/}
George Keishing4ef29082017-05-13 05:01:23 -050019
George Keishing4bbf5202017-05-18 06:55:53 -050020# Error strings to check from dmesg.
Steven Sombar130a04f2017-07-16 10:02:37 -050021${ERROR_REGEX} error|GPU|NVRM|nvidia
George Keishing4bbf5202017-05-18 06:55:53 -050022
23# GPU specific error message from dmesg.
Steven Sombar130a04f2017-07-16 10:02:37 -050024${ERROR_DBE_MSG} (DBE) has been detected on GPU
25
26# Inventory - List of I/O devices to collect for Inventory
27@{I/O} communication disk display generic input multimedia
28... network printer tape
29
30# Inventory Paths of the JSON and YAML files
Steven Sombara2f166c2017-08-02 14:22:45 -050031${json_tmp_file_path} ${EXECDIR}/inventory_temp_file.json
32${yaml_file_path} ${EXECDIR}/inventory_temp_file.yaml
Steven Sombar130a04f2017-07-16 10:02:37 -050033
34
George Keishing4ef29082017-05-13 05:01:23 -050035
George Keishing0fff68a2017-04-27 22:25:49 -050036*** Keywords ***
37
George Keishing0fff68a2017-04-27 22:25:49 -050038Login To OS
39 [Documentation] Login to OS Host.
40 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
41 ... ${os_password}=${OS_PASSWORD}
George Keishingcff7aa02017-05-16 08:05:10 -050042 ... ${alias_name}=os_connection
George Keishing91c852f2017-05-03 02:48:21 -050043 # Description of argument(s):
44 # os_host IP address of the OS Host.
45 # os_username OS Host Login user name.
46 # os_password OS Host Login passwrd.
George Keishingcff7aa02017-05-16 08:05:10 -050047 # alias_name Default OS SSH session connection alias name.
George Keishing0fff68a2017-04-27 22:25:49 -050048
George Keishing91c852f2017-05-03 02:48:21 -050049 Ping Host ${os_host}
George Keishing664a0162017-06-05 12:24:24 -050050 SSHLibrary.Open Connection ${os_host} alias=${alias_name}
Steven Sombar06d59682019-02-18 11:03:42 -060051 SSHLibrary.Login ${os_username} ${os_password}
George Keishing91c852f2017-05-03 02:48:21 -050052
53
George Keishing88366b32017-05-12 13:50:48 -050054Tool Exist
55 [Documentation] Check whether given tool is installed on OS.
56 [Arguments] ${tool_name}
57 # Description of argument(s):
58 # tool_name Tool name whose existence is to be checked.
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -050059
60 ${output} ${stderr} ${rc}= OS Execute Command which ${tool_name}
George Keishing88366b32017-05-12 13:50:48 -050061 Should Contain ${output} ${tool_name}
62 ... msg=Please install ${tool_name} tool.
George Keishing91c852f2017-05-03 02:48:21 -050063
64
65Boot To OS
66 [Documentation] Boot host OS.
67 Run Key OBMC Boot Test \ REST Power On
68
69
70Power Off Host
71 [Documentation] Power off host.
72 Run Key OBMC Boot Test \ REST Power Off
George Keishing0fff68a2017-04-27 22:25:49 -050073
George Keishing6fec3ab2017-05-05 10:45:08 -050074
75File Exist On OS
76 [Documentation] Check if the given file path exist on OS.
77 [Arguments] ${file_path}
78 # Description of argument(s):
79 # file_path Absolute file path.
80
81 Login To OS
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -050082 ${out} ${stderr} ${rc}= OS Execute Command ls ${file_path}
George Keishing6fec3ab2017-05-05 10:45:08 -050083 Log To Console \n File Exist: ${out}
84
George Keishing8740a0c2017-05-13 07:19:16 -050085
86Is HTX Running
Steven Sombar3ecb6892018-03-23 11:41:08 -050087 [Documentation] Return "True" if the HTX is running, "False"
88 ... otherwise.
89
90 # Example usage:
91 # ${status}= Is HTX Running
92 # Run Keyword If '${status}' == 'True' Shutdown HTX Exerciser
93
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -050094 ${status} ${stderr} ${rc}= OS Execute Command
Joy Onyerikwu4dbd4992018-05-03 16:03:17 -050095 ... htxcmdline -getstats ignore_err=1
96 # Get HTX state
97 # (idle, currently running, selected_mdt but not running).
98 ${running}= Set Variable If
99 ... "Currently running" in """${status}""" ${True} ${False}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500100
Steven Sombar3ecb6892018-03-23 11:41:08 -0500101 [Return] ${running}
George Keishing4ef29082017-05-13 05:01:23 -0500102
103
104Write Log Data To File
105 [Documentation] Write log data to the logs directory.
106 [Arguments] ${data}= ${log_file_path}=
107 # Description of argument(s):
108 # data String buffer.
109 # log_file_path The log file path.
110
111 Create File ${log_file_path} ${data}
112
113
114Collect HTX Log Files
115 [Documentation] Collect status and error log files.
116 # Collects the following files:
117 # HTX error log file /tmp/htxerr
118 # HTX status log file /tmp/htxstats
119
120 # Create logs directory and get current datetime.
121 Create Directory ${htx_log_dir_path}
122 ${cur_datetime}= Get Current Date result_format=%Y%m%d%H%M%S%f
123
124 File Exist On OS /tmp/htxerr
Joy Onyerikwub9922612018-05-14 12:36:57 -0500125 ${htx_err} ${std_err} ${rc}= OS Execute Command cat /tmp/htxerr
George Keishing4ef29082017-05-13 05:01:23 -0500126 Write Log Data To File
127 ... ${htx_err} ${htx_log_dir_path}/${OS_HOST}${cur_datetime}.htxerr
128
129 File Exist On OS /tmp/htxstats
Joy Onyerikwub9922612018-05-14 12:36:57 -0500130 ${htx_stats} ${std_err} ${rc}= OS Execute Command
131 ... cat /tmp/htxstats
George Keishing4ef29082017-05-13 05:01:23 -0500132 Write Log Data To File
133 ... ${htx_stats} ${htx_log_dir_path}/${OS_HOST}_${cur_datetime}.htxstats
134
George Keishingcff7aa02017-05-16 08:05:10 -0500135
136REST Upload File To BMC
137 [Documentation] Upload a file via REST to BMC.
138
139 # Generate 32 MB file size
140 Run dd if=/dev/zero of=dummyfile bs=1 count=0 seek=32MB
141 OperatingSystem.File Should Exist dummyfile
142
143 # Get the content of the file and upload to BMC
144 ${image_data}= OperatingSystem.Get Binary File dummyfile
145
146 # Get REST session to BMC
147 Initialize OpenBMC
148
149 # Create the REST payload headers and data
150 ${data}= Create Dictionary data ${image_data}
151 ${headers}= Create Dictionary Content-Type=application/octet-stream
152 ... Accept=application/octet-stream
153 Set To Dictionary ${data} headers ${headers}
154
155 ${resp}= Post Request openbmc /upload/image &{data}
George Keishing1c1bf1a2018-11-16 05:20:48 -0600156 Should Be Equal As Strings ${resp.status_code} ${HTTP_BAD_REQUEST}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500157 ... msg=Openbmc /upload/image failed.
George Keishingcff7aa02017-05-16 08:05:10 -0500158
George Keishingcff7aa02017-05-16 08:05:10 -0500159 # Take SSH connection to BMC and switch to BMC connection to perform
160 # the task.
161 &{bmc_connection_args}= Create Dictionary alias=bmc_connection
162 Open Connection And Log In &{bmc_connection_args}
163
164 # Currently OS SSH session is active, switch to BMC connection.
165 Switch Connection bmc_connection
George Keishingcff7aa02017-05-16 08:05:10 -0500166
167 # Switch back to OS SSH connection.
168 Switch Connection os_connection
169
George Keishing4bbf5202017-05-18 06:55:53 -0500170
Steven Sombar1dc6fa72018-01-12 10:58:20 -0600171Get CPU Min Frequency Limit
172 [Documentation] Get CPU minimum assignable frequency.
173
174 # lscpu | grep min returns
175 # CPU min MHz: 1983.0000
176
177 ${cmd}= Catenate lscpu | grep min | tr -dc '0-9.\n'
178 ${cpu_freq} ${stderr} ${rc}= OS Execute Command ${cmd}
179 [Return] ${cpu_freq}
180
181
182Get CPU Min Frequency
183 [Documentation] Get CPU assigned minimum frequency.
184
185 # ppc64_cpu --frequency -t 10 returns
186 # min: 3.295 GHz (cpu 143)
187 # max: 3.295 GHz (cpu 0)
188 # avg: 3.295 GHz
189
190 ${cmd}= Catenate ppc64_cpu --frequency -t 10 | grep min
191 ... | cut -f 2 | cut -d ' ' -f 1 | tr -dc '0-9\n'
192 ${cpu_freq} ${stderr} ${rc}= OS Execute Command ${cmd}
193 [Return] ${cpu_freq}
194
195
196Get CPU Max Frequency Limit
197 [Documentation] Get CPU maximum assignable frequency.
198
199 # lscpu | grep max returns
200 # CPU max MHz: 3300.0000
201
202 ${cmd}= Catenate lscpu | grep max | tr -dc '0-9.\n'
203 ${cpu_freq} ${stderr} ${rc}= OS Execute Command ${cmd}
204 [Return] ${cpu_freq}
205
206
207Get CPU Max Frequency
208 [Documentation] Get CPU assigned maximum frequency.
209
210 # ppc64_cpu --frequency -t 10 returns
211 # min: 3.295 GHz (cpu 143)
212 # max: 3.295 GHz (cpu 0)
213 # avg: 3.295 GHz
214
215 ${cmd}= Catenate ppc64_cpu --frequency -t 10 | grep max
216 ... | cut -f 2 | cut -d ' ' -f 1 | tr -dc '0-9\n'
217 ${cpu_freq} ${stderr} ${rc}= OS Execute Command ${cmd}
218 [Return] ${cpu_freq}
219
220
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500221Get CPU Max Temperature
222 [Documentation] Get the highest CPU Temperature.
223
224 ${temperature_objs}= Read Properties
225 ... ${SENSORS_URI}temperature/enumerate
226 # Filter the dictionary to get just the CPU temperature info.
George Keishing36efbc02018-12-12 10:18:23 -0600227 ${cmd}= Catenate {k:v for k,v in $temperature_objs.items()
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500228 ... if re.match('${SENSORS_URI}temperature/p.*core.*temp', k)}
229 ${cpu_temperatuture_objs} Evaluate ${cmd} modules=re
230 # Create a list of the CPU temperature values (current).
231 ${cpu_temperatures}= Evaluate
232 ... [ x['Value'] for x in $cpu_temperatuture_objs.values() ]
233
George Keishing36efbc02018-12-12 10:18:23 -0600234 ${cpu_max_temp} Evaluate int(max(map(int, $cpu_temperatures))/1000)
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500235 [Return] ${cpu_max_temp}
236
237
238Get CPU Min Temperature
239 [Documentation] Get the CPU Temperature.
240
241 ${temperature_objs}= Read Properties
242 ... ${SENSORS_URI}temperature/enumerate
243 # Filter the dictionary to get just the CPU temperature info.
George Keishing36efbc02018-12-12 10:18:23 -0600244 ${cmd}= Catenate {k:v for k,v in $temperature_objs.items()
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500245 ... if re.match('${SENSORS_URI}temperature/p.*core.*temp', k)}
246 ${cpu_temperatuture_objs}= Evaluate ${cmd} modules=re
247 # Create a list of the CPU temperature values (current).
248 ${cpu_temperatures}= Evaluate
249 ... [ x['Value'] for x in $cpu_temperatuture_objs.values() ]
250
George Keishing36efbc02018-12-12 10:18:23 -0600251 ${cpu_min_temp} Evaluate int(min(map(int, $cpu_temperatures))/1000)
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500252 [Return] ${cpu_min_temp}
253
254
George Keishing4bbf5202017-05-18 06:55:53 -0500255Check For Errors On OS Dmesg Log
256 [Documentation] Check if dmesg has nvidia errors logged.
257
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500258 ${dmesg_log} ${stderr} ${rc}= OS Execute Command
259 ... dmesg | egrep '${ERROR_REGEX}'
George Keishing4bbf5202017-05-18 06:55:53 -0500260 # To enable multiple string check.
Steven Sombar0278b132018-01-09 14:41:32 -0600261 Should Not Contain ${dmesg_log} ${ERROR_DBE_MSG}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500262 ... msg=OS dmesg shows ${ERROR_DBE_MSG}.
George Keishing4bbf5202017-05-18 06:55:53 -0500263
264
265Collect NVIDIA Log File
266 [Documentation] Collect ndivia-smi command output.
George Keishing664a0162017-06-05 12:24:24 -0500267 [Arguments] ${suffix}
268 # Description of argument(s):
269 # suffix String name to append.
George Keishing4bbf5202017-05-18 06:55:53 -0500270
271 # Collects the output of ndivia-smi cmd output.
Steven Sombare27cca92018-02-28 10:56:38 -0600272 # +--------------------------------------------------------------------+
273 # | NVIDIA-SMI 361.89 Driver Version: 361.89 |
274 # |-------------------------------+----------------------+-------------+
275 # | GPU Name Persistence-M| Bus-Id Disp.A | GPU ECC |
276 # | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | Utiliz err |
277 # |===============================+======================+=============|
278 # | 0 Tesla P100-SXM2... On | 0002:01:00.0 Off | 0 |
279 # | N/A 25C P0 35W / 300W | 931MiB / 16280MiB | 0% Default |
280 # +-------------------------------+----------------------+-------------+
281 # | 1 Tesla P100-SXM2... On | 0003:01:00.0 Off | 0 |
282 # | N/A 26C P0 40W / 300W | 1477MiB / 16280MiB | 0% Default |
283 # +-------------------------------+----------------------+-------------+
284 # | 2 Tesla P100-SXM2... On | 0006:01:00.0 Off | 0 |
285 # | N/A 25C P0 35W / 300W | 931MiB / 16280MiB | 0% Default |
286 # +-------------------------------+----------------------+-------------+
287 # | 3 Tesla P100-SXM2... On | 0007:01:00.0 Off | 0 |
288 # | N/A 44C P0 290W / 300W | 965MiB / 16280MiB | 0% Default |
289 # +-------------------------------+----------------------+-------------+
290 # +--------------------------------------------------------------------+
291 # | Processes: GPU Memory |
292 # | GPU PID Type Process name Usage |
293 # |====================================================================|
294 # | 0 28459 C hxenvidia 929MiB |
295 # | 1 28460 C hxenvidia 1475MiB |
296 # | 2 28461 C hxenvidia 929MiB |
297 # | 3 28462 C hxenvidia 963MiB |
298 # +--------------------------------------------------------------------+
George Keishing4bbf5202017-05-18 06:55:53 -0500299
300 # Create logs directory and get current datetime.
301 Create Directory ${htx_log_dir_path}
302 ${cur_datetime}= Get Current Date result_format=%Y%m%d%H%M%S%f
303
Steven Sombar0278b132018-01-09 14:41:32 -0600304 ${nvidia_out} ${stderr} ${rc}= OS Execute Command nvidia-smi
George Keishing4bbf5202017-05-18 06:55:53 -0500305 Write Log Data To File
George Keishing664a0162017-06-05 12:24:24 -0500306 ... ${nvidia_out}
307 ... ${htx_log_dir_path}/${OS_HOST}_${cur_datetime}.nvidia_${suffix}
George Keishingbbfec9e2017-05-17 10:47:21 -0500308
309
Steven Sombar0278b132018-01-09 14:41:32 -0600310Get GPU Power Limit
311 [Documentation] Get NVIDIA GPU maximum permitted power draw.
George Keishingbbfec9e2017-05-17 10:47:21 -0500312
Steven Sombar0278b132018-01-09 14:41:32 -0600313 # nvidia-smi --query-gpu=power.limit --format=csv returns
314 # power.limit [W]
315 # 300.00 W
316 # 300.00 W
317 # 300.00 W
318 # 300.00 W
George Keishingbbfec9e2017-05-17 10:47:21 -0500319
Steven Sombar0278b132018-01-09 14:41:32 -0600320 ${cmd}= Catenate nvidia-smi --query-gpu=power.limit
321 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
322 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
323 # Allow for sensor overshoot. That is, max power reported for
324 # a GPU could be a few watts above the limit.
325 ${power_max}= Evaluate ${nvidia_out}+${7.00}
326 [Return] ${power_max}
327
328
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500329Get GPU Max Power
330 [Documentation] Get the maximum GPU power dissipation.
Steven Sombar0278b132018-01-09 14:41:32 -0600331
332 # nvidia-smi --query-gpu=power.draw --format=csv returns
333 # power.draw [W]
334 # 34.12 W
335 # 34.40 W
336 # 36.55 W
337 # 36.05 W
338
339 ${cmd}= Catenate nvidia-smi --query-gpu=power.draw
340 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
341 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
342 [Return] ${nvidia_out}
343
344
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500345Get GPU Min Power
346 [Documentation] Return the minimum GPU power value as record by
347 ... nvidia-smi.
348
349 ${cmd}= Catenate nvidia-smi --query-gpu=power.draw --format=csv |
350 ... grep -v 'power.draw' | cut -f 1 -d ' ' | sort -n -u | head -1
351 ${gpu_min_power} ${stderr} ${rc}= OS Execute Command ${cmd}
352 [Return] ${gpu_min_power}
353
354
Steven Sombar0278b132018-01-09 14:41:32 -0600355Get GPU Temperature Limit
356 [Documentation] Get NVIDIA GPU maximum permitted temperature.
357
358 # nvidia-smi -q -d TEMPERATURE | grep "GPU Max" returns
359 # GPU Max Operating Temp : 83 C
360 # GPU Max Operating Temp : 83 C
361 # GPU Max Operating Temp : 83 C
362 # GPU Max Operating Temp : 83 C
363
364 ${cmd}= Catenate nvidia-smi -q -d TEMPERATURE | grep "GPU Max"
365 ... | cut -f 2 -d ":" | tr -dc '0-9\n' | sort -n -u | tail -n 1
366 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
367 [Return] ${nvidia_out}
368
369
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500370Get GPU Min Temperature
371 [Documentation] Get the minimum GPU temperature.
372
373 ${cmd}= Catenate nvidia-smi --query-gpu=temperature.gpu
374 ... --format=csv | grep -v 'temperature.gpu' | sort -n -u | head -1
375 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
376 [Return] ${nvidia_out}
377
378
379Get GPU Max Temperature
380 [Documentation] Get the maximum GPU temperature.
Steven Sombar0278b132018-01-09 14:41:32 -0600381
382 # nvidia-smi --query-gpu=temperature.gpu --format=csv returns
383 # 38
384 # 41
385 # 38
386 # 40
387
388 ${cmd}= Catenate nvidia-smi --query-gpu=temperature.gpu
389 ... --format=csv | sort -n -u | tail -n 1
390 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
391 [Return] ${nvidia_out}
392
393
Steven Sombarc02dde82018-05-01 09:49:14 -0500394Get GPU Temperature Via REST
395 [Documentation] Return the temperature in degrees C of the warmest GPU
396 ... as reportd by REST.
397
398 # NOTE: This endpoint path is not defined until system has been powered-on.
399 ${temperature_objs}= Read Properties ${SENSORS_URI}temperature/enumerate
400 ... timeout=30 quiet=1
401
George Keishing36efbc02018-12-12 10:18:23 -0600402 ${core_temperatures_list}= Catenate {k:v for k,v in $temperature_objs.items()
Steven Sombarc02dde82018-05-01 09:49:14 -0500403 ... if re.match('${SENSORS_URI}temperature/.*_core_temp', k)}
404 ${gpu_temperature_objs_dict}= Evaluate ${core_temperatures_list} modules=re
405
406 # Create a list containing all of the GPU temperatures.
407 ${gpu_temperatures}= Evaluate
408 ... [ x['Value'] for x in $gpu_temperature_objs_dict.values() ]
409
410 # Find the max temperature value and divide by 1000 to get just the integer
411 # portion.
George Keishing36efbc02018-12-12 10:18:23 -0600412 ${max_gpu_temperature}= Evaluate
413 ... int(max(map(int, $gpu_temperatures))/1000)
Steven Sombarc02dde82018-05-01 09:49:14 -0500414
415 [Return] ${max_gpu_temperature}
416
417
Steven Sombar0278b132018-01-09 14:41:32 -0600418Get GPU Clock Limit
419 [Documentation] Get NVIDIA GPU maximum permitted graphics clock.
420
421 # nvidia-smi --query-gpu=clocks.max.gr --format=csv returns
422 # 1530 MHz
423 # 1530 MHz
424 # 1530 MHz
425 # 1530 MHz
426
427 ${cmd}= Catenate nvidia-smi --query-gpu=clocks.max.gr
428 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
429 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
430 [Return] ${nvidia_out}
431
432
433Get GPU Clock
434 [Documentation] Get the highest assigned value of the GPU graphics clock.
435
436 # nvidia-smi --query-gpu=clocks.gr --format=csv returns
437 # 1230 MHz
438 # 1230 MHz
439 # 135 MHz
440 # 150 MHz
441
442 ${cmd}= Catenate nvidia-smi --query-gpu=clocks.gr
443 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
444 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
445 [Return] ${nvidia_out}
446
447
448Count GPUs From BMC
449 [Documentation] Determine number of GPUs from the BMC. Hostboot
450 ... needs to have been run previously because the BMC gets GPU data
451 ... from Hostboot.
452
453 # Example of gv* endpoint data:
454 # "/xyz/openbmc_project/inventory/system/chassis/motherboard/gv100card0": {
455 # "Functional": 1,
456 # "Present": 1,
457 # "PrettyName": ""
458 # },
459
460 ${num_bmc_gpus}= Set Variable ${0}
461
462 ${gpu_list}= Get Endpoint Paths
463 ... ${HOST_INVENTORY_URI}system/chassis/motherboard gv*
464
465 :FOR ${gpu_uri} IN @{gpu_list}
466 \ ${present}= Read Attribute ${gpu_uri} Present
467 \ ${state}= Read Attribute ${gpu_uri} Functional
468 \ Rpvars gpu_uri present state
469 \ ${num_bmc_gpus}= Run Keyword If ${present} and ${state}
470 ... Evaluate ${num_bmc_gpus}+${1}
471 [Return] ${num_bmc_gpus}
George Keishingbbfec9e2017-05-17 10:47:21 -0500472
473
474Create Default MDT Profile
475 [Documentation] Create default mdt.bu profile and run.
476
Steven Sombar021cbc42019-03-28 11:49:21 -0500477 Print Timen Create HTX mdt profile.
George Keishingbbfec9e2017-05-17 10:47:21 -0500478
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500479 ${profile} ${stderr} ${rc}= OS Execute Command
480 ... htxcmdline -createmdt
Steven Sombar021cbc42019-03-28 11:49:21 -0500481 Printn ${profile}
George Keishingbbfec9e2017-05-17 10:47:21 -0500482 Should Contain ${profile} mdts are created successfully
Steven Sombar3ecb6892018-03-23 11:41:08 -0500483 ... msg=Create MDT profile failed. response=${profile}
George Keishingbbfec9e2017-05-17 10:47:21 -0500484
485
486Run MDT Profile
487 [Documentation] Load user pre-defined MDT profile.
Daniel Gonzalezbfd8aff2018-03-27 10:20:37 -0600488 [Arguments] ${HTX_MDT_PROFILE}=${HTX_MDT_PROFILE}
489 # Description of argument(s):
490 # HTX_MDT_PROFILE MDT profile to be executed (e.g. "mdt.bu").
George Keishingbbfec9e2017-05-17 10:47:21 -0500491
Steven Sombar021cbc42019-03-28 11:49:21 -0500492 Print Timen Start HTX mdt profile execution.
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500493 ${htx_run} ${stderr} ${rc}= OS Execute Command
George Keishingbbfec9e2017-05-17 10:47:21 -0500494 ... htxcmdline -run -mdt ${HTX_MDT_PROFILE}
Steven Sombar021cbc42019-03-28 11:49:21 -0500495 Printn ${htx_run}
George Keishingbbfec9e2017-05-17 10:47:21 -0500496 Should Contain ${htx_run} Activated
Steven Sombar3ecb6892018-03-23 11:41:08 -0500497 ... msg=htxcmdline run mdt did not return "Activated" status.
George Keishingbbfec9e2017-05-17 10:47:21 -0500498
499
500Check HTX Run Status
501 [Documentation] Get HTX exerciser status and check for error.
Steven Sombar9d5fc2d2018-04-30 09:09:13 -0500502 [Arguments] ${sleep_time}=${0}
Joy Onyerikwua8074172018-04-20 07:08:19 -0500503
504 # Description of argument(s):
Steven Sombar56845272018-07-18 14:32:01 -0500505 # sleep_time The amount of time to sleep after checking status,
506 # for example "3s" or "2m".
George Keishingbbfec9e2017-05-17 10:47:21 -0500507
Steven Sombar021cbc42019-03-28 11:49:21 -0500508 Print Timen Check HTX mdt Status and error.
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500509 ${htx_status} ${stderr} ${rc}= OS Execute Command
George Keishingbbfec9e2017-05-17 10:47:21 -0500510 ... htxcmdline -status -mdt ${HTX_MDT_PROFILE}
Steven Sombar021cbc42019-03-28 11:49:21 -0500511 Printn ${htx_status}
George Keishingbbfec9e2017-05-17 10:47:21 -0500512
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500513 ${htx_errlog} ${stderr} ${rc}= OS Execute Command
514 ... htxcmdline -geterrlog
Steven Sombar021cbc42019-03-28 11:49:21 -0500515 Printn ${htx_errlog}
George Keishingbbfec9e2017-05-17 10:47:21 -0500516
Steven Sombar3ecb6892018-03-23 11:41:08 -0500517 Should Contain ${htx_errlog} file </tmp/htxerr> is empty
518 ... msg=HTX geterrorlog was not empty.
George Keishingbbfec9e2017-05-17 10:47:21 -0500519
Steven Sombar56845272018-07-18 14:32:01 -0500520 Return From Keyword If "${sleep_time}" == "${0}"
Joy Onyerikwua8074172018-04-20 07:08:19 -0500521
Steven Sombar56845272018-07-18 14:32:01 -0500522 Run Key U Sleep \ ${sleep_time}
Joy Onyerikwua8074172018-04-20 07:08:19 -0500523
George Keishingbbfec9e2017-05-17 10:47:21 -0500524
525Shutdown HTX Exerciser
526 [Documentation] Shut down HTX exerciser run.
527
Steven Sombar021cbc42019-03-28 11:49:21 -0500528 Print Timen Shutdown HTX Run
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500529 ${shutdown} ${stderr} ${rc}= OS Execute Command
George Keishingbbfec9e2017-05-17 10:47:21 -0500530 ... htxcmdline -shutdown -mdt ${HTX_MDT_PROFILE}
Steven Sombare27cca92018-02-28 10:56:38 -0600531
Steven Sombar021cbc42019-03-28 11:49:21 -0500532 Printn ${shutdown}
533
534 ${down1}= Evaluate 'shutdown successfully' in $shutdown
535 Return From Keyword If '${down1}' == 'True'
536 ${down2}= Evaluate 'No MDT is currently running' in $shutdown
537 Return From Keyword If '${down2}' == 'True'
538 Fail msg=Shutdown returned unexpected message.
Steven Sombare27cca92018-02-28 10:56:38 -0600539
George Keishingbbfec9e2017-05-17 10:47:21 -0500540
Steven Sombar130a04f2017-07-16 10:02:37 -0500541Create JSON Inventory File
542 [Documentation] Create a JSON inventory file, and make a YAML copy.
543 [Arguments] ${json_file_path}
544 # Description of argument:
545 # json_file_path Where the inventory file is wrtten to.
546
547 Login To OS
548 Compile Inventory JSON
549 Run json2yaml ${json_tmp_file_path} ${yaml_file_path}
550 # Format to JSON pretty print to file.
551 Run python -m json.tool ${json_tmp_file_path} > ${json_file_path}
552 OperatingSystem.File Should Exist ${json_file_path}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500553 ... msg=File ${json_file_path} does not exist.
Steven Sombar130a04f2017-07-16 10:02:37 -0500554
555
556Compile Inventory JSON
557 [Documentation] Compile the Inventory into a JSON file.
558 Create File ${json_tmp_file_path}
559 Write New JSON List ${json_tmp_file_path} Inventory
560 Retrieve HW Info And Write processor ${json_tmp_file_path}
561 Retrieve HW Info And Write memory ${json_tmp_file_path}
562 Retrieve HW Info And Write List ${I/O} ${json_tmp_file_path} I/O last
563 Close New JSON List ${json_tmp_file_path}
564
Steven Sombar3ecb6892018-03-23 11:41:08 -0500565
Steven Sombar130a04f2017-07-16 10:02:37 -0500566Write New JSON List
567 [Documentation] Start a new JSON list element in file.
568 [Arguments] ${json_tmp_file_path} ${json_field_name}
569 # Description of argument(s):
570 # json_tmp_file_path Name of file to write to.
571 # json_field_name Name to give json list element.
572 Append to File ${json_tmp_file_path} { "${json_field_name}" : [
573
Steven Sombar3ecb6892018-03-23 11:41:08 -0500574
Steven Sombar130a04f2017-07-16 10:02:37 -0500575Close New JSON List
576 [Documentation] Close JSON list element in file.
577 [Arguments] ${json_tmp_file_path}
578 # Description of argument(s):
579 # json_tmp_file_path Path of file to write to.
580 Append to File ${json_tmp_file_path} ]}
581
Steven Sombar3ecb6892018-03-23 11:41:08 -0500582
Steven Sombar130a04f2017-07-16 10:02:37 -0500583Retrieve HW Info And Write
584 [Documentation] Retrieve and write info, add a comma if not last item.
585 [Arguments] ${class} ${json_tmp_file_path} ${last}=false
586 # Description of argument(s):
587 # class Device class to retrieve with lshw.
588 # json_tmp_file_path Path of file to write to.
589 # last Is this the last element in the parent JSON?
590 Write New JSON List ${json_tmp_file_path} ${class}
George Keishingfb218a12018-11-28 11:20:42 -0600591 ${output}= Retrieve Hardware Info ${class}
592 ${output}= Clean Up String ${output}
Steven Sombar130a04f2017-07-16 10:02:37 -0500593 Run Keyword if ${output.__class__ is not type(None)}
594 ... Append To File ${json_tmp_file_path} ${output}
595 Close New JSON List ${json_tmp_file_path}
596 Run Keyword if '${last}' == 'false'
597 ... Append to File ${json_tmp_file_path} ,
598
Steven Sombar3ecb6892018-03-23 11:41:08 -0500599
Steven Sombar130a04f2017-07-16 10:02:37 -0500600Retrieve HW Info And Write List
601 [Documentation] Does a Retrieve/Write with a list of classes and
602 ... encapsulates them into one large JSON element.
603 [Arguments] ${list} ${json_tmp_file_path} ${json_field_name}
604 ... ${last}=false
605 # Description of argument(s):
606 # list The list of devices classes to retrieve with lshw.
607 # json_tmp_file_path Path of file to write to.
608 # json_field_name Name of the JSON element to encapsulate this list.
609 # last Is this the last element in the parent JSON?
610 Write New JSON List ${json_tmp_file_path} ${json_field_name}
611 : FOR ${class} IN @{list}
612 \ ${tail} Get From List ${list} -1
613 \ Run Keyword if '${tail}' == '${class}'
614 \ ... Retrieve HW Info And Write ${class} ${json_tmp_file_path} true
615 \ ... ELSE Retrieve HW Info And Write ${class} ${json_tmp_file_path}
616 Close New JSON List ${json_tmp_file_path}
617 Run Keyword if '${last}' == 'false'
618 ... Append to File ${json_tmp_file_path} ,
619
Steven Sombar3ecb6892018-03-23 11:41:08 -0500620
Steven Sombar130a04f2017-07-16 10:02:37 -0500621Retrieve Hardware Info
622 [Documentation] Retrieves the lshw output of the device class as JSON.
623 [Arguments] ${class}
624 # Description of argument(s):
625 # class Device class to retrieve with lshw.
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500626 ${output} ${stderr} ${rc}= OS Execute Command lshw -c ${class} -json
George Keishingfb218a12018-11-28 11:20:42 -0600627 ${output}= Verify JSON string ${output}
Steven Sombar130a04f2017-07-16 10:02:37 -0500628 [Return] ${output}
629
Steven Sombar3ecb6892018-03-23 11:41:08 -0500630
Steven Sombar130a04f2017-07-16 10:02:37 -0500631Verify JSON String
Gunnar Mills28e403b2017-10-25 16:16:38 -0500632 [Documentation] Ensure the JSON string content is separated by commas.
Steven Sombar130a04f2017-07-16 10:02:37 -0500633 [Arguments] ${unver_string}
634 # Description of argument(s):
635 # unver_string JSON String we will be checking for lshw comma errors.
George Keishingfb218a12018-11-28 11:20:42 -0600636 ${unver_string}= Convert to String ${unver_string}
637 ${ver_string}= Replace String Using Regexp ${unver_string} }\\s*{ },{
Steven Sombar130a04f2017-07-16 10:02:37 -0500638 [Return] ${ver_string}
639
Steven Sombar3ecb6892018-03-23 11:41:08 -0500640
Steven Sombar130a04f2017-07-16 10:02:37 -0500641Clean Up String
642 [Documentation] Remove extra whitespace and trailing commas.
643 [Arguments] ${dirty_string}
644 # Description of argument(s):
645 # dirty_string String that will be space stripped and have comma removed.
George Keishingfb218a12018-11-28 11:20:42 -0600646 ${clean_string}= Strip String ${dirty_string}
647 ${last_char}= Get Substring ${clean_string} -1
648 ${trimmed_string}= Get Substring ${clean_string} 0 -1
649 ${clean_string}= Set Variable If '${last_char}' == ','
Steven Sombar130a04f2017-07-16 10:02:37 -0500650 ... ${trimmed_string} ${clean_string}
651 [Return] ${clean_string}
Joy Onyerikwu4cb8c0a2018-04-11 18:05:13 -0500652
653
654Get OS Network Interface Names
655 [Documentation] Return a list of interface names on the OS.
656
657 ${stdout} ${stderr} ${rc}= OS Execute Command ls /sys/class/net
658 @{interface_names}= Split String ${stdout}
659 [Return] @{interface_names}
Daniel Gonzalezbfd8aff2018-03-27 10:20:37 -0600660
661
662Run Soft Bootme
663 [Documentation] Run a soft bootme for a period of an hour.
664 [Arguments] ${bootme_period}=3
665 # Description of argument(s):
666 # bootme_time Bootme period to be rebooting the system.
667
668 ${output} ${stderr} ${rc}= OS Execute Command
669 ... htxcmdline -bootme on mode:soft period:${bootme_period}
670 Should Contain ${output} bootme on is completed successfully
671
672
673Shutdown Bootme
674 [Documentation] Stop the bootme process.
675
676 ${output} ${stderr} ${rc}= OS Execute Command htxcmdline -bootme off
Steven Sombar56845272018-07-18 14:32:01 -0500677 Should Contain ${output} bootme off is completed successfully