Commit | Line | Data |
---|---|---|
b3300ee2 DG |
1 | #!/bin/bash |
2 | # | |
9d16b343 | 3 | # Copyright (C) 2013 David Goulet <dgoulet@efficios.com> |
b3300ee2 | 4 | # |
9d16b343 | 5 | # SPDX-License-Identifier: LGPL-2.1-only |
b3300ee2 | 6 | # |
b3300ee2 | 7 | |
c1896e2d KS |
8 | CURDIR=$(dirname "$0")/ |
9 | TESTDIR="$CURDIR/.." | |
b3300ee2 DG |
10 | LAUNCH_APP="launch_ust_app" |
11 | KILL_RELAYD_HELPER="kill_relayd" | |
12 | SESSION_NAME="stress" | |
13 | EVENT_NAME="tp:tptest" | |
14 | LOG_FILE_SESSIOND="sessiond.log" | |
15 | LOG_FILE_RELAYD="relayd.log" | |
16 | CHANNEL_NAME="channel0" | |
17 | NR_APP=5 | |
18 | NR_SESSION=5 | |
19 | NR_LOOP=100000 | |
20 | COREDUMP_FILE=$(cat /proc/sys/kernel/core_pattern) | |
21 | NUM_TESTS=16 | |
c1896e2d | 22 | APP_PIDS=() |
b3300ee2 DG |
23 | |
24 | TEST_DESC="Stress test - $NR_SESSION sessions per UID streaming with $NR_APP apps. The relayd is killed sporadically" | |
25 | ||
c1896e2d KS |
26 | # shellcheck source-path=SCRIPTDIR/../ |
27 | source "$TESTDIR/utils/utils.sh" | |
b3300ee2 DG |
28 | |
29 | # MUST set TESTDIR before calling those functions | |
30 | ||
31 | function enable_channel_per_uid() | |
32 | { | |
c1896e2d KS |
33 | local sess_name=$1 |
34 | local channel_name=$2 | |
b3300ee2 | 35 | |
c1896e2d KS |
36 | "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-channel --buffers-uid -u "$channel_name" -s "$sess_name" >/dev/null 2>&1 |
37 | ok $? "Enable channel $channel_name per UID for session $sess_name" | |
b3300ee2 DG |
38 | } |
39 | ||
b3300ee2 DG |
40 | function check_sessiond() |
41 | { | |
c1896e2d KS |
42 | local str_date |
43 | if [ -z "$(lttng_pgrep lttng-sessiond)" ]; then | |
44 | str_date=$(date +%H%M%S-%d%m%Y) | |
b3300ee2 DG |
45 | |
46 | diag "!!!The session daemon died unexpectedly!!!" | |
c1896e2d KS |
47 | mv $LOG_FILE_SESSIOND "$LOG_FILE_SESSIOND-$str_date" |
48 | if [ -e "$COREDUMP_FILE" ]; then | |
49 | mv "$COREDUMP_FILE" "$COREDUMP_FILE-$str_date" | |
b3300ee2 DG |
50 | fi |
51 | exit 1 | |
52 | fi | |
53 | } | |
54 | ||
55 | function start_sessiond() | |
56 | { | |
c1896e2d | 57 | if ! validate_kernel_version ; then |
b3300ee2 DG |
58 | fail "Start session daemon" |
59 | BAIL_OUT "*** Kernel too old for session daemon tests ***" | |
60 | fi | |
61 | ||
c1896e2d | 62 | if [ -z "$(lttng_pgrep $SESSIOND_BIN)" ]; then |
b3300ee2 DG |
63 | # We have to start it like this so the ulimit -c is used by this |
64 | # process. Also, we collect any error message printed out. | |
0fc2834c | 65 | #$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 |
c1896e2d | 66 | "$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 |
0fc2834c | 67 | #$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 | 68 | status=$? |
b3300ee2 DG |
69 | ok $status "Start session daemon" |
70 | fi | |
71 | } | |
72 | ||
73 | function start_relayd | |
74 | { | |
75 | local opt=$1 | |
b3300ee2 | 76 | |
c1896e2d KS |
77 | if [ -z "$(lttng_pgrep $RELAYD_BIN)" ]; then |
78 | "$TESTDIR/../src/bin/lttng-relayd/$RELAYD_BIN" "$opt" >$LOG_FILE_RELAYD 2>&1 & | |
b3300ee2 DG |
79 | ok $? "Start lttng-relayd (opt: \"$opt\")" |
80 | fi | |
81 | } | |
82 | ||
83 | function check_relayd() | |
84 | { | |
c1896e2d KS |
85 | local str_date |
86 | if [ -z "$(lttng_pgrep lttng-relayd)" ]; then | |
87 | str_date=$(date +%H%M%S-%d%m%Y) | |
b3300ee2 DG |
88 | |
89 | #diag "Relay daemon died. Starting it again" | |
c1896e2d KS |
90 | if [ -e "$COREDUMP_FILE" ]; then |
91 | mv "$COREDUMP_FILE" "$COREDUMP_FILE-$str_date" | |
b3300ee2 DG |
92 | fi |
93 | start_relayd | |
94 | fi | |
95 | } | |
96 | ||
97 | test_stress() | |
98 | { | |
c1896e2d | 99 | # shellcheck disable=SC2034 |
b3300ee2 DG |
100 | for b in $(seq 1 $NR_LOOP); do |
101 | for a in $(seq 1 $NR_SESSION); do | |
c1896e2d | 102 | create_lttng_session_uri $SESSION_NAME-"$a" net://localhost |
b3300ee2 DG |
103 | check_sessiond |
104 | check_relayd | |
c1896e2d | 105 | enable_channel_per_uid $SESSION_NAME-"$a" $CHANNEL_NAME |
b3300ee2 DG |
106 | check_sessiond |
107 | check_relayd | |
c1896e2d | 108 | enable_ust_lttng_event_ok $SESSION_NAME-"$a" $EVENT_NAME |
b3300ee2 DG |
109 | check_sessiond |
110 | check_relayd | |
c1896e2d | 111 | start_lttng_tracing_ok $SESSION_NAME-"$a" |
b3300ee2 DG |
112 | check_sessiond |
113 | check_relayd | |
114 | done | |
115 | ||
116 | for a in $(seq 1 $NR_SESSION); do | |
c1896e2d | 117 | stop_lttng_tracing_ok $SESSION_NAME-"$a" |
b3300ee2 DG |
118 | check_sessiond |
119 | check_relayd | |
c1896e2d | 120 | destroy_lttng_session_ok $SESSION_NAME-"$a" |
b3300ee2 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!" | |
c1896e2d KS |
132 | kill "${APP_PIDS[@]}" |
133 | wait "${APP_PIDS[@]}" 2>/dev/null | |
134 | APP_PIDS=() | |
135 | # shellcheck disable=SC2119 | |
b3300ee2 | 136 | stop_lttng_sessiond |
c1896e2d | 137 | # shellcheck disable=SC2119 |
b3300ee2 DG |
138 | stop_lttng_relayd |
139 | } | |
140 | ||
141 | function sighandler() | |
142 | { | |
143 | cleanup | |
144 | #rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD | |
3be453c9 | 145 | full_cleanup |
b3300ee2 DG |
146 | } |
147 | ||
3be453c9 | 148 | trap sighandler SIGINT SIGTERM |
b3300ee2 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 | ||
8d5a3312 | 158 | TRACE_PATH=$(mktemp -d -t tmp.test_multi_sess_per_uid_5app_kill_relayd.XXXXXX) |
b3300ee2 DG |
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. | |
c1896e2d KS |
166 | "./$TESTDIR/stress/$LAUNCH_APP" $NR_APP & |
167 | APP_PIDS+=(${!}) | |
7e635e71 | 168 | |
b3300ee2 | 169 | # Launch the helper script that will randomly kill the relayd at vitam eternam. |
c1896e2d KS |
170 | "./$TESTDIR/stress/$KILL_RELAYD_HELPER" 1 1 & |
171 | APP_PIDS+=(${!}) | |
b3300ee2 DG |
172 | |
173 | test_stress | |
174 | out=$? | |
175 | if [ $out -ne 0 ]; then | |
176 | cleanup | |
177 | exit $out | |
178 | fi | |
179 | ||
180 | cleanup | |
c1896e2d | 181 | rm -rf "${TRACE_PATH:?}/" |
b3300ee2 DG |
182 | rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD |
183 | exit 0 |