| 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 |  | 
| George Keishing | 76a5daf | 2018-09-14 06:00:01 -0500 | [diff] [blame] | 11 | Library          String | 
| George Keishing | f32ee4c | 2019-06-17 22:30:07 -0500 | [diff] [blame] | 12 | Resource         ../../lib/openbmc_ffdc.robot | 
 | 13 | Resource         ../../lib/boot_utils.robot | 
 | 14 | Resource         ../../lib/remote_logging_utils.robot | 
 | 15 | Resource         ../../lib/bmc_redfish_resource.robot | 
 | 16 | Resource         ../../lib/ipmi_client.robot | 
 | 17 | Resource         ../../lib/bmc_redfish_resource.robot | 
| George Keishing | c15a7e6 | 2019-08-09 00:23:45 -0500 | [diff] [blame] | 18 | Resource         ../../lib/ipmi_client.robot | 
 | 19 | Library          ../../lib/ipmi_utils.py | 
| George Keishing | f32ee4c | 2019-06-17 22:30:07 -0500 | [diff] [blame] | 20 | Library          ../../lib/gen_misc.py | 
| George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 21 |  | 
 | 22 | Suite Setup      Suite Setup Execution | 
| George Keishing | 216e584 | 2018-08-31 14:58:15 -0500 | [diff] [blame] | 23 | Test Setup       Test Setup Execution | 
| George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 24 | Test Teardown    FFDC On Test Case Fail | 
 | 25 |  | 
| George Keishing | 2cec186 | 2018-09-03 12:59:25 -0500 | [diff] [blame] | 26 | *** Variables *** | 
 | 27 |  | 
| George Keishing | c1ca5e9 | 2018-09-03 11:19:23 -0500 | [diff] [blame] | 28 | # Strings to check from journald. | 
| George Keishing | f32ee4c | 2019-06-17 22:30:07 -0500 | [diff] [blame] | 29 | ${BMC_STOP_MSG}          Stopping Network IPMI daemon | 
| George Keishing | 13451ed | 2018-09-06 12:46:16 -0500 | [diff] [blame] | 30 | ${BMC_START_MSG}         Starting Flush Journal to Persistent Storage | 
 | 31 | ${BMC_BOOT_MSG}          Startup finished in | 
 | 32 | ${BMC_SYSLOG_REGEX}      dropbear|vrm-control.sh | 
| George Keishing | eacb188 | 2018-09-20 00:11:00 -0500 | [diff] [blame] | 33 | ${RSYSLOG_REGEX}         start|exiting on signal 15|there are no active actions configured | 
| George Keishing | 686cacb | 2019-01-16 01:05:20 -0600 | [diff] [blame] | 34 | ${RSYSLOG_RETRY_REGEX}   suspended | 
| George Keishing | 80bfd31 | 2019-03-19 12:05:24 -0500 | [diff] [blame] | 35 | ${valid_password}        0penBmc1 | 
| George Keishing | c15a7e6 | 2019-08-09 00:23:45 -0500 | [diff] [blame] | 36 | ${max_password_length}   20 | 
| George Keishing | c1ca5e9 | 2018-09-03 11:19:23 -0500 | [diff] [blame] | 37 |  | 
| George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 38 | *** Test Cases *** | 
 | 39 |  | 
| George Keishing | eb9fc59 | 2018-09-18 07:58:17 -0500 | [diff] [blame] | 40 | Test BMC Hostname Service And Verify | 
 | 41 |     [Documentation]  Write to hostname interface and verify via REST and | 
 | 42 |     ...              'hostname' command. | 
 | 43 |     [Tags]  Test_BMC_Hostname_Service_And_Verify | 
 | 44 |  | 
 | 45 |     ${openbmc_host_name}  ${openbmc_ip}  ${openbmc_short_name}= | 
 | 46 |     ...  Get Host Name IP  host=${OPENBMC_HOST}  short_name=1 | 
 | 47 |  | 
 | 48 |     ${host_name_dict}=  Create Dictionary  data=${openbmc_short_name} | 
 | 49 |     Write Attribute  ${NETWORK_MANAGER}config  HostName  data=${host_name_dict} | 
 | 50 |     ...  verify=${TRUE}  expected_value=${openbmc_short_name} | 
 | 51 |  | 
 | 52 |     ${hostname}  ${stderr}  ${rc}=  BMC Execute Command  hostname | 
 | 53 |  | 
 | 54 |     Should Be Equal As Strings  ${hostname}  ${openbmc_short_name} | 
 | 55 |     ...  msg=The hostname interface ${openbmc_short_name} and command value ${hostname} do not match. | 
 | 56 |  | 
 | 57 |     # Override the suite hostname variable if this test is executed. | 
 | 58 |     Set Suite Variable  ${bmc_hostname}  ${openbmc_short_name} | 
 | 59 |  | 
 | 60 |  | 
| George Keishing | 13a64e6 | 2018-09-10 13:07:36 -0500 | [diff] [blame] | 61 | Verify REST Logging On BMC Journal When Disabled | 
 | 62 |     [Documentation]  Enable REST logging and verify from journald. | 
| George Keishing | b77a357 | 2018-09-13 23:26:28 -0500 | [diff] [blame] | 63 |     [Tags]  Verify_REST_Logging_On_BMC_Journal_When_Disabled | 
| George Keishing | 13a64e6 | 2018-09-10 13:07:36 -0500 | [diff] [blame] | 64 |  | 
 | 65 |     ${log_dict}=  Create Dictionary  data=${False} | 
 | 66 |     Write Attribute  ${BMC_LOGGING_URI}${/}rest_api_logs  Enabled  data=${log_dict} | 
 | 67 |     ...  verify=${True}  expected_value=${False} | 
 | 68 |  | 
| George Keishing | eacb188 | 2018-09-20 00:11:00 -0500 | [diff] [blame] | 69 |     # If it was enabled prior, this REST footprint will show up. | 
 | 70 |     # Takes around 5 seconds for the REST to restart service when policy is changed. | 
 | 71 |     Sleep  10s | 
 | 72 |  | 
| George Keishing | f2a92a0 | 2019-07-22 23:49:19 -0500 | [diff] [blame] | 73 |     ${login_footprint}=  Catenate  login json: None 200 OK | 
| George Keishing | 4df837f | 2018-09-19 14:06:01 -0500 | [diff] [blame] | 74 |     # Example: Just get the message part of the syslog | 
| George Keishing | f2a92a0 | 2019-07-22 23:49:19 -0500 | [diff] [blame] | 75 |     # user:root POST http://xx.xx.xx.xx/login json: None 200 OK | 
| George Keishing | 4df837f | 2018-09-19 14:06:01 -0500 | [diff] [blame] | 76 |     ${cmd}=  Catenate  SEPARATOR=  --no-pager | egrep '${login_footprint}' | 
| George Keishing | 4df837f | 2018-09-19 14:06:01 -0500 | [diff] [blame] | 77 |  | 
 | 78 |     Start Journal Log  filter=${cmd} | 
| George Keishing | 13a64e6 | 2018-09-10 13:07:36 -0500 | [diff] [blame] | 79 |     Initialize OpenBMC | 
| George Keishing | 4df837f | 2018-09-19 14:06:01 -0500 | [diff] [blame] | 80 |     Sleep  5s | 
 | 81 |     ${bmc_journald}=  Stop Journal Log | 
| George Keishing | 13a64e6 | 2018-09-10 13:07:36 -0500 | [diff] [blame] | 82 |  | 
| George Keishing | 4df837f | 2018-09-19 14:06:01 -0500 | [diff] [blame] | 83 |     Should Be Empty  ${bmc_journald} | 
| George Keishing | 13a64e6 | 2018-09-10 13:07:36 -0500 | [diff] [blame] | 84 |     ...  msg=${bmc_journald} contains unexpected REST entries. | 
 | 85 |  | 
 | 86 |  | 
| George Keishing | b77a357 | 2018-09-13 23:26:28 -0500 | [diff] [blame] | 87 | Verify REST Logging On BMC Journal When Enabled | 
| George Keishing | 13a64e6 | 2018-09-10 13:07:36 -0500 | [diff] [blame] | 88 |     [Documentation]  Enable REST logging and verify from journald. | 
| George Keishing | b77a357 | 2018-09-13 23:26:28 -0500 | [diff] [blame] | 89 |     [Tags]  Verify_REST_Logging_On_BMC_Journal_When_Enabled | 
| George Keishing | 13a64e6 | 2018-09-10 13:07:36 -0500 | [diff] [blame] | 90 |  | 
 | 91 |     ${log_dict}=  Create Dictionary  data=${True} | 
 | 92 |     Write Attribute  ${BMC_LOGGING_URI}${/}rest_api_logs  Enabled  data=${log_dict} | 
 | 93 |     ...  verify=${True}  expected_value=${True} | 
 | 94 |  | 
| George Keishing | 686cacb | 2019-01-16 01:05:20 -0600 | [diff] [blame] | 95 |     Sleep  5s | 
 | 96 |  | 
 | 97 |     Start Journal Log | 
