| 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} | 
|  | 192 | Return From Keyword If  '${l_ping}' == '${False}'    ${False} | 
|  | 193 |  | 
|  | 194 | ${l_rest} =   Run Keyword And Return Status | 
|  | 195 | ...    Initialize OpenBMC | 
|  | 196 | Return From Keyword If  '${l_rest}' == '${False}'    ${False} | 
|  | 197 |  | 
|  | 198 | # Just to make sure the SSH is working for SCP | 
|  | 199 | Open Connection And Log In | 
|  | 200 | ${system}   ${stderr}=    Execute Command   hostname   return_stderr=True | 
|  | 201 | Should Be Empty     ${stderr} | 
|  | 202 |  | 
|  | 203 | [return]    ${True} | 
| George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 204 |  | 
|  | 205 | Check If warmReset is Initiated | 
|  | 206 | [Documentation]  Ping would be still alive, so try SSH to connect | 
|  | 207 | ...              if fails the ports are down indicating reboot | 
|  | 208 | ...              is in progress | 
|  | 209 | ${alive}=   Run Keyword and Return Status | 
|  | 210 | ...    Open Connection And Log In | 
|  | 211 | Return From Keyword If   '${alive}' == '${False}'    ${False} | 
|  | 212 | [return]    ${True} | 
|  | 213 |  | 
| George Keishing | 06ae4aa | 2016-08-30 01:41:28 -0500 | [diff] [blame] | 214 | Flush REST Sessions | 
|  | 215 | [Documentation]   Removes all the active session objects | 
|  | 216 | Delete All Sessions | 
| George Keishing | b370081 | 2016-08-31 03:03:30 -0500 | [diff] [blame] | 217 |  | 
| Sivas SRR | e1143ae | 2016-08-26 22:31:02 -0500 | [diff] [blame] | 218 | Initialize DBUS cmd | 
|  | 219 | [Documentation]  Initialize dbus string with property string to extract | 
|  | 220 | [arguments]   ${boot_property} | 
|  | 221 | ${cmd} =     Catenate  ${dbuscmdBase} ${dbuscmdGet} ${dbuscmdString} | 
|  | 222 | ${cmd} =     Catenate  ${cmd}${boot_property} | 
|  | 223 | Set Global Variable   ${dbuscmd}     ${cmd} | 
|  | 224 |  | 
| George Keishing | 30c12ff | 2016-09-02 10:25:29 -0500 | [diff] [blame^] | 225 |  | 
|  | 226 | Start SOL Console Logging | 
|  | 227 | [Documentation]   Start logging to a file in /tmp so that it can | 
|  | 228 | ...               be read by any other test cases. Stop existing | 
|  | 229 | ...               running client processes if there is any. | 
|  | 230 | ...               By default logging at /tmp/obmc-console.log else | 
|  | 231 | ...               user input location. | 
|  | 232 | ...               The File is appended with datetime and pid of | 
|  | 233 | ...               process which created this log file. | 
|  | 234 | [Arguments]       ${file_path}=/tmp/obmc-console.log | 
|  | 235 |  | 
|  | 236 | Open Connection And Log In | 
|  | 237 |  | 
|  | 238 | ${cur_time}=    Get Time Stamp | 
|  | 239 | Set Global Variable   ${LOG_TIME}   ${cur_time} | 
|  | 240 | Start Command | 
|  | 241 | ...  obmc-console-client > ${file_path}-${LOG_TIME}_$$ | 
|  | 242 |  | 
|  | 243 |  | 
|  | 244 | Stop SOL Console Logging | 
|  | 245 | [Documentation]   Login to BMC and Stop the obmc-console-client process. | 
|  | 246 | ...               Find the pids from the log to filter the one started by | 
|  | 247 | ...               specific test datetime and stop that process only. | 
|  | 248 | ...               Ignore if there is no process running and return message | 
|  | 249 | ...               "No obmc-console-client process running" | 
|  | 250 | ...               By default retrieving log from /tmp/obmc-console.log else | 
|  | 251 | ...               user input location. | 
|  | 252 | [Arguments]       ${file_path}=/tmp/obmc-console.log | 
|  | 253 |  | 
|  | 254 | Open Connection And Log In | 
|  | 255 |  | 
|  | 256 | ${pid}  ${stderr} = | 
|  | 257 | ...  Execute Command | 
|  | 258 | ...  ls ${file_path}-${LOG_TIME}_* | cut -d'_' -f 2 | 
|  | 259 | ...  return_stderr=True | 
|  | 260 | Return From Keyword If   '${pid}' == '${EMPTY}' | 
|  | 261 | ...   No obmc-console-client process running | 
|  | 262 | Should Be Empty     ${stderr} | 
|  | 263 |  | 
|  | 264 | ${console}  ${stderr}= | 
|  | 265 | ...  Execute Command   kill -s KILL ${pid} | 
|  | 266 | ...  return_stderr=True | 
|  | 267 | Should Be Empty     ${stderr} | 
|  | 268 | Log    Current Client PID:${pid} | 
|  | 269 |  | 
|  | 270 | ${console}  ${stderr}= | 
|  | 271 | ...  Execute Command | 
|  | 272 | ...  cat ${file_path}-${LOG_TIME}_${pid} | 
|  | 273 | ...  return_stderr=True | 
|  | 274 | Should Be Empty     ${stderr} | 
|  | 275 |  | 
|  | 276 | [Return]    ${console} | 
|  | 277 |  | 
|  | 278 |  | 
|  | 279 | Get Time Stamp | 
|  | 280 | [Documentation]     Get the current time stamp data | 
|  | 281 | ${cur_time}=    Get Current Date   result_format=%Y%m%d%H%M%S%f | 
|  | 282 | [return]   ${cur_time} | 
|  | 283 |  |