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"
12 EVENT_NAME
="tp:tptest"
13 LOG_FILE_SESSIOND
="sessiond.log"
14 LOG_FILE_RELAYD
="relayd.log"
15 CHANNEL_NAME
="channel0"
19 COREDUMP_FILE
=$
(cat /proc
/sys
/kernel
/core_pattern
)
23 TEST_DESC
="Stress test - $NR_SESSION sessions per UID streaming with $NR_APP apps"
25 # shellcheck source-path=SCRIPTDIR/../
26 source "$TESTDIR/utils/utils.sh"
28 # MUST set TESTDIR before calling those functions
30 function enable_channel_per_uid
()
35 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-channel
--buffers-uid -u "$channel_name" -s "$sess_name" >/dev
/null
2>&1
36 ok $?
"Enable channel $channel_name per UID for session $sess_name"
39 function check_sessiond
()
42 if [ -z "$(lttng_pgrep lttng-sessiond)" ]; then
43 str_date
=$
(date +%H
%M
%S-
%d
%m
%Y
)
45 diag
"!!!The session daemon died unexpectedly!!!"
46 mv $LOG_FILE_SESSIOND "$LOG_FILE_SESSIOND-$str_date"
47 if [ -e "$COREDUMP_FILE" ]; then
48 mv "$COREDUMP_FILE" "$COREDUMP_FILE-$str_date"
54 function check_relayd
()
57 if [ -z "$(lttng_pgrep lttng-relayd)" ]; then
58 str_date
=$
(date +%H
%M
%S-
%d
%m
%Y
)
60 diag
"!!!The relay daemon died unexpectedly!!!"
61 mv $LOG_FILE_RELAYD "$LOG_FILE_RELAYD-$str_date"
62 if [ -e "$COREDUMP_FILE" ]; then
63 mv "$COREDUMP_FILE" "$COREDUMP_FILE-$str_date"
69 function start_sessiond
()
71 if ! validate_kernel_version
; then
72 fail
"Start session daemon"
73 BAIL_OUT
"*** Kernel too old for session daemon tests ***"
76 if [ -z "$(lttng_pgrep lt-$SESSIOND_BIN)" ]; then
77 # We have to start it like this so the ulimit -c is used by this
78 # process. Also, we collect any error message printed out.
79 "$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
81 ok
$status "Start session daemon"
89 if [ -z "$(lttng_pgrep lt-$RELAYD_BIN)" ]; then
90 "$TESTDIR/../src/bin/lttng-relayd/$RELAYD_BIN" "$opt" >"$LOG_FILE_RELAYD" 2>&1 &
91 ok $?
"Start lttng-relayd (opt: \"$opt\")"
97 # shellcheck disable=SC2034
98 for b
in $
(seq 1 $NR_LOOP); do
99 for a
in $
(seq 1 $NR_SESSION); do
100 create_lttng_session_uri
$SESSION_NAME-"$a" net
://localhost
103 enable_channel_per_uid
$SESSION_NAME-"$a" $CHANNEL_NAME
106 enable_ust_lttng_event_ok
$SESSION_NAME-"$a" $EVENT_NAME
109 start_lttng_tracing_ok
$SESSION_NAME-"$a"
114 for a
in $
(seq 1 $NR_SESSION); do
115 stop_lttng_tracing_ok
$SESSION_NAME-"$a"
118 destroy_lttng_session_ok
$SESSION_NAME-"$a"
130 kill -s SIGKILL
"${APP_PIDS[@]}"
131 wait "${APP_PIDS[@]}" 2>/dev
/null
133 # shellcheck disable=SC2119
135 # shellcheck disable=SC2119
139 function sighandler
()
142 rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD
146 trap sighandler SIGINT SIGTERM
148 # Make sure we collect a coredump if possible.
151 # MUST set TESTDIR before calling those functions
152 plan_tests
$NUM_TESTS
154 print_test_banner
"$TEST_DESC"
156 TRACE_PATH
=$
(mktemp
-d -t tmp.test_multi_sess_per_uid_5app_streaming.XXXXXX
)
158 start_relayd
"-o $TRACE_PATH"
161 diag
"Starting applications launcher"
163 # Start NR_APP applications script that will spawn apps non stop.
164 "./$TESTDIR/stress/$LAUNCH_APP" $NR_APP &
169 if [ $out -ne 0 ]; then
175 rm -rf "${TRACE_PATH:?}/"
176 rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD