Remote logging REST interface and config test

Changes:
       - New test suite file for remote logging testing.
       - Test to verify the REST interface and config.

Change-Id: Icb959b7e2c8d55697c500bce282c436fe1ad122a
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/remote_logging/test_remote_logging.robot b/remote_logging/test_remote_logging.robot
new file mode 100644
index 0000000..20f8498
--- /dev/null
+++ b/remote_logging/test_remote_logging.robot
@@ -0,0 +1,101 @@
+*** Settings ***
+Documentation    Remote logging test for rsyslog.
+
+# Program arguments:
+# REMOTE_LOG_SERVER_HOST    The host name or IP address of the remote
+#                               logging server.
+# REMOTE_LOG_SERVER_PORT    The port number for the remote logging server.
+
+Resource         ../lib/resource.txt
+Resource         ../lib/rest_client.robot
+Resource         ../lib/utils.robot
+Resource         ../lib/openbmc_ffdc.robot
+
+Suite Setup      Suite Setup Execution
+Test Teardown    FFDC On Test Case Fail
+
+*** Test Cases ***
+
+Test Remote Logging REST Interface And Verify Config
+    [Documentation]  Test remote logging interface and configuration.
+    [Tags]  Test_Remote_Logging_REST_Interface_And_Verify_Config
+
+    Configure Remote Logging Server
+    Verify Rsyslog Config On BMC
+
+    Configure Remote Logging Server  remote_host=${EMPTY}  remote_port=0
+    Verify Rsyslog Config On BMC  remote_host=remote-host  remote_port=port
+
+
+*** Keywords ***
+
+Suite Setup Execution
+    [Documentation]  Do the suite setup.
+
+    Should Not Be Empty  ${REMOTE_LOG_SERVER_HOST}
+    Should Not Be Empty  ${REMOTE_LOG_SERVER_PORT}
+    Ping Host  ${REMOTE_LOG_SERVER_HOST}
+    Remote Logging Interface Should Exist
+
+
+Remote Logging Interface Should Exist
+    [Documentation]  Check that the remote logging URI exist.
+
+    ${resp}=  OpenBMC Get Request  ${REMOTE_LOGGING_URI}
+    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
+
+
+Configure Remote Logging Server
+    [Documentation]  Configure the remote logging server on BMC.
+    [Arguments]  ${remote_host}=${REMOTE_LOG_SERVER_HOST}
+    ...          ${remote_port}=${REMOTE_LOG_SERVER_PORT}
+
+    # Description of argument(s):
+    # remote_host  The host name or IP address of the remote logging server
+    #              (e.g. "xx.xx.xx.xx").
+    # remote_port  Remote ryslog server port number (e.g. "514").
+
+    # Example:
+    # https://xx.xx.xx.xx/xyz/openbmc_project/logging/config/remote
+    # Response code:200, Content:{
+    # "data": {
+    #     "Address": "xx.xx.xx.xx",
+    #     "Port": 514
+    # },
+    # "message": "200 OK",
+    # "status": "ok"
+    # }
+
+    ${host_dict}=  Create Dictionary  data=${remote_host}
+    Write Attribute  ${REMOTE_LOGGING_URI}  Address  data=${host_dict}
+    ...  verify=${TRUE}  expected_value=${remote_host}
+
+    ${remote_port}=  Convert To Integer  ${remote_port}
+    ${port_dict}=  Create Dictionary  data=${remote_port}
+    Write Attribute  ${REMOTE_LOGGING_URI}  Port  data=${port_dict}
+    ...  verify=${TRUE}  expected_value=${remote_port}
+
+
+Verify Rsyslog Config On BMC
+    [Documentation]  Check if the rsyslog configuration on BMC is correct.
+    [Arguments]  ${remote_host}=${REMOTE_LOG_SERVER_HOST}
+    ...          ${remote_port}=${REMOTE_LOG_SERVER_PORT}
+
+    # Description of argument(s):
+    # remote_host  The host name or IP address of the remote logging server
+    #              (e.g. "xx.xx.xx.xx").
+    # remote_port  Remote ryslog server port number (e.g. "514").
+
+    # Example:
+    # Configured:
+    # *.* @@xx.xx.xx.xx:514root@wsbmc123
+    # By default:
+    # #*.* @@remote-host:port
+
+    ${ryslog_conf}  ${stderr}  ${rc}=  BMC Execute Command
+    ...  cat /etc/rsyslog.d/server.conf
+
+    ${config}=  Catenate  @@${remote_host}:${remote_port}
+
+    Should Contain  ${ryslog_conf}  ${config}
+    ...  msg=${remote_host} and ${remote_port} are not configured.