1 # Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
2 # Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 # SPDX-License-Identifier: GPL-2.0-only
6 TESTDIR
=${CURDIR}/..
/..
/..
7 UST_EVENT_NAME
="tp:tptest"
8 KERNEL_EVENT_NAME
="sched_switch"
9 CHANNEL_NAME
="testchan"
10 HEALTH_CHECK_BIN
="health_check"
14 source $TESTDIR/utils
/utils.sh
16 function report_errors
18 test_thread_error_string
="$1"
20 err_no_relayd_match
="Error querying relayd health"
22 # Check for health errors
23 # Include inability to contact relayd health as an expected
24 # error, since this can happen whenever the relayd shutdown due
25 # to an error in any thread.
26 out
=$
(grep "${test_thread_error_string}" ${STDOUT_PATH} |
wc -l)
27 if [ $test_relayd -ne 0 ]; then
28 outerr
=$
(grep "${err_no_relayd_match}" ${STDERR_PATH} |
wc -l)
32 if [ $out -eq 0 ] && [ $outerr -eq 0 ]; then
33 fail
"Validation failure"
34 diag
"Health returned:"
55 test_thread_error_string
="$3"
60 diag
"Test health problem detection with ${test_thread_name}"
62 # Set the socket timeout to 5 so the health check detection
64 export LTTNG_NETWORK_SOCKET_TIMEOUT
=5
65 export LTTNG_RELAYD_HEALTH
="${HEALTH_PATH}/test-health"
68 export LTTNG_TESTPOINT_ENABLE
=1
70 # Activate specific thread test
71 export ${test_thread_name}_
${test_suffix}=1
73 # Spawn sessiond with preload healthexit lib
74 export LD_PRELOAD
="$CURDIR/$SESSIOND_PRELOAD"
76 diag
"Start session daemon"
79 if [ ${test_consumerd} -eq 1 ]; then
80 create_lttng_session_no_output
$SESSION_NAME
82 diag
"With UST consumer daemons"
83 enable_ust_lttng_event_ok
$SESSION_NAME $UST_EVENT_NAME $CHANNEL_NAME
85 skip
$isroot "Root access is needed. Skipping kernel consumer health check test." "1" ||
87 diag
"With kernel consumer daemon"
88 lttng_enable_kernel_event
$SESSION_NAME $KERNEL_EVENT_NAME $CHANNEL_NAME
90 start_lttng_tracing_ok
$SESSION_NAME
93 if [ ${test_relayd} -eq 1 ]; then
94 diag
"With relay daemon"
95 RELAYD_ARGS
="--relayd-path=${LTTNG_RELAYD_HEALTH}"
97 start_lttng_relayd
"-o $TRACE_PATH"
102 # Check health status, not caring about result
103 $CURDIR/$HEALTH_CHECK_BIN ${RELAYD_ARGS} \
107 diag
"Check after running for ${SLEEP_TIME} seconds"
110 # Check health status
111 $CURDIR/$HEALTH_CHECK_BIN ${RELAYD_ARGS} \
112 > ${STDOUT_PATH} 2> ${STDERR_PATH}
115 if [ ${test_needs_root} -eq 1 ]; then
116 skip
${isroot} "Root access needed for test \"${test_thread_name}\"." "1" ||
118 report_errors
"${test_thread_error_string}" "${test_relayd}"
121 report_errors
"${test_thread_error_string}" "${test_relayd}"
124 if [ ${test_relayd} -eq 1 ]; then
125 # We may fail to stop relayd here, and this is OK, since
126 # it may have been killed volountarily by testpoint.
127 stop_lttng_relayd_notap
$KILL_SIGNAL
129 stop_lttng_consumerd
$KILL_SIGNAL
130 stop_lttng_sessiond
$KILL_SIGNAL
132 unset LTTNG_TESTPOINT_ENABLE
133 unset ${test_thread_name}_
${test_suffix}
135 unset LTTNG_NETWORK_SOCKET_TIMEOUT
136 unset LTTNG_RELAYD_HEALTH
139 plan_tests
$NUM_TESTS
141 print_test_banner
"$TEST_DESC"
143 if [ -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
149 skip
$foundobj "No shared object generated. Skipping all tests." $NUM_TESTS && exit 0
151 THREAD
=("LTTNG_SESSIOND_THREAD_MANAGE_CLIENTS"
152 "LTTNG_SESSIOND_THREAD_MANAGE_APPS"
153 "LTTNG_SESSIOND_THREAD_REG_APPS"
154 "LTTNG_SESSIOND_THREAD_HT_CLEANUP"
155 "LTTNG_SESSIOND_THREAD_APP_MANAGE_NOTIFY"
156 "LTTNG_SESSIOND_THREAD_APP_REG_DISPATCH"
157 "LTTNG_SESSIOND_THREAD_MANAGE_KERNEL"
159 "LTTNG_CONSUMERD_THREAD_CHANNEL"
160 "LTTNG_CONSUMERD_THREAD_METADATA"
161 "LTTNG_CONSUMERD_THREAD_METADATA_TIMER"
163 "LTTNG_RELAYD_THREAD_DISPATCHER"
164 "LTTNG_RELAYD_THREAD_WORKER"
165 "LTTNG_RELAYD_THREAD_LISTENER"
166 "LTTNG_RELAYD_THREAD_LIVE_DISPATCHER"
167 "LTTNG_RELAYD_THREAD_LIVE_WORKER"
168 "LTTNG_RELAYD_THREAD_LIVE_LISTENER"
172 "Thread \"Session daemon command\" is not responding in component \"sessiond\"."
173 "Thread \"Session daemon application manager\" is not responding in component \"sessiond\"."
174 "Thread \"Session daemon application registration\" is not responding in component \"sessiond\"."
175 "Thread \"Session daemon hash table cleanup\" is not responding in component \"sessiond\"."
176 "Thread \"Session daemon application notification manager\" is not responding in component \"sessiond\"."
177 "Thread \"Session daemon application registration dispatcher\" is not responding in component \"sessiond\"."
178 "Thread \"Session daemon kernel\" is not responding in component \"sessiond\"."
180 "Thread \"Consumer daemon channel\" is not responding"
181 "Thread \"Consumer daemon metadata\" is not responding"
182 "Thread \"Consumer daemon metadata timer\" is not responding"
184 "Thread \"Relay daemon dispatcher\" is not responding in component \"relayd\"."
185 "Thread \"Relay daemon worker\" is not responding in component \"relayd\"."
186 "Thread \"Relay daemon listener\" is not responding in component \"relayd\"."
187 "Thread \"Relay daemon live dispatcher\" is not responding in component \"relayd\"."
188 "Thread \"Relay daemon live worker\" is not responding in component \"relayd\"."
189 "Thread \"Relay daemon live listener\" is not responding in component \"relayd\"."
193 # "LTTNG_SESSIOND_THREAD_MANAGE_CONSUMER"
194 # "Thread \"Session daemon manage consumer\" is not responding in component \"sessiond\"."
196 # TODO: test kernel consumerd specifically in addition to UST consumerd
198 # TODO: need refactoring of consumerd teardown
199 # "LTTNG_CONSUMERD_THREAD_SESSIOND"
200 # "Thread \"Consumer daemon session daemon command manager\" is not responding"
202 # TODO: this thread is responsible for close a file descriptor that
203 # triggers teardown of metadata thread. We should revisit teardown of
205 # "LTTNG_CONSUMERD_THREAD_DATA"
206 # "Thread \"Consumer daemon data\" is not responding"
271 STDOUT_PATH
=$
(mktemp
)
272 STDERR_PATH
=$
(mktemp
)
273 TRACE_PATH
=$
(mktemp
-d)
274 HEALTH_PATH
=$
(mktemp
-d)
276 if [ "$(id -u)" == "0" ]; then
282 THREAD_COUNT
=${#THREAD[@]}
284 while [ "$i" -lt "$THREAD_COUNT" ]; do
285 test_health
"${TEST_SUFFIX}" \
287 "${ERROR_STRING[$i]}" \
288 "${NEEDS_ROOT[$i]}" \
289 "${TEST_CONSUMERD[$i]}" \
294 rm -rf ${HEALTH_PATH}