Test to verify journald data when BMC is running

Changes:
    - Test to boot host and verify the syslog data.
    - Add parameter to journald utility keyword to accept filters.

Change-Id: Ic6e1e2249b96fbe8d158d0ed7e0415aea8c9461f
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/utils.robot b/lib/utils.robot
index 53072d5..05898f4 100755
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -754,15 +754,16 @@
     ...               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
+    [Arguments]       ${file_path}=/tmp/journal_log  ${filter}=${EMPTY}
 
     # Description of arguments:
     # file_path   The file path of the journal file.
 
     ${cur_time}=    Get Time Stamp
     Set Global Variable   ${LOG_TIME}   ${cur_time}
+    Open Connection And Log In
     Start Command
-    ...  journalctl -f > ${file_path}-${LOG_TIME}
+    ...  journalctl -f ${filter} > ${file_path}-${LOG_TIME}
     Log    Journal Log Started: ${file_path}-${LOG_TIME}
 
 
@@ -779,7 +780,7 @@
 
     ${rc}=
     ...  Execute Command
-    ...  ps ax | grep journalctl | grep -v grep
+    ...  ps | grep journalctl | grep -v grep
     ...  return_stdout=False  return_rc=True
 
     Return From Keyword If   '${rc}' == '${1}'
diff --git a/remote_logging/test_remote_logging.robot b/remote_logging/test_remote_logging.robot
index 1757d20..fcfdeef 100644
--- a/remote_logging/test_remote_logging.robot
+++ b/remote_logging/test_remote_logging.robot
@@ -8,10 +8,12 @@
 # REMOTE_USERNAME           The username for the remote logging server.
 # REMOTE_PASSWORD           The password for the remote logging server.
 
+Library          String
 Resource         ../lib/resource.txt
 Resource         ../lib/rest_client.robot
 Resource         ../lib/utils.robot
 Resource         ../lib/openbmc_ffdc.robot
+Resource         ../lib/boot_utils.robot
 Library          ../lib/gen_misc.py
 
 Suite Setup      Suite Setup Execution
@@ -25,7 +27,8 @@
 ${BMC_BOOT_MSG}    Startup finished in
 
 # Strings to check from journald.
-${RSYSLOG_REGEX}   start|exiting on signal 15
+${RSYSLOG_REGEX}      start|exiting on signal 15
+${BMC_SYSLOG_REGEX}   dropbear|vrm-control.sh|
 
 *** Test Cases ***
 
@@ -179,6 +182,32 @@
     ...  msg=${remote_journald} don't contain ${bmc_journald} entry.
 
 
+Boot Host And Verify Data Is Synced To Remote Server
+    [Documentation]  Boot host and verify the power on sequence logs are synced
+    ...              to remote logging server.
+    [Tags]  Boot_Host_And_Verify_Data_Is_Synced_To_Remote_Server
+
+    ${cmd}=  Catenate  SEPARATOR=  --no-pager | egrep -Ev '${BMC_SYSLOG_REGEX}'
+    ...  | awk -F': ' '{print $2}'
+
+    # Example: Just get the message part of the syslog
+    # Started OpenPOWER OCC Active Disable.
+    Start Journal Log  filter=${cmd}
+
+    # Irrespective of the outcome, the journald should be synced.
+    Run Keyword And Ignore Error  REST Power On
+    ${bmc_journald}=  Stop Journal Log
+
+    ${cmd}=  Catenate  SEPARATOR=  egrep '${bmc_hostname}' /var/log/syslog
+    ${remote_journald}=  Remote Logging Server Execute Command  command=${cmd}
+
+    @{lines}=  Split To Lines  ${bmc_journald}
+    :FOR  ${line}  IN  @{lines}
+    \  Log To Console  \n ${line}
+    \  Should Contain  ${remote_journald}  ${line}
+    ...  mgs=${line} line doesn't contain in ${remote_journald}.
+
+
 *** Keywords ***
 
 Suite Setup Execution