3 # Copyright (C) - 2013 David Goulet <dgoulet@efficios.com>
5 # This library is free software; you can redistribute it and/or modify it under
6 # the terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation; version 2.1 of the License. details.
9 # You should have received a copy of the GNU Lesser General Public License
10 # along with this library; if not, write to the Free Software Foundation, Inc.,
11 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 LAUNCH_APP
="launch_ust_app"
16 KILL_RELAYD_HELPER
="kill_relayd"
18 EVENT_NAME
="tp:tptest"
19 LOG_FILE_SESSIOND
="sessiond.log"
20 LOG_FILE_RELAYD
="relayd.log"
21 CHANNEL_NAME
="channel0"
25 COREDUMP_FILE
=$
(cat /proc
/sys
/kernel
/core_pattern
)
29 TEST_DESC
="Stress test - $NR_SESSION sessions per UID streaming with $NR_APP apps. The relayd is killed sporadically"
31 source $TESTDIR/utils
/utils.sh
33 # MUST set TESTDIR before calling those functions
35 function enable_channel_per_uid
()
40 $TESTDIR/..
/src
/bin
/lttng
/$LTTNG_BIN enable-channel
--buffers-uid -u $channel_name -s $sess_name >/dev
/null
2>&1
41 ok $?
"Enable channel $channel_name per UID for session $sess_name"
44 function check_sessiond
()
46 if [ -z "$(pgrep --full lt-lttng-sessiond)" ]; then
47 local str_date
=$
(date +%H
%M
%S-
%d
%m
%Y
)
49 diag
"!!!The session daemon died unexpectedly!!!"
50 mv $LOG_FILE_SESSIOND $LOG_FILE_SESSIOND-$str_date
51 if [ -e $COREDUMP_FILE ]; then
52 mv $COREDUMP_FILE $COREDUMP_FILE-$str_date
58 function start_sessiond
()
60 validate_kernel_version
62 fail
"Start session daemon"
63 BAIL_OUT
"*** Kernel too old for session daemon tests ***"
66 if [ -z $
(pgrep
--full lt-
$SESSIOND_BIN) ]; then
67 # We have to start it like this so the ulimit -c is used by this
68 # process. Also, we collect any error message printed out.
69 #$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
70 $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
71 #$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
73 ok
$status "Start session daemon"
81 if [ -z $
(pgrep
--full lt-
$RELAYD_BIN) ]; then
82 $TESTDIR/..
/src
/bin
/lttng-relayd
/$RELAYD_BIN $opt >$LOG_FILE_RELAYD 2>&1 &
83 ok $?
"Start lttng-relayd (opt: \"$opt\")"
87 function check_relayd
()
89 if [ -z "$(pgrep --full lt-lttng-relayd)" ]; then
90 local str_date
=$
(date +%H
%M
%S-
%d
%m
%Y
)
92 #diag "Relay daemon died. Starting it again"
93 if [ -e $COREDUMP_FILE ]; then
94 mv $COREDUMP_FILE $COREDUMP_FILE-$str_date
102 for b
in $
(seq 1 $NR_LOOP); do
103 for a
in $
(seq 1 $NR_SESSION); do
104 create_lttng_session_uri
$SESSION_NAME-$a net
://localhost
107 enable_channel_per_uid
$SESSION_NAME-$a $CHANNEL_NAME
110 enable_ust_lttng_event_ok
$SESSION_NAME-$a $EVENT_NAME
113 start_lttng_tracing_ok
$SESSION_NAME-$a
118 for a
in $
(seq 1 $NR_SESSION); do
119 stop_lttng_tracing_ok
$SESSION_NAME-$a
122 destroy_lttng_session_ok
$SESSION_NAME-$a
134 for p
in ${APPS_PID}; do
136 wait ${p} 2>/dev
/null
143 function sighandler
()
146 #rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD
150 trap sighandler SIGINT
151 trap sighandler SIGTERM
153 # Make sure we collect a coredump if possible.
156 # MUST set TESTDIR before calling those functions
157 plan_tests
$NUM_TESTS
159 print_test_banner
"$TEST_DESC"
161 TRACE_PATH
=$
(mktemp
-d)
163 start_relayd
"-o $TRACE_PATH"
166 diag
"Starting applications launcher"
168 # Start NR_APP applications script that will spawn apps non stop.
169 .
/$TESTDIR/stress
/$LAUNCH_APP $NR_APP &
170 APPS_PID
="${APPS_PID} ${!}"
172 # Launch the helper script that will randomly kill the relayd at vitam eternam.
173 .
/$TESTDIR/stress
/$KILL_RELAYD_HELPER 1 1 &
174 APPS_PID
="${APPS_PID} ${!}"
178 if [ $out -ne 0 ]; then
185 rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD