Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Resource ../lib/resource.txt |
| 3 | Resource ../lib/rest_client.robot |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 4 | Resource ../lib/connection_client.robot |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 5 | Library DateTime |
| 6 | Library Process |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 7 | Library OperatingSystem |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 8 | Library gen_print.py |
| 9 | Library gen_robot_print.py |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 10 | |
| 11 | *** Variables *** |
| 12 | ${SYSTEM_SHUTDOWN_TIME} ${5} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 13 | ${dbuscmdBase} |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 14 | ... dbus-send --system --print-reply --dest=${OPENBMC_BASE_DBUS}.settings.Host |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 15 | ${dbuscmdGet} |
George Keishing | 9485af9 | 2017-01-04 10:21:43 -0600 | [diff] [blame] | 16 | ... ${SETTINGS_URI}host0 org.freedesktop.DBus.Properties.Get |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 17 | # Enable when ready with openbmc/openbmc-test-automation#203 |
| 18 | #${dbuscmdString}= string:"xyz.openbmc_project.settings.Host" string: |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 19 | ${dbuscmdString}= string:"org.openbmc.settings.Host" string: |
| 20 | |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 21 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 22 | # Assign default value to QUIET for programs which may not define it. |
| 23 | ${QUIET} ${0} |
Sivas SRR | ea85d1f | 2016-11-13 22:44:28 -0600 | [diff] [blame] | 24 | ${bmc_mem_free_cmd}= free | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f4 |
| 25 | ${bmc_mem_total_cmd}= free | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f2 |
| 26 | ${bmc_cpu_usage_cmd}= top -n 1 | grep CPU: | cut -c 7-9 |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 27 | |
| 28 | *** Keywords *** |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 29 | Wait For Host To Ping |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 30 | [Arguments] ${host} ${timeout}=${OPENBMC_REBOOT_TIMEOUT}min |
| 31 | ... ${interval}=5 sec |
| 32 | |
| 33 | # host The DNS name or IP of the host to ping. |
| 34 | # timeout The amount of time after which attempts to ping cease. |
| 35 | # interval The amount of time in between attempts to ping. |
| 36 | |
| 37 | Wait Until Keyword Succeeds ${timeout} ${interval} Ping Host ${host} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 38 | |
| 39 | Ping Host |
| 40 | [Arguments] ${host} |
George Keishing | 8a84f95 | 2016-08-25 04:54:53 -0500 | [diff] [blame] | 41 | Should Not Be Empty ${host} msg=No host provided |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 42 | ${RC} ${output}= Run and return RC and Output ping -c 4 ${host} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 43 | Log RC: ${RC}\nOutput:\n${output} |
| 44 | Should be equal ${RC} ${0} |
| 45 | |
| 46 | Get Boot Progress |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 47 | [Arguments] ${quiet}=${QUIET} |
| 48 | |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 49 | ${state}= Read Attribute ${OPENBMC_BASE_URI}sensors/host/BootProgress |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 50 | ... value quiet=${quiet} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 51 | [Return] ${state} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 52 | |
| 53 | Is Power On |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 54 | ${state}= Get Power State |
| 55 | Should be equal ${state} ${1} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 56 | |
| 57 | Is Power Off |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 58 | ${state}= Get Power State |
| 59 | Should be equal ${state} ${0} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 60 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 61 | Initiate Power On |
| 62 | [Documentation] Initiates the power on and waits until the Is Power On |
| 63 | ... keyword returns that the power state has switched to on. |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 64 | [Arguments] ${wait}=${1} |
| 65 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 66 | @{arglist}= Create List |
| 67 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 68 | ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOn |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 69 | ... data=${args} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 70 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 71 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 72 | # Does caller want to wait for power on status? |
| 73 | Run Keyword If '${wait}' == '${0}' Return From Keyword |
| 74 | Wait Until Keyword Succeeds 3 min 10 sec Is Power On |
Rahul Maheshwari | f684ba7 | 2016-10-25 07:24:41 -0500 | [diff] [blame] | 75 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 76 | Initiate Power Off |
| 77 | [Documentation] Initiates the power off and waits until the Is Power Off |
| 78 | ... keyword returns that the power state has switched to off. |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 79 | @{arglist}= Create List |
| 80 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 81 | ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOff |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 82 | ... data=${args} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 83 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 84 | Wait Until Keyword Succeeds 1 min 10 sec Is Power Off |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 85 | |
| 86 | Trigger Warm Reset |
| 87 | log to console "Triggering warm reset" |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 88 | ${data}= create dictionary data=@{EMPTY} |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 89 | ${resp}= openbmc post request |
| 90 | ... ${OPENBMC_BASE_URI}control/bmc0/action/warmReset data=${data} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 91 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 92 | ${session_active}= Check If warmReset is Initiated |
| 93 | Run Keyword If '${session_active}' == '${True}' |
| 94 | ... Fail msg=warm reset didn't occur |
| 95 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 96 | Sleep ${SYSTEM_SHUTDOWN_TIME}min |
| 97 | Wait For Host To Ping ${OPENBMC_HOST} |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 98 | |
| 99 | Check OS |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 100 | [Documentation] Attempts to ping the host OS and then checks that the host |
| 101 | ... OS is up by running an SSH command. |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 102 | |
| 103 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 104 | ... ${os_password}=${OS_PASSWORD} ${quiet}=${QUIET} |
| 105 | ... ${print_string}=${EMPTY} |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 106 | [Teardown] Close Connection |
| 107 | |
| 108 | # os_host The DNS name/IP of the OS host associated with our BMC. |
| 109 | # os_username The username to be used to sign on to the OS host. |
| 110 | # os_password The password to be used to sign on to the OS host. |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 111 | # quiet Indicates whether this keyword should write to console. |
| 112 | # print_string A string to be printed before checking the OS. |
| 113 | |
| 114 | rprint ${print_string} |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 115 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 116 | # Attempt to ping the OS. Store the return code to check later. |
| 117 | ${ping_rc}= Run Keyword and Return Status Ping Host ${os_host} |
| 118 | |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 119 | Open connection ${os_host} |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 120 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 121 | ${status} ${msg}= Run Keyword And Ignore Error Login ${os_username} |
| 122 | ... ${os_password} |
| 123 | ${err_msg1}= Sprint Error ${msg} |
| 124 | ${err_msg}= Catenate SEPARATOR= \n ${err_msg1} |
| 125 | Run Keyword If '${status}' == 'FAIL' Fail msg=${err_msg} |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 126 | ${output} ${stderr} ${rc}= Execute Command uptime return_stderr=True |
| 127 | ... return_rc=True |
| 128 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 129 | ${temp_msg}= Catenate Could not execute a command on the operating |
| 130 | ... system.\n |
| 131 | ${err_msg1}= Sprint Error ${temp_msg} |
| 132 | ${err_msg}= Catenate SEPARATOR= \n ${err_msg1} |
| 133 | |
| 134 | # If the return code returned by "Execute Command" is non-zero, this |
| 135 | # keyword will fail. |
| 136 | Should Be Equal ${rc} ${0} msg=${err_msg} |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 137 | # We will likewise fail if there is any stderr data. |
| 138 | Should Be Empty ${stderr} |
| 139 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 140 | ${temp_msg}= Set Variable Could not ping the operating system.\n |
| 141 | ${err_msg1}= Sprint Error ${temp_msg} |
| 142 | ${err_msg}= Catenate SEPARATOR= \n ${err_msg1} |
| 143 | # We will likewise fail if the OS did not ping, as we could SSH but not |
| 144 | # ping |
| 145 | Should Be Equal As Strings ${ping_rc} ${TRUE} msg=${err_msg} |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 146 | |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 147 | Wait for OS |
| 148 | [Documentation] Waits for the host OS to come up via calls to "Check OS". |
| 149 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
| 150 | ... ${os_password}=${OS_PASSWORD} ${timeout}=${OS_WAIT_TIMEOUT} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 151 | ... ${quiet}=${0} |
| 152 | [Teardown] rprintn |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 153 | |
| 154 | # os_host The DNS name or IP of the OS host associated with our |
| 155 | # BMC. |
| 156 | # os_username The username to be used to sign on to the OS host. |
| 157 | # os_password The password to be used to sign on to the OS host. |
| 158 | # timeout The timeout in seconds indicating how long you're |
| 159 | # willing to wait for the OS to respond. |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 160 | # quiet Indicates whether this keyword should write to console. |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 161 | |
| 162 | # The interval to be used between calls to "Check OS". |
| 163 | ${interval}= Set Variable 5 |
| 164 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 165 | ${message}= Catenate Checking every ${interval} seconds for up to |
| 166 | ... ${timeout} seconds for the operating system to communicate. |
| 167 | rqprint_timen ${message} |
| 168 | |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 169 | Wait Until Keyword Succeeds ${timeout} sec ${interval} Check OS |
| 170 | ... ${os_host} ${os_username} ${os_password} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 171 | ... print_string=\# |
| 172 | |
| 173 | rqprintn |
| 174 | |
| 175 | rqprint_timen The operating system is now communicating. |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 176 | |
| 177 | Get BMC State |
| 178 | [Documentation] Returns the state of the BMC as a string. (i.e: BMC_READY) |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 179 | [Arguments] ${quiet}=${QUIET} |
| 180 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 181 | @{arglist}= Create List |
| 182 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 183 | ${resp}= Call Method ${OPENBMC_BASE_URI}managers/System/ getSystemState |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 184 | ... data=${args} quiet=${quiet} |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 185 | Should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 186 | ${content}= to json ${resp.content} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 187 | [Return] ${content["data"]} |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 188 | |
| 189 | Get Power State |
| 190 | [Documentation] Returns the power state as an integer. Either 0 or 1. |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 191 | [Arguments] ${quiet}=${QUIET} |
| 192 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 193 | @{arglist}= Create List |
| 194 | ${args}= Create Dictionary data=@{arglist} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 195 | |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 196 | ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ getPowerState |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 197 | ... data=${args} quiet=${quiet} |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 198 | Should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 199 | ${content}= to json ${resp.content} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 200 | [Return] ${content["data"]} |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame] | 201 | |
| 202 | Clear BMC Record Log |
| 203 | [Documentation] Clears all the event logs on the BMC. This would be |
| 204 | ... equivalent to ipmitool sel clear. |
| 205 | @{arglist}= Create List |
| 206 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 207 | ${resp}= Call Method |
| 208 | ... ${OPENBMC_BASE_URI}records/events/ clear data=${args} |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame] | 209 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 210 | |
| 211 | Copy PNOR to BMC |
| 212 | Import Library SCPLibrary WITH NAME scp |
| 213 | Open Connection for SCP |
| 214 | Log Copying ${PNOR_IMAGE_PATH} to /tmp |
| 215 | scp.Put File ${PNOR_IMAGE_PATH} /tmp |
| 216 | |
| 217 | Flash PNOR |
| 218 | [Documentation] Calls flash bios update method to flash PNOR image |
Gunnar Mills | 3803280 | 2016-12-12 13:43:40 -0600 | [diff] [blame] | 219 | [Arguments] ${pnor_image} |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame] | 220 | @{arglist}= Create List ${pnor_image} |
| 221 | ${args}= Create Dictionary data=@{arglist} |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 222 | ${resp}= Call Method ${OPENBMC_BASE_URI}control/flash/bios/ update |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 223 | ... data=${args} |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame] | 224 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 225 | Wait Until Keyword Succeeds 2 min 10 sec Is PNOR Flashing |
| 226 | |
| 227 | Get Flash BIOS Status |
| 228 | [Documentation] Returns the status of the flash BIOS API as a string. For |
| 229 | ... example 'Flashing', 'Flash Done', etc |
George Keishing | 85ca05e | 2016-11-30 09:47:18 -0600 | [diff] [blame] | 230 | ${data}= Read Properties ${OPENBMC_BASE_URI}control/flash/bios |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 231 | [Return] ${data['status']} |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame] | 232 | |
| 233 | Is PNOR Flashing |
| 234 | [Documentation] Get BIOS 'Flashing' status. This indicates that PNOR |
| 235 | ... flashing has started. |
| 236 | ${status}= Get Flash BIOS Status |
| 237 | should be equal as strings ${status} Flashing |
| 238 | |
| 239 | Is PNOR Flash Done |
| 240 | [Documentation] Get BIOS 'Flash Done' status. This indicates that the |
| 241 | ... PNOR flashing has completed. |
Leah McNutt | 9ba3227 | 2016-11-17 15:48:39 +0000 | [diff] [blame] | 242 | ${status}= Get Flash BIOS Status |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame] | 243 | should be equal as strings ${status} Flash Done |
| 244 | |
| 245 | Is System State Host Booted |
| 246 | [Documentation] Checks whether system state is HOST_BOOTED. |
| 247 | ${state}= Get BMC State |
| 248 | should be equal as strings ${state} HOST_BOOTED |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 249 | |
| 250 | Verify Ping and REST Authentication |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 251 | ${l_ping}= Run Keyword And Return Status |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 252 | ... Ping Host ${OPENBMC_HOST} |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 253 | Run Keyword If '${l_ping}' == '${False}' |
| 254 | ... Fail msg=Ping Failed |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 255 | |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 256 | ${l_rest}= Run Keyword And Return Status |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 257 | ... Initialize OpenBMC |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 258 | Run Keyword If '${l_rest}' == '${False}' |
| 259 | ... Fail msg=REST Authentication Failed |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 260 | |
| 261 | # Just to make sure the SSH is working for SCP |
| 262 | Open Connection And Log In |
| 263 | ${system} ${stderr}= Execute Command hostname return_stderr=True |
| 264 | Should Be Empty ${stderr} |
| 265 | |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 266 | Check If BMC is Up |
| 267 | [Documentation] Wait for Host to be online. Checks every X seconds |
| 268 | ... interval for Y minutes and fails if timed out. |
| 269 | ... Default MAX timedout is 10 min, interval 10 seconds. |
Gunnar Mills | 3803280 | 2016-12-12 13:43:40 -0600 | [diff] [blame] | 270 | [Arguments] ${max_timeout}=${OPENBMC_REBOOT_TIMEOUT} min |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame] | 271 | ... ${interval}=10 sec |
| 272 | |
| 273 | Wait Until Keyword Succeeds |
| 274 | ... ${max_timeout} ${interval} Verify Ping and REST Authentication |
| 275 | |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 276 | |
| 277 | Check If warmReset is Initiated |
| 278 | [Documentation] Ping would be still alive, so try SSH to connect |
| 279 | ... if fails the ports are down indicating reboot |
| 280 | ... is in progress |
George Keishing | 3c05d35 | 2016-12-13 06:54:50 -0600 | [diff] [blame] | 281 | |
| 282 | # Warm reset adds 3 seconds delay before forcing reboot |
| 283 | # To minimize race conditions, we wait for 7 seconds |
| 284 | Sleep 7s |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 285 | ${alive}= Run Keyword and Return Status |
| 286 | ... Open Connection And Log In |
| 287 | Return From Keyword If '${alive}' == '${False}' ${False} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 288 | [Return] ${True} |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 289 | |
George Keishing | 06ae4aa | 2016-08-30 01:41:28 -0500 | [diff] [blame] | 290 | Flush REST Sessions |
| 291 | [Documentation] Removes all the active session objects |
| 292 | Delete All Sessions |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 293 | |
Sivas SRR | e1143ae | 2016-08-26 22:31:02 -0500 | [diff] [blame] | 294 | Initialize DBUS cmd |
| 295 | [Documentation] Initialize dbus string with property string to extract |
Gunnar Mills | 3803280 | 2016-12-12 13:43:40 -0600 | [diff] [blame] | 296 | [Arguments] ${boot_property} |
Michael Walsh | a6723f2 | 2016-11-22 11:12:01 -0600 | [diff] [blame] | 297 | ${cmd}= Catenate ${dbuscmdBase} ${dbuscmdGet} ${dbuscmdString} |
| 298 | ${cmd}= Catenate ${cmd}${boot_property} |
Sivas SRR | e1143ae | 2016-08-26 22:31:02 -0500 | [diff] [blame] | 299 | Set Global Variable ${dbuscmd} ${cmd} |
| 300 | |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 301 | |
Gunnar Mills | 9c76034 | 2016-12-08 10:12:06 -0600 | [diff] [blame] | 302 | Stop OBMC Console Client |
| 303 | [Documentation] Stop any running obmc_console_client |
| 304 | ... writing to file_path. |
| 305 | [Arguments] ${file_path}=/tmp/obmc-console.log |
| 306 | |
Michael Walsh | 01bd368 | 2017-01-10 11:21:05 -0600 | [diff] [blame] | 307 | ${cmd_buf}= Catenate SEPARATOR=${SPACE} |
| 308 | ... ps ax | grep obmc-console-client | grep ${file_path} | grep -v grep |
| 309 | ... | awk '{print $1}' |
| 310 | |
Gunnar Mills | 9c76034 | 2016-12-08 10:12:06 -0600 | [diff] [blame] | 311 | ${pid}= |
Michael Walsh | 01bd368 | 2017-01-10 11:21:05 -0600 | [diff] [blame] | 312 | ... Execute Command ${cmd_buf} |
Gunnar Mills | 9c76034 | 2016-12-08 10:12:06 -0600 | [diff] [blame] | 313 | |
| 314 | Run Keyword If '${pid}' != '${EMPTY}' |
| 315 | ... Execute Command kill -s KILL ${pid} |
| 316 | ... ELSE Log "No obmc-console-client process running" |
| 317 | |
| 318 | |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 319 | Start SOL Console Logging |
Gunnar Mills | 9c76034 | 2016-12-08 10:12:06 -0600 | [diff] [blame] | 320 | [Documentation] Start a new obmc_console_client process and direct |
| 321 | ... output to a file. |
| 322 | [Arguments] ${file_path}=/tmp/obmc-console.log |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 323 | |
| 324 | Open Connection And Log In |
| 325 | |
Gunnar Mills | 9c76034 | 2016-12-08 10:12:06 -0600 | [diff] [blame] | 326 | Stop OBMC Console Client ${file_path} |
| 327 | |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 328 | Start Command |
Gunnar Mills | 9c76034 | 2016-12-08 10:12:06 -0600 | [diff] [blame] | 329 | ... obmc-console-client > ${file_path} |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 330 | |
| 331 | |
| 332 | Stop SOL Console Logging |
Michael Walsh | 01bd368 | 2017-01-10 11:21:05 -0600 | [diff] [blame] | 333 | [Documentation] Stop obmc_console_client process, if any, and |
| 334 | ... return the console output as a string. |
| 335 | [Arguments] ${file_path}=/tmp/obmc-console.log ${targ_file_path}=${EMPTY} |
| 336 | |
| 337 | # Description of arguments: |
| 338 | # file_path The path on the obmc system where SOL output may be |
| 339 | # found. |
| 340 | # targ_file_path If specified, the file path to which SOL data should be |
| 341 | # written. |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 342 | |
| 343 | Open Connection And Log In |
| 344 | |
Gunnar Mills | 9c76034 | 2016-12-08 10:12:06 -0600 | [diff] [blame] | 345 | Stop OBMC Console Client ${file_path} |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 346 | |
Michael Walsh | 01bd368 | 2017-01-10 11:21:05 -0600 | [diff] [blame] | 347 | ${cmd_buf}= Set Variable cat ${file_path} |
| 348 | |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 349 | ${console} ${stderr}= |
| 350 | ... Execute Command |
Michael Walsh | 01bd368 | 2017-01-10 11:21:05 -0600 | [diff] [blame] | 351 | ... if [ -f ${file_path} ] ; then cat ${file_path} ; fi |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 352 | ... return_stderr=True |
Gunnar Mills | 9c76034 | 2016-12-08 10:12:06 -0600 | [diff] [blame] | 353 | Should Be Empty ${stderr} |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 354 | |
Michael Walsh | 01bd368 | 2017-01-10 11:21:05 -0600 | [diff] [blame] | 355 | Run Keyword If '${targ_file_path}' != '${EMPTY}' |
| 356 | ... Append To File ${targ_file_path} ${console} |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 357 | |
Michael Walsh | 01bd368 | 2017-01-10 11:21:05 -0600 | [diff] [blame] | 358 | [Return] ${console} |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 359 | |
| 360 | Get Time Stamp |
| 361 | [Documentation] Get the current time stamp data |
| 362 | ${cur_time}= Get Current Date result_format=%Y%m%d%H%M%S%f |
Sridevi Ramesh | b96a0c3 | 2016-10-19 05:09:52 -0500 | [diff] [blame] | 363 | [Return] ${cur_time} |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 364 | |
George Keishing | 1b15020 | 2016-09-29 08:51:58 -0500 | [diff] [blame] | 365 | |
| 366 | Verify BMC State |
| 367 | [Documentation] Get the BMC state and verify if the current |
| 368 | ... BMC state is as expected. |
| 369 | [Arguments] ${expected} |
| 370 | |
| 371 | ${current}= Get BMC State |
George Keishing | 8db0e1b | 2016-10-20 13:46:54 -0500 | [diff] [blame] | 372 | Should Contain ${expected} ${current} |
George Keishing | 1b15020 | 2016-09-29 08:51:58 -0500 | [diff] [blame] | 373 | |
Rahul Maheshwari | f684ba7 | 2016-10-25 07:24:41 -0500 | [diff] [blame] | 374 | Start Journal Log |
| 375 | [Documentation] Start capturing journal log to a file in /tmp using |
| 376 | ... journalctl command. By default journal log is collected |
| 377 | ... at /tmp/journal_log else user input location. |
| 378 | ... The File is appended with datetime. |
| 379 | [Arguments] ${file_path}=/tmp/journal_log |
| 380 | |
| 381 | Open Connection And Log In |
| 382 | |
| 383 | ${cur_time}= Get Time Stamp |
| 384 | Set Global Variable ${LOG_TIME} ${cur_time} |
| 385 | Start Command |
| 386 | ... journalctl -f > ${file_path}-${LOG_TIME} |
| 387 | Log Journal Log Started: ${file_path}-${LOG_TIME} |
| 388 | |
| 389 | Stop Journal Log |
| 390 | [Documentation] Stop journalctl process if its running. |
| 391 | ... By default return log from /tmp/journal_log else |
| 392 | ... user input location. |
| 393 | [Arguments] ${file_path}=/tmp/journal_log |
| 394 | |
| 395 | Open Connection And Log In |
| 396 | |
| 397 | ${rc}= |
| 398 | ... Execute Command |
| 399 | ... ps ax | grep journalctl | grep -v grep |
| 400 | ... return_stdout=False return_rc=True |
| 401 | |
| 402 | Return From Keyword If '${rc}' == '${1}' |
| 403 | ... No journal log process running |
| 404 | |
| 405 | ${output} ${stderr}= |
| 406 | ... Execute Command killall journalctl |
| 407 | ... return_stderr=True |
| 408 | Should Be Empty ${stderr} |
| 409 | |
| 410 | ${journal_log} ${stderr}= |
| 411 | ... Execute Command |
| 412 | ... cat ${file_path}-${LOG_TIME} |
| 413 | ... return_stderr=True |
| 414 | Should Be Empty ${stderr} |
| 415 | |
| 416 | Log ${journal_log} |
| 417 | |
| 418 | Execute Command rm ${file_path}-${LOG_TIME} |
| 419 | |
| 420 | [Return] ${journal_log} |
Rahul Maheshwari | 757d80c | 2016-10-17 01:09:55 -0500 | [diff] [blame] | 421 | |
| 422 | Mac Address To Hex String |
| 423 | [Documentation] Converts MAC address into hex format. |
| 424 | ... Example |
| 425 | ... Given the following MAC: 00:01:6C:80:02:78 |
| 426 | ... This keyword will return: 0x00 0x01 0x6C 0x80 0x02 0x78 |
| 427 | ... Description of arguments: |
Michael Walsh | 01bd368 | 2017-01-10 11:21:05 -0600 | [diff] [blame] | 428 | ... i_macaddress MAC address in the following format |
| 429 | ... 00:01:6C:80:02:78 |
Rahul Maheshwari | 757d80c | 2016-10-17 01:09:55 -0500 | [diff] [blame] | 430 | [Arguments] ${i_macaddress} |
| 431 | |
| 432 | ${mac_hex}= Catenate 0x${i_macaddress.replace(':', ' 0x')} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 433 | [Return] ${mac_hex} |
Rahul Maheshwari | 757d80c | 2016-10-17 01:09:55 -0500 | [diff] [blame] | 434 | |
| 435 | IP Address To Hex String |
| 436 | [Documentation] Converts IP address into hex format. |
| 437 | ... Example: |
| 438 | ... Given the following IP: 10.3.164.100 |
| 439 | ... This keyword will return: 0xa 0x3 0xa4 0xa0 |
| 440 | ... Description of arguments: |
Michael Walsh | 01bd368 | 2017-01-10 11:21:05 -0600 | [diff] [blame] | 441 | ... i_ipaddress IP address in the following format |
| 442 | ... 10.10.10.10 |
Rahul Maheshwari | 757d80c | 2016-10-17 01:09:55 -0500 | [diff] [blame] | 443 | [Arguments] ${i_ipaddress} |
| 444 | |
| 445 | @{ip}= Split String ${i_ipaddress} . |
| 446 | ${index}= Set Variable ${0} |
| 447 | |
| 448 | :FOR ${item} IN @{ip} |
| 449 | \ ${hex}= Convert To Hex ${item} prefix=0x lowercase=yes |
| 450 | \ Set List Value ${ip} ${index} ${hex} |
| 451 | \ ${index}= Set Variable ${index + 1} |
| 452 | ${ip_hex}= Catenate @{ip} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 453 | [Return] ${ip_hex} |
Sivas SRR | ea85d1f | 2016-11-13 22:44:28 -0600 | [diff] [blame] | 454 | |
| 455 | BMC CPU Performance Check |
| 456 | [Documentation] Minimal 10% of proc should be free in this instance |
| 457 | |
| 458 | ${bmc_cpu_usage_output} ${stderr}= Execute Command ${bmc_cpu_usage_cmd} |
| 459 | ... return_stderr=True |
| 460 | Should be empty ${stderr} |
| 461 | ${bmc_cpu_percentage}= Fetch From Left ${bmc_cpu_usage_output} % |
| 462 | Should be true ${bmc_cpu_percentage} < 90 |
| 463 | |
| 464 | BMC Mem Performance Check |
| 465 | [Documentation] Minimal 10% of memory should be free in this instance |
| 466 | |
| 467 | ${bmc_mem_free_output} ${stderr}= Execute Command ${bmc_mem_free_cmd} |
| 468 | ... return_stderr=True |
| 469 | Should be empty ${stderr} |
| 470 | |
| 471 | ${bmc_mem_total_output} ${stderr}= Execute Command ${bmc_mem_total_cmd} |
| 472 | ... return_stderr=True |
| 473 | Should be empty ${stderr} |
| 474 | |
| 475 | ${bmc_mem_percentage}= Evaluate ${bmc_mem_free_output}*100 |
| 476 | ${bmc_mem_percentage}= Evaluate |
| 477 | ... ${bmc_mem_percentage}/${bmc_mem_total_output} |
| 478 | Should be true ${bmc_mem_percentage} > 10 |
| 479 | |
| 480 | Check BMC CPU Performance |
| 481 | [Documentation] Minimal 10% of proc should be free in 3 sample |
| 482 | :FOR ${var} IN Range 1 4 |
| 483 | \ BMC CPU Performance check |
| 484 | |
| 485 | Check BMC Mem Performance |
| 486 | [Documentation] Minimal 10% of memory should be free |
| 487 | |
| 488 | :FOR ${var} IN Range 1 4 |
| 489 | \ BMC Mem Performance check |
| 490 | |
Rahul Maheshwari | 9a8d3b1 | 2016-12-05 04:06:16 -0600 | [diff] [blame] | 491 | Get Endpoint Paths |
| 492 | [Documentation] Returns all url paths ending with given endpoint |
| 493 | ... Example: |
| 494 | ... Given the following endpoint: cpu |
Michael Walsh | 01bd368 | 2017-01-10 11:21:05 -0600 | [diff] [blame] | 495 | ... This keyword will return: list of all urls ending with |
| 496 | ... cpu - |
Rahul Maheshwari | 9a8d3b1 | 2016-12-05 04:06:16 -0600 | [diff] [blame] | 497 | ... /org/openbmc/inventory/system/chassis/motherboard/cpu0, |
| 498 | ... /org/openbmc/inventory/system/chassis/motherboard/cpu1 |
| 499 | ... Description of arguments: |
| 500 | ... path URL path for enumeration |
| 501 | ... endpoint string for which url path ending |
| 502 | [Arguments] ${path} ${endpoint} |
| 503 | |
| 504 | ${resp}= Read Properties ${path}/enumerate timeout=30 |
| 505 | log Dictionary ${resp} |
| 506 | |
| 507 | ${list}= Get Dictionary Keys ${resp} |
| 508 | ${resp}= Get Matches ${list} regexp=^.*[0-9a-z_].${endpoint}[0-9]*$ |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 509 | [Return] ${resp} |
Sridevi Ramesh | b96a0c3 | 2016-10-19 05:09:52 -0500 | [diff] [blame] | 510 | |
| 511 | Check Zombie Process |
| 512 | [Documentation] Check if any defunct process exist or not on BMC |
Michael Walsh | 01bd368 | 2017-01-10 11:21:05 -0600 | [diff] [blame] | 513 | ${count} ${stderr} ${rc}= Execute Command ps -o stat | grep Z | wc -l |
Sridevi Ramesh | b96a0c3 | 2016-10-19 05:09:52 -0500 | [diff] [blame] | 514 | ... return_stderr=True return_rc=True |
| 515 | Should Be True ${count}==0 |
| 516 | Should Be Empty ${stderr} |
George Keishing | 5327d01 | 2016-12-08 08:43:29 -0600 | [diff] [blame] | 517 | |
| 518 | Prune Journal Log |
| 519 | [Documentation] Prune archived journal logs. |
| 520 | [Arguments] ${vacuum_size}=1M |
| 521 | |
| 522 | # This keyword can be used to prevent the journal |
| 523 | # log from filling up the /run filesystem. |
| 524 | # This command will retain only the latest logs |
| 525 | # of the user specified size. |
| 526 | |
| 527 | Open Connection And Log In |
| 528 | ${output} ${stderr} ${rc}= |
| 529 | ... Execute Command |
| 530 | ... journalctl --vacuum-size=${vacuum_size} |
| 531 | ... return_stderr=True return_rc=True |
| 532 | |
| 533 | Should Be Equal ${rc} ${0} msg=${stderr} |
| 534 | Should Contain ${stderr} Vacuuming done |