Fix: compat: 'LTTNG_UST_ABI_PROCNAME_LEN' is undeclared
[lttng-tools.git] / tests / regression / tools / save-load / test_load
1 #!/bin/bash
2 #
3 # Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
4 #
5 # SPDX-License-Identifier: LGPL-2.1-only
6
7 TEST_DESC="Load session(s)"
8
9 CURDIR=$(dirname $0)/
10 CONFIG_DIR="${CURDIR}/configuration"
11 TESTDIR=$CURDIR/../../../
12 export LTTNG_SESSION_CONFIG_XSD_PATH=$(readlink -m ${TESTDIR}../src/common/)
13
14 SESSION_NAME="load-42"
15 EVENT_NAME="tp:tptest"
16
17 DIR=$(readlink -f $TESTDIR)
18
19 NUM_TESTS=75
20
21 source $TESTDIR/utils/utils.sh
22
23 # MUST set TESTDIR before calling those functions
24 plan_tests $NUM_TESTS
25
26 print_test_banner "$TEST_DESC"
27
28 function test_basic_load()
29 {
30 diag "Test basic load"
31
32 lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng"
33
34 destroy_lttng_session_ok $SESSION_NAME
35 }
36
37 function test_complex_load()
38 {
39 local sess="$SESSION_NAME-complex"
40 local mi_result=""
41 local ret=1
42 diag "Test complex load"
43
44 # Start relayd with localhost binding. The complex session uses those
45 # custom values.
46 start_lttng_relayd "-C tcp://localhost:8172 -D tcp://localhost:9817"
47
48 lttng_load_ok "-i $CURDIR/$sess.lttng"
49
50 # Once loaded, we are suppose to be able to disable certain events/channels
51 # thus having a confirmation that it's valid
52 disable_ust_lttng_event $sess uevent1 chan1
53 disable_ust_lttng_event $sess uevent2 chan2
54 disable_ust_lttng_event $sess uevent3* chan3
55
56 disable_ust_lttng_channel $sess chan1
57 disable_ust_lttng_channel $sess chan2
58 disable_ust_lttng_channel $sess chan3
59
60 # Confirm that an event stored as disabled is restored in its disabled state
61 local mi_output_file=$(mktemp --tmpdir "tmp.${FUNCNAME[0]}_output_file.XXXXXX")
62 if [ $? -ne 0 ]; then
63 break;
64 fi
65 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list $sess -c chan2 > $mi_output_file
66 mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain[lttng:type='UST']/lttng:channels/lttng:channel[lttng:name='chan2']/lttng:events/lttng:event[lttng:name='uevent_disabled']/lttng:enabled/text()")
67 if [[ $mi_result = "false" ]]; then
68 ok 0 "Disabled event is loaded in disabled state"
69 else
70 fail "Disabled event is loaded in disabled state"
71 fi
72
73 mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:channels/lttng:channel[lttng:name='chan2']/lttng:events/lttng:event[lttng:name='uevent_disabled']/lttng:enabled/text()")
74 test $mi_result = "false"
75 ok $? "Disabled event is loaded in disabled state"
76
77 # Check that uevent_same_name_diff_llevel with log level 6 (TRACE_INFO) is enabled
78 # This ensure that the state of events with similar name but not same
79 # descriptor tuple (exclusion,filter,loglevel) is restored correctly.
80 mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:channels/lttng:channel[lttng:name='chan2']/lttng:events/lttng:event[lttng:name='uevent_same_name_diff_llevel' and lttng:loglevel='TRACE_INFO']/lttng:enabled/text()")
81 test $mi_result = "true"
82 ok $? "Enabled event with same name but different loglevel is in disabled state"
83
84 destroy_lttng_session_ok $sess
85
86 rm $mi_output_file
87 stop_lttng_relayd
88 rm -rf ${mi_output_file}
89 }
90
91 function test_all_load()
92 {
93 diag "Test load all sessions"
94
95 # Start relayd with localhost binding. The complex session uses those
96 # custom values.
97 start_lttng_relayd "-C tcp://localhost:8172 -D tcp://localhost:9817"
98
99 lttng_load_ok "-a -i $CURDIR"
100
101 destroy_lttng_session_ok $SESSION_NAME
102 destroy_lttng_session_ok "$SESSION_NAME-complex"
103 destroy_lttng_session_ok "$SESSION_NAME-trackers"
104 destroy_lttng_session_ok "tracker_legacy_all"
105 destroy_lttng_session_ok "tracker_legacy_none"
106 destroy_lttng_session_ok "tracker_legacy_selective"
107
108 stop_lttng_relayd
109 }
110
111 function test_overwrite()
112 {
113 diag "Test load overwrite"
114
115 lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng"
116
117 # This one should succeed
118 lttng_load_ok "-f -i $CURDIR $SESSION_NAME"
119
120 destroy_lttng_session_ok $SESSION_NAME
121 }
122
123 function test_trackers()
124 {
125 diag "Test trackers loading"
126
127 lttng_load_ok "-i $CURDIR/$SESSION_NAME-trackers.lttng"
128
129 diag "Test pid tracker"
130 local mi_output_file=$(mktemp --tmpdir "tmp.${FUNCNAME[0]}_output_file.XXXXXX")
131 if [ $? -ne 0 ]; then
132 break;
133 fi
134 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME-trackers" > $mi_output_file
135 mi_result=$($XML_NODE_CHECK $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:process_attr_trackers/lttng:vpid_process_attr_tracker/lttng:process_attr_values/lttng:vpid")
136 if [[ $mi_result = "true" ]]; then
137 ok 0 "VPID target is present"
138 else
139 fail "VPID target missing"
140 fi
141
142 mi_result=$($XML_NODE_CHECK $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:process_attr_trackers/lttng:vuid_process_attr_tracker/lttng:process_attr_values/lttng:vuid")
143 if [[ $mi_result = "true" ]]; then
144 ok 0 "VUID target is present"
145 else
146 fail "VUID target missing"
147 fi
148
149 mi_result=$($XML_NODE_CHECK $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:process_attr_trackers/lttng:vgid_process_attr_tracker/lttng:process_attr_values/lttng:vgid")
150 if [[ $mi_result = "true" ]]; then
151 ok 0 "VGID target is present"
152 else
153 fail "VGID target missing"
154 fi
155
156 # Test to remove the target just to make sure
157 lttng_untrack_ok "--vpid 666 -u -s $SESSION_NAME-trackers"
158 lttng_untrack_ok "--vuid 777 -u -s $SESSION_NAME-trackers"
159 lttng_untrack_ok "--vgid 888 -u -s $SESSION_NAME-trackers"
160 # Actually using vpid (backward compat)
161 lttng_untrack_ok "--pid 999 -u -s $SESSION_NAME-trackers"
162
163 destroy_lttng_session_ok "$SESSION_NAME-trackers"
164 rm -f ${mi_output_file}
165 }
166
167 function test_override_url_normal()
168 {
169 local local_url_override="file:///tmp/override/to/here"
170 local local_path_override="/tmp/override/to/here"
171 local local_path_compare_value="/tmp/override/to/here/"
172 local stream_url_override="net://127.0.0.1:8172:9817"
173 local stream_url_compare="tcp4://127.0.0.1:8172/ [data: 9817]"
174
175 diag "Test url override for normal session"
176
177 start_lttng_relayd "-C tcp://127.0.0.1:8172 -D tcp://127.0.0.1:9817"
178
179 local mi_output_file=$(mktemp --tmpdir "tmp.${FUNCNAME[0]}_output_file.XXXXXX")
180 if [ $? -ne 0 ]; then
181 break;
182 fi
183
184 # Url of style file://
185 lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng --override-url=${local_url_override}"
186 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME" > $mi_output_file
187 mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
188
189 test $mi_result = "${local_path_compare_value}"
190 ok $? "Path url file:// override [{$mi_result}, ${local_path_compare_value}]"
191 destroy_lttng_session_ok "$SESSION_NAME"
192
193 # Url of style /
194 lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng --override-url=${local_path_override}"
195 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME" > $mi_output_file
196 mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
197
198 test $mi_result = "${local_path_compare_value}"
199 ok $? "Path url / override [{$mi_result}, ${local_path_compare_value}]"
200 destroy_lttng_session_ok "$SESSION_NAME"
201
202 # Url of style net://ip:port:port
203 lttng_load_ok "-i $CURDIR/$SESSION_NAME.lttng --override-url=${stream_url_override}"
204 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$SESSION_NAME" > $mi_output_file
205 mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
206
207 test "$mi_result" = "${stream_url_compare}"
208 ok $? "Path url net://host:port:port override [${mi_result}, ${stream_url_compare}]"
209
210 destroy_lttng_session_ok "$SESSION_NAME"
211 stop_lttng_relayd
212 rm -rf ${mi_output_file}
213 }
214
215 function test_override_url_snapshot()
216 {
217 local url_override="file:///tmp/override/to/here"
218 local path_override="/tmp/override/to/here"
219 local path_compare_value="/tmp/override/to/here/"
220 local stream_url_override="net://127.0.0.1:8172:9817"
221 local stream_url_compare_ctrl="tcp4://127.0.0.1:8172/"
222 local stream_url_compare_data="tcp4://127.0.0.1:9817/"
223 local local_session_name="${SESSION_NAME}-snapshot"
224
225 diag "Test url override for snapshot session"
226
227 start_lttng_relayd "-C tcp://127.0.0.1:8172 -D tcp://127.0.0.1:9817"
228
229 local mi_output_file=$(mktemp --tmpdir "tmp.${FUNCNAME[0]}_output_file.XXXXXX")
230 if [ $? -ne 0 ]; then
231 break;
232 fi
233
234 # Url of style file://
235 lttng_load_ok "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${url_override}"
236 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML snapshot list-output -s "$local_session_name" > $mi_output_file
237 mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:ctrl_url")
238
239 test $mi_result = "${path_compare_value}"
240 ok $? "Path url file:// override [{$mi_result}, ${path_compare_value}]"
241 destroy_lttng_session_ok "$local_session_name"
242
243 # Url of style /
244 lttng_load_ok "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${path_override}"
245 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML snapshot list-output -s "$local_session_name" > $mi_output_file
246 mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:ctrl_url")
247
248 test $mi_result = "${path_compare_value}"
249 ok $? "Path url / override [{$mi_result}, ${path_compare_value}]"
250 destroy_lttng_session_ok "$local_session_name"
251
252 # Url of style net://ip:port:port
253 lttng_load_ok "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${stream_url_override}"
254 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML snapshot list-output -s "$local_session_name" > $mi_output_file
255 mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:ctrl_url")
256
257 test "$mi_result" = "${stream_url_compare_ctrl}"
258 ok $? "Path url ctrl net://host:port:port override [${mi_result}, ${stream_url_compare_ctrl}]"
259
260 mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:snapshot_action/lttng:output/lttng:session/lttng:snapshots/lttng:snapshot/lttng:data_url")
261
262 test "$mi_result" = "${stream_url_compare_data}"
263 ok $? "Path url data net://host:port:port override [${mi_result}, ${stream_url_compare_data}]"
264
265 destroy_lttng_session_ok "$local_session_name"
266 stop_lttng_relayd
267 rm -rf ${mi_output_file}
268 }
269
270 function test_override_url_live()
271 {
272 local url_override="file:///tmp/override/to/here"
273 local path_override="/tmp/override/to/here"
274 local path_compare_value="/tmp/override/to/here/"
275 local stream_url_override="net://127.0.0.1:8172:9817"
276 local stream_url_compare="tcp4://127.0.0.1:8172/ [data: 9817]"
277 local local_session_name="${SESSION_NAME}-live"
278
279 diag "Test url override for live session"
280
281 start_lttng_relayd "-C tcp://127.0.0.1:8172 -D tcp://127.0.0.1:9817"
282
283 local mi_output_file=$(mktemp --tmpdir "tmp.${FUNCNAME[0]}_output_file.XXXXXX")
284 if [ $? -ne 0 ]; then
285 break;
286 fi
287
288 # Url of style file://
289 # Expect this to fail since live session should never accept local
290 # output.
291 lttng_load_fail "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${url_override}"
292 destroy_lttng_session_fail "$local_session_name"
293
294 # Url of style /
295 # Expect this to fail since live session should never accept local
296 # output.
297 lttng_load_fail "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${path_override}"
298 destroy_lttng_session_fail "$local_session_name"
299
300 # Url of style net://ip:port:port
301 lttng_load_ok "-i $CONFIG_DIR/$local_session_name.lttng --override-url=${stream_url_override}"
302 $TESTDIR/../src/bin/lttng/$LTTNG_BIN --mi XML list "$local_session_name" > $mi_output_file
303 mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
304
305 test "$mi_result" = "${stream_url_compare}"
306 ok $? "Path url net://host:port:port override [${mi_result}, ${stream_url_compare}]"
307
308 destroy_lttng_session_ok "$local_session_name"
309 stop_lttng_relayd
310 rm -rf ${mi_output_file}
311 }
312
313 function test_override_session_name()
314 {
315 diag "Test session name override"
316 local override_name="PinkyAndTheBrain"
317 local output_path="/tmp/lttng/load-42-1"
318
319 local mi_output_file=$(mktemp --tmpdir "tmp.${FUNCNAME[0]}_output_file.XXXXXX")
320 if [ $? -ne 0 ]; then
321 break;
322 fi
323
324 lttng_load_ok "-i ${CURDIR}/${SESSION_NAME}.lttng --override-name=${override_name} ${SESSION_NAME}"
325 ${TESTDIR}/../src/bin/lttng/${LTTNG_BIN} --mi XML list "${SESSION_NAME}" &> /dev/null
326 if [ $? -eq 0 ]; then
327 fail "Expected a failure on listing for old session name"
328 fi
329
330 ${TESTDIR}/../src/bin/lttng/${LTTNG_BIN} --mi XML list "${override_name}" > $mi_output_file
331 mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:name")
332
333 test "${mi_result}" = "${override_name}"
334 ok $? "Override name successful [${SESSION_NAME} to ${override_name}]"
335
336 # Make sure that the name override did not change something else
337 mi_result=$("$XML_EXTRACT" $mi_output_file "//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:path")
338 test "${mi_result}" = "${output_path}"
339 ok $? "Output path is not affected by name override"
340
341 destroy_lttng_session_ok "${override_name}"
342
343 diag "Test session name override with all (Do not permit)"
344 lttng_load_fail "-i ${CURDIR}/${SESSION_NAME}.lttng --override-name=${override_name}"
345
346 rm -rf ${mi_output_file}
347 }
348
349 start_lttng_sessiond
350
351 TESTS=(
352 test_basic_load
353 test_complex_load
354 test_all_load
355 test_overwrite
356 test_trackers
357 test_override_session_name
358 test_override_url_normal
359 test_override_url_snapshot
360 test_override_url_live
361 )
362
363 for fct_test in ${TESTS[@]};
364 do
365 TRACE_PATH=$(mktemp --tmpdir -d tmp.test_load_trace_path.XXXXXX)
366
367 ${fct_test}
368 if [ $? -ne 0 ]; then
369 break;
370 fi
371 # Only delete if successful
372 rm -rf $TRACE_PATH
373 done
374
375 stop_lttng_sessiond
This page took 0.072327 seconds and 4 git commands to generate.