blob: 655500864d9916942cc5f0db077325b789cbb1c3 [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
133 ${htx_err}= Execute Command On BMC cat /tmp/htxerr
134 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
138 ${htx_stats}= Execute Command On BMC cat /tmp/htxstats
139 Write Log Data To File
140 ... ${htx_stats} ${htx_log_dir_path}/${OS_HOST}_${cur_datetime}.htxstats
141
George Keishingcff7aa02017-05-16 08:05:10 -0500142
143REST Upload File To BMC
144 [Documentation] Upload a file via REST to BMC.
145
146 # Generate 32 MB file size
147 Run dd if=/dev/zero of=dummyfile bs=1 count=0 seek=32MB
148 OperatingSystem.File Should Exist dummyfile
149
150 # Get the content of the file and upload to BMC
151 ${image_data}= OperatingSystem.Get Binary File dummyfile
152
153 # Get REST session to BMC
154 Initialize OpenBMC
155
156 # Create the REST payload headers and data
157 ${data}= Create Dictionary data ${image_data}
158 ${headers}= Create Dictionary Content-Type=application/octet-stream
159 ... Accept=application/octet-stream
160 Set To Dictionary ${data} headers ${headers}
161
162 ${resp}= Post Request openbmc /upload/image &{data}
163 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500164 ... msg=Openbmc /upload/image failed.
George Keishingcff7aa02017-05-16 08:05:10 -0500165
George Keishingcff7aa02017-05-16 08:05:10 -0500166 # Take SSH connection to BMC and switch to BMC connection to perform
167 # the task.
168 &{bmc_connection_args}= Create Dictionary alias=bmc_connection
169 Open Connection And Log In &{bmc_connection_args}
170
171 # Currently OS SSH session is active, switch to BMC connection.
172 Switch Connection bmc_connection
George Keishingcff7aa02017-05-16 08:05:10 -0500173
174 # Switch back to OS SSH connection.
175 Switch Connection os_connection
176
George Keishing4bbf5202017-05-18 06:55:53 -0500177
Steven Sombar1dc6fa72018-01-12 10:58:20 -0600178Get CPU Min Frequency Limit
179 [Documentation] Get CPU minimum assignable frequency.
180
181 # lscpu | grep min returns
182 # CPU min MHz: 1983.0000
183
184 ${cmd}= Catenate lscpu | grep min | tr -dc '0-9.\n'
185 ${cpu_freq} ${stderr} ${rc}= OS Execute Command ${cmd}
186 [Return] ${cpu_freq}
187
188
189Get CPU Min Frequency
190 [Documentation] Get CPU assigned minimum frequency.
191
192 # ppc64_cpu --frequency -t 10 returns
193 # min: 3.295 GHz (cpu 143)
194 # max: 3.295 GHz (cpu 0)
195 # avg: 3.295 GHz
196
197 ${cmd}= Catenate ppc64_cpu --frequency -t 10 | grep min
198 ... | cut -f 2 | cut -d ' ' -f 1 | tr -dc '0-9\n'
199 ${cpu_freq} ${stderr} ${rc}= OS Execute Command ${cmd}
200 [Return] ${cpu_freq}
201
202
203Get CPU Max Frequency Limit
204 [Documentation] Get CPU maximum assignable frequency.
205
206 # lscpu | grep max returns
207 # CPU max MHz: 3300.0000
208
209 ${cmd}= Catenate lscpu | grep max | tr -dc '0-9.\n'
210 ${cpu_freq} ${stderr} ${rc}= OS Execute Command ${cmd}
211 [Return] ${cpu_freq}
212
213
214Get CPU Max Frequency
215 [Documentation] Get CPU assigned maximum frequency.
216
217 # ppc64_cpu --frequency -t 10 returns
218 # min: 3.295 GHz (cpu 143)
219 # max: 3.295 GHz (cpu 0)
220 # avg: 3.295 GHz
221
222 ${cmd}= Catenate ppc64_cpu --frequency -t 10 | grep max
223 ... | cut -f 2 | cut -d ' ' -f 1 | tr -dc '0-9\n'
224 ${cpu_freq} ${stderr} ${rc}= OS Execute Command ${cmd}
225 [Return] ${cpu_freq}
226
227
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500228Get CPU Max Temperature
229 [Documentation] Get the highest CPU Temperature.
230
231 ${temperature_objs}= Read Properties
232 ... ${SENSORS_URI}temperature/enumerate
233 # Filter the dictionary to get just the CPU temperature info.
234 ${cmd}= Catenate {k:v for k,v in $temperature_objs.iteritems()
235 ... if re.match('${SENSORS_URI}temperature/p.*core.*temp', k)}
236 ${cpu_temperatuture_objs} Evaluate ${cmd} modules=re
237 # Create a list of the CPU temperature values (current).
238 ${cpu_temperatures}= Evaluate
239 ... [ x['Value'] for x in $cpu_temperatuture_objs.values() ]
240
241 ${cpu_max_temp} Evaluate max(map(int, $cpu_temperatures))/1000
242 [Return] ${cpu_max_temp}
243
244
245Get CPU Min Temperature
246 [Documentation] Get the CPU Temperature.
247
248 ${temperature_objs}= Read Properties
249 ... ${SENSORS_URI}temperature/enumerate
250 # Filter the dictionary to get just the CPU temperature info.
251 ${cmd}= Catenate {k:v for k,v in $temperature_objs.iteritems()
252 ... if re.match('${SENSORS_URI}temperature/p.*core.*temp', k)}
253 ${cpu_temperatuture_objs}= Evaluate ${cmd} modules=re
254 # Create a list of the CPU temperature values (current).
255 ${cpu_temperatures}= Evaluate
256 ... [ x['Value'] for x in $cpu_temperatuture_objs.values() ]
257
258 ${cpu_min_temp} Evaluate min(map(int, $cpu_temperatures))/1000
259 [Return] ${cpu_min_temp}
260
261
George Keishing4bbf5202017-05-18 06:55:53 -0500262Check For Errors On OS Dmesg Log
263 [Documentation] Check if dmesg has nvidia errors logged.
264
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500265 ${dmesg_log} ${stderr} ${rc}= OS Execute Command
266 ... dmesg | egrep '${ERROR_REGEX}'
George Keishing4bbf5202017-05-18 06:55:53 -0500267 # To enable multiple string check.
Steven Sombar0278b132018-01-09 14:41:32 -0600268 Should Not Contain ${dmesg_log} ${ERROR_DBE_MSG}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500269 ... msg=OS dmesg shows ${ERROR_DBE_MSG}.
George Keishing4bbf5202017-05-18 06:55:53 -0500270
271
272Collect NVIDIA Log File
273 [Documentation] Collect ndivia-smi command output.
George Keishing664a0162017-06-05 12:24:24 -0500274 [Arguments] ${suffix}
275 # Description of argument(s):
276 # suffix String name to append.
George Keishing4bbf5202017-05-18 06:55:53 -0500277
278 # Collects the output of ndivia-smi cmd output.
Steven Sombare27cca92018-02-28 10:56:38 -0600279 # +--------------------------------------------------------------------+
280 # | NVIDIA-SMI 361.89 Driver Version: 361.89 |
281 # |-------------------------------+----------------------+-------------+
282 # | GPU Name Persistence-M| Bus-Id Disp.A | GPU ECC |
283 # | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | Utiliz err |
284 # |===============================+======================+=============|
285 # | 0 Tesla P100-SXM2... On | 0002:01:00.0 Off | 0 |
286 # | N/A 25C P0 35W / 300W | 931MiB / 16280MiB | 0% Default |
287 # +-------------------------------+----------------------+-------------+
288 # | 1 Tesla P100-SXM2... On | 0003:01:00.0 Off | 0 |
289 # | N/A 26C P0 40W / 300W | 1477MiB / 16280MiB | 0% Default |
290 # +-------------------------------+----------------------+-------------+
291 # | 2 Tesla P100-SXM2... On | 0006:01:00.0 Off | 0 |
292 # | N/A 25C P0 35W / 300W | 931MiB / 16280MiB | 0% Default |
293 # +-------------------------------+----------------------+-------------+
294 # | 3 Tesla P100-SXM2... On | 0007:01:00.0 Off | 0 |
295 # | N/A 44C P0 290W / 300W | 965MiB / 16280MiB | 0% Default |
296 # +-------------------------------+----------------------+-------------+
297 # +--------------------------------------------------------------------+
298 # | Processes: GPU Memory |
299 # | GPU PID Type Process name Usage |
300 # |====================================================================|
301 # | 0 28459 C hxenvidia 929MiB |
302 # | 1 28460 C hxenvidia 1475MiB |
303 # | 2 28461 C hxenvidia 929MiB |
304 # | 3 28462 C hxenvidia 963MiB |
305 # +--------------------------------------------------------------------+
George Keishing4bbf5202017-05-18 06:55:53 -0500306
307 # Create logs directory and get current datetime.
308 Create Directory ${htx_log_dir_path}
309 ${cur_datetime}= Get Current Date result_format=%Y%m%d%H%M%S%f
310
Steven Sombar0278b132018-01-09 14:41:32 -0600311 ${nvidia_out} ${stderr} ${rc}= OS Execute Command nvidia-smi
George Keishing4bbf5202017-05-18 06:55:53 -0500312 Write Log Data To File
George Keishing664a0162017-06-05 12:24:24 -0500313 ... ${nvidia_out}
314 ... ${htx_log_dir_path}/${OS_HOST}_${cur_datetime}.nvidia_${suffix}
George Keishingbbfec9e2017-05-17 10:47:21 -0500315
316
Steven Sombar0278b132018-01-09 14:41:32 -0600317Get GPU Power Limit
318 [Documentation] Get NVIDIA GPU maximum permitted power draw.
George Keishingbbfec9e2017-05-17 10:47:21 -0500319
Steven Sombar0278b132018-01-09 14:41:32 -0600320 # nvidia-smi --query-gpu=power.limit --format=csv returns
321 # power.limit [W]
322 # 300.00 W
323 # 300.00 W
324 # 300.00 W
325 # 300.00 W
George Keishingbbfec9e2017-05-17 10:47:21 -0500326
Steven Sombar0278b132018-01-09 14:41:32 -0600327 ${cmd}= Catenate nvidia-smi --query-gpu=power.limit
328 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
329 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
330 # Allow for sensor overshoot. That is, max power reported for
331 # a GPU could be a few watts above the limit.
332 ${power_max}= Evaluate ${nvidia_out}+${7.00}
333 [Return] ${power_max}
334
335
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500336Get GPU Max Power
337 [Documentation] Get the maximum GPU power dissipation.
Steven Sombar0278b132018-01-09 14:41:32 -0600338
339 # nvidia-smi --query-gpu=power.draw --format=csv returns
340 # power.draw [W]
341 # 34.12 W
342 # 34.40 W
343 # 36.55 W
344 # 36.05 W
345
346 ${cmd}= Catenate nvidia-smi --query-gpu=power.draw
347 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
348 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
349 [Return] ${nvidia_out}
350
351
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500352Get GPU Min Power
353 [Documentation] Return the minimum GPU power value as record by
354 ... nvidia-smi.
355
356 ${cmd}= Catenate nvidia-smi --query-gpu=power.draw --format=csv |
357 ... grep -v 'power.draw' | cut -f 1 -d ' ' | sort -n -u | head -1
358 ${gpu_min_power} ${stderr} ${rc}= OS Execute Command ${cmd}
359 [Return] ${gpu_min_power}
360
361
Steven Sombar0278b132018-01-09 14:41:32 -0600362Get GPU Temperature Limit
363 [Documentation] Get NVIDIA GPU maximum permitted temperature.
364
365 # nvidia-smi -q -d TEMPERATURE | grep "GPU Max" returns
366 # GPU Max Operating Temp : 83 C
367 # GPU Max Operating Temp : 83 C
368 # GPU Max Operating Temp : 83 C
369 # GPU Max Operating Temp : 83 C
370
371 ${cmd}= Catenate nvidia-smi -q -d TEMPERATURE | grep "GPU Max"
372 ... | cut -f 2 -d ":" | tr -dc '0-9\n' | sort -n -u | tail -n 1
373 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
374 [Return] ${nvidia_out}
375
376
Joy Onyerikwu26975f02018-05-08 12:55:12 -0500377Get GPU Min Temperature
378 [Documentation] Get the minimum GPU temperature.
379
380 ${cmd}= Catenate nvidia-smi --query-gpu=temperature.gpu
381 ... --format=csv | grep -v 'temperature.gpu' | sort -n -u | head -1
382 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
383 [Return] ${nvidia_out}
384
385
386Get GPU Max Temperature
387 [Documentation] Get the maximum GPU temperature.
Steven Sombar0278b132018-01-09 14:41:32 -0600388
389 # nvidia-smi --query-gpu=temperature.gpu --format=csv returns
390 # 38
391 # 41
392 # 38
393 # 40
394
395 ${cmd}= Catenate nvidia-smi --query-gpu=temperature.gpu
396 ... --format=csv | sort -n -u | tail -n 1
397 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
398 [Return] ${nvidia_out}
399
400
Steven Sombarc02dde82018-05-01 09:49:14 -0500401Get GPU Temperature Via REST
402 [Documentation] Return the temperature in degrees C of the warmest GPU
403 ... as reportd by REST.
404
405 # NOTE: This endpoint path is not defined until system has been powered-on.
406 ${temperature_objs}= Read Properties ${SENSORS_URI}temperature/enumerate
407 ... timeout=30 quiet=1
408
409 ${core_temperatures_list}= Catenate {k:v for k,v in $temperature_objs.iteritems()
410 ... if re.match('${SENSORS_URI}temperature/.*_core_temp', k)}
411 ${gpu_temperature_objs_dict}= Evaluate ${core_temperatures_list} modules=re
412
413 # Create a list containing all of the GPU temperatures.
414 ${gpu_temperatures}= Evaluate
415 ... [ x['Value'] for x in $gpu_temperature_objs_dict.values() ]
416
417 # Find the max temperature value and divide by 1000 to get just the integer
418 # portion.
419 ${max_gpu_temperature}= Evaluate max(map(int, $gpu_temperatures))/1000
420
421 [Return] ${max_gpu_temperature}
422
423
Steven Sombar0278b132018-01-09 14:41:32 -0600424Get GPU Clock Limit
425 [Documentation] Get NVIDIA GPU maximum permitted graphics clock.
426
427 # nvidia-smi --query-gpu=clocks.max.gr --format=csv returns
428 # 1530 MHz
429 # 1530 MHz
430 # 1530 MHz
431 # 1530 MHz
432
433 ${cmd}= Catenate nvidia-smi --query-gpu=clocks.max.gr
434 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
435 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
436 [Return] ${nvidia_out}
437
438
439Get GPU Clock
440 [Documentation] Get the highest assigned value of the GPU graphics clock.
441
442 # nvidia-smi --query-gpu=clocks.gr --format=csv returns
443 # 1230 MHz
444 # 1230 MHz
445 # 135 MHz
446 # 150 MHz
447
448 ${cmd}= Catenate nvidia-smi --query-gpu=clocks.gr
449 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
450 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
451 [Return] ${nvidia_out}
452
453
454Count GPUs From BMC
455 [Documentation] Determine number of GPUs from the BMC. Hostboot
456 ... needs to have been run previously because the BMC gets GPU data
457 ... from Hostboot.
458
459 # Example of gv* endpoint data:
460 # "/xyz/openbmc_project/inventory/system/chassis/motherboard/gv100card0": {
461 # "Functional": 1,
462 # "Present": 1,
463 # "PrettyName": ""
464 # },
465
466 ${num_bmc_gpus}= Set Variable ${0}
467
468 ${gpu_list}= Get Endpoint Paths
469 ... ${HOST_INVENTORY_URI}system/chassis/motherboard gv*
470
471 :FOR ${gpu_uri} IN @{gpu_list}
472 \ ${present}= Read Attribute ${gpu_uri} Present
473 \ ${state}= Read Attribute ${gpu_uri} Functional
474 \ Rpvars gpu_uri present state
475 \ ${num_bmc_gpus}= Run Keyword If ${present} and ${state}
476 ... Evaluate ${num_bmc_gpus}+${1}
477 [Return] ${num_bmc_gpus}
George Keishingbbfec9e2017-05-17 10:47:21 -0500478
479
480Create Default MDT Profile
481 [Documentation] Create default mdt.bu profile and run.
482
483 Rprint Timen Create HTX mdt profile.
484
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500485 ${profile} ${stderr} ${rc}= OS Execute Command
486 ... htxcmdline -createmdt
George Keishingbbfec9e2017-05-17 10:47:21 -0500487 Rprintn ${profile}
488 Should Contain ${profile} mdts are created successfully
Steven Sombar3ecb6892018-03-23 11:41:08 -0500489 ... msg=Create MDT profile failed. response=${profile}
George Keishingbbfec9e2017-05-17 10:47:21 -0500490
491
492Run MDT Profile
493 [Documentation] Load user pre-defined MDT profile.
Daniel Gonzalezbfd8aff2018-03-27 10:20:37 -0600494 [Arguments] ${HTX_MDT_PROFILE}=${HTX_MDT_PROFILE}
495 # Description of argument(s):
496 # HTX_MDT_PROFILE MDT profile to be executed (e.g. "mdt.bu").
George Keishingbbfec9e2017-05-17 10:47:21 -0500497
498 Rprint Timen Start HTX mdt profile execution.
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500499 ${htx_run} ${stderr} ${rc}= OS Execute Command
George Keishingbbfec9e2017-05-17 10:47:21 -0500500 ... htxcmdline -run -mdt ${HTX_MDT_PROFILE}
501 Rprintn ${htx_run}
502 Should Contain ${htx_run} Activated
Steven Sombar3ecb6892018-03-23 11:41:08 -0500503 ... msg=htxcmdline run mdt did not return "Activated" status.
George Keishingbbfec9e2017-05-17 10:47:21 -0500504
505
506Check HTX Run Status
507 [Documentation] Get HTX exerciser status and check for error.
Steven Sombar9d5fc2d2018-04-30 09:09:13 -0500508 [Arguments] ${sleep_time}=${0}
Joy Onyerikwua8074172018-04-20 07:08:19 -0500509
510 # Description of argument(s):
511 # sleep_time The amount of time to sleep after checking status.
George Keishingbbfec9e2017-05-17 10:47:21 -0500512
513 Rprint Timen Check HTX mdt Status and error.
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500514 ${htx_status} ${stderr} ${rc}= OS Execute Command
George Keishingbbfec9e2017-05-17 10:47:21 -0500515 ... htxcmdline -status -mdt ${HTX_MDT_PROFILE}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500516 Rprintn ${htx_status}
George Keishingbbfec9e2017-05-17 10:47:21 -0500517
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500518 ${htx_errlog} ${stderr} ${rc}= OS Execute Command
519 ... htxcmdline -geterrlog
Steven Sombar3ecb6892018-03-23 11:41:08 -0500520 Rprintn ${htx_errlog}
George Keishingbbfec9e2017-05-17 10:47:21 -0500521
Steven Sombar3ecb6892018-03-23 11:41:08 -0500522 Should Contain ${htx_errlog} file </tmp/htxerr> is empty
523 ... msg=HTX geterrorlog was not empty.
George Keishingbbfec9e2017-05-17 10:47:21 -0500524
Steven Sombar9d5fc2d2018-04-30 09:09:13 -0500525 Return From Keyword If ${sleep_time} == ${0}
Joy Onyerikwua8074172018-04-20 07:08:19 -0500526
527 Run Key U Sleep \ ${sleep-time}
528
George Keishingbbfec9e2017-05-17 10:47:21 -0500529
530Shutdown HTX Exerciser
531 [Documentation] Shut down HTX exerciser run.
532
533 Rprint Timen Shutdown HTX Run
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500534 ${shutdown} ${stderr} ${rc}= OS Execute Command
George Keishingbbfec9e2017-05-17 10:47:21 -0500535 ... htxcmdline -shutdown -mdt ${HTX_MDT_PROFILE}
536 Rprintn ${shutdown}
Steven Sombare27cca92018-02-28 10:56:38 -0600537
538 ${match_count_no_mdt}= Count Values In List ${shutdown}
539 ... No MDT is currently running
540 ${match_count_success}= Count Values In List ${shutdown}
541 ... shutdown successfully
542 Run Keyword If ${match_count_no_mdt} == 0 and ${match_count_success} == 0
543 ... Fail msg=Shutdown command returned unexpected message.
544
George Keishingbbfec9e2017-05-17 10:47:21 -0500545
Steven Sombar130a04f2017-07-16 10:02:37 -0500546Create JSON Inventory File
547 [Documentation] Create a JSON inventory file, and make a YAML copy.
548 [Arguments] ${json_file_path}
549 # Description of argument:
550 # json_file_path Where the inventory file is wrtten to.
551
552 Login To OS
553 Compile Inventory JSON
554 Run json2yaml ${json_tmp_file_path} ${yaml_file_path}
555 # Format to JSON pretty print to file.
556 Run python -m json.tool ${json_tmp_file_path} > ${json_file_path}
557 OperatingSystem.File Should Exist ${json_file_path}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500558 ... msg=File ${json_file_path} does not exist.
Steven Sombar130a04f2017-07-16 10:02:37 -0500559
560
561Compile Inventory JSON
562 [Documentation] Compile the Inventory into a JSON file.
563 Create File ${json_tmp_file_path}
564 Write New JSON List ${json_tmp_file_path} Inventory
565 Retrieve HW Info And Write processor ${json_tmp_file_path}
566 Retrieve HW Info And Write memory ${json_tmp_file_path}
567 Retrieve HW Info And Write List ${I/O} ${json_tmp_file_path} I/O last
568 Close New JSON List ${json_tmp_file_path}
569
Steven Sombar3ecb6892018-03-23 11:41:08 -0500570
Steven Sombar130a04f2017-07-16 10:02:37 -0500571Write New JSON List
572 [Documentation] Start a new JSON list element in file.
573 [Arguments] ${json_tmp_file_path} ${json_field_name}
574 # Description of argument(s):
575 # json_tmp_file_path Name of file to write to.
576 # json_field_name Name to give json list element.
577 Append to File ${json_tmp_file_path} { "${json_field_name}" : [
578
Steven Sombar3ecb6892018-03-23 11:41:08 -0500579
Steven Sombar130a04f2017-07-16 10:02:37 -0500580Close New JSON List
581 [Documentation] Close JSON list element in file.
582 [Arguments] ${json_tmp_file_path}
583 # Description of argument(s):
584 # json_tmp_file_path Path of file to write to.
585 Append to File ${json_tmp_file_path} ]}
586
Steven Sombar3ecb6892018-03-23 11:41:08 -0500587
Steven Sombar130a04f2017-07-16 10:02:37 -0500588Retrieve HW Info And Write
589 [Documentation] Retrieve and write info, add a comma if not last item.
590 [Arguments] ${class} ${json_tmp_file_path} ${last}=false
591 # Description of argument(s):
592 # class Device class to retrieve with lshw.
593 # json_tmp_file_path Path of file to write to.
594 # last Is this the last element in the parent JSON?
595 Write New JSON List ${json_tmp_file_path} ${class}
596 ${output} = Retrieve Hardware Info ${class}
597 ${output} = Clean Up String ${output}
598 Run Keyword if ${output.__class__ is not type(None)}
599 ... Append To File ${json_tmp_file_path} ${output}
600 Close New JSON List ${json_tmp_file_path}
601 Run Keyword if '${last}' == 'false'
602 ... Append to File ${json_tmp_file_path} ,
603
Steven Sombar3ecb6892018-03-23 11:41:08 -0500604
Steven Sombar130a04f2017-07-16 10:02:37 -0500605Retrieve HW Info And Write List
606 [Documentation] Does a Retrieve/Write with a list of classes and
607 ... encapsulates them into one large JSON element.
608 [Arguments] ${list} ${json_tmp_file_path} ${json_field_name}
609 ... ${last}=false
610 # Description of argument(s):
611 # list The list of devices classes to retrieve with lshw.
612 # json_tmp_file_path Path of file to write to.
613 # json_field_name Name of the JSON element to encapsulate this list.
614 # last Is this the last element in the parent JSON?
615 Write New JSON List ${json_tmp_file_path} ${json_field_name}
616 : FOR ${class} IN @{list}
617 \ ${tail} Get From List ${list} -1
618 \ Run Keyword if '${tail}' == '${class}'
619 \ ... Retrieve HW Info And Write ${class} ${json_tmp_file_path} true
620 \ ... ELSE Retrieve HW Info And Write ${class} ${json_tmp_file_path}
621 Close New JSON List ${json_tmp_file_path}
622 Run Keyword if '${last}' == 'false'
623 ... Append to File ${json_tmp_file_path} ,
624
Steven Sombar3ecb6892018-03-23 11:41:08 -0500625
Steven Sombar130a04f2017-07-16 10:02:37 -0500626Retrieve Hardware Info
627 [Documentation] Retrieves the lshw output of the device class as JSON.
628 [Arguments] ${class}
629 # Description of argument(s):
630 # class Device class to retrieve with lshw.
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500631 ${output} ${stderr} ${rc}= OS Execute Command lshw -c ${class} -json
Steven Sombar130a04f2017-07-16 10:02:37 -0500632 ${output} = Verify JSON string ${output}
633 [Return] ${output}
634
Steven Sombar3ecb6892018-03-23 11:41:08 -0500635
Steven Sombar130a04f2017-07-16 10:02:37 -0500636Verify JSON String
Gunnar Mills28e403b2017-10-25 16:16:38 -0500637 [Documentation] Ensure the JSON string content is separated by commas.
Steven Sombar130a04f2017-07-16 10:02:37 -0500638 [Arguments] ${unver_string}
639 # Description of argument(s):
640 # unver_string JSON String we will be checking for lshw comma errors.
641 ${unver_string} = Convert to String ${unver_string}
642 ${ver_string} = Replace String Using Regexp ${unver_string} }\\s*{ },{
643 [Return] ${ver_string}
644
Steven Sombar3ecb6892018-03-23 11:41:08 -0500645
Steven Sombar130a04f2017-07-16 10:02:37 -0500646Clean Up String
647 [Documentation] Remove extra whitespace and trailing commas.
648 [Arguments] ${dirty_string}
649 # Description of argument(s):
650 # dirty_string String that will be space stripped and have comma removed.
651 ${clean_string} = Strip String ${dirty_string}
652 ${last_char} = Get Substring ${clean_string} -1
653 ${trimmed_string} = Get Substring ${clean_string} 0 -1
654 ${clean_string} = Set Variable If '${last_char}' == ','
655 ... ${trimmed_string} ${clean_string}
656 [Return] ${clean_string}
Joy Onyerikwu4cb8c0a2018-04-11 18:05:13 -0500657
658
659Get OS Network Interface Names
660 [Documentation] Return a list of interface names on the OS.
661
662 ${stdout} ${stderr} ${rc}= OS Execute Command ls /sys/class/net
663 @{interface_names}= Split String ${stdout}
664 [Return] @{interface_names}
Daniel Gonzalezbfd8aff2018-03-27 10:20:37 -0600665
666
667Run Soft Bootme
668 [Documentation] Run a soft bootme for a period of an hour.
669 [Arguments] ${bootme_period}=3
670 # Description of argument(s):
671 # bootme_time Bootme period to be rebooting the system.
672
673 ${output} ${stderr} ${rc}= OS Execute Command
674 ... htxcmdline -bootme on mode:soft period:${bootme_period}
675 Should Contain ${output} bootme on is completed successfully
676
677
678Shutdown Bootme
679 [Documentation] Stop the bootme process.
680
681 ${output} ${stderr} ${rc}= OS Execute Command htxcmdline -bootme off
682 Should Contain ${output} bootme off is completed successfully