3 # Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
4 # Copyright (C) - 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License, version 2 only, as
8 # published by the Free Software Foundation.
10 # This program is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 # You should have received a copy of the GNU General Public License along with
16 # this program; if not, write to the Free Software Foundation, Inc., 51
17 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 TEST_DESC
="Health check - Thread OK"
22 TESTDIR
=$CURDIR/..
/..
/..
24 SESSION_NAME
="health_thread_ok"
25 UST_EVENT_NAME
="tp:tptest"
26 KERNEL_EVENT_NAME
="sched_switch"
27 CHANNEL_NAME
="testchan"
28 HEALTH_CHECK_BIN
="health_check"
32 source $TESTDIR/utils
/utils.sh
34 function report_errors
36 # Report health errors
37 out
=$
(cat ${STDOUT_PATH} |
wc -l)
38 if [ $out -ne 0 ]; then
39 fail
"Validation failure"
40 diag
"Health returned:"
57 function test_thread_ok
61 # Set the socket timeout to 5 so the health check delta is set to 25.
62 export LTTNG_NETWORK_SOCKET_TIMEOUT
=5
63 export LTTNG_RELAYD_HEALTH
="${HEALTH_PATH}/test-health"
65 diag
"Only session daemon"
69 $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
72 diag
"With UST consumer daemons"
73 create_lttng_session_no_output
$SESSION_NAME
74 enable_ust_lttng_event_ok
$SESSION_NAME $UST_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}
82 skip
$isroot "Root access is needed. Skipping kernel consumer health check test." "5" ||
84 diag
"With kernel consumer daemon"
85 create_lttng_session_no_output
$SESSION_NAME
86 lttng_enable_kernel_event
$SESSION_NAME $KERNEL_EVENT_NAME $CHANNEL_NAME
87 start_lttng_tracing_ok
$SESSION_NAME
88 destroy_lttng_session_ok
$SESSION_NAME
91 $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
95 diag
"With relay daemon"
97 start_lttng_relayd
"-o $TRACE_PATH"
99 $CURDIR/$HEALTH_CHECK_BIN \
100 --relayd-path="${LTTNG_RELAYD_HEALTH}" \
101 > ${STDOUT_PATH} 2> ${STDERR_PATH}
105 diag
"Check after running for ${SLEEP_TIME} seconds"
108 # Check health status
109 $CURDIR/$HEALTH_CHECK_BIN \
110 --relayd-path="${LTTNG_RELAYD_HEALTH}" \
111 > ${STDOUT_PATH} 2> ${STDERR_PATH}
117 unset LTTNG_NETWORK_SOCKET_TIMEOUT
118 unset LTTNG_RELAYD_HEALTH
121 plan_tests
$NUM_TESTS
123 print_test_banner
"$TEST_DESC"
125 STDOUT_PATH
=$
(mktemp
)
126 STDERR_PATH
=$
(mktemp
)
127 TRACE_PATH
=$
(mktemp
-d)
128 HEALTH_PATH
=$
(mktemp
-d)
130 # The manage kernel thread is only spawned if we are root
131 if [ "$(id -u)" == "0" ]; then
139 rm -rf ${HEALTH_PATH}