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 lttng_create_session_uri
36 # Create session with default path
37 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN create
$SESSION_NAME \
38 -U net
://localhost
>/dev
/null
2>&1
39 ok $?
"Create session with default path"
42 function report_errors
44 # Report health errors
45 out
=$
(cat ${STDOUT_PATH} |
wc -l)
46 if [ $out -ne 0 ]; then
47 fail
"Validation failure"
48 diag
"Health returned:"
65 function test_thread_ok
69 # Set the socket timeout to 5 so the health check delta is set to 25.
70 export LTTNG_NETWORK_SOCKET_TIMEOUT
=5
71 export LTTNG_RELAYD_HEALTH
="${HEALTH_PATH}/test-health"
73 diag
"Only session daemon"
77 $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
80 diag
"With UST consumer daemons"
81 create_lttng_session_no_output
$SESSION_NAME
82 enable_ust_lttng_event
$SESSION_NAME $UST_EVENT_NAME $CHANNEL_NAME
83 start_lttng_tracing
$SESSION_NAME
84 destroy_lttng_session
$SESSION_NAME
87 $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
90 skip
$isroot "Root access is needed. Skipping kernel consumer health check test." "5" ||
92 diag
"With kernel consumer daemon"
93 create_lttng_session_no_output
$SESSION_NAME
94 lttng_enable_kernel_event
$SESSION_NAME $KERNEL_EVENT_NAME $CHANNEL_NAME
95 start_lttng_tracing
$SESSION_NAME
96 destroy_lttng_session
$SESSION_NAME
99 $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
103 diag
"With relay daemon"
105 start_lttng_relayd
"-o $TRACE_PATH"
106 # Check health status
107 $CURDIR/$HEALTH_CHECK_BIN \
108 --relayd-path="${LTTNG_RELAYD_HEALTH}" \
109 > ${STDOUT_PATH} 2> ${STDERR_PATH}
113 diag
"Check after running for ${SLEEP_TIME} seconds"
116 # Check health status
117 $CURDIR/$HEALTH_CHECK_BIN \
118 --relayd-path="${LTTNG_RELAYD_HEALTH}" \
119 > ${STDOUT_PATH} 2> ${STDERR_PATH}
125 unset LTTNG_NETWORK_SOCKET_TIMEOUT
126 unset LTTNG_RELAYD_HEALTH
129 plan_tests
$NUM_TESTS
131 print_test_banner
"$TEST_DESC"
133 STDOUT_PATH
=$
(mktemp
)
134 STDERR_PATH
=$
(mktemp
)
135 TRACE_PATH
=$
(mktemp
-d)
136 HEALTH_PATH
=$
(mktemp
-d)
138 # The manage kernel thread is only spawned if we are root
139 if [ "$(id -u)" == "0" ]; then
147 rm -rf ${HEALTH_PATH}