Steven Sombar | 3468df5 | 2019-06-29 11:01:47 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | |
| 3 | Documentation Websocket functionality test. |
| 4 | |
| 5 | # Test Parameters: |
| 6 | # OPENBMC_HOST The BMC host name or IP address. |
| 7 | # OPENBMC_USERNAME The username for the BMC login. |
| 8 | # OPENBMC_PASSWORD The password for OPENBMC_USERNAME. |
| 9 | # OS_HOST The OS host name or IP address. |
| 10 | # OS_USERNAME The username for the OS login. |
| 11 | # OS_PASSWORD The password for OS_USERNAME. |
| 12 | |
| 13 | Resource ../../lib/esel_utils.robot |
| 14 | Resource ../../lib/bmc_redfish_resource.robot |
| 15 | Resource ../../lib/logging_utils.robot |
Steven Sombar | 69b87c1 | 2019-11-07 15:28:42 -0600 | [diff] [blame] | 16 | Resource ../../lib/dump_utils.robot |
| 17 | Resource ../../syslib/utils_os.robot |
Steven Sombar | 3468df5 | 2019-06-29 11:01:47 -0500 | [diff] [blame] | 18 | Library ../../lib/gen_cmd.py |
| 19 | Library OperatingSystem |
| 20 | |
| 21 | |
| 22 | Suite Setup Suite Setup Execution |
| 23 | Suite Teardown Suite Teardown Execution |
| 24 | Test Teardown Test Teardown Execution |
| 25 | |
| 26 | |
| 27 | *** Variables *** |
| 28 | |
Steven Sombar | 9686b76 | 2019-09-19 12:22:13 -0500 | [diff] [blame] | 29 | ${monitor_pgm} websocket_monitor.py |
Steven Sombar | 3468df5 | 2019-06-29 11:01:47 -0500 | [diff] [blame] | 30 | ${monitor_file} websocket_monitor_out.txt |
Steven Sombar | 69b87c1 | 2019-11-07 15:28:42 -0600 | [diff] [blame] | 31 | ${esel_received} eSEL received over websocket interface |
| 32 | ${dump_received} Dump notification received over websocket interface |
Steven Sombar | 3468df5 | 2019-06-29 11:01:47 -0500 | [diff] [blame] | 33 | ${min_number_chars} 22 |
| 34 | ${monitor_cmd} ${monitor_pgm} ${OPENBMC_HOST} --openbmc_username ${OPENBMC_USERNAME} |
| 35 | |
| 36 | |
| 37 | *** Test Cases *** |
| 38 | |
| 39 | |
Steven Sombar | 69b87c1 | 2019-11-07 15:28:42 -0600 | [diff] [blame] | 40 | Test BMC Websocket ESEL Interface |
| 41 | [Documentation] Verify eSELs are reported over the websocket interface. |
| 42 | [Tags] Test_BMC_Websocket_ESEL_Interface |
| 43 | |
| 44 | # Check that the ipmitool is available. That tool is used to create an eSEL. |
| 45 | Tool Exist ipmitool |
Steven Sombar | 3468df5 | 2019-06-29 11:01:47 -0500 | [diff] [blame] | 46 | |
| 47 | # Spawn the websocket monitor program and then generate an eSEL. |
| 48 | # The monitor should asynchronously receive the eSEL through the |
| 49 | # websocket interface and report this fact to standard output. |
| 50 | |
Steven Sombar | 69b87c1 | 2019-11-07 15:28:42 -0600 | [diff] [blame] | 51 | Start Websocket Monitor logging |
Steven Sombar | 3468df5 | 2019-06-29 11:01:47 -0500 | [diff] [blame] | 52 | |
| 53 | ${initial_esel_count}= Get Number Of Event Logs |
| 54 | |
| 55 | # Generate eSEL (e.g. typically "CPU 1 core 3 has failed"). |
| 56 | Create eSEL |
| 57 | |
| 58 | ${current_esel_count}= Get Number Of Event Logs |
| 59 | |
| 60 | Run Keyword If ${initial_esel_count} == ${current_esel_count} |
| 61 | ... Fail msg=System failed to generate eSEL upon request. |
| 62 | |
Steven Sombar | 69b87c1 | 2019-11-07 15:28:42 -0600 | [diff] [blame] | 63 | ${line}= Grep File ${monitor_file} ${esel_received} |
Steven Sombar | 3468df5 | 2019-06-29 11:01:47 -0500 | [diff] [blame] | 64 | # Typical monitor_file contents: |
| 65 | # --------------- ON_MESSAGE:begin -------------------- |
| 66 | # {"event":"PropertiesChanged","interface":"xyz.openbmc_project.Logging. |
| 67 | # Entry","path":"/xyz/openbmc_project/logging/entry/5","properties":{"Id":5}} |
| 68 | # eSEL received over websocket interface. |
| 69 | |
| 70 | ${num_chars}= Get Length ${line} |
| 71 | Run Keyword If ${num_chars} < ${min_number_chars} Fail |
| 72 | ... msg=No eSEL notification from websocket_monitor.py. |
| 73 | |
| 74 | |
Steven Sombar | 69b87c1 | 2019-11-07 15:28:42 -0600 | [diff] [blame] | 75 | Test BMC Websocket Dump Interface |
| 76 | [Documentation] Verify dumps are reported over the websocket interface. |
| 77 | [Tags] Test_BMC_Websocket_Dump_Interface |
| 78 | |
Tim Lee | 4aff2d0 | 2021-06-08 13:26:25 +0800 | [diff] [blame] | 79 | Redfish Delete All BMC Dumps |
Steven Sombar | 69b87c1 | 2019-11-07 15:28:42 -0600 | [diff] [blame] | 80 | Start Websocket Monitor dump |
Tim Lee | 19b1a8f | 2021-12-10 16:57:47 +0800 | [diff] [blame] | 81 | ${dump_id}= Create User Initiated BMC Dump Using Redfish |
Steven Sombar | 69b87c1 | 2019-11-07 15:28:42 -0600 | [diff] [blame] | 82 | Check Existence Of BMC Dump File ${dump_id} |
| 83 | |
| 84 | # Check that the monitor received notification of the dump. |
| 85 | ${line}= Grep File ${monitor_file} ${dump_received} |
| 86 | # Typical monitor_file contents: |
| 87 | # --------------- ON_MESSAGE:begin -------------------- |
| 88 | # {"event":"PropertiesChanged","interface":"xyz.openbmc_project.Dump. |
| 89 | # Entry","path":"/xyz/openbmc_project/dump/entry/1","properties":{"Size":157888}} |
| 90 | # Dump notification received over websocket interface. |
| 91 | |
| 92 | ${num_chars}= Get Length ${line} |
| 93 | Run Keyword If ${num_chars} < ${min_number_chars} Fail |
| 94 | ... msg=No dump notification from websocket_monitor.py. |
| 95 | |
| 96 | |
Steven Sombar | 3468df5 | 2019-06-29 11:01:47 -0500 | [diff] [blame] | 97 | *** Keywords *** |
| 98 | |
| 99 | |
| 100 | Start Websocket Monitor |
| 101 | [Documentation] Fork the monitor to run in the background. |
Steven Sombar | 69b87c1 | 2019-11-07 15:28:42 -0600 | [diff] [blame] | 102 | [Arguments] ${monitor_type} |
| 103 | |
| 104 | # Description of Argument(s): |
| 105 | # monitor_type The type of websocket notifications to monitor, |
| 106 | # either "logging" or "dump". |
Steven Sombar | 3468df5 | 2019-06-29 11:01:47 -0500 | [diff] [blame] | 107 | |
| 108 | # Delete the previous output file, if any. |
| 109 | Remove File ${monitor_file} |
| 110 | |
Steven Sombar | 69b87c1 | 2019-11-07 15:28:42 -0600 | [diff] [blame] | 111 | ${command}= Catenate ${monitor_cmd} --openbmc_password ${OPENBMC_PASSWORD} |
| 112 | ... --monitor_type ${monitor_type} 1>${monitor_file} 2>&1 |
| 113 | |
Steven Sombar | 3468df5 | 2019-06-29 11:01:47 -0500 | [diff] [blame] | 114 | # Start the monitor. Fork so its a parallel task. |
Steven Sombar | 69b87c1 | 2019-11-07 15:28:42 -0600 | [diff] [blame] | 115 | Shell Cmd ${command} fork=${1} |
Steven Sombar | 3468df5 | 2019-06-29 11:01:47 -0500 | [diff] [blame] | 116 | |
| 117 | # Allow time for the monitor to initialize. |
| 118 | Sleep 5s |
| 119 | |
| 120 | |
| 121 | Find Websocket Monitor |
| 122 | [Documentation] Return the process Id(s) of running websocket monitors. |
| 123 | |
| 124 | ${cmd}= Catenate ps -ef | grep '${monitor_cmd}' |
| 125 | ... | grep -v grep | grep -v bash | cut -c10-14 |
| 126 | ${shell_rc} ${pid}= Shell Cmd ${cmd} |
| 127 | # There may be more than one pid returned if there is an instance |
| 128 | # of a monitory_pgm running from a previous run. |
| 129 | @{pid_list}= Split String ${pid} |
| 130 | [Return] ${pid_list} |
| 131 | |
| 132 | |
| 133 | Kill Websocket Monitor |
| 134 | [Documentation] Terminate running websocket monitor. |
| 135 | |
| 136 | ${pid_list}= Find Websocket Monitor |
| 137 | FOR ${pid} IN @{pid_list} |
| 138 | Shell Cmd kill -s SIGTERM ${pid} |
| 139 | END |
| 140 | |
| 141 | |
| 142 | Print Websocket Monitor Log |
| 143 | [Documentation] Show the contents of the monitor output file. |
| 144 | |
| 145 | ${websocket_monitor_log}= OperatingSystem.Get File ${monitor_file} |
| 146 | Log to Console websocket_monitor_log: |
| 147 | Log to Console ${websocket_monitor_log} |
| 148 | |
| 149 | |
| 150 | Suite Setup Execution |
| 151 | [Documentation] Do the suite setup tasks. |
| 152 | |
| 153 | Run Keyword Redfish Power On stack_mode=skip |
| 154 | |
| 155 | Redfish.Login |
| 156 | |
| 157 | Delete All Error Logs |
| 158 | Kill Websocket Monitor |
| 159 | |
| 160 | # Allow time for Error Logs to be deleted. |
| 161 | Sleep 5s |
| 162 | |
| 163 | |
| 164 | Test Teardown Execution |
| 165 | [Documentation] Do teardown tasks after a test. |
| 166 | |
| 167 | FFDC On Test Case Fail |
| 168 | Run Keyword If '${TEST_STATUS}' == 'FAIL' Print Websocket Monitor Log |
| 169 | Kill Websocket Monitor |
| 170 | |
Tim Lee | 4aff2d0 | 2021-06-08 13:26:25 +0800 | [diff] [blame] | 171 | Redfish Delete All BMC Dumps |
Steven Sombar | 69b87c1 | 2019-11-07 15:28:42 -0600 | [diff] [blame] | 172 | |
Steven Sombar | 3468df5 | 2019-06-29 11:01:47 -0500 | [diff] [blame] | 173 | |
| 174 | Suite Teardown Execution |
| 175 | [Documentation] Do the post-suite teardown. |
| 176 | |
| 177 | Delete All Error Logs |
| 178 | Run Keyword and Return Status Redfish.Logout |