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 |
George Keishing | 2cec186 | 2018-09-03 12:59:25 -0500 | [diff] [blame] | 15 | Resource ../lib/boot_utils.robot |
George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 16 | |
| 17 | Suite Setup Suite Setup Execution |
| 18 | Test Teardown FFDC On Test Case Fail |
| 19 | |
George Keishing | 2cec186 | 2018-09-03 12:59:25 -0500 | [diff] [blame] | 20 | *** Variables *** |
| 21 | |
| 22 | ${BMC_STOP_MSG} Stopping Phosphor IPMI BT DBus Bridge |
| 23 | ${BMC_START_MSG} Starting Flush Journal to Persistent Storage |
| 24 | ${BMC_BOOT_MSG} Startup finished in |
| 25 | |
George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 26 | *** Test Cases *** |
| 27 | |
| 28 | Test Remote Logging REST Interface And Verify Config |
| 29 | [Documentation] Test remote logging interface and configuration. |
| 30 | [Tags] Test_Remote_Logging_REST_Interface_And_Verify_Config |
| 31 | |
| 32 | Configure Remote Logging Server |
| 33 | Verify Rsyslog Config On BMC |
| 34 | |
| 35 | Configure Remote Logging Server remote_host=${EMPTY} remote_port=0 |
| 36 | Verify Rsyslog Config On BMC remote_host=remote-host remote_port=port |
| 37 | |
| 38 | |
George Keishing | 6713367 | 2018-08-31 10:23:15 -0500 | [diff] [blame] | 39 | Verfiy BMC Journald Synced To Remote Logging Server |
| 40 | [Documentation] Check that BMC journald is sync to remote rsyslog. |
| 41 | [Tags] Verfiy_BMC_Journald_Synced_To_Remote_Logging_Server |
| 42 | |
| 43 | ${hostname} ${stderr} ${rc}= BMC Execute Command /bin/hostname |
| 44 | Remove Journald Logs |
| 45 | |
| 46 | Configure Remote Logging Server |
| 47 | # Take a couple second to restart rsyslog service. |
| 48 | Sleep 3s |
| 49 | |
| 50 | # Restart BMC dump service and get the last entry of the journald. |
| 51 | # Example: |
| 52 | # Aug 31 15:16:54 wsbmc123 systemd[1]: Started Phosphor Dump Manager |
| 53 | BMC Execute Command |
| 54 | ... systemctl restart xyz.openbmc_project.Dump.Manager.service |
| 55 | |
| 56 | ${bmc_journald} ${stderr} ${rc}= BMC Execute Command |
| 57 | ... journalctl --no-pager | tail -1 |
| 58 | |
| 59 | ${cmd}= Catenate cat /var/log/syslog|grep ${hostname} | tail -1 |
| 60 | ${remote_journald}= Remote Logging Server Execute Command command=${cmd} |
| 61 | |
| 62 | Should Be Equal As Strings ${bmc_journald} ${remote_journald} |
| 63 | ... msg=${bmc_journald} and ${remote_journald} don't match. |
| 64 | |
| 65 | |
George Keishing | 2cec186 | 2018-09-03 12:59:25 -0500 | [diff] [blame] | 66 | Verify Journald Post BMC Reset |
| 67 | [Documentation] Check that BMC journald is sync'ed to remote rsyslog after |
| 68 | ... BMC reset. |
| 69 | [Tags] Verify_Journald_Post_BMC_Reset |
| 70 | |
| 71 | ${hostname} ${stderr} ${rc}= BMC Execute Command hostname |
| 72 | OBMC Reboot (off) |
| 73 | |
| 74 | ${cmd}= Catenate grep ${hostname} /var/log/syslog | |
| 75 | ... egrep '${BMC_STOP_MSG}|${BMC_START_MSG}|${BMC_BOOT_MSG}' |
| 76 | ${remote_journald}= Remote Logging Server Execute Command command=${cmd} |
| 77 | |
| 78 | # 1. Last reboot message to verify. |
| 79 | Should Contain ${remote_journald} ${BMC_STOP_MSG} |
| 80 | ... msg=The remote journald doesn't contain the IPMI shutdown message: ${BMC_STOP_MSG}. |
| 81 | |
| 82 | # 2. Earliest booting message on journald. |
| 83 | Should Contain ${remote_journald} ${BMC_START_MSG} |
| 84 | ... msg=The remote journald doesn't contain the start message: ${BMC_START_MSG}. |
| 85 | |
| 86 | # 3. Unique boot to standby message. |
| 87 | # Startup finished in 9.961s (kernel) + 1min 59.039s (userspace) = 2min 9.000s |
| 88 | ${bmc_journald} ${stderr} ${rc}= BMC Execute Command |
| 89 | ... journalctl --no-pager | egrep '${BMC_BOOT_MSG}' | tail -1 |
| 90 | |
| 91 | Should Contain ${remote_journald} |
| 92 | ... ${bmc_journald.split('${hostname}')[1]} |
| 93 | ... msg=The remote journald doesn't contain the boot message: ${BMC_BOOT_MSG}. |
| 94 | |
| 95 | |
George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 96 | *** Keywords *** |
| 97 | |
| 98 | Suite Setup Execution |
| 99 | [Documentation] Do the suite setup. |
| 100 | |
| 101 | Should Not Be Empty ${REMOTE_LOG_SERVER_HOST} |
| 102 | Should Not Be Empty ${REMOTE_LOG_SERVER_PORT} |
George Keishing | 6713367 | 2018-08-31 10:23:15 -0500 | [diff] [blame] | 103 | Should Not Be Empty ${REMOTE_USERNAME} |
| 104 | Should Not Be Empty ${REMOTE_PASSWORD} |
George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 105 | Ping Host ${REMOTE_LOG_SERVER_HOST} |
George Keishing | 6713367 | 2018-08-31 10:23:15 -0500 | [diff] [blame] | 106 | Remote Logging Server Execute Command true |
George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 107 | Remote Logging Interface Should Exist |
| 108 | |
| 109 | |
| 110 | Remote Logging Interface Should Exist |
| 111 | [Documentation] Check that the remote logging URI exist. |
| 112 | |
| 113 | ${resp}= OpenBMC Get Request ${REMOTE_LOGGING_URI} |
| 114 | Should Be Equal As Strings ${resp.status_code} ${HTTP_OK} |
| 115 | |
| 116 | |
| 117 | Configure Remote Logging Server |
| 118 | [Documentation] Configure the remote logging server on BMC. |
| 119 | [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST} |
| 120 | ... ${remote_port}=${REMOTE_LOG_SERVER_PORT} |
| 121 | |
| 122 | # Description of argument(s): |
| 123 | # remote_host The host name or IP address of the remote logging server |
| 124 | # (e.g. "xx.xx.xx.xx"). |
| 125 | # remote_port Remote ryslog server port number (e.g. "514"). |
| 126 | |
| 127 | # Example: |
| 128 | # https://xx.xx.xx.xx/xyz/openbmc_project/logging/config/remote |
| 129 | # Response code:200, Content:{ |
| 130 | # "data": { |
| 131 | # "Address": "xx.xx.xx.xx", |
| 132 | # "Port": 514 |
| 133 | # }, |
| 134 | # "message": "200 OK", |
| 135 | # "status": "ok" |
| 136 | # } |
| 137 | |
| 138 | ${host_dict}= Create Dictionary data=${remote_host} |
| 139 | Write Attribute ${REMOTE_LOGGING_URI} Address data=${host_dict} |
| 140 | ... verify=${TRUE} expected_value=${remote_host} |
| 141 | |
| 142 | ${remote_port}= Convert To Integer ${remote_port} |
| 143 | ${port_dict}= Create Dictionary data=${remote_port} |
| 144 | Write Attribute ${REMOTE_LOGGING_URI} Port data=${port_dict} |
| 145 | ... verify=${TRUE} expected_value=${remote_port} |
| 146 | |
| 147 | |
| 148 | Verify Rsyslog Config On BMC |
| 149 | [Documentation] Check if the rsyslog configuration on BMC is correct. |
| 150 | [Arguments] ${remote_host}=${REMOTE_LOG_SERVER_HOST} |
| 151 | ... ${remote_port}=${REMOTE_LOG_SERVER_PORT} |
| 152 | |
| 153 | # Description of argument(s): |
| 154 | # remote_host The host name or IP address of the remote logging server |
| 155 | # (e.g. "xx.xx.xx.xx"). |
| 156 | # remote_port Remote ryslog server port number (e.g. "514"). |
| 157 | |
| 158 | # Example: |
| 159 | # Configured: |
| 160 | # *.* @@xx.xx.xx.xx:514root@wsbmc123 |
| 161 | # By default: |
| 162 | # #*.* @@remote-host:port |
| 163 | |
| 164 | ${ryslog_conf} ${stderr} ${rc}= BMC Execute Command |
| 165 | ... cat /etc/rsyslog.d/server.conf |
| 166 | |
| 167 | ${config}= Catenate @@${remote_host}:${remote_port} |
| 168 | |
| 169 | Should Contain ${ryslog_conf} ${config} |
| 170 | ... msg=${remote_host} and ${remote_port} are not configured. |
George Keishing | 6713367 | 2018-08-31 10:23:15 -0500 | [diff] [blame] | 171 | |
| 172 | |
| 173 | Remote Logging Server Execute Command |
| 174 | [Documentation] Login to remote logging server. |
| 175 | [Arguments] ${command} |
| 176 | ... ${remote_host}=${REMOTE_LOG_SERVER_HOST} |
| 177 | ... ${user_name}=${REMOTE_USERNAME} |
| 178 | ... ${user_password}=${REMOTE_PASSWORD} |
| 179 | |
| 180 | ${remote_dict}= Create Dictionary host=${remote_host} |
| 181 | Open Connection And Log In ${user_name} ${user_password} |
| 182 | ... &{remote_dict} |
| 183 | ${stdout} ${stderr}= Execute Command ${command} return_stderr=True |
| 184 | Should Be Empty ${stderr} |
| 185 | [Return] ${stdout} |
| 186 | |