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 preloaded testpoint override 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_cleanup
$KILL_SIGNAL
130 if [ ${test_consumerd} -eq 1 ]; then
131 stop_lttng_consumerd
$KILL_SIGNAL
133 stop_lttng_sessiond
$KILL_SIGNAL
135 unset LTTNG_TESTPOINT_ENABLE
136 unset ${test_thread_name}_
${test_suffix}
138 unset LTTNG_NETWORK_SOCKET_TIMEOUT
139 unset LTTNG_RELAYD_HEALTH
142 plan_tests
$NUM_TESTS
144 print_test_banner
"$TEST_DESC"
146 if [ -f "$CURDIR/$SESSIOND_PRELOAD" ]; then
152 skip
$foundobj "No shared object generated. Skipping all tests." $NUM_TESTS && exit 0
154 THREAD
=("LTTNG_SESSIOND_THREAD_MANAGE_CLIENTS"
155 "LTTNG_SESSIOND_THREAD_MANAGE_APPS"
156 "LTTNG_SESSIOND_THREAD_REG_APPS"
157 "LTTNG_SESSIOND_THREAD_HT_CLEANUP"
158 "LTTNG_SESSIOND_THREAD_APP_MANAGE_NOTIFY"
159 "LTTNG_SESSIOND_THREAD_APP_REG_DISPATCH"
160 "LTTNG_SESSIOND_THREAD_MANAGE_KERNEL"
162 "LTTNG_CONSUMERD_THREAD_CHANNEL"
163 "LTTNG_CONSUMERD_THREAD_METADATA"
164 "LTTNG_CONSUMERD_THREAD_METADATA_TIMER"
166 "LTTNG_RELAYD_THREAD_DISPATCHER"
167 "LTTNG_RELAYD_THREAD_WORKER"
168 "LTTNG_RELAYD_THREAD_LISTENER"
169 "LTTNG_RELAYD_THREAD_LIVE_DISPATCHER"
170 "LTTNG_RELAYD_THREAD_LIVE_WORKER"
171 "LTTNG_RELAYD_THREAD_LIVE_LISTENER"
175 "Thread \"Session daemon command\" is not responding in component \"sessiond\"."
176 "Thread \"Session daemon application manager\" is not responding in component \"sessiond\"."
177 "Thread \"Session daemon application registration\" is not responding in component \"sessiond\"."
178 "Thread \"Session daemon hash table cleanup\" is not responding in component \"sessiond\"."
179 "Thread \"Session daemon application notification manager\" is not responding in component \"sessiond\"."
180 "Thread \"Session daemon application registration dispatcher\" is not responding in component \"sessiond\"."
181 "Thread \"Session daemon kernel\" is not responding in component \"sessiond\"."
183 "Thread \"Consumer daemon channel\" is not responding"
184 "Thread \"Consumer daemon metadata\" is not responding"
185 "Thread \"Consumer daemon metadata timer\" is not responding"
187 "Thread \"Relay daemon dispatcher\" is not responding in component \"relayd\"."
188 "Thread \"Relay daemon worker\" is not responding in component \"relayd\"."
189 "Thread \"Relay daemon listener\" is not responding in component \"relayd\"."
190 "Thread \"Relay daemon live dispatcher\" is not responding in component \"relayd\"."
191 "Thread \"Relay daemon live worker\" is not responding in component \"relayd\"."
192 "Thread \"Relay daemon live listener\" is not responding in component \"relayd\"."
196 # "LTTNG_SESSIOND_THREAD_MANAGE_CONSUMER"
197 # "Thread \"Session daemon manage consumer\" is not responding in component \"sessiond\"."
199 # TODO: test kernel consumerd specifically in addition to UST consumerd
201 # TODO: need refactoring of consumerd teardown
202 # "LTTNG_CONSUMERD_THREAD_SESSIOND"
203 # "Thread \"Consumer daemon session daemon command manager\" is not responding"
205 # TODO: this thread is responsible for close a file descriptor that
206 # triggers teardown of metadata thread. We should revisit teardown of
208 # "LTTNG_CONSUMERD_THREAD_DATA"
209 # "Thread \"Consumer daemon data\" is not responding"
274 STDOUT_PATH
=$
(mktemp
)
275 STDERR_PATH
=$
(mktemp
)
276 TRACE_PATH
=$
(mktemp
-d)
277 HEALTH_PATH
=$
(mktemp
-d)
279 if [ "$(id -u)" == "0" ]; then
285 THREAD_COUNT
=${#THREAD[@]}
287 while [ "$i" -lt "$THREAD_COUNT" ]; do
288 test_health
"${TEST_SUFFIX}" \
290 "${ERROR_STRING[$i]}" \
291 "${NEEDS_ROOT[$i]}" \
292 "${TEST_CONSUMERD[$i]}" \
297 rm -rf ${HEALTH_PATH}