blob: 89a5d5e4fa780559dd0cd26f6e9fbc33382a2a32 [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
George Keishing36efbc02018-12-12 10:18:23 -06005Library ../lib/gen_robot_print.py
Steven Sombar07be3742018-01-11 13:02:40 -06006Resource ../lib/boot_utils.robot
George Keishing91c852f2017-05-03 02:48:21 -05007Resource ../extended/obmc_boot_test_resource.robot
George Keishing0fff68a2017-04-27 22:25:49 -05008Resource ../lib/utils.robot
George Keishing91c852f2017-05-03 02:48:21 -05009Resource ../lib/state_manager.robot
George Keishingcff7aa02017-05-16 08:05:10 -050010Resource ../lib/rest_client.robot
George Keishingbbfec9e2017-05-17 10:47:21 -050011Resource resource.txt
George Keishing4ef29082017-05-13 05:01:23 -050012Library OperatingSystem
13Library DateTime
14
George Keishing0fff68a2017-04-27 22:25:49 -050015*** Variables ***
16
Steven Sombar130a04f2017-07-16 10:02:37 -050017${htx_log_dir_path} ${EXECDIR}${/}logs${/}
George Keishing4ef29082017-05-13 05:01:23 -050018
George Keishing4bbf5202017-05-18 06:55:53 -050019# Error strings to check from dmesg.
Steven Sombar130a04f2017-07-16 10:02:37 -050020${ERROR_REGEX} error|GPU|NVRM|nvidia
George Keishing4bbf5202017-05-18 06:55:53 -050021
22# GPU specific error message from dmesg.
Steven Sombar130a04f2017-07-16 10:02:37 -050023${ERROR_DBE_MSG} (DBE) has been detected on GPU
24
25# Inventory - List of I/O devices to collect for Inventory
26@{I/O} communication disk display generic input multimedia
27... network printer tape
28
29# Inventory Paths of the JSON and YAML files
Steven Sombara2f166c2017-08-02 14:22:45 -050030${json_tmp_file_path} ${EXECDIR}/inventory_temp_file.json
31${yaml_file_path} ${EXECDIR}/inventory_temp_file.yaml
Steven Sombar130a04f2017-07-16 10:02:37 -050032
33
George Keishing4ef29082017-05-13 05:01:23 -050034
George Keishing0fff68a2017-04-27 22:25:49 -050035*** Keywords ***
36
George Keishing0fff68a2017-04-27 22:25:49 -050037Login To OS
38 [Documentation] Login to OS Host.
39 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
40 ... ${os_password}=${OS_PASSWORD}
George Keishingcff7aa02017-05-16 08:05:10 -050041 ... ${alias_name}=os_connection
George Keishing91c852f2017-05-03 02:48:21 -050042 # Description of argument(s):
43 # os_host IP address of the OS Host.
44 # os_username OS Host Login user name.
45 # os_password OS Host Login passwrd.
George Keishingcff7aa02017-05-16 08:05:10 -050046 # alias_name Default OS SSH session connection alias name.
George Keishing0fff68a2017-04-27 22:25:49 -050047
George Keishing91c852f2017-05-03 02:48:21 -050048 Ping Host ${os_host}
George Keishing664a0162017-06-05 12:24:24 -050049 SSHLibrary.Open Connection ${os_host} alias=${alias_name}
George Keishing91c852f2017-05-03 02:48:21 -050050 Login ${os_username} ${os_password}
51
52
George Keishing88366b32017-05-12 13:50:48 -050053Tool Exist
54 [Documentation] Check whether given tool is installed on OS.
55 [Arguments] ${tool_name}
56 # Description of argument(s):
57 # tool_name Tool name whose existence is to be checked.
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -050058
59 ${output} ${stderr} ${rc}= OS Execute Command which ${tool_name}
George Keishing88366b32017-05-12 13:50:48 -050060 Should Contain ${output} ${tool_name}
61 ... msg=Please install ${tool_name} tool.
George Keishing91c852f2017-05-03 02:48:21 -050062
63
64Boot To OS
65 [Documentation] Boot host OS.
66 Run Key OBMC Boot Test \ REST Power On
67
68
69Power Off Host
70 [Documentation] Power off host.
71 Run Key OBMC Boot Test \ REST Power Off
George Keishing0fff68a2017-04-27 22:25:49 -050072
George Keishing6fec3ab2017-05-05 10:45:08 -050073
74File Exist On OS
75 [Documentation] Check if the given file path exist on OS.
76 [Arguments] ${file_path}
77 # Description of argument(s):
78 # file_path Absolute file path.
79
80 Login To OS
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -050081 ${out} ${stderr} ${rc}= OS Execute Command ls ${file_path}
George Keishing6fec3ab2017-05-05 10:45:08 -050082 Log To Console \n File Exist: ${out}
83
George Keishing8740a0c2017-05-13 07:19:16 -050084
85Is HTX Running
Steven Sombar3ecb6892018-03-23 11:41:08 -050086 [Documentation] Return "True" if the HTX is running, "False"
87 ... otherwise.
88
89 # Example usage:
90 # ${status}= Is HTX Running
91 # Run Keyword If '${status}' == 'True' Shutdown HTX Exerciser
92
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -050093 ${status} ${stderr} ${rc}= OS Execute Command
Joy Onyerikwu4dbd4992018-05-03 16:03:17 -050094 ... htxcmdline -getstats ignore_err=1
95 # Get HTX state
96 # (idle, currently running, selected_mdt but not running).
97 ${running}= Set Variable If
98 ... "Currently running" in """${status}""" ${True} ${False}
Steven Sombar3ecb6892018-03-23 11:41:08 -050099
Steven Sombar3ecb6892018-03-23 11:41:08 -0500100 [Return] ${running}
George Keishing4ef29082017-05-13 05:01:23 -0500101
102
103Write Log Data To File
104 [Documentation] Write log data to the logs directory.
105 [Arguments] ${data}= ${log_file_path}=
106 # Description of argument(s):
107 # data String buffer.
108 # log_file_path The log file path.
109
110 Create File ${log_file_path} ${data}
111
112
113Collect HTX Log Files
114 [Documentation] Collect status and error log files.
115 # Collects the following files:
116 # HTX error log file /tmp/htxerr
117 # HTX status log file /tmp/htxstats
118
119 # Create logs directory and get current datetime.
120 Create Directory ${htx_log_dir_path}
121 ${cur_datetime}= Get Current Date result_format=%Y%m%d%H%M%S%f
122
123 File Exist On OS /tmp/htxerr
Joy Onyerikwub9922612018-05-14 12:36:57 -0500124 ${htx_err} ${std_err} ${rc}= OS Execute Command cat /tmp/htxerr
George Keishing4ef29082017-05-13 05:01:23 -0500125 Write Log Data To File
126 ... ${htx_err} ${htx_log_dir_path}/${OS_HOST}${cur_datetime}.htxerr
127
128 File Exist On OS /tmp/htxstats
Joy Onyerikwub9922612018-05-14 12:36:57 -0500129 ${htx_stats} ${std_err} ${rc}= OS Execute Command
130 ... cat /tmp/htxstats
George Keishing4ef29082017-05-13 05:01:23 -0500131 Write Log Data To File
132 ... ${htx_stats} ${htx_log_dir_path}/${OS_HOST}_${cur_datetime}.htxstats
133
George Keishingcff7aa02017-05-16 08:05:10 -0500134
135REST Upload File To BMC
136 [Documentation] Upload a file via REST to BMC.
137
138 # Generate 32 MB file size
139 Run dd if=/dev/zero of=dummyfile bs=1 count=0 seek=32MB
140 OperatingSystem.File Should Exist dummyfile
141
142 # Get the content of the file and upload to BMC
143 ${image_data}= OperatingSystem.Get Binary File dummyfile
144
145 # Get REST session to BMC
146 Initialize OpenBMC
147
148 # Create the REST payload headers and data
149 ${data}= Create Dictionary data ${image_data}
150 ${headers}= Create Dictionary Content-Type=application/octet-stream
151 ... Accept=application/octet-stream
152 Set To Dictionary ${data} headers ${headers}
153
154 ${resp}= Post Request openbmc /upload/image &{data}
George Keishing1c1bf1a2018-11-16 05:20:48 -0600155 Should Be Equal As Strings ${resp.status_code} ${HTTP_BAD_REQUEST}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500156 ... msg=Openbmc /upload/image failed.
George Keishingcff7aa02017-05-16 08:05:10 -0500157
George Keishingcff7aa02017-05-16 08:05:10 -0500158 # Take SSH connection to BMC and switch to BMC connection to perform
159 # the task.
160 &{bmc_connection_args}= Create Dictionary alias=bmc_connection
161 Open Connection And Log In &{bmc_connection_args}
162
163 # Currently OS SSH session is active, switch to BMC connection.
164 Switch Connection bmc_connection
George Keishingcff7aa02017-05-16 08:05:10 -0500165
166 # Switch back to OS SSH connection.
167 Switch Connection os_connection
168
George Keishing4bbf5202017-05-18 06:55:53 -0500169
Steven Sombar1dc6fa72018-01-12 10:58:20 -0600170Get CPU Min Frequency Limit
171 [Documentation] Get CPU minimum assignable frequency.
172
173 # lscpu | grep min returns
174 # CPU min MHz: 1983.0000
175
176 ${cmd}= Catenate lscpu | grep min | tr -dc '0-9.\n'
177 ${cpu_freq} ${stderr} ${rc}= OS Execute Command ${cmd}
178 [Return] ${cpu_freq}
179
180
181Get CPU Min Frequency
182 [Documentation] Get CPU assigned minimum frequency.
183
184 # ppc64_cpu --frequency -t 10 returns
185 # min: 3.295 GHz (cpu 143)
186 # max: 3.295 GHz (cpu 0)
187 # avg: 3.295 GHz
188
189 ${cmd}= Catenate ppc64_cpu --frequency -t 10 | grep min
190 ... | cut -f 2 | cut -d ' ' -f 1 | tr -dc '0-9\n'
191 ${cpu_freq} ${stderr} ${rc}= OS Execute Command ${cmd}
192 [Return] ${cpu_freq}
193
194
195Get CPU Max Frequency Limit
196 [Documentation] Get CPU maximum assignable frequency.
197
198 # lscpu | grep max returns
199 # CPU max MHz: 3300.0000
200
201 ${cmd}= Catenate lscpu | grep max | tr -dc '0-9.\n'
202 ${cpu_freq} ${stderr} ${rc}= OS Execute Command ${cmd}
203 [Return] ${cpu_freq}
204
205
206Get CPU Max Frequency
207 [Documentation] Get CPU assigned maximum frequency.
208
209 # ppc64_cpu --frequency -t 10 returns
210 # min: 3.295 GHz (cpu 143)
211 # max: 3.295 GHz (cpu 0)
212 # avg: 3.295 GHz
213
214 ${cmd}= Catenate ppc64_cpu --frequency -t 10 | grep max
215 ... | cut -f 2 | cut -d ' ' -f 1 | tr -dc '0-9\n'
216 ${cpu_freq} ${stderr} ${rc}= OS Execute Command ${cmd}
217 [Return] ${cpu_freq}
218
219
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500220Get CPU Max Temperature
221 [Documentation] Get the highest CPU Temperature.
222
223 ${temperature_objs}= Read Properties
224 ... ${SENSORS_URI}temperature/enumerate
225 # Filter the dictionary to get just the CPU temperature info.
George Keishing36efbc02018-12-12 10:18:23 -0600226 ${cmd}= Catenate {k:v for k,v in $temperature_objs.items()
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500227 ... if re.match('${SENSORS_URI}temperature/p.*core.*temp', k)}
228 ${cpu_temperatuture_objs} Evaluate ${cmd} modules=re
229 # Create a list of the CPU temperature values (current).
230 ${cpu_temperatures}= Evaluate
231 ... [ x['Value'] for x in $cpu_temperatuture_objs.values() ]
232
George Keishing36efbc02018-12-12 10:18:23 -0600233 ${cpu_max_temp} Evaluate int(max(map(int, $cpu_temperatures))/1000)
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500234 [Return] ${cpu_max_temp}
235
236
237Get CPU Min Temperature
238 [Documentation] Get the CPU Temperature.
239
240 ${temperature_objs}= Read Properties
241 ... ${SENSORS_URI}temperature/enumerate
242 # Filter the dictionary to get just the CPU temperature info.
George Keishing36efbc02018-12-12 10:18:23 -0600243 ${cmd}= Catenate {k:v for k,v in $temperature_objs.items()
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500244 ... if re.match('${SENSORS_URI}temperature/p.*core.*temp', k)}
245 ${cpu_temperatuture_objs}= Evaluate ${cmd} modules=re
246 # Create a list of the CPU temperature values (current).
247 ${cpu_temperatures}= Evaluate
248 ... [ x['Value'] for x in $cpu_temperatuture_objs.values() ]
249
George Keishing36efbc02018-12-12 10:18:23 -0600250 ${cpu_min_temp} Evaluate int(min(map(int, $cpu_temperatures))/1000)
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500251 [Return] ${cpu_min_temp}
252
253
George Keishing4bbf5202017-05-18 06:55:53 -0500254Check For Errors On OS Dmesg Log
255 [Documentation] Check if dmesg has nvidia errors logged.
256
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500257 ${dmesg_log} ${stderr} ${rc}= OS Execute Command
258 ... dmesg | egrep '${ERROR_REGEX}'
George Keishing4bbf5202017-05-18 06:55:53 -0500259 # To enable multiple string check.
Steven Sombar0278b132018-01-09 14:41:32 -0600260 Should Not Contain ${dmesg_log} ${ERROR_DBE_MSG}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500261 ... msg=OS dmesg shows ${ERROR_DBE_MSG}.
George Keishing4bbf5202017-05-18 06:55:53 -0500262
263
264Collect NVIDIA Log File
265 [Documentation] Collect ndivia-smi command output.
George Keishing664a0162017-06-05 12:24:24 -0500266 [Arguments] ${suffix}
267 # Description of argument(s):
268 # suffix String name to append.
George Keishing4bbf5202017-05-18 06:55:53 -0500269
270 # Collects the output of ndivia-smi cmd output.
Steven Sombare27cca92018-02-28 10:56:38 -0600271 # +--------------------------------------------------------------------+
272 # | NVIDIA-SMI 361.89 Driver Version: 361.89 |
273 # |-------------------------------+----------------------+-------------+
274 # | GPU Name Persistence-M| Bus-Id Disp.A | GPU ECC |
275 # | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | Utiliz err |
276 # |===============================+======================+=============|
277 # | 0 Tesla P100-SXM2... On | 0002:01:00.0 Off | 0 |
278 # | N/A 25C P0 35W / 300W | 931MiB / 16280MiB | 0% Default |
279 # +-------------------------------+----------------------+-------------+
280 # | 1 Tesla P100-SXM2... On | 0003:01:00.0 Off | 0 |
281 # | N/A 26C P0 40W / 300W | 1477MiB / 16280MiB | 0% Default |
282 # +-------------------------------+----------------------+-------------+
283 # | 2 Tesla P100-SXM2... On | 0006:01:00.0 Off | 0 |
284 # | N/A 25C P0 35W / 300W | 931MiB / 16280MiB | 0% Default |
285 # +-------------------------------+----------------------+-------------+
286 # | 3 Tesla P100-SXM2... On | 0007:01:00.0 Off | 0 |
287 # | N/A 44C P0 290W / 300W | 965MiB / 16280MiB | 0% Default |
288 # +-------------------------------+----------------------+-------------+
289 # +--------------------------------------------------------------------+
290 # | Processes: GPU Memory |
291 # | GPU PID Type Process name Usage |
292 # |====================================================================|
293 # | 0 28459 C hxenvidia 929MiB |
294 # | 1 28460 C hxenvidia 1475MiB |
295 # | 2 28461 C hxenvidia 929MiB |
296 # | 3 28462 C hxenvidia 963MiB |
297 # +--------------------------------------------------------------------+
George Keishing4bbf5202017-05-18 06:55:53 -0500298
299 # Create logs directory and get current datetime.
300 Create Directory ${htx_log_dir_path}
301 ${cur_datetime}= Get Current Date result_format=%Y%m%d%H%M%S%f
302
Steven Sombar0278b132018-01-09 14:41:32 -0600303 ${nvidia_out} ${stderr} ${rc}= OS Execute Command nvidia-smi
George Keishing4bbf5202017-05-18 06:55:53 -0500304 Write Log Data To File
George Keishing664a0162017-06-05 12:24:24 -0500305 ... ${nvidia_out}
306 ... ${htx_log_dir_path}/${OS_HOST}_${cur_datetime}.nvidia_${suffix}
George Keishingbbfec9e2017-05-17 10:47:21 -0500307
308
Steven Sombar0278b132018-01-09 14:41:32 -0600309Get GPU Power Limit
310 [Documentation] Get NVIDIA GPU maximum permitted power draw.
George Keishingbbfec9e2017-05-17 10:47:21 -0500311
Steven Sombar0278b132018-01-09 14:41:32 -0600312 # nvidia-smi --query-gpu=power.limit --format=csv returns
313 # power.limit [W]
314 # 300.00 W
315 # 300.00 W
316 # 300.00 W
317 # 300.00 W
George Keishingbbfec9e2017-05-17 10:47:21 -0500318
Steven Sombar0278b132018-01-09 14:41:32 -0600319 ${cmd}= Catenate nvidia-smi --query-gpu=power.limit
320 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
321 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
322 # Allow for sensor overshoot. That is, max power reported for
323 # a GPU could be a few watts above the limit.
324 ${power_max}= Evaluate ${nvidia_out}+${7.00}
325 [Return] ${power_max}
326
327
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500328Get GPU Max Power
329 [Documentation] Get the maximum GPU power dissipation.
Steven Sombar0278b132018-01-09 14:41:32 -0600330
331 # nvidia-smi --query-gpu=power.draw --format=csv returns
332 # power.draw [W]
333 # 34.12 W
334 # 34.40 W
335 # 36.55 W
336 # 36.05 W
337
338 ${cmd}= Catenate nvidia-smi --query-gpu=power.draw
339 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
340 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
341 [Return] ${nvidia_out}
342
343
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500344Get GPU Min Power
345 [Documentation] Return the minimum GPU power value as record by
346 ... nvidia-smi.
347
348 ${cmd}= Catenate nvidia-smi --query-gpu=power.draw --format=csv |
349 ... grep -v 'power.draw' | cut -f 1 -d ' ' | sort -n -u | head -1
350 ${gpu_min_power} ${stderr} ${rc}= OS Execute Command ${cmd}
351 [Return] ${gpu_min_power}
352
353
Steven Sombar0278b132018-01-09 14:41:32 -0600354Get GPU Temperature Limit
355 [Documentation] Get NVIDIA GPU maximum permitted temperature.
356
357 # nvidia-smi -q -d TEMPERATURE | grep "GPU Max" returns
358 # GPU Max Operating Temp : 83 C
359 # GPU Max Operating Temp : 83 C
360 # GPU Max Operating Temp : 83 C
361 # GPU Max Operating Temp : 83 C
362
363 ${cmd}= Catenate nvidia-smi -q -d TEMPERATURE | grep "GPU Max"
364 ... | cut -f 2 -d ":" | tr -dc '0-9\n' | sort -n -u | tail -n 1
365 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
366 [Return] ${nvidia_out}
367
368
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500369Get GPU Min Temperature
370 [Documentation] Get the minimum GPU temperature.
371
372 ${cmd}= Catenate nvidia-smi --query-gpu=temperature.gpu
373 ... --format=csv | grep -v 'temperature.gpu' | sort -n -u | head -1
374 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
375 [Return] ${nvidia_out}
376
377
378Get GPU Max Temperature
379 [Documentation] Get the maximum GPU temperature.
Steven Sombar0278b132018-01-09 14:41:32 -0600380
381 # nvidia-smi --query-gpu=temperature.gpu --format=csv returns
382 # 38
383 # 41
384 # 38
385 # 40
386
387 ${cmd}= Catenate nvidia-smi --query-gpu=temperature.gpu
388 ... --format=csv | sort -n -u | tail -n 1
389 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
390 [Return] ${nvidia_out}
391
392
Steven Sombarc02dde82018-05-01 09:49:14 -0500393Get GPU Temperature Via REST
394 [Documentation] Return the temperature in degrees C of the warmest GPU
395 ... as reportd by REST.
396
397 # NOTE: This endpoint path is not defined until system has been powered-on.
398 ${temperature_objs}= Read Properties ${SENSORS_URI}temperature/enumerate
399 ... timeout=30 quiet=1
400
George Keishing36efbc02018-12-12 10:18:23 -0600401 ${core_temperatures_list}= Catenate {k:v for k,v in $temperature_objs.items()
Steven Sombarc02dde82018-05-01 09:49:14 -0500402 ... if re.match('${SENSORS_URI}temperature/.*_core_temp', k)}
403 ${gpu_temperature_objs_dict}= Evaluate ${core_temperatures_list} modules=re
404
405 # Create a list containing all of the GPU temperatures.
406 ${gpu_temperatures}= Evaluate
407 ... [ x['Value'] for x in $gpu_temperature_objs_dict.values() ]
408
409 # Find the max temperature value and divide by 1000 to get just the integer
410 # portion.
George Keishing36efbc02018-12-12 10:18:23 -0600411 ${max_gpu_temperature}= Evaluate
412 ... int(max(map(int, $gpu_temperatures))/1000)
Steven Sombarc02dde82018-05-01 09:49:14 -0500413
414 [Return] ${max_gpu_temperature}
415
416
Steven Sombar0278b132018-01-09 14:41:32 -0600417Get GPU Clock Limit
418 [Documentation] Get NVIDIA GPU maximum permitted graphics clock.
419
420 # nvidia-smi --query-gpu=clocks.max.gr --format=csv returns
421 # 1530 MHz
422 # 1530 MHz
423 # 1530 MHz
424 # 1530 MHz
425
426 ${cmd}= Catenate nvidia-smi --query-gpu=clocks.max.gr
427 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
428 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
429 [Return] ${nvidia_out}
430
431
432Get GPU Clock
433 [Documentation] Get the highest assigned value of the GPU graphics clock.
434
435 # nvidia-smi --query-gpu=clocks.gr --format=csv returns
436 # 1230 MHz
437 # 1230 MHz
438 # 135 MHz
439 # 150 MHz
440
441 ${cmd}= Catenate nvidia-smi --query-gpu=clocks.gr
442 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
443 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
444 [Return] ${nvidia_out}
445
446
447Count GPUs From BMC
448 [Documentation] Determine number of GPUs from the BMC. Hostboot
449 ... needs to have been run previously because the BMC gets GPU data
450 ... from Hostboot.
451
452 # Example of gv* endpoint data:
453 # "/xyz/openbmc_project/inventory/system/chassis/motherboard/gv100card0": {
454 # "Functional": 1,
455 # "Present": 1,
456 # "PrettyName": ""
457 # },
458
459 ${num_bmc_gpus}= Set Variable ${0}
460
461 ${gpu_list}= Get Endpoint Paths
462 ... ${HOST_INVENTORY_URI}system/chassis/motherboard gv*
463
464 :FOR ${gpu_uri} IN @{gpu_list}
465 \ ${present}= Read Attribute ${gpu_uri} Present
466 \ ${state}= Read Attribute ${gpu_uri} Functional
467 \ Rpvars gpu_uri present state
468 \ ${num_bmc_gpus}= Run Keyword If ${present} and ${state}
469 ... Evaluate ${num_bmc_gpus}+${1}
470 [Return] ${num_bmc_gpus}
George Keishingbbfec9e2017-05-17 10:47:21 -0500471
472
473Create Default MDT Profile
474 [Documentation] Create default mdt.bu profile and run.
475
476 Rprint Timen Create HTX mdt profile.
477
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500478 ${profile} ${stderr} ${rc}= OS Execute Command
479 ... htxcmdline -createmdt
George Keishingbbfec9e2017-05-17 10:47:21 -0500480 Rprintn ${profile}
481 Should Contain ${profile} mdts are created successfully
Steven Sombar3ecb6892018-03-23 11:41:08 -0500482 ... msg=Create MDT profile failed. response=${profile}
George Keishingbbfec9e2017-05-17 10:47:21 -0500483
484
485Run MDT Profile
486 [Documentation] Load user pre-defined MDT profile.
Daniel Gonzalezbfd8aff2018-03-27 10:20:37 -0600487 [Arguments] ${HTX_MDT_PROFILE}=${HTX_MDT_PROFILE}
488 # Description of argument(s):
489 # HTX_MDT_PROFILE MDT profile to be executed (e.g. "mdt.bu").
George Keishingbbfec9e2017-05-17 10:47:21 -0500490
491 Rprint Timen Start HTX mdt profile execution.
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500492 ${htx_run} ${stderr} ${rc}= OS Execute Command
George Keishingbbfec9e2017-05-17 10:47:21 -0500493 ... htxcmdline -run -mdt ${HTX_MDT_PROFILE}
494 Rprintn ${htx_run}
495 Should Contain ${htx_run} Activated
Steven Sombar3ecb6892018-03-23 11:41:08 -0500496 ... msg=htxcmdline run mdt did not return "Activated" status.
George Keishingbbfec9e2017-05-17 10:47:21 -0500497
498
499Check HTX Run Status
500 [Documentation] Get HTX exerciser status and check for error.
Steven Sombar9d5fc2d2018-04-30 09:09:13 -0500501 [Arguments] ${sleep_time}=${0}
Joy Onyerikwua8074172018-04-20 07:08:19 -0500502
503 # Description of argument(s):
Steven Sombar56845272018-07-18 14:32:01 -0500504 # sleep_time The amount of time to sleep after checking status,
505 # for example "3s" or "2m".
George Keishingbbfec9e2017-05-17 10:47:21 -0500506
507 Rprint Timen Check HTX mdt Status and error.
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500508 ${htx_status} ${stderr} ${rc}= OS Execute Command
George Keishingbbfec9e2017-05-17 10:47:21 -0500509 ... htxcmdline -status -mdt ${HTX_MDT_PROFILE}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500510 Rprintn ${htx_status}
George Keishingbbfec9e2017-05-17 10:47:21 -0500511
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500512 ${htx_errlog} ${stderr} ${rc}= OS Execute Command
513 ... htxcmdline -geterrlog
Steven Sombar3ecb6892018-03-23 11:41:08 -0500514 Rprintn ${htx_errlog}
George Keishingbbfec9e2017-05-17 10:47:21 -0500515
Steven Sombar3ecb6892018-03-23 11:41:08 -0500516 Should Contain ${htx_errlog} file </tmp/htxerr> is empty
517 ... msg=HTX geterrorlog was not empty.
George Keishingbbfec9e2017-05-17 10:47:21 -0500518
Steven Sombar56845272018-07-18 14:32:01 -0500519 Return From Keyword If "${sleep_time}" == "${0}"
Joy Onyerikwua8074172018-04-20 07:08:19 -0500520
Steven Sombar56845272018-07-18 14:32:01 -0500521 Run Key U Sleep \ ${sleep_time}
Joy Onyerikwua8074172018-04-20 07:08:19 -0500522
George Keishingbbfec9e2017-05-17 10:47:21 -0500523
524Shutdown HTX Exerciser
525 [Documentation] Shut down HTX exerciser run.
526
527 Rprint Timen Shutdown HTX Run
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500528 ${shutdown} ${stderr} ${rc}= OS Execute Command
George Keishingbbfec9e2017-05-17 10:47:21 -0500529 ... htxcmdline -shutdown -mdt ${HTX_MDT_PROFILE}
530 Rprintn ${shutdown}
Steven Sombare27cca92018-02-28 10:56:38 -0600531
532 ${match_count_no_mdt}= Count Values In List ${shutdown}
533 ... No MDT is currently running
534 ${match_count_success}= Count Values In List ${shutdown}
535 ... shutdown successfully
536 Run Keyword If ${match_count_no_mdt} == 0 and ${match_count_success} == 0
537 ... Fail msg=Shutdown command returned unexpected message.
538
George Keishingbbfec9e2017-05-17 10:47:21 -0500539
Steven Sombar130a04f2017-07-16 10:02:37 -0500540Create JSON Inventory File
541 [Documentation] Create a JSON inventory file, and make a YAML copy.
542 [Arguments] ${json_file_path}
543 # Description of argument:
544 # json_file_path Where the inventory file is wrtten to.
545
546 Login To OS
547 Compile Inventory JSON
548 Run json2yaml ${json_tmp_file_path} ${yaml_file_path}
549 # Format to JSON pretty print to file.
550 Run python -m json.tool ${json_tmp_file_path} > ${json_file_path}
551 OperatingSystem.File Should Exist ${json_file_path}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500552 ... msg=File ${json_file_path} does not exist.
Steven Sombar130a04f2017-07-16 10:02:37 -0500553
554
555Compile Inventory JSON
556 [Documentation] Compile the Inventory into a JSON file.
557 Create File ${json_tmp_file_path}
558 Write New JSON List ${json_tmp_file_path} Inventory
559 Retrieve HW Info And Write processor ${json_tmp_file_path}
560 Retrieve HW Info And Write memory ${json_tmp_file_path}
561 Retrieve HW Info And Write List ${I/O} ${json_tmp_file_path} I/O last
562 Close New JSON List ${json_tmp_file_path}
563
Steven Sombar3ecb6892018-03-23 11:41:08 -0500564
Steven Sombar130a04f2017-07-16 10:02:37 -0500565Write New JSON List
566 [Documentation] Start a new JSON list element in file.
567 [Arguments] ${json_tmp_file_path} ${json_field_name}
568 # Description of argument(s):
569 # json_tmp_file_path Name of file to write to.
570 # json_field_name Name to give json list element.
571 Append to File ${json_tmp_file_path} { "${json_field_name}" : [
572
Steven Sombar3ecb6892018-03-23 11:41:08 -0500573
Steven Sombar130a04f2017-07-16 10:02:37 -0500574Close New JSON List
575 [Documentation] Close JSON list element in file.
576 [Arguments] ${json_tmp_file_path}
577 # Description of argument(s):
578 # json_tmp_file_path Path of file to write to.
579 Append to File ${json_tmp_file_path} ]}
580
Steven Sombar3ecb6892018-03-23 11:41:08 -0500581
Steven Sombar130a04f2017-07-16 10:02:37 -0500582Retrieve HW Info And Write
583 [Documentation] Retrieve and write info, add a comma if not last item.
584 [Arguments] ${class} ${json_tmp_file_path} ${last}=false
585 # Description of argument(s):
586 # class Device class to retrieve with lshw.
587 # json_tmp_file_path Path of file to write to.
588 # last Is this the last element in the parent JSON?
589 Write New JSON List ${json_tmp_file_path} ${class}
George Keishingfb218a12018-11-28 11:20:42 -0600590 ${output}= Retrieve Hardware Info ${class}
591 ${output}= Clean Up String ${output}
Steven Sombar130a04f2017-07-16 10:02:37 -0500592 Run Keyword if ${output.__class__ is not type(None)}
593 ... Append To File ${json_tmp_file_path} ${output}
594 Close New JSON List ${json_tmp_file_path}
595 Run Keyword if '${last}' == 'false'
596 ... Append to File ${json_tmp_file_path} ,
597
Steven Sombar3ecb6892018-03-23 11:41:08 -0500598
Steven Sombar130a04f2017-07-16 10:02:37 -0500599Retrieve HW Info And Write List
600 [Documentation] Does a Retrieve/Write with a list of classes and
601 ... encapsulates them into one large JSON element.
602 [Arguments] ${list} ${json_tmp_file_path} ${json_field_name}
603 ... ${last}=false
604 # Description of argument(s):
605 # list The list of devices classes to retrieve with lshw.
606 # json_tmp_file_path Path of file to write to.
607 # json_field_name Name of the JSON element to encapsulate this list.
608 # last Is this the last element in the parent JSON?
609 Write New JSON List ${json_tmp_file_path} ${json_field_name}
610 : FOR ${class} IN @{list}
611 \ ${tail} Get From List ${list} -1
612 \ Run Keyword if '${tail}' == '${class}'
613 \ ... Retrieve HW Info And Write ${class} ${json_tmp_file_path} true
614 \ ... ELSE Retrieve HW Info And Write ${class} ${json_tmp_file_path}
615 Close New JSON List ${json_tmp_file_path}
616 Run Keyword if '${last}' == 'false'
617 ... Append to File ${json_tmp_file_path} ,
618
Steven Sombar3ecb6892018-03-23 11:41:08 -0500619
Steven Sombar130a04f2017-07-16 10:02:37 -0500620Retrieve Hardware Info
621 [Documentation] Retrieves the lshw output of the device class as JSON.
622 [Arguments] ${class}
623 # Description of argument(s):
624 # class Device class to retrieve with lshw.
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500625 ${output} ${stderr} ${rc}= OS Execute Command lshw -c ${class} -json
George Keishingfb218a12018-11-28 11:20:42 -0600626 ${output}= Verify JSON string ${output}
Steven Sombar130a04f2017-07-16 10:02:37 -0500627 [Return] ${output}
628
Steven Sombar3ecb6892018-03-23 11:41:08 -0500629
Steven Sombar130a04f2017-07-16 10:02:37 -0500630Verify JSON String
Gunnar Mills28e403b2017-10-25 16:16:38 -0500631 [Documentation] Ensure the JSON string content is separated by commas.
Steven Sombar130a04f2017-07-16 10:02:37 -0500632 [Arguments] ${unver_string}
633 # Description of argument(s):
634 # unver_string JSON String we will be checking for lshw comma errors.
George Keishingfb218a12018-11-28 11:20:42 -0600635 ${unver_string}= Convert to String ${unver_string}
636 ${ver_string}= Replace String Using Regexp ${unver_string} }\\s*{ },{
Steven Sombar130a04f2017-07-16 10:02:37 -0500637 [Return] ${ver_string}
638
Steven Sombar3ecb6892018-03-23 11:41:08 -0500639
Steven Sombar130a04f2017-07-16 10:02:37 -0500640Clean Up String
641 [Documentation] Remove extra whitespace and trailing commas.
642 [Arguments] ${dirty_string}
643 # Description of argument(s):
644 # dirty_string String that will be space stripped and have comma removed.
George Keishingfb218a12018-11-28 11:20:42 -0600645 ${clean_string}= Strip String ${dirty_string}
646 ${last_char}= Get Substring ${clean_string} -1
647 ${trimmed_string}= Get Substring ${clean_string} 0 -1
648 ${clean_string}= Set Variable If '${last_char}' == ','
Steven Sombar130a04f2017-07-16 10:02:37 -0500649 ... ${trimmed_string} ${clean_string}
650 [Return] ${clean_string}
Joy Onyerikwu4cb8c0a2018-04-11 18:05:13 -0500651
652
653Get OS Network Interface Names
654 [Documentation] Return a list of interface names on the OS.
655
656 ${stdout} ${stderr} ${rc}= OS Execute Command ls /sys/class/net
657 @{interface_names}= Split String ${stdout}
658 [Return] @{interface_names}
Daniel Gonzalezbfd8aff2018-03-27 10:20:37 -0600659
660
661Run Soft Bootme
662 [Documentation] Run a soft bootme for a period of an hour.
663 [Arguments] ${bootme_period}=3
664 # Description of argument(s):
665 # bootme_time Bootme period to be rebooting the system.
666
667 ${output} ${stderr} ${rc}= OS Execute Command
668 ... htxcmdline -bootme on mode:soft period:${bootme_period}
669 Should Contain ${output} bootme on is completed successfully
670
671
672Shutdown Bootme
673 [Documentation] Stop the bootme process.
674
675 ${output} ${stderr} ${rc}= OS Execute Command htxcmdline -bootme off
Steven Sombar56845272018-07-18 14:32:01 -0500676 Should Contain ${output} bootme off is completed successfully