eb68107d5d08b55e7f77516cdb7ac8bc99db1e0f
[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 --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 # Wait for sessiond to bootstrap
95 sleep 2
96 ok $status "Start session daemon"
97 fi
98 }
99
100 function start_relayd
101 {
102 local opt=$1
103 local RELAYD_BIN="lttng-relayd"
104
105 if [ -z $(pidof lt-$RELAYD_BIN) ]; then
106 $TESTDIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >$LOG_FILE_RELAYD 2>&1 &
107 ok $? "Start lttng-relayd (opt: \"$opt\")"
108 fi
109 }
110
111 test_stress()
112 {
113 for b in $(seq 1 $NR_LOOP); do
114 for a in $(seq 1 $NR_SESSION); do
115 lttng_create_session_uri $SESSION_NAME-$a
116 check_sessiond
117 check_relayd
118 enable_channel_per_uid $SESSION_NAME-$a $CHANNEL_NAME
119 check_sessiond
120 check_relayd
121 enable_ust_lttng_event $SESSION_NAME-$a $EVENT_NAME
122 check_sessiond
123 check_relayd
124 start_lttng_tracing $SESSION_NAME-$a
125 check_sessiond
126 check_relayd
127 done
128
129 for a in $(seq 1 $NR_SESSION); do
130 stop_lttng_tracing $SESSION_NAME-$a
131 check_sessiond
132 check_relayd
133 destroy_lttng_session $SESSION_NAME-$a
134 check_sessiond
135 check_relayd
136 done
137 done
138
139 return 0
140 }
141
142 function cleanup()
143 {
144 diag "Cleaning up!"
145 killall -9 $LAUNCH_APP
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
159 # Make sure we collect a coredump if possible.
160 ulimit -c unlimited
161
162 # MUST set TESTDIR before calling those functions
163 plan_tests $NUM_TESTS
164
165 print_test_banner "$TEST_DESC"
166
167 TRACE_PATH=$(mktemp -d)
168
169 start_relayd "-o $TRACE_PATH"
170 start_sessiond
171
172 diag "Starting applications launcher"
173
174 # Start NR_APP applications script that will spawn apps non stop.
175 ./$TESTDIR/stress/$LAUNCH_APP $NR_APP &
176
177 test_stress
178 out=$?
179 if [ $out -ne 0 ]; then
180 cleanup
181 exit $out
182 fi
183
184 cleanup
185 rm -rf $TRACE_PATH
186 rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD
187 exit 0
This page took 0.032658 seconds and 3 git commands to generate.