Add session configuration load capability to libconfig
[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
27
28TEST_DESC="Stress test - $NR_SESSION sessions per UID streaming with $NR_APP apps. The relayd is killed sporadically"
29
30source $TESTDIR/utils/utils.sh
31
32# MUST set TESTDIR before calling those functions
33
34function 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
43function lttng_create_session_uri
44{
45 local name=$1
46
47 # Create session with default path
48 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $name -U net://localhost >/dev/null 2>&1
49 ok $? "Create session on net://localhost"
50}
51
52function check_sessiond()
53{
54 if [ -z "$(pidof lt-lttng-sessiond)" ]; then
55 local str_date=$(date +%H%M%S-%d%m%Y)
56
57 diag "!!!The session daemon died unexpectedly!!!"
58 mv $LOG_FILE_SESSIOND $LOG_FILE_SESSIOND-$str_date
59 if [ -e $COREDUMP_FILE ]; then
60 mv $COREDUMP_FILE $COREDUMP_FILE-$str_date
61 fi
62 exit 1
63 fi
64}
65
66function start_sessiond()
67{
68 local SESSIOND_BIN="lttng-sessiond"
69
70 validate_kernel_version
71 if [ $? -ne 0 ]; then
72 fail "Start session daemon"
73 BAIL_OUT "*** Kernel too old for session daemon tests ***"
74 fi
75
76 if [ -z $(pidof 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 --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 --verbose-consumer -vvv --consumerd32-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" >$LOG_FILE_SESSIOND 2>&1 &
81 #$TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --consumerd32-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$TESTDIR/../src/bin/lttng-consumerd/lttng-consumerd" >$LOG_FILE_SESSIOND 2>&1 &
82 status=$?
83 # Wait for sessiond to bootstrap
84 sleep 2
85 ok $status "Start session daemon"
86 fi
87}
88
89function start_relayd
90{
91 local opt=$1
92 local RELAYD_BIN="lttng-relayd"
93
94 if [ -z $(pidof lt-$RELAYD_BIN) ]; then
95 $TESTDIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >$LOG_FILE_RELAYD 2>&1 &
96 ok $? "Start lttng-relayd (opt: \"$opt\")"
97 fi
98}
99
100function check_relayd()
101{
102 if [ -z "$(pidof lt-lttng-relayd)" ]; then
103 local str_date=$(date +%H%M%S-%d%m%Y)
104
105 #diag "Relay daemon died. Starting it again"
106 if [ -e $COREDUMP_FILE ]; then
107 mv $COREDUMP_FILE $COREDUMP_FILE-$str_date
108 fi
109 start_relayd
110 fi
111}
112
113test_stress()
114{
115 for b in $(seq 1 $NR_LOOP); do
116 for a in $(seq 1 $NR_SESSION); do
117 lttng_create_session_uri $SESSION_NAME-$a
118 check_sessiond
119 check_relayd
120 enable_channel_per_uid $SESSION_NAME-$a $CHANNEL_NAME
121 check_sessiond
122 check_relayd
123 enable_ust_lttng_event $SESSION_NAME-$a $EVENT_NAME
124 check_sessiond
125 check_relayd
126 start_lttng_tracing $SESSION_NAME-$a
127 check_sessiond
128 check_relayd
129 done
130
131 for a in $(seq 1 $NR_SESSION); do
132 stop_lttng_tracing $SESSION_NAME-$a
133 check_sessiond
134 check_relayd
135 destroy_lttng_session $SESSION_NAME-$a
136 check_sessiond
137 check_relayd
138 done
139 done
140
141 return 0
142}
143
144function cleanup()
145{
146 diag "Cleaning up!"
147 killall -9 $LAUNCH_APP
148 killall -9 $KILL_RELAYD_HELPER
149 stop_lttng_sessiond
150 stop_lttng_relayd
151}
152
153function sighandler()
154{
155 cleanup
156 #rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD
157 exit 1
158}
159
160trap sighandler SIGINT
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 &
179# Launch the helper script that will randomly kill the relayd at vitam eternam.
180./$TESTDIR/stress/$KILL_RELAYD_HELPER 1 1 &
181
182test_stress
183out=$?
184if [ $out -ne 0 ]; then
185 cleanup
186 exit $out
187fi
188
189cleanup
190rm -rf $TRACE_PATH
191rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD
192exit 0
This page took 0.029627 seconds and 4 git commands to generate.