Fix: tests: `pgrep -f` flags unrelated process as lttng-sessiond
[lttng-tools.git] / tests / regression / tools / rotation / test_ust
1 #!/bin/bash
2 #
3 # Copyright (C) 2017 Julien Desfossez <jdesfossez@efficios.com>
4 #
5 # SPDX-License-Identifier: LGPL-2.1-only
6
7 TEST_DESC="Rotation - User space tracing"
8
9 CURDIR=$(dirname $0)/
10 TESTDIR=$CURDIR/../../..
11 NR_USEC_WAIT=0
12 TESTAPP_PATH="$TESTDIR/utils/testapp"
13 TESTAPP_NAME="gen-ust-events"
14 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
15 SESSION_NAME="stream"
16 EVENT_NAME="tp:tptest"
17
18 TRACE_PATH=$(mktemp -d)
19
20 NUM_TESTS=136
21
22 source $TESTDIR/utils/utils.sh
23 source $CURDIR/rotate_utils.sh
24
25 if [ ! -x "$TESTAPP_BIN" ]; then
26 BAIL_OUT "No UST events binary detected."
27 fi
28
29 function enable_channel_per_pid ()
30 {
31 sess_name=$1
32 channel_name=$2
33
34 enable_ust_lttng_channel_ok $sess_name $channel_name --buffers-pid
35 }
36
37 # MUST set TESTDIR before calling those functions
38
39 function rotate_ust_test ()
40 {
41 local_path=$1
42 app_path=$2
43 per_pid=$3
44
45 start_lttng_tracing_ok $SESSION_NAME
46 today=$(date +%Y%m%d)
47
48 $TESTAPP_BIN -i 10 -w $NR_USEC_WAIT > /dev/null 2>&1
49 rotate_session_ok $SESSION_NAME
50
51 $TESTAPP_BIN -i 20 -w $NR_USEC_WAIT > /dev/null 2>&1
52 stop_lttng_tracing_ok $SESSION_NAME
53
54 # Third chunk contains no event (rotate after stop).
55 rotate_session_ok $SESSION_NAME
56
57 destroy_lttng_session_ok $SESSION_NAME
58
59 validate_test_chunks "${local_path}" $today $app_path ust $per_pid
60 }
61
62 function test_ust_streaming_uid ()
63 {
64 diag "Test UST streaming with session rotation per UID"
65 create_lttng_session_uri $SESSION_NAME net://localhost
66 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
67
68 rotate_ust_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" "ust/uid/*/*/" 0
69 }
70
71 function test_ust_local_uid ()
72 {
73 diag "Test UST local with session rotation per UID"
74 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
75 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
76
77 rotate_ust_test "${TRACE_PATH}/archives" "ust/uid/*/*/" 0
78 }
79
80 function test_ust_streaming_pid ()
81 {
82 diag "Test UST streaming with session rotation per PID"
83 create_lttng_session_uri $SESSION_NAME net://localhost
84 enable_channel_per_pid $SESSION_NAME "channel0"
85 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0"
86
87 rotate_ust_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" "ust/pid/*/" 1
88 }
89
90 function test_ust_local_pid ()
91 {
92 diag "Test UST local with session rotation per PID"
93 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
94 enable_channel_per_pid $SESSION_NAME "channel0"
95 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0"
96
97 rotate_ust_test "${TRACE_PATH}/archives" "ust/pid/*/" 1
98 }
99
100 function test_ust_local_timer_uid ()
101 {
102 diag "Test ust local with session rotation timer per-uid"
103 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
104 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
105 lttng_enable_rotation_timer_ok $SESSION_NAME 500ms
106 start_lttng_tracing_ok $SESSION_NAME
107 # We just want the app to register, no event generated
108 $TESTAPP_BIN -i 0 -w 0 > /dev/null 2>&1
109
110 rotate_timer_test "${TRACE_PATH}/archives" 0
111 }
112
113 function test_ust_streaming_timer_uid ()
114 {
115 diag "Test ust remote with session rotation timer per-uid"
116 create_lttng_session_uri $SESSION_NAME net://localhost
117 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
118 lttng_enable_rotation_timer_ok $SESSION_NAME 500ms
119 start_lttng_tracing_ok $SESSION_NAME
120 # We just want the app to register, no event generated
121 $TESTAPP_BIN -i 0 -w 0 > /dev/null 2>&1
122
123 rotate_timer_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" 0
124 }
125
126 function test_ust_local_timer_pid ()
127 {
128 diag "Test ust local with session rotation timer per-pid"
129 create_lttng_session_ok $SESSION_NAME $TRACE_PATH
130 enable_channel_per_pid $SESSION_NAME "channel0"
131 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0"
132 lttng_enable_rotation_timer_ok $SESSION_NAME 500ms
133 start_lttng_tracing_ok $SESSION_NAME
134 # We just want the app to register, no event generated
135 $TESTAPP_BIN -i 0 -w 0 > /dev/null 2>&1
136
137 rotate_timer_test "${TRACE_PATH}/archives" 1
138 }
139
140 function test_ust_streaming_timer_pid ()
141 {
142 diag "Test ust remote with session rotation timer per-pid"
143 create_lttng_session_uri $SESSION_NAME net://localhost
144 enable_channel_per_pid $SESSION_NAME "channel0"
145 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME "channel0"
146 lttng_enable_rotation_timer_ok $SESSION_NAME 500ms
147 start_lttng_tracing_ok $SESSION_NAME
148 # We just want the app to register, no event generated
149 $TESTAPP_BIN -i 0 -w 0 > /dev/null 2>&1
150
151 rotate_timer_test "${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*/archives" 1
152 }
153
154 function test_incompatible_sessions ()
155 {
156 diag "Check incompatible session types with rotation"
157
158 diag "Live session with rotate timer"
159 # Should not be able to enable a rotation timer with a live session
160 create_lttng_session_uri $SESSION_NAME net://localhost --live
161 lttng_enable_rotation_timer_fail $SESSION_NAME 500ms
162 destroy_lttng_session_ok $SESSION_NAME
163
164 diag "Snapshot session with rotate timer"
165 # Should not be able to enable a rotation timer with a snapshot session
166 create_lttng_session_ok $SESSION_NAME $TRACE_PATH --snapshot
167 lttng_enable_rotation_timer_fail $SESSION_NAME 500ms
168 destroy_lttng_session_ok $SESSION_NAME
169
170 diag "Live session with rotate"
171 # Should not be able to rotate a live session
172 create_lttng_session_uri $SESSION_NAME net://localhost --live
173 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
174 start_lttng_tracing_ok $SESSION_NAME
175 rotate_session_fail $SESSION_NAME
176 destroy_lttng_session_ok $SESSION_NAME
177
178 diag "Snapshot session with rotate"
179 # Should not be able to rotate a snapshot session
180 create_lttng_session_ok $SESSION_NAME $TRACE_PATH --snapshot
181 enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME
182 start_lttng_tracing_ok $SESSION_NAME
183 rotate_session_fail $SESSION_NAME
184 destroy_lttng_session_ok $SESSION_NAME
185 }
186
187 plan_tests $NUM_TESTS
188
189 print_test_banner "$TEST_DESC"
190
191 start_lttng_relayd "-o $TRACE_PATH"
192 start_lttng_sessiond
193
194 tests=( test_ust_streaming_uid test_ust_local_uid \
195 test_ust_streaming_pid test_ust_local_pid \
196 test_ust_local_timer_uid test_ust_streaming_timer_uid \
197 test_ust_local_timer_pid test_ust_streaming_timer_pid \
198 test_incompatible_sessions )
199
200 for fct_test in ${tests[@]};
201 do
202 SESSION_NAME=$(randstring 16 0)
203 ${fct_test}
204 clean_path $TRACE_PATH
205 done
206
207 stop_lttng_sessiond
208 stop_lttng_relayd
209
210 # Remove tmp dir
211 rm -rf $TRACE_PATH
This page took 0.03425 seconds and 4 git commands to generate.