Tests: consolidate session creation with a uri parameter in utils.sh
[lttng-tools.git] / tests / regression / tools / rotation / test_ust
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
17 TEST_DESC="Rotation - User space tracing"
18
19 CURDIR=$(dirname $0)/
20 TESTDIR=$CURDIR/../../..
21 NR_ITER=1
22 NR_USEC_WAIT=0
23 TESTAPP_PATH="$TESTDIR/utils/testapp"
24 TESTAPP_NAME="gen-ust-events"
25 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
26 SESSION_NAME="stream"
27 EVENT_NAME="tp:tptest"
28 PID_RELAYD=0
29
30 TRACE_PATH=$(mktemp -d)
31
32 NUM_TESTS=146
33
34 source $TESTDIR/utils/utils.sh
35 source $CURDIR/rotate_utils.sh
36
37 if [ ! -x "$TESTAPP_BIN" ]; then
38 BAIL_OUT "No UST events binary detected."
39 fi
40
41 function enable_channel_per_pid ()
42 {
43 sess_name=$1
44 channel_name=$2
45
46 enable_ust_lttng_channel_ok $sess_name $channel_name --buffers-pid
47 }
48
49 # MUST set TESTDIR before calling those functions
50
51 function 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
82 function test_ust_streaming_uid ()
83 {
84 diag "Test UST streaming with session rotation per UID"
85 create_lttng_session_uri $SESSION_NAME net://localhost
86 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
87
88 rotate_ust_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*" "ust/uid/*/*/" 0
89 clean_path $TRACE_PATH
90 }
91
92 function 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
99 clean_path $TRACE_PATH
100 }
101
102 function test_ust_streaming_pid ()
103 {
104 diag "Test UST streaming with session rotation per PID"
105 create_lttng_session_uri $SESSION_NAME net://localhost
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
110 clean_path $TRACE_PATH
111 }
112
113 function 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
121 clean_path $TRACE_PATH
122 }
123
124 function 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
135 clean_path $TRACE_PATH
136 }
137
138 function test_ust_streaming_timer_uid ()
139 {
140 diag "Test ust remote with session rotation timer per-uid"
141 create_lttng_session_uri $SESSION_NAME net://localhost
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
149 clean_path $TRACE_PATH
150 }
151
152 function 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
164 clean_path $TRACE_PATH
165 }
166
167 function test_ust_streaming_timer_pid ()
168 {
169 diag "Test ust remote with session rotation timer per-pid"
170 create_lttng_session_uri $SESSION_NAME net://localhost
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
179 clean_path $TRACE_PATH
180 }
181
182 function 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
216 plan_tests $NUM_TESTS
217
218 print_test_banner "$TEST_DESC"
219
220 start_lttng_relayd "-o $TRACE_PATH"
221 start_lttng_sessiond
222
223 tests=( 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
229 for fct_test in ${tests[@]};
230 do
231 SESSION_NAME=$(randstring 16 0)
232 ${fct_test}
233 done
234
235 stop_lttng_sessiond
236 stop_lttng_relayd
237
238 # Remove tmp dir
239 rm -rf $TRACE_PATH
This page took 0.042113 seconds and 5 git commands to generate.