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