Fix: syscall event rule: emission sites not compared in is_equal
[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 # 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 --buffers-uid -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 # shellcheck disable=SC2119
134 stop_lttng_sessiond
135 # shellcheck disable=SC2119
136 stop_lttng_relayd
137 }
138
139 function sighandler()
140 {
141 cleanup
142 rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD
143 full_cleanup
144 }
145
146 trap sighandler SIGINT SIGTERM
147
148 # Make sure we collect a coredump if possible.
149 ulimit -c unlimited
150
151 # MUST set TESTDIR before calling those functions
152 plan_tests $NUM_TESTS
153
154 print_test_banner "$TEST_DESC"
155
156 TRACE_PATH=$(mktemp -d -t tmp.test_multi_sess_per_uid_5app_streaming.XXXXXX)
157
158 start_relayd "-o $TRACE_PATH"
159 start_sessiond
160
161 diag "Starting applications launcher"
162
163 # Start NR_APP applications script that will spawn apps non stop.
164 "./$TESTDIR/stress/$LAUNCH_APP" $NR_APP &
165 APP_PIDS+=(${!})
166
167 test_stress
168 out=$?
169 if [ $out -ne 0 ]; then
170 cleanup
171 exit $out
172 fi
173
174 cleanup
175 rm -rf "${TRACE_PATH:?}/"
176 rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD
177 exit 0
This page took 0.039402 seconds and 5 git commands to generate.