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