blob: f02f3c10d72198f71d839979357c8192222c9d31 [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
42 Should Be Empty ${stderr}
43 [Return] ${stdout}
44
George Keishing0fff68a2017-04-27 22:25:49 -050045Login To OS
46 [Documentation] Login to OS Host.
47 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
48 ... ${os_password}=${OS_PASSWORD}
George Keishingcff7aa02017-05-16 08:05:10 -050049 ... ${alias_name}=os_connection
George Keishing91c852f2017-05-03 02:48:21 -050050 # Description of argument(s):
51 # os_host IP address of the OS Host.
52 # os_username OS Host Login user name.
53 # os_password OS Host Login passwrd.
George Keishingcff7aa02017-05-16 08:05:10 -050054 # alias_name Default OS SSH session connection alias name.
55 # TODO: Generalize alias naming using openbmc/openbmc-test-automation#633
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.
George Keishing91c852f2017-05-03 02:48:21 -050067 Login To OS
George Keishing88366b32017-05-12 13:50:48 -050068 ${output}= Execute Command On OS which ${tool_name}
69 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
90 ${out}= Execute Command On OS ls ${file_path}
91 Log To Console \n File Exist: ${out}
92
George Keishing8740a0c2017-05-13 07:19:16 -050093
94Is HTX Running
95 [Documentation] Check if the HTX exerciser is currently running.
96
97 ${status}= Execute Command On OS htxcmdline -status
98 Should Not Contain ${status} Daemon state is <IDLE>
George Keishing4ef29082017-05-13 05:01:23 -050099
100
101Write Log Data To File
102 [Documentation] Write log data to the logs directory.
103 [Arguments] ${data}= ${log_file_path}=
104 # Description of argument(s):
105 # data String buffer.
106 # log_file_path The log file path.
107
108 Create File ${log_file_path} ${data}
109
110
111Collect HTX Log Files
112 [Documentation] Collect status and error log files.
113 # Collects the following files:
114 # HTX error log file /tmp/htxerr
115 # HTX status log file /tmp/htxstats
116
117 # Create logs directory and get current datetime.
118 Create Directory ${htx_log_dir_path}
119 ${cur_datetime}= Get Current Date result_format=%Y%m%d%H%M%S%f
120
121 File Exist On OS /tmp/htxerr
122 ${htx_err}= Execute Command On BMC cat /tmp/htxerr
123 Write Log Data To File
124 ... ${htx_err} ${htx_log_dir_path}/${OS_HOST}${cur_datetime}.htxerr
125
126 File Exist On OS /tmp/htxstats
127 ${htx_stats}= Execute Command On BMC cat /tmp/htxstats
128 Write Log Data To File
129 ... ${htx_stats} ${htx_log_dir_path}/${OS_HOST}_${cur_datetime}.htxstats
130
George Keishingcff7aa02017-05-16 08:05:10 -0500131
132REST Upload File To BMC
133 [Documentation] Upload a file via REST to BMC.
134
135 # Generate 32 MB file size
136 Run dd if=/dev/zero of=dummyfile bs=1 count=0 seek=32MB
137 OperatingSystem.File Should Exist dummyfile
138
139 # Get the content of the file and upload to BMC
140 ${image_data}= OperatingSystem.Get Binary File dummyfile
141
142 # Get REST session to BMC
143 Initialize OpenBMC
144
145 # Create the REST payload headers and data
146 ${data}= Create Dictionary data ${image_data}
147 ${headers}= Create Dictionary Content-Type=application/octet-stream
148 ... Accept=application/octet-stream
149 Set To Dictionary ${data} headers ${headers}
150
151 ${resp}= Post Request openbmc /upload/image &{data}
152 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
153
154 # Delete uploaded image file.
155 # TODO: Delete via REST openbmc/openbmc#1550
156 # Take SSH connection to BMC and switch to BMC connection to perform
157 # the task.
158 &{bmc_connection_args}= Create Dictionary alias=bmc_connection
159 Open Connection And Log In &{bmc_connection_args}
160
161 # Currently OS SSH session is active, switch to BMC connection.
162 Switch Connection bmc_connection
163 Execute Command On BMC rm -f /tmp/images/*
164
165 # Switch back to OS SSH connection.
166 Switch Connection os_connection
167
George Keishing4bbf5202017-05-18 06:55:53 -0500168
169Check For Errors On OS Dmesg Log
170 [Documentation] Check if dmesg has nvidia errors logged.
171
172 ${dmesg_log}= Execute Command On OS dmesg | egrep '${ERROR_REGEX}'
173 # To enable multiple string check.
Steven Sombar0278b132018-01-09 14:41:32 -0600174 Should Not Contain ${dmesg_log} ${ERROR_DBE_MSG}
George Keishing4bbf5202017-05-18 06:55:53 -0500175
176
177Collect NVIDIA Log File
178 [Documentation] Collect ndivia-smi command output.
George Keishing664a0162017-06-05 12:24:24 -0500179 [Arguments] ${suffix}
180 # Description of argument(s):
181 # suffix String name to append.
George Keishing4bbf5202017-05-18 06:55:53 -0500182
183 # Collects the output of ndivia-smi cmd output.
George Keishing4bbf5202017-05-18 06:55:53 -0500184 # +-----------------------------------------------------------------------------+
185 # | NVIDIA-SMI 361.89 Driver Version: 361.89 |
186 # |-------------------------------+----------------------+----------------------+
187 # | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
188 # | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
189 # |===============================+======================+======================|
190 # | 0 Tesla P100-SXM2... On | 0002:01:00.0 Off | 0 |
191 # | N/A 25C P0 35W / 300W | 931MiB / 16280MiB | 0% Default |
192 # +-------------------------------+----------------------+----------------------+
193 # | 1 Tesla P100-SXM2... On | 0003:01:00.0 Off | 0 |
194 # | N/A 26C P0 40W / 300W | 1477MiB / 16280MiB | 0% Default |
195 # +-------------------------------+----------------------+----------------------+
196 # | 2 Tesla P100-SXM2... On | 0006:01:00.0 Off | 0 |
197 # | N/A 25C P0 35W / 300W | 931MiB / 16280MiB | 0% Default |
198 # +-------------------------------+----------------------+----------------------+
199 # | 3 Tesla P100-SXM2... On | 0007:01:00.0 Off | 0 |
200 # | N/A 44C P0 290W / 300W | 965MiB / 16280MiB | 99% Default |
201 # +-------------------------------+----------------------+----------------------+
202 # +-----------------------------------------------------------------------------+
203 # | Processes: GPU Memory |
204 # | GPU PID Type Process name Usage |
205 # |=============================================================================|
206 # | 0 28459 C hxenvidia 929MiB |
207 # | 1 28460 C hxenvidia 1475MiB |
208 # | 2 28461 C hxenvidia 929MiB |
209 # | 3 28462 C hxenvidia 963MiB |
210 # +-----------------------------------------------------------------------------+
211
212 # Create logs directory and get current datetime.
213 Create Directory ${htx_log_dir_path}
214 ${cur_datetime}= Get Current Date result_format=%Y%m%d%H%M%S%f
215
Steven Sombar0278b132018-01-09 14:41:32 -0600216 ${nvidia_out} ${stderr} ${rc}= OS Execute Command nvidia-smi
George Keishing4bbf5202017-05-18 06:55:53 -0500217 Write Log Data To File
George Keishing664a0162017-06-05 12:24:24 -0500218 ... ${nvidia_out}
219 ... ${htx_log_dir_path}/${OS_HOST}_${cur_datetime}.nvidia_${suffix}
George Keishingbbfec9e2017-05-17 10:47:21 -0500220
221
Steven Sombar0278b132018-01-09 14:41:32 -0600222Get GPU Power Limit
223 [Documentation] Get NVIDIA GPU maximum permitted power draw.
George Keishingbbfec9e2017-05-17 10:47:21 -0500224
Steven Sombar0278b132018-01-09 14:41:32 -0600225 # nvidia-smi --query-gpu=power.limit --format=csv returns
226 # power.limit [W]
227 # 300.00 W
228 # 300.00 W
229 # 300.00 W
230 # 300.00 W
George Keishingbbfec9e2017-05-17 10:47:21 -0500231
Steven Sombar0278b132018-01-09 14:41:32 -0600232 ${cmd}= Catenate nvidia-smi --query-gpu=power.limit
233 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
234 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
235 # Allow for sensor overshoot. That is, max power reported for
236 # a GPU could be a few watts above the limit.
237 ${power_max}= Evaluate ${nvidia_out}+${7.00}
238 [Return] ${power_max}
239
240
241Get GPU Power
242 [Documentation] Get the GPU power dissipation.
243
244 # nvidia-smi --query-gpu=power.draw --format=csv returns
245 # power.draw [W]
246 # 34.12 W
247 # 34.40 W
248 # 36.55 W
249 # 36.05 W
250
251 ${cmd}= Catenate nvidia-smi --query-gpu=power.draw
252 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
253 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
254 [Return] ${nvidia_out}
255
256
257Get GPU Temperature Limit
258 [Documentation] Get NVIDIA GPU maximum permitted temperature.
259
260 # nvidia-smi -q -d TEMPERATURE | grep "GPU Max" returns
261 # GPU Max Operating Temp : 83 C
262 # GPU Max Operating Temp : 83 C
263 # GPU Max Operating Temp : 83 C
264 # GPU Max Operating Temp : 83 C
265
266 ${cmd}= Catenate nvidia-smi -q -d TEMPERATURE | grep "GPU Max"
267 ... | cut -f 2 -d ":" | tr -dc '0-9\n' | sort -n -u | tail -n 1
268 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
269 [Return] ${nvidia_out}
270
271
272Get GPU Temperature
273 [Documentation] Get the GPU temperature.
274
275 # nvidia-smi --query-gpu=temperature.gpu --format=csv returns
276 # 38
277 # 41
278 # 38
279 # 40
280
281 ${cmd}= Catenate nvidia-smi --query-gpu=temperature.gpu
282 ... --format=csv | sort -n -u | tail -n 1
283 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
284 [Return] ${nvidia_out}
285
286
287Get GPU Clock Limit
288 [Documentation] Get NVIDIA GPU maximum permitted graphics clock.
289
290 # nvidia-smi --query-gpu=clocks.max.gr --format=csv returns
291 # 1530 MHz
292 # 1530 MHz
293 # 1530 MHz
294 # 1530 MHz
295
296 ${cmd}= Catenate nvidia-smi --query-gpu=clocks.max.gr
297 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
298 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
299 [Return] ${nvidia_out}
300
301
302Get GPU Clock
303 [Documentation] Get the highest assigned value of the GPU graphics clock.
304
305 # nvidia-smi --query-gpu=clocks.gr --format=csv returns
306 # 1230 MHz
307 # 1230 MHz
308 # 135 MHz
309 # 150 MHz
310
311 ${cmd}= Catenate nvidia-smi --query-gpu=clocks.gr
312 ... --format=csv | cut -f 1 -d ' ' | sort -n -u | tail -n 1
313 ${nvidia_out} ${stderr} ${rc}= OS Execute Command ${cmd}
314 [Return] ${nvidia_out}
315
316
317Count GPUs From BMC
318 [Documentation] Determine number of GPUs from the BMC. Hostboot
319 ... needs to have been run previously because the BMC gets GPU data
320 ... from Hostboot.
321
322 # Example of gv* endpoint data:
323 # "/xyz/openbmc_project/inventory/system/chassis/motherboard/gv100card0": {
324 # "Functional": 1,
325 # "Present": 1,
326 # "PrettyName": ""
327 # },
328
329 ${num_bmc_gpus}= Set Variable ${0}
330
331 ${gpu_list}= Get Endpoint Paths
332 ... ${HOST_INVENTORY_URI}system/chassis/motherboard gv*
333
334 :FOR ${gpu_uri} IN @{gpu_list}
335 \ ${present}= Read Attribute ${gpu_uri} Present
336 \ ${state}= Read Attribute ${gpu_uri} Functional
337 \ Rpvars gpu_uri present state
338 \ ${num_bmc_gpus}= Run Keyword If ${present} and ${state}
339 ... Evaluate ${num_bmc_gpus}+${1}
340 [Return] ${num_bmc_gpus}
George Keishingbbfec9e2017-05-17 10:47:21 -0500341
342
343Create Default MDT Profile
344 [Documentation] Create default mdt.bu profile and run.
345
346 Rprint Timen Create HTX mdt profile.
347
348 ${profile}= Execute Command On OS htxcmdline -createmdt
349 Rprintn ${profile}
350 Should Contain ${profile} mdts are created successfully
351
352
353Run MDT Profile
354 [Documentation] Load user pre-defined MDT profile.
355
356 Rprint Timen Start HTX mdt profile execution.
357 ${htx_run}= Execute Command On OS
358 ... htxcmdline -run -mdt ${HTX_MDT_PROFILE}
359 Rprintn ${htx_run}
360 Should Contain ${htx_run} Activated
361
362
363Check HTX Run Status
364 [Documentation] Get HTX exerciser status and check for error.
365
366 Rprint Timen Check HTX mdt Status and error.
367 ${status}= Execute Command On OS
368 ... htxcmdline -status -mdt ${HTX_MDT_PROFILE}
369 Rprintn ${status}
370
371 ${errlog}= Execute Command On OS htxcmdline -geterrlog
372 Rprintn ${errlog}
373
374 Should Contain ${errlog} file </tmp/htxerr> is empty
375
376
377Shutdown HTX Exerciser
378 [Documentation] Shut down HTX exerciser run.
379
380 Rprint Timen Shutdown HTX Run
381 ${shutdown}= Execute Command On OS
382 ... htxcmdline -shutdown -mdt ${HTX_MDT_PROFILE}
383 Rprintn ${shutdown}
384 Should Contain ${shutdown} shutdown successfully
385
Steven Sombar130a04f2017-07-16 10:02:37 -0500386
387Create JSON Inventory File
388 [Documentation] Create a JSON inventory file, and make a YAML copy.
389 [Arguments] ${json_file_path}
390 # Description of argument:
391 # json_file_path Where the inventory file is wrtten to.
392
393 Login To OS
394 Compile Inventory JSON
395 Run json2yaml ${json_tmp_file_path} ${yaml_file_path}
396 # Format to JSON pretty print to file.
397 Run python -m json.tool ${json_tmp_file_path} > ${json_file_path}
398 OperatingSystem.File Should Exist ${json_file_path}
399
400
401Compile Inventory JSON
402 [Documentation] Compile the Inventory into a JSON file.
403 Create File ${json_tmp_file_path}
404 Write New JSON List ${json_tmp_file_path} Inventory
405 Retrieve HW Info And Write processor ${json_tmp_file_path}
406 Retrieve HW Info And Write memory ${json_tmp_file_path}
407 Retrieve HW Info And Write List ${I/O} ${json_tmp_file_path} I/O last
408 Close New JSON List ${json_tmp_file_path}
409
410Write New JSON List
411 [Documentation] Start a new JSON list element in file.
412 [Arguments] ${json_tmp_file_path} ${json_field_name}
413 # Description of argument(s):
414 # json_tmp_file_path Name of file to write to.
415 # json_field_name Name to give json list element.
416 Append to File ${json_tmp_file_path} { "${json_field_name}" : [
417
418Close New JSON List
419 [Documentation] Close JSON list element in file.
420 [Arguments] ${json_tmp_file_path}
421 # Description of argument(s):
422 # json_tmp_file_path Path of file to write to.
423 Append to File ${json_tmp_file_path} ]}
424
425Retrieve HW Info And Write
426 [Documentation] Retrieve and write info, add a comma if not last item.
427 [Arguments] ${class} ${json_tmp_file_path} ${last}=false
428 # Description of argument(s):
429 # class Device class to retrieve with lshw.
430 # json_tmp_file_path Path of file to write to.
431 # last Is this the last element in the parent JSON?
432 Write New JSON List ${json_tmp_file_path} ${class}
433 ${output} = Retrieve Hardware Info ${class}
434 ${output} = Clean Up String ${output}
435 Run Keyword if ${output.__class__ is not type(None)}
436 ... Append To File ${json_tmp_file_path} ${output}
437 Close New JSON List ${json_tmp_file_path}
438 Run Keyword if '${last}' == 'false'
439 ... Append to File ${json_tmp_file_path} ,
440
441Retrieve HW Info And Write List
442 [Documentation] Does a Retrieve/Write with a list of classes and
443 ... encapsulates them into one large JSON element.
444 [Arguments] ${list} ${json_tmp_file_path} ${json_field_name}
445 ... ${last}=false
446 # Description of argument(s):
447 # list The list of devices classes to retrieve with lshw.
448 # json_tmp_file_path Path of file to write to.
449 # json_field_name Name of the JSON element to encapsulate this list.
450 # last Is this the last element in the parent JSON?
451 Write New JSON List ${json_tmp_file_path} ${json_field_name}
452 : FOR ${class} IN @{list}
453 \ ${tail} Get From List ${list} -1
454 \ Run Keyword if '${tail}' == '${class}'
455 \ ... Retrieve HW Info And Write ${class} ${json_tmp_file_path} true
456 \ ... ELSE Retrieve HW Info And Write ${class} ${json_tmp_file_path}
457 Close New JSON List ${json_tmp_file_path}
458 Run Keyword if '${last}' == 'false'
459 ... Append to File ${json_tmp_file_path} ,
460
461Retrieve Hardware Info
462 [Documentation] Retrieves the lshw output of the device class as JSON.
463 [Arguments] ${class}
464 # Description of argument(s):
465 # class Device class to retrieve with lshw.
466 ${output} = Execute Command On OS lshw -c ${class} -json
467 ${output} = Verify JSON string ${output}
468 [Return] ${output}
469
470Verify JSON String
Gunnar Mills28e403b2017-10-25 16:16:38 -0500471 [Documentation] Ensure the JSON string content is separated by commas.
Steven Sombar130a04f2017-07-16 10:02:37 -0500472 [Arguments] ${unver_string}
473 # Description of argument(s):
474 # unver_string JSON String we will be checking for lshw comma errors.
475 ${unver_string} = Convert to String ${unver_string}
476 ${ver_string} = Replace String Using Regexp ${unver_string} }\\s*{ },{
477 [Return] ${ver_string}
478
479Clean Up String
480 [Documentation] Remove extra whitespace and trailing commas.
481 [Arguments] ${dirty_string}
482 # Description of argument(s):
483 # dirty_string String that will be space stripped and have comma removed.
484 ${clean_string} = Strip String ${dirty_string}
485 ${last_char} = Get Substring ${clean_string} -1
486 ${trimmed_string} = Get Substring ${clean_string} 0 -1
487 ${clean_string} = Set Variable If '${last_char}' == ','
488 ... ${trimmed_string} ${clean_string}
489 [Return] ${clean_string}