test: UST tracing destroy flush behavior with tracefile rotation
[lttng-tools.git] / tests / regression / ust / rotation-destroy-flush / test_rotation_destroy_flush
1 #!/bin/bash
2 #
3 # Copyright (C) - 2015 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
4 # Copyright (C) - 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 #
6 # This library is free software; you can redistribute it and/or modify it under
7 # the terms of the GNU Lesser General Public License as published by the Free
8 # Software Foundation; version 2.1 of the License.
9 #
10 # This library is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 # details.
14 #
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this library; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 TEST_DESC="UST - Rotation destroy flush"
19
20 CURDIR=$(dirname $0)/
21 TESTDIR=$CURDIR/../../..
22 SESSION_NAME="rotation_destroy_flush"
23
24 TESTAPP_PATH="$TESTDIR/utils/testapp"
25 TESTAPP_NAME="gen-ust-events"
26 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
27 NUM_EVENT=1000000
28 EVENT_NAME="tp:tptest"
29 CHANNEL_NAME="testchan"
30 PAGE_SIZE=$(getconf PAGE_SIZE)
31 SIZE_LIMIT=$PAGE_SIZE
32
33 NR_ITER=10
34 NUM_TESTS=$((15*$NR_ITER))
35
36 # Ensure the daemons invoke abort on error.
37 export LTTNG_ABORT_ON_ERROR=1
38
39 source $TESTDIR/utils/utils.sh
40
41 # MUST set TESTDIR before calling those functions
42 function run_app()
43 {
44 $TESTAPP_BIN $NUM_EVENT
45 ok $? "Application done"
46 }
47
48 function signal_cleanup()
49 {
50 diag "*** Exiting ***"
51 stop_lttng_sessiond
52 exit 1
53 }
54
55 function enable_ust_lttng_channel_size_limit ()
56 {
57 sess_name="$1"
58 channel_name="$2"
59 tracefile_size_limit="$3"
60
61 test_name="Enable channel $channel_name "
62 test_name+="for session $sess_name: "
63 test_name+="$tracefile_size_limit bytes tracefile limit"
64
65 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel \
66 -u $channel_name -s $sess_name --buffers-pid \
67 -C $tracefile_size_limit >/dev/null 2>&1
68
69 ok $? "$test_name"
70 }
71
72 function enable_ust_lttng_event_per_channel ()
73 {
74 sess_name="$1"
75 event_name="$2"
76 channel_name="$3"
77
78 test_name="Enable event $event_name "
79 test_name+="for session $sess_name "
80 test_name+="in channel $channel_name"
81
82 $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" \
83 -s $sess_name -u -c $channel_name >/dev/null 2>&1
84
85 ok $? "$test_name"
86 }
87
88 function test_rotation_destroy_flush_single()
89 {
90 start_lttng_sessiond
91
92 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
93 enable_ust_lttng_channel_size_limit \
94 $SESSION_NAME $CHANNEL_NAME $SIZE_LIMIT
95 enable_ust_lttng_event_per_channel \
96 $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
97 start_lttng_tracing_ok $SESSION_NAME
98 run_app
99 # stop and destroy
100 stop_lttng_tracing_ok $SESSION_NAME
101 destroy_lttng_session_ok $SESSION_NAME
102
103 rm -rf $TRACE_PATH
104
105 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
106 enable_ust_lttng_channel_size_limit \
107 $SESSION_NAME $CHANNEL_NAME $SIZE_LIMIT
108 enable_ust_lttng_event_per_channel \
109 $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
110 start_lttng_tracing_ok $SESSION_NAME
111 run_app
112 # destroy only
113 destroy_lttng_session_ok $SESSION_NAME
114
115 rm -rf $TRACE_PATH
116
117 stop_lttng_sessiond
118 }
119
120 function test_rotation_destroy_flush()
121 {
122 for a in $(seq 1 ${NR_ITER}); do
123 diag "Iteration ${a}/${NR_ITER}"
124 test_rotation_destroy_flush_single
125 done
126 }
127
128
129 plan_tests $NUM_TESTS
130
131 print_test_banner "$TEST_DESC"
132
133 TESTS=(
134 "test_rotation_destroy_flush"
135 )
136
137 TEST_COUNT=${#TESTS[@]}
138 i=0
139
140 while [ "$i" -lt "$TEST_COUNT" ]; do
141
142 trap signal_cleanup SIGTERM SIGINT
143
144 TRACE_PATH=$(mktemp -d)
145
146 # Execute test
147 ${TESTS[$i]}
148
149 let "i++"
150 done
This page took 0.047141 seconds and 4 git commands to generate.