George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Keywords for system related test. This is a subset of the |
| 3 | ... utils.robot. This resource file keywords is specifically |
| 4 | ... define for system test use cases. |
| 5 | |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 6 | Library ../lib/gen_robot_keyword.py |
George Keishing | cff7aa0 | 2017-05-16 08:05:10 -0500 | [diff] [blame] | 7 | Library OperatingSystem |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 8 | Resource ../extended/obmc_boot_test_resource.robot |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 9 | Resource ../lib/utils.robot |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 10 | Resource ../lib/state_manager.robot |
George Keishing | cff7aa0 | 2017-05-16 08:05:10 -0500 | [diff] [blame] | 11 | Resource ../lib/rest_client.robot |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 12 | |
George Keishing | 4ef2908 | 2017-05-13 05:01:23 -0500 | [diff] [blame] | 13 | Library OperatingSystem |
| 14 | Library DateTime |
| 15 | |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 16 | *** Variables *** |
| 17 | |
George Keishing | 4ef2908 | 2017-05-13 05:01:23 -0500 | [diff] [blame] | 18 | ${htx_log_dir_path} ${EXECDIR}${/}logs${/} |
| 19 | |
| 20 | |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 21 | *** Keywords *** |
| 22 | |
| 23 | Execute Command On OS |
| 24 | [Documentation] Execute given command on OS and return output. |
| 25 | [Arguments] ${command} |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 26 | # Description of argument(s): |
| 27 | # command Shell command to be executed on OS. |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 28 | ${stdout} ${stderr}= Execute Command ${command} return_stderr=True |
| 29 | Should Be Empty ${stderr} |
| 30 | [Return] ${stdout} |
| 31 | |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 32 | Login To OS |
| 33 | [Documentation] Login to OS Host. |
| 34 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
| 35 | ... ${os_password}=${OS_PASSWORD} |
George Keishing | cff7aa0 | 2017-05-16 08:05:10 -0500 | [diff] [blame] | 36 | ... ${alias_name}=os_connection |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 37 | # Description of argument(s): |
| 38 | # os_host IP address of the OS Host. |
| 39 | # os_username OS Host Login user name. |
| 40 | # os_password OS Host Login passwrd. |
George Keishing | cff7aa0 | 2017-05-16 08:05:10 -0500 | [diff] [blame] | 41 | # alias_name Default OS SSH session connection alias name. |
| 42 | # TODO: Generalize alias naming using openbmc/openbmc-test-automation#633 |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 43 | |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 44 | Ping Host ${os_host} |
George Keishing | cff7aa0 | 2017-05-16 08:05:10 -0500 | [diff] [blame] | 45 | Open Connection ${os_host} alias=${alias_name} |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 46 | Login ${os_username} ${os_password} |
| 47 | |
| 48 | |
George Keishing | 88366b3 | 2017-05-12 13:50:48 -0500 | [diff] [blame] | 49 | Tool Exist |
| 50 | [Documentation] Check whether given tool is installed on OS. |
| 51 | [Arguments] ${tool_name} |
| 52 | # Description of argument(s): |
| 53 | # tool_name Tool name whose existence is to be checked. |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 54 | Login To OS |
George Keishing | 88366b3 | 2017-05-12 13:50:48 -0500 | [diff] [blame] | 55 | ${output}= Execute Command On OS which ${tool_name} |
| 56 | Should Contain ${output} ${tool_name} |
| 57 | ... msg=Please install ${tool_name} tool. |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 58 | |
| 59 | |
| 60 | Boot To OS |
| 61 | [Documentation] Boot host OS. |
| 62 | Run Key OBMC Boot Test \ REST Power On |
| 63 | |
| 64 | |
| 65 | Power Off Host |
| 66 | [Documentation] Power off host. |
| 67 | Run Key OBMC Boot Test \ REST Power Off |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 68 | |
George Keishing | 6fec3ab | 2017-05-05 10:45:08 -0500 | [diff] [blame] | 69 | |
| 70 | File Exist On OS |
| 71 | [Documentation] Check if the given file path exist on OS. |
| 72 | [Arguments] ${file_path} |
| 73 | # Description of argument(s): |
| 74 | # file_path Absolute file path. |
| 75 | |
| 76 | Login To OS |
| 77 | ${out}= Execute Command On OS ls ${file_path} |
| 78 | Log To Console \n File Exist: ${out} |
| 79 | |
George Keishing | 8740a0c | 2017-05-13 07:19:16 -0500 | [diff] [blame] | 80 | |
| 81 | Is HTX Running |
| 82 | [Documentation] Check if the HTX exerciser is currently running. |
| 83 | |
| 84 | ${status}= Execute Command On OS htxcmdline -status |
| 85 | Should Not Contain ${status} Daemon state is <IDLE> |
George Keishing | 4ef2908 | 2017-05-13 05:01:23 -0500 | [diff] [blame] | 86 | |
| 87 | |
| 88 | Write Log Data To File |
| 89 | [Documentation] Write log data to the logs directory. |
| 90 | [Arguments] ${data}= ${log_file_path}= |
| 91 | # Description of argument(s): |
| 92 | # data String buffer. |
| 93 | # log_file_path The log file path. |
| 94 | |
| 95 | Create File ${log_file_path} ${data} |
| 96 | |
| 97 | |
| 98 | Collect HTX Log Files |
| 99 | [Documentation] Collect status and error log files. |
| 100 | # Collects the following files: |
| 101 | # HTX error log file /tmp/htxerr |
| 102 | # HTX status log file /tmp/htxstats |
| 103 | |
| 104 | # Create logs directory and get current datetime. |
| 105 | Create Directory ${htx_log_dir_path} |
| 106 | ${cur_datetime}= Get Current Date result_format=%Y%m%d%H%M%S%f |
| 107 | |
| 108 | File Exist On OS /tmp/htxerr |
| 109 | ${htx_err}= Execute Command On BMC cat /tmp/htxerr |
| 110 | Write Log Data To File |
| 111 | ... ${htx_err} ${htx_log_dir_path}/${OS_HOST}${cur_datetime}.htxerr |
| 112 | |
| 113 | File Exist On OS /tmp/htxstats |
| 114 | ${htx_stats}= Execute Command On BMC cat /tmp/htxstats |
| 115 | Write Log Data To File |
| 116 | ... ${htx_stats} ${htx_log_dir_path}/${OS_HOST}_${cur_datetime}.htxstats |
| 117 | |
George Keishing | cff7aa0 | 2017-05-16 08:05:10 -0500 | [diff] [blame] | 118 | |
| 119 | REST Upload File To BMC |
| 120 | [Documentation] Upload a file via REST to BMC. |
| 121 | |
| 122 | # Generate 32 MB file size |
| 123 | Run dd if=/dev/zero of=dummyfile bs=1 count=0 seek=32MB |
| 124 | OperatingSystem.File Should Exist dummyfile |
| 125 | |
| 126 | # Get the content of the file and upload to BMC |
| 127 | ${image_data}= OperatingSystem.Get Binary File dummyfile |
| 128 | |
| 129 | # Get REST session to BMC |
| 130 | Initialize OpenBMC |
| 131 | |
| 132 | # Create the REST payload headers and data |
| 133 | ${data}= Create Dictionary data ${image_data} |
| 134 | ${headers}= Create Dictionary Content-Type=application/octet-stream |
| 135 | ... Accept=application/octet-stream |
| 136 | Set To Dictionary ${data} headers ${headers} |
| 137 | |
| 138 | ${resp}= Post Request openbmc /upload/image &{data} |
| 139 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 140 | |
| 141 | # Delete uploaded image file. |
| 142 | # TODO: Delete via REST openbmc/openbmc#1550 |
| 143 | # Take SSH connection to BMC and switch to BMC connection to perform |
| 144 | # the task. |
| 145 | &{bmc_connection_args}= Create Dictionary alias=bmc_connection |
| 146 | Open Connection And Log In &{bmc_connection_args} |
| 147 | |
| 148 | # Currently OS SSH session is active, switch to BMC connection. |
| 149 | Switch Connection bmc_connection |
| 150 | Execute Command On BMC rm -f /tmp/images/* |
| 151 | |
| 152 | # Switch back to OS SSH connection. |
| 153 | Switch Connection os_connection |
| 154 | |