Debian Codegraph @

tests/stress/test_multi_sessions_per_uid_5app_streaming

raw symbols SCIP
1 #!/bin/bash
2 #
3 # SPDX-FileCopyrightText: 2013 David Goulet <[email protected]>
4 #
5 # SPDX-License-Identifier: LGPL-2.1-only
6 #
7
8 CURDIR=$(dirname "$0")/
9 TESTDIR="$CURDIR/.."
10 LAUNCH_APP="launch_ust_app"
11 SESSION_NAME="stress"
12 EVENT_NAME="tp:tptest"
13 LOG_FILE_SESSIOND="sessiond.log"
14 LOG_FILE_RELAYD="relayd.log"
15 CHANNEL_NAME="channel0"
16 NR_APP=5
17 NR_SESSION=5
18 NR_LOOP=1000
19 COREDUMP_FILE=$(cat /proc/sys/kernel/core_pattern)
20 NUM_TESTS=16
21 APP_PIDS=()
22
23 TEST_DESC="Stress test - $NR_SESSION sessions per UID streaming with $NR_APP apps"
24
25 # shellcheck source-path=SCRIPTDIR/../
26 source "$TESTDIR/utils/utils.sh"
27
28 # MUST set TESTDIR before calling those functions
29
30 function enable_channel_per_uid()
31 {
32 local sess_name=$1
33 local channel_name=$2
34
35 "$TESTDIR/../src/bin/lttng/$LTTNG_BIN" enable-channel --buffer-ownership=user -u "$channel_name" -s "$sess_name" >/dev/null 2>&1
36 ok $? "Enable channel $channel_name per UID for session $sess_name"
37 }
38
39 function check_sessiond()
40 {
41 local str_date
42 if [ -z "$(lttng_pgrep lttng-sessiond)" ]; then
43 str_date=$(date +%H%M%S-%d%m%Y)
44
45 diag "!!!The session daemon died unexpectedly!!!"
46 mv $LOG_FILE_SESSIOND "$LOG_FILE_SESSIOND-$str_date"
47 if [ -e "$COREDUMP_FILE" ]; then
48 mv "$COREDUMP_FILE" "$COREDUMP_FILE-$str_date"
49 fi
50 exit 1
51 fi
52 }
53
54 function check_relayd()
55 {
56 local str_date
57 if [ -z "$(lttng_pgrep lttng-relayd)" ]; then
58 str_date=$(date +%H%M%S-%d%m%Y)
59
60 diag "!!!The relay daemon died unexpectedly!!!"
61 mv $LOG_FILE_RELAYD "$LOG_FILE_RELAYD-$str_date"
62 if [ -e "$COREDUMP_FILE" ]; then
63 mv "$COREDUMP_FILE" "$COREDUMP_FILE-$str_date"
64 fi
65 exit 1
66 fi
67 }
68
69 function start_sessiond()
70 {
71 if ! validate_kernel_version ; then
72 fail "Start session daemon"
73 BAIL_OUT "*** Kernel too old for session daemon tests ***"
74 fi
75
76 if [ -z "$(lttng_pgrep lt-$SESSIOND_BIN)" ]; then
77 # We have to start it like this so the ulimit -c is used by this
78 # process. Also, we collect any error message printed out.
79 "$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
80 status=$?
81 ok $status "Start session daemon"
82 fi
83 }
84
85 function start_relayd
86 {
87 local opt=$1
88
89 if [ -z "$(lttng_pgrep lt-$RELAYD_BIN)" ]; then
90 "$TESTDIR/../src/bin/lttng-relayd/$RELAYD_BIN" "$opt" >"$LOG_FILE_RELAYD" 2>&1 &
91 ok $? "Start lttng-relayd (opt: \"$opt\")"
92 fi
93 }
94
95 test_stress()
96 {
97 # shellcheck disable=SC2034
98 for b in $(seq 1 $NR_LOOP); do
99 for a in $(seq 1 $NR_SESSION); do
100 create_lttng_session_uri $SESSION_NAME-"$a" net://localhost
101 check_sessiond
102 check_relayd
103 enable_channel_per_uid $SESSION_NAME-"$a" $CHANNEL_NAME
104 check_sessiond
105 check_relayd
106 enable_ust_lttng_event_ok $SESSION_NAME-"$a" $EVENT_NAME
107 check_sessiond
108 check_relayd
109 start_lttng_tracing_ok $SESSION_NAME-"$a"
110 check_sessiond
111 check_relayd
112 done
113
114 for a in $(seq 1 $NR_SESSION); do
115 stop_lttng_tracing_ok $SESSION_NAME-"$a"
116 check_sessiond
117 check_relayd
118 destroy_lttng_session_ok $SESSION_NAME-"$a"
119 check_sessiond
120 check_relayd
121 done
122 done
123
124 return 0
125 }
126
127 function cleanup()
128 {
129 diag "Cleaning up!"
130 kill -s SIGKILL "${APP_PIDS[@]}"
131 wait "${APP_PIDS[@]}" 2>/dev/null
132 APP_PIDS=()
133 stop_lttng_sessiond
134 stop_lttng_relayd
135 }
136
137 function sighandler()
138 {
139 cleanup
140 rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD
141 full_cleanup
142 }
143
144 trap sighandler SIGINT SIGTERM
145
146 # Make sure we collect a coredump if possible.
147 ulimit -c unlimited
148
149 # MUST set TESTDIR before calling those functions
150 plan_tests $NUM_TESTS
151
152 print_test_banner "$TEST_DESC"
153
154 TRACE_PATH=$(mktemp -d -t tmp.test_multi_sess_per_uid_5app_streaming.XXXXXX)
155
156 start_relayd "-o $TRACE_PATH"
157 start_sessiond
158
159 diag "Starting applications launcher"
160
161 # Start NR_APP applications script that will spawn apps non stop.
162 "./$TESTDIR/stress/$LAUNCH_APP" $NR_APP &
163 APP_PIDS+=(${!})
164
165 test_stress
166 out=$?
167 if [ $out -ne 0 ]; then
168 cleanup
169 exit $out
170 fi
171
172 cleanup
173 rm -rf "${TRACE_PATH:?}/"
174 rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD
175 exit 0