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 |
| 8 | |
| 9 | *** Variables *** |
| 10 | ${SYSTEM_SHUTDOWN_TIME} ${5} |
Sivas SRR | e1143ae | 2016-08-26 22:31:02 -0500 | [diff] [blame] | 11 | ${dbuscmdBase} = dbus-send --system --print-reply --dest=org.openbmc.settings.Host |
| 12 | ${dbuscmdGet} = /org/openbmc/settings/host0 org.freedesktop.DBus.Properties.Get |
| 13 | ${dbuscmdString} = string:"org.openbmc.settings.Host" string: |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 14 | |
| 15 | *** Keywords *** |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 16 | Wait For Host To Ping |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 17 | [Arguments] ${host} ${timeout}=${OPENBMC_REBOOT_TIMEOUT}min |
| 18 | ... ${interval}=5 sec |
| 19 | |
| 20 | # host The DNS name or IP of the host to ping. |
| 21 | # timeout The amount of time after which attempts to ping cease. |
| 22 | # interval The amount of time in between attempts to ping. |
| 23 | |
| 24 | Wait Until Keyword Succeeds ${timeout} ${interval} Ping Host ${host} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 25 | |
| 26 | Ping Host |
| 27 | [Arguments] ${host} |
George Keishing | 8a84f95 | 2016-08-25 04:54:53 -0500 | [diff] [blame] | 28 | Should Not Be Empty ${host} msg=No host provided |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 29 | ${RC} ${output} = Run and return RC and Output ping -c 4 ${host} |
| 30 | Log RC: ${RC}\nOutput:\n${output} |
| 31 | Should be equal ${RC} ${0} |
| 32 | |
| 33 | Get Boot Progress |
| 34 | ${state} = Read Attribute /org/openbmc/sensors/host/BootProgress value |
| 35 | [return] ${state} |
| 36 | |
| 37 | Is Power On |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 38 | ${state}= Get Power State |
| 39 | Should be equal ${state} ${1} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 40 | |
| 41 | Is Power Off |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 42 | ${state}= Get Power State |
| 43 | Should be equal ${state} ${0} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 44 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 45 | Initiate Power On |
| 46 | [Documentation] Initiates the power on and waits until the Is Power On |
| 47 | ... keyword returns that the power state has switched to on. |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 48 | @{arglist}= Create List |
| 49 | ${args}= Create Dictionary data=@{arglist} |
| 50 | ${resp}= Call Method /org/openbmc/control/chassis0/ powerOn data=${args} |
| 51 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 52 | Wait Until Keyword Succeeds 3 min 10 sec Is Power On |
| 53 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 54 | Initiate Power Off |
| 55 | [Documentation] Initiates the power off and waits until the Is Power Off |
| 56 | ... keyword returns that the power state has switched to off. |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 57 | @{arglist}= Create List |
| 58 | ${args}= Create Dictionary data=@{arglist} |
| 59 | ${resp}= Call Method /org/openbmc/control/chassis0/ powerOff data=${args} |
| 60 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 61 | Wait Until Keyword Succeeds 1 min 10 sec Is Power Off |
| 62 | |
| 63 | Trigger Warm Reset |
| 64 | log to console "Triggering warm reset" |
| 65 | ${data} = create dictionary data=@{EMPTY} |
| 66 | ${resp} = openbmc post request /org/openbmc/control/bmc0/action/warmReset data=${data} |
| 67 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 68 | ${session_active}= Check If warmReset is Initiated |
| 69 | Run Keyword If '${session_active}' == '${True}' |
| 70 | ... Fail msg=warm reset didn't occur |
| 71 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 72 | Sleep ${SYSTEM_SHUTDOWN_TIME}min |
| 73 | Wait For Host To Ping ${OPENBMC_HOST} |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 74 | |
| 75 | Check OS |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 76 | [Documentation] Attempts to ping the host OS and then checks that the host |
| 77 | ... OS is up by running an SSH command. |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 78 | |
| 79 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
| 80 | ... ${os_password}=${OS_PASSWORD} |
| 81 | [Teardown] Close Connection |
| 82 | |
| 83 | # os_host The DNS name/IP of the OS host associated with our BMC. |
| 84 | # os_username The username to be used to sign on to the OS host. |
| 85 | # os_password The password to be used to sign on to the OS host. |
| 86 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 87 | # Attempt to ping the OS. Store the return code to check later. |
| 88 | ${ping_rc}= Run Keyword and Return Status Ping Host ${os_host} |
| 89 | |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 90 | Open connection ${os_host} |
| 91 | Login ${os_username} ${os_password} |
| 92 | |
| 93 | ${output} ${stderr} ${rc}= Execute Command uptime return_stderr=True |
| 94 | ... return_rc=True |
| 95 | |
| 96 | # If the return code returned by "Execute Command" is non-zero, this keyword |
| 97 | # will fail. |
| 98 | Should Be Equal ${rc} ${0} |
| 99 | # We will likewise fail if there is any stderr data. |
| 100 | Should Be Empty ${stderr} |
| 101 | |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 102 | # We will likewise fail if the OS did not ping, as we could SSH but not ping |
| 103 | Should Be Equal As Strings ${ping_rc} ${TRUE} |
| 104 | |
Michael Walsh | 49ab0f4 | 2016-07-20 11:44:33 -0500 | [diff] [blame] | 105 | Wait for OS |
| 106 | [Documentation] Waits for the host OS to come up via calls to "Check OS". |
| 107 | [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
| 108 | ... ${os_password}=${OS_PASSWORD} ${timeout}=${OS_WAIT_TIMEOUT} |
| 109 | |
| 110 | # os_host The DNS name or IP of the OS host associated with our |
| 111 | # BMC. |
| 112 | # os_username The username to be used to sign on to the OS host. |
| 113 | # os_password The password to be used to sign on to the OS host. |
| 114 | # timeout The timeout in seconds indicating how long you're |
| 115 | # willing to wait for the OS to respond. |
| 116 | |
| 117 | # The interval to be used between calls to "Check OS". |
| 118 | ${interval}= Set Variable 5 |
| 119 | |
| 120 | Wait Until Keyword Succeeds ${timeout} sec ${interval} Check OS |
| 121 | ... ${os_host} ${os_username} ${os_password} |
root | 442f0ef | 2016-08-04 20:23:05 +0000 | [diff] [blame] | 122 | |
| 123 | Get BMC State |
| 124 | [Documentation] Returns the state of the BMC as a string. (i.e: BMC_READY) |
| 125 | @{arglist}= Create List |
| 126 | ${args}= Create Dictionary data=@{arglist} |
| 127 | ${resp}= Call Method /org/openbmc/managers/System/ getSystemState |
| 128 | ... data=${args} |
| 129 | Should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 130 | ${content}= to json ${resp.content} |
| 131 | [return] ${content["data"]} |
| 132 | |
| 133 | Get Power State |
| 134 | [Documentation] Returns the power state as an integer. Either 0 or 1. |
| 135 | @{arglist}= Create List |
| 136 | ${args}= Create Dictionary data=@{arglist} |
| 137 | ${resp}= Call Method /org/openbmc/control/chassis0/ getPowerState |
| 138 | ... data=${args} |
| 139 | Should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 140 | ${content}= to json ${resp.content} |
| 141 | [return] ${content["data"]} |
Jay Azurin | e4c52eb | 2016-08-16 20:51:10 -0500 | [diff] [blame] | 142 | |
| 143 | Clear BMC Record Log |
| 144 | [Documentation] Clears all the event logs on the BMC. This would be |
| 145 | ... equivalent to ipmitool sel clear. |
| 146 | @{arglist}= Create List |
| 147 | ${args}= Create Dictionary data=@{arglist} |
| 148 | ${resp}= Call Method /org/openbmc/records/events/ clear data=${args} |
| 149 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 150 | |
| 151 | Copy PNOR to BMC |
| 152 | Import Library SCPLibrary WITH NAME scp |
| 153 | Open Connection for SCP |
| 154 | Log Copying ${PNOR_IMAGE_PATH} to /tmp |
| 155 | scp.Put File ${PNOR_IMAGE_PATH} /tmp |
| 156 | |
| 157 | Flash PNOR |
| 158 | [Documentation] Calls flash bios update method to flash PNOR image |
| 159 | [arguments] ${pnor_image} |
| 160 | @{arglist}= Create List ${pnor_image} |
| 161 | ${args}= Create Dictionary data=@{arglist} |
| 162 | ${resp}= Call Method /org/openbmc/control/flash/bios/ update data=${args} |
| 163 | should be equal as strings ${resp.status_code} ${HTTP_OK} |
| 164 | Wait Until Keyword Succeeds 2 min 10 sec Is PNOR Flashing |
| 165 | |
| 166 | Get Flash BIOS Status |
| 167 | [Documentation] Returns the status of the flash BIOS API as a string. For |
| 168 | ... example 'Flashing', 'Flash Done', etc |
| 169 | ${data}= Read Properties /org/openbmc/control/flash/bios |
| 170 | [return] ${data['status']} |
| 171 | |
| 172 | Is PNOR Flashing |
| 173 | [Documentation] Get BIOS 'Flashing' status. This indicates that PNOR |
| 174 | ... flashing has started. |
| 175 | ${status}= Get Flash BIOS Status |
| 176 | should be equal as strings ${status} Flashing |
| 177 | |
| 178 | Is PNOR Flash Done |
| 179 | [Documentation] Get BIOS 'Flash Done' status. This indicates that the |
| 180 | ... PNOR flashing has completed. |
| 181 | ${status}= Get Flash BIOS Status |
| 182 | should be equal as strings ${status} Flash Done |
| 183 | |
| 184 | Is System State Host Booted |
| 185 | [Documentation] Checks whether system state is HOST_BOOTED. |
| 186 | ${state}= Get BMC State |
| 187 | should be equal as strings ${state} HOST_BOOTED |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 188 | |
| 189 | Verify Ping and REST Authentication |
| 190 | ${l_ping} = Run Keyword And Return Status |
| 191 | ... Ping Host ${OPENBMC_HOST} |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame^] | 192 | Run Keyword If '${l_ping}' == '${False}' |
| 193 | ... Fail msg=Ping Failed |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 194 | |
| 195 | ${l_rest} = Run Keyword And Return Status |
| 196 | ... Initialize OpenBMC |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame^] | 197 | Run Keyword If '${l_rest}' == '${False}' |
| 198 | ... Fail msg=REST Authentication Failed |
George Keishing | 5e870cd | 2016-08-24 10:05:47 -0500 | [diff] [blame] | 199 | |
| 200 | # Just to make sure the SSH is working for SCP |
| 201 | Open Connection And Log In |
| 202 | ${system} ${stderr}= Execute Command hostname return_stderr=True |
| 203 | Should Be Empty ${stderr} |
| 204 | |
George Keishing | c4d3dc0 | 2016-09-19 03:45:55 -0500 | [diff] [blame^] | 205 | |
| 206 | Check If BMC is Up |
| 207 | [Documentation] Wait for Host to be online. Checks every X seconds |
| 208 | ... interval for Y minutes and fails if timed out. |
| 209 | ... Default MAX timedout is 10 min, interval 10 seconds. |
| 210 | [arguments] ${max_timeout}=${OPENBMC_REBOOT_TIMEOUT} |
| 211 | ... ${interval}=10 sec |
| 212 | |
| 213 | Wait Until Keyword Succeeds |
| 214 | ... ${max_timeout} ${interval} Verify Ping and REST Authentication |
| 215 | |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 216 | |
| 217 | Check If warmReset is Initiated |
| 218 | [Documentation] Ping would be still alive, so try SSH to connect |
| 219 | ... if fails the ports are down indicating reboot |
| 220 | ... is in progress |
| 221 | ${alive}= Run Keyword and Return Status |
| 222 | ... Open Connection And Log In |
| 223 | Return From Keyword If '${alive}' == '${False}' ${False} |
| 224 | [return] ${True} |
| 225 | |
George Keishing | 06ae4aa | 2016-08-30 01:41:28 -0500 | [diff] [blame] | 226 | Flush REST Sessions |
| 227 | [Documentation] Removes all the active session objects |
| 228 | Delete All Sessions |
George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 229 | |
Sivas SRR | e1143ae | 2016-08-26 22:31:02 -0500 | [diff] [blame] | 230 | Initialize DBUS cmd |
| 231 | [Documentation] Initialize dbus string with property string to extract |
| 232 | [arguments] ${boot_property} |
| 233 | ${cmd} = Catenate ${dbuscmdBase} ${dbuscmdGet} ${dbuscmdString} |
| 234 | ${cmd} = Catenate ${cmd}${boot_property} |
| 235 | Set Global Variable ${dbuscmd} ${cmd} |
| 236 | |
George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame] | 237 | |
| 238 | Start SOL Console Logging |
| 239 | [Documentation] Start logging to a file in /tmp so that it can |
| 240 | ... be read by any other test cases. Stop existing |
| 241 | ... running client processes if there is any. |
| 242 | ... By default logging at /tmp/obmc-console.log else |
| 243 | ... user input location. |
| 244 | ... The File is appended with datetime and pid of |
| 245 | ... process which created this log file. |
| 246 | [Arguments] ${file_path}=/tmp/obmc-console.log |
| 247 | |
| 248 | Open Connection And Log In |
| 249 | |
| 250 | ${cur_time}= Get Time Stamp |
| 251 | Set Global Variable ${LOG_TIME} ${cur_time} |
| 252 | Start Command |
| 253 | ... obmc-console-client > ${file_path}-${LOG_TIME}_$$ |
| 254 | |
| 255 | |
| 256 | Stop SOL Console Logging |
| 257 | [Documentation] Login to BMC and Stop the obmc-console-client process. |
| 258 | ... Find the pids from the log to filter the one started by |
| 259 | ... specific test datetime and stop that process only. |
| 260 | ... Ignore if there is no process running and return message |
| 261 | ... "No obmc-console-client process running" |
| 262 | ... By default retrieving log from /tmp/obmc-console.log else |
| 263 | ... user input location. |
| 264 | [Arguments] ${file_path}=/tmp/obmc-console.log |
| 265 | |
| 266 | Open Connection And Log In |
| 267 | |
| 268 | ${pid} ${stderr} = |
| 269 | ... Execute Command |
| 270 | ... ls ${file_path}-${LOG_TIME}_* | cut -d'_' -f 2 |
| 271 | ... return_stderr=True |
| 272 | Return From Keyword If '${pid}' == '${EMPTY}' |
| 273 | ... No obmc-console-client process running |
| 274 | Should Be Empty ${stderr} |
| 275 | |
| 276 | ${console} ${stderr}= |
| 277 | ... Execute Command kill -s KILL ${pid} |
| 278 | ... return_stderr=True |
| 279 | Should Be Empty ${stderr} |
| 280 | Log Current Client PID:${pid} |
| 281 | |
| 282 | ${console} ${stderr}= |
| 283 | ... Execute Command |
| 284 | ... cat ${file_path}-${LOG_TIME}_${pid} |
| 285 | ... return_stderr=True |
| 286 | Should Be Empty ${stderr} |
| 287 | |
| 288 | [Return] ${console} |
| 289 | |
| 290 | |
| 291 | Get Time Stamp |
| 292 | [Documentation] Get the current time stamp data |
| 293 | ${cur_time}= Get Current Date result_format=%Y%m%d%H%M%S%f |
| 294 | [return] ${cur_time} |
| 295 | |