3 # Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
4 # Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 # SPDX-License-Identifier: GPL-2.0-only
8 TEST_DESC
="Health check - Thread OK"
11 TESTDIR
=$CURDIR/..
/..
/..
12 SESSION_NAME
="health_thread_ok"
13 UST_EVENT_NAME
="tp:tptest"
14 KERNEL_EVENT_NAME
="sched_switch"
15 CHANNEL_NAME
="testchan"
16 HEALTH_CHECK_BIN
="health_check"
20 source $TESTDIR/utils
/utils.sh
22 function report_errors
24 # Report health errors
25 out
=$
(cat ${STDOUT_PATH} |
wc -l)
26 if [ $out -ne 0 ]; then
27 fail
"Validation failure"
28 diag
"Health returned:"
45 function test_thread_ok
49 # Set the socket timeout to 5 so the health check delta is set to 25.
50 export LTTNG_NETWORK_SOCKET_TIMEOUT
=5
51 export LTTNG_RELAYD_HEALTH
="${HEALTH_PATH}/test-health"
53 diag
"Only session daemon"
57 $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
60 diag
"With UST consumer daemons"
61 create_lttng_session_no_output
$SESSION_NAME
62 enable_ust_lttng_event_ok
$SESSION_NAME $UST_EVENT_NAME $CHANNEL_NAME
63 start_lttng_tracing_ok
$SESSION_NAME
64 destroy_lttng_session_ok
$SESSION_NAME
67 $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
70 skip
$isroot "Root access is needed. Skipping kernel consumer health check test." "5" ||
72 diag
"With kernel consumer daemon"
73 create_lttng_session_no_output
$SESSION_NAME
74 lttng_enable_kernel_event
$SESSION_NAME $KERNEL_EVENT_NAME $CHANNEL_NAME
75 start_lttng_tracing_ok
$SESSION_NAME
76 destroy_lttng_session_ok
$SESSION_NAME
79 $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
83 diag
"With relay daemon"
85 start_lttng_relayd
"-o $TRACE_PATH"
87 $CURDIR/$HEALTH_CHECK_BIN \
88 --relayd-path="${LTTNG_RELAYD_HEALTH}" \
89 > ${STDOUT_PATH} 2> ${STDERR_PATH}
93 diag
"Check after running for ${SLEEP_TIME} seconds"
97 $CURDIR/$HEALTH_CHECK_BIN \
98 --relayd-path="${LTTNG_RELAYD_HEALTH}" \
99 > ${STDOUT_PATH} 2> ${STDERR_PATH}
105 unset LTTNG_NETWORK_SOCKET_TIMEOUT
106 unset LTTNG_RELAYD_HEALTH
109 plan_tests
$NUM_TESTS
111 print_test_banner
"$TEST_DESC"
113 STDOUT_PATH
=$
(mktemp
)
114 STDERR_PATH
=$
(mktemp
)
115 TRACE_PATH
=$
(mktemp
-d)
116 HEALTH_PATH
=$
(mktemp
-d)
118 # The manage kernel thread is only spawned if we are root
119 if [ "$(id -u)" == "0" ]; then
127 rm -rf ${HEALTH_PATH}