George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Remote logging test for rsyslog. |
| 3 | |
| 4 | # Program arguments: |
| 5 | # REMOTE_LOG_SERVER_HOST The host name or IP address of the remote |
George Keishing | 6713367 | 2018-08-31 10:23:15 -0500 | [diff] [blame] | 6 | # logging server. |
George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 7 | # REMOTE_LOG_SERVER_PORT The port number for the remote logging server. |
George Keishing | 6713367 | 2018-08-31 10:23:15 -0500 | [diff] [blame] | 8 | # REMOTE_USERNAME The username for the remote logging server. |
| 9 | # REMOTE_PASSWORD The password for the remote logging server. |
George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 10 | |
| 11 | Resource ../lib/resource.txt |
| 12 | Resource ../lib/rest_client.robot |
| 13 | Resource ../lib/utils.robot |
| 14 | Resource ../lib/openbmc_ffdc.robot |
| 15 | |
| 16 | Suite Setup Suite Setup Execution |
| 17 | Test Teardown FFDC On Test Case Fail |
| 18 | |
| 19 | *** Test Cases *** |
| 20 | |
| 21 | Test Remote Logging REST Interface And Verify Config |
| 22 | [Documentation] Test remote logging interface and configuration. |
| 23 | [Tags] Test_Remote_Logging_REST_Interface_And_Verify_Config |
| 24 | |
| 25 | Configure Remote Logging Server |
| 26 | Verify Rsyslog Config On BMC |
| 27 | |
| 28 | Configure Remote Logging Server remote_host=${EMPTY} remote_port=0 |
| 29 | Verify Rsyslog Config On BMC remote_host=remote-host remote_port=port |
| 30 | |
| 31 | |
George Keishing | 6713367 | 2018-08-31 10:23:15 -0500 | [diff] [blame] | 32 | Verfiy BMC Journald Synced To Remote Logging Server |
| 33 | [Documentation] Check that BMC journald is sync to remote rsyslog. |
| 34 | [Tags] Verfiy_BMC_Journald_Synced_To_Remote_Logging_Server |
| 35 | |
| 36 | ${hostname} ${stderr} ${rc}= BMC Execute Command /bin/hostname |
| 37 | Remove Journald Logs |
| 38 | |
| 39 | Configure Remote Logging Server |
| 40 | # Take a couple second to restart rsyslog service. |
| 41 | Sleep 3s |
| 42 | |
| 43 | # Restart BMC dump service and get the last entry of the journald. |
| 44 | # Example: |
| 45 | # Aug 31 15:16:54 wsbmc123 systemd[1]: Started Phosphor Dump Manager |
| 46 | BMC Execute Command |
| 47 | ... systemctl restart xyz.openbmc_project.Dump.Manager.service |
| 48 | |
| 49 | ${bmc_journald} ${stderr} ${rc}= BMC Execute Command |
| 50 | ... journalctl --no-pager | tail -1 |
| 51 | |
| 52 | ${cmd}= Catenate cat /var/log/syslog|grep ${hostname} | tail -1 |
| 53 | ${remote_journald}= Remote Logging Server Execute Command command=${cmd} |
| 54 | |
| 55 | Should Be Equal As Strings ${bmc_journald} ${remote_journald} |
| 56 | ... msg=${bmc_journald} and ${remote_journald} don't match. |
| 57 | |
| 58 | |
George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 59 | *** Keywords *** |
| 60 | |
| 61 | Suite Setup Execution |
| 62 | [Documentation] Do the suite setup. |
| 63 | |
| 64 | Should Not Be Empty ${REMOTE_LOG_SERVER_HOST} |
| 65 | Should Not Be Empty ${REMOTE_LOG_SERVER_PORT} |
George Keishing | 6713367 | 2018-08-31 10:23:15 -0500 | [diff] [blame] | 66 | Should Not Be Empty ${REMOTE_USERNAME} |
| 67 | Should Not Be Empty ${REMOTE_PASSWORD} |
George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 68 | Ping Host ${REMOTE_LOG_SERVER_HOST} |
George Keishing | 6713367 | 2018-08-31 10:23:15 -0500 | [diff] [blame] | 69 | Remote Logging Server Execute Command true |
George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 70 | Remote Logging Interface Should Exist |
| 71 | |
| 72 | |
| 73 | Remote Logging Interface Should Exist |
| 74 | [Documentation] Check that the remote logging URI exist. |
| 75 | |
| 76 | ${resp}= OpenBMC Get Request ${REMOTE_LOGGING_URI} |
| 77 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 78 | |
| 79 | |
| 80 | Configure Remote Logging Server |
| 81 | [Documentation] Configure the remote logging server on BMC. |
| 82 | [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST} |
| 83 | ... ${remote_port}=${REMOTE_LOG_SERVER_PORT} |
| 84 | |
| 85 | # Description of argument(s): |
| 86 | # remote_host The host name or IP address of the remote logging server |
| 87 | # (e.g. "xx.xx.xx.xx"). |
| 88 | # remote_port Remote ryslog server port number (e.g. "514"). |
| 89 | |
| 90 | # Example: |
| 91 | # https://xx.xx.xx.xx/xyz/openbmc_project/logging/config/remote |
| 92 | # Response code:200, Content:{ |
| 93 | # "data": { |
| 94 | # "Address": "xx.xx.xx.xx", |
| 95 | # "Port": 514 |
| 96 | # }, |
| 97 | # "message": "200 OK", |
| 98 | # "status": "ok" |
| 99 | # } |
| 100 | |
| 101 | ${host_dict}= Create Dictionary data=${remote_host} |
| 102 | Write Attribute ${REMOTE_LOGGING_URI} Address data=${host_dict} |
| 103 | ... verify=${TRUE} expected_value=${remote_host} |
| 104 | |
| 105 | ${remote_port}= Convert To Integer ${remote_port} |
| 106 | ${port_dict}= Create Dictionary data=${remote_port} |
| 107 | Write Attribute ${REMOTE_LOGGING_URI} Port data=${port_dict} |
| 108 | ... verify=${TRUE} expected_value=${remote_port} |
| 109 | |
| 110 | |
| 111 | Verify Rsyslog Config On BMC |
| 112 | [Documentation] Check if the rsyslog configuration on BMC is correct. |
| 113 | [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST} |
| 114 | ... ${remote_port}=${REMOTE_LOG_SERVER_PORT} |
| 115 | |
| 116 | # Description of argument(s): |
| 117 | # remote_host The host name or IP address of the remote logging server |
| 118 | # (e.g. "xx.xx.xx.xx"). |
| 119 | # remote_port Remote ryslog server port number (e.g. "514"). |
| 120 | |
| 121 | # Example: |
| 122 | # Configured: |
| 123 | # *.* @@xx.xx.xx.xx:514root@wsbmc123 |
| 124 | # By default: |
| 125 | # #*.* @@remote-host:port |
| 126 | |
| 127 | ${ryslog_conf} ${stderr} ${rc}= BMC Execute Command |
| 128 | ... cat /etc/rsyslog.d/server.conf |
| 129 | |
| 130 | ${config}= Catenate @@${remote_host}:${remote_port} |
| 131 | |
| 132 | Should Contain ${ryslog_conf} ${config} |
| 133 | ... msg=${remote_host} and ${remote_port} are not configured. |
George Keishing | 6713367 | 2018-08-31 10:23:15 -0500 | [diff] [blame] | 134 | |
| 135 | |
| 136 | Remote Logging Server Execute Command |
| 137 | [Documentation] Login to remote logging server. |
| 138 | [Arguments] ${command} |
| 139 | ... ${remote_host}=${REMOTE_LOG_SERVER_HOST} |
| 140 | ... ${user_name}=${REMOTE_USERNAME} |
| 141 | ... ${user_password}=${REMOTE_PASSWORD} |
| 142 | |
| 143 | ${remote_dict}= Create Dictionary host=${remote_host} |
| 144 | Open Connection And Log In ${user_name} ${user_password} |
| 145 | ... &{remote_dict} |
| 146 | ${stdout} ${stderr}= Execute Command ${command} return_stderr=True |
| 147 | Should Be Empty ${stderr} |
| 148 | [Return] ${stdout} |
| 149 | |