| George Keishing | 13a64e6 | 2018-09-10 13:07:36 -0500 | [diff] [blame] | 98 |     Initialize OpenBMC | 
| George Keishing | 6218e76 | 2018-10-06 13:14:36 -0500 | [diff] [blame] | 99 |     Log Out OpenBMC | 
| George Keishing | 686cacb | 2019-01-16 01:05:20 -0600 | [diff] [blame] | 100 |     ${bmc_journald}=  Stop Journal Log | 
| George Keishing | 13a64e6 | 2018-09-10 13:07:36 -0500 | [diff] [blame] | 101 |  | 
| George Keishing | f2a92a0 | 2019-07-22 23:49:19 -0500 | [diff] [blame] | 102 |     Should Contain  ${bmc_journald}  login json: None 200 OK | 
| George Keishing | 13a64e6 | 2018-09-10 13:07:36 -0500 | [diff] [blame] | 103 |     ...  msg=${bmc_journald} doesn't contains REST entries. | 
 | 104 |  | 
 | 105 |  | 
| George Keishing | 38733f3 | 2018-09-20 05:56:50 -0500 | [diff] [blame] | 106 | Test Remote API Valid Config Combination | 
 | 107 |     [Documentation]  Verify  valid combination of address and port. | 
 | 108 |     [Tags]  Test_Remote_API_Valid_Config_Combination | 
 | 109 |     [Template]  Verify Configure Remote Logging Server | 
 | 110 |     # Forego normal test setup: | 
 | 111 |     [Setup]  No Operation | 
 | 112 |  | 
 | 113 |     # Address                    Port                        Expected result | 
 | 114 |     ${EMPTY}                     ${REMOTE_LOG_SERVER_PORT}   ${True} | 
 | 115 |     ${REMOTE_LOG_SERVER_HOST}    ${REMOTE_LOG_SERVER_PORT}   ${True} | 
| George Keishing | 38733f3 | 2018-09-20 05:56:50 -0500 | [diff] [blame] | 116 |     ${REMOTE_LOG_SERVER_HOST}    ${0}                        ${True} | 
 | 117 |  | 
 | 118 |  | 
 | 119 | Test Remote API Invalid Config Combination | 
 | 120 |     [Documentation]  Verify invalid combination of address and port. | 
 | 121 |     [Tags]  Test_Remote_API_Invalid_Config_Combination | 
 | 122 |     [Template]  Verify Configure Remote Logging Server | 
 | 123 |     # Forego normal test setup: | 
 | 124 |     [Setup]  No Operation | 
 | 125 |  | 
 | 126 |     # Address                    Port                        Expected result | 
 | 127 |     ${0}                         ${REMOTE_LOG_SERVER_PORT}   ${False} | 
 | 128 |     "0"                          ${REMOTE_LOG_SERVER_PORT}   ${False} | 
 | 129 |     ${REMOTE_LOG_SERVER_HOST}    ${EMPTY}                    ${False} | 
 | 130 |     ${REMOTE_LOG_SERVER_HOST}    "0"                         ${False} | 
 | 131 |  | 
 | 132 |  | 
| George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 133 | Test Remote Logging REST Interface And Verify Config | 
 | 134 |     [Documentation]  Test remote logging interface and configuration. | 
 | 135 |     [Tags]  Test_Remote_Logging_REST_Interface_And_Verify_Config | 
 | 136 |  | 
| George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 137 |     Verify Rsyslog Config On BMC | 
 | 138 |  | 
| George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 139 |  | 
| George Keishing | 13451ed | 2018-09-06 12:46:16 -0500 | [diff] [blame] | 140 | Test Remote Logging Invalid Port Config And Verify BMC Journald | 
 | 141 |     [Documentation]  Test remote logging interface and configuration. | 
 | 142 |     [Tags]  Test_Remote_Logging_Invalid_Port_Config_And_Verify_BMC_Journald | 
 | 143 |  | 
 | 144 |     # Invalid port derived by (REMOTE_LOG_SERVER_PORT + 1) port config setting. | 
 | 145 |     ${INVALID_PORT}=  Evaluate  ${REMOTE_LOG_SERVER_PORT} + ${1} | 
| George Keishing | bbfc394 | 2018-09-19 10:15:48 -0500 | [diff] [blame] | 146 |     Configure Remote Log Server With Parameters | 
| George Keishing | 13451ed | 2018-09-06 12:46:16 -0500 | [diff] [blame] | 147 |     ...  remote_host=${REMOTE_LOG_SERVER_HOST}  remote_port=${INVALID_PORT} | 
 | 148 |  | 
 | 149 |     Sleep  3s | 
| Joy Onyerikwu | dbfe97d | 2019-03-11 19:44:56 -0500 | [diff] [blame] | 150 |     # rsyslogd[1870]: action 'action 0' suspended, | 
 | 151 |     # next retry is Fri Sep 14 05:47:39 2018 [v8.29.0 try http://www.rsyslog.com/e/2007 ] | 
| George Keishing | 13451ed | 2018-09-06 12:46:16 -0500 | [diff] [blame] | 152 |     ${bmc_journald}  ${stderr}  ${rc}=  BMC Execute Command | 
 | 153 |     ...  journalctl -b --no-pager | egrep 'rsyslog.*${RSYSLOG_RETRY_REGEX}' | 
 | 154 |  | 
 | 155 |     Should Contain  ${bmc_journald}  ${RSYSLOG_RETRY_REGEX} | 
 | 156 |     ...  msg=${bmc_journald} doesn't contain rsyslog retry entries. | 
 | 157 |  | 
 | 158 |  | 
| George Keishing | 6713367 | 2018-08-31 10:23:15 -0500 | [diff] [blame] | 159 | Verfiy BMC Journald Synced To Remote Logging Server | 
 | 160 |     [Documentation]  Check that BMC journald is sync to remote rsyslog. | 
 | 161 |     [Tags]  Verfiy_BMC_Journald_Synced_To_Remote_Logging_Server | 
 | 162 |  | 
| George Keishing | 6713367 | 2018-08-31 10:23:15 -0500 | [diff] [blame] | 163 |     # Restart BMC dump service and get the last entry of the journald. | 
 | 164 |     # Example: | 
| George Keishing | 96904c4 | 2018-09-20 09:25:30 -0500 | [diff] [blame] | 165 |     # systemd[1]: Started Phosphor Dump Manager. | 
| George Keishing | 6713367 | 2018-08-31 10:23:15 -0500 | [diff] [blame] | 166 |     BMC Execute Command | 
 | 167 |     ...  systemctl restart xyz.openbmc_project.Dump.Manager.service | 
 | 168 |  | 
 | 169 |     ${bmc_journald}  ${stderr}  ${rc}=  BMC Execute Command | 
| George Keishing | 82ea1d4 | 2018-09-11 13:45:36 -0500 | [diff] [blame] | 170 |     ...  journalctl --no-pager | grep 'Started Phosphor Dump Manager' | 
| George Keishing | 6713367 | 2018-08-31 10:23:15 -0500 | [diff] [blame] | 171 |  | 
| George Keishing | 96904c4 | 2018-09-20 09:25:30 -0500 | [diff] [blame] | 172 |     # systemd[1]: Started Phosphor Dump Manager. | 
| George Keishing | 82ea1d4 | 2018-09-11 13:45:36 -0500 | [diff] [blame] | 173 |     ${cmd}=  Catenate  SEPARATOR=  egrep '${bmc_hostname}.*Started Phosphor Dump Manager' /var/log/syslog | 
| George Keishing | 6713367 | 2018-08-31 10:23:15 -0500 | [diff] [blame] | 174 |     ${remote_journald}=  Remote Logging Server Execute Command  command=${cmd} | 
 | 175 |  | 
| George Keishing | 216e584 | 2018-08-31 14:58:15 -0500 | [diff] [blame] | 176 |     # TODO: rsyslog configuration and time date template to match BMC journald. | 
 | 177 |     # Compare the BMC journlad log. Example: | 
 | 178 |     # systemd[1]: Started Phosphor Dump Manager. | 
| George Keishing | 82ea1d4 | 2018-09-11 13:45:36 -0500 | [diff] [blame] | 179 |     Should Contain  ${remote_journald}  ${bmc_journald.split('${bmc_hostname}')[1][0]} | 
| George Keishing | 216e584 | 2018-08-31 14:58:15 -0500 | [diff] [blame] | 180 |     ...  msg= ${bmc_journald} doesn't match remote rsyslog:${remote_journald}. | 
| George Keishing | 6713367 | 2018-08-31 10:23:15 -0500 | [diff] [blame] | 181 |  | 
 | 182 |  | 
| George Keishing | 2cec186 | 2018-09-03 12:59:25 -0500 | [diff] [blame] | 183 | Verify Journald Post BMC Reset | 
 | 184 |     [Documentation]  Check that BMC journald is sync'ed to remote rsyslog after | 
 | 185 |     ...              BMC reset. | 
 | 186 |     [Tags]  Verify_Journald_Post_BMC_Reset | 
 | 187 |  | 
 | 188 |     ${hostname}  ${stderr}  ${rc}=  BMC Execute Command  hostname | 
 | 189 |     OBMC Reboot (off) | 
 | 190 |  | 
 | 191 |     ${cmd}=  Catenate  grep ${hostname} /var/log/syslog | | 
 | 192 |     ...  egrep '${BMC_STOP_MSG}|${BMC_START_MSG}|${BMC_BOOT_MSG}' | 
 | 193 |     ${remote_journald}=  Remote Logging Server Execute Command  command=${cmd} | 
 | 194 |  | 
 | 195 |     # 1. Last reboot message to verify. | 
 | 196 |     Should Contain  ${remote_journald}  ${BMC_STOP_MSG} | 
 | 197 |     ...  msg=The remote journald doesn't contain the IPMI shutdown message: ${BMC_STOP_MSG}. | 
 | 198 |  | 
 | 199 |     # 2. Earliest booting message on journald. | 
 | 200 |     Should Contain  ${remote_journald}  ${BMC_START_MSG} | 
 | 201 |     ...  msg=The remote journald doesn't contain the start message: ${BMC_START_MSG}. | 
 | 202 |  | 
 | 203 |     # 3. Unique boot to standby message. | 
 | 204 |     # Startup finished in 9.961s (kernel) + 1min 59.039s (userspace) = 2min 9.000s | 
 | 205 |     ${bmc_journald}  ${stderr}  ${rc}=  BMC Execute Command | 
| George Keishing | 6218e76 | 2018-10-06 13:14:36 -0500 | [diff] [blame] | 206 |     ...  journalctl -b --no-pager | egrep '${BMC_BOOT_MSG}' | 
| George Keishing | 2cec186 | 2018-09-03 12:59:25 -0500 | [diff] [blame] | 207 |  | 
 | 208 |     Should Contain  ${remote_journald} | 
 | 209 |     ...  ${bmc_journald.split('${hostname}')[1]} | 
 | 210 |     ...  msg=The remote journald doesn't contain the boot message: ${BMC_BOOT_MSG}. | 
 | 211 |  | 
 | 212 |  | 
| George Keishing | cc18f7c | 2018-09-03 09:40:11 -0500 | [diff] [blame] | 213 | Verify BMC Journald Contains No Credential Data | 
| George Keishing | cb3b9b6 | 2018-09-14 12:11:19 -0500 | [diff] [blame] | 214 |     [Documentation]  Check that BMC journald doesn't log any credential data. | 
| George Keishing | cc18f7c | 2018-09-03 09:40:11 -0500 | [diff] [blame] | 215 |     [Tags]  Verify_BMC_Journald_Contains_No_Credential_Data | 
 | 216 |  | 
| George Keishing | c25c55d | 2018-10-30 02:23:44 -0500 | [diff] [blame] | 217 |     Initialize OpenBMC | 
| George Keishing | 80bfd31 | 2019-03-19 12:05:24 -0500 | [diff] [blame] | 218 |  | 
 | 219 |     Create Redfish And IPMI Users | 
| George Keishing | c25c55d | 2018-10-30 02:23:44 -0500 | [diff] [blame] | 220 |  | 
 | 221 |     # Time for user manager to sync. | 
 | 222 |     Sleep  5 s | 
 | 223 |  | 
| George Keishing | cc18f7c | 2018-09-03 09:40:11 -0500 | [diff] [blame] | 224 |     Open Connection And Log In | 
 | 225 |     ${bmc_journald}  ${stderr}  ${rc}=  BMC Execute Command | 
 | 226 |     ...  journalctl -o json-pretty | cat | 
 | 227 |  | 
| George Keishing | c15a7e6 | 2019-08-09 00:23:45 -0500 | [diff] [blame] | 228 |     Should Not Contain Any  ${bmc_journald}  ${OPENBMC_PASSWORD}  ${REST_PASSWORD}  ${valid_password} | 
 | 229 |     ...  ignore_case=False  msg=Journald logs BMC credentials/password ${OPENBMC_PASSWORD}. | 
| George Keishing | cc18f7c | 2018-09-03 09:40:11 -0500 | [diff] [blame] | 230 |  | 
 | 231 |  | 
| George Keishing | 9a0d480 | 2018-08-31 13:29:40 -0500 | [diff] [blame] | 232 | Audit BMC SSH Login And Remote Logging | 
 | 233 |     [Documentation]  Check that the SSH login to BMC is logged and synced to | 
 | 234 |     ...              remote logging server. | 
 | 235 |     [Tags]  Audit_BMC_SSH_Login_And_Remote_Logging | 
 | 236 |  | 
| George Keishing | aef483e | 2018-09-19 07:57:22 -0500 | [diff] [blame] | 237 |     ${login_footprint}=  Catenate  Started SSH Per-Connection Server | 
 | 238 |     # Example: Just get the message part of the syslog | 
 | 239 |     # Started SSH Per-Connection Server (xx.xx.xx.xx:51292) | 
 | 240 |     ${cmd}=  Catenate  SEPARATOR=  --no-pager | egrep '${login_footprint}' | 
 | 241 |     ...  | awk -F': ' '{print $2}' | 
| George Keishing | 9a0d480 | 2018-08-31 13:29:40 -0500 | [diff] [blame] | 242 |  | 
| George Keishing | aef483e | 2018-09-19 07:57:22 -0500 | [diff] [blame] | 243 |     Start Journal Log  filter=${cmd} | 
| George Keishing | 9a0d480 | 2018-08-31 13:29:40 -0500 | [diff] [blame] | 244 |     Open Connection And Log In | 
| George Keishing | aef483e | 2018-09-19 07:57:22 -0500 | [diff] [blame] | 245 |     Sleep  5s | 
 | 246 |     ${bmc_journald}=  Stop Journal Log | 
 | 247 |     @{ssh_entry}=  Split To Lines  ${bmc_journald} | 
| George Keishing | 9a0d480 | 2018-08-31 13:29:40 -0500 | [diff] [blame] | 248 |  | 
| George Keishing | aef483e | 2018-09-19 07:57:22 -0500 | [diff] [blame] | 249 |     ${cmd}=  Catenate  SEPARATOR=  egrep -E '*${bmc_hostname}.*${login_footprint}' /var/log/syslog | 
| George Keishing | 9a0d480 | 2018-08-31 13:29:40 -0500 | [diff] [blame] | 250 |  | 
 | 251 |     ${remote_journald}=  Remote Logging Server Execute Command  command=${cmd} | 
 | 252 |  | 
| George Keishing | aef483e | 2018-09-19 07:57:22 -0500 | [diff] [blame] | 253 |     Should Contain  ${remote_journald}  ${ssh_entry[0]} | 
| George Keishing | 9a0d480 | 2018-08-31 13:29:40 -0500 | [diff] [blame] | 254 |     ...  msg=${remote_journald} don't contain ${bmc_journald} entry. | 
 | 255 |  | 
 | 256 |  | 
| George Keishing | 6218e76 | 2018-10-06 13:14:36 -0500 | [diff] [blame] | 257 | Verify Rsyslog Does Not Log On BMC | 
 | 258 |     [Documentation]  Check that rsyslog journald doesn't log on BMC. | 
 | 259 |     [Tags]  Verify_Rsyslog_Does_Not_Log_On_BMC | 
 | 260 |  | 
 | 261 |     # Expected filter rsyslog entries. | 
 | 262 |     # Example: | 
| Joy Onyerikwu | dbfe97d | 2019-03-11 19:44:56 -0500 | [diff] [blame] | 263 |     # syslogd[3356]: | 
 | 264 |     #   [origin software="rsyslogd" swVersion="8.29.0" x-pid="3356" x-info="http://www.rsyslog.com"] | 
 | 265 |     #     exiting on signal 15. | 
 | 266 |     # rsyslogd[3364]: | 
 | 267 |     # [origin software="rsyslogd" swVersion="8.29.0" x-pid="3364" x-info="http://www.rsyslog.com"] start | 
| George Keishing | 6218e76 | 2018-10-06 13:14:36 -0500 | [diff] [blame] | 268 |     ${bmc_journald}  ${stderr}  ${rc}=  BMC Execute Command | 
 | 269 |     ...  journalctl -b --no-pager | egrep 'rsyslog' | egrep -Ev '${RSYSLOG_REGEX}|${RSYSLOG_RETRY_REGEX}' | 
 | 270 |     ...  ignore_err=${1} | 
 | 271 |  | 
 | 272 |     Should Be Empty  ${bmc_journald} | 
 | 273 |     ...  msg=${bmc_journald} contains unexpected rsyslog entries. | 
 | 274 |  | 
 | 275 |  | 
| George Keishing | 76a5daf | 2018-09-14 06:00:01 -0500 | [diff] [blame] | 276 | Boot Host And Verify Data Is Synced To Remote Server | 
 | 277 |     [Documentation]  Boot host and verify the power on sequence logs are synced | 
 | 278 |     ...              to remote logging server. | 
 | 279 |     [Tags]  Boot_Host_And_Verify_Data_Is_Synced_To_Remote_Server | 
 | 280 |  | 
| George Keishing | 307c3fa | 2018-10-25 11:43:23 -0500 | [diff] [blame] | 281 |     # Filter kernel dmesg from the journald log. | 
 | 282 |     # Example: xx.xx.xx kernel: | 
 | 283 |  | 
 | 284 |     ${openbmc_host_name}  ${openbmc_ip}  ${openbmc_short_name}= | 
 | 285 |     ...  Get Host Name IP  host=${OPENBMC_HOST}  short_name=1 | 
 | 286 |  | 
 | 287 |     ${cmd}=  Catenate  SEPARATOR=  --no-pager | egrep -Ev '${BMC_SYSLOG_REGEX} | 
 | 288 |     ...  |${openbmc_short_name} kernel' | awk -F': ' '{print $2}' | 
| George Keishing | 76a5daf | 2018-09-14 06:00:01 -0500 | [diff] [blame] | 289 |  | 
 | 290 |     # Example: Just get the message part of the syslog | 
 | 291 |     # Started OpenPOWER OCC Active Disable. | 
 | 292 |     Start Journal Log  filter=${cmd} | 
 | 293 |  | 
 | 294 |     # Irrespective of the outcome, the journald should be synced. | 
| George Keishing | f32ee4c | 2019-06-17 22:30:07 -0500 | [diff] [blame] | 295 |     Run Keyword And Ignore Error  Redfish Power On | 
| George Keishing | 76a5daf | 2018-09-14 06:00:01 -0500 | [diff] [blame] | 296 |     ${bmc_journald}=  Stop Journal Log | 
 | 297 |  | 
| George Keishing | 274f3bd | 2019-07-09 10:25:34 -0500 | [diff] [blame] | 298 |     ${cmd}=  Catenate  SEPARATOR=  egrep -a '${bmc_hostname}' /var/log/syslog | 
| George Keishing | 76a5daf | 2018-09-14 06:00:01 -0500 | [diff] [blame] | 299 |     ${remote_journald}=  Remote Logging Server Execute Command  command=${cmd} | 
 | 300 |  | 
 | 301 |     @{lines}=  Split To Lines  ${bmc_journald} | 
| George Keishing | 307c3fa | 2018-10-25 11:43:23 -0500 | [diff] [blame] | 302 |  | 
| George Keishing | 76a5daf | 2018-09-14 06:00:01 -0500 | [diff] [blame] | 303 |     :FOR  ${line}  IN  @{lines} | 
 | 304 |     \  Log To Console  \n ${line} | 
 | 305 |     \  Should Contain  ${remote_journald}  ${line} | 
 | 306 |     ...  mgs=${line} line doesn't contain in ${remote_journald}. | 
 | 307 |  | 
 | 308 |  | 
| George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 309 | *** Keywords *** | 
 | 310 |  | 
 | 311 | Suite Setup Execution | 
 | 312 |     [Documentation]  Do the suite setup. | 
 | 313 |  | 
 | 314 |     Should Not Be Empty  ${REMOTE_LOG_SERVER_HOST} | 
 | 315 |     Should Not Be Empty  ${REMOTE_LOG_SERVER_PORT} | 
| George Keishing | 6713367 | 2018-08-31 10:23:15 -0500 | [diff] [blame] | 316 |     Should Not Be Empty  ${REMOTE_USERNAME} | 
 | 317 |     Should Not Be Empty  ${REMOTE_PASSWORD} | 
| George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 318 |     Ping Host  ${REMOTE_LOG_SERVER_HOST} | 
| George Keishing | 6713367 | 2018-08-31 10:23:15 -0500 | [diff] [blame] | 319 |     Remote Logging Server Execute Command  true | 
| George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 320 |     Remote Logging Interface Should Exist | 
 | 321 |  | 
| George Keishing | 216e584 | 2018-08-31 14:58:15 -0500 | [diff] [blame] | 322 |     ${hostname}  ${stderr}  ${rc}=  BMC Execute Command  /bin/hostname | 
 | 323 |     Set Suite Variable  ${bmc_hostname}  ${hostname} | 
| George Keishing | bbfc394 | 2018-09-19 10:15:48 -0500 | [diff] [blame] | 324 |     Configure Remote Log Server With Parameters | 
| George Keishing | 216e584 | 2018-08-31 14:58:15 -0500 | [diff] [blame] | 325 |  | 
 | 326 |  | 
 | 327 | Test Setup Execution | 
 | 328 |     [Documentation]  Do the test setup. | 
 | 329 |  | 
| George Keishing | b77a357 | 2018-09-13 23:26:28 -0500 | [diff] [blame] | 330 |     # Retain only the past 1 second log: | 
 | 331 |     BMC Execute Command  journalctl --vacuum-time=1s | 
| George Keishing | 13a64e6 | 2018-09-10 13:07:36 -0500 | [diff] [blame] | 332 |  | 
 | 333 |     ${config_status}=  Run Keyword And Return Status | 
| George Keishing | 216e584 | 2018-08-31 14:58:15 -0500 | [diff] [blame] | 334 |     ...  Get Remote Log Server Configured | 
 | 335 |  | 
| George Keishing | bbfc394 | 2018-09-19 10:15:48 -0500 | [diff] [blame] | 336 |     Run Keyword If  ${config_status}==${FALSE} | 
 | 337 |     ...  Configure Remote Log Server With Parameters | 
