Commit | Line | Data |
---|---|---|
605ac758 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. | |
8 | # details. | |
9 | # | |
10 | # You should have received a copy of the GNU Lesser General Public License | |
11 | # along with this library; if not, write to the Free Software Foundation, Inc., | |
12 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
13 | ||
14 | ||
15 | CURDIR=$(dirname $0)/ | |
16 | TESTDIR=$CURDIR/.. | |
17 | LAUNCH_APP="launch_ust_app" | |
18 | SESSION_NAME="stress" | |
19 | EVENT_NAME="tp:tptest" | |
20 | LOG_FILE="sessiond.log" | |
21 | CHANNEL_NAME="channel0" | |
22 | NUM_TESTS=16 | |
23 | NR_APP=10 | |
24 | NR_SESSION=5 | |
25 | NR_LOOP=1000 | |
26 | COREDUMP_FILE=$(cat /proc/sys/kernel/core_pattern) | |
27 | ||
28 | TEST_DESC="Stress test - $NR_SESSION sessions per UID with $NR_APP apps" | |
29 | ||
30 | source $TESTDIR/utils/utils.sh | |
31 | ||
32 | # MUST set TESTDIR before calling those functions | |
33 | ||
34 | function 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 | ||
43 | function check_sessiond() | |
44 | { | |
45 | if [ -z "$(pidof lt-lttng-sessiond)" ]; then | |
46 | local str_date=$(date +%H%M%S-%d%m%Y) | |
47 | ||
48 | diag "!!!The session daemon died unexpectedly!!!" | |
49 | mv $LOG_FILE $LOG_FILE-$str_date | |
50 | if [ -e $COREDUMP_FILE ]; then | |
51 | mv $COREDUMP_FILE $COREDUMP_FILE-$str_date | |
52 | fi | |
53 | exit 1 | |
54 | fi | |
55 | } | |
56 | ||
57 | function start_sessiond() | |
58 | { | |
59 | local SESSIOND_BIN="lttng-sessiond" | |
60 | ||
61 | validate_kernel_version | |
62 | if [ $? -ne 0 ]; then | |
63 | fail "Start session daemon" | |
64 | BAIL_OUT "*** Kernel too old for session daemon tests ***" | |
65 | fi | |
66 | ||
67 | if [ -z $(pidof lt-$SESSIOND_BIN) ]; then | |
68 | # We have to start it like this so the ulimit -c is used by this | |
69 | # process. Also, we collect any error message printed out. | |
70 | $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 2>&1 & | |
71 | status=$? | |
72 | # Wait for sessiond to bootstrap | |
73 | sleep 2 | |
74 | ok $status "Start session daemon" | |
75 | fi | |
76 | } | |
77 | ||
78 | test_stress() | |
79 | { | |
80 | for b in $(seq 1 $NR_LOOP); do | |
81 | for a in $(seq 1 $NR_SESSION); do | |
82 | create_lttng_session $SESSION_NAME-$a $TRACE_PATH | |
83 | check_sessiond | |
84 | enable_channel_per_uid $SESSION_NAME-$a $CHANNEL_NAME | |
85 | check_sessiond | |
86 | enable_ust_lttng_event $SESSION_NAME-$a $EVENT_NAME | |
87 | check_sessiond | |
88 | start_lttng_tracing $SESSION_NAME-$a | |
89 | check_sessiond | |
90 | done | |
91 | ||
92 | for a in $(seq 1 $NR_SESSION); do | |
93 | stop_lttng_tracing $SESSION_NAME-$a | |
94 | check_sessiond | |
95 | destroy_lttng_session $SESSION_NAME-$a | |
96 | check_sessiond | |
97 | done | |
98 | done | |
99 | ||
100 | return 0 | |
101 | } | |
102 | ||
103 | function cleanup() | |
104 | { | |
105 | diag "Cleaning up!" | |
106 | killall -9 $LAUNCH_APP | |
107 | stop_lttng_sessiond | |
108 | } | |
109 | ||
110 | function sighandler() | |
111 | { | |
112 | cleanup | |
113 | rm $LOG_FILE | |
114 | exit 1 | |
115 | } | |
116 | ||
117 | trap sighandler SIGINT | |
118 | ||
119 | # Make sure we collect a coredump if possible. | |
120 | ulimit -c unlimited | |
121 | ||
122 | # MUST set TESTDIR before calling those functions | |
123 | plan_tests $NUM_TESTS | |
124 | ||
125 | print_test_banner "$TEST_DESC" | |
126 | ||
127 | start_sessiond | |
128 | ||
129 | diag "Starting applications" | |
130 | ||
131 | # Start NR_APP applications script that will spawn apps non stop. | |
132 | ./$TESTDIR/stress/$LAUNCH_APP $NR_APP & | |
133 | ||
134 | TRACE_PATH=$(mktemp -d) | |
135 | ||
136 | test_stress | |
137 | out=$? | |
138 | if [ $out -ne 0 ]; then | |
139 | cleanup | |
140 | exit $out | |
141 | fi | |
142 | ||
143 | cleanup | |
144 | rm -rf $TRACE_PATH | |
145 | rm $LOG_FILE | |
146 | exit 0 |