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