1 # Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
2 # Copyright (C) - 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 # This program is free software; you can redistribute it and/or modify it
5 # under the terms of the GNU General Public License, version 2 only, as
6 # published by the Free Software Foundation.
8 # This program is distributed in the hope that it will be useful, but WITHOUT
9 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 # You should have received a copy of the GNU General Public License along with
14 # this program; if not, write to the Free Software Foundation, Inc., 51
15 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 TESTDIR
=${CURDIR}/..
/..
/..
19 UST_EVENT_NAME
="tp:tptest"
20 KERNEL_EVENT_NAME
="sched_switch"
21 CHANNEL_NAME
="testchan"
22 HEALTH_CHECK_BIN
="health_check"
26 source $TESTDIR/utils
/utils.sh
28 function report_errors
30 test_thread_error_string
="$1"
32 err_no_relayd_match
="Error querying relayd health"
34 # Check for health errors
35 # Include inability to contact relayd health as an expected
36 # error, since this can happen whenever the relayd shutdown due
37 # to an error in any thread.
38 out
=$
(grep "${test_thread_error_string}" ${STDOUT_PATH} |
wc -l)
39 if [ $test_relayd -ne 0 ]; then
40 outerr
=$
(grep "${err_no_relayd_match}" ${STDERR_PATH} |
wc -l)
44 if [ $out -eq 0 ] && [ $outerr -eq 0 ]; then
45 fail
"Validation failure"
46 diag
"Health returned:"
67 test_thread_error_string
="$3"
72 diag
"Test health problem detection with ${test_thread_name}"
74 # Set the socket timeout to 5 so the health check detection
76 export LTTNG_NETWORK_SOCKET_TIMEOUT
=5
77 export LTTNG_RELAYD_HEALTH
="${HEALTH_PATH}/test-health"
80 export LTTNG_TESTPOINT_ENABLE
=1
82 # Activate specific thread test
83 export ${test_thread_name}_
${test_suffix}=1
85 # Spawn sessiond with preload healthexit lib
86 export LD_PRELOAD
="$CURDIR/$SESSIOND_PRELOAD"
88 diag
"Start session daemon"
91 if [ ${test_consumerd} -eq 1 ]; then
92 create_lttng_session_no_output
$SESSION_NAME
94 diag
"With UST consumer daemons"
95 enable_ust_lttng_event_ok
$SESSION_NAME $UST_EVENT_NAME $CHANNEL_NAME
97 skip
$isroot "Root access is needed. Skipping kernel consumer health check test." "1" ||
99 diag
"With kernel consumer daemon"
100 lttng_enable_kernel_event
$SESSION_NAME $KERNEL_EVENT_NAME $CHANNEL_NAME
102 start_lttng_tracing_ok
$SESSION_NAME
105 if [ ${test_relayd} -eq 1 ]; then
106 diag
"With relay daemon"
107 RELAYD_ARGS
="--relayd-path=${LTTNG_RELAYD_HEALTH}"
109 start_lttng_relayd
"-o $TRACE_PATH"
114 # Check health status, not caring about result
115 $CURDIR/$HEALTH_CHECK_BIN ${RELAYD_ARGS} \
119 diag
"Check after running for ${SLEEP_TIME} seconds"
122 # Check health status
123 $CURDIR/$HEALTH_CHECK_BIN ${RELAYD_ARGS} \
124 > ${STDOUT_PATH} 2> ${STDERR_PATH}
127 if [ ${test_needs_root} -eq 1 ]; then
128 skip
${isroot} "Root access needed for test \"${test_thread_name}\"." "1" ||
130 report_errors
"${test_thread_error_string}" "${test_relayd}"
133 report_errors
"${test_thread_error_string}" "${test_relayd}"
136 if [ ${test_relayd} -eq 1 ]; then
137 # We may fail to stop relayd here, and this is OK, since
138 # it may have been killed volountarily by testpoint.
139 stop_lttng_relayd_notap
$KILL_SIGNAL
141 stop_lttng_consumerd
$KILL_SIGNAL
142 stop_lttng_sessiond
$KILL_SIGNAL
144 unset LTTNG_TESTPOINT_ENABLE
145 unset ${test_thread_name}_
${test_suffix}
147 unset LTTNG_NETWORK_SOCKET_TIMEOUT
148 unset LTTNG_RELAYD_HEALTH
151 plan_tests
$NUM_TESTS
153 print_test_banner
"$TEST_DESC"
155 if [ -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
161 skip
$foundobj "No shared object generated. Skipping all tests." $NUM_TESTS && exit 0
163 THREAD
=("LTTNG_SESSIOND_THREAD_MANAGE_CLIENTS"
164 "LTTNG_SESSIOND_THREAD_MANAGE_APPS"
165 "LTTNG_SESSIOND_THREAD_REG_APPS"
166 "LTTNG_SESSIOND_THREAD_HT_CLEANUP"
167 "LTTNG_SESSIOND_THREAD_APP_MANAGE_NOTIFY"
168 "LTTNG_SESSIOND_THREAD_APP_REG_DISPATCH"
169 "LTTNG_SESSIOND_THREAD_MANAGE_KERNEL"
171 "LTTNG_CONSUMERD_THREAD_CHANNEL"
172 "LTTNG_CONSUMERD_THREAD_METADATA"
173 "LTTNG_CONSUMERD_THREAD_METADATA_TIMER"
175 "LTTNG_RELAYD_THREAD_DISPATCHER"
176 "LTTNG_RELAYD_THREAD_WORKER"
177 "LTTNG_RELAYD_THREAD_LISTENER"
178 "LTTNG_RELAYD_THREAD_LIVE_DISPATCHER"
179 "LTTNG_RELAYD_THREAD_LIVE_WORKER"
180 "LTTNG_RELAYD_THREAD_LIVE_LISTENER"
184 "Thread \"Session daemon command\" is not responding in component \"sessiond\"."
185 "Thread \"Session daemon application manager\" is not responding in component \"sessiond\"."
186 "Thread \"Session daemon application registration\" is not responding in component \"sessiond\"."
187 "Thread \"Session daemon hash table cleanup\" is not responding in component \"sessiond\"."
188 "Thread \"Session daemon application notification manager\" is not responding in component \"sessiond\"."
189 "Thread \"Session daemon application registration dispatcher\" is not responding in component \"sessiond\"."
190 "Thread \"Session daemon kernel\" is not responding in component \"sessiond\"."
192 "Thread \"Consumer daemon channel\" is not responding"
193 "Thread \"Consumer daemon metadata\" is not responding"
194 "Thread \"Consumer daemon metadata timer\" is not responding"
196 "Thread \"Relay daemon dispatcher\" is not responding in component \"relayd\"."
197 "Thread \"Relay daemon worker\" is not responding in component \"relayd\"."
198 "Thread \"Relay daemon listener\" is not responding in component \"relayd\"."
199 "Thread \"Relay daemon live dispatcher\" is not responding in component \"relayd\"."
200 "Thread \"Relay daemon live worker\" is not responding in component \"relayd\"."
201 "Thread \"Relay daemon live listener\" is not responding in component \"relayd\"."
205 # "LTTNG_SESSIOND_THREAD_MANAGE_CONSUMER"
206 # "Thread \"Session daemon manage consumer\" is not responding in component \"sessiond\"."
208 # TODO: test kernel consumerd specifically in addition to UST consumerd
210 # TODO: need refactoring of consumerd teardown
211 # "LTTNG_CONSUMERD_THREAD_SESSIOND"
212 # "Thread \"Consumer daemon session daemon command manager\" is not responding"
214 # TODO: this thread is responsible for close a file descriptor that
215 # triggers teardown of metadata thread. We should revisit teardown of
217 # "LTTNG_CONSUMERD_THREAD_DATA"
218 # "Thread \"Consumer daemon data\" is not responding"
283 STDOUT_PATH
=$
(mktemp
)
284 STDERR_PATH
=$
(mktemp
)
285 TRACE_PATH
=$
(mktemp
-d)
286 HEALTH_PATH
=$
(mktemp
-d)
288 if [ "$(id -u)" == "0" ]; then
294 THREAD_COUNT
=${#THREAD[@]}
296 while [ "$i" -lt "$THREAD_COUNT" ]; do
297 test_health
"${TEST_SUFFIX}" \
299 "${ERROR_STRING[$i]}" \
300 "${NEEDS_ROOT[$i]}" \
301 "${TEST_CONSUMERD[$i]}" \
306 rm -rf ${HEALTH_PATH}