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 |
| 7 | Resource ../extended/obmc_boot_test_resource.robot |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 8 | Resource ../lib/utils.robot |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 9 | Resource ../lib/state_manager.robot |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 10 | |
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 | |
George Keishing | 4ef2908 | 2017-05-13 05:01:23 -0500 | [diff] [blame] | 16 | ${htx_log_dir_path} ${EXECDIR}${/}logs${/} |
| 17 | |
| 18 | |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 19 | *** Keywords *** |
| 20 | |
| 21 | Execute Command On OS |
| 22 | [Documentation] Execute given command on OS and return output. |
| 23 | [Arguments] ${command} |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 24 | # Description of argument(s): |
| 25 | # command Shell command to be executed on OS. |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 26 | ${stdout} ${stderr}= Execute Command ${command} return_stderr=True |
| 27 | Should Be Empty ${stderr} |
| 28 | [Return] ${stdout} |
| 29 | |
| 30 | |
| 31 | Login To OS |
| 32 | [Documentation] Login to OS Host. |
| 33 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
| 34 | ... ${os_password}=${OS_PASSWORD} |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 35 | # Description of argument(s): |
| 36 | # os_host IP address of the OS Host. |
| 37 | # os_username OS Host Login user name. |
| 38 | # os_password OS Host Login passwrd. |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 39 | |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 40 | Ping Host ${os_host} |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 41 | Open Connection ${os_host} |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 42 | Login ${os_username} ${os_password} |
| 43 | |
| 44 | |
George Keishing | 88366b3 | 2017-05-12 13:50:48 -0500 | [diff] [blame] | 45 | Tool Exist |
| 46 | [Documentation] Check whether given tool is installed on OS. |
| 47 | [Arguments] ${tool_name} |
| 48 | # Description of argument(s): |
| 49 | # tool_name Tool name whose existence is to be checked. |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 50 | Login To OS |
George Keishing | 88366b3 | 2017-05-12 13:50:48 -0500 | [diff] [blame] | 51 | ${output}= Execute Command On OS which ${tool_name} |
| 52 | Should Contain ${output} ${tool_name} |
| 53 | ... msg=Please install ${tool_name} tool. |
George Keishing | 91c852f | 2017-05-03 02:48:21 -0500 | [diff] [blame] | 54 | |
| 55 | |
| 56 | Boot To OS |
| 57 | [Documentation] Boot host OS. |
| 58 | Run Key OBMC Boot Test \ REST Power On |
| 59 | |
| 60 | |
| 61 | Power Off Host |
| 62 | [Documentation] Power off host. |
| 63 | Run Key OBMC Boot Test \ REST Power Off |
George Keishing | 0fff68a | 2017-04-27 22:25:49 -0500 | [diff] [blame] | 64 | |
George Keishing | 6fec3ab | 2017-05-05 10:45:08 -0500 | [diff] [blame] | 65 | |
| 66 | File Exist On OS |
| 67 | [Documentation] Check if the given file path exist on OS. |
| 68 | [Arguments] ${file_path} |
| 69 | # Description of argument(s): |
| 70 | # file_path Absolute file path. |
| 71 | |
| 72 | Login To OS |
| 73 | ${out}= Execute Command On OS ls ${file_path} |
| 74 | Log To Console \n File Exist: ${out} |
| 75 | |
George Keishing | 8740a0c | 2017-05-13 07:19:16 -0500 | [diff] [blame] | 76 | |
| 77 | Is HTX Running |
| 78 | [Documentation] Check if the HTX exerciser is currently running. |
| 79 | |
| 80 | ${status}= Execute Command On OS htxcmdline -status |
| 81 | Should Not Contain ${status} Daemon state is <IDLE> |
George Keishing | 4ef2908 | 2017-05-13 05:01:23 -0500 | [diff] [blame] | 82 | |
| 83 | |
| 84 | Write Log Data To File |
| 85 | [Documentation] Write log data to the logs directory. |
| 86 | [Arguments] ${data}= ${log_file_path}= |
| 87 | # Description of argument(s): |
| 88 | # data String buffer. |
| 89 | # log_file_path The log file path. |
| 90 | |
| 91 | Create File ${log_file_path} ${data} |
| 92 | |
| 93 | |
| 94 | Collect HTX Log Files |
| 95 | [Documentation] Collect status and error log files. |
| 96 | # Collects the following files: |
| 97 | # HTX error log file /tmp/htxerr |
| 98 | # HTX status log file /tmp/htxstats |
| 99 | |
| 100 | # Create logs directory and get current datetime. |
| 101 | Create Directory ${htx_log_dir_path} |
| 102 | ${cur_datetime}= Get Current Date result_format=%Y%m%d%H%M%S%f |
| 103 | |
| 104 | File Exist On OS /tmp/htxerr |
| 105 | ${htx_err}= Execute Command On BMC cat /tmp/htxerr |
| 106 | Write Log Data To File |
| 107 | ... ${htx_err} ${htx_log_dir_path}/${OS_HOST}${cur_datetime}.htxerr |
| 108 | |
| 109 | File Exist On OS /tmp/htxstats |
| 110 | ${htx_stats}= Execute Command On BMC cat /tmp/htxstats |
| 111 | Write Log Data To File |
| 112 | ... ${htx_stats} ${htx_log_dir_path}/${OS_HOST}_${cur_datetime}.htxstats |
| 113 | |