| George Keishing | 216e584 | 2018-08-31 14:58:15 -0500 | [diff] [blame] | 338 |  | 
| George Keishing | 6a514ef | 2018-08-27 05:19:19 -0500 | [diff] [blame] | 339 |  | 
 | 340 | Remote Logging Interface Should Exist | 
 | 341 |     [Documentation]  Check that the remote logging URI exist. | 
 | 342 |  | 
 | 343 |     ${resp}=  OpenBMC Get Request  ${REMOTE_LOGGING_URI} | 
 | 344 |     Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK} | 
| George Keishing | 38733f3 | 2018-09-20 05:56:50 -0500 | [diff] [blame] | 345 |  | 
 | 346 |  | 
 | 347 | Verify Configure Remote Logging Server | 
 | 348 |     [Documentation]  Configure the remote logging REST interface on BMC. | 
 | 349 |     [Arguments]  ${remote_host}  ${remote_port}  ${expectation} | 
 | 350 |  | 
 | 351 |     # Description of argument(s): | 
 | 352 |     # remote_host  The host name or IP address of the remote logging server | 
 | 353 |     #              (e.g. "xx.xx.xx.xx"). | 
 | 354 |     # remote_port  Remote ryslog server port number (e.g. "514"). | 
 | 355 |     # expectation  Expect boolean True/False. | 
 | 356 |  | 
 | 357 |  | 
 | 358 |     ${status}=  Run Keyword And Return Status | 
| George Keishing | ccd6d09 | 2018-09-21 00:39:43 -0500 | [diff] [blame] | 359 |     ...  Configure Remote Log Server With Parameters  remote_host=${remote_host}  remote_port=${remote_port} | 
| George Keishing | 38733f3 | 2018-09-20 05:56:50 -0500 | [diff] [blame] | 360 |  | 
 | 361 |     Should Be Equal  ${status}  ${expectation} | 
 | 362 |     ...  msg=Test result ${status} and expectation ${expectation} do not match. | 
| George Keishing | 80bfd31 | 2019-03-19 12:05:24 -0500 | [diff] [blame] | 363 |  | 
 | 364 |  | 
 | 365 | Create Redfish And IPMI Users | 
 | 366 |     [Documentation]  Create a valid Redfish and IPMI local user accounts and | 
 | 367 |     ...  delete them. | 
 | 368 |  | 
 | 369 |     # Create redfish local valid user. | 
 | 370 |     ${redfish_username}=  Generate Random String  8  [LETTERS] | 
 | 371 |  | 
 | 372 |     Redfish.Login | 
 | 373 |  | 
 | 374 |     ${payload}=  Create Dictionary | 
 | 375 |     ...  UserName=${redfish_username}  Password=${valid_password} | 
 | 376 |     ...  RoleId=Administrator  Enabled=${True} | 
 | 377 |     Redfish.Post  /redfish/v1/AccountService/Accounts  body=&{payload} | 
 | 378 |     ...  valid_status_codes=[${HTTP_CREATED}] | 
 | 379 |  | 
 | 380 |     # Delete newly created user. | 
 | 381 |     Redfish.Delete  /redfish/v1/AccountService/Accounts/${redfish_username} | 
 | 382 |  | 
 | 383 |     Redfish.Logout | 
 | 384 |  | 
 | 385 |     # Create IPMI local valid user. | 
| George Keishing | c15a7e6 | 2019-08-09 00:23:45 -0500 | [diff] [blame] | 386 |     ${random_username}=  Generate Random String  8  [LETTERS] | 
 | 387 |     Set Test Variable  ${random_username} | 
| George Keishing | 80bfd31 | 2019-03-19 12:05:24 -0500 | [diff] [blame] | 388 |     ${random_userid}=  Evaluate  random.randint(2, 15)  modules=random | 
| George Keishing | c15a7e6 | 2019-08-09 00:23:45 -0500 | [diff] [blame] | 389 |     IPMI Create User  ${random_userid}  ${random_username} | 
 | 390 |  | 
 | 391 |     Run IPMI Standard Command   user set password ${random_userid} ${valid_password} | 
 | 392 |  | 
 | 393 |     ${msg}=  Run IPMI Standard Command  user test ${random_userid} ${max_password_length} ${valid_password} | 
 | 394 |     Should Contain  ${msg}  Success | 
| George Keishing | 80bfd31 | 2019-03-19 12:05:24 -0500 | [diff] [blame] | 395 |  | 
 | 396 |     # Delete IPMI user. | 
 | 397 |     Run IPMI Standard Command  user set name ${random_userid} "" |