3 # Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
5 # SPDX-License-Identifier: LGPL-2.1-only
8 CURDIR
=$
(dirname "$0")/
10 LAUNCH_APP
="launch_ust_app"
11 KILL_RELAYD_HELPER
="kill_relayd"
13 EVENT_NAME
="tp:tptest"
14 LOG_FILE_SESSIOND
="sessiond.log"
15 LOG_FILE_RELAYD
="relayd.log"
16 CHANNEL_NAME
="channel0"
20 COREDUMP_FILE
=$
(cat /proc
/sys
/kernel
/core_pattern
)
24 TEST_DESC
="Stress test - $NR_SESSION sessions per UID streaming with $NR_APP apps. The relayd is killed sporadically"
26 # shellcheck source-path=SCRIPTDIR/../
27 source "$TESTDIR/utils/utils.sh"
29 # MUST set TESTDIR before calling those functions
31 function enable_channel_per_uid
()
36 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-channel
--buffers-uid -u "$channel_name" -s "$sess_name" >/dev
/null
2>&1
37 ok $?
"Enable channel $channel_name per UID for session $sess_name"
40 function check_sessiond
()
43 if [ -z "$(lttng_pgrep lttng-sessiond)" ]; then
44 str_date
=$
(date +%H
%M
%S-
%d
%m
%Y
)
46 diag
"!!!The session daemon died unexpectedly!!!"
47 mv $LOG_FILE_SESSIOND "$LOG_FILE_SESSIOND-$str_date"
48 if [ -e "$COREDUMP_FILE" ]; then
49 mv "$COREDUMP_FILE" "$COREDUMP_FILE-$str_date"
55 function start_sessiond
()
57 if ! validate_kernel_version
; then
58 fail
"Start session daemon"
59 BAIL_OUT
"*** Kernel too old for session daemon tests ***"
62 if [ -z "$(lttng_pgrep $SESSIOND_BIN)" ]; then
63 # We have to start it like this so the ulimit -c is used by this
64 # process. Also, we collect any error message printed out.
65 #$TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --quiet --background --consumerd32-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" >$LOG_FILE_SESSIOND 2>&1
66 "$TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN" --verbose-consumer -vvv --background --consumerd32-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" >$LOG_FILE_SESSIOND 2>&1
67 #$TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --consumerd32-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" >$LOG_FILE_SESSIOND 2>&1
69 ok
$status "Start session daemon"
77 if [ -z "$(lttng_pgrep $RELAYD_BIN)" ]; then
78 "$TESTDIR/../src/bin/lttng-relayd/$RELAYD_BIN" "$opt" >$LOG_FILE_RELAYD 2>&1 &
79 ok $?
"Start lttng-relayd (opt: \"$opt\")"
83 function check_relayd
()
86 if [ -z "$(lttng_pgrep lttng-relayd)" ]; then
87 str_date
=$
(date +%H
%M
%S-
%d
%m
%Y
)
89 #diag "Relay daemon died. Starting it again"
90 if [ -e "$COREDUMP_FILE" ]; then
91 mv "$COREDUMP_FILE" "$COREDUMP_FILE-$str_date"
99 # shellcheck disable=SC2034
100 for b
in $
(seq 1 $NR_LOOP); do
101 for a
in $
(seq 1 $NR_SESSION); do
102 create_lttng_session_uri
$SESSION_NAME-"$a" net
://localhost
105 enable_channel_per_uid
$SESSION_NAME-"$a" $CHANNEL_NAME
108 enable_ust_lttng_event_ok
$SESSION_NAME-"$a" $EVENT_NAME
111 start_lttng_tracing_ok
$SESSION_NAME-"$a"
116 for a
in $
(seq 1 $NR_SESSION); do
117 stop_lttng_tracing_ok
$SESSION_NAME-"$a"
120 destroy_lttng_session_ok
$SESSION_NAME-"$a"
132 kill "${APP_PIDS[@]}"
133 wait "${APP_PIDS[@]}" 2>/dev
/null
135 # shellcheck disable=SC2119
137 # shellcheck disable=SC2119
141 function sighandler
()
144 #rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD
148 trap sighandler SIGINT SIGTERM
150 # Make sure we collect a coredump if possible.
153 # MUST set TESTDIR before calling those functions
154 plan_tests
$NUM_TESTS
156 print_test_banner
"$TEST_DESC"
158 TRACE_PATH
=$
(mktemp
-d -t tmp.test_multi_sess_per_uid_5app_kill_relayd.XXXXXX
)
160 start_relayd
"-o $TRACE_PATH"
163 diag
"Starting applications launcher"
165 # Start NR_APP applications script that will spawn apps non stop.
166 "./$TESTDIR/stress/$LAUNCH_APP" $NR_APP &
169 # Launch the helper script that will randomly kill the relayd at vitam eternam.
170 "./$TESTDIR/stress/$KILL_RELAYD_HELPER" 1 1 &
175 if [ $out -ne 0 ]; then
181 rm -rf "${TRACE_PATH:?}/"
182 rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD