blob: 1ff53444e4afdead9e492b5bd93a59612279fd3d [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
16Library ../../lib/gen_cmd.py
17Library OperatingSystem
18
19
20Suite Setup Suite Setup Execution
21Suite Teardown Suite Teardown Execution
22Test Teardown Test Teardown Execution
23
24
25*** Variables ***
26
27${monitor_pgm} bin/websocket_monitor.py
28${monitor_file} websocket_monitor_out.txt
29${expected_string} eSEL received over websocket interface
30${min_number_chars} 22
31${monitor_cmd} ${monitor_pgm} ${OPENBMC_HOST} --openbmc_username ${OPENBMC_USERNAME}
32
33
34*** Test Cases ***
35
36
37Test BMC Websocket Interface
38 [Documentation] Verify eSELs are seen over the websocket interface.
39 [Tags] Test_BMC_Websocket_Interface
40
41 # Spawn the websocket monitor program and then generate an eSEL.
42 # The monitor should asynchronously receive the eSEL through the
43 # websocket interface and report this fact to standard output.
44
45 Start Websocket Monitor
46
47 ${initial_esel_count}= Get Number Of Event Logs
48
49 # Generate eSEL (e.g. typically "CPU 1 core 3 has failed").
50 Create eSEL
51
52 ${current_esel_count}= Get Number Of Event Logs
53
54 Run Keyword If ${initial_esel_count} == ${current_esel_count}
55 ... Fail msg=System failed to generate eSEL upon request.
56
57 ${line}= Grep File ${monitor_file} ${expected_string}
58 # Typical monitor_file contents:
59 # --------------- ON_MESSAGE:begin --------------------
60 # {"event":"PropertiesChanged","interface":"xyz.openbmc_project.Logging.
61 # Entry","path":"/xyz/openbmc_project/logging/entry/5","properties":{"Id":5}}
62 # eSEL received over websocket interface.
63
64 ${num_chars}= Get Length ${line}
65 Run Keyword If ${num_chars} < ${min_number_chars} Fail
66 ... msg=No eSEL notification from websocket_monitor.py.
67
68
69*** Keywords ***
70
71
72Start Websocket Monitor
73 [Documentation] Fork the monitor to run in the background.
74
75 # Delete the previous output file, if any.
76 Remove File ${monitor_file}
77
78 # Start the monitor. Fork so its a parallel task.
79 Shell Cmd
80 ... ${monitor_cmd} --openbmc_password ${OPENBMC_PASSWORD} 1>${monitor_file} 2>&1 fork=${1}
81
82 # Allow time for the monitor to initialize.
83 Sleep 5s
84
85
86Find Websocket Monitor
87 [Documentation] Return the process Id(s) of running websocket monitors.
88
89 ${cmd}= Catenate ps -ef | grep '${monitor_cmd}'
90 ... | grep -v grep | grep -v bash | cut -c10-14
91 ${shell_rc} ${pid}= Shell Cmd ${cmd}
92 # There may be more than one pid returned if there is an instance
93 # of a monitory_pgm running from a previous run.
94 @{pid_list}= Split String ${pid}
95 [Return] ${pid_list}
96
97
98Kill Websocket Monitor
99 [Documentation] Terminate running websocket monitor.
100
101 ${pid_list}= Find Websocket Monitor
102 FOR ${pid} IN @{pid_list}
103 Shell Cmd kill -s SIGTERM ${pid}
104 END
105
106
107Print Websocket Monitor Log
108 [Documentation] Show the contents of the monitor output file.
109
110 ${websocket_monitor_log}= OperatingSystem.Get File ${monitor_file}
111 Log to Console websocket_monitor_log:
112 Log to Console ${websocket_monitor_log}
113
114
115Suite Setup Execution
116 [Documentation] Do the suite setup tasks.
117
118 Run Keyword Redfish Power On stack_mode=skip
119
120 Redfish.Login
121
122 Delete All Error Logs
123 Kill Websocket Monitor
124
125 # Allow time for Error Logs to be deleted.
126 Sleep 5s
127
128
129Test Teardown Execution
130 [Documentation] Do teardown tasks after a test.
131
132 FFDC On Test Case Fail
133 Run Keyword If '${TEST_STATUS}' == 'FAIL' Print Websocket Monitor Log
134 Kill Websocket Monitor
135
136
137Suite Teardown Execution
138 [Documentation] Do the post-suite teardown.
139
140 Delete All Error Logs
141 Run Keyword and Return Status Redfish.Logout