663b7e4cb2eab1bf9bd1bb5ea7d9bb9a5f336c59
[lttng-tools.git] / tests / regression / tools / health / test_thread_ok
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 # SPDX-License-Identifier: GPL-2.0-only
7
8 TEST_DESC="Health check - Thread OK"
9
10 CURDIR=$(dirname $0)/
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"
17 NUM_TESTS=17
18 SLEEP_TIME=30
19
20 source $TESTDIR/utils/utils.sh
21
22 function report_errors
23 {
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:"
29 diag "stdout:"
30 file=${STDOUT_PATH}
31 while read line ; do
32 diag "$line"
33 done < ${file}
34
35 diag "stderr:"
36 file=${STDERR_PATH}
37 while read line ; do
38 diag "$line"
39 done < ${file}
40 else
41 pass "Validation OK"
42 fi
43 }
44
45 function test_thread_ok
46 {
47 diag "Test health OK"
48
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"
52
53 diag "Only session daemon"
54 start_lttng_sessiond
55
56 # Check health status
57 $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
58 report_errors
59
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
65
66 # Check health status
67 $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
68 report_errors
69
70 skip $isroot "Root access is needed. Skipping kernel consumer health check test." "5" ||
71 {
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
77
78 # Check health status
79 $CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
80 report_errors
81 }
82
83 diag "With relay daemon"
84
85 start_lttng_relayd "-o $TRACE_PATH"
86 # Check health status
87 $CURDIR/$HEALTH_CHECK_BIN \
88 --relayd-path="${LTTNG_RELAYD_HEALTH}" \
89 > ${STDOUT_PATH} 2> ${STDERR_PATH}
90 report_errors
91
92 # Wait
93 diag "Check after running for ${SLEEP_TIME} seconds"
94 sleep ${SLEEP_TIME}
95
96 # Check health status
97 $CURDIR/$HEALTH_CHECK_BIN \
98 --relayd-path="${LTTNG_RELAYD_HEALTH}" \
99 > ${STDOUT_PATH} 2> ${STDERR_PATH}
100 report_errors
101
102 stop_lttng_relayd
103 stop_lttng_sessiond
104
105 unset LTTNG_NETWORK_SOCKET_TIMEOUT
106 unset LTTNG_RELAYD_HEALTH
107 }
108
109 plan_tests $NUM_TESTS
110
111 print_test_banner "$TEST_DESC"
112
113 STDOUT_PATH=$(mktemp -t tmp.test_thread_ok_stdout_path.XXXXXX)
114 STDERR_PATH=$(mktemp -t tmp.test_thread_ok_stderr_path.XXXXXX)
115 TRACE_PATH=$(mktemp -d -t tmp.test_thread_ok_trace_path.XXXXXX)
116 HEALTH_PATH=$(mktemp -d -t tmp.test_thread_ok_trace_path.XXXXXX)
117
118 # The manage kernel thread is only spawned if we are root
119 if [ "$(id -u)" == "0" ]; then
120 isroot=1
121 else
122 isroot=0
123 fi
124
125 test_thread_ok
126
127 rm -rf ${HEALTH_PATH}
128 rm -rf ${TRACE_PATH}
129 rm -f ${STDOUT_PATH}
130 rm -f ${STDERR_PATH}
This page took 0.03316 seconds and 4 git commands to generate.