Tests: consolidate session creation with a uri parameter in utils.sh
[lttng-tools.git] / tests / regression / tools / health / test_thread_ok
CommitLineData
de3f672b
MD
1#!/bin/bash
2#
3# Copyright (C) - 2012 Christian Babeux <christian.babeux@efficios.com>
4# Copyright (C) - 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5#
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.
9#
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
13# more details.
14#
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.
18
19TEST_DESC="Health check - Thread OK"
20
21CURDIR=$(dirname $0)/
22TESTDIR=$CURDIR/../../..
23LTTNG_BIN="lttng"
24SESSION_NAME="health_thread_ok"
25UST_EVENT_NAME="tp:tptest"
26KERNEL_EVENT_NAME="sched_switch"
27CHANNEL_NAME="testchan"
28HEALTH_CHECK_BIN="health_check"
29NUM_TESTS=17
30SLEEP_TIME=30
31
32source $TESTDIR/utils/utils.sh
33
de3f672b
MD
34function report_errors
35{
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:"
41 diag "stdout:"
42 file=${STDOUT_PATH}
43 while read line ; do
44 diag "$line"
45 done < ${file}
46
47 diag "stderr:"
48 file=${STDERR_PATH}
49 while read line ; do
50 diag "$line"
51 done < ${file}
52 else
53 pass "Validation OK"
54 fi
55}
56
57function test_thread_ok
58{
59 diag "Test health OK"
60
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"
64
65 diag "Only session daemon"
66 start_lttng_sessiond
67
68 # Check health status
69 $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
70 report_errors
71
72 diag "With UST consumer daemons"
73 create_lttng_session_no_output $SESSION_NAME
c4926bb5 74 enable_ust_lttng_event_ok $SESSION_NAME $UST_EVENT_NAME $CHANNEL_NAME
e563bbdb 75 start_lttng_tracing_ok $SESSION_NAME
67b4c664 76 destroy_lttng_session_ok $SESSION_NAME
de3f672b
MD
77
78 # Check health status
79 $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
80 report_errors
81
82 skip $isroot "Root access is needed. Skipping kernel consumer health check test." "5" ||
83 {
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
e563bbdb 87 start_lttng_tracing_ok $SESSION_NAME
67b4c664 88 destroy_lttng_session_ok $SESSION_NAME
de3f672b
MD
89
90 # Check health status
91 $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
92 report_errors
93 }
94
95 diag "With relay daemon"
96
97 start_lttng_relayd "-o $TRACE_PATH"
98 # Check health status
99 $CURDIR/$HEALTH_CHECK_BIN \
100 --relayd-path="${LTTNG_RELAYD_HEALTH}" \
101 > ${STDOUT_PATH} 2> ${STDERR_PATH}
102 report_errors
103
104 # Wait
a33d2d4a 105 diag "Check after running for ${SLEEP_TIME} seconds"
de3f672b
MD
106 sleep ${SLEEP_TIME}
107
108 # Check health status
109 $CURDIR/$HEALTH_CHECK_BIN \
110 --relayd-path="${LTTNG_RELAYD_HEALTH}" \
111 > ${STDOUT_PATH} 2> ${STDERR_PATH}
112 report_errors
113
114 stop_lttng_relayd
115 stop_lttng_sessiond
116
117 unset LTTNG_NETWORK_SOCKET_TIMEOUT
118 unset LTTNG_RELAYD_HEALTH
119}
120
121plan_tests $NUM_TESTS
122
123print_test_banner "$TEST_DESC"
124
125STDOUT_PATH=$(mktemp)
126STDERR_PATH=$(mktemp)
127TRACE_PATH=$(mktemp -d)
128HEALTH_PATH=$(mktemp -d)
129
130# The manage kernel thread is only spawned if we are root
131if [ "$(id -u)" == "0" ]; then
132 isroot=1
133else
134 isroot=0
135fi
136
137test_thread_ok
138
139rm -rf ${HEALTH_PATH}
140rm -rf ${TRACE_PATH}
141rm -f ${STDOUT_PATH}
142rm -f ${STDERR_PATH}
This page took 0.03519 seconds and 4 git commands to generate.