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