Commit | Line | Data |
---|---|---|
b3300ee2 DG |
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 | |
d0f10e08 | 27 | APPS_PID= |
b3300ee2 DG |
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 lttng_create_session_uri | |
45 | { | |
46 | local name=$1 | |
47 | ||
48 | # Create session with default path | |
49 | $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $name -U net://localhost >/dev/null 2>&1 | |
50 | ok $? "Create session on net://localhost" | |
51 | } | |
52 | ||
53 | function check_sessiond() | |
54 | { | |
55 | if [ -z "$(pidof lt-lttng-sessiond)" ]; then | |
56 | local str_date=$(date +%H%M%S-%d%m%Y) | |
57 | ||
58 | diag "!!!The session daemon died unexpectedly!!!" | |
59 | mv $LOG_FILE_SESSIOND $LOG_FILE_SESSIOND-$str_date | |
60 | if [ -e $COREDUMP_FILE ]; then | |
61 | mv $COREDUMP_FILE $COREDUMP_FILE-$str_date | |
62 | fi | |
63 | exit 1 | |
64 | fi | |
65 | } | |
66 | ||
67 | function start_sessiond() | |
68 | { | |
69 | local SESSIOND_BIN="lttng-sessiond" | |
70 | ||
71 | validate_kernel_version | |
72 | if [ $? -ne 0 ]; then | |
73 | fail "Start session daemon" | |
74 | BAIL_OUT "*** Kernel too old for session daemon tests ***" | |
75 | fi | |
76 | ||
77 | if [ -z $(pidof lt-$SESSIOND_BIN) ]; then | |
78 | # We have to start it like this so the ulimit -c is used by this | |
79 | # process. Also, we collect any error message printed out. | |
d4607bc6 MD |
80 | #$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 |
81 | $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 | |
82 | #$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 | |
b3300ee2 | 83 | status=$? |
b3300ee2 DG |
84 | ok $status "Start session daemon" |
85 | fi | |
86 | } | |
87 | ||
88 | function start_relayd | |
89 | { | |
90 | local opt=$1 | |
91 | local RELAYD_BIN="lttng-relayd" | |
92 | ||
93 | if [ -z $(pidof lt-$RELAYD_BIN) ]; then | |
94 | $TESTDIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >$LOG_FILE_RELAYD 2>&1 & | |
95 | ok $? "Start lttng-relayd (opt: \"$opt\")" | |
96 | fi | |
97 | } | |
98 | ||
99 | function check_relayd() | |
100 | { | |
101 | if [ -z "$(pidof lt-lttng-relayd)" ]; then | |
102 | local str_date=$(date +%H%M%S-%d%m%Y) | |
103 | ||
104 | #diag "Relay daemon died. Starting it again" | |
105 | if [ -e $COREDUMP_FILE ]; then | |
106 | mv $COREDUMP_FILE $COREDUMP_FILE-$str_date | |
107 | fi | |
108 | start_relayd | |
109 | fi | |
110 | } | |
111 | ||
112 | test_stress() | |
113 | { | |
114 | for b in $(seq 1 $NR_LOOP); do | |
115 | for a in $(seq 1 $NR_SESSION); do | |
116 | lttng_create_session_uri $SESSION_NAME-$a | |
117 | check_sessiond | |
118 | check_relayd | |
119 | enable_channel_per_uid $SESSION_NAME-$a $CHANNEL_NAME | |
120 | check_sessiond | |
121 | check_relayd | |
122 | enable_ust_lttng_event $SESSION_NAME-$a $EVENT_NAME | |
123 | check_sessiond | |
124 | check_relayd | |
125 | start_lttng_tracing $SESSION_NAME-$a | |
126 | check_sessiond | |
127 | check_relayd | |
128 | done | |
129 | ||
130 | for a in $(seq 1 $NR_SESSION); do | |
131 | stop_lttng_tracing $SESSION_NAME-$a | |
132 | check_sessiond | |
133 | check_relayd | |
134 | destroy_lttng_session $SESSION_NAME-$a | |
135 | check_sessiond | |
136 | check_relayd | |
137 | done | |
138 | done | |
139 | ||
140 | return 0 | |
141 | } | |
142 | ||
143 | function cleanup() | |
144 | { | |
145 | diag "Cleaning up!" | |
d0f10e08 MD |
146 | for p in ${APPS_PID}; do |
147 | kill ${p} | |
148 | wait ${p} 2>/dev/null | |
149 | done | |
150 | APPS_PID= | |
b3300ee2 DG |
151 | stop_lttng_sessiond |
152 | stop_lttng_relayd | |
153 | } | |
154 | ||
155 | function sighandler() | |
156 | { | |
157 | cleanup | |
158 | #rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD | |
159 | exit 1 | |
160 | } | |
161 | ||
162 | trap sighandler SIGINT | |
d0f10e08 | 163 | trap sighandler SIGTERM |
b3300ee2 DG |
164 | |
165 | # Make sure we collect a coredump if possible. | |
166 | ulimit -c unlimited | |
167 | ||
168 | # MUST set TESTDIR before calling those functions | |
169 | plan_tests $NUM_TESTS | |
170 | ||
171 | print_test_banner "$TEST_DESC" | |
172 | ||
173 | TRACE_PATH=$(mktemp -d) | |
174 | ||
175 | start_relayd "-o $TRACE_PATH" | |
176 | start_sessiond | |
177 | ||
178 | diag "Starting applications launcher" | |
179 | ||
180 | # Start NR_APP applications script that will spawn apps non stop. | |
181 | ./$TESTDIR/stress/$LAUNCH_APP $NR_APP & | |
d0f10e08 MD |
182 | APPS_PID="${APPS_PID} ${!}" |
183 | ||
b3300ee2 DG |
184 | # Launch the helper script that will randomly kill the relayd at vitam eternam. |
185 | ./$TESTDIR/stress/$KILL_RELAYD_HELPER 1 1 & | |
d0f10e08 | 186 | APPS_PID="${APPS_PID} ${!}" |
b3300ee2 DG |
187 | |
188 | test_stress | |
189 | out=$? | |
190 | if [ $out -ne 0 ]; then | |
191 | cleanup | |
192 | exit $out | |
193 | fi | |
194 | ||
195 | cleanup | |
196 | rm -rf $TRACE_PATH | |
197 | rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD | |
198 | exit 0 |