blob: cfcbd8fc60fa024e6d2952f441f54f095db608b6 [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
2Resource ../lib/resource.txt
3Resource ../lib/rest_client.robot
George Keishing5e870cd2016-08-24 10:05:47 -05004Resource ../lib/connection_client.robot
George Keishing30c12ff2016-09-02 10:25:29 -05005Library DateTime
6Library Process
Chris Austenb29d2e82016-06-07 12:25:35 -05007Library OperatingSystem
Michael Walsha6723f22016-11-22 11:12:01 -06008Library gen_print.py
9Library gen_robot_print.py
Chris Austenb29d2e82016-06-07 12:25:35 -050010
11*** Variables ***
12${SYSTEM_SHUTDOWN_TIME} ${5}
Michael Walsha6723f22016-11-22 11:12:01 -060013${dbuscmdBase}
George Keishing85ca05e2016-11-30 09:47:18 -060014... dbus-send --system --print-reply --dest=${OPENBMC_BASE_DBUS}.settings.Host
Michael Walsha6723f22016-11-22 11:12:01 -060015${dbuscmdGet}
George Keishing85ca05e2016-11-30 09:47:18 -060016... ${OPENBMC_BASE_URI}settings/host0 org.freedesktop.DBus.Properties.Get
17# Enable when ready with openbmc/openbmc-test-automation#203
18#${dbuscmdString}= string:"xyz.openbmc_project.settings.Host" string:
Michael Walsha6723f22016-11-22 11:12:01 -060019${dbuscmdString}= string:"org.openbmc.settings.Host" string:
20
George Keishing85ca05e2016-11-30 09:47:18 -060021
Michael Walsha6723f22016-11-22 11:12:01 -060022# Assign default value to QUIET for programs which may not define it.
23${QUIET} ${0}
Gunnar Mills59204d22016-12-06 11:05:19 -060024${dbuscmdBase}= dbus-send --system --print-reply --dest=org.openbmc.settings.Host
25${dbuscmdGet}= /org/openbmc/settings/host0 org.freedesktop.DBus.Properties.Get
26${dbuscmdString}= string:"org.openbmc.settings.Host" string:
Sivas SRRea85d1f2016-11-13 22:44:28 -060027${bmc_mem_free_cmd}= free | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f4
28${bmc_mem_total_cmd}= free | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f2
29${bmc_cpu_usage_cmd}= top -n 1 | grep CPU: | cut -c 7-9
Chris Austenb29d2e82016-06-07 12:25:35 -050030
31*** Keywords ***
Chris Austenb29d2e82016-06-07 12:25:35 -050032Wait For Host To Ping
root442f0ef2016-08-04 20:23:05 +000033 [Arguments] ${host} ${timeout}=${OPENBMC_REBOOT_TIMEOUT}min
34 ... ${interval}=5 sec
35
36 # host The DNS name or IP of the host to ping.
37 # timeout The amount of time after which attempts to ping cease.
38 # interval The amount of time in between attempts to ping.
39
40 Wait Until Keyword Succeeds ${timeout} ${interval} Ping Host ${host}
Chris Austenb29d2e82016-06-07 12:25:35 -050041
42Ping Host
43 [Arguments] ${host}
George Keishing8a84f952016-08-25 04:54:53 -050044 Should Not Be Empty ${host} msg=No host provided
Michael Walsha6723f22016-11-22 11:12:01 -060045 ${RC} ${output}= Run and return RC and Output ping -c 4 ${host}
Chris Austenb29d2e82016-06-07 12:25:35 -050046 Log RC: ${RC}\nOutput:\n${output}
47 Should be equal ${RC} ${0}
48
49Get Boot Progress
Michael Walsha6723f22016-11-22 11:12:01 -060050 [Arguments] ${quiet}=${QUIET}
51
George Keishing85ca05e2016-11-30 09:47:18 -060052 ${state}= Read Attribute ${OPENBMC_BASE_URI}sensors/host/BootProgress
Michael Walsha6723f22016-11-22 11:12:01 -060053 ... value quiet=${quiet}
Chris Austenb29d2e82016-06-07 12:25:35 -050054 [return] ${state}
55
56Is Power On
root442f0ef2016-08-04 20:23:05 +000057 ${state}= Get Power State
58 Should be equal ${state} ${1}
Chris Austenb29d2e82016-06-07 12:25:35 -050059
60Is Power Off
root442f0ef2016-08-04 20:23:05 +000061 ${state}= Get Power State
62 Should be equal ${state} ${0}
Chris Austenb29d2e82016-06-07 12:25:35 -050063
root442f0ef2016-08-04 20:23:05 +000064Initiate Power On
65 [Documentation] Initiates the power on and waits until the Is Power On
66 ... keyword returns that the power state has switched to on.
Michael Walsha6723f22016-11-22 11:12:01 -060067 [Arguments] ${wait}=${1}
68
Chris Austenb29d2e82016-06-07 12:25:35 -050069 @{arglist}= Create List
70 ${args}= Create Dictionary data=@{arglist}
George Keishing85ca05e2016-11-30 09:47:18 -060071 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOn
Michael Walsha6723f22016-11-22 11:12:01 -060072 ... data=${args}
Chris Austenb29d2e82016-06-07 12:25:35 -050073 should be equal as strings ${resp.status_code} ${HTTP_OK}
Chris Austenb29d2e82016-06-07 12:25:35 -050074
Michael Walsha6723f22016-11-22 11:12:01 -060075 # Does caller want to wait for power on status?
76 Run Keyword If '${wait}' == '${0}' Return From Keyword
77 Wait Until Keyword Succeeds 3 min 10 sec Is Power On
Rahul Maheshwarif684ba72016-10-25 07:24:41 -050078
root442f0ef2016-08-04 20:23:05 +000079Initiate Power Off
80 [Documentation] Initiates the power off and waits until the Is Power Off
81 ... keyword returns that the power state has switched to off.
Chris Austenb29d2e82016-06-07 12:25:35 -050082 @{arglist}= Create List
83 ${args}= Create Dictionary data=@{arglist}
George Keishing85ca05e2016-11-30 09:47:18 -060084 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOff
Michael Walsha6723f22016-11-22 11:12:01 -060085 ... data=${args}
Chris Austenb29d2e82016-06-07 12:25:35 -050086 should be equal as strings ${resp.status_code} ${HTTP_OK}
Michael Walsha6723f22016-11-22 11:12:01 -060087 Wait Until Keyword Succeeds 1 min 10 sec Is Power Off
Chris Austenb29d2e82016-06-07 12:25:35 -050088
89Trigger Warm Reset
90 log to console "Triggering warm reset"
Michael Walsha6723f22016-11-22 11:12:01 -060091 ${data}= create dictionary data=@{EMPTY}
George Keishing85ca05e2016-11-30 09:47:18 -060092 ${resp}= openbmc post request
93 ... ${OPENBMC_BASE_URI}control/bmc0/action/warmReset data=${data}
Chris Austenb29d2e82016-06-07 12:25:35 -050094 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
George Keishingb3700812016-08-31 03:03:30 -050095 ${session_active}= Check If warmReset is Initiated
96 Run Keyword If '${session_active}' == '${True}'
97 ... Fail msg=warm reset didn't occur
98
Chris Austenb29d2e82016-06-07 12:25:35 -050099 Sleep ${SYSTEM_SHUTDOWN_TIME}min
100 Wait For Host To Ping ${OPENBMC_HOST}
Michael Walsh49ab0f42016-07-20 11:44:33 -0500101
102Check OS
root442f0ef2016-08-04 20:23:05 +0000103 [Documentation] Attempts to ping the host OS and then checks that the host
104 ... OS is up by running an SSH command.
Michael Walsh49ab0f42016-07-20 11:44:33 -0500105
106 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
Michael Walsha6723f22016-11-22 11:12:01 -0600107 ... ${os_password}=${OS_PASSWORD} ${quiet}=${QUIET}
108 ... ${print_string}=${EMPTY}
Michael Walsh49ab0f42016-07-20 11:44:33 -0500109 [Teardown] Close Connection
110
111 # os_host The DNS name/IP of the OS host associated with our 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.
Michael Walsha6723f22016-11-22 11:12:01 -0600114 # quiet Indicates whether this keyword should write to console.
115 # print_string A string to be printed before checking the OS.
116
117 rprint ${print_string}
Michael Walsh49ab0f42016-07-20 11:44:33 -0500118
root442f0ef2016-08-04 20:23:05 +0000119 # Attempt to ping the OS. Store the return code to check later.
120 ${ping_rc}= Run Keyword and Return Status Ping Host ${os_host}
121
Michael Walsh49ab0f42016-07-20 11:44:33 -0500122 Open connection ${os_host}
Michael Walsh49ab0f42016-07-20 11:44:33 -0500123
Michael Walsha6723f22016-11-22 11:12:01 -0600124 ${status} ${msg}= Run Keyword And Ignore Error Login ${os_username}
125 ... ${os_password}
126 ${err_msg1}= Sprint Error ${msg}
127 ${err_msg}= Catenate SEPARATOR= \n ${err_msg1}
128 Run Keyword If '${status}' == 'FAIL' Fail msg=${err_msg}
Michael Walsh49ab0f42016-07-20 11:44:33 -0500129 ${output} ${stderr} ${rc}= Execute Command uptime return_stderr=True
130 ... return_rc=True
131
Michael Walsha6723f22016-11-22 11:12:01 -0600132 ${temp_msg}= Catenate Could not execute a command on the operating
133 ... system.\n
134 ${err_msg1}= Sprint Error ${temp_msg}
135 ${err_msg}= Catenate SEPARATOR= \n ${err_msg1}
136
137 # If the return code returned by "Execute Command" is non-zero, this
138 # keyword will fail.
139 Should Be Equal ${rc} ${0} msg=${err_msg}
Michael Walsh49ab0f42016-07-20 11:44:33 -0500140 # We will likewise fail if there is any stderr data.
141 Should Be Empty ${stderr}
142
Michael Walsha6723f22016-11-22 11:12:01 -0600143 ${temp_msg}= Set Variable Could not ping the operating system.\n
144 ${err_msg1}= Sprint Error ${temp_msg}
145 ${err_msg}= Catenate SEPARATOR= \n ${err_msg1}
146 # We will likewise fail if the OS did not ping, as we could SSH but not
147 # ping
148 Should Be Equal As Strings ${ping_rc} ${TRUE} msg=${err_msg}
root442f0ef2016-08-04 20:23:05 +0000149
Michael Walsh49ab0f42016-07-20 11:44:33 -0500150Wait for OS
151 [Documentation] Waits for the host OS to come up via calls to "Check OS".
152 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
153 ... ${os_password}=${OS_PASSWORD} ${timeout}=${OS_WAIT_TIMEOUT}
Michael Walsha6723f22016-11-22 11:12:01 -0600154 ... ${quiet}=${0}
155 [Teardown] rprintn
Michael Walsh49ab0f42016-07-20 11:44:33 -0500156
157 # os_host The DNS name or IP of the OS host associated with our
158 # BMC.
159 # os_username The username to be used to sign on to the OS host.
160 # os_password The password to be used to sign on to the OS host.
161 # timeout The timeout in seconds indicating how long you're
162 # willing to wait for the OS to respond.
Michael Walsha6723f22016-11-22 11:12:01 -0600163 # quiet Indicates whether this keyword should write to console.
Michael Walsh49ab0f42016-07-20 11:44:33 -0500164
165 # The interval to be used between calls to "Check OS".
166 ${interval}= Set Variable 5
167
Michael Walsha6723f22016-11-22 11:12:01 -0600168 ${message}= Catenate Checking every ${interval} seconds for up to
169 ... ${timeout} seconds for the operating system to communicate.
170 rqprint_timen ${message}
171
Michael Walsh49ab0f42016-07-20 11:44:33 -0500172 Wait Until Keyword Succeeds ${timeout} sec ${interval} Check OS
173 ... ${os_host} ${os_username} ${os_password}
Michael Walsha6723f22016-11-22 11:12:01 -0600174 ... print_string=\#
175
176 rqprintn
177
178 rqprint_timen The operating system is now communicating.
root442f0ef2016-08-04 20:23:05 +0000179
180Get BMC State
181 [Documentation] Returns the state of the BMC as a string. (i.e: BMC_READY)
Michael Walsha6723f22016-11-22 11:12:01 -0600182 [Arguments] ${quiet}=${QUIET}
183
root442f0ef2016-08-04 20:23:05 +0000184 @{arglist}= Create List
185 ${args}= Create Dictionary data=@{arglist}
George Keishing85ca05e2016-11-30 09:47:18 -0600186 ${resp}= Call Method ${OPENBMC_BASE_URI}managers/System/ getSystemState
Michael Walsha6723f22016-11-22 11:12:01 -0600187 ... data=${args} quiet=${quiet}
root442f0ef2016-08-04 20:23:05 +0000188 Should be equal as strings ${resp.status_code} ${HTTP_OK}
189 ${content}= to json ${resp.content}
190 [return] ${content["data"]}
191
192Get Power State
193 [Documentation] Returns the power state as an integer. Either 0 or 1.
Michael Walsha6723f22016-11-22 11:12:01 -0600194 [Arguments] ${quiet}=${QUIET}
195
root442f0ef2016-08-04 20:23:05 +0000196 @{arglist}= Create List
197 ${args}= Create Dictionary data=@{arglist}
Michael Walsha6723f22016-11-22 11:12:01 -0600198
George Keishing85ca05e2016-11-30 09:47:18 -0600199 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ getPowerState
Michael Walsha6723f22016-11-22 11:12:01 -0600200 ... data=${args} quiet=${quiet}
root442f0ef2016-08-04 20:23:05 +0000201 Should be equal as strings ${resp.status_code} ${HTTP_OK}
202 ${content}= to json ${resp.content}
203 [return] ${content["data"]}
Jay Azurine4c52eb2016-08-16 20:51:10 -0500204
205Clear BMC Record Log
206 [Documentation] Clears all the event logs on the BMC. This would be
207 ... equivalent to ipmitool sel clear.
208 @{arglist}= Create List
209 ${args}= Create Dictionary data=@{arglist}
George Keishing85ca05e2016-11-30 09:47:18 -0600210 ${resp}= Call Method
211 ... ${OPENBMC_BASE_URI}records/events/ clear data=${args}
Jay Azurine4c52eb2016-08-16 20:51:10 -0500212 should be equal as strings ${resp.status_code} ${HTTP_OK}
213
214Copy PNOR to BMC
215 Import Library SCPLibrary WITH NAME scp
216 Open Connection for SCP
217 Log Copying ${PNOR_IMAGE_PATH} to /tmp
218 scp.Put File ${PNOR_IMAGE_PATH} /tmp
219
220Flash PNOR
221 [Documentation] Calls flash bios update method to flash PNOR image
Gunnar Mills38032802016-12-12 13:43:40 -0600222 [Arguments] ${pnor_image}
Jay Azurine4c52eb2016-08-16 20:51:10 -0500223 @{arglist}= Create List ${pnor_image}
224 ${args}= Create Dictionary data=@{arglist}
George Keishing85ca05e2016-11-30 09:47:18 -0600225 ${resp}= Call Method ${OPENBMC_BASE_URI}control/flash/bios/ update
Michael Walsha6723f22016-11-22 11:12:01 -0600226 ... data=${args}
Jay Azurine4c52eb2016-08-16 20:51:10 -0500227 should be equal as strings ${resp.status_code} ${HTTP_OK}
228 Wait Until Keyword Succeeds 2 min 10 sec Is PNOR Flashing
229
230Get Flash BIOS Status
231 [Documentation] Returns the status of the flash BIOS API as a string. For
232 ... example 'Flashing', 'Flash Done', etc
George Keishing85ca05e2016-11-30 09:47:18 -0600233 ${data}= Read Properties ${OPENBMC_BASE_URI}control/flash/bios
Jay Azurine4c52eb2016-08-16 20:51:10 -0500234 [return] ${data['status']}
235
236Is PNOR Flashing
237 [Documentation] Get BIOS 'Flashing' status. This indicates that PNOR
238 ... flashing has started.
239 ${status}= Get Flash BIOS Status
240 should be equal as strings ${status} Flashing
241
242Is PNOR Flash Done
243 [Documentation] Get BIOS 'Flash Done' status. This indicates that the
244 ... PNOR flashing has completed.
Leah McNutt9ba32272016-11-17 15:48:39 +0000245 ${status}= Get Flash BIOS Status
Jay Azurine4c52eb2016-08-16 20:51:10 -0500246 should be equal as strings ${status} Flash Done
247
248Is System State Host Booted
249 [Documentation] Checks whether system state is HOST_BOOTED.
250 ${state}= Get BMC State
251 should be equal as strings ${state} HOST_BOOTED
George Keishing5e870cd2016-08-24 10:05:47 -0500252
253Verify Ping and REST Authentication
Michael Walsha6723f22016-11-22 11:12:01 -0600254 ${l_ping}= Run Keyword And Return Status
George Keishing5e870cd2016-08-24 10:05:47 -0500255 ... Ping Host ${OPENBMC_HOST}
George Keishingc4d3dc02016-09-19 03:45:55 -0500256 Run Keyword If '${l_ping}' == '${False}'
257 ... Fail msg=Ping Failed
George Keishing5e870cd2016-08-24 10:05:47 -0500258
Michael Walsha6723f22016-11-22 11:12:01 -0600259 ${l_rest}= Run Keyword And Return Status
George Keishing5e870cd2016-08-24 10:05:47 -0500260 ... Initialize OpenBMC
George Keishingc4d3dc02016-09-19 03:45:55 -0500261 Run Keyword If '${l_rest}' == '${False}'
262 ... Fail msg=REST Authentication Failed
George Keishing5e870cd2016-08-24 10:05:47 -0500263
264 # Just to make sure the SSH is working for SCP
265 Open Connection And Log In
266 ${system} ${stderr}= Execute Command hostname return_stderr=True
267 Should Be Empty ${stderr}
268
George Keishingc4d3dc02016-09-19 03:45:55 -0500269Check If BMC is Up
270 [Documentation] Wait for Host to be online. Checks every X seconds
271 ... interval for Y minutes and fails if timed out.
272 ... Default MAX timedout is 10 min, interval 10 seconds.
Gunnar Mills38032802016-12-12 13:43:40 -0600273 [Arguments] ${max_timeout}=${OPENBMC_REBOOT_TIMEOUT} min
George Keishingc4d3dc02016-09-19 03:45:55 -0500274 ... ${interval}=10 sec
275
276 Wait Until Keyword Succeeds
277 ... ${max_timeout} ${interval} Verify Ping and REST Authentication
278
George Keishingb3700812016-08-31 03:03:30 -0500279
280Check If warmReset is Initiated
281 [Documentation] Ping would be still alive, so try SSH to connect
282 ... if fails the ports are down indicating reboot
283 ... is in progress
George Keishing3c05d352016-12-13 06:54:50 -0600284
285 # Warm reset adds 3 seconds delay before forcing reboot
286 # To minimize race conditions, we wait for 7 seconds
287 Sleep 7s
George Keishingb3700812016-08-31 03:03:30 -0500288 ${alive}= Run Keyword and Return Status
289 ... Open Connection And Log In
290 Return From Keyword If '${alive}' == '${False}' ${False}
291 [return] ${True}
292
George Keishing06ae4aa2016-08-30 01:41:28 -0500293Flush REST Sessions
294 [Documentation] Removes all the active session objects
295 Delete All Sessions
George Keishingb3700812016-08-31 03:03:30 -0500296
Sivas SRRe1143ae2016-08-26 22:31:02 -0500297Initialize DBUS cmd
298 [Documentation] Initialize dbus string with property string to extract
Gunnar Mills38032802016-12-12 13:43:40 -0600299 [Arguments] ${boot_property}
Michael Walsha6723f22016-11-22 11:12:01 -0600300 ${cmd}= Catenate ${dbuscmdBase} ${dbuscmdGet} ${dbuscmdString}
301 ${cmd}= Catenate ${cmd}${boot_property}
Sivas SRRe1143ae2016-08-26 22:31:02 -0500302 Set Global Variable ${dbuscmd} ${cmd}
303
George Keishing30c12ff2016-09-02 10:25:29 -0500304
305Start SOL Console Logging
306 [Documentation] Start logging to a file in /tmp so that it can
307 ... be read by any other test cases. Stop existing
308 ... running client processes if there is any.
309 ... By default logging at /tmp/obmc-console.log else
310 ... user input location.
311 ... The File is appended with datetime and pid of
312 ... process which created this log file.
313 [Arguments] ${file_path}=/tmp/obmc-console.log
314
315 Open Connection And Log In
316
317 ${cur_time}= Get Time Stamp
318 Set Global Variable ${LOG_TIME} ${cur_time}
319 Start Command
320 ... obmc-console-client > ${file_path}-${LOG_TIME}_$$
321
322
323Stop SOL Console Logging
324 [Documentation] Login to BMC and Stop the obmc-console-client process.
325 ... Find the pids from the log to filter the one started by
326 ... specific test datetime and stop that process only.
327 ... Ignore if there is no process running and return message
328 ... "No obmc-console-client process running"
329 ... By default retrieving log from /tmp/obmc-console.log else
330 ... user input location.
331 [Arguments] ${file_path}=/tmp/obmc-console.log
332
333 Open Connection And Log In
334
Michael Walsha6723f22016-11-22 11:12:01 -0600335 ${pid} ${stderr}=
George Keishing30c12ff2016-09-02 10:25:29 -0500336 ... Execute Command
337 ... ls ${file_path}-${LOG_TIME}_* | cut -d'_' -f 2
338 ... return_stderr=True
George Keishing30c12ff2016-09-02 10:25:29 -0500339 Should Be Empty ${stderr}
340
George Keishingd4678952016-10-12 04:29:28 -0500341 ${rc}=
342 ... Execute Command
343 ... ps ax | grep ${pid} | grep -v grep
344 ... return_stdout=False return_rc=True
345
346 Return From Keyword If '${rc}' == '${1}'
347 ... No obmc-console-client process running
348
George Keishing30c12ff2016-09-02 10:25:29 -0500349 ${console} ${stderr}=
350 ... Execute Command kill -s KILL ${pid}
351 ... return_stderr=True
352 Should Be Empty ${stderr}
George Keishingd4678952016-10-12 04:29:28 -0500353 Log Current Client PID:${pid}
George Keishing30c12ff2016-09-02 10:25:29 -0500354
355 ${console} ${stderr}=
356 ... Execute Command
357 ... cat ${file_path}-${LOG_TIME}_${pid}
358 ... return_stderr=True
359 Should Be Empty ${stderr}
360
361 [Return] ${console}
362
363
364Get Time Stamp
365 [Documentation] Get the current time stamp data
366 ${cur_time}= Get Current Date result_format=%Y%m%d%H%M%S%f
Sridevi Rameshb96a0c32016-10-19 05:09:52 -0500367 [Return] ${cur_time}
George Keishing30c12ff2016-09-02 10:25:29 -0500368
George Keishing1b150202016-09-29 08:51:58 -0500369
370Verify BMC State
371 [Documentation] Get the BMC state and verify if the current
372 ... BMC state is as expected.
373 [Arguments] ${expected}
374
375 ${current}= Get BMC State
George Keishing8db0e1b2016-10-20 13:46:54 -0500376 Should Contain ${expected} ${current}
George Keishing1b150202016-09-29 08:51:58 -0500377
Rahul Maheshwarif684ba72016-10-25 07:24:41 -0500378Start Journal Log
379 [Documentation] Start capturing journal log to a file in /tmp using
380 ... journalctl command. By default journal log is collected
381 ... at /tmp/journal_log else user input location.
382 ... The File is appended with datetime.
383 [Arguments] ${file_path}=/tmp/journal_log
384
385 Open Connection And Log In
386
387 ${cur_time}= Get Time Stamp
388 Set Global Variable ${LOG_TIME} ${cur_time}
389 Start Command
390 ... journalctl -f > ${file_path}-${LOG_TIME}
391 Log Journal Log Started: ${file_path}-${LOG_TIME}
392
393Stop Journal Log
394 [Documentation] Stop journalctl process if its running.
395 ... By default return log from /tmp/journal_log else
396 ... user input location.
397 [Arguments] ${file_path}=/tmp/journal_log
398
399 Open Connection And Log In
400
401 ${rc}=
402 ... Execute Command
403 ... ps ax | grep journalctl | grep -v grep
404 ... return_stdout=False return_rc=True
405
406 Return From Keyword If '${rc}' == '${1}'
407 ... No journal log process running
408
409 ${output} ${stderr}=
410 ... Execute Command killall journalctl
411 ... return_stderr=True
412 Should Be Empty ${stderr}
413
414 ${journal_log} ${stderr}=
415 ... Execute Command
416 ... cat ${file_path}-${LOG_TIME}
417 ... return_stderr=True
418 Should Be Empty ${stderr}
419
420 Log ${journal_log}
421
422 Execute Command rm ${file_path}-${LOG_TIME}
423
424 [Return] ${journal_log}
Rahul Maheshwari757d80c2016-10-17 01:09:55 -0500425
426Mac Address To Hex String
427 [Documentation] Converts MAC address into hex format.
428 ... Example
429 ... Given the following MAC: 00:01:6C:80:02:78
430 ... This keyword will return: 0x00 0x01 0x6C 0x80 0x02 0x78
431 ... Description of arguments:
432 ... i_macaddress MAC address in the following format 00:01:6C:80:02:78
433 [Arguments] ${i_macaddress}
434
435 ${mac_hex}= Catenate 0x${i_macaddress.replace(':', ' 0x')}
436 [return] ${mac_hex}
437
438IP Address To Hex String
439 [Documentation] Converts IP address into hex format.
440 ... Example:
441 ... Given the following IP: 10.3.164.100
442 ... This keyword will return: 0xa 0x3 0xa4 0xa0
443 ... Description of arguments:
444 ... i_ipaddress IP address in the following format 10.10.10.10
445 [Arguments] ${i_ipaddress}
446
447 @{ip}= Split String ${i_ipaddress} .
448 ${index}= Set Variable ${0}
449
450 :FOR ${item} IN @{ip}
451 \ ${hex}= Convert To Hex ${item} prefix=0x lowercase=yes
452 \ Set List Value ${ip} ${index} ${hex}
453 \ ${index}= Set Variable ${index + 1}
454 ${ip_hex}= Catenate @{ip}
455 [return] ${ip_hex}
Sivas SRRea85d1f2016-11-13 22:44:28 -0600456
457BMC CPU Performance Check
458 [Documentation] Minimal 10% of proc should be free in this instance
459
460 ${bmc_cpu_usage_output} ${stderr}= Execute Command ${bmc_cpu_usage_cmd}
461 ... return_stderr=True
462 Should be empty ${stderr}
463 ${bmc_cpu_percentage}= Fetch From Left ${bmc_cpu_usage_output} %
464 Should be true ${bmc_cpu_percentage} < 90
465
466BMC Mem Performance Check
467 [Documentation] Minimal 10% of memory should be free in this instance
468
469 ${bmc_mem_free_output} ${stderr}= Execute Command ${bmc_mem_free_cmd}
470 ... return_stderr=True
471 Should be empty ${stderr}
472
473 ${bmc_mem_total_output} ${stderr}= Execute Command ${bmc_mem_total_cmd}
474 ... return_stderr=True
475 Should be empty ${stderr}
476
477 ${bmc_mem_percentage}= Evaluate ${bmc_mem_free_output}*100
478 ${bmc_mem_percentage}= Evaluate
479 ... ${bmc_mem_percentage}/${bmc_mem_total_output}
480 Should be true ${bmc_mem_percentage} > 10
481
482Check BMC CPU Performance
483 [Documentation] Minimal 10% of proc should be free in 3 sample
484 :FOR ${var} IN Range 1 4
485 \ BMC CPU Performance check
486
487Check BMC Mem Performance
488 [Documentation] Minimal 10% of memory should be free
489
490 :FOR ${var} IN Range 1 4
491 \ BMC Mem Performance check
492
Rahul Maheshwari9a8d3b12016-12-05 04:06:16 -0600493Get Endpoint Paths
494 [Documentation] Returns all url paths ending with given endpoint
495 ... Example:
496 ... Given the following endpoint: cpu
497 ... This keyword will return: list of all urls ending with cpu -
498 ... /org/openbmc/inventory/system/chassis/motherboard/cpu0,
499 ... /org/openbmc/inventory/system/chassis/motherboard/cpu1
500 ... Description of arguments:
501 ... path URL path for enumeration
502 ... endpoint string for which url path ending
503 [Arguments] ${path} ${endpoint}
504
505 ${resp}= Read Properties ${path}/enumerate timeout=30
506 log Dictionary ${resp}
507
508 ${list}= Get Dictionary Keys ${resp}
509 ${resp}= Get Matches ${list} regexp=^.*[0-9a-z_].${endpoint}[0-9]*$
510 [return] ${resp}
Sridevi Rameshb96a0c32016-10-19 05:09:52 -0500511
512Check Zombie Process
513 [Documentation] Check if any defunct process exist or not on BMC
514 ${count} ${stderr} ${rc}= Execute Command ps -o stat | grep Z | wc -l
515 ... return_stderr=True return_rc=True
516 Should Be True ${count}==0
517 Should Be Empty ${stderr}