blob: d7061d60491aa4faa9c7c83e39af2344088e939b [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 Sombar07be3742018-01-11 13:02:40 -06005Resource ../lib/boot_utils.robot
George Keishing91c852f2017-05-03 02:48:21 -05006Resource ../extended/obmc_boot_test_resource.robot
George Keishing0fff68a2017-04-27 22:25:49 -05007Resource ../lib/utils.robot
George Keishing91c852f2017-05-03 02:48:21 -05008Resource ../lib/state_manager.robot
George Keishingcff7aa02017-05-16 08:05:10 -05009Resource ../lib/rest_client.robot
George Keishingbbfec9e2017-05-17 10:47:21 -050010Resource resource.txt
George Keishing4ef29082017-05-13 05:01:23 -050011Library OperatingSystem
12Library DateTime
13
George Keishing0fff68a2017-04-27 22:25:49 -050014*** Variables ***
15
Steven Sombar130a04f2017-07-16 10:02:37 -050016${htx_log_dir_path} ${EXECDIR}${/}logs${/}
George Keishing4ef29082017-05-13 05:01:23 -050017
George Keishing4bbf5202017-05-18 06:55:53 -050018# Error strings to check from dmesg.
Steven Sombar130a04f2017-07-16 10:02:37 -050019${ERROR_REGEX} error|GPU|NVRM|nvidia
George Keishing4bbf5202017-05-18 06:55:53 -050020
21# GPU specific error message from dmesg.
Steven Sombar130a04f2017-07-16 10:02:37 -050022${ERROR_DBE_MSG} (DBE) has been detected on GPU
23
24# Inventory - List of I/O devices to collect for Inventory
25@{I/O} communication disk display generic input multimedia
26... network printer tape
27
28# Inventory Paths of the JSON and YAML files
Steven Sombara2f166c2017-08-02 14:22:45 -050029${json_tmp_file_path} ${EXECDIR}/inventory_temp_file.json
30${yaml_file_path} ${EXECDIR}/inventory_temp_file.yaml
Steven Sombar130a04f2017-07-16 10:02:37 -050031
32
George Keishing4ef29082017-05-13 05:01:23 -050033
George Keishing0fff68a2017-04-27 22:25:49 -050034*** Keywords ***
35
36Execute Command On OS
37 [Documentation] Execute given command on OS and return output.
38 [Arguments] ${command}
George Keishing91c852f2017-05-03 02:48:21 -050039 # Description of argument(s):
40 # command Shell command to be executed on OS.
George Keishing0fff68a2017-04-27 22:25:49 -050041 ${stdout} ${stderr}= Execute Command ${command} return_stderr=True
Steven Sombar3ecb6892018-03-23 11:41:08 -050042 Should Be Empty ${stderr} msg=Failed running ${command}. stderr=${stderr}
George Keishing0fff68a2017-04-27 22:25:49 -050043 [Return] ${stdout}
44
Steven Sombar3ecb6892018-03-23 11:41:08 -050045
George Keishing0fff68a2017-04-27 22:25:49 -050046Login To OS
47 [Documentation] Login to OS Host.
48 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
49 ... ${os_password}=${OS_PASSWORD}
George Keishingcff7aa02017-05-16 08:05:10 -050050 ... ${alias_name}=os_connection
George Keishing91c852f2017-05-03 02:48:21 -050051 # Description of argument(s):
52 # os_host IP address of the OS Host.
53 # os_username OS Host Login user name.
54 # os_password OS Host Login passwrd.
George Keishingcff7aa02017-05-16 08:05:10 -050055 # alias_name Default OS SSH session connection alias name.
George Keishing0fff68a2017-04-27 22:25:49 -050056
George Keishing91c852f2017-05-03 02:48:21 -050057 Ping Host ${os_host}
George Keishing664a0162017-06-05 12:24:24 -050058 SSHLibrary.Open Connection ${os_host} alias=${alias_name}
George Keishing91c852f2017-05-03 02:48:21 -050059 Login ${os_username} ${os_password}
60
61
George Keishing88366b32017-05-12 13:50:48 -050062Tool Exist
63 [Documentation] Check whether given tool is installed on OS.
64 [Arguments] ${tool_name}
65 # Description of argument(s):
66 # tool_name Tool name whose existence is to be checked.
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -050067
68 ${output} ${stderr} ${rc}= OS Execute Command which ${tool_name}
George Keishing88366b32017-05-12 13:50:48 -050069 Should Contain ${output} ${tool_name}
70 ... msg=Please install ${tool_name} tool.
George Keishing91c852f2017-05-03 02:48:21 -050071
72
73Boot To OS
74 [Documentation] Boot host OS.
75 Run Key OBMC Boot Test \ REST Power On
76
77
78Power Off Host
79 [Documentation] Power off host.
80 Run Key OBMC Boot Test \ REST Power Off
George Keishing0fff68a2017-04-27 22:25:49 -050081
George Keishing6fec3ab2017-05-05 10:45:08 -050082
83File Exist On OS
84 [Documentation] Check if the given file path exist on OS.
85 [Arguments] ${file_path}
86 # Description of argument(s):
87 # file_path Absolute file path.
88
89 Login To OS
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -050090 ${out} ${stderr} ${rc}= OS Execute Command ls ${file_path}
George Keishing6fec3ab2017-05-05 10:45:08 -050091 Log To Console \n File Exist: ${out}
92
George Keishing8740a0c2017-05-13 07:19:16 -050093
94Is HTX Running
Steven Sombar3ecb6892018-03-23 11:41:08 -050095 [Documentation] Return "True" if the HTX is running, "False"
96 ... otherwise.
97
98 # Example usage:
99 # ${status}= Is HTX Running
100 # Run Keyword If '${status}' == 'True' Shutdown HTX Exerciser
101
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500102 ${status} ${stderr} ${rc}= OS Execute Command
Joy Onyerikwu4dbd4992018-05-03 16:03:17 -0500103 ... htxcmdline -getstats ignore_err=1
104 # Get HTX state
105 # (idle, currently running, selected_mdt but not running).
106 ${running}= Set Variable If
107 ... "Currently running" in """${status}""" ${True} ${False}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500108
Steven Sombar3ecb6892018-03-23 11:41:08 -0500109 [Return] ${running}
George Keishing4ef29082017-05-13 05:01:23 -0500110
111
112Write Log Data To File
113 [Documentation] Write log data to the logs directory.
114 [Arguments] ${data}= ${log_file_path}=
115 # Description of argument(s):
116 # data String buffer.
117 # log_file_path The log file path.
118
119 Create File ${log_file_path} ${data}
120
121
122Collect HTX Log Files
123 [Documentation] Collect status and error log files.
124 # Collects the following files:
125 # HTX error log file /tmp/htxerr
126 # HTX status log file /tmp/htxstats
127
128 # Create logs directory and get current datetime.
129 Create Directory ${htx_log_dir_path}
130 ${cur_datetime}= Get Current Date result_format=%Y%m%d%H%M%S%f
131
132 File Exist On OS /tmp/htxerr
Joy Onyerikwub9922612018-05-14 12:36:57 -0500133 ${htx_err} ${std_err} ${rc}= OS Execute Command cat /tmp/htxerr
George Keishing4ef29082017-05-13 05:01:23 -0500134 Write Log Data To File
135 ... ${htx_err} ${htx_log_dir_path}/${OS_HOST}${cur_datetime}.htxerr
136
137 File Exist On OS /tmp/htxstats
Joy Onyerikwub9922612018-05-14 12:36:57 -0500138 ${htx_stats} ${std_err} ${rc}= OS Execute Command
139 ... cat /tmp/htxstats
George Keishing4ef29082017-05-13 05:01:23 -0500140 Write Log Data To File
141 ... ${htx_stats} ${htx_log_dir_path}/${OS_HOST}_${cur_datetime}.htxstats
142
George Keishingcff7aa02017-05-16 08:05:10 -0500143
144REST Upload File To BMC
145 [Documentation] Upload a file via REST to BMC.
146
147 # Generate 32 MB file size
148 Run dd if=/dev/zero of=dummyfile bs=1 count=0 seek=32MB
149 OperatingSystem.File Should Exist dummyfile
150
151 # Get the content of the file and upload to BMC
152 ${image_data}= OperatingSystem.Get Binary File dummyfile
153
154 # Get REST session to BMC
155 Initialize OpenBMC
156
157 # Create the REST payload headers and data
158 ${data}= Create Dictionary data ${image_data}
159 ${headers}= Create Dictionary Content-Type=application/octet-stream
160 ... Accept=application/octet-stream
161 Set To Dictionary ${data} headers ${headers}
162
163 ${resp}= Post Request openbmc /upload/image &{data}
164 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500165 ... msg=Openbmc /upload/image failed.
George Keishingcff7aa02017-05-16 08:05:10 -0500166
George Keishingcff7aa02017-05-16 08:05:10 -0500167 # Take SSH connection to BMC and switch to BMC connection to perform
168 # the task.
169 &{bmc_connection_args}= Create Dictionary alias=bmc_connection
170 Open Connection And Log In &{bmc_connection_args}
171
172 # Currently OS SSH session is active, switch to BMC connection.
173 Switch Connection bmc_connection
George Keishingcff7aa02017-05-16 08:05:10 -0500174
175 # Switch back to OS SSH connection.
176 Switch Connection os_connection
177
George Keishing4bbf5202017-05-18 06:55:53 -0500178
Steven Sombar1dc6fa72018-01-12 10:58:20 -0600179Get CPU Min Frequency Limit
180 [Documentation] Get CPU minimum assignable frequency.
181
182 # lscpu | grep min returns
183 # CPU min MHz: 1983.0000
184
185 ${cmd}= Catenate lscpu | grep min | tr -dc '0-9.\n'
186 ${cpu_freq} ${stderr} ${rc}= OS Execute Command ${cmd}
187 [Return] ${cpu_freq}
188
189
190Get CPU Min Frequency
191 [Documentation] Get CPU assigned minimum frequency.
192
193 # ppc64_cpu --frequency -t 10 returns
194 # min: 3.295 GHz (cpu 143)
195 # max: 3.295 GHz (cpu 0)
196 # avg: 3.295 GHz
197
198 ${cmd}= Catenate ppc64_cpu --frequency -t 10 | grep min
199 ... | cut -f 2 | cut -d ' ' -f 1 | tr -dc '0-9\n'
200 ${cpu_freq} ${stderr} ${rc}= OS Execute Command ${cmd}
201 [Return] ${cpu_freq}
202
203
204Get CPU Max Frequency Limit
205 [Documentation] Get CPU maximum assignable frequency.
206
207 # lscpu | grep max returns
208 # CPU max MHz: 3300.0000
209
210 ${cmd}= Catenate lscpu | grep max | tr -dc '0-9.\n'
211 ${cpu_freq} ${stderr} ${rc}= OS Execute Command ${cmd}
212 [Return] ${cpu_freq}
213
214
215Get CPU Max Frequency
216 [Documentation] Get CPU assigned maximum frequency.
217
218 # ppc64_cpu --frequency -t 10 returns
219 # min: 3.295 GHz (cpu 143)
220 # max: 3.295 GHz (cpu 0)
221 # avg: 3.295 GHz
222
223 ${cmd}= Catenate ppc64_cpu --frequency -t 10 | grep max
224 ... | cut -f 2 | cut -d ' ' -f 1 | tr -dc '0-9\n'
225 ${cpu_freq} ${stderr} ${rc}= OS Execute Command ${cmd}
226 [Return] ${cpu_freq}
227
228
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500229Get CPU Max Temperature
230 [Documentation] Get the highest CPU Temperature.
231
232 ${temperature_objs}= Read Properties
233 ... ${SENSORS_URI}temperature/enumerate
234 # Filter the dictionary to get just the CPU temperature info.
235 ${cmd}= Catenate {k:v for k,v in $temperature_objs.iteritems()
236 ... if re.match('${SENSORS_URI}temperature/p.*core.*temp', k)}
237 ${cpu_temperatuture_objs} Evaluate ${cmd} modules=re
238 # Create a list of the CPU temperature values (current).
239 ${cpu_temperatures}= Evaluate
240 ... [ x['Value'] for x in $cpu_temperatuture_objs.values() ]
241
242 ${cpu_max_temp} Evaluate max(map(int, $cpu_temperatures))/1000
243 [Return] ${cpu_max_temp}
244
245
246Get CPU Min Temperature
247 [Documentation] Get the CPU Temperature.
248
249 ${temperature_objs}= Read Properties
250 ... ${SENSORS_URI}temperature/enumerate
251 # Filter the dictionary to get just the CPU temperature info.
252 ${cmd}= Catenate {k:v for k,v in $temperature_objs.iteritems()
253 ... if re.match('${SENSORS_URI}temperature/p.*core.*temp', k)}
254 ${cpu_temperatuture_objs}= Evaluate ${cmd} modules=re
255 # Create a list of the CPU temperature values (current).
256 ${cpu_temperatures}= Evaluate
257 ... [ x['Value'] for x in $cpu_temperatuture_objs.values() ]
258
259 ${cpu_min_temp} Evaluate min(map(int, $cpu_temperatures))/1000
260 [Return] ${cpu_min_temp}
261
262
George Keishing4bbf5202017-05-18 06:55:53 -0500263Check For Errors On OS Dmesg Log
264 [Documentation] Check if dmesg has nvidia errors logged.
265
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500266 ${dmesg_log} ${stderr} ${rc}= OS Execute Command
267 ... dmesg | egrep '${ERROR_REGEX}'
George Keishing4bbf5202017-05-18 06:55:53 -0500268 # To enable multiple string check.
Steven Sombar0278b132018-01-09 14:41:32 -0600269 Should Not Contain ${dmesg_log} ${ERROR_DBE_MSG}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500270 ... msg=OS dmesg shows ${ERROR_DBE_MSG}.
George Keishing4bbf5202017-05-18 06:55:53 -0500271
272
273Collect NVIDIA Log File
274 [Documentation] Collect ndivia-smi command output.
George Keishing664a0162017-06-05 12:24:24 -0500275 [Arguments] ${suffix}
276 # Description of argument(s):
277 # suffix String name to append.
George Keishing4bbf5202017-05-18 06:55:53 -0500278
279 # Collects the output of ndivia-smi cmd output.
Steven Sombare27cca92018-02-28 10:56:38 -0600280 # +--------------------------------------------------------------------+
281 # | NVIDIA-SMI 361.89 Driver Version: 361.89 |
282 # |-------------------------------+----------------------+-------------+
283 # | GPU Name Persistence-M| Bus-Id Disp.A | GPU ECC |
284 # | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | Utiliz err |
285 # |===============================+======================+=============|
286 # | 0 Tesla P100-SXM2... On | 0002:01:00.0 Off | 0 |
287 # | N/A 25C P0 35W / 300W | 931MiB / 16280MiB | 0% Default |
288 # +-------------------------------+----------------------+-------------+
289 # | 1 Tesla P100-SXM2... On | 0003:01:00.0 Off | 0 |
290 # | N/A 26C P0 40W / 300W | 1477MiB / 16280MiB | 0% Default |
291 # +-------------------------------+----------------------+-------------+
292 # | 2 Tesla P100-SXM2... On | 0006:01:00.0 Off | 0 |
293 # | N/A 25C P0 35W / 300W | 931MiB / 16280MiB | 0% Default |
294 # +-------------------------------+----------------------+-------------+
295 # | 3 Tesla P100-SXM2... On | 0007:01:00.0 Off | 0 |
296 # | N/A 44C P0 290W / 300W | 965MiB / 16280MiB | 0% Default |
297 # +-------------------------------+----------------------+-------------+
298 # +--------------------------------------------------------------------+
299 # | Processes: GPU Memory |
300 # | GPU PID Type Process name Usage |
301 # |====================================================================|
302 # | 0 28459 C hxenvidia 929MiB |
303 # | 1 28460 C hxenvidia 1475MiB |
304 # | 2 28461 C hxenvidia 929MiB |
305 # | 3 28462 C hxenvidia 963MiB |
306 # +--------------------------------------------------------------------+
George Keishing4bbf5202017-05-18 06:55:53 -0500307
308 # Create logs directory and get current datetime.
309 Create Directory ${htx_log_dir_path}
310 ${cur_datetime}= Get Current Date result_format=%Y%m%d%H%M%S%f
311
Steven Sombar0278b132018-01-09 14:41:32 -0600312 ${nvidia_out} ${stderr} ${rc}= OS Execute Command nvidia-smi
George Keishing4bbf5202017-05-18 06:55:53 -0500313 Write Log Data To File
George Keishing664a0162017-06-05 12:24:24 -0500314 ... ${nvidia_out}
315 ... ${htx_log_dir_path}/${OS_HOST}_${cur_datetime}.nvidia_${suffix}
George Keishingbbfec9e2017-05-17 10:47:21 -0500316
317
Steven Sombar0278b132018-01-09 14:41:32 -0600318Get GPU Power Limit
319 [Documentation] Get NVIDIA GPU maximum permitted power draw.
George Keishingbbfec9e2017-05-17 10:47:21 -0500320
Steven Sombar0278b132018-01-09 14:41:32 -0600321 # nvidia-smi --query-gpu=power.limit --format=csv returns
322 # power.limit [W]
323 # 300.00 W
324 # 300.00 W
325 # 300.00 W
326 # 300.00 W
George Keishingbbfec9e2017-05-17 10:47:21 -0500327
Steven Sombar0278b132018-01-09 14:41:32 -0600328 ${cmd}= Catenate nvidia-smi --query-gpu=power.limit
329 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
330 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
331 # Allow for sensor overshoot. That is, max power reported for
332 # a GPU could be a few watts above the limit.
333 ${power_max}= Evaluate ${nvidia_out}+${7.00}
334 [Return] ${power_max}
335
336
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500337Get GPU Max Power
338 [Documentation] Get the maximum GPU power dissipation.
Steven Sombar0278b132018-01-09 14:41:32 -0600339
340 # nvidia-smi --query-gpu=power.draw --format=csv returns
341 # power.draw [W]
342 # 34.12 W
343 # 34.40 W
344 # 36.55 W
345 # 36.05 W
346
347 ${cmd}= Catenate nvidia-smi --query-gpu=power.draw
348 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
349 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
350 [Return] ${nvidia_out}
351
352
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500353Get GPU Min Power
354 [Documentation] Return the minimum GPU power value as record by
355 ... nvidia-smi.
356
357 ${cmd}= Catenate nvidia-smi --query-gpu=power.draw --format=csv |
358 ... grep -v 'power.draw' | cut -f 1 -d ' ' | sort -n -u | head -1
359 ${gpu_min_power} ${stderr} ${rc}= OS Execute Command ${cmd}
360 [Return] ${gpu_min_power}
361
362
Steven Sombar0278b132018-01-09 14:41:32 -0600363Get GPU Temperature Limit
364 [Documentation] Get NVIDIA GPU maximum permitted temperature.
365
366 # nvidia-smi -q -d TEMPERATURE | grep "GPU Max" returns
367 # GPU Max Operating Temp : 83 C
368 # GPU Max Operating Temp : 83 C
369 # GPU Max Operating Temp : 83 C
370 # GPU Max Operating Temp : 83 C
371
372 ${cmd}= Catenate nvidia-smi -q -d TEMPERATURE | grep "GPU Max"
373 ... | cut -f 2 -d ":" | tr -dc '0-9\n' | sort -n -u | tail -n 1
374 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
375 [Return] ${nvidia_out}
376
377
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500378Get GPU Min Temperature
379 [Documentation] Get the minimum GPU temperature.
380
381 ${cmd}= Catenate nvidia-smi --query-gpu=temperature.gpu
382 ... --format=csv | grep -v 'temperature.gpu' | sort -n -u | head -1
383 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
384 [Return] ${nvidia_out}
385
386
387Get GPU Max Temperature
388 [Documentation] Get the maximum GPU temperature.
Steven Sombar0278b132018-01-09 14:41:32 -0600389
390 # nvidia-smi --query-gpu=temperature.gpu --format=csv returns
391 # 38
392 # 41
393 # 38
394 # 40
395
396 ${cmd}= Catenate nvidia-smi --query-gpu=temperature.gpu
397 ... --format=csv | sort -n -u | tail -n 1
398 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
399 [Return] ${nvidia_out}
400
401
Steven Sombarc02dde82018-05-01 09:49:14 -0500402Get GPU Temperature Via REST
403 [Documentation] Return the temperature in degrees C of the warmest GPU
404 ... as reportd by REST.
405
406 # NOTE: This endpoint path is not defined until system has been powered-on.
407 ${temperature_objs}= Read Properties ${SENSORS_URI}temperature/enumerate
408 ... timeout=30 quiet=1
409
410 ${core_temperatures_list}= Catenate {k:v for k,v in $temperature_objs.iteritems()
411 ... if re.match('${SENSORS_URI}temperature/.*_core_temp', k)}
412 ${gpu_temperature_objs_dict}= Evaluate ${core_temperatures_list} modules=re
413
414 # Create a list containing all of the GPU temperatures.
415 ${gpu_temperatures}= Evaluate
416 ... [ x['Value'] for x in $gpu_temperature_objs_dict.values() ]
417
418 # Find the max temperature value and divide by 1000 to get just the integer
419 # portion.
420 ${max_gpu_temperature}= Evaluate max(map(int, $gpu_temperatures))/1000
421
422 [Return] ${max_gpu_temperature}
423
424
Steven Sombar0278b132018-01-09 14:41:32 -0600425Get GPU Clock Limit
426 [Documentation] Get NVIDIA GPU maximum permitted graphics clock.
427
428 # nvidia-smi --query-gpu=clocks.max.gr --format=csv returns
429 # 1530 MHz
430 # 1530 MHz
431 # 1530 MHz
432 # 1530 MHz
433
434 ${cmd}= Catenate nvidia-smi --query-gpu=clocks.max.gr
435 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
436 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
437 [Return] ${nvidia_out}
438
439
440Get GPU Clock
441 [Documentation] Get the highest assigned value of the GPU graphics clock.
442
443 # nvidia-smi --query-gpu=clocks.gr --format=csv returns
444 # 1230 MHz
445 # 1230 MHz
446 # 135 MHz
447 # 150 MHz
448
449 ${cmd}= Catenate nvidia-smi --query-gpu=clocks.gr
450 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
451 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
452 [Return] ${nvidia_out}
453
454
455Count GPUs From BMC
456 [Documentation] Determine number of GPUs from the BMC. Hostboot
457 ... needs to have been run previously because the BMC gets GPU data
458 ... from Hostboot.
459
460 # Example of gv* endpoint data:
461 # "/xyz/openbmc_project/inventory/system/chassis/motherboard/gv100card0": {
462 # "Functional": 1,
463 # "Present": 1,
464 # "PrettyName": ""
465 # },
466
467 ${num_bmc_gpus}= Set Variable ${0}
468
469 ${gpu_list}= Get Endpoint Paths
470 ... ${HOST_INVENTORY_URI}system/chassis/motherboard gv*
471
472 :FOR ${gpu_uri} IN @{gpu_list}
473 \ ${present}= Read Attribute ${gpu_uri} Present
474 \ ${state}= Read Attribute ${gpu_uri} Functional
475 \ Rpvars gpu_uri present state
476 \ ${num_bmc_gpus}= Run Keyword If ${present} and ${state}
477 ... Evaluate ${num_bmc_gpus}+${1}
478 [Return] ${num_bmc_gpus}
George Keishingbbfec9e2017-05-17 10:47:21 -0500479
480
481Create Default MDT Profile
482 [Documentation] Create default mdt.bu profile and run.
483
484 Rprint Timen Create HTX mdt profile.
485
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500486 ${profile} ${stderr} ${rc}= OS Execute Command
487 ... htxcmdline -createmdt
George Keishingbbfec9e2017-05-17 10:47:21 -0500488 Rprintn ${profile}
489 Should Contain ${profile} mdts are created successfully
Steven Sombar3ecb6892018-03-23 11:41:08 -0500490 ... msg=Create MDT profile failed. response=${profile}
George Keishingbbfec9e2017-05-17 10:47:21 -0500491
492
493Run MDT Profile
494 [Documentation] Load user pre-defined MDT profile.
Daniel Gonzalezbfd8aff2018-03-27 10:20:37 -0600495 [Arguments] ${HTX_MDT_PROFILE}=${HTX_MDT_PROFILE}
496 # Description of argument(s):
497 # HTX_MDT_PROFILE MDT profile to be executed (e.g. "mdt.bu").
George Keishingbbfec9e2017-05-17 10:47:21 -0500498
499 Rprint Timen Start HTX mdt profile execution.
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500500 ${htx_run} ${stderr} ${rc}= OS Execute Command
George Keishingbbfec9e2017-05-17 10:47:21 -0500501 ... htxcmdline -run -mdt ${HTX_MDT_PROFILE}
502 Rprintn ${htx_run}
503 Should Contain ${htx_run} Activated
Steven Sombar3ecb6892018-03-23 11:41:08 -0500504 ... msg=htxcmdline run mdt did not return "Activated" status.
George Keishingbbfec9e2017-05-17 10:47:21 -0500505
506
507Check HTX Run Status
508 [Documentation] Get HTX exerciser status and check for error.
Steven Sombar9d5fc2d2018-04-30 09:09:13 -0500509 [Arguments] ${sleep_time}=${0}
Joy Onyerikwua8074172018-04-20 07:08:19 -0500510
511 # Description of argument(s):
512 # sleep_time The amount of time to sleep after checking status.
George Keishingbbfec9e2017-05-17 10:47:21 -0500513
514 Rprint Timen Check HTX mdt Status and error.
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500515 ${htx_status} ${stderr} ${rc}= OS Execute Command
George Keishingbbfec9e2017-05-17 10:47:21 -0500516 ... htxcmdline -status -mdt ${HTX_MDT_PROFILE}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500517 Rprintn ${htx_status}
George Keishingbbfec9e2017-05-17 10:47:21 -0500518
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500519 ${htx_errlog} ${stderr} ${rc}= OS Execute Command
520 ... htxcmdline -geterrlog
Steven Sombar3ecb6892018-03-23 11:41:08 -0500521 Rprintn ${htx_errlog}
George Keishingbbfec9e2017-05-17 10:47:21 -0500522
Steven Sombar3ecb6892018-03-23 11:41:08 -0500523 Should Contain ${htx_errlog} file </tmp/htxerr> is empty
524 ... msg=HTX geterrorlog was not empty.
George Keishingbbfec9e2017-05-17 10:47:21 -0500525
Steven Sombar9d5fc2d2018-04-30 09:09:13 -0500526 Return From Keyword If ${sleep_time} == ${0}
Joy Onyerikwua8074172018-04-20 07:08:19 -0500527
528 Run Key U Sleep \ ${sleep-time}
529
George Keishingbbfec9e2017-05-17 10:47:21 -0500530
531Shutdown HTX Exerciser
532 [Documentation] Shut down HTX exerciser run.
533
534 Rprint Timen Shutdown HTX Run
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500535 ${shutdown} ${stderr} ${rc}= OS Execute Command
George Keishingbbfec9e2017-05-17 10:47:21 -0500536 ... htxcmdline -shutdown -mdt ${HTX_MDT_PROFILE}
537 Rprintn ${shutdown}
Steven Sombare27cca92018-02-28 10:56:38 -0600538
539 ${match_count_no_mdt}= Count Values In List ${shutdown}
540 ... No MDT is currently running
541 ${match_count_success}= Count Values In List ${shutdown}
542 ... shutdown successfully
543 Run Keyword If ${match_count_no_mdt} == 0 and ${match_count_success} == 0
544 ... Fail msg=Shutdown command returned unexpected message.
545
George Keishingbbfec9e2017-05-17 10:47:21 -0500546
Steven Sombar130a04f2017-07-16 10:02:37 -0500547Create JSON Inventory File
548 [Documentation] Create a JSON inventory file, and make a YAML copy.
549 [Arguments] ${json_file_path}
550 # Description of argument:
551 # json_file_path Where the inventory file is wrtten to.
552
553 Login To OS
554 Compile Inventory JSON
555 Run json2yaml ${json_tmp_file_path} ${yaml_file_path}
556 # Format to JSON pretty print to file.
557 Run python -m json.tool ${json_tmp_file_path} > ${json_file_path}
558 OperatingSystem.File Should Exist ${json_file_path}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500559 ... msg=File ${json_file_path} does not exist.
Steven Sombar130a04f2017-07-16 10:02:37 -0500560
561
562Compile Inventory JSON
563 [Documentation] Compile the Inventory into a JSON file.
564 Create File ${json_tmp_file_path}
565 Write New JSON List ${json_tmp_file_path} Inventory
566 Retrieve HW Info And Write processor ${json_tmp_file_path}
567 Retrieve HW Info And Write memory ${json_tmp_file_path}
568 Retrieve HW Info And Write List ${I/O} ${json_tmp_file_path} I/O last
569 Close New JSON List ${json_tmp_file_path}
570
Steven Sombar3ecb6892018-03-23 11:41:08 -0500571
Steven Sombar130a04f2017-07-16 10:02:37 -0500572Write New JSON List
573 [Documentation] Start a new JSON list element in file.
574 [Arguments] ${json_tmp_file_path} ${json_field_name}
575 # Description of argument(s):
576 # json_tmp_file_path Name of file to write to.
577 # json_field_name Name to give json list element.
578 Append to File ${json_tmp_file_path} { "${json_field_name}" : [
579
Steven Sombar3ecb6892018-03-23 11:41:08 -0500580
Steven Sombar130a04f2017-07-16 10:02:37 -0500581Close New JSON List
582 [Documentation] Close JSON list element in file.
583 [Arguments] ${json_tmp_file_path}
584 # Description of argument(s):
585 # json_tmp_file_path Path of file to write to.
586 Append to File ${json_tmp_file_path} ]}
587
Steven Sombar3ecb6892018-03-23 11:41:08 -0500588
Steven Sombar130a04f2017-07-16 10:02:37 -0500589Retrieve HW Info And Write
590 [Documentation] Retrieve and write info, add a comma if not last item.
591 [Arguments] ${class} ${json_tmp_file_path} ${last}=false
592 # Description of argument(s):
593 # class Device class to retrieve with lshw.
594 # json_tmp_file_path Path of file to write to.
595 # last Is this the last element in the parent JSON?
596 Write New JSON List ${json_tmp_file_path} ${class}
597 ${output} = Retrieve Hardware Info ${class}
598 ${output} = Clean Up String ${output}
599 Run Keyword if ${output.__class__ is not type(None)}
600 ... Append To File ${json_tmp_file_path} ${output}
601 Close New JSON List ${json_tmp_file_path}
602 Run Keyword if '${last}' == 'false'
603 ... Append to File ${json_tmp_file_path} ,
604
Steven Sombar3ecb6892018-03-23 11:41:08 -0500605
Steven Sombar130a04f2017-07-16 10:02:37 -0500606Retrieve HW Info And Write List
607 [Documentation] Does a Retrieve/Write with a list of classes and
608 ... encapsulates them into one large JSON element.
609 [Arguments] ${list} ${json_tmp_file_path} ${json_field_name}
610 ... ${last}=false
611 # Description of argument(s):
612 # list The list of devices classes to retrieve with lshw.
613 # json_tmp_file_path Path of file to write to.
614 # json_field_name Name of the JSON element to encapsulate this list.
615 # last Is this the last element in the parent JSON?
616 Write New JSON List ${json_tmp_file_path} ${json_field_name}
617 : FOR ${class} IN @{list}
618 \ ${tail} Get From List ${list} -1
619 \ Run Keyword if '${tail}' == '${class}'
620 \ ... Retrieve HW Info And Write ${class} ${json_tmp_file_path} true
621 \ ... ELSE Retrieve HW Info And Write ${class} ${json_tmp_file_path}
622 Close New JSON List ${json_tmp_file_path}
623 Run Keyword if '${last}' == 'false'
624 ... Append to File ${json_tmp_file_path} ,
625
Steven Sombar3ecb6892018-03-23 11:41:08 -0500626
Steven Sombar130a04f2017-07-16 10:02:37 -0500627Retrieve Hardware Info
628 [Documentation] Retrieves the lshw output of the device class as JSON.
629 [Arguments] ${class}
630 # Description of argument(s):
631 # class Device class to retrieve with lshw.
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500632 ${output} ${stderr} ${rc}= OS Execute Command lshw -c ${class} -json
Steven Sombar130a04f2017-07-16 10:02:37 -0500633 ${output} = Verify JSON string ${output}
634 [Return] ${output}
635
Steven Sombar3ecb6892018-03-23 11:41:08 -0500636
Steven Sombar130a04f2017-07-16 10:02:37 -0500637Verify JSON String
Gunnar Mills28e403b2017-10-25 16:16:38 -0500638 [Documentation] Ensure the JSON string content is separated by commas.
Steven Sombar130a04f2017-07-16 10:02:37 -0500639 [Arguments] ${unver_string}
640 # Description of argument(s):
641 # unver_string JSON String we will be checking for lshw comma errors.
642 ${unver_string} = Convert to String ${unver_string}
643 ${ver_string} = Replace String Using Regexp ${unver_string} }\\s*{ },{
644 [Return] ${ver_string}
645
Steven Sombar3ecb6892018-03-23 11:41:08 -0500646
Steven Sombar130a04f2017-07-16 10:02:37 -0500647Clean Up String
648 [Documentation] Remove extra whitespace and trailing commas.
649 [Arguments] ${dirty_string}
650 # Description of argument(s):
651 # dirty_string String that will be space stripped and have comma removed.
652 ${clean_string} = Strip String ${dirty_string}
653 ${last_char} = Get Substring ${clean_string} -1
654 ${trimmed_string} = Get Substring ${clean_string} 0 -1
655 ${clean_string} = Set Variable If '${last_char}' == ','
656 ... ${trimmed_string} ${clean_string}
657 [Return] ${clean_string}
Joy Onyerikwu4cb8c0a2018-04-11 18:05:13 -0500658
659
660Get OS Network Interface Names
661 [Documentation] Return a list of interface names on the OS.
662
663 ${stdout} ${stderr} ${rc}= OS Execute Command ls /sys/class/net
664 @{interface_names}= Split String ${stdout}
665 [Return] @{interface_names}
Daniel Gonzalezbfd8aff2018-03-27 10:20:37 -0600666
667
668Run Soft Bootme
669 [Documentation] Run a soft bootme for a period of an hour.
670 [Arguments] ${bootme_period}=3
671 # Description of argument(s):
672 # bootme_time Bootme period to be rebooting the system.
673
674 ${output} ${stderr} ${rc}= OS Execute Command
675 ... htxcmdline -bootme on mode:soft period:${bootme_period}
676 Should Contain ${output} bootme on is completed successfully
677
678
679Shutdown Bootme
680 [Documentation] Stop the bootme process.
681
682 ${output} ${stderr} ${rc}= OS Execute Command htxcmdline -bootme off
683 Should Contain ${output} bootme off is completed successfully