blob: bbf8b8a946e3c69fccc0e9ce193b54a699b209a8 [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
George Keishing4bbf5202017-05-18 06:55:53 -0500228Check For Errors On OS Dmesg Log
229 [Documentation] Check if dmesg has nvidia errors logged.
230
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500231 ${dmesg_log} ${stderr} ${rc}= OS Execute Command
232 ... dmesg | egrep '${ERROR_REGEX}'
George Keishing4bbf5202017-05-18 06:55:53 -0500233 # To enable multiple string check.
Steven Sombar0278b132018-01-09 14:41:32 -0600234 Should Not Contain ${dmesg_log} ${ERROR_DBE_MSG}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500235 ... msg=OS dmesg shows ${ERROR_DBE_MSG}.
George Keishing4bbf5202017-05-18 06:55:53 -0500236
237
238Collect NVIDIA Log File
239 [Documentation] Collect ndivia-smi command output.
George Keishing664a0162017-06-05 12:24:24 -0500240 [Arguments] ${suffix}
241 # Description of argument(s):
242 # suffix String name to append.
George Keishing4bbf5202017-05-18 06:55:53 -0500243
244 # Collects the output of ndivia-smi cmd output.
Steven Sombare27cca92018-02-28 10:56:38 -0600245 # +--------------------------------------------------------------------+
246 # | NVIDIA-SMI 361.89 Driver Version: 361.89 |
247 # |-------------------------------+----------------------+-------------+
248 # | GPU Name Persistence-M| Bus-Id Disp.A | GPU ECC |
249 # | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | Utiliz err |
250 # |===============================+======================+=============|
251 # | 0 Tesla P100-SXM2... On | 0002:01:00.0 Off | 0 |
252 # | N/A 25C P0 35W / 300W | 931MiB / 16280MiB | 0% Default |
253 # +-------------------------------+----------------------+-------------+
254 # | 1 Tesla P100-SXM2... On | 0003:01:00.0 Off | 0 |
255 # | N/A 26C P0 40W / 300W | 1477MiB / 16280MiB | 0% Default |
256 # +-------------------------------+----------------------+-------------+
257 # | 2 Tesla P100-SXM2... On | 0006:01:00.0 Off | 0 |
258 # | N/A 25C P0 35W / 300W | 931MiB / 16280MiB | 0% Default |
259 # +-------------------------------+----------------------+-------------+
260 # | 3 Tesla P100-SXM2... On | 0007:01:00.0 Off | 0 |
261 # | N/A 44C P0 290W / 300W | 965MiB / 16280MiB | 0% Default |
262 # +-------------------------------+----------------------+-------------+
263 # +--------------------------------------------------------------------+
264 # | Processes: GPU Memory |
265 # | GPU PID Type Process name Usage |
266 # |====================================================================|
267 # | 0 28459 C hxenvidia 929MiB |
268 # | 1 28460 C hxenvidia 1475MiB |
269 # | 2 28461 C hxenvidia 929MiB |
270 # | 3 28462 C hxenvidia 963MiB |
271 # +--------------------------------------------------------------------+
George Keishing4bbf5202017-05-18 06:55:53 -0500272
273 # Create logs directory and get current datetime.
274 Create Directory ${htx_log_dir_path}
275 ${cur_datetime}= Get Current Date result_format=%Y%m%d%H%M%S%f
276
Steven Sombar0278b132018-01-09 14:41:32 -0600277 ${nvidia_out} ${stderr} ${rc}= OS Execute Command nvidia-smi
George Keishing4bbf5202017-05-18 06:55:53 -0500278 Write Log Data To File
George Keishing664a0162017-06-05 12:24:24 -0500279 ... ${nvidia_out}
280 ... ${htx_log_dir_path}/${OS_HOST}_${cur_datetime}.nvidia_${suffix}
George Keishingbbfec9e2017-05-17 10:47:21 -0500281
282
Steven Sombar0278b132018-01-09 14:41:32 -0600283Get GPU Power Limit
284 [Documentation] Get NVIDIA GPU maximum permitted power draw.
George Keishingbbfec9e2017-05-17 10:47:21 -0500285
Steven Sombar0278b132018-01-09 14:41:32 -0600286 # nvidia-smi --query-gpu=power.limit --format=csv returns
287 # power.limit [W]
288 # 300.00 W
289 # 300.00 W
290 # 300.00 W
291 # 300.00 W
George Keishingbbfec9e2017-05-17 10:47:21 -0500292
Steven Sombar0278b132018-01-09 14:41:32 -0600293 ${cmd}= Catenate nvidia-smi --query-gpu=power.limit
294 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
295 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
296 # Allow for sensor overshoot. That is, max power reported for
297 # a GPU could be a few watts above the limit.
298 ${power_max}= Evaluate ${nvidia_out}+${7.00}
299 [Return] ${power_max}
300
301
302Get GPU Power
303 [Documentation] Get the GPU power dissipation.
304
305 # nvidia-smi --query-gpu=power.draw --format=csv returns
306 # power.draw [W]
307 # 34.12 W
308 # 34.40 W
309 # 36.55 W
310 # 36.05 W
311
312 ${cmd}= Catenate nvidia-smi --query-gpu=power.draw
313 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
314 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
315 [Return] ${nvidia_out}
316
317
318Get GPU Temperature Limit
319 [Documentation] Get NVIDIA GPU maximum permitted temperature.
320
321 # nvidia-smi -q -d TEMPERATURE | grep "GPU Max" returns
322 # GPU Max Operating Temp : 83 C
323 # GPU Max Operating Temp : 83 C
324 # GPU Max Operating Temp : 83 C
325 # GPU Max Operating Temp : 83 C
326
327 ${cmd}= Catenate nvidia-smi -q -d TEMPERATURE | grep "GPU Max"
328 ... | cut -f 2 -d ":" | tr -dc '0-9\n' | sort -n -u | tail -n 1
329 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
330 [Return] ${nvidia_out}
331
332
333Get GPU Temperature
334 [Documentation] Get the GPU temperature.
335
336 # nvidia-smi --query-gpu=temperature.gpu --format=csv returns
337 # 38
338 # 41
339 # 38
340 # 40
341
342 ${cmd}= Catenate nvidia-smi --query-gpu=temperature.gpu
343 ... --format=csv | sort -n -u | tail -n 1
344 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
345 [Return] ${nvidia_out}
346
347
Steven Sombarc02dde82018-05-01 09:49:14 -0500348Get GPU Temperature Via REST
349 [Documentation] Return the temperature in degrees C of the warmest GPU
350 ... as reportd by REST.
351
352 # NOTE: This endpoint path is not defined until system has been powered-on.
353 ${temperature_objs}= Read Properties ${SENSORS_URI}temperature/enumerate
354 ... timeout=30 quiet=1
355
356 ${core_temperatures_list}= Catenate {k:v for k,v in $temperature_objs.iteritems()
357 ... if re.match('${SENSORS_URI}temperature/.*_core_temp', k)}
358 ${gpu_temperature_objs_dict}= Evaluate ${core_temperatures_list} modules=re
359
360 # Create a list containing all of the GPU temperatures.
361 ${gpu_temperatures}= Evaluate
362 ... [ x['Value'] for x in $gpu_temperature_objs_dict.values() ]
363
364 # Find the max temperature value and divide by 1000 to get just the integer
365 # portion.
366 ${max_gpu_temperature}= Evaluate max(map(int, $gpu_temperatures))/1000
367
368 [Return] ${max_gpu_temperature}
369
370
Steven Sombar0278b132018-01-09 14:41:32 -0600371Get GPU Clock Limit
372 [Documentation] Get NVIDIA GPU maximum permitted graphics clock.
373
374 # nvidia-smi --query-gpu=clocks.max.gr --format=csv returns
375 # 1530 MHz
376 # 1530 MHz
377 # 1530 MHz
378 # 1530 MHz
379
380 ${cmd}= Catenate nvidia-smi --query-gpu=clocks.max.gr
381 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
382 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
383 [Return] ${nvidia_out}
384
385
386Get GPU Clock
387 [Documentation] Get the highest assigned value of the GPU graphics clock.
388
389 # nvidia-smi --query-gpu=clocks.gr --format=csv returns
390 # 1230 MHz
391 # 1230 MHz
392 # 135 MHz
393 # 150 MHz
394
395 ${cmd}= Catenate nvidia-smi --query-gpu=clocks.gr
396 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
397 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
398 [Return] ${nvidia_out}
399
400
401Count GPUs From BMC
402 [Documentation] Determine number of GPUs from the BMC. Hostboot
403 ... needs to have been run previously because the BMC gets GPU data
404 ... from Hostboot.
405
406 # Example of gv* endpoint data:
407 # "/xyz/openbmc_project/inventory/system/chassis/motherboard/gv100card0": {
408 # "Functional": 1,
409 # "Present": 1,
410 # "PrettyName": ""
411 # },
412
413 ${num_bmc_gpus}= Set Variable ${0}
414
415 ${gpu_list}= Get Endpoint Paths
416 ... ${HOST_INVENTORY_URI}system/chassis/motherboard gv*
417
418 :FOR ${gpu_uri} IN @{gpu_list}
419 \ ${present}= Read Attribute ${gpu_uri} Present
420 \ ${state}= Read Attribute ${gpu_uri} Functional
421 \ Rpvars gpu_uri present state
422 \ ${num_bmc_gpus}= Run Keyword If ${present} and ${state}
423 ... Evaluate ${num_bmc_gpus}+${1}
424 [Return] ${num_bmc_gpus}
George Keishingbbfec9e2017-05-17 10:47:21 -0500425
426
427Create Default MDT Profile
428 [Documentation] Create default mdt.bu profile and run.
429
430 Rprint Timen Create HTX mdt profile.
431
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500432 ${profile} ${stderr} ${rc}= OS Execute Command
433 ... htxcmdline -createmdt
George Keishingbbfec9e2017-05-17 10:47:21 -0500434 Rprintn ${profile}
435 Should Contain ${profile} mdts are created successfully
Steven Sombar3ecb6892018-03-23 11:41:08 -0500436 ... msg=Create MDT profile failed. response=${profile}
George Keishingbbfec9e2017-05-17 10:47:21 -0500437
438
439Run MDT Profile
440 [Documentation] Load user pre-defined MDT profile.
Daniel Gonzalezbfd8aff2018-03-27 10:20:37 -0600441 [Arguments] ${HTX_MDT_PROFILE}=${HTX_MDT_PROFILE}
442 # Description of argument(s):
443 # HTX_MDT_PROFILE MDT profile to be executed (e.g. "mdt.bu").
George Keishingbbfec9e2017-05-17 10:47:21 -0500444
445 Rprint Timen Start HTX mdt profile execution.
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500446 ${htx_run} ${stderr} ${rc}= OS Execute Command
George Keishingbbfec9e2017-05-17 10:47:21 -0500447 ... htxcmdline -run -mdt ${HTX_MDT_PROFILE}
448 Rprintn ${htx_run}
449 Should Contain ${htx_run} Activated
Steven Sombar3ecb6892018-03-23 11:41:08 -0500450 ... msg=htxcmdline run mdt did not return "Activated" status.
George Keishingbbfec9e2017-05-17 10:47:21 -0500451
452
453Check HTX Run Status
454 [Documentation] Get HTX exerciser status and check for error.
Steven Sombar9d5fc2d2018-04-30 09:09:13 -0500455 [Arguments] ${sleep_time}=${0}
Joy Onyerikwua8074172018-04-20 07:08:19 -0500456
457 # Description of argument(s):
458 # sleep_time The amount of time to sleep after checking status.
George Keishingbbfec9e2017-05-17 10:47:21 -0500459
460 Rprint Timen Check HTX mdt Status and error.
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500461 ${htx_status} ${stderr} ${rc}= OS Execute Command
George Keishingbbfec9e2017-05-17 10:47:21 -0500462 ... htxcmdline -status -mdt ${HTX_MDT_PROFILE}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500463 Rprintn ${htx_status}
George Keishingbbfec9e2017-05-17 10:47:21 -0500464
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500465 ${htx_errlog} ${stderr} ${rc}= OS Execute Command
466 ... htxcmdline -geterrlog
Steven Sombar3ecb6892018-03-23 11:41:08 -0500467 Rprintn ${htx_errlog}
George Keishingbbfec9e2017-05-17 10:47:21 -0500468
Steven Sombar3ecb6892018-03-23 11:41:08 -0500469 Should Contain ${htx_errlog} file </tmp/htxerr> is empty
470 ... msg=HTX geterrorlog was not empty.
George Keishingbbfec9e2017-05-17 10:47:21 -0500471
Steven Sombar9d5fc2d2018-04-30 09:09:13 -0500472 Return From Keyword If ${sleep_time} == ${0}
Joy Onyerikwua8074172018-04-20 07:08:19 -0500473
474 Run Key U Sleep \ ${sleep-time}
475
George Keishingbbfec9e2017-05-17 10:47:21 -0500476
477Shutdown HTX Exerciser
478 [Documentation] Shut down HTX exerciser run.
479
480 Rprint Timen Shutdown HTX Run
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500481 ${shutdown} ${stderr} ${rc}= OS Execute Command
George Keishingbbfec9e2017-05-17 10:47:21 -0500482 ... htxcmdline -shutdown -mdt ${HTX_MDT_PROFILE}
483 Rprintn ${shutdown}
Steven Sombare27cca92018-02-28 10:56:38 -0600484
485 ${match_count_no_mdt}= Count Values In List ${shutdown}
486 ... No MDT is currently running
487 ${match_count_success}= Count Values In List ${shutdown}
488 ... shutdown successfully
489 Run Keyword If ${match_count_no_mdt} == 0 and ${match_count_success} == 0
490 ... Fail msg=Shutdown command returned unexpected message.
491
George Keishingbbfec9e2017-05-17 10:47:21 -0500492
Steven Sombar130a04f2017-07-16 10:02:37 -0500493Create JSON Inventory File
494 [Documentation] Create a JSON inventory file, and make a YAML copy.
495 [Arguments] ${json_file_path}
496 # Description of argument:
497 # json_file_path Where the inventory file is wrtten to.
498
499 Login To OS
500 Compile Inventory JSON
501 Run json2yaml ${json_tmp_file_path} ${yaml_file_path}
502 # Format to JSON pretty print to file.
503 Run python -m json.tool ${json_tmp_file_path} > ${json_file_path}
504 OperatingSystem.File Should Exist ${json_file_path}
Steven Sombar3ecb6892018-03-23 11:41:08 -0500505 ... msg=File ${json_file_path} does not exist.
Steven Sombar130a04f2017-07-16 10:02:37 -0500506
507
508Compile Inventory JSON
509 [Documentation] Compile the Inventory into a JSON file.
510 Create File ${json_tmp_file_path}
511 Write New JSON List ${json_tmp_file_path} Inventory
512 Retrieve HW Info And Write processor ${json_tmp_file_path}
513 Retrieve HW Info And Write memory ${json_tmp_file_path}
514 Retrieve HW Info And Write List ${I/O} ${json_tmp_file_path} I/O last
515 Close New JSON List ${json_tmp_file_path}
516
Steven Sombar3ecb6892018-03-23 11:41:08 -0500517
Steven Sombar130a04f2017-07-16 10:02:37 -0500518Write New JSON List
519 [Documentation] Start a new JSON list element in file.
520 [Arguments] ${json_tmp_file_path} ${json_field_name}
521 # Description of argument(s):
522 # json_tmp_file_path Name of file to write to.
523 # json_field_name Name to give json list element.
524 Append to File ${json_tmp_file_path} { "${json_field_name}" : [
525
Steven Sombar3ecb6892018-03-23 11:41:08 -0500526
Steven Sombar130a04f2017-07-16 10:02:37 -0500527Close New JSON List
528 [Documentation] Close JSON list element in file.
529 [Arguments] ${json_tmp_file_path}
530 # Description of argument(s):
531 # json_tmp_file_path Path of file to write to.
532 Append to File ${json_tmp_file_path} ]}
533
Steven Sombar3ecb6892018-03-23 11:41:08 -0500534
Steven Sombar130a04f2017-07-16 10:02:37 -0500535Retrieve HW Info And Write
536 [Documentation] Retrieve and write info, add a comma if not last item.
537 [Arguments] ${class} ${json_tmp_file_path} ${last}=false
538 # Description of argument(s):
539 # class Device class to retrieve with lshw.
540 # json_tmp_file_path Path of file to write to.
541 # last Is this the last element in the parent JSON?
542 Write New JSON List ${json_tmp_file_path} ${class}
543 ${output} = Retrieve Hardware Info ${class}
544 ${output} = Clean Up String ${output}
545 Run Keyword if ${output.__class__ is not type(None)}
546 ... Append To File ${json_tmp_file_path} ${output}
547 Close New JSON List ${json_tmp_file_path}
548 Run Keyword if '${last}' == 'false'
549 ... Append to File ${json_tmp_file_path} ,
550
Steven Sombar3ecb6892018-03-23 11:41:08 -0500551
Steven Sombar130a04f2017-07-16 10:02:37 -0500552Retrieve HW Info And Write List
553 [Documentation] Does a Retrieve/Write with a list of classes and
554 ... encapsulates them into one large JSON element.
555 [Arguments] ${list} ${json_tmp_file_path} ${json_field_name}
556 ... ${last}=false
557 # Description of argument(s):
558 # list The list of devices classes to retrieve with lshw.
559 # json_tmp_file_path Path of file to write to.
560 # json_field_name Name of the JSON element to encapsulate this list.
561 # last Is this the last element in the parent JSON?
562 Write New JSON List ${json_tmp_file_path} ${json_field_name}
563 : FOR ${class} IN @{list}
564 \ ${tail} Get From List ${list} -1
565 \ Run Keyword if '${tail}' == '${class}'
566 \ ... Retrieve HW Info And Write ${class} ${json_tmp_file_path} true
567 \ ... ELSE Retrieve HW Info And Write ${class} ${json_tmp_file_path}
568 Close New JSON List ${json_tmp_file_path}
569 Run Keyword if '${last}' == 'false'
570 ... Append to File ${json_tmp_file_path} ,
571
Steven Sombar3ecb6892018-03-23 11:41:08 -0500572
Steven Sombar130a04f2017-07-16 10:02:37 -0500573Retrieve Hardware Info
574 [Documentation] Retrieves the lshw output of the device class as JSON.
575 [Arguments] ${class}
576 # Description of argument(s):
577 # class Device class to retrieve with lshw.
Joy Onyerikwuf73a62a2018-05-02 10:50:20 -0500578 ${output} ${stderr} ${rc}= OS Execute Command lshw -c ${class} -json
Steven Sombar130a04f2017-07-16 10:02:37 -0500579 ${output} = Verify JSON string ${output}
580 [Return] ${output}
581
Steven Sombar3ecb6892018-03-23 11:41:08 -0500582
Steven Sombar130a04f2017-07-16 10:02:37 -0500583Verify JSON String
Gunnar Mills28e403b2017-10-25 16:16:38 -0500584 [Documentation] Ensure the JSON string content is separated by commas.
Steven Sombar130a04f2017-07-16 10:02:37 -0500585 [Arguments] ${unver_string}
586 # Description of argument(s):
587 # unver_string JSON String we will be checking for lshw comma errors.
588 ${unver_string} = Convert to String ${unver_string}
589 ${ver_string} = Replace String Using Regexp ${unver_string} }\\s*{ },{
590 [Return] ${ver_string}
591
Steven Sombar3ecb6892018-03-23 11:41:08 -0500592
Steven Sombar130a04f2017-07-16 10:02:37 -0500593Clean Up String
594 [Documentation] Remove extra whitespace and trailing commas.
595 [Arguments] ${dirty_string}
596 # Description of argument(s):
597 # dirty_string String that will be space stripped and have comma removed.
598 ${clean_string} = Strip String ${dirty_string}
599 ${last_char} = Get Substring ${clean_string} -1
600 ${trimmed_string} = Get Substring ${clean_string} 0 -1
601 ${clean_string} = Set Variable If '${last_char}' == ','
602 ... ${trimmed_string} ${clean_string}
603 [Return] ${clean_string}
Joy Onyerikwu4cb8c0a2018-04-11 18:05:13 -0500604
605
606Get OS Network Interface Names
607 [Documentation] Return a list of interface names on the OS.
608
609 ${stdout} ${stderr} ${rc}= OS Execute Command ls /sys/class/net
610 @{interface_names}= Split String ${stdout}
611 [Return] @{interface_names}
Daniel Gonzalezbfd8aff2018-03-27 10:20:37 -0600612
613
614Run Soft Bootme
615 [Documentation] Run a soft bootme for a period of an hour.
616 [Arguments] ${bootme_period}=3
617 # Description of argument(s):
618 # bootme_time Bootme period to be rebooting the system.
619
620 ${output} ${stderr} ${rc}= OS Execute Command
621 ... htxcmdline -bootme on mode:soft period:${bootme_period}
622 Should Contain ${output} bootme on is completed successfully
623
624
625Shutdown Bootme
626 [Documentation] Stop the bootme process.
627
628 ${output} ${stderr} ${rc}= OS Execute Command htxcmdline -bootme off
629 Should Contain ${output} bootme off is completed successfully