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