Refactor: test: wrapper for create_lttng_session
[lttng-tools.git] / tests / stress / test_multi_sessions_per_uid_5app_streaming
CommitLineData
30d86f7d
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"
16SESSION_NAME="stress"
17EVENT_NAME="tp:tptest"
18LOG_FILE_SESSIOND="sessiond.log"
19LOG_FILE_RELAYD="relayd.log"
20CHANNEL_NAME="channel0"
21NR_APP=5
22NR_SESSION=5
23NR_LOOP=1000
24COREDUMP_FILE=$(cat /proc/sys/kernel/core_pattern)
25NUM_TESTS=16
7e635e71 26APPS_PID=
30d86f7d
DG
27
28TEST_DESC="Stress test - $NR_SESSION sessions per UID streaming with $NR_APP apps"
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 check_relayd()
67{
68 if [ -z "$(pidof lt-lttng-relayd)" ]; then
69 local str_date=$(date +%H%M%S-%d%m%Y)
70
71 diag "!!!The relay daemon died unexpectedly!!!"
72 mv $LOG_FILE_RELAYD $LOG_FILE_RELAYD-$str_date
73 if [ -e $COREDUMP_FILE ]; then
74 mv $COREDUMP_FILE $COREDUMP_FILE-$str_date
75 fi
76 exit 1
77 fi
78}
79
80function start_sessiond()
81{
82 local SESSIOND_BIN="lttng-sessiond"
83
84 validate_kernel_version
85 if [ $? -ne 0 ]; then
86 fail "Start session daemon"
87 BAIL_OUT "*** Kernel too old for session daemon tests ***"
88 fi
89
90 if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
91 # We have to start it like this so the ulimit -c is used by this
92 # process. Also, we collect any error message printed out.
0fc2834c 93 $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
30d86f7d 94 status=$?
30d86f7d
DG
95 ok $status "Start session daemon"
96 fi
97}
98
99function start_relayd
100{
101 local opt=$1
102 local RELAYD_BIN="lttng-relayd"
103
104 if [ -z $(pidof lt-$RELAYD_BIN) ]; then
105 $TESTDIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >$LOG_FILE_RELAYD 2>&1 &
106 ok $? "Start lttng-relayd (opt: \"$opt\")"
107 fi
108}
109
110test_stress()
111{
112 for b in $(seq 1 $NR_LOOP); do
113 for a in $(seq 1 $NR_SESSION); do
114 lttng_create_session_uri $SESSION_NAME-$a
115 check_sessiond
116 check_relayd
117 enable_channel_per_uid $SESSION_NAME-$a $CHANNEL_NAME
118 check_sessiond
119 check_relayd
120 enable_ust_lttng_event $SESSION_NAME-$a $EVENT_NAME
121 check_sessiond
122 check_relayd
123 start_lttng_tracing $SESSION_NAME-$a
124 check_sessiond
125 check_relayd
126 done
127
128 for a in $(seq 1 $NR_SESSION); do
129 stop_lttng_tracing $SESSION_NAME-$a
130 check_sessiond
131 check_relayd
132 destroy_lttng_session $SESSION_NAME-$a
133 check_sessiond
134 check_relayd
135 done
136 done
137
138 return 0
139}
140
141function cleanup()
142{
143 diag "Cleaning up!"
7e635e71
MD
144 for p in ${APPS_PID}; do
145 kill -s SIGKILL ${p}
146 wait ${p} 2>/dev/null
147 done
148 APPS_PID=
30d86f7d
DG
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
7e635e71 161trap sighandler SIGTERM
30d86f7d
DG
162
163# Make sure we collect a coredump if possible.
164ulimit -c unlimited
165
166# MUST set TESTDIR before calling those functions
167plan_tests $NUM_TESTS
168
169print_test_banner "$TEST_DESC"
170
171TRACE_PATH=$(mktemp -d)
172
173start_relayd "-o $TRACE_PATH"
174start_sessiond
175
176diag "Starting applications launcher"
177
178# Start NR_APP applications script that will spawn apps non stop.
179./$TESTDIR/stress/$LAUNCH_APP $NR_APP &
7e635e71 180APPS_PID="${APPS_PID} ${!}"
30d86f7d
DG
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.032677 seconds and 4 git commands to generate.