Tests: remove declaration already present in utils.sh
[lttng-tools.git] / tests / stress / test_multi_sessions_per_uid_5app_streaming_kill_relayd
CommitLineData
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
13CURDIR=$(dirname $0)/
14TESTDIR=$CURDIR/..
15LAUNCH_APP="launch_ust_app"
16KILL_RELAYD_HELPER="kill_relayd"
17SESSION_NAME="stress"
18EVENT_NAME="tp:tptest"
19LOG_FILE_SESSIOND="sessiond.log"
20LOG_FILE_RELAYD="relayd.log"
21CHANNEL_NAME="channel0"
22NR_APP=5
23NR_SESSION=5
24NR_LOOP=100000
25COREDUMP_FILE=$(cat /proc/sys/kernel/core_pattern)
26NUM_TESTS=16
7e635e71 27APPS_PID=
b3300ee2
DG
28
29TEST_DESC="Stress test - $NR_SESSION sessions per UID streaming with $NR_APP apps. The relayd is killed sporadically"
30
31source $TESTDIR/utils/utils.sh
32
33# MUST set TESTDIR before calling those functions
34
35function 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
44function 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
53function check_sessiond()
54{
db7b260c 55 if [ -z "$(pgrep --full lt-lttng-sessiond)" ]; then
b3300ee2
DG
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
67function start_sessiond()
68{
b3300ee2
DG
69 validate_kernel_version
70 if [ $? -ne 0 ]; then
71 fail "Start session daemon"
72 BAIL_OUT "*** Kernel too old for session daemon tests ***"
73 fi
74
db7b260c 75 if [ -z $(pgrep --full lt-$SESSIOND_BIN) ]; then
b3300ee2
DG
76 # We have to start it like this so the ulimit -c is used by this
77 # process. Also, we collect any error message printed out.
0fc2834c
MD
78 #$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
79 $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
80 #$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 81 status=$?
b3300ee2
DG
82 ok $status "Start session daemon"
83 fi
84}
85
86function start_relayd
87{
88 local opt=$1
b3300ee2 89
db7b260c 90 if [ -z $(pgrep --full lt-$RELAYD_BIN) ]; then
b3300ee2
DG
91 $TESTDIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >$LOG_FILE_RELAYD 2>&1 &
92 ok $? "Start lttng-relayd (opt: \"$opt\")"
93 fi
94}
95
96function check_relayd()
97{
db7b260c 98 if [ -z "$(pgrep --full lt-lttng-relayd)" ]; then
b3300ee2
DG
99 local str_date=$(date +%H%M%S-%d%m%Y)
100
101 #diag "Relay daemon died. Starting it again"
102 if [ -e $COREDUMP_FILE ]; then
103 mv $COREDUMP_FILE $COREDUMP_FILE-$str_date
104 fi
105 start_relayd
106 fi
107}
108
109test_stress()
110{
111 for b in $(seq 1 $NR_LOOP); do
112 for a in $(seq 1 $NR_SESSION); do
113 lttng_create_session_uri $SESSION_NAME-$a
114 check_sessiond
115 check_relayd
116 enable_channel_per_uid $SESSION_NAME-$a $CHANNEL_NAME
117 check_sessiond
118 check_relayd
c4926bb5 119 enable_ust_lttng_event_ok $SESSION_NAME-$a $EVENT_NAME
b3300ee2
DG
120 check_sessiond
121 check_relayd
e563bbdb 122 start_lttng_tracing_ok $SESSION_NAME-$a
b3300ee2
DG
123 check_sessiond
124 check_relayd
125 done
126
127 for a in $(seq 1 $NR_SESSION); do
96340a01 128 stop_lttng_tracing_ok $SESSION_NAME-$a
b3300ee2
DG
129 check_sessiond
130 check_relayd
67b4c664 131 destroy_lttng_session_ok $SESSION_NAME-$a
b3300ee2
DG
132 check_sessiond
133 check_relayd
134 done
135 done
136
137 return 0
138}
139
140function cleanup()
141{
142 diag "Cleaning up!"
7e635e71
MD
143 for p in ${APPS_PID}; do
144 kill ${p}
145 wait ${p} 2>/dev/null
146 done
147 APPS_PID=
b3300ee2
DG
148 stop_lttng_sessiond
149 stop_lttng_relayd
150}
151
152function sighandler()
153{
154 cleanup
155 #rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD
156 exit 1
157}
158
159trap sighandler SIGINT
7e635e71 160trap sighandler SIGTERM
b3300ee2
DG
161
162# Make sure we collect a coredump if possible.
163ulimit -c unlimited
164
165# MUST set TESTDIR before calling those functions
166plan_tests $NUM_TESTS
167
168print_test_banner "$TEST_DESC"
169
170TRACE_PATH=$(mktemp -d)
171
172start_relayd "-o $TRACE_PATH"
173start_sessiond
174
175diag "Starting applications launcher"
176
177# Start NR_APP applications script that will spawn apps non stop.
178./$TESTDIR/stress/$LAUNCH_APP $NR_APP &
7e635e71
MD
179APPS_PID="${APPS_PID} ${!}"
180
b3300ee2
DG
181# Launch the helper script that will randomly kill the relayd at vitam eternam.
182./$TESTDIR/stress/$KILL_RELAYD_HELPER 1 1 &
7e635e71 183APPS_PID="${APPS_PID} ${!}"
b3300ee2
DG
184
185test_stress
186out=$?
187if [ $out -ne 0 ]; then
188 cleanup
189 exit $out
190fi
191
192cleanup
193rm -rf $TRACE_PATH
194rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD
195exit 0
This page took 0.049906 seconds and 5 git commands to generate.