Tests: consolidate session creation with a uri parameter in utils.sh
[lttng-tools.git] / tests / regression / tools / rotation / test_ust
CommitLineData
e7716c6a
JD
1#!/bin/bash
2#
3# Copyright (C) - 2017 Julien Desfossez <jdesfossez@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#
9# This library is distributed in the hope that it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12# details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this library; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17TEST_DESC="Rotation - User space tracing"
18
19CURDIR=$(dirname $0)/
20TESTDIR=$CURDIR/../../..
21NR_ITER=1
22NR_USEC_WAIT=0
23TESTAPP_PATH="$TESTDIR/utils/testapp"
24TESTAPP_NAME="gen-ust-events"
25TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
26SESSION_NAME="stream"
27EVENT_NAME="tp:tptest"
28PID_RELAYD=0
29
30TRACE_PATH=$(mktemp -d)
31
32NUM_TESTS=146
33
34source $TESTDIR/utils/utils.sh
35source $CURDIR/rotate_utils.sh
36
37if [ ! -x "$TESTAPP_BIN" ]; then
38 BAIL_OUT "No UST events binary detected."
39fi
40
d09115ee 41function enable_channel_per_pid ()
e7716c6a
JD
42{
43 sess_name=$1
44 channel_name=$2
45
da0e4484 46 enable_ust_lttng_channel_ok $sess_name $channel_name --buffers-pid
e7716c6a
JD
47}
48
e7716c6a
JD
49# MUST set TESTDIR before calling those functions
50
51function rotate_ust_test ()
52{
53 local_path=$1
54 app_path=$2
55 per_pid=$3
56
57 start_lttng_tracing_ok $SESSION_NAME
58 today=$(date +%Y%m%d)
59
60 $TESTAPP_BIN 10 $NR_USEC_WAIT /dev/null 2>&1
61 rotate_session_ok $SESSION_NAME
62
63 $TESTAPP_BIN 20 $NR_USEC_WAIT /dev/null 2>&1
64 stop_lttng_tracing_ok $SESSION_NAME
65
66 # Third chunk contains no event (rotate after stop).
67 rotate_session_ok $SESSION_NAME
68
69 destroy_lttng_session_ok $SESSION_NAME
70
71 # The tests on the chunk folder rely on the date staying the same during
72 # the duration of the test, if this fail we will now why the other checks
73 # fail afterwards. There is a short window of time where an automated test
74 # could fail because of that.
75 now=$(date +%Y%m%d)
76 test $today = $now
77 ok $? "Date did not change during the test"
78
79 validate_test_chunks "${local_path}" $today $app_path ust $per_pid
80}
81
82function test_ust_streaming_uid ()
83{
84 diag "Test UST streaming with session rotation per UID"
f0d43d3d 85 create_lttng_session_uri $SESSION_NAME net://localhost
e7716c6a
JD
86 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
87
88 rotate_ust_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" "ust/uid/*/*/" 0
9dc506ae 89 clean_path $TRACE_PATH
e7716c6a
JD
90}
91
92function test_ust_local_uid ()
93{
94 diag "Test UST local with session rotation per UID"
95 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
96 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
97
98 rotate_ust_test "${TRACE_PATH}" "ust/uid/*/*/" 0
9dc506ae 99 clean_path $TRACE_PATH
e7716c6a
JD
100}
101
102function test_ust_streaming_pid ()
103{
104 diag "Test UST streaming with session rotation per PID"
f0d43d3d 105 create_lttng_session_uri $SESSION_NAME net://localhost
e7716c6a
JD
106 enable_channel_per_pid $SESSION_NAME "channel0"
107 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0"
108
109 rotate_ust_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" "ust/pid/*/" 1
9dc506ae 110 clean_path $TRACE_PATH
e7716c6a
JD
111}
112
113function test_ust_local_pid ()
114{
115 diag "Test UST local with session rotation per PID"
116 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
117 enable_channel_per_pid $SESSION_NAME "channel0"
118 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0"
119
120 rotate_ust_test "${TRACE_PATH}" "ust/pid/*/" 1
9dc506ae 121 clean_path $TRACE_PATH
e7716c6a
JD
122}
123
124function test_ust_local_timer_uid ()
125{
126 diag "Test ust local with session rotation timer per-uid"
127 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
128 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
129 lttng_enable_rotation_timer_ok $SESSION_NAME 500ms
130 start_lttng_tracing_ok $SESSION_NAME
131 # We just want the app to register, no event generated
132 $TESTAPP_BIN 0 0 /dev/null 2>&1
133
134 rotate_timer_test "${TRACE_PATH}" 0
9dc506ae 135 clean_path $TRACE_PATH
e7716c6a
JD
136}
137
138function test_ust_streaming_timer_uid ()
139{
140 diag "Test ust remote with session rotation timer per-uid"
f0d43d3d 141 create_lttng_session_uri $SESSION_NAME net://localhost
e7716c6a
JD
142 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
143 lttng_enable_rotation_timer_ok $SESSION_NAME 500ms
144 start_lttng_tracing_ok $SESSION_NAME
145 # We just want the app to register, no event generated
146 $TESTAPP_BIN 0 0 /dev/null 2>&1
147
148 rotate_timer_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" 0
9dc506ae 149 clean_path $TRACE_PATH
e7716c6a
JD
150}
151
152function test_ust_local_timer_pid ()
153{
154 diag "Test ust local with session rotation timer per-pid"
155 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
156 enable_channel_per_pid $SESSION_NAME "channel0"
157 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0"
158 lttng_enable_rotation_timer_ok $SESSION_NAME 500ms
159 start_lttng_tracing_ok $SESSION_NAME
160 # We just want the app to register, no event generated
161 $TESTAPP_BIN 0 0 /dev/null 2>&1
162
163 rotate_timer_test "${TRACE_PATH}" 1
9dc506ae 164 clean_path $TRACE_PATH
e7716c6a
JD
165}
166
167function test_ust_streaming_timer_pid ()
168{
169 diag "Test ust remote with session rotation timer per-pid"
f0d43d3d 170 create_lttng_session_uri $SESSION_NAME net://localhost
e7716c6a
JD
171 enable_channel_per_pid $SESSION_NAME "channel0"
172 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0"
173 lttng_enable_rotation_timer_ok $SESSION_NAME 500ms
174 start_lttng_tracing_ok $SESSION_NAME
175 # We just want the app to register, no event generated
176 $TESTAPP_BIN 0 0 /dev/null 2>&1
177
178 rotate_timer_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" 1
9dc506ae 179 clean_path $TRACE_PATH
e7716c6a
JD
180}
181
182function test_incompatible_sessions ()
183{
184 diag "Check incompatible session types with rotation"
185
186 diag "Live session with rotate timer"
187 # Should not be able to enable a rotation timer with a live session
188 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME --live >/dev/null 2>&1
189 lttng_enable_rotation_timer_fail $SESSION_NAME 500ms
190 destroy_lttng_session_ok $SESSION_NAME
191
192 diag "Snapshot session with rotate timer"
193 # Should not be able to enable a rotation timer with a snapshot session
194 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME --snapshot >/dev/null 2>&1
195 lttng_enable_rotation_timer_fail $SESSION_NAME 500ms
196 destroy_lttng_session_ok $SESSION_NAME
197
198 diag "Live session with rotate"
199 # Should not be able to rotate a live session
200 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME --live >/dev/null 2>&1
201 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
202 start_lttng_tracing_ok $SESSION_NAME
203 rotate_session_fail $SESSION_NAME
204 destroy_lttng_session_ok $SESSION_NAME
205
206 diag "Snapshot session with rotate"
207 # Should not be able to rotate a snapshot session
208 $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME --snapshot >/dev/null 2>&1
209 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
210 start_lttng_tracing_ok $SESSION_NAME
211 rotate_session_fail $SESSION_NAME
212 destroy_lttng_session_ok $SESSION_NAME
213
214}
215
216plan_tests $NUM_TESTS
217
218print_test_banner "$TEST_DESC"
219
220start_lttng_relayd "-o $TRACE_PATH"
221start_lttng_sessiond
222
223tests=( test_ust_streaming_uid test_ust_local_uid \
224 test_ust_streaming_pid test_ust_local_pid \
225 test_ust_local_timer_uid test_ust_streaming_timer_uid \
226 test_ust_local_timer_pid test_ust_streaming_timer_pid \
227 test_incompatible_sessions )
228
229for fct_test in ${tests[@]};
230do
231 SESSION_NAME=$(randstring 16 0)
232 ${fct_test}
233done
234
235stop_lttng_sessiond
236stop_lttng_relayd
9dc506ae
JR
237
238# Remove tmp dir
239rm -rf $TRACE_PATH
This page took 0.031609 seconds and 4 git commands to generate.