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