Enable of test cases for testing journal log
What is enabled
- Added test cases in extended folder to verify that proper logs are
getting logged in journal log for different REST operations.
- Test cases are framed for GET, POST and PUT request.
Resolves openbmc/openbmc-test-automation#210
Change-Id: I66758dc65e2e093373dcb998d3ec4b648a40e0e7
Signed-off-by: Rahul Maheshwari <rahulmaheshwari@in.ibm.com>
diff --git a/lib/utils.robot b/lib/utils.robot
index 6fdd88d..841e223 100644
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -51,6 +51,7 @@
should be equal as strings ${resp.status_code} ${HTTP_OK}
Wait Until Keyword Succeeds 3 min 10 sec Is Power On
+
Initiate Power Off
[Documentation] Initiates the power off and waits until the Is Power Off
... keyword returns that the power state has switched to off.
@@ -308,3 +309,51 @@
${current}= Get BMC State
Should Contain ${expected} ${current}
+Start Journal Log
+ [Documentation] Start capturing journal log to a file in /tmp using
+ ... journalctl command. By default journal log is collected
+ ... at /tmp/journal_log else user input location.
+ ... The File is appended with datetime.
+ [Arguments] ${file_path}=/tmp/journal_log
+
+ Open Connection And Log In
+
+ ${cur_time}= Get Time Stamp
+ Set Global Variable ${LOG_TIME} ${cur_time}
+ Start Command
+ ... journalctl -f > ${file_path}-${LOG_TIME}
+ Log Journal Log Started: ${file_path}-${LOG_TIME}
+
+Stop Journal Log
+ [Documentation] Stop journalctl process if its running.
+ ... By default return log from /tmp/journal_log else
+ ... user input location.
+ [Arguments] ${file_path}=/tmp/journal_log
+
+ Open Connection And Log In
+
+ ${rc}=
+ ... Execute Command
+ ... ps ax | grep journalctl | grep -v grep
+ ... return_stdout=False return_rc=True
+
+ Return From Keyword If '${rc}' == '${1}'
+ ... No journal log process running
+
+ ${output} ${stderr}=
+ ... Execute Command killall journalctl
+ ... return_stderr=True
+ Should Be Empty ${stderr}
+
+ ${journal_log} ${stderr}=
+ ... Execute Command
+ ... cat ${file_path}-${LOG_TIME}
+ ... return_stderr=True
+ Should Be Empty ${stderr}
+
+ Log ${journal_log}
+
+ Execute Command rm ${file_path}-${LOG_TIME}
+
+ [Return] ${journal_log}
+