George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 1 | *** Settings *** |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 2 | Documentation Keywords for system test. |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 3 | |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 4 | Library ../lib/gen_robot_keyword.py |
Steven Sombar | 07be374 | 2018-01-11 13:02:40 -0600 | [diff] [blame] | 5 | Resource ../lib/boot_utils.robot |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 6 | Resource ../extended/obmc_boot_test_resource.robot |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 7 | Resource ../lib/utils.robot |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 8 | Resource ../lib/state_manager.robot |
George Keishing | cff7aa0 | 2017-05-16 08:05:10 -0500 | [diff] [blame] | 9 | Resource ../lib/rest_client.robot |
George Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 10 | Resource resource.txt |
George Keishing | 4ef2908 | 2017-05-13 05:01:23 -0500 | [diff] [blame] | 11 | Library OperatingSystem |
| 12 | Library DateTime |
| 13 | |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 14 | *** Variables *** |
| 15 | |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 16 | ${htx_log_dir_path} ${EXECDIR}${/}logs${/} |
George Keishing | 4ef2908 | 2017-05-13 05:01:23 -0500 | [diff] [blame] | 17 | |
George Keishing | 4bbf520 | 2017-05-18 06:55:53 -0500 | [diff] [blame] | 18 | # Error strings to check from dmesg. |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 19 | ${ERROR_REGEX} error|GPU|NVRM|nvidia |
George Keishing | 4bbf520 | 2017-05-18 06:55:53 -0500 | [diff] [blame] | 20 | |
| 21 | # GPU specific error message from dmesg. |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 22 | ${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 Sombar | a2f166c | 2017-08-02 14:22:45 -0500 | [diff] [blame] | 29 | ${json_tmp_file_path} ${EXECDIR}/inventory_temp_file.json |
| 30 | ${yaml_file_path} ${EXECDIR}/inventory_temp_file.yaml |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 31 | |
| 32 | |
George Keishing | 4ef2908 | 2017-05-13 05:01:23 -0500 | [diff] [blame] | 33 | |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 34 | *** Keywords *** |
| 35 | |
| 36 | Execute Command On OS |
| 37 | [Documentation] Execute given command on OS and return output. |
| 38 | [Arguments] ${command} |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 39 | # Description of argument(s): |
| 40 | # command Shell command to be executed on OS. |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 41 | ${stdout} ${stderr}= Execute Command ${command} return_stderr=True |
Steven Sombar | 3ecb689 | 2018-03-23 11:41:08 -0500 | [diff] [blame] | 42 | Should Be Empty ${stderr} msg=Failed running ${command}. stderr=${stderr} |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 43 | [Return] ${stdout} |
| 44 | |
Steven Sombar | 3ecb689 | 2018-03-23 11:41:08 -0500 | [diff] [blame] | 45 | |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 46 | Login To OS |
| 47 | [Documentation] Login to OS Host. |
| 48 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
| 49 | ... ${os_password}=${OS_PASSWORD} |
George Keishing | cff7aa0 | 2017-05-16 08:05:10 -0500 | [diff] [blame] | 50 | ... ${alias_name}=os_connection |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 51 | # 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 Keishing | cff7aa0 | 2017-05-16 08:05:10 -0500 | [diff] [blame] | 55 | # alias_name Default OS SSH session connection alias name. |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 56 | |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 57 | Ping Host ${os_host} |
George Keishing | 664a016 | 2017-06-05 12:24:24 -0500 | [diff] [blame] | 58 | SSHLibrary.Open Connection ${os_host} alias=${alias_name} |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 59 | Login ${os_username} ${os_password} |
| 60 | |
| 61 | |
George Keishing | 88366b3 | 2017-05-12 13:50:48 -0500 | [diff] [blame] | 62 | Tool 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 Onyerikwu | f73a62a | 2018-05-02 10:50:20 -0500 | [diff] [blame] | 67 | |
| 68 | ${output} ${stderr} ${rc}= OS Execute Command which ${tool_name} |
George Keishing | 88366b3 | 2017-05-12 13:50:48 -0500 | [diff] [blame] | 69 | Should Contain ${output} ${tool_name} |
| 70 | ... msg=Please install ${tool_name} tool. |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 71 | |
| 72 | |
| 73 | Boot To OS |
| 74 | [Documentation] Boot host OS. |
| 75 | Run Key OBMC Boot Test \ REST Power On |
| 76 | |
| 77 | |
| 78 | Power Off Host |
| 79 | [Documentation] Power off host. |
| 80 | Run Key OBMC Boot Test \ REST Power Off |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 81 | |
George Keishing | 6fec3ab | 2017-05-05 10:45:08 -0500 | [diff] [blame] | 82 | |
| 83 | File 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 Onyerikwu | f73a62a | 2018-05-02 10:50:20 -0500 | [diff] [blame] | 90 | ${out} ${stderr} ${rc}= OS Execute Command ls ${file_path} |
George Keishing | 6fec3ab | 2017-05-05 10:45:08 -0500 | [diff] [blame] | 91 | Log To Console \n File Exist: ${out} |
| 92 | |
George Keishing | 8740a0c | 2017-05-13 07:19:16 -0500 | [diff] [blame] | 93 | |
| 94 | Is HTX Running |
Steven Sombar | 3ecb689 | 2018-03-23 11:41:08 -0500 | [diff] [blame] | 95 | [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 Onyerikwu | f73a62a | 2018-05-02 10:50:20 -0500 | [diff] [blame] | 102 | ${status} ${stderr} ${rc}= OS Execute Command |
Joy Onyerikwu | 4dbd499 | 2018-05-03 16:03:17 -0500 | [diff] [blame] | 103 | ... 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 Sombar | 3ecb689 | 2018-03-23 11:41:08 -0500 | [diff] [blame] | 108 | |
Steven Sombar | 3ecb689 | 2018-03-23 11:41:08 -0500 | [diff] [blame] | 109 | [Return] ${running} |
George Keishing | 4ef2908 | 2017-05-13 05:01:23 -0500 | [diff] [blame] | 110 | |
| 111 | |
| 112 | Write 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 | |
| 122 | Collect 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 Keishing | cff7aa0 | 2017-05-16 08:05:10 -0500 | [diff] [blame] | 142 | |
| 143 | REST 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 Sombar | 3ecb689 | 2018-03-23 11:41:08 -0500 | [diff] [blame] | 164 | ... msg=Openbmc /upload/image failed. |
George Keishing | cff7aa0 | 2017-05-16 08:05:10 -0500 | [diff] [blame] | 165 | |
George Keishing | cff7aa0 | 2017-05-16 08:05:10 -0500 | [diff] [blame] | 166 | # 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 Keishing | cff7aa0 | 2017-05-16 08:05:10 -0500 | [diff] [blame] | 173 | |
| 174 | # Switch back to OS SSH connection. |
| 175 | Switch Connection os_connection |
| 176 | |
George Keishing | 4bbf520 | 2017-05-18 06:55:53 -0500 | [diff] [blame] | 177 | |
Steven Sombar | 1dc6fa7 | 2018-01-12 10:58:20 -0600 | [diff] [blame] | 178 | Get 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 | |
| 189 | Get 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 | |
| 203 | Get 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 | |
| 214 | Get 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 Keishing | 4bbf520 | 2017-05-18 06:55:53 -0500 | [diff] [blame] | 228 | Check For Errors On OS Dmesg Log |
| 229 | [Documentation] Check if dmesg has nvidia errors logged. |
| 230 | |
Joy Onyerikwu | f73a62a | 2018-05-02 10:50:20 -0500 | [diff] [blame] | 231 | ${dmesg_log} ${stderr} ${rc}= OS Execute Command |
| 232 | ... dmesg | egrep '${ERROR_REGEX}' |
George Keishing | 4bbf520 | 2017-05-18 06:55:53 -0500 | [diff] [blame] | 233 | # To enable multiple string check. |
Steven Sombar | 0278b13 | 2018-01-09 14:41:32 -0600 | [diff] [blame] | 234 | Should Not Contain ${dmesg_log} ${ERROR_DBE_MSG} |
Steven Sombar | 3ecb689 | 2018-03-23 11:41:08 -0500 | [diff] [blame] | 235 | ... msg=OS dmesg shows ${ERROR_DBE_MSG}. |
George Keishing | 4bbf520 | 2017-05-18 06:55:53 -0500 | [diff] [blame] | 236 | |
| 237 | |
| 238 | Collect NVIDIA Log File |
| 239 | [Documentation] Collect ndivia-smi command output. |
George Keishing | 664a016 | 2017-06-05 12:24:24 -0500 | [diff] [blame] | 240 | [Arguments] ${suffix} |
| 241 | # Description of argument(s): |
| 242 | # suffix String name to append. |
George Keishing | 4bbf520 | 2017-05-18 06:55:53 -0500 | [diff] [blame] | 243 | |
| 244 | # Collects the output of ndivia-smi cmd output. |
Steven Sombar | e27cca9 | 2018-02-28 10:56:38 -0600 | [diff] [blame] | 245 | # +--------------------------------------------------------------------+ |
| 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 Keishing | 4bbf520 | 2017-05-18 06:55:53 -0500 | [diff] [blame] | 272 | |
| 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 Sombar | 0278b13 | 2018-01-09 14:41:32 -0600 | [diff] [blame] | 277 | ${nvidia_out} ${stderr} ${rc}= OS Execute Command nvidia-smi |
George Keishing | 4bbf520 | 2017-05-18 06:55:53 -0500 | [diff] [blame] | 278 | Write Log Data To File |
George Keishing | 664a016 | 2017-06-05 12:24:24 -0500 | [diff] [blame] | 279 | ... ${nvidia_out} |
| 280 | ... ${htx_log_dir_path}/${OS_HOST}_${cur_datetime}.nvidia_${suffix} |
George Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 281 | |
| 282 | |
Steven Sombar | 0278b13 | 2018-01-09 14:41:32 -0600 | [diff] [blame] | 283 | Get GPU Power Limit |
| 284 | [Documentation] Get NVIDIA GPU maximum permitted power draw. |
George Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 285 | |
Steven Sombar | 0278b13 | 2018-01-09 14:41:32 -0600 | [diff] [blame] | 286 | # 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 Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 292 | |
Steven Sombar | 0278b13 | 2018-01-09 14:41:32 -0600 | [diff] [blame] | 293 | ${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 | |
| 302 | Get 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 | |
| 318 | Get 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 | |
| 333 | Get 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 Sombar | c02dde8 | 2018-05-01 09:49:14 -0500 | [diff] [blame] | 348 | Get 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 Sombar | 0278b13 | 2018-01-09 14:41:32 -0600 | [diff] [blame] | 371 | Get 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 | |
| 386 | Get 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 | |
| 401 | Count 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 Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 425 | |
| 426 | |
| 427 | Create Default MDT Profile |
| 428 | [Documentation] Create default mdt.bu profile and run. |
| 429 | |
| 430 | Rprint Timen Create HTX mdt profile. |
| 431 | |
Joy Onyerikwu | f73a62a | 2018-05-02 10:50:20 -0500 | [diff] [blame] | 432 | ${profile} ${stderr} ${rc}= OS Execute Command |
| 433 | ... htxcmdline -createmdt |
George Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 434 | Rprintn ${profile} |
| 435 | Should Contain ${profile} mdts are created successfully |
Steven Sombar | 3ecb689 | 2018-03-23 11:41:08 -0500 | [diff] [blame] | 436 | ... msg=Create MDT profile failed. response=${profile} |
George Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 437 | |
| 438 | |
| 439 | Run MDT Profile |
| 440 | [Documentation] Load user pre-defined MDT profile. |
| 441 | |
| 442 | Rprint Timen Start HTX mdt profile execution. |
Joy Onyerikwu | f73a62a | 2018-05-02 10:50:20 -0500 | [diff] [blame] | 443 | ${htx_run} ${stderr} ${rc}= OS Execute Command |
George Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 444 | ... htxcmdline -run -mdt ${HTX_MDT_PROFILE} |
| 445 | Rprintn ${htx_run} |
| 446 | Should Contain ${htx_run} Activated |
Steven Sombar | 3ecb689 | 2018-03-23 11:41:08 -0500 | [diff] [blame] | 447 | ... msg=htxcmdline run mdt did not return "Activated" status. |
George Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 448 | |
| 449 | |
| 450 | Check HTX Run Status |
| 451 | [Documentation] Get HTX exerciser status and check for error. |
Steven Sombar | 9d5fc2d | 2018-04-30 09:09:13 -0500 | [diff] [blame] | 452 | [Arguments] ${sleep_time}=${0} |
Joy Onyerikwu | a807417 | 2018-04-20 07:08:19 -0500 | [diff] [blame] | 453 | |
| 454 | # Description of argument(s): |
| 455 | # sleep_time The amount of time to sleep after checking status. |
George Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 456 | |
| 457 | Rprint Timen Check HTX mdt Status and error. |
Joy Onyerikwu | f73a62a | 2018-05-02 10:50:20 -0500 | [diff] [blame] | 458 | ${htx_status} ${stderr} ${rc}= OS Execute Command |
George Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 459 | ... htxcmdline -status -mdt ${HTX_MDT_PROFILE} |
Steven Sombar | 3ecb689 | 2018-03-23 11:41:08 -0500 | [diff] [blame] | 460 | Rprintn ${htx_status} |
George Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 461 | |
Joy Onyerikwu | f73a62a | 2018-05-02 10:50:20 -0500 | [diff] [blame] | 462 | ${htx_errlog} ${stderr} ${rc}= OS Execute Command |
| 463 | ... htxcmdline -geterrlog |
Steven Sombar | 3ecb689 | 2018-03-23 11:41:08 -0500 | [diff] [blame] | 464 | Rprintn ${htx_errlog} |
George Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 465 | |
Steven Sombar | 3ecb689 | 2018-03-23 11:41:08 -0500 | [diff] [blame] | 466 | Should Contain ${htx_errlog} file </tmp/htxerr> is empty |
| 467 | ... msg=HTX geterrorlog was not empty. |
George Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 468 | |
Steven Sombar | 9d5fc2d | 2018-04-30 09:09:13 -0500 | [diff] [blame] | 469 | Return From Keyword If ${sleep_time} == ${0} |
Joy Onyerikwu | a807417 | 2018-04-20 07:08:19 -0500 | [diff] [blame] | 470 | |
| 471 | Run Key U Sleep \ ${sleep-time} |
| 472 | |
George Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 473 | |
| 474 | Shutdown HTX Exerciser |
| 475 | [Documentation] Shut down HTX exerciser run. |
| 476 | |
| 477 | Rprint Timen Shutdown HTX Run |
Joy Onyerikwu | f73a62a | 2018-05-02 10:50:20 -0500 | [diff] [blame] | 478 | ${shutdown} ${stderr} ${rc}= OS Execute Command |
George Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 479 | ... htxcmdline -shutdown -mdt ${HTX_MDT_PROFILE} |
| 480 | Rprintn ${shutdown} |
Steven Sombar | e27cca9 | 2018-02-28 10:56:38 -0600 | [diff] [blame] | 481 | |
| 482 | ${match_count_no_mdt}= Count Values In List ${shutdown} |
| 483 | ... No MDT is currently running |
| 484 | ${match_count_success}= Count Values In List ${shutdown} |
| 485 | ... shutdown successfully |
| 486 | Run Keyword If ${match_count_no_mdt} == 0 and ${match_count_success} == 0 |
| 487 | ... Fail msg=Shutdown command returned unexpected message. |
| 488 | |
George Keishing | bbfec9e | 2017-05-17 10:47:21 -0500 | [diff] [blame] | 489 | |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 490 | Create JSON Inventory File |
| 491 | [Documentation] Create a JSON inventory file, and make a YAML copy. |
| 492 | [Arguments] ${json_file_path} |
| 493 | # Description of argument: |
| 494 | # json_file_path Where the inventory file is wrtten to. |
| 495 | |
| 496 | Login To OS |
| 497 | Compile Inventory JSON |
| 498 | Run json2yaml ${json_tmp_file_path} ${yaml_file_path} |
| 499 | # Format to JSON pretty print to file. |
| 500 | Run python -m json.tool ${json_tmp_file_path} > ${json_file_path} |
| 501 | OperatingSystem.File Should Exist ${json_file_path} |
Steven Sombar | 3ecb689 | 2018-03-23 11:41:08 -0500 | [diff] [blame] | 502 | ... msg=File ${json_file_path} does not exist. |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 503 | |
| 504 | |
| 505 | Compile Inventory JSON |
| 506 | [Documentation] Compile the Inventory into a JSON file. |
| 507 | Create File ${json_tmp_file_path} |
| 508 | Write New JSON List ${json_tmp_file_path} Inventory |
| 509 | Retrieve HW Info And Write processor ${json_tmp_file_path} |
| 510 | Retrieve HW Info And Write memory ${json_tmp_file_path} |
| 511 | Retrieve HW Info And Write List ${I/O} ${json_tmp_file_path} I/O last |
| 512 | Close New JSON List ${json_tmp_file_path} |
| 513 | |
Steven Sombar | 3ecb689 | 2018-03-23 11:41:08 -0500 | [diff] [blame] | 514 | |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 515 | Write New JSON List |
| 516 | [Documentation] Start a new JSON list element in file. |
| 517 | [Arguments] ${json_tmp_file_path} ${json_field_name} |
| 518 | # Description of argument(s): |
| 519 | # json_tmp_file_path Name of file to write to. |
| 520 | # json_field_name Name to give json list element. |
| 521 | Append to File ${json_tmp_file_path} { "${json_field_name}" : [ |
| 522 | |
Steven Sombar | 3ecb689 | 2018-03-23 11:41:08 -0500 | [diff] [blame] | 523 | |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 524 | Close New JSON List |
| 525 | [Documentation] Close JSON list element in file. |
| 526 | [Arguments] ${json_tmp_file_path} |
| 527 | # Description of argument(s): |
| 528 | # json_tmp_file_path Path of file to write to. |
| 529 | Append to File ${json_tmp_file_path} ]} |
| 530 | |
Steven Sombar | 3ecb689 | 2018-03-23 11:41:08 -0500 | [diff] [blame] | 531 | |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 532 | Retrieve HW Info And Write |
| 533 | [Documentation] Retrieve and write info, add a comma if not last item. |
| 534 | [Arguments] ${class} ${json_tmp_file_path} ${last}=false |
| 535 | # Description of argument(s): |
| 536 | # class Device class to retrieve with lshw. |
| 537 | # json_tmp_file_path Path of file to write to. |
| 538 | # last Is this the last element in the parent JSON? |
| 539 | Write New JSON List ${json_tmp_file_path} ${class} |
| 540 | ${output} = Retrieve Hardware Info ${class} |
| 541 | ${output} = Clean Up String ${output} |
| 542 | Run Keyword if ${output.__class__ is not type(None)} |
| 543 | ... Append To File ${json_tmp_file_path} ${output} |
| 544 | Close New JSON List ${json_tmp_file_path} |
| 545 | Run Keyword if '${last}' == 'false' |
| 546 | ... Append to File ${json_tmp_file_path} , |
| 547 | |
Steven Sombar | 3ecb689 | 2018-03-23 11:41:08 -0500 | [diff] [blame] | 548 | |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 549 | Retrieve HW Info And Write List |
| 550 | [Documentation] Does a Retrieve/Write with a list of classes and |
| 551 | ... encapsulates them into one large JSON element. |
| 552 | [Arguments] ${list} ${json_tmp_file_path} ${json_field_name} |
| 553 | ... ${last}=false |
| 554 | # Description of argument(s): |
| 555 | # list The list of devices classes to retrieve with lshw. |
| 556 | # json_tmp_file_path Path of file to write to. |
| 557 | # json_field_name Name of the JSON element to encapsulate this list. |
| 558 | # last Is this the last element in the parent JSON? |
| 559 | Write New JSON List ${json_tmp_file_path} ${json_field_name} |
| 560 | : FOR ${class} IN @{list} |
| 561 | \ ${tail} Get From List ${list} -1 |
| 562 | \ Run Keyword if '${tail}' == '${class}' |
| 563 | \ ... Retrieve HW Info And Write ${class} ${json_tmp_file_path} true |
| 564 | \ ... ELSE Retrieve HW Info And Write ${class} ${json_tmp_file_path} |
| 565 | Close New JSON List ${json_tmp_file_path} |
| 566 | Run Keyword if '${last}' == 'false' |
| 567 | ... Append to File ${json_tmp_file_path} , |
| 568 | |
Steven Sombar | 3ecb689 | 2018-03-23 11:41:08 -0500 | [diff] [blame] | 569 | |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 570 | Retrieve Hardware Info |
| 571 | [Documentation] Retrieves the lshw output of the device class as JSON. |
| 572 | [Arguments] ${class} |
| 573 | # Description of argument(s): |
| 574 | # class Device class to retrieve with lshw. |
Joy Onyerikwu | f73a62a | 2018-05-02 10:50:20 -0500 | [diff] [blame] | 575 | ${output} ${stderr} ${rc}= OS Execute Command lshw -c ${class} -json |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 576 | ${output} = Verify JSON string ${output} |
| 577 | [Return] ${output} |
| 578 | |
Steven Sombar | 3ecb689 | 2018-03-23 11:41:08 -0500 | [diff] [blame] | 579 | |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 580 | Verify JSON String |
Gunnar Mills | 28e403b | 2017-10-25 16:16:38 -0500 | [diff] [blame] | 581 | [Documentation] Ensure the JSON string content is separated by commas. |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 582 | [Arguments] ${unver_string} |
| 583 | # Description of argument(s): |
| 584 | # unver_string JSON String we will be checking for lshw comma errors. |
| 585 | ${unver_string} = Convert to String ${unver_string} |
| 586 | ${ver_string} = Replace String Using Regexp ${unver_string} }\\s*{ },{ |
| 587 | [Return] ${ver_string} |
| 588 | |
Steven Sombar | 3ecb689 | 2018-03-23 11:41:08 -0500 | [diff] [blame] | 589 | |
Steven Sombar | 130a04f | 2017-07-16 10:02:37 -0500 | [diff] [blame] | 590 | Clean Up String |
| 591 | [Documentation] Remove extra whitespace and trailing commas. |
| 592 | [Arguments] ${dirty_string} |
| 593 | # Description of argument(s): |
| 594 | # dirty_string String that will be space stripped and have comma removed. |
| 595 | ${clean_string} = Strip String ${dirty_string} |
| 596 | ${last_char} = Get Substring ${clean_string} -1 |
| 597 | ${trimmed_string} = Get Substring ${clean_string} 0 -1 |
| 598 | ${clean_string} = Set Variable If '${last_char}' == ',' |
| 599 | ... ${trimmed_string} ${clean_string} |
| 600 | [Return] ${clean_string} |
Joy Onyerikwu | 4cb8c0a | 2018-04-11 18:05:13 -0500 | [diff] [blame] | 601 | |
| 602 | |
| 603 | Get OS Network Interface Names |
| 604 | [Documentation] Return a list of interface names on the OS. |
| 605 | |
| 606 | ${stdout} ${stderr} ${rc}= OS Execute Command ls /sys/class/net |
| 607 | @{interface_names}= Split String ${stdout} |
| 608 | [Return] @{interface_names} |