blob: d74494e32cd51a9117d6507df1e8f74f7fc259d1 [file] [log] [blame]
Steven Sombar3468df52019-06-29 11:01:47 -05001*** Settings ***
2
3Documentation 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
13Resource ../../lib/esel_utils.robot
14Resource ../../lib/bmc_redfish_resource.robot
15Resource ../../lib/logging_utils.robot
Steven Sombar69b87c12019-11-07 15:28:42 -060016Resource ../../lib/dump_utils.robot
George Keishinga28061a2023-12-15 14:46:54 +053017Resource ../../lib/os_utilities.robot
Steven Sombar3468df52019-06-29 11:01:47 -050018Library ../../lib/gen_cmd.py
19Library OperatingSystem
20
21
22Suite Setup Suite Setup Execution
23Suite Teardown Suite Teardown Execution
24Test Teardown Test Teardown Execution
25
26
27*** Variables ***
28
Steven Sombar9686b762019-09-19 12:22:13 -050029${monitor_pgm} websocket_monitor.py
Steven Sombar3468df52019-06-29 11:01:47 -050030${monitor_file} websocket_monitor_out.txt
Steven Sombar69b87c12019-11-07 15:28:42 -060031${esel_received} eSEL received over websocket interface
32${dump_received} Dump notification received over websocket interface
Steven Sombar3468df52019-06-29 11:01:47 -050033${min_number_chars} 22
34${monitor_cmd} ${monitor_pgm} ${OPENBMC_HOST} --openbmc_username ${OPENBMC_USERNAME}
35
36
37*** Test Cases ***
38
39
Steven Sombar69b87c12019-11-07 15:28:42 -060040Test 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 Sombar3468df52019-06-29 11:01:47 -050046
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 Sombar69b87c12019-11-07 15:28:42 -060051 Start Websocket Monitor logging
Steven Sombar3468df52019-06-29 11:01:47 -050052
53 ${initial_esel_count}= Get Number Of Event Logs
54
55 # Generate eSEL (e.g. typically "CPU 1 core 3 has failed").
George Keishing3a5ce062025-04-03 09:37:16 +053056 Create eSEL ${RAW_PREFIX}
Steven Sombar3468df52019-06-29 11:01:47 -050057
58 ${current_esel_count}= Get Number Of Event Logs
59
George Keishing7dc48472025-05-07 20:23:47 +053060 IF ${initial_esel_count} == ${current_esel_count}
61 Fail msg=System failed to generate eSEL upon request.
62 END
Steven Sombar3468df52019-06-29 11:01:47 -050063
Steven Sombar69b87c12019-11-07 15:28:42 -060064 ${line}= Grep File ${monitor_file} ${esel_received}
Steven Sombar3468df52019-06-29 11:01:47 -050065 # Typical monitor_file contents:
66 # --------------- ON_MESSAGE:begin --------------------
67 # {"event":"PropertiesChanged","interface":"xyz.openbmc_project.Logging.
68 # Entry","path":"/xyz/openbmc_project/logging/entry/5","properties":{"Id":5}}
69 # eSEL received over websocket interface.
70
71 ${num_chars}= Get Length ${line}
George Keishing7dc48472025-05-07 20:23:47 +053072 IF ${num_chars} < ${min_number_chars}
73 Fail msg=No eSEL notification from websocket_monitor.py.
74 END
Steven Sombar3468df52019-06-29 11:01:47 -050075
76
Steven Sombar69b87c12019-11-07 15:28:42 -060077Test BMC Websocket Dump Interface
78 [Documentation] Verify dumps are reported over the websocket interface.
79 [Tags] Test_BMC_Websocket_Dump_Interface
80
Tim Lee4aff2d02021-06-08 13:26:25 +080081 Redfish Delete All BMC Dumps
Steven Sombar69b87c12019-11-07 15:28:42 -060082 Start Websocket Monitor dump
Tim Lee792e31e2021-12-10 14:10:46 +080083 ${dump_id}= Create User Initiated BMC Dump Via Redfish
Steven Sombar69b87c12019-11-07 15:28:42 -060084 Check Existence Of BMC Dump File ${dump_id}
85
86 # Check that the monitor received notification of the dump.
87 ${line}= Grep File ${monitor_file} ${dump_received}
88 # Typical monitor_file contents:
89 # --------------- ON_MESSAGE:begin --------------------
90 # {"event":"PropertiesChanged","interface":"xyz.openbmc_project.Dump.
91 # Entry","path":"/xyz/openbmc_project/dump/entry/1","properties":{"Size":157888}}
92 # Dump notification received over websocket interface.
93
94 ${num_chars}= Get Length ${line}
George Keishing7dc48472025-05-07 20:23:47 +053095 IF ${num_chars} < ${min_number_chars}
96 Fail msg=No dump notification from websocket_monitor.py.
97 END
Steven Sombar69b87c12019-11-07 15:28:42 -060098
99
Steven Sombar3468df52019-06-29 11:01:47 -0500100*** Keywords ***
101
102
103Start Websocket Monitor
104 [Documentation] Fork the monitor to run in the background.
Steven Sombar69b87c12019-11-07 15:28:42 -0600105 [Arguments] ${monitor_type}
106
107 # Description of Argument(s):
108 # monitor_type The type of websocket notifications to monitor,
109 # either "logging" or "dump".
Steven Sombar3468df52019-06-29 11:01:47 -0500110
111 # Delete the previous output file, if any.
112 Remove File ${monitor_file}
113
Steven Sombar69b87c12019-11-07 15:28:42 -0600114 ${command}= Catenate ${monitor_cmd} --openbmc_password ${OPENBMC_PASSWORD}
115 ... --monitor_type ${monitor_type} 1>${monitor_file} 2>&1
116
Steven Sombar3468df52019-06-29 11:01:47 -0500117 # Start the monitor. Fork so its a parallel task.
Steven Sombar69b87c12019-11-07 15:28:42 -0600118 Shell Cmd ${command} fork=${1}
Steven Sombar3468df52019-06-29 11:01:47 -0500119
120 # Allow time for the monitor to initialize.
121 Sleep 5s
122
123
124Find Websocket Monitor
125 [Documentation] Return the process Id(s) of running websocket monitors.
126
127 ${cmd}= Catenate ps -ef | grep '${monitor_cmd}'
128 ... | grep -v grep | grep -v bash | cut -c10-14
129 ${shell_rc} ${pid}= Shell Cmd ${cmd}
130 # There may be more than one pid returned if there is an instance
131 # of a monitory_pgm running from a previous run.
132 @{pid_list}= Split String ${pid}
George Keishing409df052024-01-17 22:36:14 +0530133 RETURN ${pid_list}
Steven Sombar3468df52019-06-29 11:01:47 -0500134
135
136Kill Websocket Monitor
137 [Documentation] Terminate running websocket monitor.
138
139 ${pid_list}= Find Websocket Monitor
140 FOR ${pid} IN @{pid_list}
141 Shell Cmd kill -s SIGTERM ${pid}
142 END
143
144
145Print Websocket Monitor Log
146 [Documentation] Show the contents of the monitor output file.
147
148 ${websocket_monitor_log}= OperatingSystem.Get File ${monitor_file}
149 Log to Console websocket_monitor_log:
150 Log to Console ${websocket_monitor_log}
151
152
153Suite Setup Execution
154 [Documentation] Do the suite setup tasks.
155
156 Run Keyword Redfish Power On stack_mode=skip
157
158 Redfish.Login
159
160 Delete All Error Logs
161 Kill Websocket Monitor
162
163 # Allow time for Error Logs to be deleted.
164 Sleep 5s
165
166
167Test Teardown Execution
168 [Documentation] Do teardown tasks after a test.
169
170 FFDC On Test Case Fail
George Keishing7dc48472025-05-07 20:23:47 +0530171 IF '${TEST_STATUS}' == 'FAIL' Print Websocket Monitor Log
Steven Sombar3468df52019-06-29 11:01:47 -0500172 Kill Websocket Monitor
173
Tim Lee4aff2d02021-06-08 13:26:25 +0800174 Redfish Delete All BMC Dumps
Steven Sombar69b87c12019-11-07 15:28:42 -0600175
Steven Sombar3468df52019-06-29 11:01:47 -0500176
177Suite Teardown Execution
178 [Documentation] Do the post-suite teardown.
179
180 Delete All Error Logs
181 Run Keyword and Return Status Redfish.Logout