Fix: test flaky sleep and wait patterns
[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
26
27TEST_DESC="Stress test - $NR_SESSION sessions per UID streaming with $NR_APP apps"
28
29source $TESTDIR/utils/utils.sh
30
31# MUST set TESTDIR before calling those functions
32
33function enable_channel_per_uid()
34{
35 local sess_name=$1
36 local channel_name=$2
37
38 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-uid -u $channel_name -s $sess_name >/dev/null 2>&1
39 ok $? "Enable channel $channel_name per UID for session $sess_name"
40}
41
42function lttng_create_session_uri
43{
44 local name=$1
45
46 # Create session with default path
47 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $name -U net://localhost >/dev/null 2>&1
48 ok $? "Create session on net://localhost"
49}
50
51function check_sessiond()
52{
53 if [ -z "$(pidof lt-lttng-sessiond)" ]; then
54 local str_date=$(date +%H%M%S-%d%m%Y)
55
56 diag "!!!The session daemon died unexpectedly!!!"
57 mv $LOG_FILE_SESSIOND $LOG_FILE_SESSIOND-$str_date
58 if [ -e $COREDUMP_FILE ]; then
59 mv $COREDUMP_FILE $COREDUMP_FILE-$str_date
60 fi
61 exit 1
62 fi
63}
64
65function check_relayd()
66{
67 if [ -z "$(pidof lt-lttng-relayd)" ]; then
68 local str_date=$(date +%H%M%S-%d%m%Y)
69
70 diag "!!!The relay daemon died unexpectedly!!!"
71 mv $LOG_FILE_RELAYD $LOG_FILE_RELAYD-$str_date
72 if [ -e $COREDUMP_FILE ]; then
73 mv $COREDUMP_FILE $COREDUMP_FILE-$str_date
74 fi
75 exit 1
76 fi
77}
78
79function start_sessiond()
80{
81 local SESSIOND_BIN="lttng-sessiond"
82
83 validate_kernel_version
84 if [ $? -ne 0 ]; then
85 fail "Start session daemon"
86 BAIL_OUT "*** Kernel too old for session daemon tests ***"
87 fi
88
89 if [ -z $(pidof lt-$SESSIOND_BIN) ]; then
90 # We have to start it like this so the ulimit -c is used by this
91 # process. Also, we collect any error message printed out.
0fc2834c 92 $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 93 status=$?
30d86f7d
DG
94 ok $status "Start session daemon"
95 fi
96}
97
98function start_relayd
99{
100 local opt=$1
101 local RELAYD_BIN="lttng-relayd"
102
103 if [ -z $(pidof lt-$RELAYD_BIN) ]; then
104 $TESTDIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >$LOG_FILE_RELAYD 2>&1 &
105 ok $? "Start lttng-relayd (opt: \"$opt\")"
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
119 enable_ust_lttng_event $SESSION_NAME-$a $EVENT_NAME
120 check_sessiond
121 check_relayd
122 start_lttng_tracing $SESSION_NAME-$a
123 check_sessiond
124 check_relayd
125 done
126
127 for a in $(seq 1 $NR_SESSION); do
128 stop_lttng_tracing $SESSION_NAME-$a
129 check_sessiond
130 check_relayd
131 destroy_lttng_session $SESSION_NAME-$a
132 check_sessiond
133 check_relayd
134 done
135 done
136
137 return 0
138}
139
140function cleanup()
141{
142 diag "Cleaning up!"
143 killall -9 $LAUNCH_APP
144 stop_lttng_sessiond
145 stop_lttng_relayd
146}
147
148function sighandler()
149{
150 cleanup
151 rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD
152 exit 1
153}
154
155trap sighandler SIGINT
156
157# Make sure we collect a coredump if possible.
158ulimit -c unlimited
159
160# MUST set TESTDIR before calling those functions
161plan_tests $NUM_TESTS
162
163print_test_banner "$TEST_DESC"
164
165TRACE_PATH=$(mktemp -d)
166
167start_relayd "-o $TRACE_PATH"
168start_sessiond
169
170diag "Starting applications launcher"
171
172# Start NR_APP applications script that will spawn apps non stop.
173./$TESTDIR/stress/$LAUNCH_APP $NR_APP &
174
175test_stress
176out=$?
177if [ $out -ne 0 ]; then
178 cleanup
179 exit $out
180fi
181
182cleanup
183rm -rf $TRACE_PATH
184rm $LOG_FILE_SESSIOND $LOG_FILE_RELAYD
185exit 0
This page took 0.031455 seconds and 4 git commands to generate.