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