00778f83a1d55ab2d526471a1df5ca49cd8033f4
[lttng-tools.git] / tests / stress / test_multi_sessions_per_uid_5app_streaming_kill_relayd
1 #!/bin/bash
2 #
3 # Copyright (C) - 2013 David Goulet <dgoulet@efficios.com>
4 #
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.
8 #
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
12
13 CURDIR=$(dirname $0)/
14 TESTDIR=$CURDIR/..
15 LAUNCH_APP="launch_ust_app"
16 KILL_RELAYD_HELPER="kill_relayd"
17 SESSION_NAME="stress"
18 EVENT_NAME="tp:tptest"
19 LOG_FILE_SESSIOND="sessiond.log"
20 LOG_FILE_RELAYD="relayd.log"
21 CHANNEL_NAME="channel0"
22 NR_APP=5
23 NR_SESSION=5
24 NR_LOOP=100000
25 COREDUMP_FILE=$(cat /proc/sys/kernel/core_pattern)
26 NUM_TESTS=16
27 APPS_PID=
28
29 TEST_DESC="Stress test - $NR_SESSION sessions per UID streaming with $NR_APP apps. The relayd is killed sporadically"
30
31 source $TESTDIR/utils/utils.sh
32
33 # MUST set TESTDIR before calling those functions
34
35 function enable_channel_per_uid()
36 {
37 local sess_name=$1
38 local channel_name=$2
39
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"
42 }
43
44 function check_sessiond()
45 {
46 if [ -z "$(pgrep --full lt-lttng-sessiond)" ]; then
47 local str_date=$(date +%H%M%S-%d%m%Y)
48
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
53 fi
54 exit 1
55 fi
56 }
57
58 function start_sessiond()
59 {
60 local SESSIOND_BIN="lttng-sessiond"
61
62 validate_kernel_version
63 if [ $? -ne 0 ]; then
64 fail "Start session daemon"
65 BAIL_OUT "*** Kernel too old for session daemon tests ***"
66 fi
67
68 if [ -z $(pgrep --full lt-$SESSIOND_BIN) ]; then
69 # We have to start it like this so the ulimit -c is used by this
70 # process. Also, we collect any error message printed out.
71 #$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
72 $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
73 #$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
74 status=$?
75 ok $status "Start session daemon"
76 fi
77 }
78
79 function start_relayd
80 {
81 local opt=$1
82 local RELAYD_BIN="lttng-relayd"
83
84 if [ -z $(pgrep --full lt-$RELAYD_BIN) ]; then
85 $TESTDIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >$LOG_FILE_RELAYD 2>&1 &
86 ok $? "Start lttng-relayd (opt: \"$opt\")"
87 fi
88 }
89
90 function check_relayd()
91 {
92 if [ -z "$(pgrep --full lt-lttng-relayd)" ]; then
93 local str_date=$(date +%H%M%S-%d%m%Y)
94
95 #diag "Relay daemon died. Starting it again"
96 if [ -e $COREDUMP_FILE ]; then
97 mv $COREDUMP_FILE $COREDUMP_FILE-$str_date
98 fi
99 start_relayd
100 fi
101 }
102
103 test_stress()
104 {
105 for b in $(seq 1 $NR_LOOP); do
106 for a in $(seq 1 $NR_SESSION); do
107 create_lttng_session_uri $SESSION_NAME-$a net://localhost
108 check_sessiond
109 check_relayd
110 enable_channel_per_uid $SESSION_NAME-$a $CHANNEL_NAME
111 check_sessiond
112 check_relayd
113 enable_ust_lttng_event_ok $SESSION_NAME-$a $EVENT_NAME
114 check_sessiond
115 check_relayd
116 start_lttng_tracing_ok $SESSION_NAME-$a
117 check_sessiond
118 check_relayd
119 done
120
121 for a in $(seq 1 $NR_SESSION); do
122 stop_lttng_tracing_ok $SESSION_NAME-$a
123 check_sessiond
124 check_relayd
125 destroy_lttng_session_ok $SESSION_NAME-$a
126 check_sessiond
127 check_relayd
128 done
129 done
130
131 return 0
132 }
133
134 function cleanup()
135 {
136 diag "Cleaning up!"
137 for p in ${APPS_PID}; do
138 kill ${p}
139 wait ${p} 2>/dev/null
140 done
141 APPS_PID=
142 stop_lttng_sessiond
143 stop_lttng_relayd
144 }
145
146 function sighandler()
147 {
148 cleanup
149 #rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD
150 exit 1
151 }
152
153 trap sighandler SIGINT
154 trap sighandler SIGTERM
155
156 # Make sure we collect a coredump if possible.
157 ulimit -c unlimited
158
159 # MUST set TESTDIR before calling those functions
160 plan_tests $NUM_TESTS
161
162 print_test_banner "$TEST_DESC"
163
164 TRACE_PATH=$(mktemp -d)
165
166 start_relayd "-o $TRACE_PATH"
167 start_sessiond
168
169 diag "Starting applications launcher"
170
171 # Start NR_APP applications script that will spawn apps non stop.
172 ./$TESTDIR/stress/$LAUNCH_APP $NR_APP &
173 APPS_PID="${APPS_PID} ${!}"
174
175 # Launch the helper script that will randomly kill the relayd at vitam eternam.
176 ./$TESTDIR/stress/$KILL_RELAYD_HELPER 1 1 &
177 APPS_PID="${APPS_PID} ${!}"
178
179 test_stress
180 out=$?
181 if [ $out -ne 0 ]; then
182 cleanup
183 exit $out
184 fi
185
186 cleanup
187 rm -rf $TRACE_PATH
188 rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD
189 exit 0
This page took 0.034222 seconds and 4 git commands to generate.